@qredence/fleet 0.5.1 → 0.5.5

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 (78) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bin/fleet-prime.mjs +6 -0
  3. package/dist/web/client/assets/action-swap-roll-DX5o_33Q.js +1 -0
  4. package/dist/web/client/assets/artifacts-panel-C3yewUBP.js +1 -0
  5. package/dist/web/client/assets/{chat-CsepBQwy.js → chat-W-yOMyG_.js} +1 -1
  6. package/dist/web/client/assets/chat-command-palette-D0xDK1j4.js +1 -0
  7. package/dist/web/client/assets/command-CQzrtjyj.js +2 -0
  8. package/dist/web/client/assets/{fleet-pi-tool-renderer-BD_ZAjlG.js → fleet-pi-tool-renderer-B0Y7ou0U.js} +16 -16
  9. package/dist/web/client/assets/generative-text-renderer-SS9c1kNX.js +6 -0
  10. package/dist/web/client/assets/globals-D_Hy9bT1.css +2 -0
  11. package/dist/web/client/assets/{index-DweoFRMs.js → index-C9FloFgj.js} +2 -2
  12. package/dist/web/client/assets/{ipython-tool-BfeIa0nK.js → ipython-tool-BrMePqD-.js} +1 -1
  13. package/dist/web/client/assets/{openui-renderer-DlUo6ehT.js → openui-renderer-CCfQqUfE.js} +5 -5
  14. package/dist/web/client/assets/{prime-agent-artifacts-CHGb5V_j.js → prime-agent-artifacts-C-g1VPiW.js} +1 -1
  15. package/dist/web/client/assets/range-65lubOFp.js +2 -0
  16. package/dist/web/client/assets/repl-panel-CCh4ly7J.js +1 -0
  17. package/dist/web/client/assets/routes-DSTyx_J0.js +16 -0
  18. package/dist/web/client/assets/session-insights-panel-CQdT90Op.js +1 -0
  19. package/dist/web/client/assets/subagent-chat-panel-D-qw4uWb.js +1 -0
  20. package/dist/web/client/assets/subagent-transcript-C7oRwEEP.js +1 -0
  21. package/dist/web/client/assets/subagents-panel-aSMWZP9p.js +1 -0
  22. package/dist/web/client/assets/{tool-result-CBzwwUE9.js → tool-result-C2NvnN32.js} +3 -3
  23. package/dist/web/server/{_tanstack-start-manifest_v-bDUlyKY0-KFW35JRO.js → _tanstack-start-manifest_v-DZc7dwm7-6ZQLGXB7.js} +13 -13
  24. package/dist/web/server/{artifacts-panel-D9w1DHAN-FGRDCYU2.js → artifacts-panel-Bt7YUzm4-NCBMXJ25.js} +15 -15
  25. package/dist/web/server/{chat-command-palette-BaenPkCN-BHSOPGU4.js → chat-command-palette-Co1L3rUY-RQLNME4T.js} +33 -12
  26. package/dist/web/server/{chunk-KPNGZR2R.js → chunk-2V6B62OF.js} +204 -204
  27. package/dist/web/server/{chunk-44IVTHDV.js → chunk-3HUI75QM.js} +60 -60
  28. package/dist/web/server/{chunk-5AVQZ4AZ.js → chunk-4UBOIY2S.js} +2 -1
  29. package/dist/web/server/{chunk-Y6LJ4WBI.js → chunk-56HSKUBD.js} +699 -691
  30. package/dist/web/server/{chunk-RPROZ2JC.js → chunk-5RQ6QAZX.js} +133 -133
  31. package/dist/web/server/{chunk-PWK2HJIV.js → chunk-6D524OCJ.js} +175 -175
  32. package/dist/web/server/{chunk-FBOO3G67.js → chunk-AECEK3K7.js} +6 -6
  33. package/dist/web/server/{chunk-VHCAD46L.js → chunk-AWFOBHH4.js} +4 -4
  34. package/dist/web/server/{chunk-FVWDJNXR.js → chunk-BEMDNODD.js} +1 -1
  35. package/dist/web/server/{chunk-X2TUFLTP.js → chunk-BLVCDQ7E.js} +438 -438
  36. package/dist/web/server/{chunk-EIVNRYP3.js → chunk-FZRBAPUM.js} +2 -2
  37. package/dist/web/server/chunk-KOIPYBJF.js +3773 -0
  38. package/dist/web/server/{chunk-XYYNYFFD.js → chunk-LSIHVSUT.js} +2 -2
  39. package/dist/web/server/{chunk-H64JLONZ.js → chunk-PDRD2X5G.js} +2 -2
  40. package/dist/web/server/{chunk-FE4KN6T2.js → chunk-RX62LUDV.js} +4 -4
  41. package/dist/web/server/chunk-SR65ARVS.js +192 -0
  42. package/dist/web/server/{chunk-WK7CQS2N.js → chunk-SZ65K4CO.js} +48 -48
  43. package/dist/web/server/{chunk-DO3TVNGA.js → chunk-TO3YPLNZ.js} +6 -6
  44. package/dist/web/server/{chunk-3IKSPTYI.js → chunk-UKINNXJY.js} +2 -2
  45. package/dist/web/server/{chunk-M2FGGPNA.js → chunk-VGDP4YDU.js} +70 -45
  46. package/dist/web/server/{chunk-PCJ5EKFE.js → chunk-VRLTWOVJ.js} +11 -6
  47. package/dist/web/server/{chunk-HBZ6YKRB.js → chunk-WN77JNYY.js} +2 -2
  48. package/dist/web/server/{chunk-2U7PWSJX.js → chunk-WZNZQNI4.js} +231 -3633
  49. package/dist/web/server/{chunk-B2F6MLVZ.js → chunk-XFVL5ITL.js} +2246 -2228
  50. package/dist/web/server/{chunk-3GSFXWL5.js → chunk-XLCTCC4W.js} +3 -3
  51. package/dist/web/server/{chunk-AZZHUVJR.js → chunk-Y4MHIA7B.js} +18 -26
  52. package/dist/web/server/{fleet-pi-tool-renderer-lJvZWmBJ-4M5YI6VS.js → fleet-pi-tool-renderer-CE45vM6T-2UQN6RJM.js} +11 -9
  53. package/dist/web/server/{fork-picker-dialog-BZzfxdQd-Y725VJ7G.js → fork-picker-dialog-DCzuGelH-TN2Q5OXI.js} +5 -5
  54. package/dist/web/server/{openui-renderer-Cg4RSE9k-7BTJIYZJ.js → openui-renderer-c36_GYes-HX46N4M5.js} +11 -11
  55. package/dist/web/server/{repl-panel-BEQrC2ef-V3YEZ7EO.js → repl-panel-D9E8nkQy-L45ZNG2V.js} +4 -3
  56. package/dist/web/server/{router-CEahIUpn-SRG7XKIH.js → router-_ZpegqiQ-QIE44PIB.js} +1737 -1370
  57. package/dist/web/server/{routes-BznemByz-F4DJAYIM.js → routes-Ct81-8Tq-LHRMOS7R.js} +2882 -2330
  58. package/dist/web/server/server.js +3 -3
  59. package/dist/web/server/{session-insights-panel-JfeTHE0d-3HZB3ZWI.js → session-insights-panel-BHZyKDTo-LRMAMA3O.js} +4 -2
  60. package/dist/web/server/{settings-dialog-DgeBMORv-7SRSENPM.js → settings-dialog-B4uUS6f--AZ4I4ZOT.js} +142 -142
  61. package/dist/web/server/{start-CLAD7RcD-56S4BWMM.js → start-BYVnok_H-IA6TWGA3.js} +1 -1
  62. package/dist/web/server/subagent-chat-panel-C97S3WID-DLOAD5TG.js +63 -0
  63. package/dist/web/server/subagents-panel-iHpvMIZy-LI6XK66M.js +181 -0
  64. package/dist/web/server/{workspace-panel-y54P79_B-VPIYUXF6.js → workspace-panel-CHPoiXEo-YB4WS3MK.js} +2 -2
  65. package/package.json +5 -5
  66. package/dist/web/client/assets/artifacts-panel-CX62LQ13.js +0 -1
  67. package/dist/web/client/assets/chat-command-palette-C4sSf8Kg.js +0 -1
  68. package/dist/web/client/assets/collapsible-DmyYcezk.js +0 -1
  69. package/dist/web/client/assets/command-CB6emP8m.js +0 -2
  70. package/dist/web/client/assets/conversation-turns-ByFoWPXe.js +0 -6
  71. package/dist/web/client/assets/globals-CqqQdk2S.css +0 -2
  72. package/dist/web/client/assets/range-vSJ7Ux_5.js +0 -2
  73. package/dist/web/client/assets/repl-panel-DiGS6uCw.js +0 -1
  74. package/dist/web/client/assets/routes-CxlNCi_v.js +0 -16
  75. package/dist/web/client/assets/session-insights-panel-DwmwiikS.js +0 -1
  76. package/dist/web/client/assets/subagents-panel-DGnsK6Nx.js +0 -1
  77. package/dist/web/server/chunk-ZEVZFLIY.js +0 -334
  78. package/dist/web/server/subagents-panel-CzZe3co7-2VZ5JTWF.js +0 -332
@@ -1,16 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fleet-pi-tool-renderer-BD_ZAjlG.js","assets/rolldown-runtime-hePW80VL.js","assets/bundle-mjs-DKHVkVWu.js","assets/jsx-runtime-NZYk81nU.js","assets/ease-vFBiNFNK.js","assets/layout-gyLzPvVv.js","assets/x-BgciQ7_C.js","assets/react-dom-Bwxum3ti.js","assets/createLucideIcon-DwxZHm0M.js","assets/utils-Eg7xtNmV.js","assets/tool-result-CBzwwUE9.js","assets/useControlled-CoY1jSuL.js","assets/chevron-down-BEVGmnSb.js","assets/loader-circle-6JG5RwxH.js","assets/collapsible-DmyYcezk.js","assets/useBaseUiId-B9f7fokB.js","assets/rotate-ccw-WNFNkKQD.js","assets/square-terminal-BYTN_I86.js","assets/preload-helper-Czpn1I53.js","assets/range-vSJ7Ux_5.js","assets/safe-external-url-Bl_78dpZ.js","assets/sparkles-C5H3Jtgf.js","assets/chevron-right-DrJxToLs.js","assets/file-text-BhQ0ZnoU.js","assets/ipython-tool-BfeIa0nK.js","assets/cn-C8c0S2mI.js","assets/eye-B0DFz5hL.js","assets/search-eWVnAJsb.js","assets/dist-H-qlGkmT.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/workspace-path-nav-C0AQNZyy.js","assets/chat-command-palette-C4sSf8Kg.js","assets/command-CB6emP8m.js","assets/dialog-DZ44tBtH.js","assets/button-0At5xSyU.js","assets/bot-Bs7QWJ2q.js","assets/folder-BC5p7qK7.js","assets/package-CdcJFPf2.js","assets/input-group-H0TG-mkU.js","assets/input-CqC82Agz.js","assets/skeleton-CkR2VmWc.js","assets/dist-MNgIFxqY.js","assets/sun-BWiZFty0.js","assets/settings-dialog-CkfpTKfM.js","assets/toast-C4s7FYYa.js","assets/provider-catalog-BZhZuKSz.js","assets/provider-label-jKm8v18u.js","assets/plug-Dt6VN0zF.js","assets/hard-drive-CHqgr7VQ.js","assets/notify-Duj26eeZ.js","assets/ui-preferences-DUEFuJFj.js","assets/switch-BFEBpUEU.js","assets/fork-picker-dialog-C2cVJUbf.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./bundle-mjs-DKHVkVWu.js";import{t as n}from"./react-dom-Bwxum3ti.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{A as i,D as a,E as o,F as s,I as c,M as l,N as u,O as d,d as f,g as p,h as m,k as h,l as g,m as _,o as v,p as y,s as b,v as x,w as S,x as C}from"./analytics-stub-Jh3lkb8P.js";import{A as w,B as T,D as E,E as D,Q as O,S as k,T as A,V as j,b as M,c as N,et as P,f as F,k as I,m as L,n as R,nt as z,p as B,r as V,t as H,v as U,x as ee,z as W}from"./button-0At5xSyU.js";import{$ as te,C as ne,G as re,H as ie,I as ae,J as oe,K as se,L as ce,M as le,N as ue,P as de,Q as fe,U as pe,V as me,W as he,X as ge,Y as _e,Z as ve,at as ye,ct as be,et as xe,h as Se,it as Ce,j as we,m as Te,nt as Ee,ot as De,q as Oe,rt as ke,tt as Ae,y as je,z as Me}from"./layout-gyLzPvVv.js";import{_ as Ne,a as Pe,c as Fe,d as G,f as Ie,g as Le,h as Re,l as ze,m as Be,n as Ve,o as He,p as K,r as Ue,s as We,t as Ge,u as Ke}from"./ease-vFBiNFNK.js";import{M as qe,S as Je,T as Ye,a as Xe,c as Ze,ct as Qe,f as $e,g as et,it as tt,k as nt,l as rt,n as it,p as at,q as ot,rt as st,s as ct,st as lt,t as ut,tt as dt,w as ft,x as pt,y as mt}from"./x-BgciQ7_C.js";import{r as ht}from"./toast-C4s7FYYa.js";import{$ as gt,A as _t,B as vt,C as yt,D as bt,E as xt,F as St,G as Ct,H as wt,I as Tt,J as Et,K as Dt,L as Ot,M as kt,N as At,O as jt,P as Mt,Q as Nt,R as Pt,S as Ft,U as It,V as Lt,W as Rt,X as zt,Z as Bt,_ as Vt,a as Ht,b as Ut,et as Wt,g as Gt,h as Kt,i as qt,j as Jt,n as Yt,o as Xt,q as Zt,r as Qt,t as $t,w as en,x as tn,y as nn}from"./dialog-DZ44tBtH.js";import{A as rn,_ as an,b as on,d as sn,g as cn,h as ln,l as un,o as dn,p as fn,s as pn,v as mn,y as hn}from"./provider-catalog-BZhZuKSz.js";import{t as gn}from"./useBaseUiId-B9f7fokB.js";import{A as _n,C as vn,D as yn,M as bn,O as xn,T as Sn,a as Cn,c as wn,d as Tn,f as En,h as Dn,i as On,k as kn,l as An,m as jn,n as Mn,o as Nn,p as Pn,s as Fn,t as In,u as Ln,w as Rn,x as zn}from"./provider-label-jKm8v18u.js";import{t as q}from"./utils-Eg7xtNmV.js";import{t as Bn}from"./createLucideIcon-DwxZHm0M.js";import{a as Vn,d as Hn,f as Un,i as Wn,l as Gn,o as Kn,p as qn,r as Jn,s as Yn,t as Xn,u as Zn}from"./command-CB6emP8m.js";import{S as Qn,b as $n,d as er,f as tr,g as nr,h as rr,i as ir,l as ar,m as or,o as sr,p as cr,r as lr,s as ur,u as dr,v as fr,x as pr,y as mr}from"./range-vSJ7Ux_5.js";import{r as hr}from"./resource-helpers-ULlyU8qK.js";import{t as gr}from"./bot-Bs7QWJ2q.js";import{n as _r,t as vr}from"./useControlled-CoY1jSuL.js";import{t as yr}from"./chevron-down-BEVGmnSb.js";import{t as br}from"./chevron-right-DrJxToLs.js";import{_ as xr,c as Sr,d as Cr,f as wr,g as Tr,h as Er,l as Dr,m as Or,n as kr,o as Ar,p as jr,r as Mr,s as Nr,t as Pr,u as Fr}from"./conversation-turns-ByFoWPXe.js";import{n as Ir,t as Lr}from"./safe-external-url-Bl_78dpZ.js";import{n as Rr,t as zr}from"./file-text-BhQ0ZnoU.js";import{t as Br}from"./loader-circle-6JG5RwxH.js";import{a as Vr,c as Hr,i as Ur,n as Wr,o as Gr,r as Kr,s as qr,t as Jr}from"./collapsible-DmyYcezk.js";import{t as Yr}from"./sparkles-C5H3Jtgf.js";import{a as Xr,c as Zr,d as Qr,f as $r,h as ei,i as ti,l as ni,m as ri,n as ii,r as ai,s as oi,t as si,u as ci,v as li,y as ui}from"./horizontal-resize-C1TpRLNC.js";import{t as di}from"./folder-BC5p7qK7.js";import{t as fi}from"./package-CdcJFPf2.js";import{a as pi,c as mi,l as hi,o as gi}from"./input-group-H0TG-mkU.js";import{n as _i,t as vi}from"./notify-Duj26eeZ.js";import{t as yi}from"./rotate-ccw-WNFNkKQD.js";import{t as bi}from"./search-eWVnAJsb.js";import{t as xi}from"./square-terminal-BYTN_I86.js";import{t as Si}from"./preload-helper-Czpn1I53.js";import{A as Ci,C as wi,D as Ti,E as Ei,F as Di,I as Oi,L as ki,M as Ai,O as ji,P as J,R as Mi,S as Ni,T as Pi,V as Y,_ as Fi,a as Ii,c as Li,d as Ri,f as zi,g as Bi,h as Vi,i as Hi,j as Ui,l as Wi,m as Gi,n as Ki,o as qi,p as Ji,q as Yi,r as Xi,s as Zi,t as Qi,u as $i,v as ea,w as ta,y as na,z as X}from"./chat-CsepBQwy.js";import{t as ra}from"./input-CqC82Agz.js";import{t as ia}from"./artifacts-utils-N_kUFbz2.js";import"./cn-C8c0S2mI.js";import{t as aa}from"./prime-agent-artifacts-CHGb5V_j.js";import{n as oa}from"./workspace-path-nav-C0AQNZyy.js";var sa=class extends m{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),la(this.#t,this.options)?this.#m():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ua(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ua(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#b(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof a(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#x(),this.#t.setOptions(this.options),t._defaulted&&!h(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&da(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||d(this.options.staleTime,this.#t)!==d(t.staleTime,this.#t))&&this.#h();let i=this.#g();r&&(this.#t!==n||a(this.options.enabled,this.#t)!==a(t.enabled,this.#t)||i!==this.#f)&&this.#_(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return pa(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(S)),t}#h(){this.#y();let e=d(this.options.staleTime,this.#t);if(p.isServer()||this.#r.isStale||!C(e))return;let t=l(this.#r.dataUpdatedAt,e)+1;this.#u=u.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#g(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#_(e){this.#b(),this.#f=e,!(p.isServer()||a(this.options.enabled,this.#t)===!1||!C(this.#f)||this.#f===0)&&(this.#d=u.setInterval(()=>{(this.options.refetchIntervalInBackground||_.isFocused())&&this.#m()},this.#f))}#v(){this.#h(),this.#_(this.#g())}#y(){this.#u!==void 0&&(u.clearTimeout(this.#u),this.#u=void 0)}#b(){this.#d!==void 0&&(u.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,s=this.#i,c=this.#a,l=e===n?this.#n:e.state,{state:u}=e,d={...u},p=!1,m;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&la(e,t),o=i&&da(e,n,t,r);(a||o)&&(d={...d,...f(u.data,e.options)}),t._optimisticResults===`isRestoring`&&(d.fetchStatus=`idle`)}let{error:h,errorUpdatedAt:g,status:_}=d;m=d.data;let v=!1;if(t.placeholderData!==void 0&&m===void 0&&_===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=i.data,v=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(_=`success`,m=o(i?.data,e,t),p=!0)}if(t.select&&m!==void 0&&!v){if(i&&m===s?.data&&t.select===this.#s)m=this.#c;else try{this.#s=t.select,m=t.select(m),m=o(i?.data,m,t),this.#c=m,this.#o=null}catch(e){this.#o=e}}else m===void 0&&(this.#o=null);this.#o&&(h=this.#o,m=this.#c,g=Date.now(),_=`error`,p=!1);let y=d.fetchStatus===`fetching`,b=_===`pending`,x=_===`error`,S=b&&y,C=m!==void 0;return{status:_,fetchStatus:d.fetchStatus,isPending:b,isSuccess:_===`success`,isError:x,isInitialLoading:S,isLoading:S,data:m,dataUpdatedAt:d.dataUpdatedAt,error:h,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!b,isLoadingError:x&&!C,isPaused:d.fetchStatus===`paused`,isPlaceholderData:p,isRefetchError:x&&C,isStale:fa(e,t),refetch:this.refetch,isEnabled:a(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),!h(t,e)&&(this.#r=t,this.#S({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#x(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#S(e){y.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ca(e,t){return a(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||a(t.retryOnMount,e)!==!1)}function la(e,t){return ca(e,t)||e.state.data!==void 0&&ua(e,t,t.refetchOnMount)}function ua(e,t,n){if(a(t.enabled,e)!==!1&&d(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&fa(e,t)}return!1}function da(e,t,n,r){return(e!==t||a(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&fa(e,n)}function fa(e,t){return a(t.enabled,e)!==!1&&e.isStaleByTime(d(t.staleTime,e))}function pa(e,t){return!h(e.getCurrentResult(),t)}var ma=class extends m{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),h(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&x(t.mutationKey)!==x(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??g();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){y.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Z=e(t(),1),ha=Z.createContext(!1),ga=()=>Z.useContext(ha);ha.Provider;var Q=r();function _a(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var va=Z.createContext(_a()),ya=()=>Z.useContext(va),ba=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?i(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},xa=e=>{Z.useEffect(()=>{e.clearReset()},[e])},Sa=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||i(n,[e.error,r])),Ca=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},wa=(e,t)=>e?.suspense&&t.isPending,Ta=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ea(e,t,n){let r=ga(),i=ya(),a=s(n),o=a.defaultQueryOptions(e),c=a.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,Ca(o),ba(o,i,c),xa(i);let[u]=Z.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&l;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=f?u.subscribe(y.batchCalls(e)):S;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Z.useEffect(()=>{u.setOptions(o)},[o,u]),wa(o,d))throw Ta(o,u,i);if(Sa({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function Da(e,t){return Ea(e,sa,t)}function Oa(e,t){let n=s(t),[r]=Z.useState(()=>new ma(n,e));Z.useEffect(()=>{r.setOptions(e)},[r,e]);let a=Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(y.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=Z.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(S)},[r]);if(a.error&&i(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}var ka=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function Aa(e,t){return xe(e)?e[ka(0,e.length,t)]:e}var ja=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return Ma(this.animations,`duration`)}get iterationDuration(){return Ma(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function Ma(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var Na=class extends ja{then(e,t){return this.finished.finally(e).then(()=>{})}};function Pa(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=oe(i,a,o);return t?s(r):s}function Fa(e,t,n={}){let r=e.get(),i=null,a=r,o,s=typeof r==`string`?r.replace(/[\d.-]/g,``):void 0,c=()=>{i&&=(i.stop(),null),e.animation=void 0},l=()=>{let t=La(e.get()),r=La(a);if(t===r){c();return}let s=i?i.getGeneratorVelocity():e.getVelocity();c(),i=new re({keyframes:[t,r],velocity:s,type:`spring`,restDelta:.001,restSpeed:.01,...n,onUpdate:o})},u=()=>{l(),e.animation=i??void 0,e.events.animationStart?.notify(),i?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((e,t)=>{a=e,o=e=>t(Ia(e,s)),te.postRender(u)},c),Me(t)){let r=n.skipInitialAnimation===!0,i=t.on(`change`,t=>{r?(r=!1,e.jump(Ia(t,s),!1)):e.set(Ia(t,s))}),a=e.on(`destroy`,i);return()=>{i(),a()}}return c}function Ia(e,t){return t?e+t:e}function La(e){return typeof e==`number`?e:parseFloat(e)}function Ra(e,t){return e in t}var za=class extends ne{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(Ra(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return le()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},Ba=e=>!e.isLayoutDirty&&e.willUpdate(!1);function Va(){let e=new Set,t=new WeakMap,n=()=>e.forEach(Ba);return{add:r=>{e.add(r),t.set(r,r.addEventListener(`willUpdate`,n))},remove:r=>{e.delete(r);let i=t.get(r);i&&(i(),t.delete(r)),n()},dirty:n}}var Ha=(0,Z.createContext)(null);function Ua(){let e=(0,Z.useRef)(!1);return Le(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Wa(){let e=Ua(),[t,n]=(0,Z.useState)(0),r=(0,Z.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,Z.useCallback)(()=>te.postRender(r),[r]),t]}var Ga=e=>e===!0,Ka=e=>Ga(e===!0)||e===`id`,qa=({children:e,id:t,inherit:n=!0})=>{let r=(0,Z.useContext)(be),i=(0,Z.useContext)(Ha),[a,o]=Wa(),s=(0,Z.useRef)(null),c=r.id||i;s.current===null&&(Ka(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:Ga(n)&&r.group||Va()});let l=(0,Z.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Q.jsx)(be.Provider,{value:l,children:e})};function Ja({children:e,...t}){let n=(0,Z.useContext)(Re);t={...n,...t},t.transition=me(t.transition,n.transition),t.isStatic=Ne(()=>t.isStatic);let r=(0,Z.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Q.jsx)(Re.Provider,{value:r,children:e})}function Ya(e){let t=Ne(()=>pe(e)),{isStatic:n}=(0,Z.useContext)(Re);if(n){let[,n]=(0,Z.useState)(e);(0,Z.useEffect)(()=>t.on(`change`,n),[])}return t}function Xa(e,t){let n=Ya(t()),r=()=>n.set(t());return r(),Le(()=>{let t=()=>te.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),fe(r)}}),n}function Za(e){ie.current=[],e();let t=Xa(ie.current,e);return ie.current=void 0,t}function Qa(e,t,n,r){if(typeof e==`function`)return Za(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return eo(e,t,n,r);let i=typeof t==`function`?t:Pa(t,n,r),a=Array.isArray(e)?$a(e,i):$a([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function $a(e,t){let n=Ne(()=>[]);return Xa(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function eo(e,t,n,r){let i=Ne(()=>Object.keys(n)),a=Ne(()=>({}));for(let o of i)a[o]=Qa(e,t,n[o],r);return a}function to(e,t={}){let{isStatic:n}=(0,Z.useContext)(Re),r=()=>Me(e)?e.get():e;if(n)return Qa(r);let i=Ya(r());return(0,Z.useInsertionEffect)(()=>Fa(i,e,t),[i,JSON.stringify(t)]),i}function no(e,t={}){return to(e,{type:`spring`,...t})}function ro(e){return typeof e==`object`&&!Array.isArray(e)}function io(e,t,n,r){return e==null?[]:typeof e==`string`&&ro(t)?ae(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>e!=null):[e]}function ao(e,t,n){return e*(t+1)+n*t}function oo(e,t,n,r){return typeof t==`number`?t:t.startsWith(`-`)||t.startsWith(`+`)?Math.max(0,e+parseFloat(t)):t===`<`?n:t.startsWith(`<`)?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function so(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(De(e,i),r--)}}function co(e,t,n,r,i,a){so(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:ve(i,a,r[o]),easing:Aa(n,o)})}function lo(e,t,n=0){let r=t+1+t*n;for(let t=0;t<e.length;t++)e[t]=e[t]/r}function uo(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var fo=`easeInOut`,po=20;function mo(e,{defaultTransition:t={},...n}={},r,i){let a=t.duration||.3,o=new Map,s=new Map,c={},l=new Map,u=0,d=0,f=0;for(let n=0;n<e.length;n++){let o=e[n];if(typeof o==`string`){l.set(o,d);continue}if(!Array.isArray(o)){l.set(o.name,oo(d,o.at,u,l));continue}let[p,m,h={}]=o;h.at!==void 0&&(d=oo(d,h.at,u,l));let g=0,_=(e,n,r,o=0,s=0)=>{let c=_o(e),{delay:l=0,times:u=se(c),type:p=t.type||`keyframes`,repeat:m,repeatType:h,repeatDelay:_=0,...v}=n,{ease:y=t.ease||`easeOut`,duration:b}=n,x=typeof l==`function`?l(o,s):l,S=c.length,C=he(p)?p:i?.[p||`keyframes`];if(S<=2&&C){let e=100;if(S===2&&bo(c)){let t=c[1]-c[0];e=Math.abs(t)}let n={...t,...v};b!==void 0&&(n.duration=Ee(b));let r=ge(n,e,C);y=r.ease,b=r.duration}b??=a;let w=d+x;u.length===1&&u[0]===0&&(u[1]=1);let T=u.length-c.length;if(T>0&&Oe(u,T),c.length===1&&c.unshift(null),m&&ye(m<po,`Sequence segments can't repeat ${m} times — ignoring repeat option. Use a value below ${po} or apply repeat at the sequence level instead.`),m&&m<po){let e=b>0?_/b:0;b=ao(b,m,_);let t=[...c],n=[...u];y=Array.isArray(y)?[...y]:[y];let r=[...y],i=h===`reverse`||h===`mirror`,a=t,o=r;i&&(a=[...t].reverse(),h===`reverse`&&(o=[...r].reverse().map(e=>typeof e==`function`?Ae(e):e)));for(let s=0;s<m;s++){let l=i&&s%2==0,d=l?a:t,f=l?o:r,p=(s+1)*(1+e);e>0&&(c.push(c[c.length-1]),u.push(p),y.push(`linear`)),c.push(...d);for(let e=0;e<d.length;e++)u.push(n[e]+p),y.push(e===0?`linear`:Aa(f,e-1))}lo(u,m,e)}let E=w+b;co(r,c,y,u,w,E),g=Math.max(x+b,g),f=Math.max(E,f)};if(Me(p)){let e=ho(p,s);_(m,h,go(`default`,e))}else{let e=io(p,m,r,c),t=e.length;for(let n=0;n<t;n++){m=m,h=h;let r=e[n],i=ho(r,s);for(let e in m)_(m[e],vo(h,e),go(e,i),n,t)}}u=d,d+=g}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(uo);let s=[],c=[],l=[];for(let e=0;e<a.length;e++){let{at:t,value:n,easing:r}=a[e];s.push(n),c.push(ke(0,f,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift(fo)),c[c.length-1]!==1&&(c.push(1),s.push(null)),o.has(r)||o.set(r,{keyframes:{},transition:{}});let u=o.get(r);u.keyframes[i]=s;let{type:d,...p}=t;u.transition[i]={...p,duration:f,ease:l,times:c,...n}}}),o}function ho(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function go(e,t){return t[e]||(t[e]=[]),t[e]}function _o(e){return Array.isArray(e)?e:[e]}function vo(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var yo=e=>typeof e==`number`,bo=e=>e.every(yo);function xo(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=de(e)&&!ue(e)?new Se(t):new je(t);n.mount(e),we.set(e,n)}function So(e){let t=new za({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),we.set(e,t)}function Co(e,t){return Me(e)||typeof e==`number`||typeof e==`string`&&!ro(t)}function wo(e,t,n,r){let i=[];if(Co(e,t))i.push(Te(e,ro(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;let a=io(e,t,r),o=a.length;Ce(!!o,`No valid elements provided.`,`no-valid-elements`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?xo:So;we.has(r)||s(r);let c=we.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...ce(c,{...t,transition:l},{}))}}return i}function To(e,t,n){let r=[];return mo(e.map(e=>{if(Array.isArray(e)&&typeof e[0]==`function`){let t=e[0],n=pe(0);return n.on(`change`,t),e.length===1?[n,[0,1]]:e.length===2?[n,[0,1],e[1]]:[n,e[1],e[2]]}return e}),t,n,{spring:_e}).forEach(({keyframes:e,transition:t},n)=>{r.push(...wo(n,e,t))}),r}function Eo(e){return Array.isArray(e)&&e.some(Array.isArray)}function Do(e={}){let{scope:t,reduceMotion:n,skipAnimations:r}=e;function i(e,i,a){let o=[],s,c={};if(n!==void 0&&(c.reduceMotion=n),r!==void 0&&(c.skipAnimations=r),Eo(e)){let{onComplete:n,...r}=i||{};typeof n==`function`&&(s=n),o=To(e,{...c,...r},t)}else{let{onComplete:n,...r}=a||{};typeof n==`function`&&(s=n),o=wo(e,i,{...c,...r},t)}let l=new Na(o);return s&&l.finished.then(s),t&&(t.animations.push(l),l.finished.then(()=>{De(t.animations,l)})),l}return i}var Oo=Do(),ko=Bn(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Ao=Bn(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),jo=Bn(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),Mo=Bn(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),No=Bn(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Po=Bn(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Fo=Bn(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Io=Bn(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Lo=Bn(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),Ro=Bn(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),zo=Bn(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 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 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Bo=Bn(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Vo=Bn(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Ho=Bn(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Uo=Bn(`list-restart`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M7 12H3`,key:`13ou7f`}],[`path`,{d:`M7 19H3`,key:`wbqt3n`}],[`path`,{d:`M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14`,key:`qth677`}],[`path`,{d:`M11 10v4h4`,key:`172dkj`}]]),Wo=Bn(`message-square-plus`,[[`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`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Go=Bn(`message-square-text`,[[`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`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Ko=Bn(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),qo=Bn(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Jo=Bn(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Yo=Bn(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Xo=Bn(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Zo=Bn(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Qo=Bn(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),$o=Bn(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),es=Bn(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]);function ts({children:e,dataTestid:t,headerLeading:n,loading:r,onClose:i,onRefresh:a,onResizeStart:o,open:s,headerActions:c,title:l,titleIcon:u,width:d}){let f=K(),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{s&&p.current?.focus({preventScroll:!0})},[s]),(0,Q.jsx)(b,{features:v,children:(0,Q.jsx)(Be,{children:s&&(0,Q.jsxs)(G.aside,{ref:p,initial:!f&&{x:d,opacity:.8},animate:{x:0,opacity:1},exit:f?{opacity:0}:{x:d,opacity:.8},transition:f?{duration:0}:{duration:.2,ease:`easeInOut`},className:`relative h-full shrink-0 border-l border-border/70 bg-background/95 outline-none hidden min-[960px]:flex`,"data-fleet-panel-focus":!0,"data-testid":t,style:{width:d},tabIndex:-1,role:`dialog`,"aria-label":l,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())},children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Resize ${l} panel`,className:`absolute top-0 bottom-0 left-0 z-10 w-2 -translate-x-1 cursor-col-resize touch-none bg-transparent transition-colors outline-none hover:bg-foreground/10 focus-visible:bg-foreground/10`,"data-testid":`pi-resources-resize-handle`,onPointerDown:o}),(0,Q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex h-[60px] min-w-0 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:n??(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px] font-medium text-foreground/80`,children:[(0,Q.jsx)(u,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:l})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[c,(0,Q.jsx)(H,{type:`button`,onClick:a,disabled:!a,variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 text-foreground/40 hover:text-foreground/70 disabled:cursor-not-allowed disabled:opacity-35`,"aria-label":`Refresh ${l}`,title:`Refresh ${l}`,children:(0,Q.jsx)(_i,{"data-icon":`inline-start`,className:`size-3.5 ${r?`animate-spin`:``}`})}),(0,Q.jsx)(H,{type:`button`,onClick:i,variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 text-foreground/40 hover:text-foreground/70`,"aria-label":`Close panel`,title:`Close panel`,children:(0,Q.jsx)(ut,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:e})]})]})})})}var ns=Z.createContext(void 0);function rs(){let e=Z.useContext(ns);if(e===void 0)throw Error(st(64));return e}var is={tabActivationDirection:e=>({"data-activation-direction":e})},as=Z.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=Z.useRef([]),[f,p]=Z.useState(()=>new Map),[m,h]=vr({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=Z.useState(()=>new Map),y=Z.useRef(void 0),b=Z.useCallback(e=>os(_,e),[_]),[x,S]=Z.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=ss(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;tt(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=dt((e,t)=>{t.activationDirection=ss(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),A=dt((e,t)=>{i?.(e,it(t,void 0,void 0,{activationDirection:`none`}))}),j=dt((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),M=Z.useCallback(e=>f.get(e),[f]),N=Z.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=Z.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:N,getTabPanelIdByValue:M,onValueChange:k,orientation:a,registerMountedTabPanel:j,setTabMap:v,tabActivationDirection:T,value:m}),[b,N,M,k,a,j,v,T,m]),F=Z.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=Z.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=Z.useRef(!u),R=Z.useRef(r),z=Z.useRef(u),B=Z.useRef(!1);tt(()=>{if(g)return;function e(e,t){h(e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){B.current&&m!==null&&!y.current?.isConnected&&e(null,$e);return}B.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===R.current&&(z.current=!1),z.current&&t&&m===R.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=$e;r?i=rt:t&&(i=Xe),e(n,i);return}r&&F!=null&&(A(m,rt),L.current=!1)},[I,g,A,F,h,_,m]);let V=nt(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:is});return(0,Q.jsx)(ns.Provider,{value:P,children:(0,Q.jsx)(cn,{elementsRef:d,children:V})})});function os(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function ss(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=os(r,e),c=os(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var cs=`data-composite-item-active`;function ls(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Je(),{ref:i,index:a}=ln(e),o=n===a,s=Z.useRef(null),c=qe(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}var us=Z.createContext(void 0);function ds(){let e=Z.useContext(us);if(e===void 0)throw Error(st(65));return e}var fs=Z.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=rs(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=ds(),{highlightedIndex:v,onHighlightedIndexChange:y}=Je(),b=gn(o),{compositeProps:x,compositeRef:S,index:C}=ls({metadata:Z.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),w=a===u,E=Z.useRef(!1),D=Z.useRef(null),O=dt(e=>{D.current?.(),D.current=e?g(e):null});tt(()=>{if(E.current){E.current=!1;return}if(!(w&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=W(P(e));if(t&&T(e,t))return}r||y(C)},[w,C,v,y,r,_]);let{getButtonProps:k,buttonRef:A}=mt({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=Z.useRef(!1),N=Z.useRef(!1);function F(e){f(a,it(at,e.nativeEvent,void 0,{activationDirection:`none`}))}function I(e){w||r||F(e)}function L(e){w||r||h&&(!M.current||N.current)&&F(e)}function R(e){if(w||r)return;M.current=!0,N.current=e.button===0;let t=P(e.currentTarget);function n(){M.current=!1,N.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return nt(`button`,e,{state:{disabled:r,active:w,orientation:p,tabActivationDirection:m},ref:[t,A,S,O],props:[x,{role:`tab`,"aria-controls":j,"aria-selected":w,id:b,onClick:I,onFocus:L,onPointerDown:R,[cs]:w?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:is})}),ps=[];function ms(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=ps}=e,[p,m]=Z.useState(0),h=r!=null,g=Z.useRef(null),_=qe(g,c),v=Z.useRef([]),y=Z.useRef(!1),b=o??p,x=dt((e,t=!1)=>{if((s??m)(e),t){let t=v.current[e];jt(g.current,t,a,n)}}),S=dt(e=>{if(e.size===0||y.current)return;y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)x(i);else if(w(t,b,d)){let e=A(t,{disabledIndices:d});I(t,e)||x(e)}jt(g.current,r,a,n)});tt(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(w(e,b,d)){let t=A(e,{disabledIndices:d});I(e,t)||x(t)}},[d,o,b,v,x]);let C=dt((e,t,n)=>i?i(e,t,n,v):n),T=dt(e=>{let o=e.key===`Home`||e.key===`End`;if(!en.has(e.key)||!l&&o||hs(e,f)||!g.current)return;let s=a===`rtl`,c=s?tn:Ft,p=s?Ft:tn,m=n===`vertical`?Ut:c,_=n===`vertical`?yt:p,y=j(e.nativeEvent);if(y!=null&&bt(y)&&!fn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let S=b,w=E(v,d),T=D(v,d);r!=null&&(S=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:b,loopFocus:t,maxIndex:T,minIndex:w,onLoop:C,orientation:n,rtl:s}));let O=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,k=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?S=w:e.key===`End`&&(S=T)),S===b&&(O||k)&&(t&&S===T&&O?(S=w,i&&(S=i(e,b,S,v))):t&&S===w&&k?(S=T,i&&(S=i(e,b,S,v))):S=A(v.current,{startingIndex:S,decrement:k,disabledIndices:d})),S!==b&&!I(v.current,S)&&(u&&e.stopPropagation(),(h||o||O||k)&&e.preventDefault(),x(S,!0),queueMicrotask(()=>{v.current[S]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=j(e.nativeEvent);!t||n==null||!bt(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:b,onHighlightedIndexChange:x,elementsRef:v,onMapChange:S,relayKeyboardEvent:T}}function hs(e,t){for(let n of xt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function gs(e){let{render:t,className:n,style:r,refs:i=lt,props:a=lt,state:o=Qe,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=ms({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:on(),disabledIndices:v,modifierKeys:y}),k=nt(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=Z.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Q.jsx)(pt.Provider,{value:A,children:(0,Q.jsx)(cn,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var _s=Z.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=rs(),[d,f]=Z.useState(0),[p,m]=Z.useState(null),h=Z.useRef(new Set),g=Z.useRef(new Set),_=Z.useRef(null);tt(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=dt(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=dt(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),b={orientation:c,tabActivationDirection:u},x={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},S=Z.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,Q.jsx)(us.Provider,{value:S,children:(0,Q.jsx)(gs,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:is,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:lt})})});function vs({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(as,{"data-slot":`tabs`,"data-orientation":t,className:q(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var ys=R(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function bs({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(_s,{"data-slot":`tabs-list`,"data-variant":t,className:q(ys({variant:t}),e),...n})}function xs({className:e,...t}){return(0,Q.jsx)(fs,{"data-slot":`tabs-trigger`,className:q(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Ss(e,t={}){let{axis:n=`y`}=t,r=(0,Z.useRef)(new Map),i=(0,Z.useRef)(new Map),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)([]),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useCallback)(()=>{if(!e.current)return;let t=[];r.current.forEach((e,n)=>{t[n]={top:e.offsetTop,height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth}});let n=l.current,i=n.length!==t.length;for(let e=0;!i&&e<t.length;e++){let r=n[e],a=t[e];r!==a&&(i=!r||!a||r.top!==a.top||r.left!==a.left||r.width!==a.width||r.height!==a.height)}i&&(l.current=t,c(t))},[e]),p=(0,Z.useCallback)(()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})},[f]),m=(0,Z.useCallback)((e,t)=>{let n=i.current.get(e);if(n&&(n.disconnect(),i.current.delete(e)),t){if(r.current.set(e,t),typeof ResizeObserver<`u`){let n=new ResizeObserver(()=>p());n.observe(t),i.current.set(e,n)}}else r.current.delete(e);p()},[p]),h=(0,Z.useCallback)(t=>{let r=t.clientX,i=t.clientY;u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null;let t=e.current;if(!t)return;let a=t.getBoundingClientRect(),s=n===`x`?r:i,c=null,d=1/0,f=null,p=l.current,m=n===`x`?t.scrollLeft:t.scrollTop,h=n===`x`?t.clientLeft:t.clientTop,g=n===`x`?a.left:a.top,_=n===`x`?t.offsetWidth:t.offsetHeight,v=n===`x`?a.width:a.height,y=_>0?v/_:1;for(let e=0;e<p.length;e++){let t=p[e];if(!t)continue;let r=g+(h+(n===`x`?t.left:t.top)-m)*y,i=(n===`x`?t.width:t.height)*y,a=r+i;s>=r&&s<=a&&(f=e);let o=r+i/2,l=Math.abs(s-o);l<d&&(d=l,c=e)}o(f??c)})},[n,e]),g=(0,Z.useCallback)(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),o(null)},[]);return(0,Z.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>p());return n.observe(t),()=>n.disconnect()},[e,p]),(0,Z.useEffect)(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),d.current!==null&&cancelAnimationFrame(d.current),i.current.forEach(e=>{e.disconnect()}),i.current.clear()},[]),{activeIndex:a,setActiveIndex:o,itemRects:s,onMouseMove:h,onMouseLeave:g,registerItem:m,measureItems:f}}var Cs={normal:`'wght' 400, 'opsz' 14`,medium:`'wght' 450, 'opsz' 15`,semibold:`'wght' 550, 'opsz' 20`,bold:`'wght' 700, 'opsz' 25`},ws={fast:{enter:{type:`spring`,duration:.08,bounce:0},exit:{duration:.06}},moderate:{enter:{type:`spring`,duration:.16,bounce:0},exit:{duration:.12}},slow:{enter:{type:`spring`,duration:.24,bounce:.12},exit:{duration:.16}}},Ts=`bg-background shadow-sm`,Es=`rounded-full border border-border/70 bg-sidebar p-0.5 shadow-sm backdrop-blur`,Ds=`rounded-full`;function Os(e,t){return t?e?`text-foreground/75`:`text-foreground`:e?`text-foreground/55`:`text-muted-foreground`}var ks=(0,Z.createContext)(null);function As(){let e=(0,Z.useContext)(ks);if(!e)throw Error(`useTabsSubtle must be used within a TabsSubtle`);return e}function js({selectedRect:e,hoverRect:t,focusRect:n,isHovering:r,isHoveringSelected:i}){let a=K()?{duration:0}:void 0;return(0,Q.jsxs)(b,{features:v,children:[e?(0,Q.jsx)(G.div,{className:q(`pointer-events-none absolute`,Ts,Ds),layout:!0,initial:!1,style:{left:e.left,top:e.top,width:e.width,height:e.height},animate:{opacity:r?.8:1},transition:a??{...ws.moderate.enter,opacity:{duration:.08}}}):null,(0,Q.jsx)(Be,{children:t&&!i?(0,Q.jsx)(G.div,{className:q(`pointer-events-none absolute`,Ts,Ds),layout:!0,style:{left:t.left,top:t.top,width:t.width,height:t.height},initial:{opacity:0},animate:{opacity:.4},exit:{opacity:0,transition:a??ws.fast.exit},transition:a??{...ws.fast.enter,opacity:{duration:.08}}}):null}),(0,Q.jsx)(Be,{children:n?(0,Q.jsx)(G.div,{className:q(`pointer-events-none absolute z-20 border border-ring`,Ds),layout:!0,initial:!1,style:{left:n.left-2,top:n.top-2,width:n.width+4,height:n.height+4},exit:{opacity:0,transition:a??ws.fast.exit},transition:a??{...ws.fast.enter,opacity:{duration:.08}}}):null})]})}var Ms=(0,Z.forwardRef)(({children:e,selectedIndex:t,onSelect:n,idPrefix:r,activeLabel:i=!1,variant:a=`default`,className:o,...s},c)=>{let l=(0,Z.useRef)(null),u=(0,Z.useRef)(!1),d=a===`pill`,{activeIndex:f,setActiveIndex:p,itemRects:m,onMouseMove:h,onMouseLeave:g,registerItem:_}=Ss(l,{axis:`x`}),v=(0,Z.useCallback)((e,t)=>{_(e,t)},[_]),y=(0,Z.useCallback)(e=>{u.current=!0,h(e)},[h]),b=(0,Z.useCallback)(()=>{u.current=!1,g()},[g]),[x,S]=(0,Z.useState)(null),C=t>=0?m[t]:void 0,w=f===null?null:m[f],T=x===null?null:m[x],E=f===t,D=f!==null&&!E,O=(0,Z.useMemo)(()=>({registerTab:v,hoveredIndex:f,selectedIndex:t,idPrefix:r,activeLabel:i,variant:a,onSelect:n}),[v,f,t,r,i,a,n]);return(0,Q.jsx)(ks.Provider,{value:O,children:(0,Q.jsx)(vs,{className:`data-horizontal:!flex-row !gap-0.5`,value:t>=0?t:null,onValueChange:e=>{let t=typeof e==`number`?e:Number(e);Number.isInteger(t)&&n(t)},render:(0,Q.jsxs)(bs,{activateOnFocus:!1,variant:`line`,ref:e=>{l.current=e,typeof c==`function`?c(e):c&&(c.current=e)},onMouseMove:y,onMouseLeave:b,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);if(t!=null){let n=Number(t);p(n),S(e.target.matches(`:focus-visible`)?n:null)}},onBlur:e=>{l.current?.contains(e.relatedTarget)||(S(null),!u.current&&p(null))},className:q(`relative flex max-w-full [scrollbar-width:none] items-center gap-0.5 overflow-x-auto select-none [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,d?Es:`-mx-1 -my-1 px-1 py-1`,o),...s,children:[(0,Q.jsx)(js,{selectedRect:C,hoverRect:w,focusRect:T,isHovering:D,isHoveringSelected:E}),e]})})})});Ms.displayName=`TabsSubtle`;var Ns=(0,Z.forwardRef)(({icon:e,label:t,index:n,badge:r,className:i,"aria-label":a,onClick:o,...s},c)=>{let l=(0,Z.useRef)(null),{registerTab:u,hoveredIndex:d,selectedIndex:f,idPrefix:p,activeLabel:m,variant:h,onSelect:g}=As();(0,Z.useEffect)(()=>(u(n,l.current),()=>u(n,null)),[n,u]);let _=f===n,y=d===n||_,x=m&&!!e,S=!x||_,C=h===`pill`,w=Os(C,y),T=a??(x&&!S?t:void 0),E=(0,Q.jsxs)(`span`,{className:q(`inline-grid whitespace-nowrap`,C?`text-[12px] font-medium`:`text-[13px]`),children:[(0,Q.jsx)(`span`,{className:`invisible col-start-1 row-start-1 [text-box:trim-both_cap_alphabetic]`,style:{fontVariationSettings:Cs.semibold},"aria-hidden":`true`,children:t}),(0,Q.jsx)(`span`,{className:q(`col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]`,w),style:{fontVariationSettings:_?Cs.semibold:Cs.normal},children:t})]});return(0,Q.jsxs)(xs,{ref:e=>{let t=e;l.current=t,typeof c==`function`?c(t):c&&(c.current=t)},value:n,"data-proximity-index":n,id:p?`${p}-tab-${n}`:void 0,"aria-controls":p?`${p}-panel-${n}`:void 0,"aria-label":T,className:q(`relative z-10 flex flex-none cursor-pointer items-center border-none !bg-transparent !shadow-none outline-none after:hidden`,C?`h-8 px-2.5`:x?`h-8 px-3`:`h-9 gap-2 px-3`,Ds,i),...s,onClick:e=>{o?.(e),_&&g(n)},children:[e?(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(e,{"data-icon":`inline-start`,size:C?14:16,strokeWidth:y?2:1.5,className:q(`shrink-0 transition-[color,stroke-width] duration-80`,w)}),r===void 0?null:(0,Q.jsx)(`span`,{className:q(`text-[11px] tabular-nums transition-colors duration-80`,w),children:r})]}):null,x?null:E,(0,Q.jsx)(b,{features:v,children:(0,Q.jsx)(Be,{initial:!1,children:x&&S?(0,Q.jsx)(G.span,{className:`ml-2 overflow-hidden`,initial:{clipPath:`inset(0 100% 0 0)`,opacity:0},animate:{clipPath:`inset(0 0% 0 0)`,opacity:1},exit:{clipPath:`inset(0 100% 0 0)`,opacity:0},transition:{...ws.fast.enter,opacity:{duration:.06}},children:E},`label`):null})})]})});Ns.displayName=`TabsSubtleItem`;var Ps=(0,Z.forwardRef)(({index:e,selectedIndex:t,idPrefix:n,children:r,className:i,...a},o)=>{let s=t===e;return(0,Q.jsx)(`div`,{ref:o,id:`${n}-panel-${e}`,role:`tabpanel`,"aria-labelledby":`${n}-tab-${e}`,hidden:!s,tabIndex:-1,className:q(`outline-none`,i),...a,children:s?r:null})});Ps.displayName=`TabsSubtlePanel`;function Fs({active:e=!1,ariaLabel:t,className:n,title:r,...i}){return(0,Q.jsx)(H,{...i,type:`button`,variant:`ghost`,size:`sm`,className:q(jn,e?Pn:Dn,n),"aria-label":t,title:r??t})}function Is(){let{reopenRightPanel:e,rightPanel:t}=gi();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`min-[960px]:hidden`,children:(0,Q.jsx)(Ls,{idPrefix:`right-panel-mobile`})}),(0,Q.jsx)(`div`,{className:`hidden min-[960px]:block`,children:t===null?(0,Q.jsx)(Rs,{onOpen:e}):null})]})}function Ls({idPrefix:e=`right-panel`}){let{artifactRuns:t,messages:n,presentation:r,rightPanel:i,setRightPanel:a,resources:o}=gi(),{workspaceTree:s}=mi();return(0,Q.jsx)(zs,{activePanel:i,onPanelChange:a,resources:o,replRuns:t.flatMap(e=>e.artifacts).filter(e=>e.kind===`ipython`).length,sessionBlocks:ia(n).length,subagents:r.rlmChildren.length,openUIArtifacts:t.flatMap(e=>e.artifacts).filter(e=>e.kind===`openui-html`).length,workspace:s,idPrefix:e})}function Rs({onOpen:e}){return(0,Q.jsx)(Fs,{ariaLabel:`Open side panel`,className:`size-9 justify-center px-0`,onClick:e,children:(0,Q.jsx)(Ko,{className:`size-4`})})}function zs({activePanel:e,onPanelChange:t,resources:n,replRuns:r=0,sessionBlocks:i=0,subagents:a=0,openUIArtifacts:o=0,workspace:s,idPrefix:c=`right-panel`}){let l=hr(n,s).reduce((e,t)=>e+t.items.length,0),u=(0,Z.useMemo)(()=>{let e=i+o;return e>0?e:void 0},[o,i]),d=(0,Z.useMemo)(()=>Gn.map(e=>({...e,badge:e.badgeSource===`resources`?l||void 0:e.badgeSource===`artifacts`?u:e.badgeSource===`repl`?r||void 0:e.badgeSource===`subagents`&&a||void 0})),[r,a,u,l]),f=d.findIndex(t=>t.id===e),p=(0,Z.useMemo)(()=>d.map(e=>({value:e.id,label:e.title,icon:e.icon})),[d]);return(0,Q.jsx)(Bs,{"data-testid":`right-panel-inline-launcher`,"data-active-panel":e??`closed`,activePanel:e,options:p,panelOptions:d,idPrefix:c,selectedIndex:f,onSelect:n=>{let r=d.at(n)?.id;r&&t(r===e?null:r)}})}function Bs({activePanel:e,className:t,idPrefix:n,onSelect:r,options:i,panelOptions:a,selectedIndex:o,...s}){let c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(()=>{let e=c.current,t=l.current;if(!e||!t)return;let n=e.parentElement?.clientWidth??e.clientWidth,r=t.getBoundingClientRect().width;d(r>n+1)},[]);(0,Z.useLayoutEffect)(()=>{f();let e=c.current,t=l.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(f);return e.parentElement&&n.observe(e.parentElement),n.observe(e),n.observe(t),()=>n.disconnect()},[f,a,o]);let p=(0,Z.useCallback)(e=>{let t=a.findIndex(t=>t.id===e);t>=0&&r(t)},[r,a]);return(0,Q.jsxs)(`div`,{ref:c,className:`relative ${u?`w-full`:`w-fit`} min-w-0 max-w-full overflow-hidden ${t??``}`,"data-panel-launcher-mode":u?`dropdown`:`tabs`,...s,children:[u?(0,Q.jsx)(dn,{"aria-label":`Select panel`,className:`w-full min-w-0 max-w-full rounded-full border-border/70 bg-sidebar`,onValueChange:p,options:i,placeholder:`Open panel`,value:e}):(0,Q.jsx)(Ms,{activeLabel:!0,className:`w-fit max-w-full`,idPrefix:n,selectedIndex:o,onSelect:r,children:a.map((e,t)=>(0,Q.jsx)(Ns,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))}),(0,Q.jsx)(`div`,{ref:l,"aria-hidden":`true`,className:`pointer-events-none invisible absolute top-0 left-0 -z-10 h-0 w-max max-w-none overflow-hidden`,"data-panel-launcher-measurement":!0,inert:!0,children:(0,Q.jsx)(Ms,{activeLabel:!0,className:`w-max max-w-none`,idPrefix:`${n}-measurement`,selectedIndex:o,onSelect:()=>void 0,children:a.map((e,t)=>(0,Q.jsx)(Ns,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))})})]})}function Vs({children:e,dataTestid:t,headerActions:n,icon:r,onClose:i,open:a,title:o}){let s=(0,Z.useRef)(null),c=(0,Z.useId)(),l=(0,Z.useRef)(!1),u=(0,Z.useEffectEvent)(e=>{s.current&&e.target===s.current&&i?.()});return(0,Z.useEffect)(()=>{if(!a)return;let e=s.current;if(!e)return;let t=e=>u(e);return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[a]),(0,Z.useEffect)(()=>{let e=s.current;if(!e)return;if(!a){e.open&&(l.current=!0,e.close(),l.current=!1);return}let t=window.matchMedia(`(min-width: 960px)`),n=()=>{if(t.matches){e.open&&(l.current=!0,e.close());return}e.open||(e.showModal(),e.focus())};return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[a]),a?(0,Q.jsx)(`dialog`,{ref:s,"data-testid":t,className:`fixed top-[var(--chat-chrome-top)] right-3 bottom-3 m-0 ${zn} backdrop:bg-black/20 ${ri}`,"aria-labelledby":c,onClose:()=>{if(l.current){l.current=!1;return}i?.()},children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{id:c,className:`sr-only`,children:o??`Panel`}),o&&(0,Q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[13px] font-medium text-foreground/80`,children:[r&&(0,Q.jsx)(r,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:o})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,i&&(0,Q.jsx)(H,{type:`button`,onClick:i,variant:`ghost`,size:`icon-sm`,className:`relative after:absolute after:top-1/2 after:left-1/2 after:size-10 after:-translate-x-1/2 after:-translate-y-1/2 text-foreground/40 hover:text-foreground/70`,"aria-label":`Close panel`,title:`Close panel`,children:(0,Q.jsx)(ut,{"data-icon":`inline-start`,className:`size-3.5`})})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2`,children:e})]})}):null}function Hs({handleResourceCanvasResizeStart:e,onClose:t,resourceCanvasWidth:n}){let r=gi(),i=mi(),{rightPanel:a}=r,o=a!==null,s=a?Zn(a):null,c=s?.component,l=s?.loadingSource===`resources`?r.resourcesLoading:s?.loadingSource===`workspace`&&i.workspaceLoading,u=s?.refreshSource===`resources`?r.refreshResources:s?.refreshSource===`workspace`?i.refreshWorkspace:void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Vs,{dataTestid:s?.mobileDataTestid,icon:s?.icon,onClose:t,open:o,title:s?.title??``,children:c?(0,Q.jsx)(c,{}):null}),(0,Q.jsx)(ts,{dataTestid:s?.dataTestid,headerLeading:(0,Q.jsx)(Ls,{idPrefix:`right-panel-desktop`}),loading:l,onClose:t,onRefresh:u,onResizeStart:e,open:o,title:s?.title??``,titleIcon:s?.icon??qn,width:n,children:c?(0,Q.jsx)(c,{}):null})]})}var Us={"--chat-chrome-top":`56px`,"--chat-header-height":`36px`,"--chat-header-top":`12px`};function Ws({children:e,headerCenter:t,headerLeft:n,headerRight:r,panel:i}){return(0,Q.jsxs)(`div`,{className:`flex h-svh min-w-0 overflow-hidden`,"data-testid":`chat-shell`,style:Us,children:[(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,"data-testid":`chat-column`,children:[(0,Q.jsxs)(`header`,{className:q(En,`grid min-h-[calc(var(--chat-header-top)+var(--chat-header-height))] shrink-0 grid-cols-[auto_1fr_auto] items-center gap-2 px-3 pt-[var(--chat-header-top)] pb-3`),"data-testid":`chat-header`,children:[(0,Q.jsx)(`div`,{className:`justify-self-start`,children:n}),(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center justify-start gap-2 justify-self-start`,children:t}),(0,Q.jsx)(`div`,{className:`justify-self-end`,children:r})]}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e})]}),i]})}var Gs=e(n(),1),Ks=`(max-width: 767px)`,qs=`b`,Js={duration:.36,ease:Ge},Ys={type:`spring`,stiffness:380,damping:35,mass:.75},Xs={duration:.18,ease:Ue},Zs={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:Ue,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:Ue,staggerChildren:.045}}},Qs={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:Xs}},$s={duration:.16,ease:Ue},ec=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function tc(e){let t=window.matchMedia(Ks);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function nc(){return window.matchMedia(Ks).matches}function rc(){return!1}function ic(){return(0,Z.useSyncExternalStore)(tc,nc,rc)}var ac=(0,Z.createContext)(null),oc=(0,Z.createContext)(null);function sc(){let e=(0,Z.useContext)(ac);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function cc(){let e=(0,Z.useContext)(oc);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function lc({children:e,open:t,defaultOpen:n=!0,onOpenChange:r,openMobile:i,defaultOpenMobile:a=!1,onOpenMobileChange:o,className:s,style:c,...l}){let[u,d]=(0,Z.useState)(n),[f,p]=(0,Z.useState)(a),m=ic(),h=K()??!1,g=(0,Z.useId)(),_=(0,Z.useRef)(null),v=t??u,y=i??f,b=(0,Z.useCallback)(e=>{t===void 0&&d(e),r?.(e)},[r,t]),x=(0,Z.useCallback)(e=>{i===void 0&&p(e),o?.(e)},[o,i]),S=(0,Z.useCallback)(()=>{m?x(!y):b(!v)},[v,m,y,b,x]),C=(0,Z.useMemo)(()=>({isMobile:m,layoutId:`${g}-active`,open:v,openMobile:y,reduce:h,setOpen:b,setOpenMobile:x,state:v?`expanded`:`collapsed`,toggleSidebar:S,triggerRef:_}),[v,g,m,y,h,b,x,S]);return(0,Z.useEffect)(()=>{let e=e=>{e.key.toLowerCase()===qs&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]),(0,Q.jsx)(ac.Provider,{value:C,children:(0,Q.jsx)(`div`,{...l,"data-slot":`sidebar-wrapper`,"data-state":v?`expanded`:`collapsed`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`4.25rem`,"--sidebar-width-mobile":`18rem`,...c},className:q(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function uc({ariaLabel:e,children:t,className:n,side:r}){let i=sc(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(!1),c=(0,Z.useMemo)(()=>({collapsed:!1,collapsible:`none`,side:r}),[r]);return(0,Z.useEffect)(()=>s(!0),[]),(0,Z.useEffect)(()=>{if(!i.openMobile)return;let e=a.current;if(!e)return;let t=i.triggerRef.current,n=document.body,r=window.scrollY,o={left:n.style.left,overflow:n.style.overflow,position:n.style.position,right:n.style.right,top:n.style.top};n.style.position=`fixed`,n.style.top=`-${r}px`,n.style.left=`0`,n.style.right=`0`,n.style.overflow=`hidden`;let s=requestAnimationFrame(()=>{(e.querySelector(ec)??e).focus({preventScroll:!0})});return()=>{cancelAnimationFrame(s),n.style.position=o.position,n.style.top=o.top,n.style.left=o.left,n.style.right=o.right,n.style.overflow=o.overflow,window.scrollTo(0,r),t?.focus({preventScroll:!0})}},[i.openMobile,i.triggerRef,o]),o?(0,Gs.createPortal)((0,Q.jsxs)(`div`,{className:q(`pointer-events-none fixed inset-0 z-50 md:hidden`,i.openMobile?`visible`:`invisible`),children:[(0,Q.jsx)(G.button,{type:`button`,"aria-label":`Close sidebar`,tabIndex:i.openMobile?0:-1,initial:!1,animate:{opacity:+!!i.openMobile},transition:i.reduce?$s:Js,onClick:()=>i.setOpenMobile(!1),className:q(`absolute inset-0 bg-black/40`,i.openMobile?`pointer-events-auto`:`pointer-events-none`)}),(0,Q.jsx)(G.div,{ref:a,role:`dialog`,"aria-modal":`true`,"aria-label":e,"aria-hidden":!i.openMobile,inert:!i.openMobile,tabIndex:-1,"data-mobile":`true`,"data-state":i.openMobile?`expanded`:`collapsed`,"data-side":r,initial:!1,animate:{opacity:i.reduce?+!!i.openMobile:1,x:i.reduce?0:i.openMobile?`0%`:r===`left`?`-100%`:`100%`},transition:i.reduce?$s:Js,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),i.setOpenMobile(!1);return}if(e.key!==`Tab`)return;let t=a.current?Array.from(a.current.querySelectorAll(ec)):[];if(t.length===0){e.preventDefault(),a.current?.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())},className:q(`pointer-events-auto absolute inset-y-0 flex h-dvh w-(--sidebar-width-mobile) max-w-[88vw] flex-col overflow-hidden`,`border-border bg-background shadow-2xl will-change-transform`,r===`left`?`left-0 border-r`:`right-0 border-l`,!i.openMobile&&`pointer-events-none`,n),children:(0,Q.jsx)(oc.Provider,{value:c,children:t})})]}),document.body):null}var dc=(0,Z.forwardRef)(function({side:e=`left`,variant:t=`sidebar`,collapsible:n=`icon`,ariaLabel:r=`Sidebar`,children:i,className:a,panelClassName:o,style:s,...c},l){let u=sc(),d=n!==`none`&&!u.open,f=d&&n===`offcanvas`,p=t===`floating`||t===`inset`,m=f?`0px`:d?p?`calc(var(--sidebar-width-icon) + 1rem)`:`var(--sidebar-width-icon)`:p?`calc(var(--sidebar-width) + 1rem)`:`var(--sidebar-width)`,h=(0,Z.useMemo)(()=>({collapsed:d,collapsible:n,side:e}),[d,n,e]);return u.isMobile?(0,Q.jsx)(uc,{ariaLabel:r,className:a,side:e,children:i}):(0,Q.jsx)(G.aside,{...c,ref:l,initial:!1,"aria-label":r,"data-slot":`sidebar`,"data-state":d?`collapsed`:`expanded`,"data-collapsible":n,"data-variant":t,"data-side":e,transition:u.reduce?{duration:0}:Ys,layout:`size`,style:{...s,width:m},className:q(`group/sidebar relative hidden h-auto shrink-0 md:block will-change-transform`,`peer`,e===`right`&&`order-last`,a),children:(0,Q.jsx)(G.div,{initial:!1,animate:{opacity:+!f,x:f?e===`left`?`-120%`:`120%`:`0%`},transition:u.reduce?$s:Js,className:q(`sticky top-0 flex h-svh w-full flex-col overflow-hidden`,p&&(d?`w-[var(--sidebar-width-icon)]`:`w-[var(--sidebar-width)]`),n===`offcanvas`&&`w-[var(--sidebar-width)]`,t===`sidebar`&&(e===`left`?`border-border border-r bg-background`:`border-border border-l bg-background`),t===`floating`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl bg-sidebar shadow-surface-3`,t===`inset`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl bg-background`,o),children:(0,Q.jsx)(oc.Provider,{value:h,children:i})})})}),fc=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=sc(),o=a.isMobile?a.openMobile:a.open;return(0,Q.jsx)(H,{...r,ref:e=>{a.triggerRef.current=e,typeof i==`function`?i(e):i&&(i.current=e)},type:n,variant:`ghost`,size:`icon-lg`,"aria-label":r[`aria-label`]??`Toggle sidebar`,"aria-expanded":o,"data-slot":`sidebar-trigger`,"data-state":o?`expanded`:`collapsed`,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:q(`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,e)})});(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=sc();return(0,Q.jsx)(H,{...r,ref:i,type:n,variant:`ghost`,size:`icon-lg`,"aria-label":r[`aria-label`]??`Close sidebar`,onClick:e=>{t?.(e),!e.defaultPrevented&&(a.isMobile?a.setOpenMobile(!1):a.setOpen(!1))},className:q(`focus-visible:ring-2 focus-visible:ring-ring`,e)})});var pc=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=sc(),o=cc();return(0,Q.jsx)(`button`,{...r,ref:i,type:n,"data-side":o.side,"aria-label":r[`aria-label`]??`Toggle sidebar`,title:`Toggle sidebar`,tabIndex:-1,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:q(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 outline-none md:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent after:transition-colors hover:after:bg-border`,`data-[side=right]:right-0 data-[side=right]:translate-x-1/2 data-[side=left]:left-full`,e)})}),mc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(G.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:q(`relative flex min-h-svh min-w-0 flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:shadow-sm`,e)})}),hc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:q(`flex shrink-0 flex-col gap-2 p-3`,e)})}),gc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:q(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})}),_c=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:q(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})}),vc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:q(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})}),yc=(0,Z.forwardRef)(function({children:e,className:t,...n},r){let{collapsed:i}=cc();return(0,Q.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:q(`mb-1 h-7 overflow-hidden px-2 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity`,i?`opacity-0`:`opacity-100`,t),children:e})}),bc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:q(`w-full min-w-0`,e)})});(0,Z.forwardRef)(function({children:e,className:t,...n},r){return(0,Q.jsx)($r,{...n,ref:r,as:`ul`,inset:0,pillClassName:`rounded-xl bg-muted/70`,pillContainerClassName:`inset-y-auto top-0 h-9`,"data-slot":`sidebar-menu`,className:q(`flex w-full min-w-0 list-none flex-col gap-0.5`,t),children:e})}),(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(G.li,{...t,ref:n,layout:`position`,transition:He,"data-slot":`sidebar-menu-item`,className:q(`relative`,e)})}),(0,Z.forwardRef)(function({open:e,children:t,className:n,...r},i){let a=sc(),o=cc();return(0,Q.jsx)(Be,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,Z.createElement)(G.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:Zs,initial:!a.reduce&&`closed`,animate:a.reduce?{opacity:1}:`open`,exit:a.reduce?{opacity:0}:`closed`,transition:a.reduce?{duration:.12}:void 0,"data-slot":`sidebar-menu-sub`,className:q(`relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3`,n)},t):null})}),(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(G.li,{...t,ref:n,variants:Qs,"data-slot":`sidebar-menu-sub-item`,className:q(`relative min-w-0`,e)})});function xc({children:e,className:t,sidebarWidth:n=`17rem`,style:r,...i}){return(0,Q.jsx)(lc,{...i,style:{...r,"--sidebar-width":n},className:q(`min-h-0 w-full overflow-hidden rounded-2xl border border-border bg-background`,t),children:e})}var Sc=`https://docs.qredence.ai`,Cc=`fleet-prime:v1:sidebar-expanded-projects`,wc=[],Tc=`new-session:`,Ec=`project:`,Dc=`session:`;function Oc(e){return`${Ec}${e}`}function kc(e){return`${Dc}${e}`}function Ac(e){return`${Tc}${e}`}function jc(e,t){return e.startsWith(t)?e.slice(t.length):null}function Mc(e){return oi(e.title||e.firstMessage||e.sessionId.slice(0,8))}function Nc(e,t){return`${e.projectId?t.get(e.projectId)?.name??`Unassigned`:`Unassigned`} · ${e.status===`idle`?`Ready`:e.status} · ${`${String(e.messageCount)} ${e.messageCount===1?`message`:`messages`}`}`}function Pc(e){let t=Date.parse(e);if(!Number.isFinite(t))return`Earlier`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=Math.floor((r-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?`Today`:i===1?`Yesterday`:`Earlier`}function Fc(e){return e.hasChildren?`${e.name}/`:e.name}function Ic(e,t){return e instanceof Error&&e.message.trim()?e.message:t}function Lc(e){if(typeof window>`u`)return e?[Oc(e)]:[];let t=window.localStorage.getItem(Cc);if(!t)return e?[Oc(e)]:[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return e?[Oc(e)]:[]}}function Rc(e,t){return t.type===`update`?t.update(e):{...e,[t.field.key]:t.field.value}}function zc(e){let[t,n]=(0,Z.useReducer)(Rc,e,e=>({brandMenuOpen:!1,projectActionsOpen:!1,searchOpen:!1,query:``,expandedProjectIds:Lc(e),revealedProjectIds:new Set,renameTarget:null,renameTitle:``,renameProjectTarget:null,renameProjectName:``,deleteTarget:null,unregisterTarget:null,createOpen:!1,createPath:``,createName:``,directoryToken:void 0,directoryBrowser:null,directoryBrowseLoading:!1,directoryBrowseError:null,createSubmitting:!1,createSubmitError:null,forkTarget:null,forkProjectId:void 0})),r=(0,Z.useCallback)(function(e,t){n({type:`set`,field:{key:e,value:t}})},[]),i=(0,Z.useCallback)(function(e,t){n({type:`update`,update:n=>({...n,[e]:t(n[e])})})},[]),a=(0,Z.useCallback)(e=>r(`brandMenuOpen`,e),[r]),o=(0,Z.useCallback)(e=>r(`projectActionsOpen`,e),[r]),s=(0,Z.useCallback)(e=>r(`searchOpen`,e),[r]),c=(0,Z.useCallback)(e=>r(`query`,e),[r]),l=(0,Z.useCallback)(e=>typeof e==`function`?i(`expandedProjectIds`,e):r(`expandedProjectIds`,e),[r,i]),u=(0,Z.useCallback)(e=>typeof e==`function`?i(`revealedProjectIds`,e):r(`revealedProjectIds`,e),[r,i]),d=(0,Z.useCallback)(e=>r(`renameTarget`,e),[r]),f=(0,Z.useCallback)(e=>r(`renameTitle`,e),[r]),p=(0,Z.useCallback)(e=>r(`renameProjectTarget`,e),[r]),m=(0,Z.useCallback)(e=>r(`renameProjectName`,e),[r]),h=(0,Z.useCallback)(e=>r(`deleteTarget`,e),[r]),g=(0,Z.useCallback)(e=>r(`unregisterTarget`,e),[r]),_=(0,Z.useCallback)(e=>r(`createOpen`,e),[r]),v=(0,Z.useCallback)(e=>r(`createPath`,e),[r]),y=(0,Z.useCallback)(e=>r(`createName`,e),[r]),b=(0,Z.useCallback)(e=>r(`directoryToken`,e),[r]),x=(0,Z.useCallback)(e=>r(`directoryBrowser`,e),[r]),S=(0,Z.useCallback)(e=>r(`directoryBrowseLoading`,e),[r]),C=(0,Z.useCallback)(e=>r(`directoryBrowseError`,e),[r]),w=(0,Z.useCallback)(e=>r(`createSubmitting`,e),[r]),T=(0,Z.useCallback)(e=>r(`createSubmitError`,e),[r]),E=(0,Z.useCallback)(e=>r(`forkTarget`,e),[r]),D=(0,Z.useCallback)(e=>r(`forkProjectId`,e),[r]);return{...t,setBrandMenuOpen:a,setProjectActionsOpen:o,setSearchOpen:s,setQuery:c,setExpandedProjectIds:l,setRevealedProjectIds:u,setRenameTarget:d,setRenameTitle:f,setRenameProjectTarget:p,setRenameProjectName:m,setDeleteTarget:h,setUnregisterTarget:g,setCreateOpen:_,setCreatePath:v,setCreateName:y,setDirectoryToken:b,setDirectoryBrowser:x,setDirectoryBrowseLoading:S,setDirectoryBrowseError:C,setCreateSubmitting:w,setCreateSubmitError:T,setForkTarget:E,setForkProjectId:D}}function Bc(e,t){return e.filter(e=>e.messageCount>0||e.sessionId===t)}function Vc(e){return e.toSorted((e,t)=>Date.parse(t.updatedAt)-Date.parse(e.updatedAt))}function Hc(e,t,n){let r=Vc(e);if(n||r.length<=5)return r;let i=r.slice(0,5),a=r.find(e=>e.sessionId===t);return a&&!i.some(e=>e.sessionId===a.sessionId)&&(i[4]=a),i}function Uc(e,t){let n=new Map(e.map((e,t)=>[e.projectId,t])),r=new Map;for(let e of t){if(!e.projectId)continue;let t=Date.parse(e.updatedAt);r.set(e.projectId,Math.max(r.get(e.projectId)??0,t))}return e.toSorted((e,t)=>{let i=r.get(e.projectId)??0,a=r.get(t.projectId)??0;return i===a?(n.get(e.projectId)??0)-(n.get(t.projectId)??0):a-i})}var Wc=[[`resources`,`Open Resources`,qn],[`workspace`,`Open Workspace`,di],[`artifacts`,`Open Artifacts`,fi]];function Gc({icon:e,label:t,destructive:n=!1,onClick:r}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:n?`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-destructive hover:bg-destructive/10`:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs hover:bg-muted`,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]})}function Kc({sessions:e,projects:t=wc,projectSessions:n=e,activeProjectId:r,activeSessionId:i,onNewSession:a,onNewSessionInProject:o,onProjectSelect:s,onResumeSession:c,onCreateProject:l,onForkSessionIntoProject:u,onOpenPanelAction:d,onBrowseDirectories:f,createOpen:p,expandedProjectIds:m,revealedProjectIds:h,setExpandedProjectIds:g,setRevealedProjectIds:_,setSearchOpen:v,setDirectoryBrowser:y,setDirectoryBrowseLoading:b,setDirectoryBrowseError:x,setDirectoryToken:S,setCreatePath:C,setRenameTarget:w,setRenameTitle:T,setForkTarget:E,setForkProjectId:D,setDeleteTarget:O,setRenameProjectTarget:k,setRenameProjectName:A,setUnregisterTarget:j,createPath:M,directoryToken:N,createName:P,setCreateName:F,setCreateOpen:I,setCreateSubmitError:L,setCreateSubmitting:R}){let z=(0,Z.useRef)(!1),B=(0,Z.useCallback)(async e=>{if(!f)return!1;b(!0),x(null);try{let t=await f(e);return y(t),S(t.directoryToken),C(t.pathLabel),!0}catch(e){return x(Ic(e,`Could not browse this directory.`)),!1}finally{b(!1)}},[f,C,x,b,y,S]);(0,Z.useEffect)(()=>{let e=p&&!z.current;z.current=p,!(!e||!f)&&B({})},[p,B,f]);let V=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.projectId,e])),[t]),H=(0,Z.useMemo)(()=>Uc(t,n),[n,t]);(0,Z.useEffect)(()=>{if(!r)return;let e=Oc(r);g(t=>t.includes(e)?t:[...t,e])},[r,g]),(0,Z.useEffect)(()=>{window.localStorage.setItem(Cc,JSON.stringify(m))},[m]);let U=(0,Z.useMemo)(()=>{let e=H.map(e=>{let t=Bc(n.filter(t=>t.projectId===e.projectId),i),r=h.has(e.projectId),a=Hc(t,i,r).map(e=>({id:kc(e.sessionId),label:Mc(e),kind:`file`}));return t.length===0?a.push({id:Ac(e.projectId),label:`Start first chat`,kind:`action`}):t.length>5&&a.push({id:`toggle:${e.projectId}`,label:r?`Show less`:`Show more`,kind:`action`}),{id:Oc(e.projectId),label:e.name,kind:`project`,children:a}}),t=Vc(Bc(n.filter(e=>!e.projectId),i));if(t.length>0){let n=Hc(t,i,h.has(`unassigned`)).map(e=>({id:kc(e.sessionId),label:Mc(e),kind:`file`}));t.length>5&&n.push({id:`toggle:unassigned`,label:h.has(`unassigned`)?`Show less`:`Show more`,kind:`action`}),e.push({id:`project:unassigned`,label:`Unassigned`,kind:`folder`,children:n})}return e},[i,n,h,H]),ee=(0,Z.useCallback)(e=>{o?o(e):(s?.(e),a())},[a,o,s]);return{loadDirectories:B,projectById:V,sortedProjects:H,sidebarItems:U,resumeResource:(0,Z.useCallback)(e=>{let t=jc(e,`toggle:`);if(t){_(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});return}let r=jc(e,Tc);if(r){ee(r);return}let i=jc(e,Dc);if(!i)return;let a=n.find(e=>e.sessionId===i);a&&c(a)},[ee,c,n,_]),toggleProjectResource:(0,Z.useCallback)(e=>{g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[g]),selectSearchResult:(0,Z.useCallback)(e=>{let t=jc(e,`search-project:`);if(t){let e=Oc(t);g(t=>t.includes(e)?t:[...t,e]),s?.(t),v(!1);return}let r=jc(e,`search-session:`),i=r?n.find(e=>e.sessionId===r):void 0;if(i){if(i.projectId){let e=Oc(i.projectId);g(t=>t.includes(e)?t:[...t,e])}c(i),v(!1)}},[s,c,n,g,v]),renderMenu:(0,Z.useCallback)((e,r)=>{let i=jc(e.id,Dc),a=jc(e.id,`project:`);if(i){let e=n.find(e=>e.sessionId===i);if(!e)return null;let a=e.projectId??void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gc,{icon:Jo,label:`Rename`,onClick:()=>{r.close(),w(e),T(Mc(e))}}),u&&t.length>1?(0,Q.jsx)(Gc,{icon:Vo,label:`Fork into project`,onClick:()=>{r.close(),E(e),D(t.find(t=>t.projectId!==e.projectId)?.projectId)}}):null,d&&a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 border-t`}),Wc.map(([e,t,n])=>(0,Q.jsx)(Gc,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null,(0,Q.jsx)(Gc,{icon:vn,label:`Delete`,destructive:!0,onClick:()=>{r.close(),O(e)}})]})}if(a&&a!==`unassigned`){let e=V.get(a);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gc,{icon:Jo,label:`Rename project`,onClick:()=>{r.close(),k(e),A(e.name)}}),(0,Q.jsx)(Gc,{icon:es,label:`Unregister project`,destructive:!0,onClick:()=>{r.close(),j(e)}}),d?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 border-t`}),Wc.map(([e,t,n])=>(0,Q.jsx)(Gc,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null]}):null}return null},[u,d,V,n,t,O,D,E,A,k,w,T,j]),submitCreate:async()=>{let e=M.trim();if(!(!l||!e&&!N)){R(!0),L(null);try{await l({path:N?void 0:e,directoryToken:N,name:P.trim()||void 0}),I(!1),C(``),F(``),S(void 0),y(null),x(null)}catch(e){L(Ic(e,`Could not add this project.`))}finally{R(!1)}}}}}var qc=Z.createContext(void 0);function Jc(e){let t=Z.useContext(qc);if(t===void 0&&!e)throw Error(st(47));return t}var Yc={...St,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Xc=class extends z{constructor(e,t,n){let r=new Tt;super(Zc(e,r,t,n),Qc(r),Yc)}setOpen=(e,t)=>{let n=t.reason===et,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=vt(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};wt(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Gs.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Zc(e,t,n,r=!1){let i={...At(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Mt(t,n,r),i}function Qc(e){return{popupRef:Z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),stickIfOpenTimeout:new O,triggerElements:e}}function $c({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=tl(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Zt(u,d),It(u);let{forceUnmount:m}=Rt(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),Z.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Z.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,it(Ze))}),[m,u]);let h=d||f;return(0,Q.jsxs)(qc.Provider,{value:u,children:[s&&(0,Q.jsx)(Pt,{handle:s,store:u}),h&&(0,Q.jsx)(nl,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function el(e){return Jc(!0)?(0,Q.jsx)($c,{props:e}):(0,Q.jsx)(gt,{children:(0,Q.jsx)($c,{props:e})})}function tl(e,t){let n=Dt((e,n)=>new Xc(t,e,n));return Z.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function nl({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=zt(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Ct(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}function rl(e,t){let n=Z.useRef(null);function r(t){Gs.flushSync(()=>{e.setOpen(!1,it(ct,t.nativeEvent,t.currentTarget))}),ee(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&k(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{Gs.flushSync(()=>{e.setOpen(!1,it(ct,n.nativeEvent,n.currentTarget))});let i=M(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&T(r,i);){let e=i;if(i=U(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var il=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=Jc(!0),h=bn(s)??m;if(!h)throw Error(st(74));let g=gn(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=Z.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Et(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=kn(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:xn(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=rn(v,{stickIfOpen:T}),A=sn(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:P}=mt({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?Jt.open(e):kt.open(e)}},{preFocusGuardRef:I,handlePreFocusGuardFocus:R,handleFocusTargetFocus:z}=rl(h,x),B=nt(`button`,e,{state:{disabled:a,open:y},ref:[P,t,S,x],props:[k.reference,O,j,A,{[N]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:F}),V=(0,Q.jsx)(Z.Fragment,{children:B},g);return C&&!D?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(L,{ref:I,onFocus:R}),V,(0,Q.jsx)(L,{ref:h.context.triggerFocusTargetRef,onFocus:z})]}):V}),al=Z.createContext(void 0);function ol(){let e=Z.useContext(al);if(e===void 0)throw Error(st(45));return e}var sl=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Jc().useState(`mounted`)||n?(0,Q.jsx)(al.Provider,{value:n,children:(0,Q.jsx)(V,{ref:t,...r})}):null}),cl=Z.createContext(void 0);function ll(){let e=Z.useContext(cl);if(!e)throw Error(st(46));return e}var ul=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=F,..._}=e,v=Jc(),y=ol(),b=Wt(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=Z.useRef(null),N=Ye(O),P=hn({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),I=x.useState(`domReferenceElement`);tt(()=>{let e=I,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,N,v]);let L=E===!0&&w!==`trigger-hover`;un(C&&L,D===`touch`,O,T);let R=v.useStateSetter(`positionerElement`),z={open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},V=an(e,z,{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,R],hidden:!S,inert:!C});return(0,Q.jsxs)(cl.Provider,{value:P,children:[S&&L&&(0,Q.jsx)(nn,{inert:B(!C),cutout:T}),(0,Q.jsx)(Nt,{id:b,children:V})]})}),dl=Z.createContext(void 0);function fl(){let[e,t]=Z.useState(0),n=dt(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var pl=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Jc(),l=ll(),u=pn(!0)!=null,{context:d,hasClosePart:f}=fl(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);ft({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),_n(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Lt(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},N=nt(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Ot,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&en.has(e.key)&&e.stopPropagation()}},mn(g),s],stateAttributesMapping:_t});return(0,Q.jsx)(Bt,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ot(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Q.jsx)(dl.Provider,{value:d,children:N})})}),ml=2;function hl({...e}){return(0,Q.jsx)(el,{"data-slot":`popover`,...e})}function gl({...e}){return(0,Q.jsx)(il,{"data-slot":`popover-trigger`,...e})}function _l({className:e,children:t,align:n=`center`,alignOffset:r=0,side:i=`bottom`,sideOffset:a=4,...o}){let s=Gt(),c=Math.min(s+ml,8);return(0,Q.jsx)(sl,{children:(0,Q.jsx)(ul,{align:n,alignOffset:r,side:i,sideOffset:a,className:`isolate z-50`,children:(0,Q.jsx)(pl,{"data-slot":`popover-content`,className:q(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg p-2.5 text-sm text-popover-foreground outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,Vt(c,3),e),...o,children:(0,Q.jsx)(Kt,{value:c,children:t})})})})}function vl({trigger:e,children:t,contentId:n,open:r,defaultOpen:i,onOpenChange:a,side:o=`top`,align:s=`start`,sideOffset:c=6,className:l,overlay:u=!1}){let d=(0,Z.useId)(),f=n??d,[p,m]=(0,Z.useState)(i??!1),h=r??p;return(0,Q.jsxs)(hl,{open:h,onOpenChange:e=>{r===void 0&&m(e),a?.(e)},children:[(0,Z.isValidElement)(e)?(0,Q.jsx)(gl,{render:e,"aria-controls":f,className:`inline-flex`}):(0,Q.jsx)(gl,{render:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,children:e}),"aria-controls":f,className:`inline-flex`}),u&&h?(0,Q.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/20`,"aria-hidden":`true`}):null,(0,Q.jsx)(_l,{id:f,side:o,align:s,sideOffset:c,className:q(`max-h-[min(320px,var(--available-height,320px))] max-w-[calc(100vw-16px)] min-w-[180px] overflow-y-auto overscroll-contain p-1`,l),children:t})]})}function yl({threads:e,query:t,activeId:n,onQueryChange:r,onSelect:i,className:a,...o}){let s=e.filter(e=>`${e.title} ${e.preview} ${(e.keywords??[]).join(` `)}`.toLowerCase().includes(t.toLowerCase())),c=s.filter(e=>e.pinned),l=[...new Set(s.flatMap(e=>e.pinned?[]:[e.group]))],u=[...c,...l.flatMap(e=>s.filter(t=>!t.pinned&&t.group===e))],[d,f]=(0,Z.useState)(null),p=e=>{if(u.length===0)return;let t=u.findIndex(e=>e.id===d),n=u[((t===-1?e>0?-1:0:t)+e+u.length)%u.length];f(n?n.id:null)},m=e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),p(1)):e.key===`ArrowUp`?(e.preventDefault(),p(-1)):e.key===`Enter`&&d&&(e.preventDefault(),i?.(d)))},h=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{f(e.id),i?.(e.id)},className:q(`flex flex-col gap-0.5 rounded-xl px-2 py-1 text-start transition-colors`,e.id===d?`bg-foreground/[0.05]`:e.id===n?`bg-foreground/[0.02] hover:bg-foreground/[0.03]`:`hover:bg-foreground/[0.03]`),children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.pinned&&(0,Q.jsx)(Yo,{className:`text-foreground/30 size-2.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title})]}),(0,Q.jsx)(`span`,{className:`text-foreground/35 truncate text-xs`,children:e.preview})]},e.id);return(0,Q.jsxs)(`div`,{"data-slot":`thread-search`,className:q(nr,`flex w-full max-w-sm flex-col gap-1.5 rounded-2xl p-3`,a),...o,children:[(0,Q.jsxs)(`div`,{className:q(cr,`flex items-center gap-2 rounded-xl px-2.5 py-1.5`),children:[(0,Q.jsx)(bi,{className:`text-foreground/30 size-3.5 shrink-0`}),(0,Q.jsx)(`input`,{value:t,onChange:e=>{f(null),r?.(e.target.value)},onKeyDown:m,placeholder:`Search threads`,"aria-label":`Search threads`,className:`text-foreground/85 placeholder:text-foreground/30 min-w-0 flex-1 bg-transparent text-base outline-none md:text-[13px]`})]}),c.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:q(`font-mono text-[11px] tracking-tight`,`text-foreground/25 px-2 pb-1`),children:`pinned`}),c.map(h)]}),l.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:q(rr,`text-foreground/25 px-2 pb-1`),children:e}),s.flatMap(t=>!t.pinned&&t.group===e?[h(t)]:[])]},e)),s.length===0&&(0,Q.jsxs)(`span`,{className:`text-foreground/30 px-2 py-4 text-center text-xs`,children:[`No thread matches “`,t,`”`]})]})}function bl(e,t){return e?.trigger.left===t.trigger.left&&e.trigger.top===t.trigger.top&&e.trigger.width===t.trigger.width&&e.trigger.height===t.trigger.height&&e.content.width===t.content.width&&e.content.height===t.content.height}function xl(e,t,n){let[r,i]=(0,Z.useState)(null),a=(0,Z.useCallback)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let a=n.getBoundingClientRect(),o={trigger:{left:a.left,top:a.top,width:a.width,height:a.height},content:{width:r.offsetWidth,height:r.offsetHeight}};i(e=>bl(e,o)?e:o)},[t,e]);return(0,Z.useLayoutEffect)(()=>{if(a(),!n)return;let r=e.current,i=t.current,o=new ResizeObserver(a);return r&&o.observe(r),i&&o.observe(i),window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{o.disconnect(),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a)}},[n,t,e,a]),r}function Sl(){return()=>{}}function Cl(){return!0}function wl(){return!1}function Tl(){return(0,Z.useSyncExternalStore)(Sl,Cl,wl)}var El=(0,Z.createContext)(null);function Dl(e){let t=(0,Z.useContext)(El);if(!t)throw Error(`${e} must be used within <MorphPopover>`);return t}function Ol({children:e,open:t,defaultOpen:n=!1,onOpenChange:r,className:i}){let a=(0,Z.useId)(),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(n),d=t!==void 0,f=d?t:l,p=(0,Z.useCallback)(e=>{d||u(e),r?.(e)},[d,r]),m=(0,Z.useCallback)(()=>p(!f),[p,f]),h=(0,Z.useEffectEvent)(p);(0,Z.useEffect)(()=>{if(!f)return;let e=e=>e.key===`Escape`&&h(!1),t=e=>{let t=e.target;o.current&&!o.current.contains(t)&&!c.current?.contains(t)&&h(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t)}},[f]);let g=(0,Z.useMemo)(()=>({open:f,setOpen:p,toggle:m,triggerId:`${a}-trigger`,contentId:`${a}-content`,triggerRef:s,contentRef:c}),[f,p,m,a]);return(0,Q.jsx)(El.Provider,{value:g,children:(0,Q.jsx)(`div`,{ref:o,className:q(`relative inline-flex`,i),children:e})})}function kl(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function Al({children:e}){let t=Dl(`MorphPopoverTrigger`);if(!(0,Z.isValidElement)(e))return e;let n=e,r=n.props.onClick,i=n.props.ref;return(0,Z.cloneElement)(n,{id:t.triggerId,ref:kl(i,e=>{t.triggerRef.current=e}),onClick:e=>{r?.(e),t.toggle()},"aria-haspopup":`dialog`,"aria-expanded":t.open,"aria-controls":t.open?t.contentId:void 0})}var jl=(e,t)=>`${e===`bottom`?`top`:`bottom`} ${t===`end`?`right`:`left`}`;function Ml(e,t,n){return`inset(${e===`bottom`?`0%`:`92%`} ${t===`end`?`0%`:`92%`} ${e===`bottom`?`92%`:`0%`} ${t===`end`?`92%`:`0%`} round ${n}px)`}var Nl=e=>`inset(0% 0% 0% 0% round ${e}px)`,Pl={duration:.32,ease:Ue};function Fl({children:e,side:t=`bottom`,align:n=`end`,sideOffset:r=8,radius:i=16,className:a}){let o=Dl(`MorphPopoverContent`),s=K()??!1,c=Tl(),l=xl(o.triggerRef,o.contentRef,c&&o.open),u=l?n===`end`?l.trigger.left+l.trigger.width-l.content.width:l.trigger.left:0,d=l?t===`bottom`?l.trigger.top+l.trigger.height+r:l.trigger.top-l.content.height-r:0,f=s?void 0:{hidden:{opacity:0,scale:.96,transition:Fe},show:{opacity:1,scale:1,transition:Fe}},p=s?void 0:{hidden:{clipPath:Ml(t,n,i),transition:Pl},show:{clipPath:Nl(i),transition:Pl}};return c?(0,Gs.createPortal)((0,Q.jsx)(Be,{children:o.open?(0,Q.jsx)(G.div,{"data-morph-popover-portal":``,variants:f,initial:s?{opacity:0}:`hidden`,animate:s?{opacity:1}:`show`,exit:s?{opacity:0}:`hidden`,transition:s?{duration:.12}:void 0,style:{left:u,top:d,visibility:l?`visible`:`hidden`,transformOrigin:jl(t,n)},className:`fixed z-[9999] [filter:drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]`,children:(0,Q.jsx)(G.div,{ref:o.contentRef,id:o.contentId,role:`dialog`,"aria-labelledby":o.triggerId,variants:p,style:{borderRadius:i},className:q(`overflow-hidden border border-border bg-background`,a),children:e})}):null}),document.body):null}var Il={duration:.16,ease:Ue},Ll=[],Rl=[];function zl(e){return e.kind===`folder`||e.kind===`project`}function Bl(e,t,n=0,r=null){return e.flatMap(e=>{let i={item:e,depth:n,parentId:r};return!e.children?.length||!t.has(e.id)?[i]:[i,...Bl(e.children,t,n+1,e.id)]})}function Vl(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?Vl(n.children,t):void 0;if(e)return e}}function Hl(e,t){return e.id===t||e.children?.some(e=>Hl(e,t))===!0}function Ul(e,t){let n,r=[];for(let i of e){if(i.id===t){n=i;continue}if(i.children?.length){let e=Ul(i.children,t);if(e.removed){n=e.removed,r.push({...i,children:e.items});continue}}r.push(i)}return{items:r,removed:n}}function Wl(e,t,n,r){if(n===null)return[...e,t];let i=[];for(let a of e){if(a.id===n){r===`before`?i.push(t,a):r===`after`?i.push(a,t):i.push({...a,children:[...a.children??[],t]});continue}a.children?.length?i.push({...a,children:Wl(a.children,t,n,r)}):i.push(a)}return i}function Gl(e,t){let n=Vl(e,t.itemId);if(!n||n.disabled||t.targetId&&Hl(n,t.targetId))return null;let r=t.targetId?Vl(e,t.targetId):void 0;if(t.position===`inside`&&(!r||r.disabled||!zl(r)))return null;let i=Ul(e,t.itemId);return i.removed?Wl(i.items,i.removed,t.targetId,t.position):null}function Kl(e,t,n){return e.map(e=>({...e,label:e.id===t?n:e.label,children:e.children?Kl(e.children,t,n):void 0}))}function ql(e,t){if(e.kind===`action`)return null;let n=e.kind===`folder`||e.kind===`project`?t?li:di:e.kind===`bookmark`?jo:zr;return(0,Q.jsx)(n,{className:`size-4`})}function Jl({active:e,children:t}){let n=K()??!1,r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=()=>{let e=r.current,t=i.current;!e||!t||o(t.scrollWidth>e.clientWidth?t.scrollWidth+24:0)};e();let t=new ResizeObserver(e);return r.current&&t.observe(r.current),i.current&&t.observe(i.current),()=>t.disconnect()},[]);let s=e&&a>0&&!n;return(0,Q.jsx)(`span`,{ref:r,className:`block min-w-0 flex-1 overflow-hidden`,children:(0,Q.jsxs)(G.span,{className:`flex w-max items-center gap-6 whitespace-nowrap`,animate:{x:s?[0,-a]:0},transition:s?{duration:Math.max(2.4,a/34),ease:`linear`,repeat:1/0,repeatDelay:2}:Il,children:[(0,Q.jsx)(`span`,{ref:i,children:t}),s?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:t}):null]})})}function Yl({row:e,active:t,containerActive:n,expanded:r,focused:i,draggingId:a,dropTarget:o,menuOpen:s,renaming:c,onDragEnd:l,onDragOver:u,onDragStart:d,onDrop:f,onFocus:p,onKeyDown:m,onMenuOpenChange:h,onRenameCancel:g,onRenameCommit:_,onRenameStart:v,onSelect:y,onContainerSelect:b,allowMove:x,renderIcon:S,renderSecondaryAction:C,renderMenu:w,setRef:T}){let E=K()??!1,[D,O]=(0,Z.useState)(!1),k=(0,Z.useRef)(null),A=(0,Z.useRef)(!1),j=(0,Z.useRef)(!1),[M,N]=(0,Z.useState)(e.item.label),P=zl(e.item),F=S?.(e.item),I=F===void 0?ql(e.item,r):F,L=a===e.item.id,R=o?.id===e.item.id?o.position:null;(0,Z.useEffect)(()=>{c&&(A.current=!1,N(e.item.label),requestAnimationFrame(()=>{k.current?.focus(),k.current?.select()}))},[c,e.item.label]);let z=w?.(e.item,{close:()=>h(!1),rename:()=>{h(!1),v()}})??(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{h(!1),v()},className:`flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Q.jsx)(Jo,{"aria-hidden":`true`,className:`size-3.5`}),`Rename`]});return(0,Q.jsxs)(G.div,{ref:T,layout:`position`,transition:E?{duration:0}:He,role:`treeitem`,"aria-level":e.depth+1,"aria-selected":P?void 0:t,"aria-expanded":P?r:void 0,"aria-disabled":e.item.disabled||void 0,tabIndex:i?0:-1,draggable:x&&!e.item.disabled&&!c,"data-menu-open":s||void 0,"data-kind":e.item.kind,"data-drop":R??void 0,"data-dragging":L||void 0,onFocus:p,onKeyDown:m,onClick:t=>{t.defaultPrevented||j.current||c||e.item.disabled||(P?b():y())},onDoubleClick:t=>{P||e.item.kind===`action`||e.item.disabled||(t.preventDefault(),v())},onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),onDragStartCapture:t=>{x&&(j.current=!0,d(t,e.item.id))},onDragEndCapture:()=>{l(),requestAnimationFrame(()=>{j.current=!1})},onDragOver:t=>{x&&u(t,e)},onDrop:e=>{x&&f(e)},className:q(`group/resource relative flex min-h-8 min-w-0 cursor-pointer items-center gap-2 rounded-lg pr-2 text-[13px] outline-none`,`text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,`focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,`data-[menu-open=true]:bg-muted data-[menu-open=true]:text-foreground`,`data-[dragging=true]:opacity-40`,`data-[drop=inside]:bg-primary/10 data-[drop=inside]:ring-1 data-[drop=inside]:ring-primary/45`,`data-[drop=before]:before:absolute data-[drop=before]:before:-top-0.5 data-[drop=before]:before:right-2 data-[drop=before]:before:left-2 data-[drop=before]:before:h-0.5 data-[drop=before]:before:rounded-full data-[drop=before]:before:bg-primary`,`data-[drop=after]:after:absolute data-[drop=after]:after:-bottom-0.5 data-[drop=after]:after:right-2 data-[drop=after]:after:left-2 data-[drop=after]:after:h-0.5 data-[drop=after]:after:rounded-full data-[drop=after]:after:bg-primary`,!P&&t&&`bg-muted text-foreground`,P&&n&&`bg-muted/55 text-foreground ring-1 ring-border/70`,e.item.kind===`action`&&`text-xs text-muted-foreground`,e.item.disabled&&`cursor-not-allowed opacity-45`),style:{paddingLeft:`${8+e.depth*14}px`},children:[I===null?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center`,children:I}),c?(0,Q.jsx)(`input`,{ref:k,value:M,"aria-label":`Rename ${e.item.label}`,onChange:e=>N(e.target.value),draggable:!1,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onBlur:()=>{A.current||_(M)},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(A.current=!0,_(M)),e.key===`Escape`&&(A.current=!0,g())},className:`mx-1 h-7 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-base text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring md:text-sm`}):(0,Q.jsx)(Jl,{active:D||s,children:e.item.label}),c?null:C?.(e.item),!c&&!e.item.disabled&&e.item.kind!==`action`?(0,Q.jsxs)(Ol,{open:s,onOpenChange:h,children:[(0,Q.jsx)(Al,{children:(0,Q.jsx)(`button`,{type:`button`,draggable:!1,tabIndex:-1,"aria-label":`Actions for ${e.item.label}`,onClick:e=>e.stopPropagation(),className:`grid size-7 shrink-0 place-items-center rounded-lg opacity-0 outline-none transition-opacity hover:bg-foreground/5 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring group-hover/resource:opacity-100 group-data-[menu-open=true]/resource:opacity-100`,children:(0,Q.jsx)(Ro,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(Fl,{side:`bottom`,align:`end`,sideOffset:8,radius:12,className:`w-40 p-1.5`,children:(0,Q.jsx)(`div`,{"data-sidebar-resource-menu":e.item.id,children:z})})]}):null]})}function Xl({flat:e,selectedId:t,activeContainerId:n,expandedIds:r,focusedId:i,draggingId:a,dropTarget:o,menuOpenId:s,renamingId:c,allowMove:l,announcement:u,ariaLabel:d,className:f,renderIcon:p,renderSecondaryAction:m,renderMenu:h,onFocus:g,onSelect:_,onContainerSelect:v,onKeyDown:y,onRenameStart:b,onRenameCancel:x,onRenameCommit:S,onMenuOpenChange:C,onDragStart:w,onDragEnd:T,onDragOver:E,onRootDragOver:D,onDrop:O,setRef:k}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`tree`,"aria-label":d,"aria-multiselectable":`false`,onDragOver:D,onDrop:O,className:q(`relative flex min-w-0 flex-col gap-0.5 [overflow-anchor:none] group-data-[state=collapsed]/sidebar:hidden`,a&&`select-none pb-9`,f),children:[(0,Q.jsx)(Be,{initial:!1,children:e.map(e=>(0,Q.jsx)(Yl,{row:e,active:t===e.item.id,containerActive:n===e.item.id,expanded:r.has(e.item.id),focused:i===e.item.id,draggingId:a,dropTarget:o,menuOpen:s===e.item.id,renaming:c===e.item.id,onFocus:()=>g(e.item.id),onSelect:()=>_(e.item.id),onContainerSelect:()=>v(e.item.id),allowMove:l,onKeyDown:t=>y(t,e),onRenameStart:()=>b(e.item.id),onRenameCancel:x,onRenameCommit:t=>S(e,t),onMenuOpenChange:t=>C(e.item.id,t),onDragStart:w,onDragEnd:T,onDragOver:(e,t)=>E(e,t),onDrop:O,renderIcon:p,renderSecondaryAction:m,renderMenu:h,setRef:t=>k(e.item.id,t)},e.item.id))}),a?(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-active":o?.id===null||void 0,className:`absolute inset-x-1 bottom-0 flex h-8 items-center justify-center rounded-lg border border-dashed border-border text-[10px] text-muted-foreground data-[active=true]:border-primary/50 data-[active=true]:bg-primary/10 data-[active=true]:text-foreground`,children:`Move to top level`}):null]}),(0,Q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})}function Zl({expandedIds:e,flat:t,focusRow:n,onContainerSelect:r,performMove:i,select:a,setMenuOpenId:o,setRenamingId:s,toggle:c,updateExpandedIds:l}){return(0,Z.useCallback)((u,d)=>{let f=t.findIndex(({item:e})=>e.id===d.item.id),p=t[f-1],m=t[f+1],h=u.altKey&&u.shiftKey;if(u.key===`ArrowDown`&&!h&&m){u.preventDefault(),n(m.item.id);return}if(u.key===`ArrowUp`&&!h&&p){u.preventDefault(),n(p.item.id);return}if(u.key===`Home`&&t[0]){u.preventDefault(),n(t[0].item.id);return}if(u.key===`End`&&t.at(-1)){u.preventDefault(),n(t.at(-1)?.item.id??d.item.id);return}if(d.item.disabled){u.key===`ArrowLeft`&&d.parentId?(u.preventDefault(),n(d.parentId)):(h||[`ArrowRight`,`Enter`,` `,`F2`,`ContextMenu`].includes(u.key)||u.shiftKey&&u.key===`F10`)&&u.preventDefault();return}if(h&&u.key===`ArrowUp`&&p){u.preventDefault(),i({itemId:d.item.id,targetId:p.item.id,position:`before`});return}if(h&&u.key===`ArrowDown`&&m){u.preventDefault(),i({itemId:d.item.id,targetId:m.item.id,position:`after`});return}if(h&&u.key===`ArrowRight`&&p&&zl(p.item)){u.preventDefault(),l(e=>new Set(e).add(p.item.id)),i({itemId:d.item.id,targetId:p.item.id,position:`inside`});return}if(h&&u.key===`ArrowLeft`&&d.parentId){u.preventDefault(),i({itemId:d.item.id,targetId:d.parentId,position:`after`});return}u.key===`ArrowRight`&&zl(d.item)?(u.preventDefault(),e.has(d.item.id)?m?.parentId===d.item.id&&n(m.item.id):c(d.item.id)):u.key===`ArrowLeft`?(u.preventDefault(),e.has(d.item.id)?c(d.item.id):d.parentId&&n(d.parentId)):u.key===`Enter`||u.key===` `?(u.preventDefault(),zl(d.item)?r?r(d.item.id):c(d.item.id):a(d.item.id)):u.key===`F2`&&d.item.kind!==`action`?(u.preventDefault(),s(d.item.id)):(u.key===`ContextMenu`||u.shiftKey&&u.key===`F10`)&&(u.preventDefault(),o(d.item.id))},[e,t,n,r,i,a,o,s,c,l])}function Ql({items:e,defaultItems:t=Ll,onItemsChange:n,onMove:r,onMoveError:i,allowMove:a=!0,onRename:o,activeId:s,activeContainerId:c,defaultActiveId:l=null,onActiveChange:u,onContainerSelect:d,expandedIds:f,defaultExpandedIds:p=Rl,onExpandedIdsChange:m,renderIcon:h,renderSecondaryAction:g,renderMenu:_,ariaLabel:v=`Resources`,className:y}){let[b,x]=(0,Z.useState)(e??t),[S,C]=(0,Z.useState)(l),[w,T]=(0,Z.useState)(()=>new Set(p)),[E,D]=(0,Z.useState)(s??l),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(``),R=(0,Z.useRef)(new Map),z=(0,Z.useRef)(!1),B=b,V=s??S,H=(0,Z.useMemo)(()=>f===void 0?w:new Set(f),[f,w]);(0,Z.useEffect)(()=>{e&&x(e)},[e]),(0,Z.useEffect)(()=>{f===void 0&&p.length!==0&&T(e=>{let t=new Set(e),n=!1;for(let e of p)t.has(e)||(t.add(e),n=!0);return n?t:e})},[f,p]);let U=(0,Z.useMemo)(()=>Bl(B,H),[H,B]);(0,Z.useEffect)(()=>{E&&U.some(e=>e.item.id===E)||D(U[0]?.item.id??null)},[U,E]),(0,Z.useEffect)(()=>{if(!M)return;let e=requestAnimationFrame(()=>{Array.from(document.querySelectorAll(`[data-sidebar-resource-menu]`)).find(e=>e.dataset.sidebarResourceMenu===M)?.querySelector(`button, a[href]`)?.focus()});return()=>cancelAnimationFrame(e)},[M]);let ee=(0,Z.useCallback)(e=>{x(e),n?.(e)},[n]),W=(0,Z.useCallback)(async e=>{if(z.current){L(`Wait for the current move to finish.`);return}let t=B,n=Gl(t,e);if(!n||n===t)return;z.current=!0,ee(n),j(null),k(null);let a=Vl(t,e.itemId),o=e.targetId?Vl(t,e.targetId):null;L(o?`Moved ${a?.label??`item`} ${e.position} ${o.label}.`:`Moved ${a?.label??`item`} to the top level.`);try{await r?.(e)}catch(n){ee(t),L(`Move failed. ${a?.label??`Item`} was restored.`),i?.(n,e)}finally{z.current=!1}},[r,i,B,ee]),te=(0,Z.useCallback)(e=>{D(e),requestAnimationFrame(()=>R.current.get(e)?.focus())},[]),ne=(0,Z.useCallback)(e=>{s===void 0&&C(e),u?.(e)},[s,u]),re=(0,Z.useCallback)(e=>{let t=e(new Set(H));f===void 0&&T(t),m?.([...t])},[f,H,m]),ie=(0,Z.useCallback)(e=>{re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[re]),ae=Zl({expandedIds:H,flat:U,focusRow:te,onContainerSelect:d,performMove:W,select:ne,setMenuOpenId:N,setRenamingId:F,toggle:ie,updateExpandedIds:re});return(0,Q.jsx)(Xl,{flat:U,selectedId:V,activeContainerId:c,expandedIds:H,focusedId:E,draggingId:O,dropTarget:A,menuOpenId:M,renamingId:P,allowMove:a,announcement:I,ariaLabel:v,className:y,renderIcon:h,renderSecondaryAction:g,renderMenu:_,onFocus:D,onSelect:ne,onContainerSelect:e=>{d?d(e):ie(e)},onKeyDown:ae,onRenameStart:F,onRenameCancel:()=>F(null),onRenameCommit:(e,t)=>{let n=t.trim();if(F(null),!n||n===e.item.label)return;let r=B;ee(Kl(r,e.item.id,n)),Promise.resolve(o?.(e.item,n)).catch(()=>{ee(r),L(`Rename failed. ${e.item.label} was restored.`)})},onMenuOpenChange:(e,t)=>{N(t?e:null),t||te(e)},onDragStart:(e,t)=>{k(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},onDragEnd:()=>{k(null),j(null)},onDragOver:(e,t)=>{if(!O||O===t.item.id)return;let n=Vl(B,O);if(n&&Hl(n,t.item.id))return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget.getBoundingClientRect(),i=(e.clientY-r.top)/r.height,a=!t.item.disabled&&zl(t.item)&&i>=.25&&i<=.75?`inside`:i<.5?`before`:`after`;j({id:t.item.id,position:a})},onRootDragOver:e=>{!O||e.target!==e.currentTarget||(e.preventDefault(),j({id:null,position:`after`}))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),O&&A&&W({itemId:O,targetId:A.id,position:A.position})},setRef:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}})}var $l=5,eu=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function tu(e,t){let n=e-(t-1)/2,r=Math.abs(n),i=Math.max(0,2-r)*8;return{x:n*44,y:8-i,rotate:n*6,scale:r===0?1.04:r===1?.95:.88,opacity:r===0?1:r===1?.78:.58,zIndex:10-r}}function nu({title:e,countText:t,dialogTitleId:n,previewItems:r,isExpanded:i,isClosing:a,reduce:o,transition:s,dialogRef:c,closeButtonRef:l,closeOverlay:u}){return!i&&!a?null:(0,Q.jsxs)(`div`,{ref:c,role:`dialog`,"aria-modal":`true`,"aria-labelledby":n,"aria-hidden":i?void 0:`true`,className:q(`fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center`,a&&`pointer-events-none`),children:[(0,Q.jsx)(Be,{initial:!1,children:i?(0,Q.jsx)(G.button,{type:`button`,tabIndex:-1,"aria-label":`Close file overlay`,onClick:u,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:o?{duration:0}:{duration:.18},className:`absolute inset-0 cursor-default bg-background/80 backdrop-blur-xl`},`project-files-backdrop`):null}),(0,Q.jsxs)(`div`,{className:`relative z-10 w-full max-w-5xl px-6 py-8`,children:[(0,Q.jsx)(Be,{initial:!1,children:i?(0,Q.jsxs)(G.div,{initial:{opacity:0,y:o?0:8},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:-8},transition:o?{duration:0}:{duration:.18},className:`mb-6 flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{id:n,className:`text-xl font-medium text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,Q.jsx)(`button`,{ref:l,type:`button`,onClick:u,"aria-label":`Close ${e}`,className:`flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(ut,{className:`size-4`,"aria-hidden":`true`})})]},`project-files-header`):null}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:i?r.map(e=>(0,Q.jsx)(G.div,{layoutId:`file-${e.id}`,transition:s,className:`aspect-[3/4] w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl`,children:e.content},e.id)):null})]})]})}function ru({title:e,description:t=`Updated recently`,previews:n=[],count:r=n.length,itemLabel:i=`file`,open:a,defaultOpen:o=!1,onOpenChange:s,expanded:c,defaultExpanded:l=!1,onExpandedChange:u,onClick:d,disabled:f=!1,ariaLabel:p,className:m}){let h=K(),g=ar(),_=(0,Z.useId)(),v=`${_}-title`,y=(0,Z.useRef)(!1),b=(0,Z.useRef)(!1),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=Tl(),[E,D]=(0,Z.useState)(o),[O,k]=(0,Z.useState)(l),[A,j]=(0,Z.useState)(!1),M=a!==void 0,N=c!==void 0,P=c??O,F=(a??E)||P,I=n.slice(0,$l),L=h?{duration:0}:He,R=`${r} ${i}${r===1?``:`s`}`,z=(0,Z.useCallback)(e=>{f||(M||D(e),s?.(e))},[f,s,M]),B=(0,Z.useCallback)(e=>{f||I.length===0||(N||k(e),u?.(e))},[f,N,u,I.length]),V=(0,Z.useCallback)(()=>{j(!1),x.current=!0,requestAnimationFrame(()=>S.current?.focus())},[]),H=(0,Z.useCallback)(()=>{j(!0),z(!1),B(!1)},[B,z]),U=(0,Z.useEffectEvent)(H);(0,Z.useEffect)(()=>{h&&A&&V()},[V,A,h]),(0,Z.useEffect)(()=>{if(!P)return;let e=document.body.style.overflow,t=requestAnimationFrame(()=>C.current?.focus());document.body.style.overflow=`hidden`;let n=e=>{if(e.key===`Escape`){e.preventDefault(),U();return}if(e.key!==`Tab`||!w.current)return;let t=Array.from(w.current.querySelectorAll(eu)).filter(e=>e.tabIndex>=0),n=t[0],r=t.at(-1);!n||!r||(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,n),()=>{cancelAnimationFrame(t),document.body.style.overflow=e,document.removeEventListener(`keydown`,n)}},[P]);let ee=()=>{j(!1),B(!0),z(!0),d?.()},W=(0,Q.jsx)(nu,{title:e,countText:R,dialogTitleId:v,previewItems:I,isExpanded:P,isClosing:A,reduce:h??!1,transition:L,dialogRef:w,closeButtonRef:C,closeOverlay:H});return(0,Q.jsxs)(qa,{id:_,children:[(0,Q.jsxs)(G.button,{ref:S,type:`button`,disabled:f,"aria-label":p,"aria-haspopup":`dialog`,"aria-expanded":P,"data-open":F?`true`:`false`,"data-expanded":P?`true`:`false`,tabIndex:P?-1:void 0,onPointerEnter:()=>{g&&(y.current=!0,z(!0))},onPointerLeave:()=>{g&&(y.current=!1,!P&&!A&&z(b.current))},onFocus:()=>{if(x.current){x.current=!1,b.current=!1;return}b.current=!0,z(!0)},onBlur:()=>{b.current=!1,!P&&!A&&z(y.current)},onClick:ee,whileTap:h||f?void 0:{scale:.98},transition:h?{duration:0}:ze,className:q(`relative block h-56 w-72 select-none rounded-2xl text-left outline-none [perspective:1200px] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50`,m),children:[(0,Q.jsx)(G.span,{"aria-hidden":`true`,animate:{rotateX:F&&!h?15:0},transition:L,className:`absolute inset-0 rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl [transform-origin:center_bottom]`}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:(0,Q.jsx)(`span`,{className:`absolute left-1/2 top-0 block h-0 w-0`,children:(0,Q.jsx)(Be,{initial:!1,children:P?null:I.map((e,t)=>{let n=tu(t,I.length);return(0,Q.jsx)(G.span,{layoutId:`file-${e.id}`,initial:!1,animate:F&&!h?{x:n.x*1.4,y:n.y-8,rotate:n.rotate*1.3,scale:n.scale*1.02,opacity:Math.min(1,n.opacity+.18)}:{x:n.x,y:n.y,rotate:n.rotate,scale:n.scale,opacity:n.opacity},transition:L,onLayoutAnimationComplete:()=>{A&&t===0&&V()},className:`absolute left-0 top-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg`,style:{zIndex:n.zIndex},children:e.content},e.id)})})})}),(0,Q.jsxs)(G.span,{initial:!1,animate:{rotateX:F&&!h?-25:0},transition:L,className:`absolute inset-x-0 bottom-0 z-20 overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl [backface-visibility:hidden] [transform-origin:center_bottom]`,children:[(0,Q.jsx)(`span`,{className:`flex h-16 items-center px-4`,children:(0,Q.jsx)(`span`,{className:`line-clamp-2 text-xl font-medium leading-tight text-foreground`,children:e})}),(0,Q.jsxs)(`span`,{className:`flex h-12 items-center justify-between gap-3 border-t border-foreground/10 px-4`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/70`,children:R}),(0,Q.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:t})]})]})]}),T?(0,Gs.createPortal)(W,document.body):null]})}function iu(e){return e?.status===`running`?(0,Q.jsx)(Br,{className:`size-3.5 animate-spin`}):e?.status===`failed`?(0,Q.jsx)(ht,{className:`size-3.5 text-destructive`}):e?.status===`interrupted`?(0,Q.jsx)(Po,{className:`size-3.5 text-muted-foreground`}):null}function au({projectActionsOpen:e,setProjectActionsOpen:t,expandedProjectIds:n,setExpandedProjectIds:r,setCreateOpen:i,projects:a,projectSessions:o,sidebarItems:s,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:f,onRenameSession:p,onCreateProject:m,resumeResource:h,toggleProjectResource:g,renderMenu:_}){return(0,Q.jsx)(gc,{className:`gap-0 px-2 pb-1 pt-2`,children:(0,Q.jsxs)(vc,{className:`p-0`,children:[(0,Q.jsxs)(`div`,{className:`relative mb-1 h-8`,children:[(0,Q.jsx)(yc,{className:`mb-0 h-8 pr-16 text-xs font-normal normal-case tracking-normal text-muted-foreground`,children:`Projects`}),(0,Q.jsxs)(`div`,{className:`absolute inset-y-0 right-1 flex items-center gap-0.5`,children:[(0,Q.jsxs)(vl,{open:e,onOpenChange:t,side:`bottom`,align:`end`,className:`w-44 p-1`,trigger:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Project actions`,title:`Project actions`,className:`grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Q.jsx)(Ro,{"aria-hidden":`true`,className:`size-3.5`})}),children:[m?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{t(!1),i(!0)},className:`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none hover:bg-muted focus-visible:bg-muted`,children:[(0,Q.jsx)(Bo,{"aria-hidden":`true`,className:`size-3.5`}),`Add project`]}):null,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{t(!1),r([])},className:`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none hover:bg-muted focus-visible:bg-muted`,children:[(0,Q.jsx)(yr,{"aria-hidden":`true`,className:`size-3.5`}),`Collapse all`]})]}),m?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Add project`,title:`Add project`,onClick:()=>i(!0),className:`grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Q.jsx)(hi,{"aria-hidden":`true`,className:`size-3.5`})}):null]})]}),(0,Q.jsx)(bc,{children:a.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-4`,children:(0,Q.jsx)(ru,{title:`Add a project`,description:`Choose a local directory for Fleet Prime.`,count:0,itemLabel:`session`,previews:[{id:`empty-project`,content:(0,Q.jsx)(Bo,{className:`size-5 text-muted-foreground`})}],onClick:()=>i(!0),ariaLabel:`Add a project`,className:`w-full`})}):(0,Q.jsx)(Ql,{items:s,activeId:l?kc(l):null,activeContainerId:c?Oc(c):null,expandedIds:n,onExpandedIdsChange:r,onActiveChange:h,onContainerSelect:g,onRename:(e,t)=>{let n=jc(e.id,Dc);n&&p(n,t)},renderMenu:_,renderIcon:e=>{if(jc(e.id,`project:`))return(0,Q.jsx)(di,{className:`size-4`});if(e.kind===`action`)return null;let t=jc(e.id,Dc);return iu(o.find(e=>e.sessionId===t))},renderSecondaryAction:e=>{let t=jc(e.id,Ec);return!t||t===`unassigned`?null:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`New chat in ${e.label}`,title:`New chat in ${e.label}`,onClick:e=>{e.stopPropagation(),d?d(t):(f?.(t),u())},className:`size-7 shrink-0 opacity-0 group-hover/resource:opacity-100 group-focus-within/resource:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,Q.jsx)(Wo,{"data-icon":`inline-start`,className:`size-3.5`})})},allowMove:!1,ariaLabel:`Projects and sessions`,className:`px-0`})})]})})}var ou=`flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs outline-none transition-colors hover:bg-muted focus-visible:bg-muted`;function su({icon:e,label:t,onClick:n,href:r}){return r?(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:ou,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:ou,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]})}function cu({children:e}){return(0,Q.jsx)(`kbd`,{className:`rounded border border-border/60 bg-muted/60 px-1 font-mono text-[10px] leading-4 text-muted-foreground`,children:e})}function lu({brandMenuOpen:e,setBrandMenuOpen:t,searchOpen:n,setSearchOpen:r,query:i,setQuery:a,projectActionsOpen:o,setProjectActionsOpen:s,expandedProjectIds:c,setExpandedProjectIds:l,setCreateOpen:u,projects:d,projectSessions:f,sidebarItems:p,sortedProjects:m,projectById:h,activeProjectId:g,activeSessionId:_,onNewSession:v,onNewSessionInProject:y,onProjectSelect:b,onRenameSession:x,onCreateProject:S,onOpenSettings:C,accountMenu:w,resumeResource:T,toggleProjectResource:E,selectSearchResult:D,renderMenu:O}){let k=(0,Z.useMemo)(()=>Vc(f).map(e=>({id:e.sessionId,title:Mc(e),preview:Nc(e,h),group:Pc(e.updatedAt),keywords:e.firstMessage?[oi(e.firstMessage)]:[]})),[h,f]),A=(0,Z.useMemo)(()=>{let e=i.trim().toLowerCase();return e?m.filter(t=>`${t.name} ${t.pathLabel}`.toLowerCase().includes(e)):m},[i,m]);return(0,Q.jsx)(dc,{ariaLabel:`Fleet projects and sessions`,collapsible:`offcanvas`,variant:`floating`,className:`text-sidebar-foreground`,children:(0,Q.jsxs)(Kt,{value:2,children:[(0,Q.jsxs)(hc,{className:`gap-2 border-0 px-2.5 pb-2 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`relative flex h-9 min-w-0 items-center justify-between gap-1`,children:[(0,Q.jsxs)(vl,{open:e,onOpenChange:t,side:`bottom`,align:`start`,trigger:(0,Q.jsxs)(`button`,{type:`button`,className:`flex h-8 w-fit shrink-0 items-center gap-1 rounded-lg px-2 text-left text-sm font-medium outline-none transition-colors hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:`Qredence Fleet`}),(0,Q.jsx)(yr,{className:`size-3.5 text-muted-foreground`})]}),className:`w-52 p-1`,children:[S?(0,Q.jsx)(su,{icon:Bo,label:`Add project`,onClick:()=>{t(!1),u(!0)}}):null,(0,Q.jsx)(su,{icon:Rn,label:`Settings`,onClick:()=>{t(!1),C?.()}}),(0,Q.jsx)(su,{icon:Qn,label:`Documentation`,href:Sc})]}),(0,Q.jsx)(vl,{open:n,onOpenChange:r,side:`bottom`,align:`end`,className:`w-64 p-0`,trigger:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Search projects and sessions`,title:`Search projects and sessions`,className:`shrink-0 text-muted-foreground hover:bg-sidebar-accent`,children:(0,Q.jsx)(bi,{"data-icon":`inline-start`,className:`size-4`})}),children:(0,Q.jsxs)(`div`,{className:`max-h-[min(32rem,calc(100vh-5rem))] overflow-y-auto`,children:[(0,Q.jsx)(yl,{threads:k,query:i,activeId:_??``,onQueryChange:a,onSelect:e=>D(`search-session:${e}`),className:`max-w-none rounded-none border-0 bg-transparent p-2 shadow-none`}),(0,Q.jsxs)(`div`,{className:`border-t border-border/60 px-2 pb-2 pt-1.5`,children:[(0,Q.jsx)(`span`,{className:`px-2 pb-1 font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground/60`,children:`Projects`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5`,children:[A.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>D(`search-project:${e.projectId}`),className:`flex w-full min-w-0 items-center gap-2 rounded-xl px-2 py-1.5 text-left text-xs outline-none transition-colors hover:bg-foreground/[0.03] focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Q.jsx)(di,{className:`size-3.5 shrink-0 text-muted-foreground/60`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`max-w-24 truncate text-[10px] text-muted-foreground/55`,children:e.pathLabel})]},e.projectId)),A.length===0?(0,Q.jsxs)(`span`,{className:`px-2 py-2 text-center text-[11px] text-muted-foreground/60`,children:[`No project matches “`,i,`”`]}):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border/60 px-3 py-2 text-[10px] text-muted-foreground/70`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(cu,{children:`↑`}),(0,Q.jsx)(cu,{children:`↓`}),`navigate`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(cu,{children:`↵`}),`open`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(cu,{children:`esc`}),`close`]})]})]})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:v,className:`flex h-8 w-full items-center justify-start gap-2 rounded-lg px-2 text-[13px] font-normal text-sidebar-foreground outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:[(0,Q.jsx)(Zo,{className:`size-4 shrink-0 text-muted-foreground`}),`New chat`]})]}),(0,Q.jsx)(au,{projectActionsOpen:o,setProjectActionsOpen:s,expandedProjectIds:c,setExpandedProjectIds:l,setCreateOpen:u,projects:d,projectSessions:f,sidebarItems:p,activeProjectId:g,activeSessionId:_,onNewSession:v,onNewSessionInProject:y,onProjectSelect:b,onRenameSession:x,onCreateProject:S,resumeResource:T,toggleProjectResource:E,renderMenu:O}),(0,Q.jsxs)(_c,{className:`flex-row items-center gap-1 border-sidebar-border px-2.5 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:w??(0,Q.jsx)(`span`,{className:`flex h-8 items-center px-2 text-[13px]`,children:`Qredence`})}),(0,Q.jsx)(`a`,{href:Sc,target:`_blank`,rel:`noreferrer`,"aria-label":`Open Qredence documentation`,title:`Help`,className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,Q.jsx)(No,{className:`size-4`})})]}),(0,Q.jsx)(pc,{})]})})}var uu=(e,t,n)=>{let r=t.trim().toLocaleLowerCase();if(!r)return!0;let i=[e,...n].join(` `).toLocaleLowerCase(),a=0;for(let e of i)if(e===r[a]&&(a+=1),a===r.length)return!0;return!1},du=(0,Z.createContext)(null),fu=(0,Z.createContext)(null);function pu(e){let t=(0,Z.useContext)(du);if(!t)throw Error(`${e} must be used within <Combobox>`);return t}function mu(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function hu({children:e,value:t,defaultValue:n,onValueChange:r,open:i,defaultOpen:a=!1,onOpenChange:o,query:s,defaultQuery:c=``,onQueryChange:l,filter:u=uu,disabled:d=!1,className:f}){let p=K()??!1,m=(0,Z.useId)(),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),[y,b]=(0,Z.useState)(n),[x,S]=(0,Z.useState)(a),[C,w]=(0,Z.useState)(c),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(new Map),k=t!==void 0,A=i!==void 0,j=s!==void 0,M=k?t:y,N=A?i:x,P=j?s:C,F=(0,Z.useCallback)(e=>{j||w(e),l?.(e)},[l,j]),I=(0,Z.useCallback)((e,t=!1)=>{d&&e||(A||S(e),o?.(e),e||F(``),t&&requestAnimationFrame(()=>v.current?.focus({preventScroll:!0})))},[d,o,A,F]),L=(0,Z.useEffectEvent)(I),R=(0,Z.useCallback)(e=>{O(t=>{let n=t.get(e.value);if(n?.label===e.label&&n.disabled===e.disabled&&n.id===e.id&&n.ref===e.ref&&n.groupId===e.groupId&&n.keywords.join(`\0`)===e.keywords.join(`\0`))return t;let r=new Map(t);return r.set(e.value,e),r})},[]),z=(0,Z.useCallback)(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),B=(0,Z.useMemo)(()=>Array.from(D.values()).filter(e=>u(e.value,P,[e.label,...e.keywords])),[u,D,P]),V=(0,Z.useMemo)(()=>B.filter(e=>!e.disabled),[B]),H=(0,Z.useMemo)(()=>new Set(B.map(e=>e.value)),[B]),U=(0,Z.useMemo)(()=>new Set(B.map(e=>e.groupId)),[B]),ee=(0,Z.useCallback)(e=>{D.get(e)?.disabled||(k||b(e),r?.(e),I(!1,!0))},[D,r,I,k]),W=(0,Z.useCallback)(e=>{if(!V.length){E(null);return}if(e===`first`){E(V[0].value);return}if(e===`last`){E(V.at(-1)?.value??null);return}let t=V.findIndex(e=>e.value===T),n=t<0?e===1?0:V.length-1:(t+e+V.length)%V.length;E(V[n].value)},[T,V]),te=(0,Z.useCallback)(()=>{T&&ee(T)},[T,ee]);(0,Z.useEffect)(()=>{if(!N)return;let e=M&&H.has(M)?M:null,t=T&&H.has(T)?T:null;E(t??e??V[0]?.value??null)},[T,V,N,M,H]),(0,Z.useEffect)(()=>{N&&requestAnimationFrame(()=>v.current?.focus({preventScroll:!0}))},[N]),(0,Z.useEffect)(()=>{if(!T||!N)return;let e=D.get(T)?.ref.current,t=e?.closest(`[role='listbox']`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();n.top<r.top?t.scrollTop-=r.top-n.top:n.bottom>r.bottom&&(t.scrollTop+=n.bottom-r.bottom)},[T,D,N]),(0,Z.useEffect)(()=>{if(!N)return;let e=e=>h.current?.contains(e)||_.current?.contains(e),t=t=>{e(t.target)||L(!1)},n=t=>{e(t.target)||L(!1)},r=e=>{e.key===`Escape`&&(e.preventDefault(),L(!1,!0))};return window.addEventListener(`pointerdown`,t),window.addEventListener(`focusin`,n),window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`focusin`,n),window.removeEventListener(`keydown`,r)}},[N]);let ne=T?D.get(T):void 0,re=(0,Z.useMemo)(()=>({open:N,setOpen:I,value:M,select:ee,query:P,setQuery:F,activeValue:T,setActiveValue:E,moveActive:W,selectActive:te,registerItem:R,unregisterItem:z,labelFor:e=>e===void 0?void 0:D.get(e)?.label,isVisible:e=>!P.trim()||H.has(e),hasVisibleItems:e=>U.has(e),visibleCount:B.length,activeItemId:ne?.id,triggerId:`${m}-trigger`,listId:`${m}-list`,inputId:`${m}-input`,disabled:d,reduce:p,triggerRef:g,contentRef:_,inputRef:v,activeLayoutId:`${m}-active`}),[ne?.id,T,m,d,D,W,N,P,p,R,ee,te,z,I,F,M,B.length,U,H]);return(0,Q.jsx)(du.Provider,{value:re,children:(0,Q.jsx)(`div`,{ref:h,className:q(`relative w-full`,f),children:e})})}var gu={type:`spring`,duration:.5,bounce:.22},_u=8;function vu({children:e,side:t=`bottom`,align:n=`start`,sideOffset:r=6,avoidCollisions:i=!0,className:a}){let o=pu(`ComboboxContent`),s=(0,Z.useRef)(null),c=Tl(),[l,u]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(!1),p=Gt(),m=Math.min(p+2,8),h=xl(o.triggerRef,s,c);if((0,Z.useLayoutEffect)(()=>{if(!c)return;let e=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(e)},[c]),(0,Z.useLayoutEffect)(()=>{if(!o.open||!h)return;if(!i){u(t);return}let e=window.innerHeight-(h.trigger.top+h.trigger.height),n=h.trigger.top;t===`bottom`&&e<h.content.height+r&&n>e?u(`top`):t===`top`&&n<h.content.height+r&&e>n?u(`bottom`):u(t)},[i,o.open,h,t,r]),!c)return null;let g=h?.trigger.left??0,_=h?.trigger.width??0,v=h?.content.width??_,y=n===`end`?g+_-v:n===`center`?g+(_-v)/2:g,b=Math.max(_u,window.innerWidth-v-_u),x=Math.min(Math.max(y,_u),b),S=h?.content.height??0;return(0,Gs.createPortal)((0,Q.jsx)(G.div,{ref:o.contentRef,"data-combobox-content":``,"data-side":l,"aria-hidden":!o.open,inert:!o.open,initial:!1,animate:{opacity:+!!o.open,y:o.open?l===`bottom`?r:-r:0},transition:o.reduce||!d?{duration:0}:gu,layout:`size`,style:{height:o.open?S:0,left:x,top:l===`bottom`&&h?h.trigger.top+h.trigger.height:void 0,bottom:l===`top`&&h?window.innerHeight-h.trigger.top:void 0,minWidth:_,pointerEvents:o.open?`auto`:`none`,transformOrigin:l===`bottom`?`top`:`bottom`,visibility:h?`visible`:`hidden`,"--combobox-trigger-width":`${_}px`},className:q(`fixed z-[9999] w-(--combobox-trigger-width) overflow-hidden rounded-xl text-popover-foreground outline-none will-change-[height,transform]`,Vt(m,3),a),children:(0,Q.jsx)(Kt,{value:m,children:(0,Q.jsx)(G.div,{ref:s,initial:!1,animate:{opacity:+!!o.open},transition:o.reduce||!d?{duration:0}:gu,children:e})})}),document.body)}function yu({children:e,ariaLabel:t=`Options`,className:n}){let r=pu(`ComboboxList`);return(0,Q.jsx)(`div`,{id:r.listId,role:`listbox`,"aria-label":t,className:q(`relative isolate max-h-64 overflow-y-auto overscroll-contain p-1.5 [-ms-overflow-style:none] scrollbar-none [&::-webkit-scrollbar]:hidden`,n),children:e})}function bu({children:e,className:t}){let n=pu(`ComboboxGroup`),r=(0,Z.useId)();return(0,Q.jsx)(fu.Provider,{value:r,children:(0,Q.jsx)(`fieldset`,{hidden:!n.hasVisibleItems(r),className:q(`m-0 min-w-0 border-0 p-0 py-0.5`,t),children:e})})}function xu({children:e,className:t}){let n=(0,Z.useContext)(fu),r=q(`w-full px-2 py-1.5 text-[0.68rem] font-medium uppercase tracking-[0.12em] text-muted-foreground`,t);return n?(0,Q.jsx)(`legend`,{className:r,children:e}):(0,Q.jsx)(`div`,{className:r,children:e})}function Su({value:e,children:t,textValue:n,keywords:r=[],disabled:i=!1,onSelect:a,className:o}){let s=pu(`ComboboxItem`),c=(0,Z.useContext)(fu),l=(0,Z.useId)(),u=(0,Z.useRef)(null),d=n??(typeof t==`string`?t:e),f=s.isVisible(e),p=s.activeValue===e,m=s.value===e,h=r.join(`\0`),g=(0,Z.useMemo)(()=>h?h.split(`\0`):[],[h]),{registerItem:_,unregisterItem:v}=s;return(0,Z.useLayoutEffect)(()=>(_({value:e,label:d,keywords:g,disabled:i,groupId:c,id:l,ref:u}),()=>v(e)),[i,c,l,d,g,_,v,e]),f?(0,Q.jsxs)(`button`,{ref:u,id:l,type:`button`,role:`option`,"aria-selected":m,disabled:i,tabIndex:-1,"data-combobox-item":``,"data-active":p||void 0,"data-selected":m||void 0,onPointerMove:()=>{i||s.setActiveValue(e)},onPointerDown:e=>e.preventDefault(),onClick:()=>{i||(a?.(e),s.select(e))},className:q(`relative flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm outline-none transition-colors duration-150`,p?`text-foreground`:`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-45`,o),children:[p?(0,Q.jsx)(G.span,{"aria-hidden":!0,layoutId:s.activeLayoutId,className:`absolute inset-0 -z-10 rounded-lg bg-muted`,transition:s.reduce?{duration:0}:He}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),(0,Q.jsx)(G.span,{"aria-hidden":!0,initial:!1,animate:{opacity:+!!m,transform:m?`scale(1)`:`scale(0.82)`},transition:s.reduce?{duration:0}:{duration:.14,ease:Ue},className:`grid size-5 shrink-0 place-items-center text-foreground`,children:(0,Q.jsx)(_r,{className:`size-4`})})]}):null}function Cu({children:e=`No options found.`,className:t}){return pu(`ComboboxEmpty`).visibleCount>0?null:(0,Q.jsx)(`div`,{role:`status`,className:q(`px-3 py-8 text-center text-sm text-muted-foreground`,t),children:e})}function wu({children:e,className:t,showIndicator:n=!0}){let r=pu(`ComboboxTrigger`);return(0,Q.jsxs)(`div`,{ref:r.triggerRef,id:r.triggerId,"data-state":r.open?`open`:`closed`,onPointerDown:e=>{r.disabled||e.target===r.inputRef.current||(e.preventDefault(),r.inputRef.current?.focus({preventScroll:!0}),r.setOpen(!0))},className:q(`relative z-20 flex h-10 w-full min-w-52 cursor-text items-center justify-between gap-3 rounded-xl border border-border bg-transparent px-3 text-sm text-foreground transition-[border-color] hover:border-(--color-border-strong)`,`focus-within:ring-2 focus-within:ring-foreground/20`,r.disabled&&`pointer-events-none opacity-50`,t),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:e}),n?(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-foreground`,children:(0,Q.jsx)(Mo,{className:`size-4`})}):null]})}function Tu({ref:e,className:t,wrapperClassName:n,"aria-label":r=`Search options`,onChange:i,onClick:a,onFocus:o,onKeyDown:s,onPointerDown:c,placeholder:l=`Search…`,...u}){let d=pu(`ComboboxInput`),f=d.labelFor(d.value),p=e=>{s?.(e),!e.defaultPrevented&&(e.key===`ArrowDown`?(e.preventDefault(),d.setOpen(!0),d.moveActive(1)):e.key===`ArrowUp`?(e.preventDefault(),d.setOpen(!0),d.moveActive(-1)):e.key===`Home`&&d.open?(e.preventDefault(),d.moveActive(`first`)):e.key===`End`&&d.open?(e.preventDefault(),d.moveActive(`last`)):e.key===`Enter`?(e.preventDefault(),d.open?d.selectActive():d.setOpen(!0)):e.key===`Escape`&&d.open&&(e.preventDefault(),d.setOpen(!1,!0)))};return(0,Q.jsxs)(`div`,{className:q(`flex min-w-0 flex-1 items-center gap-2`,n),children:[(0,Q.jsx)(bi,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`input`,{...u,ref:mu(e,d.inputRef),id:d.inputId,role:`combobox`,"aria-label":r,"aria-autocomplete":`list`,"aria-expanded":d.open,"aria-controls":d.listId,"aria-activedescendant":d.open?d.activeItemId:void 0,autoComplete:`off`,disabled:d.disabled,value:d.open?d.query:f??``,placeholder:l,onPointerDown:e=>{c?.(e),!(e.defaultPrevented||d.open)&&(e.preventDefault(),d.inputRef.current?.focus({preventScroll:!0}),d.setOpen(!0))},onFocus:e=>{d.setOpen(!0),o?.(e)},onClick:e=>{d.setOpen(!0),a?.(e)},onChange:e=>{d.setOpen(!0),d.setQuery(e.target.value),i?.(e)},onKeyDown:p,className:q(`h-10 min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed`,t)})]})}function Eu({createOpen:e,setCreateOpen:t,directoryBrowser:n,setDirectoryBrowser:r,directoryBrowseLoading:i,directoryBrowseError:a,setDirectoryBrowseError:o,onBrowseDirectories:s,directoryToken:c,setDirectoryToken:l,createName:u,setCreateName:d,createPath:f,setCreatePath:p,loadDirectories:m,createSubmitting:h,createSubmitError:g,setCreateSubmitError:_,submitCreate:v}){let y=(0,Z.useId)(),b=(0,Z.useId)(),x=(0,Z.useId)(),S=n?.pathLabel??f,C=!!(c||f.trim().startsWith(`/`)),w=()=>{r(null),l(void 0),p(``),o(null)},T=()=>{h||(w(),d(``),_(null),t(!1))};return(0,Q.jsx)($t,{open:e,onOpenChange:e=>{e?t(!0):T()},children:(0,Q.jsxs)(Yt,{className:`sm:max-w-xl`,children:[(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Xt,{children:`Add project`}),(0,Q.jsx)(Qt,{children:`Choose the local directory that owns this project's sessions. Browse the server filesystem or paste an absolute path.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:y,children:`Project name`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Optional`})]}),(0,Q.jsx)(ra,{id:y,value:u,onChange:e=>d(e.target.value),placeholder:`e.g. Fleet Prime`,"aria-label":`Project name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium`,htmlFor:b,children:`Local directory`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Required`})]}),(0,Q.jsx)(ra,{id:b,value:f,onChange:e=>{p(e.target.value),l(void 0),r(null),o(null),_(null)},placeholder:`/absolute/path/to/project`,"aria-label":`Project directory`,"aria-describedby":x,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`h-10 font-mono text-xs`}),(0,Q.jsx)(`p`,{id:x,className:`text-xs text-muted-foreground`,children:`Browse to select a directory, or paste an absolute path. The server validates the final choice before registering it.`})]}),i&&!n?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-dashed px-3 py-4 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(Tn,{className:`size-4`}),`Loading directories…`]}):null,n?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl border bg-muted/20`,"data-testid":`project-directory-browser`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 p-3`,children:[(0,Q.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(li,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Selected directory`}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-foreground`,title:S,children:S})]}),(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary`,children:`Selected`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 border-t px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`Browse child directories`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open a folder to make it the selected directory.`})]}),n.parentToken?(0,Q.jsxs)(H,{type:`button`,size:`sm`,variant:`outline`,disabled:i,onClick:()=>void m({token:n.parentToken??void 0}),"aria-label":`Go up one directory`,title:`Go up one directory`,children:[(0,Q.jsx)(Ao,{className:`size-3.5`}),`Up`]}):null]}),i?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-dashed px-3 py-4 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(Tn,{className:`size-4`}),`Loading directories…`]}):n.entries.length===0?(0,Q.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-4 text-center text-sm text-muted-foreground`,children:`No child directories here.`}):(0,Q.jsxs)(hu,{value:c,onValueChange:e=>{n.entries.find(t=>t.directoryToken===e)&&m({token:e})},children:[(0,Q.jsx)(wu,{className:`h-10 bg-background`,children:(0,Q.jsx)(Tu,{"aria-label":`Search child directories`,placeholder:`Choose a child directory…`,className:`text-xs`})}),(0,Q.jsx)(vu,{className:`w-[min(32rem,calc(100vw-3rem))]`,children:(0,Q.jsxs)(yu,{ariaLabel:`Child directories`,children:[(0,Q.jsxs)(bu,{children:[(0,Q.jsx)(xu,{children:`Child directories`}),n.entries.map(e=>(0,Q.jsx)(Su,{value:e.directoryToken,textValue:`${e.name} ${e.pathLabel}`,keywords:[e.pathLabel],children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(Vo,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:Fc(e)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,title:e.pathLabel,children:e.pathLabel})]})]})},e.directoryToken))]}),(0,Q.jsx)(Cu,{children:`No matching directories.`})]})})]})]})]}):s?(0,Q.jsxs)(H,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void m({}),className:`w-full justify-start`,children:[(0,Q.jsx)(li,{className:`size-4`}),`Browse directories`]}):null,a?(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive`,role:`alert`,children:[(0,Q.jsx)(ht,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{children:a}),(0,Q.jsx)(H,{type:`button`,variant:`link`,size:`xs`,className:`mt-1 h-auto p-0 text-destructive`,onClick:()=>void m(n?{token:n.directoryToken}:{}),children:`Try again`})]})]}):null,g?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:g}):null]}),(0,Q.jsxs)(qt,{children:[(0,Q.jsx)(H,{type:`button`,variant:`outline`,disabled:h,onClick:T,children:`Cancel`}),(0,Q.jsx)(H,{type:`button`,disabled:!C||h,onClick:()=>void v(),children:h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Tn,{className:`size-3.5`}),`Adding project…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Bo,{className:`size-3.5`}),`Add project`]})})]})]})})}function Du({projects:e,onRenameSession:t,onDeleteSession:n,onRenameProject:r,onUnregisterProject:i,onForkSessionIntoProject:a,renameTarget:o,setRenameTarget:s,renameTitle:c,setRenameTitle:l,renameProjectTarget:u,setRenameProjectTarget:d,renameProjectName:f,setRenameProjectName:p,deleteTarget:m,setDeleteTarget:h,unregisterTarget:g,setUnregisterTarget:_,forkTarget:v,setForkTarget:y,forkProjectId:b,setForkProjectId:x}){let S=(0,Z.useMemo)(()=>e.flatMap(e=>e.projectId===v?.projectId?[]:[{value:e.projectId,label:`${e.name} — ${e.pathLabel}`,icon:di}]),[v?.projectId,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(On,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,Q.jsxs)(Fn,{children:[(0,Q.jsx)(Ln,{children:`Rename session`}),(0,Q.jsx)(wn,{children:`Choose a local display title for this Fleet Prime session.`}),(0,Q.jsx)(ra,{value:c,onChange:e=>l(e.target.value),"aria-label":`Session title`,autoFocus:!0}),(0,Q.jsxs)(An,{children:[(0,Q.jsx)(Nn,{children:`Cancel`}),(0,Q.jsx)(Cn,{disabled:!c.trim(),onClick:()=>{o&&c.trim()&&(t(o.sessionId,c.trim()),s(null))},children:`Rename`})]})]})}),(0,Q.jsx)(On,{open:u!==null,onOpenChange:e=>!e&&d(null),children:(0,Q.jsxs)(Fn,{children:[(0,Q.jsx)(Ln,{children:`Rename project`}),(0,Q.jsx)(wn,{children:`This changes the display name only. The registered directory stays the same.`}),(0,Q.jsx)(ra,{value:f,onChange:e=>p(e.target.value),"aria-label":`Project name`,autoFocus:!0}),(0,Q.jsxs)(An,{children:[(0,Q.jsx)(Nn,{children:`Cancel`}),(0,Q.jsx)(Cn,{disabled:!f.trim()||!r,onClick:()=>{u&&f.trim()&&(r?.(u.projectId,f.trim()),d(null))},children:`Rename`})]})]})}),(0,Q.jsx)(On,{open:m!==null,onOpenChange:e=>!e&&h(null),children:(0,Q.jsxs)(Fn,{children:[(0,Q.jsx)(Ln,{children:`Delete session?`}),(0,Q.jsx)(wn,{children:`This removes the Fleet Prime session and its managed session artifacts. This cannot be undone.`}),(0,Q.jsxs)(An,{children:[(0,Q.jsx)(Nn,{children:`Cancel`}),(0,Q.jsx)(Cn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{m&&n(m.sessionId),h(null)},children:`Delete`})]})]})}),(0,Q.jsx)(On,{open:g!==null,onOpenChange:e=>!e&&_(null),children:(0,Q.jsxs)(Fn,{children:[(0,Q.jsx)(Ln,{children:`Unregister project?`}),(0,Q.jsx)(wn,{children:`The directory and its sessions remain intact. Existing sessions will move to Unassigned until the directory is registered again.`}),(0,Q.jsxs)(An,{children:[(0,Q.jsx)(Nn,{children:`Cancel`}),(0,Q.jsx)(Cn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{g&&i?.(g.projectId),_(null)},children:`Unregister`})]})]})}),(0,Q.jsx)($t,{open:v!==null,onOpenChange:e=>!e&&y(null),children:(0,Q.jsxs)(Yt,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Xt,{children:`Fork session into project`}),(0,Q.jsx)(Qt,{children:`Create a new Fleet Prime session in another registered project.`})]}),(0,Q.jsx)(`div`,{className:`py-2`,children:(0,Q.jsx)(dn,{value:b??null,onValueChange:e=>x(e),options:S,placeholder:`Select a project…`,"aria-label":`Target project`})}),(0,Q.jsxs)(qt,{children:[(0,Q.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>y(null),children:`Cancel`}),(0,Q.jsx)(H,{type:`button`,disabled:!v||!b||!a,onClick:()=>{!v||!b||(a?.(v.sessionId,b),y(null))},children:`Fork session`})]})]})})]})}function Ou(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Eu,{...e}),(0,Q.jsx)(Du,{...e})]})}function ku({data:e,sessionActions:t,projectActions:n={},navigationActions:r={},slots:i={}}){let{sessions:a,projects:o=wc,projectSessions:s=a,activeProjectId:c,activeSessionId:l}=e,{onNewSession:u,onNewSessionInProject:d,onResumeSession:f,onRenameSession:p,onDeleteSession:m}=t,{onProjectSelect:h,onCreateProject:g,onRenameProject:_,onUnregisterProject:v,onForkSessionIntoProject:y}=n,{onOpenPanelAction:b,onBrowseDirectories:x,onOpenSettings:S}=r,{accountMenu:C}=i,w=zc(c),{loadDirectories:T,projectById:E,sortedProjects:D,sidebarItems:O,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M,submitCreate:N}=Kc({sessions:a,projects:o,projectSessions:s,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:h,onResumeSession:f,onCreateProject:g,onForkSessionIntoProject:y,onOpenPanelAction:b,onBrowseDirectories:x,createOpen:w.createOpen,expandedProjectIds:w.expandedProjectIds,revealedProjectIds:w.revealedProjectIds,setExpandedProjectIds:w.setExpandedProjectIds,setRevealedProjectIds:w.setRevealedProjectIds,setSearchOpen:w.setSearchOpen,setDirectoryBrowser:w.setDirectoryBrowser,setDirectoryBrowseLoading:w.setDirectoryBrowseLoading,setDirectoryBrowseError:w.setDirectoryBrowseError,setDirectoryToken:w.setDirectoryToken,setCreatePath:w.setCreatePath,setRenameTarget:w.setRenameTarget,setRenameTitle:w.setRenameTitle,setForkTarget:w.setForkTarget,setForkProjectId:w.setForkProjectId,setDeleteTarget:w.setDeleteTarget,setRenameProjectTarget:w.setRenameProjectTarget,setRenameProjectName:w.setRenameProjectName,setUnregisterTarget:w.setUnregisterTarget,createPath:w.createPath,directoryToken:w.directoryToken,createName:w.createName,setCreateName:w.setCreateName,setCreateOpen:w.setCreateOpen,setCreateSubmitError:w.setCreateSubmitError,setCreateSubmitting:w.setCreateSubmitting});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lu,{brandMenuOpen:w.brandMenuOpen,setBrandMenuOpen:w.setBrandMenuOpen,searchOpen:w.searchOpen,setSearchOpen:w.setSearchOpen,query:w.query,setQuery:w.setQuery,projectActionsOpen:w.projectActionsOpen,setProjectActionsOpen:w.setProjectActionsOpen,expandedProjectIds:w.expandedProjectIds,setExpandedProjectIds:w.setExpandedProjectIds,setCreateOpen:w.setCreateOpen,projects:o,projectSessions:s,sidebarItems:O,sortedProjects:D,projectById:E,activeProjectId:c,activeSessionId:l,onNewSession:u,onNewSessionInProject:d,onProjectSelect:h,onRenameSession:p,onCreateProject:g,onOpenSettings:S,accountMenu:C,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M}),(0,Q.jsx)(Ou,{projects:o,onRenameSession:p,onDeleteSession:m,onRenameProject:_,onUnregisterProject:v,onForkSessionIntoProject:y,onBrowseDirectories:x,createOpen:w.createOpen,setCreateOpen:w.setCreateOpen,directoryBrowser:w.directoryBrowser,setDirectoryBrowser:w.setDirectoryBrowser,directoryBrowseLoading:w.directoryBrowseLoading,directoryBrowseError:w.directoryBrowseError,setDirectoryBrowseError:w.setDirectoryBrowseError,directoryToken:w.directoryToken,setDirectoryToken:w.setDirectoryToken,createName:w.createName,setCreateName:w.setCreateName,createPath:w.createPath,setCreatePath:w.setCreatePath,renameTarget:w.renameTarget,setRenameTarget:w.setRenameTarget,renameTitle:w.renameTitle,setRenameTitle:w.setRenameTitle,renameProjectTarget:w.renameProjectTarget,setRenameProjectTarget:w.setRenameProjectTarget,renameProjectName:w.renameProjectName,setRenameProjectName:w.setRenameProjectName,deleteTarget:w.deleteTarget,setDeleteTarget:w.setDeleteTarget,unregisterTarget:w.unregisterTarget,setUnregisterTarget:w.setUnregisterTarget,forkTarget:w.forkTarget,setForkTarget:w.setForkTarget,forkProjectId:w.forkProjectId,setForkProjectId:w.setForkProjectId,createSubmitting:w.createSubmitting,createSubmitError:w.createSubmitError,setCreateSubmitError:w.setCreateSubmitError,loadDirectories:T,submitCreate:N})]})}var Au=[];function ju({label:e,active:t=!1,onClick:n,children:r}){let i=K()??!1;return(0,Q.jsx)(G.button,{type:`button`,"aria-label":e,title:e,"aria-pressed":e===`Helpful`||e===`Not helpful`?t:void 0,onClick:n,whileTap:i?void 0:{scale:.9},transition:ze,className:q(`grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,t&&`bg-muted text-foreground`),children:r})}function Mu({children:e,status:t=`streaming`,copyText:n,onCopy:r,onRetry:i,sources:a=Au,sourcesOpen:o,defaultSourcesOpen:s=!1,onSourcesOpenChange:c,sourceIdPrefix:l,feedback:u,defaultFeedback:d=null,onFeedbackChange:f,announce:p=!0,showActions:m=!0,className:h,contentClassName:g,actionsClassName:_}){let v=K()??!1,y=(0,Z.useId)(),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(d),[w,T]=(0,Z.useState)(s),E=(0,Z.useRef)(void 0),D=u??S,O=o??w,k=t===`streaming`,A=t===`complete`,j=!!(n||r),M=a.length>0,N=m&&!k&&(j||i||A||M),P=`${y}-sources`,F=l??`response-source-${y.replace(/:/g,``)}`;(0,Z.useEffect)(()=>()=>{E.current&&window.clearTimeout(E.current)},[]);let I=(0,Z.useCallback)(async()=>{r?await r():n&&await navigator.clipboard?.writeText(n),x(!0),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>x(!1),1600)},[n,r]),L=e=>{let t=D===e?null:e;u===void 0&&C(t),f?.(t)},R=(0,Z.useCallback)(e=>{o===void 0&&T(e),c?.(e)},[c,o]);return(0,Q.jsxs)(`div`,{"data-state":t,"aria-busy":k,className:q(`w-full`,h),children:[(0,Q.jsx)(`div`,{"aria-live":p?`polite`:`off`,className:q(`text-sm leading-6 text-foreground/90 [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:space-y-1 [&_ol]:pl-5 [&_p+p]:mt-3 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/45 [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_ul]:my-3 [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-5`,g),children:e}),(0,Q.jsx)(Be,{initial:!1,children:N?(0,Q.jsxs)(G.div,{initial:v?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:v?.12:.22,ease:Ue},className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:q(`flex items-center gap-0.5`,_),children:[j?(0,Q.jsx)(ju,{label:b?`Copied`:`Copy response`,onClick:I,children:b?(0,Q.jsx)(_r,{className:`size-3.5`}):(0,Q.jsx)(Hr,{className:`size-3.5`})}):null,i?(0,Q.jsx)(ju,{label:`Retry response`,onClick:i,children:(0,Q.jsx)(yi,{className:`size-3.5`})}):null,A?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ju,{label:`Helpful`,active:D===`up`,onClick:()=>L(`up`),children:(0,Q.jsx)($o,{className:`size-3.5`})}),(0,Q.jsx)(ju,{label:`Not helpful`,active:D===`down`,onClick:()=>L(`down`),children:(0,Q.jsx)(Qo,{className:`size-3.5`})})]}):null,M?(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":P,onClick:()=>R(!O),className:`group ml-1 inline-flex min-h-7 items-center gap-2 rounded-md px-1.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Q.jsx)(ur,{citations:a}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[a.length,` `,a.length===1?`source`:`sources`]}),(0,Q.jsx)(G.span,{"aria-hidden":`true`,animate:{rotate:O?180:0},transition:v?{duration:0}:Ke,className:`text-muted-foreground/50 group-hover:text-muted-foreground`,children:(0,Q.jsx)(yr,{className:`size-3`})})]}):null]}),M?(0,Q.jsx)(Vr,{id:P,open:O,children:(0,Q.jsx)(sr,{citations:a,idPrefix:F,className:`mt-2 rounded-xl bg-muted p-2`})}):null]}):null})]})}var Nu=`@keyframes beui-text-shimmer{from{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion: reduce){.beui-text-shimmer{animation:none !important}}`,Pu=`beui-text-shimmer bg-[length:200%_100%] bg-clip-text text-transparent bg-[linear-gradient(110deg,var(--muted-foreground)_30%,var(--foreground)_50%,var(--muted-foreground)_70%)]`;function Fu(e){return{animation:`beui-text-shimmer ${e}s linear infinite`}}function Iu({children:e,as:t=`span`,duration:n=2.5,className:r}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`style`,{children:Nu}),(0,Q.jsx)(t,{style:Fu(n),className:q(`inline-block`,Pu,r),children:e})]})}function Lu({children:e=`Thinking…`,duration:t=1.8,className:n}){return(0,Q.jsx)(Iu,{as:`span`,duration:t,className:q(`font-medium`,n),children:e})}function Ru({item:e}){let t=e.status??`complete`;return(0,Q.jsxs)(`div`,{className:`flex min-h-7 items-start gap-2.5 rounded-md px-1.5 py-1`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-4 shrink-0 place-items-center text-muted-foreground/70`,children:t===`complete`?(0,Q.jsx)(_r,{className:`size-4`,strokeWidth:1.8}):t===`active`?(0,Q.jsxs)(`span`,{className:`relative grid size-3 place-items-center`,children:[(0,Q.jsx)(Ie.span,{className:`absolute inset-0 rounded-full bg-foreground/10`,animate:{opacity:[.35,.8,.35]},transition:{duration:1.5,repeat:1/0}}),(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-foreground/60`})]}):(0,Q.jsx)(Fo,{className:`size-3`,strokeWidth:1.5})}),(0,Q.jsx)(`span`,{className:q(`min-w-0 flex-1 leading-5`,t===`pending`?`text-muted-foreground/55`:`text-foreground/90`),children:e.label}),e.meta?(0,Q.jsx)(`span`,{className:`shrink-0 leading-5 text-muted-foreground/55`,children:e.meta}):null]})}function zu({item:e}){return(0,Q.jsx)(`div`,{className:`rounded-md px-1.5 py-1 leading-5 text-muted-foreground`,children:e.content})}function Bu({result:e}){let t=e.url&&Lr(e.url)?e.url:void 0,n=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 place-items-center text-muted-foreground`,children:e.icon??(0,Q.jsx)(pr,{className:`size-3`,strokeWidth:2})}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/90`,children:e.title}),e.domain?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground/55`,children:e.domain}):null]}),r=q(`flex min-h-7 items-center gap-2 rounded-md px-1.5 py-1 text-left outline-none transition-colors`,t&&`focus-visible:ring-2 focus-visible:ring-ring`);return t?(0,Q.jsx)(`a`,{href:t,className:r,children:n}):(0,Q.jsx)(`div`,{className:r,children:n})}function Vu({item:e}){let t=K()??!1,n=t?{opacity:1}:{opacity:0,y:6},r={opacity:1,y:0},i=t?{opacity:0}:{opacity:0,y:-3},a=t?{duration:0}:{opacity:{duration:.18,ease:Ue},y:He,layout:He};return(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2.5 rounded-md px-1.5 py-1 text-muted-foreground`,children:[(0,Q.jsx)(bi,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.7}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.query})]}),e.results?.length?(0,Q.jsx)(`div`,{className:`space-y-0.5 pl-4`,children:(0,Q.jsx)(Be,{initial:!0,mode:`popLayout`,children:e.results.map(e=>(0,Q.jsx)(Ie.div,{layout:`position`,initial:n,animate:r,exit:i,transition:a,children:(0,Q.jsx)(Bu,{result:e})},e.id))})}):null,(0,Q.jsx)(Be,{initial:!0,children:e.moreCount?(0,Q.jsxs)(Ie.div,{initial:n,animate:r,exit:i,transition:a,className:`px-1.5 py-1 pl-8 text-muted-foreground/55`,children:[`+`,e.moreCount,` more`]},`more-results`):null})]})}function Hu({action:e}){return e===`read`?(0,Q.jsx)(zr,{className:`size-4`}):e===`edit`||e===`write`?(0,Q.jsx)(qo,{className:`size-4`}):e===`run`?(0,Q.jsx)(xi,{className:`size-4`}):(0,Q.jsx)(Gr,{className:`size-4`})}function Uu({action:e}){return(0,Q.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel??e.label,onClick:e.onClick,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] font-medium text-primary outline-none hover:bg-primary/10 focus-visible:ring-2 focus-visible:ring-ring`,children:e.label})}function Wu({item:e}){let t=e.action.charAt(0).toUpperCase()+e.action.slice(1),n=typeof e.additions==`number`||typeof e.deletions==`number`;return(0,Q.jsxs)(`div`,{className:`grid min-h-8 min-w-0 grid-cols-[1rem_auto_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md px-1.5 py-0.5 leading-5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 shrink-0 place-items-center text-muted-foreground/70`,children:(0,Q.jsx)(Hu,{action:e.action})}),(0,Q.jsx)(`span`,{className:`shrink-0 font-medium text-foreground/90`,children:t}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate rounded-lg bg-muted/80 px-2.5 py-1 font-mono text-xs text-muted-foreground/70`,children:e.target}),n||e.openAction?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[n?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 font-mono tabular-nums`,children:[typeof e.additions==`number`?(0,Q.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,e.additions]}):null,typeof e.deletions==`number`?(0,Q.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,e.deletions]}):null]}):null,e.openAction?(0,Q.jsx)(Uu,{action:e.openAction}):null]}):null]})}function Gu({kind:e}){return e===`thinking`?(0,Q.jsx)(Yr,{className:`size-4`}):e===`message`?(0,Q.jsx)(Sn,{className:`size-4`}):e===`write`?(0,Q.jsx)(qo,{className:`size-4`}):e===`run`?(0,Q.jsx)(xi,{className:`size-4`}):e===`read`?(0,Q.jsx)(Tr,{className:`size-4`}):(0,Q.jsx)(Gr,{className:`size-4`})}function Ku({item:e}){let t=e.kind===`thinking`;return(0,Q.jsxs)(`div`,{className:q(`grid min-h-8 grid-cols-[1rem_auto_minmax(0,1fr)_auto] gap-2.5 rounded-md px-1.5 py-0.5`,t?`items-start`:`items-center`),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 place-items-center text-muted-foreground/70`,children:e.icon??(0,Q.jsx)(Gu,{kind:e.kind})}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/90`,children:e.label}),e.detail?(0,Q.jsx)(`span`,{className:q(`min-w-0 rounded-lg bg-muted/80 px-2.5 py-1 font-mono text-xs text-muted-foreground/70`,t?`max-h-40 overflow-y-auto whitespace-pre-wrap break-words`:`truncate`),children:e.detail}):(0,Q.jsx)(`span`,{}),e.action?(0,Q.jsx)(Uu,{action:e.action}):null]})}function qu({item:e}){return e.type===`text`?(0,Q.jsx)(zu,{item:e}):e.type===`search`?(0,Q.jsx)(Vu,{item:e}):e.type===`tool`?(0,Q.jsx)(Wu,{item:e}):e.type===`trace`?(0,Q.jsx)(Ku,{item:e}):(0,Q.jsx)(Ru,{item:e})}function Ju(e){let t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function Yu({open:e,defaultOpen:t,onOpenChange:n}){let[r,i]=(0,Z.useState)(t),a=e!==void 0;return[e??r,(0,Z.useCallback)(e=>{a||i(e),n?.(e)},[a,n])]}function Xu(e){let t=e[0]?.type;return t&&e.every(e=>e.type===t)?t:`mixed`}function Zu(e){return e===`search`?`Searching the web…`:e===`tool`?`Running tools…`:e===`trace`?`Working through the run…`:e===`mixed`?`Working through it…`:`Thinking…`}function Qu(e,t,n){if(e===`step`||e===`text`)return(0,Q.jsxs)(Q.Fragment,{children:[`Thought for `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:Ju(n)})]});if(e===`search`)return`Searched the web`;if(e===`tool`)return`Ran ${t.length} ${t.length===1?`tool`:`tools`}`;if(e===`trace`){let e=t.filter(e=>e.type===`trace`&&(e.kind===`thinking`||e.kind===`message`)).length,n=t.length-e;return`${n} ${n===1?`tool call`:`tool calls`}, ${e} ${e===1?`message`:`messages`}`}return`Completed ${t.length} ${t.length===1?`step`:`steps`}`}function $u({items:e,contentType:t,status:n=`working`,duration:r=0,open:i,defaultOpen:a=!1,onOpenChange:o,collapseOnComplete:s=!0,activeLabel:c,summary:l,renderWorkingStatus:u,renderCompletedStatus:d,maxHeight:f=208,className:p,contentClassName:m}){let h=K()??!1,g=(0,Z.useId)(),_=`${g}-trigger`,v=`${g}-content`,y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(n),[S,C]=(0,Z.useState)(0),[w,T]=Yu({open:i,defaultOpen:a,onOpenChange:o}),E=n===`working`,D=E||w,O=e.length?Xu(e):t??`mixed`,k=E?Math.max(0,f):Math.min(S,Math.max(0,f)),A=S>f,j=E?Math.min(0,k-S):0;(0,Z.useLayoutEffect)(()=>{let e=y.current;if(!e)return;let t=()=>C(e.offsetHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,Z.useEffect)(()=>{x.current===`working`&&n===`complete`&&T(!s),x.current=n},[s,T,n]);let M=()=>{let e=!w;T(e),e&&requestAnimationFrame(()=>b.current?.scrollTo({top:0}))},N=c??Zu(O),P=l??Qu(O,e,r),F=A?E?`linear-gradient(to bottom, transparent, black 12px)`:`linear-gradient(to bottom, transparent, black 12px, black calc(100% - 12px), transparent)`:void 0;return(0,Q.jsxs)(`div`,{"data-state":E?`working`:D?`open`:`closed`,"data-content":O,"aria-busy":E,className:q(`w-full text-sm`,p),children:[E?(0,Q.jsx)(`div`,{id:_,role:`status`,className:`flex h-7 min-w-0 items-center text-muted-foreground`,children:u?u({label:N,duration:r}):(0,Q.jsx)(Lu,{children:N})}):(0,Q.jsxs)(`button`,{id:_,type:`button`,"aria-expanded":D,"aria-controls":v,onClick:M,className:`group flex h-7 min-w-0 items-center gap-1.5 rounded-md text-left font-medium text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:d?d({summary:P,duration:r}):P}),(0,Q.jsx)(Ie.span,{"aria-hidden":`true`,animate:{rotate:D?180:0},transition:h?{duration:0}:Ke,className:`inline-flex shrink-0 text-muted-foreground/70 group-hover:text-foreground`,children:(0,Q.jsx)(yr,{className:`size-3.5`})})]}),(0,Q.jsx)(Vr,{id:v,role:`region`,"aria-labelledby":_,open:D,openHeight:k,children:(0,Q.jsx)(`div`,{ref:b,className:q(`scrollbar-hide pr-1`,A&&D&&!E?`overflow-y-auto`:`overflow-y-hidden`),style:{height:k,maskImage:F,WebkitMaskImage:F},children:(0,Q.jsx)(Ie.div,{ref:y,role:`list`,initial:!1,animate:{y:j},transition:h?{duration:0}:He,className:q(`space-y-0.5 py-2`,m),children:(0,Q.jsx)(Be,{mode:`popLayout`,children:e.map(e=>(0,Q.jsx)(Ie.div,{layout:`position`,role:`listitem`,initial:h?{opacity:1}:{opacity:0,y:6},animate:{opacity:1,y:0},exit:h?{opacity:0}:{opacity:0,y:-3},transition:h?{duration:0}:{opacity:{duration:.18,ease:Ue},y:He,layout:He},children:(0,Q.jsx)(qu,{item:e})},e.id))})})})})]})}function ed({suggestions:e,selectedSuggestion:t,cycle:n,onSuggestion:r,variant:i=`pills`,className:a,...o}){let s=i===`list`;return(0,Q.jsx)(`div`,{"data-slot":`suggestions`,className:q(s?`flex w-full max-w-sm flex-col gap-2`:`flex w-full max-w-xl flex-wrap justify-center gap-1`,a),...o,children:e.map((e,n)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===e,onClick:()=>r(e),className:q(nr,`fade-in slide-in-from-bottom-2 animate-in fill-mode-both flex cursor-pointer items-center text-[13px] text-foreground/80 transition-[color,transform] duration-300 hover:-translate-y-px hover:text-foreground focus-visible:text-foreground active:scale-[0.96] motion-reduce:animate-none`,s?`w-full rounded-2xl px-4 py-2.5 text-start`:`rounded-full px-4 py-2`,t===e&&`!bg-foreground !text-background hover:!text-background focus-visible:!text-background`),style:{animationDelay:`${n*70}ms`},children:e},e))},n)}var td=[{id:`top-left`,delay:0},{id:`top-center`,delay:.14},{id:`top-right`,delay:.28},{id:`middle-left`,delay:.42},{id:`middle-center`,delay:.56},{id:`middle-right`,delay:.7},{id:`bottom-left`,delay:.84},{id:`bottom-center`,delay:.98},{id:`bottom-right`,delay:1.12}];function nd(e){let t=Math.max(0,e),n=Math.floor(t/60),r=(t%60).toFixed(1);return n>0?`${n}m ${r}s`:`${r}s`}function rd({label:e=`Churning`,elapsedSeconds:t,initialSeconds:n=0,running:r=!0,className:i}){let a=K()??!1,[o,s]=(0,Z.useState)(n);(0,Z.useEffect)(()=>{if(t!==void 0||!r)return;let e=performance.now()-n*1e3,i=window.setInterval(()=>{s((performance.now()-e)/1e3)},100);return()=>window.clearInterval(i)},[t,n,r]);let c=t??o;return(0,Q.jsxs)(`span`,{role:`status`,"aria-label":`${e}, in progress`,className:q(`inline-flex items-center gap-3 font-mono text-sm text-muted-foreground`,i),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 grid-cols-3 gap-[2px]`,children:td.map(({id:e,delay:t})=>(0,Q.jsx)(G.span,{className:`rounded-[1px] bg-current`,animate:a?{opacity:[.35,.8,.35]}:{opacity:[.28,1,.28],scale:[.72,1,.72]},transition:{duration:1.55,ease:Ve,repeat:1/0,delay:t}},e))}),(0,Q.jsx)(`span`,{className:`font-sans font-medium`,children:e}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-muted-foreground/70`,children:nd(c)})]})}function id({label:e,className:t}){let n=K();if(!e?.trim())return null;let{kind:r,title:i,detail:a}=ad(e),o=od(r),s=r===`queue`||r===`retry`||r===`compaction`;return(0,Q.jsxs)(G.div,{initial:!n&&{opacity:0,y:-4},animate:{opacity:1,y:0},exit:n?void 0:{opacity:0,y:-4},transition:{duration:n?0:.16},role:r===`recovery`?`status`:void 0,"aria-live":r===`recovery`?`polite`:`off`,className:q(`flex items-start gap-2 rounded-lg border border-border/60 bg-muted/45 px-3 py-2 text-xs text-muted-foreground`,t),children:[s?(0,Q.jsx)(rd,{label:i,running:!0,className:`min-w-0 text-xs`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(o,{className:q(`mt-0.5 size-3.5 shrink-0`,r===`recovery`&&`text-amber-600 dark:text-amber-400`)}),(0,Q.jsx)(`strong`,{className:`font-medium text-foreground/90`,children:i})]}),a?(0,Q.jsx)(`span`,{className:`min-w-0 leading-relaxed`,children:a}):null]})}function ad(e){let t=e.trim(),n=t.toLowerCase();return n.includes(`queued`)||n.includes(`steered`)?{kind:`queue`,title:`Queued work`,detail:t}:n.includes(`retry`)?{kind:`retry`,title:`Retrying safely`,detail:t}:n.includes(`compact`)?{kind:`compaction`,title:`Managing context`,detail:t}:n.includes(`reset`)||n.includes(`recover`)||n.includes(`sign in`)?{kind:`recovery`,title:`Run needs attention`,detail:t}:{kind:`notice`,title:`Run update`,detail:t}}function od(e){switch(e){case`queue`:return Uo;case`retry`:return yi;case`compaction`:return Ho;case`recovery`:return Rr;default:return Io}}var sd={primary:`bg-primary text-primary-foreground hover:bg-primary/90`,secondary:`border border-border bg-card text-foreground hover:border-border`,ghost:`text-muted-foreground hover:text-foreground hover:bg-primary/5`,outline:`border border-border bg-transparent text-foreground hover:bg-primary/5`},cd={sm:`h-8 px-3 text-xs gap-1.5 rounded-full`,md:`h-10 px-5 text-sm gap-2 rounded-full`,lg:`h-12 px-6 text-base gap-2 rounded-full`,icon:`h-8 w-8 rounded-lg`},ld=(0,Z.forwardRef)(function({variant:e=`primary`,size:t=`md`,pressScale:n=.93,ripple:r=!1,className:i,children:a,onPointerDown:o,...s},c){let l=K(),u=ar(),[d,f]=(0,Z.useState)([]),p=(0,Z.useRef)(0),m=(0,Z.useCallback)(e=>{if(r&&!l){let t=e.currentTarget.getBoundingClientRect(),n=Math.max(t.width,t.height)*2,r=p.current++;f(i=>[...i,{id:r,x:e.clientX-t.left,y:e.clientY-t.top,size:n}])}o?.(e)},[r,l,o]);return(0,Q.jsxs)(G.button,{ref:c,type:`button`,whileTap:l?void 0:{scale:n},whileHover:l||!u?void 0:{scale:1.02},transition:ze,onPointerDown:m,className:q(`inline-flex items-center justify-center font-medium select-none`,`transition-colors`,`disabled:pointer-events-none disabled:opacity-50`,r&&`relative overflow-hidden`,sd[e],cd[t],i),...s,children:[(0,Q.jsx)(`span`,{className:q(`pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]`,!r&&`hidden`),children:(0,Q.jsx)(Be,{children:r&&!l?d.map(e=>(0,Q.jsx)(G.span,{className:`absolute rounded-full bg-current`,style:{left:e.x,top:e.y,width:e.size,height:e.size,x:`-50%`,y:`-50%`},initial:{scale:.05,opacity:.3},animate:{scale:1,opacity:0},exit:{opacity:0},transition:{duration:1.6,ease:Ue},onAnimationComplete:()=>f(t=>t.filter(t=>t.id!==e.id))},e.id)):null})}),a]})});(0,Z.forwardRef)(function({variant:e=`primary`,size:t=`md`,pressScale:n=.93,className:r,children:i,...a},o){let s=K(),c=ar();return(0,Q.jsx)(G.a,{ref:o,whileTap:s?void 0:{scale:n},whileHover:s||!c?void 0:{scale:1.02},transition:ze,className:q(`inline-flex items-center justify-center font-medium select-none`,`transition-colors`,sd[e],cd[t],r),...a,children:i})});function ud({children:e,strength:t=.35,className:n}){let r=(0,Z.useRef)(null),i=K(),a=ar(),o=!i&&a,s=Ya(0),c=Ya(0),l=no(s,We),u=no(c,We);return(0,Q.jsx)(G.div,{ref:r,onMouseMove:e=>{let n=r.current;if(!n||!o)return;let i=n.getBoundingClientRect();s.set((e.clientX-i.left-i.width/2)*t),c.set((e.clientY-i.top-i.height/2)*t)},onMouseLeave:()=>{s.set(0),c.set(0)},style:{x:l,y:u},className:q(`inline-block`,n),children:e})}(0,Z.forwardRef)(function({strength:e=.25,magneticClassName:t,children:n,...r},i){return(0,Q.jsx)(ud,{strength:e,className:t,children:(0,Q.jsx)(ld,{ref:i,...r,children:n})})});var dd=.025,fd=`blur(6px)`,pd={initial:{opacity:0,y:`105%`,filter:fd},animate:(e=0)=>({opacity:1,y:`0%`,filter:`blur(0px)`,transition:{...Ke,delay:e}}),exit:(e=0)=>({opacity:0,y:`-105%`,filter:fd,transition:{duration:.16,ease:Ue,delay:e*.5}})},md={initial:{opacity:0,width:0,scale:.7,filter:fd},animate:{opacity:1,width:`1.5rem`,scale:1,filter:`blur(0px)`,transition:Ke},exit:{opacity:0,width:0,scale:.7,filter:fd,transition:{duration:.16,ease:Ue}}};function hd({keyId:e,children:t}){let n=K();return(0,Q.jsx)(G.span,{variants:md,initial:n?{opacity:0}:`initial`,animate:n?{opacity:1}:`animate`,exit:n?{opacity:0}:`exit`,transition:n?{duration:.15}:void 0,className:`inline-grid shrink-0 place-items-center overflow-hidden`,children:t},e)}function gd({value:e,children:t}){let n=K(),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(),o=typeof t==`string`?t:null,s=o!==null&&!n;return(0,Z.useLayoutEffect)(()=>{let e=r.current?.offsetWidth;e&&a(t=>t===e?t:e)}),(0,Q.jsxs)(G.span,{initial:!1,layout:`size`,style:{width:i},transition:n?{duration:0}:Ke,className:`relative inline-block overflow-hidden whitespace-nowrap align-bottom`,children:[(0,Q.jsx)(`span`,{ref:r,"aria-hidden":!0,className:`invisible inline-block whitespace-nowrap`,children:s?o.split(``).map((e,t)=>(0,Q.jsx)(`span`,{className:`inline-block whitespace-pre`,children:e},t)):t}),s?(0,Q.jsx)(`span`,{className:`sr-only`,children:o}):null,(0,Q.jsx)(Be,{initial:!1,children:s?(0,Q.jsx)(G.span,{"aria-hidden":!0,initial:`initial`,animate:`animate`,exit:`exit`,className:`absolute left-0 top-0 inline-block whitespace-pre`,children:o.split(``).map((e,t)=>(0,Q.jsx)(G.span,{custom:t*dd,variants:pd,className:`inline-block whitespace-pre`,children:e},t))},`cascade-${e}`):(0,Q.jsx)(G.span,{initial:n?{opacity:0}:{opacity:0,y:14,filter:fd},animate:n?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:n?{opacity:0}:{opacity:0,y:-14,filter:fd},transition:n?{duration:.15}:Ke,className:`absolute left-0 top-0 inline-block`,children:t},`text-${e}`)})]})}(0,Z.forwardRef)(function({state:e=`idle`,children:t,loadingText:n=`Loading`,successText:r=`Done`,errorText:i=`Try again`,icon:a,disabled:o,...s},c){let l=e===`loading`,u=e===`loading`?n:e===`success`?r:e===`error`?i:t,d=typeof u==`string`?`${e}-${u}`:e;return(0,Q.jsx)(ld,{ref:c,disabled:o||l,"aria-busy":l,whileHover:void 0,...s,children:(0,Q.jsxs)(`span`,{"aria-live":`polite`,className:`relative inline-flex items-center justify-center overflow-hidden`,children:[(0,Q.jsxs)(Be,{initial:!1,children:[e===`loading`?(0,Q.jsx)(hd,{keyId:`loading-icon`,children:(0,Q.jsx)(Br,{className:`h-4 w-4 animate-spin`})}):null,e===`success`?(0,Q.jsx)(hd,{keyId:`success-icon`,children:(0,Q.jsx)(_r,{className:`h-4 w-4`})}):null,e===`error`?(0,Q.jsx)(hd,{keyId:`error-icon`,children:(0,Q.jsx)(ut,{className:`h-4 w-4`})}):null]}),(0,Q.jsx)(gd,{value:d,children:u}),(0,Q.jsx)(Be,{initial:!1,children:e===`idle`&&a?(0,Q.jsx)(hd,{keyId:`idle-icon`,children:a}):null})]})})});var _d={duration:0},vd={type:`spring`,duration:.4,bounce:.3},yd={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},bd={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},xd=(0,Z.createContext)(null);function Sd(e){let t=(0,Z.useContext)(xd);if(!t)throw Error(`${e} must be used within <AnimatedSelect>`);return t}function Cd({value:e,defaultValue:t,onValueChange:n,disabled:r=!1,className:i,children:a}){let o=K()??!1,s=(0,Z.useId)(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(t),[p,m]=(0,Z.useState)(new Map),[h,g]=(0,Z.useState)(`bottom`),_=e!==void 0,v=_?e:d,y=(0,Z.useCallback)(e=>{_||f(e),n?.(e),u(!1)},[_,n]),b=(0,Z.useCallback)((e,t)=>{m(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),x=(0,Z.useCallback)(e=>{m(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]);(0,Z.useEffect)(()=>{if(!l)return;let e=e=>e.key===`Escape`&&u(!1),t=e=>{c.current&&!c.current.contains(e.target)&&u(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t)}},[l]);let S=(0,Z.useMemo)(()=>({value:v,open:l,setOpen:u,select:y,register:b,unregister:x,labelFor:e=>e===void 0?void 0:p.get(e),reduce:o,triggerId:`${s}-trigger`,listId:`${s}-list`,disabled:r,placement:h,setPlacement:g}),[v,l,y,b,x,p,o,s,r,h]);return(0,Q.jsx)(xd.Provider,{value:S,children:(0,Q.jsx)(`div`,{ref:c,className:q(`relative`,i),children:a})})}function wd({className:e,children:t}){let n=Sd(`AnimatedSelectTrigger`),r=n.placement===`top`,i=n.open?[0,0,12]:[12,0,12],a=n.reduce?{duration:0}:n.open?{duration:.6,times:[0,.4,1],ease:Ue}:{duration:.42,times:[0,.5,1],ease:Ue};return(0,Q.jsxs)(G.button,{type:`button`,id:n.triggerId,disabled:n.disabled,"aria-haspopup":`listbox`,"aria-expanded":n.open,"aria-controls":n.listId,onClick:()=>n.setOpen(!n.open),initial:!1,animate:{borderTopLeftRadius:r?i:12,borderTopRightRadius:r?i:12,borderBottomLeftRadius:r?12:i,borderBottomRightRadius:r?12:i},transition:{borderTopLeftRadius:r?a:_d,borderTopRightRadius:r?a:_d,borderBottomLeftRadius:r?_d:a,borderBottomRightRadius:r?_d:a},className:q(`relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors`,`hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20`,`disabled:pointer-events-none disabled:opacity-50`,e),children:[t,(0,Q.jsx)(G.span,{"aria-hidden":!0,animate:{rotate:n.open?180:0},transition:n.reduce?{duration:0}:vd,className:`text-muted-foreground`,children:(0,Q.jsx)(yr,{className:`h-4 w-4`})})]})}function Td({className:e,children:t}){let n=Sd(`AnimatedSelectContent`),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),o=n.open,{setPlacement:s}=n;(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}),(0,Z.useLayoutEffect)(()=>{if(!o)return;let e=document.getElementById(n.triggerId),t=r.current;if(!e||!t)return;let i=e.getBoundingClientRect(),a=t.offsetHeight,c=window.innerHeight-i.bottom,l=i.top;s(c<a+16&&l>c?`top`:`bottom`)},[o,n.triggerId,s]);let c=n.placement===`top`,l=o?8:0,u=o?12:0,d=o?{type:`spring`,duration:.6,bounce:.5,delay:.12}:{type:`spring`,duration:.3,bounce:.1},f=o?{duration:.3,ease:Ue,delay:.14}:{duration:.16,ease:Ue};return(0,Q.jsx)(G.div,{id:n.listId,role:`listbox`,"aria-labelledby":n.triggerId,"aria-hidden":!o,inert:!o,initial:!1,animate:n.reduce?{opacity:+!!o,height:o?i:0}:{opacity:+!!o,height:o?i:0,marginTop:c?0:l,marginBottom:c?l:0,borderTopLeftRadius:c?12:u,borderTopRightRadius:c?12:u,borderBottomLeftRadius:c?u:12,borderBottomRightRadius:c?u:12},transition:n.reduce?{duration:.12}:{opacity:o?{duration:.18}:{duration:.16,delay:.12},height:o?{type:`spring`,duration:.42,bounce:.14}:{duration:.26,ease:Ue,delay:.14},marginTop:c?_d:d,marginBottom:c?d:_d,borderTopLeftRadius:c?_d:f,borderTopRightRadius:c?_d:f,borderBottomLeftRadius:c?f:_d,borderBottomRightRadius:c?f:_d},style:{transformOrigin:c?`bottom`:`top`,overflow:`hidden`,pointerEvents:o?`auto`:`none`},className:q(`absolute left-0 right-0 z-20 rounded-xl border border-border bg-background shadow-lg`,c?`bottom-full`:`top-full`,e),children:(0,Q.jsx)(G.div,{ref:r,variants:n.reduce?void 0:yd,initial:!1,animate:o?`show`:`hidden`,className:`p-1`,children:t})})}function Ed({value:e,disabled:t=!1,className:n,children:r}){let i=Sd(`AnimatedSelectItem`),a=i.value===e,o=typeof r==`string`?r:e;return(0,Z.useLayoutEffect)(()=>(i.register(e,o),()=>i.unregister(e)),[i.register,i.unregister,e,o]),(0,Q.jsx)(G.li,{variants:i.reduce?void 0:bd,children:(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,disabled:t,onClick:()=>i.select(e),className:q(`flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors`,a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted`,`disabled:pointer-events-none disabled:opacity-50`,n),children:[r,a?(0,Q.jsx)(_r,{className:`h-3.5 w-3.5 shrink-0`}):null]})})}function Dd({value:e,defaultValue:t=``,onValueChange:n,models:r=[],model:i,defaultModel:a,onModelChange:o,actions:s=[],onAction:c,onSubmit:l,loading:u=!1,submitWhileLoading:d=!1,onStop:f,minRows:p=2,maxRows:m=8,leadingAction:h,className:g,disabled:_,placeholder:v=`Ask the agent to do something…`,"aria-label":y=`Prompt`,onKeyDown:b,...x}){let S=K()??!1,C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(t),[D,O]=(0,Z.useState)(a??r[0]?.value),[k,A]=(0,Z.useState)(!1),j=e??T,M=i??D,N=r.find(e=>e.value===M),P=!!j.trim()&&!_&&(!u||d),F=(0,Z.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t||e.value!==j)return;let n=`${Math.min(Math.max(t.scrollHeight,p*24),m*24)}px`;e.style.height!==n&&(e.style.height=n)},[j,m,p]);(0,Z.useLayoutEffect)(()=>{F()},[F]),(0,Z.useEffect)(()=>{let e=C.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(F);return t.observe(e),()=>t.disconnect()},[F]);let I=t=>{e===void 0&&E(t),n?.(t)},L=e=>{i===void 0&&O(e),o?.(e)},R=t=>{t?.preventDefault();let n=j.trim();!n||_||u&&!d||(l?.(n,M),e===void 0&&E(``),C.current?.focus({preventScroll:!0}))},z=e=>{b?.(e),!(e.defaultPrevented||e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing)&&(e.preventDefault(),R())};return(0,Q.jsxs)(`form`,{onSubmit:R,className:q(`relative w-full rounded-[24px] border border-border/70 bg-sidebar p-2 text-[color:var(--foreground)] shadow-sm transition-[border-color,box-shadow] focus-within:border-foreground/25 focus-within:ring-1 focus-within:ring-ring/20`,_&&`opacity-60`,g),children:[(0,Q.jsx)(`div`,{ref:w,"aria-hidden":`true`,className:`pointer-events-none invisible absolute inset-x-2 top-0 whitespace-pre-wrap px-2 text-sm leading-6 [overflow-wrap:break-word]`,children:`${j}\u200b`}),(0,Q.jsx)(`textarea`,{ref:C,value:j,disabled:_,placeholder:v,"aria-label":y,rows:p,...x,onChange:e=>I(e.target.value),onKeyDown:z,className:`scrollbar-hide block w-full resize-none overflow-y-auto bg-transparent px-2 pt-1.5 text-sm leading-6 text-foreground outline-none placeholder:text-foreground/55`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex min-h-8 items-center gap-1`,children:[s.length?(0,Q.jsxs)(Ol,{open:k,onOpenChange:A,children:[(0,Q.jsx)(Al,{children:(0,Q.jsx)(ld,{type:`button`,variant:`ghost`,size:`icon`,disabled:_||u,"aria-label":`Add to prompt`,className:`size-8 rounded-full text-foreground/70 hover:text-foreground`,children:(0,Q.jsx)(G.span,{"aria-hidden":`true`,animate:{rotate:k?45:0},transition:S?{duration:0}:Ke,children:(0,Q.jsx)(hi,{className:`size-4`})})})}),(0,Q.jsx)(Fl,{side:`top`,align:`start`,sideOffset:8,radius:12,className:`w-56 p-1.5`,children:s.map(e=>(0,Q.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>{c?.(e.value),A(!1)},className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-50`,children:[e.icon?(0,Q.jsx)(`span`,{className:`mt-0.5 grid size-5 shrink-0 place-items-center text-foreground/70 [&_svg]:size-4`,children:e.icon}):null,(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm text-foreground`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-4 text-foreground/60`,children:e.description}):null]})]},e.value))})]}):null,h,r.length?(0,Q.jsxs)(Cd,{value:M,onValueChange:L,disabled:_||u,className:`min-w-0`,children:[(0,Q.jsx)(wd,{className:`h-8 w-auto max-w-52 rounded-xl border-0 bg-transparent px-2 py-0 text-xs hover:bg-muted focus-visible:ring-2`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[N?.icon?(0,Q.jsx)(`span`,{className:`grid size-4 shrink-0 place-items-center text-foreground/70 [&_svg]:size-3.5`,children:N.icon}):null,(0,Q.jsx)(`span`,{className:`truncate text-foreground/70`,children:N?.label??`Choose model`})]})}),(0,Q.jsx)(Td,{className:`right-auto w-52 shadow-none`,children:r.map(e=>(0,Q.jsx)(Ed,{value:e.value,disabled:e.disabled,className:`py-2`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e.icon?(0,Q.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-muted-foreground [&_svg]:size-4`,children:e.icon}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm text-foreground`,children:e.label})]})},e.value))})]}):null,u&&f?(0,Q.jsx)(ld,{type:`button`,size:`icon`,"aria-label":`Stop generating`,onClick:f,className:`ml-auto size-8 rounded-full`,children:(0,Q.jsx)(Hn,{className:`size-3 fill-current`})}):null,!u||P?(0,Q.jsx)(ld,{type:`submit`,size:`icon`,disabled:!P,"aria-label":u?`Steer current run`:`Send prompt`,className:q(`size-8 rounded-full`,!u&&`ml-auto`),children:(0,Q.jsx)(Be,{initial:!1,mode:`popLayout`,children:(0,Q.jsx)(G.span,{initial:S?{opacity:1}:{opacity:0,y:3,scale:.8},animate:{opacity:1,y:0,scale:1},exit:S?{opacity:0}:{opacity:0,y:-3,scale:.8},transition:S?{duration:0}:Ke,className:`grid place-items-center`,children:(0,Q.jsx)(Ao,{className:`size-4`})},`send`)})}):null]})]})}var Od=[`·`,`•`,`●`,`•`];function kd({label:e,isActive:t,className:n}){let[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{if(!t){i(0),o(0);return}let e=Date.now(),n=window.setInterval(()=>{i(Math.max(0,Math.floor((Date.now()-e)/1e3))),o(e=>e+1)},500);return()=>window.clearInterval(n)},[t]),!t||!e?null:(0,Q.jsxs)(`div`,{className:q(`flex items-center gap-2 px-an-context-padding py-1 text-xs text-foreground/70`,n),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-an-primary-color`,children:Od[a%Od.length]}),(0,Q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:e}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`truncate`,children:e}),(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:`tabular-nums text-foreground/50`,children:[r,`s`]})]})}var Ad=`M5 13l4 4L19 7`,jd=`M6 12h12`;function Md({checked:e,onCheckedChange:t,disabled:n,indeterminate:r,label:i,className:a,id:o,"aria-label":s,"aria-describedby":c}){let l=(0,Z.useId)(),u=o??l,d=K(),f=e||r,p=r?jd:Ad;return(0,Q.jsxs)(`label`,{htmlFor:u,className:q(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,a),children:[(0,Q.jsx)(G.button,{id:u,type:`button`,role:`checkbox`,"aria-checked":r?`mixed`:e,"aria-label":s,"aria-describedby":c,disabled:n,onClick:()=>!n&&t(!e),whileTap:d||n?void 0:{scale:.92},transition:ze,"data-state":e?`checked`:r?`indeterminate`:`unchecked`,className:q(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,f?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground/50 bg-background hover:border-muted-foreground`),children:(0,Q.jsx)(Be,{initial:!1,children:f?(0,Q.jsxs)(G.svg,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:3,strokeLinecap:`round`,strokeLinejoin:`round`,initial:d?{opacity:1}:{opacity:0,scale:.5},animate:d?{opacity:1}:{opacity:1,scale:1},exit:d?{opacity:0}:{opacity:0,scale:.5,filter:`blur(4px)`},transition:d?{duration:0}:{duration:.16,ease:Ue},"aria-hidden":!0,children:[(0,Q.jsx)(`title`,{children:r?`Partially selected`:`Selected`}),(0,Q.jsx)(G.path,{d:p,initial:d?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:d?{duration:0}:{duration:r?.2:.3,ease:Ue,delay:.04}})]},r?`indeterminate`:`checked`):null})}),i?(0,Q.jsx)(`span`,{className:q(`select-none text-sm text-foreground`,n&&`opacity-60`),children:i}):null]})}var Nd=(0,Z.forwardRef)(function({label:e,value:t,defaultValue:n,onChange:r,onFocus:i,onBlur:a,error:o,success:s,leftIcon:c,rightIcon:l,className:u,classNames:d,disabled:f,id:p,type:m,...h},g){let _=(0,Z.useId)(),v=p??_,y=K(),b=t!==void 0,[x,S]=(0,Z.useState)(n??``),C=b?t??``:x,[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(null),D=!!o,O=typeof o==`string`?o:null,k=s?null:l;(0,Z.useEffect)(()=>{!E.current||y||!D||Oo(E.current,{x:[0,-6,6,-4,4,-2,0]},{duration:.45})},[D,y]);let A=e=>{b||S(e),r?.(e)};return(0,Q.jsxs)(`div`,{className:q(`flex flex-col gap-1.5`,u,d?.root),children:[e?(0,Q.jsx)(`label`,{htmlFor:v,className:q(`px-1 text-sm font-medium text-foreground`,d?.label),children:e}):null,(0,Q.jsxs)(`div`,{ref:E,"data-state":D?`error`:s?`success`:w?`focused`:`idle`,className:q(`relative h-11 overflow-hidden rounded-full border transition-colors duration-200`,`border-border`,w&&!D&&`border-foreground/40 ring-2 ring-ring/40`,D&&`border-destructive ring-2 ring-destructive/25`,f&&`opacity-60`,d?.field),children:[c?(0,Q.jsx)(`span`,{className:q(`pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4`,d?.leftIcon),children:c}):null,(0,Q.jsx)(`input`,{ref:g,id:v,type:m,value:C,disabled:f,"aria-invalid":D||void 0,"aria-describedby":O?`${v}-error`:void 0,...h,onChange:e=>A(e.target.value),onFocus:e=>{T(!0),i?.(e)},onBlur:e=>{T(!1),a?.(e)},className:q(`peer h-full w-full bg-transparent text-base leading-6 text-foreground caret-foreground outline-none`,`placeholder:text-muted-foreground/60`,c?`pl-10`:`pl-3.5`,k||s?`pr-10`:`pr-3.5`,f&&`cursor-not-allowed`,d?.input)}),s?(0,Q.jsx)(G.svg,{viewBox:`0 0 24 24`,fill:`none`,className:q(`absolute right-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-(--color-success)`,d?.successIcon),children:(0,Q.jsx)(G.path,{d:`M5 12.5l4.5 4.5L19 7.5`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:y?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:{duration:.35,ease:`easeOut`}})}):k?(0,Q.jsx)(`span`,{className:q(`absolute right-0 top-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4`,d?.rightIcon),children:k}):null]}),(0,Q.jsx)(Be,{initial:!1,children:O?(0,Q.jsx)(G.p,{id:`${v}-error`,role:`alert`,initial:y?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},animate:{opacity:1,y:0,filter:`blur(0px)`},exit:y?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},transition:{duration:.2},className:q(`px-1 text-xs text-destructive`,d?.errorMessage),children:O}):null})]})}),Pd=(0,Z.createContext)(null);function Fd(){let e=(0,Z.useContext)(Pd);if(!e)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);return e}function Id({value:e,defaultValue:t=``,onValueChange:n,children:r,className:i,orientation:a=`vertical`}){let[o,s]=(0,Z.useState)(t),c=(0,Z.useId)(),l=K(),u=e!==void 0,d=u?e:o,f=(0,Z.useCallback)(e=>{u||s(e),n?.(e)},[u,n]),p=(0,Z.useMemo)(()=>({value:d,setValue:f,layoutId:c}),[d,c,f]);return(0,Q.jsx)(Ja,{transition:l?{duration:0}:He,children:(0,Q.jsx)(Pd.Provider,{value:p,children:(0,Q.jsx)(`div`,{role:`radiogroup`,className:q(`flex gap-3`,a===`vertical`?`flex-col`:`flex-row flex-wrap`,i),children:r})})})}function Ld({value:e,label:t,disabled:n,className:r,id:i}){let{value:a,setValue:o,layoutId:s}=Fd(),c=(0,Z.useId)(),l=i??c,u=K(),d=a===e;return(0,Q.jsxs)(`label`,{htmlFor:l,className:q(`inline-flex items-center gap-3`,n?`cursor-not-allowed`:`cursor-pointer`,r),children:[(0,Q.jsx)(G.button,{id:l,type:`button`,role:`radio`,"aria-checked":d,disabled:n,onClick:()=>!n&&o(e),whileTap:u||n?void 0:{scale:.92},transition:ze,"data-state":d?`checked`:`unchecked`,className:q(`relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-60`,d?`border-primary`:`border-muted-foreground/50 hover:border-muted-foreground`),children:d?(0,Q.jsx)(G.span,{layoutId:s,className:`absolute inset-1 rounded-full bg-primary`,transition:u?{duration:0}:He}):null}),t?(0,Q.jsx)(`span`,{className:q(`select-none text-sm text-foreground`,n&&`opacity-60`),children:t}):null]})}var Rd={selected:[],custom:``};function zd(e){return e===`submitting`?`Submitting`:e===`approved`?`Approved`:e===`rejected`?`Rejected`:e===`changes-requested`?`Changes requested`:e===`answered`?`Response submitted`:`Input required`}function Bd(e){return e===`approved`||e===`answered`?`text-emerald-600 dark:text-emerald-400`:e===`rejected`?`text-rose-600 dark:text-rose-400`:e===`changes-requested`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function Vd(e){return e===`pending`||e===`changes-requested`?`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`:e===`submitting`?`border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400`:e===`approved`||e===`answered`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400`}function Hd(e){return e.selected.length>0||!!e.custom?.trim()}function Ud({question:e,answer:t,disabled:n,onChange:r,onSingleSelect:i}){let a=t.custom??``,o=new Set(t.selected);return(0,Q.jsxs)(`div`,{className:`mt-3`,children:[e.options?.length?e.multiple?(0,Q.jsx)(`div`,{className:`grid gap-0.5`,children:e.options.map(e=>(0,Q.jsx)(Md,{checked:o.has(e.value),disabled:n||e.disabled,label:e.label,onCheckedChange:n=>r({...t,selected:n?[...t.selected,e.value]:t.selected.filter(t=>t!==e.value)}),className:`min-h-9 rounded-lg px-1.5 py-1`},e.value))}):(0,Q.jsx)(Id,{value:t.selected[0]??``,onValueChange:e=>{r({selected:[e],custom:``}),i?.()},className:`gap-0.5`,children:e.options.map(e=>(0,Q.jsx)(Ld,{value:e.value,label:e.label,disabled:n||e.disabled,className:`min-h-9 rounded-lg px-1.5 py-1`},e.value))}):null,e.allowCustom?(0,Q.jsx)(Nd,{value:a,disabled:n,placeholder:e.customPlaceholder??`Add another response…`,onChange:n=>r({selected:e.multiple?t.selected:[],custom:n}),className:q(`p-0.5`,e.options?.length&&`mt-1.5`),classNames:{field:`h-10 rounded-xl border-0 bg-background/70 focus-within:bg-background`,input:`px-3 text-sm`}}):null]})}function Wd({current:e,ids:t}){return(0,Q.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Question `,e+1,` of `,t.length]}),t.map((t,n)=>(0,Q.jsx)(G.span,{"aria-hidden":`true`,initial:{scale:n===e?1:.75,opacity:n<=e?1:.35},animate:{scale:n===e?1:.75,opacity:n<=e?1:.35},transition:Ke,className:`size-1.5 rounded-full bg-foreground`},t))]})}function Gd({title:e=`Approval required`,description:t,children:n,questions:r=[],status:i=`pending`,answers:a,defaultAnswers:o={},onAnswersChange:s,step:c,defaultStep:l=0,onStepChange:u,onSubmit:d,onApprove:f,onReject:p,onRequestChanges:m,onDismiss:h,approveLabel:g=`Approve`,submitLabel:_=`Submit response`,result:v,className:y}){let b=K()??!1,[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(l),T=(0,Z.useRef)(void 0),E=a??x,D=Math.min(Math.max(0,c??C),Math.max(0,r.length-1)),O=r[D],k=r.length>0,A=i===`pending`,j=i===`submitting`,M=A||j,N=O?E[O.id]??Rd:Rd,P=O?.title??e,F=O?.id??String(i),I=zd(i),L=(0,Z.useCallback)(()=>{T.current!==void 0&&(window.clearTimeout(T.current),T.current=void 0)},[]);(0,Z.useEffect)(()=>L,[L]);let R=(0,Z.useCallback)(e=>{a===void 0&&S(e),s?.(e)},[a,s]),z=e=>{L(),c===void 0&&w(e),u?.(e)};return(0,Q.jsx)(`div`,{"data-state":i,"aria-busy":j,className:q(`w-full overflow-hidden rounded-2xl bg-muted p-4 text-sm`,y),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid size-5 shrink-0 place-items-center text-muted-foreground`,Bd(i)),children:j?(0,Q.jsx)(Br,{className:q(`size-4`,!b&&`animate-spin`)}):M?k?(0,Q.jsx)(No,{className:`size-4`}):(0,Q.jsx)(Go,{className:`size-4`}):i===`rejected`?(0,Q.jsx)(ut,{className:`size-4`}):(0,Q.jsx)(_r,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 text-base font-medium leading-5 text-foreground`,children:(0,Q.jsx)(Ur,{value:F,children:P})}),k&&M?(0,Q.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-muted-foreground/65`,children:[D+1,`/`,r.length]}):(0,Q.jsx)(`span`,{className:q(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors`,Vd(i)),children:I}),h?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:h,className:`grid size-5 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(ut,{className:`size-4`})}):null]}),(0,Q.jsxs)(Vr,{open:M,children:[(0,Q.jsx)(Be,{initial:!1,mode:`wait`,children:k&&O?(0,Q.jsxs)(G.div,{initial:b?{opacity:1}:{opacity:0,x:8},animate:{opacity:1,x:0},exit:b?{opacity:0}:{opacity:0,x:-6},transition:{duration:b?0:.2,ease:Ue},children:[O.description?(0,Q.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:O.description}):null,(0,Q.jsx)(Ud,{question:O,answer:N,disabled:j,onChange:e=>{O&&R({...E,[O.id]:e})},onSingleSelect:()=>{!O||O.multiple||O.autoAdvance===!1||D>=r.length-1||j||(L(),T.current=window.setTimeout(()=>{z(D+1)},240))}})]},O.id):(0,Q.jsxs)(G.div,{initial:!1,children:[t?(0,Q.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:t}):null,n?(0,Q.jsx)(`div`,{className:`mt-3`,children:n}):null]},`description`)}),k?(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,Q.jsx)(ld,{variant:`ghost`,size:`icon`,"aria-label":`Previous question`,disabled:j||D===0,onClick:()=>z(D-1),className:`rounded-full`,children:(0,Q.jsx)(yn,{className:`size-4`})}),(0,Q.jsx)(Wd,{current:D,ids:r.map(e=>e.id)}),(0,Q.jsx)(ld,{size:D===r.length-1?`sm`:`icon`,"aria-label":D===r.length-1?`Submit response`:`Next question`,disabled:j||!Hd(N),onClick:()=>{if(D<r.length-1){z(D+1);return}d?.(E)},className:`ml-auto rounded-full`,children:j?(0,Q.jsx)(Br,{className:q(`size-4`,!b&&`animate-spin`)}):D===r.length-1?(0,Q.jsxs)(Q.Fragment,{children:[_,(0,Q.jsx)(ko,{className:`size-3.5`})]}):(0,Q.jsx)(ko,{className:`size-4`})})]}):(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(ld,{size:`sm`,disabled:j,onClick:f,className:`rounded-full`,children:g}),m?(0,Q.jsx)(ld,{variant:`secondary`,size:`sm`,disabled:j,onClick:m,className:`rounded-full`,children:`Request changes`}):null,p?(0,Q.jsx)(ld,{variant:`ghost`,size:`sm`,disabled:j,onClick:p,className:`rounded-full text-muted-foreground hover:text-rose-600 dark:hover:text-rose-400`,children:`Reject`}):null]})]}),M?null:(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:v??I})]})]})})}function Kd({questionBar:e,navigation:t,roundedTop:n,onDismiss:r}){let{totalQuestions:i,clampedQuestionIndex:a,activeQuestion:o,showQuestionNavigation:s,canGoPrev:c,canGoNext:l,goToPreviousQuestion:u,goToNextQuestion:d,advanceQuestionIndex:f}=t;if(!o)return null;let p={id:o.id??`question-${a}`,title:o.title,description:o.description,multiple:o.kind===`multi`,allowCustom:o.kind===`text`||o.allowCustom,customPlaceholder:o.customPlaceholder??o.placeholder,options:o.options?.map(e=>({value:e.id??e.value??e.label,label:e.label}))};return(0,Q.jsxs)(`div`,{className:q(`mx-auto w-full max-w-[calc(100%-24px)] border-x border-t border-border`,n?`rounded-t-an-input-border-radius`:null),children:[(0,Q.jsxs)(`div`,{className:`flex h-7 items-center justify-between border-b border-border px-3 text-xs text-an-tool-color-muted`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(fr,{className:`h-3.5 w-3.5`}),`Question`]}),s&&(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:u,disabled:!c,className:`relative inline-flex size-5 items-center justify-center rounded-[4px] transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-2.5 after:-bottom-2.5 hover:bg-an-background-secondary active:scale-[0.96] disabled:opacity-40 disabled:active:scale-100`,"aria-label":`Previous question`,children:(0,Q.jsx)(Ir,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[a,` of `,i]}),(0,Q.jsx)(`button`,{type:`button`,onClick:d,disabled:!l,className:`relative inline-flex size-5 items-center justify-center rounded-[4px] transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-2.5 after:-bottom-2.5 hover:bg-an-background-secondary active:scale-[0.96] disabled:opacity-40 disabled:active:scale-100`,"aria-label":`Next question`,children:(0,Q.jsx)(yr,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsx)(Gd,{title:`Fleet Prime question`,questions:[p],submitLabel:e.submitLabel??`Continue`,status:`pending`,onSubmit:t=>{let n=t[p.id];if(!n)return;let s=n.custom?.trim()||void 0,c=n.selected.filter(e=>e!==`__custom__`),l=o.kind===`text`?{kind:`text`,questionId:o.id,text:s}:{kind:o.kind,questionId:o.id,selectedIds:c,text:s};e.onSubmit(l),a>=i?r(e.id):f()},className:`rounded-none bg-background p-0`},`${a}-${o.title}`),e.allowSkip?(0,Q.jsx)(`div`,{className:`border-t border-border bg-background px-3 py-2`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{e.onSkip?.(),e.onSubmit({kind:`skip`,questionId:o.id}),r(e.id)},className:`text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:e.skipLabel??`Skip`})}):null]})}var qd=(0,Z.memo)(function({modes:e,value:t,defaultValue:n,onChange:r,className:i}){let a=t!==void 0,[o,s]=(0,Z.useState)(n),c=a?t:o,l=e.find(e=>e.id===c)??e[0],[u,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(e=>{a||s(e),r?.(e),d(!1)},[a,r]);if(e.length===0)return null;let p=l?.icon,m=e.length>1,h=(0,Q.jsxs)(`button`,{type:`button`,className:q(`relative inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full px-2 text-[12px] leading-4 text-foreground/40 transition-[background-color,transform] duration-150 after:absolute after:inset-x-0 after:-top-1.5 after:-bottom-1.5 hover:bg-foreground/6 active:scale-[0.96]`,!m&&`pointer-events-none`,i),"aria-label":`Select mode`,children:[p&&(0,Q.jsx)(p,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:l?.label}),m&&(0,Q.jsx)(yr,{className:`size-3 text-foreground/40`})]});return m?(0,Q.jsx)(vl,{open:u,onOpenChange:d,side:`top`,align:`start`,trigger:h,children:e.map(e=>{let t=e.id===l?.id,n=e.icon;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:q(`flex w-full cursor-pointer items-start gap-2 rounded-[6px] px-2 py-2 text-left text-[12px] leading-4 text-foreground transition-[background-color,transform] duration-150 hover:bg-foreground/6 active:scale-[0.96]`,t&&`bg-foreground/6`),children:[n&&(0,Q.jsx)(n,{className:`mt-0.5 size-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium`,children:e.label}),e.description&&(0,Q.jsx)(`span`,{className:`block truncate text-foreground/40`,children:e.description})]}),t&&(0,Q.jsx)(_r,{className:`mt-0.5 size-3.5 shrink-0 text-foreground/60`})]},e.id)})}):h});Array.from({length:14},(e,t)=>t);function Jd(e,t){return(0,Z.useMemo)(()=>{if(!t||!e.startsWith(`/`))return[];let n=e.slice(1).toLowerCase();return t.filter(e=>e.name.startsWith(n))},[t,e])}function Yd(e,t){return(0,Z.useMemo)(()=>{if(!t)return[];let n=/(?:^|\s)@([^\s@]*)$/.exec(e);if(!n)return[];let r=n[1]?.toLowerCase()??``;return t.filter(e=>[e.name,e.id,e.path,e.description].filter(Boolean).join(` `).toLowerCase().includes(r))},[t,e])}function Xd({open:e,align:t=`start`,className:n,...r}){return(0,Q.jsx)(`div`,{"data-slot":`composer-menu`,"data-open":e||void 0,className:q(or,`absolute bottom-full z-10 mb-2 flex w-72 flex-col gap-0.5 rounded-2xl p-1.5`,t===`start`?`start-0 origin-bottom-left`:`end-0 origin-bottom-right`,`transition-[opacity,scale] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none`,e?`scale-100 opacity-100`:`pointer-events-none scale-[0.97] opacity-0`,n),...r})}function Zd({active:e=!1,className:t,...n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`composer-menu-item`,"data-active":e||void 0,className:q(`flex w-full items-center gap-2.5 rounded-[10px] px-2.5 py-2 text-[13.5px] transition-colors`,e?cr:`hover:bg-foreground/[0.04]`,t),...n})}function Qd(e,t){return t.icon?t.icon:e===`mention`?t.metadata?.kind===`folder`?(0,Q.jsx)(di,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(ui,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(Lo,{"aria-hidden":`true`,className:`size-4`})}function $d(e,t){return e&&e.length>0?e.flatMap(e=>e.items):t?[...t]:[]}var ef=(0,Z.memo)(function({open:e,kind:t,query:n,items:r,groups:i,activeIndex:a=0,onActiveIndexChange:o,onSelect:s,onClose:c,onBack:l,className:u,emptyLabel:d=`No matching items`,title:f,listId:p=`fleet-composer-trigger-list`}){let m=(0,Z.useMemo)(()=>$d(i,r),[i,r]);if(!e)return null;let h=!!(i&&i.length>0),g=m[a],_=(e,n)=>{let r=n===a,i=`${p}-${e.id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`;return(0,Q.jsxs)(Zd,{id:i,disabled:e.disabled,role:`option`,"aria-selected":r,"data-active":r?`true`:void 0,active:r,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>o?.(n),onClick:()=>{e.disabled||s(e)},className:q(`flex min-h-10 cursor-pointer items-start gap-2 rounded-lg px-3 py-2 text-left`,r&&`bg-accent text-accent-foreground`),children:[(0,Q.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground`,children:Qd(t,e)}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground`,children:e.description}):null]}),r?(0,Q.jsx)(br,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):null]},e.id)};return e?(0,Q.jsxs)(Xd,{open:!0,id:p,role:`listbox`,"aria-label":f??`Suggestions`,"aria-activedescendant":g?`${p}-${g.id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`:void 0,"data-slot":`composer-trigger-popover`,"data-kind":t,"data-state":`open`,className:q(`inset-x-0 z-50 mb-2 w-auto overflow-hidden rounded-xl border bg-popover text-popover-foreground shadow-xl`,u),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2 text-xs text-muted-foreground`,children:[l?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:l,className:`grid size-6 place-items-center rounded-md hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(xr,{"aria-hidden":`true`,className:`size-3.5`})}):null,(0,Q.jsx)(Yr,{"aria-hidden":`true`,className:`size-3.5`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:f??(t===`slash`?`Commands`:`Workspace`)}),n?(0,Q.jsx)(`span`,{className:`ml-auto max-w-[50%] truncate font-mono text-[11px]`,children:n}):null,c?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close suggestions`,onClick:c,className:`sr-only`,children:`Close suggestions`}):null]}),(0,Q.jsxs)(`div`,{className:`max-h-[min(42vh,360px)] overflow-y-auto p-1.5`,children:[m.length===0?(0,Q.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:d}):null,h?i?.map(e=>{let t=0;for(let n of i){if(n.id===e.id)break;t+=n.items.length}return(0,Q.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,Q.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),e.items.map((e,n)=>_(e,t+n))]},e.id)}):m.map(_)]})]}):null});function tf(e,t,n){return Math.min(n,Math.max(t,e))}function nf({value:e,onChange:t,min:n=0,max:r=100,step:i=1,label:a,formatValue:o=String,disabled:s=!1,className:c,...l}){let u=(0,Z.useId)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),h=Math.max(n,r),g=Math.max(2**-52,i),_=tf(e,n,h),v=h===n?0:(_-n)/(h-n),y=v*100,b=v===0?8:0,x=`calc(${y}% + ${20-20*v-b*2.5}px)`,S=`calc(${y}% + ${11-24*v}px)`,C=20-20*v-b*2.5,w=`linear-gradient(to right, transparent calc(${y}% + ${C}px), black calc(${y}% + ${C+2}px))`,T=(0,Z.useMemo)(()=>{let e=Math.floor((h-n)/g),t=Array.from({length:e+1},(e,t)=>n+t*g);return t.at(-1)!==h&&t.push(h),t},[n,h,g]),E=o(_),D=o(h),O=(e,t)=>{let r=t.getBoundingClientRect();if(r.width<=0||h===n)return n;let i=n+tf((e-r.left)/r.width,0,1)*(h-n);return tf(n+Math.round((i-n)/g)*g,n,h)},k=e=>{let r=!0,i=e.key===`ArrowRight`||e.key===`ArrowUp`?1:e.key===`ArrowLeft`||e.key===`ArrowDown`?-1:0;i===0?e.key===`Home`?(e.preventDefault(),t(n)):e.key===`End`?(e.preventDefault(),t(h)):r=!1:(e.preventDefault(),t(tf(_+i*g,n,h))),r&&e.stopPropagation()};return(0,Q.jsx)(`div`,{className:q(`relative w-full touch-none`,s&&`opacity-50`,c),...l,children:(0,Q.jsxs)(`div`,{className:q(`relative h-8 w-full select-none touch-none overflow-hidden rounded-md border border-border bg-background outline-offset-2 transition-colors duration-150`,p&&!s&&`border-foreground/25`,d&&`border-foreground/40 ring-2 ring-ring/60 ring-offset-1 ring-offset-background`),onPointerEnter:()=>m(!0),onPointerLeave:()=>m(!1),onPointerDown:e=>{s||t(O(e.clientX,e.currentTarget))},children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-0 z-[1] flex items-center justify-between px-3 pointer-events-none`,style:{WebkitMaskImage:w,maskImage:w},children:T.map(e=>(0,Q.jsx)(G.span,{className:`relative flex size-[5px] items-center justify-center rounded-full`,animate:{backgroundColor:e===_?`var(--foreground)`:`var(--muted-foreground)`,opacity:e===_?1:.3},transition:Pe},e))}),(0,Q.jsx)(G.div,{"aria-hidden":`true`,className:`absolute inset-y-0 left-0 z-[3] pointer-events-none bg-foreground/[0.08]`,layout:`size`,style:{width:x},transition:Pe}),(0,Q.jsx)(G.div,{"aria-hidden":`true`,className:q(`absolute z-[3] w-0.5 rounded-full pointer-events-none`),layout:!0,style:{left:S,top:p||d?7:8,bottom:p||d?7:8},animate:{backgroundColor:d?`var(--foreground)`:p?`color-mix(in srgb, var(--foreground) 50%, transparent)`:`color-mix(in srgb, var(--foreground) 25%, transparent)`},transition:Pe}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-[2] flex items-center px-2`,children:[a?(0,Q.jsx)(`span`,{className:`px-2 text-[13px] text-transparent select-none`,"aria-hidden":`true`,children:a}):null,(0,Q.jsx)(`span`,{className:`ml-auto px-2 text-[13px] text-transparent tabular-nums select-none`,style:{minWidth:`${D.length}ch`},"aria-hidden":`true`,children:D})]}),(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-[4] flex items-center px-2 text-[13px]`,children:[a?(0,Q.jsx)(G.span,{className:`px-2`,animate:{color:p||d?`var(--foreground)`:`var(--muted-foreground)`},transition:Pe,children:a}):null,(0,Q.jsx)(G.span,{className:`ml-auto px-2 tabular-nums`,style:{minWidth:`${D.length}ch`,textAlign:`right`},animate:{color:p||d?`var(--foreground)`:`var(--muted-foreground)`},transition:Pe,children:E})]}),(0,Q.jsx)(`input`,{id:u,type:`range`,min:n,max:h,step:g,value:_,disabled:s,"aria-label":a??`Slider`,"aria-valuetext":E,onChange:e=>t(Number(e.currentTarget.value)),onFocus:()=>f(!0),onBlur:()=>f(!1),onKeyDown:k,className:`absolute inset-0 z-20 m-0 h-full w-full cursor-ew-resize opacity-0 disabled:cursor-not-allowed`})]})})}function rf(e){let t=new Map;for(let n of e){let e=t.get(n.provider)??[];e.push(n),t.set(n.provider,e)}return[...t.entries()]}var af=(0,Z.memo)(function({models:e,value:t,effort:n,open:r,onOpenChange:i,onModelChange:a,onEffortChange:o,placeholder:s=`Model`,effortLabel:c=`Reasoning effort`,className:l,contentClassName:u}){let[d,f]=(0,Z.useState)(!1),p=(0,Z.useId)(),m=r??d,h=e=>{r===void 0&&f(e),i?.(e)},g=e.find(e=>e.id===t)??e[0],_=(0,Z.useMemo)(()=>rf(e),[e]),v=g?.efforts?.find(e=>e.id===n)??g?.efforts?.[0],y=(0,Q.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":m,"aria-controls":p,"aria-haspopup":`dialog`,"aria-label":`Select model and reasoning effort`,className:q(`relative inline-flex h-8 max-w-[18rem] min-w-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,l),children:[g?.icon?(0,Q.jsx)(`span`,{className:`shrink-0`,children:g.icon}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:g?.name??s}),v&&g?.reasoning?(0,Q.jsxs)(`span`,{className:`hidden shrink-0 text-muted-foreground/70 xl:inline`,children:[`· `,v.name]}):null,(0,Q.jsx)(yr,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]});return(0,Q.jsx)(vl,{contentId:p,open:m,onOpenChange:h,side:`top`,align:`start`,className:q(`w-[min(24rem,calc(100vw-2rem))] max-h-[min(55vh,28rem)] overflow-hidden p-0`,u),trigger:y,children:(0,Q.jsxs)(Xn,{className:`min-h-0 max-h-[min(55vh,28rem)] bg-transparent`,shouldFilter:!0,children:[(0,Q.jsx)(Vn,{placeholder:`Search models…`,"aria-label":`Search models`}),(0,Q.jsxs)(Yn,{className:`min-h-0 flex-1 p-1.5`,children:[(0,Q.jsx)(Jn,{children:`No matching models`}),_.map(([e,t])=>(0,Q.jsx)(Wn,{heading:t[0]?.providerLabel??e,children:t.map(e=>{let t=[e.id,e.name,e.provider,e.providerLabel,e.modelId,...e.keywords??[]].filter(Boolean).join(` `),n=e.id===g?.id;return(0,Q.jsxs)(Kn,{value:t,disabled:e.disabled,onSelect:()=>{e.disabled||a?.(e.id)},className:`items-start gap-2 rounded-lg px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground`,children:e.icon??(0,Q.jsx)(Ho,{"aria-hidden":`true`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),e.disabled?(0,Q.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Unavailable`}):null]}),(0,Q.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground`,children:[e.modelId??e.id,e.reasoning?` · reasoning`:``]}),e.description?(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground/80`,children:e.description}):null]}),n?(0,Q.jsx)(_r,{"aria-hidden":`true`,className:`mt-1 size-4 shrink-0`}):null]},e.id)})},e))]}),g?.reasoning&&g.efforts?.length?(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/70 p-2`,children:(0,Q.jsx)(nf,{label:c,value:Math.max(0,g.efforts.findIndex(e=>e.id===v?.id)),onChange:e=>{let t=g.efforts?.[Math.round(e)];t&&!t.disabled&&o?.(t.id)},min:0,max:Math.max(0,g.efforts.length-1),formatValue:e=>g.efforts?.[Math.round(e)]?.name??``})}):null]})})});function of(e){let[t,n]=(0,Z.useState)(1),r=e?.questions??[],i=r.length>0,a=i?r.length:1,o=e?.totalQuestions??a,s=e?.onPreviousQuestion||e?.onNextQuestion?e?.questionIndex??1:t,c=Math.max(1,Math.min(s,o)),l=i?r[c-1]:void 0,u=o>1,d=c>1,f=c<o;return{questionSet:r,totalQuestions:o,clampedQuestionIndex:c,activeQuestion:l,showQuestionNavigation:u,canGoPrev:d,canGoNext:f,goToPreviousQuestion:(0,Z.useCallback)(()=>{if(d){if(e?.onPreviousQuestion){e.onPreviousQuestion();return}n(e=>Math.max(1,e-1))}},[d,e]),goToNextQuestion:(0,Z.useCallback)(()=>{if(f){if(e?.onNextQuestion){e.onNextQuestion();return}n(e=>Math.min(o,e+1))}},[f,e,o]),advanceQuestionIndex:(0,Z.useCallback)(()=>{n(e=>Math.min(o,e+1))},[o])}}var sf=[];function cf(e){return e?Array.isArray(e)?e:e.items:[]}function lf(e){return(e.value??e.id).trim().replace(/^\/+/,``).split(/\s+/,1)[0]??e.id}function uf(e){return(e.value?.trim()??``).match(/^\/\S+\s+(.+)$/)?.[1]}function df({models:e,status:t,thinkingLevel:n,onModelChange:r,onThinkingLevelChange:i,onSend:a,onSlashCommandSelect:o,onLocalSlashSubmit:s,modelPickerOpen:c,onModelPickerOpenChange:l,effortPickerOpen:u,onEffortPickerOpenChange:d,workspaceReferences:f=sf,workspaceSuggestions:p,onWorkspaceReferenceSelect:m,onRemoveWorkspaceReference:h,controlled:g,disabled:_,questionBar:v,attachments:y,slashCommands:b}){let[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),T=g?.value??x,E=g?.onChange??S,D=t===`streaming`||t===`submitted`,O=of(v),k=cf(b),A=cf(p),j=(0,Z.useMemo)(()=>k.map(e=>({name:lf(e),description:[e.description,uf(e)].filter(Boolean).join(` `),icon:Yr})),[k]),M=(0,Z.useMemo)(()=>A.map(e=>({id:e.id,name:e.label,path:e.value??e.label,kind:e.metadata?.kind===`folder`?`folder`:`file`,description:e.description,role:`human`})),[A]),N=T.match(/^\/([^\s/]*)$/),P=T.match(/(?:^|\s)@([^\s@]*)$/),F=N?.[1]?.toLowerCase(),I=P?.[1]?.toLowerCase(),L=F===void 0?I===void 0?void 0:`mention`:`slash`,R=Jd(T,j),z=Yd(T,M),B=(0,Z.useMemo)(()=>{let e=new Set(R.map(e=>e.name));return k.filter(t=>e.has(lf(t)))},[k,R]),V=(0,Z.useMemo)(()=>{let e=new Set(z.map(e=>e.id).filter(e=>!!e));return A.filter(t=>e.has(t.id))},[z,A]),H=L===`slash`?B:V,[U,ee]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{ee(0)},[L,F,I,H.length]);let W=(0,Z.useCallback)((e,t=!1)=>{if(s?.(e)===!0){E(``);return}a({role:`user`,content:e,altKey:t}),E(``)},[s,a,E]),te=(0,Z.useCallback)(e=>{if(o?.(e)===!0){E(``);return}E(e.value??e.label)},[o,E]),ne=(0,Z.useCallback)(e=>{if(!e)return T;let t=e[0].length-e[0].trimStart().length,n=T.length-e[0].length+t;return T.slice(0,n)},[T]),re=(0,Z.useCallback)(e=>{m?.(e),E(ne(P))},[m,ne,E,P]),ie=(0,Z.useCallback)(e=>{let t=!D&&!_&&L!==void 0;if(e.key===`Backspace`&&T.length===0&&f.length>0){let t=f[f.length-1];if(t){e.preventDefault(),h?.(t.relativePath);return}}if(t&&e.key===`Escape`){e.preventDefault(),E(ne(L===`slash`?N:P));return}if(t&&H.length>0){if(e.key===`ArrowDown`){e.preventDefault(),ee(e=>(e+1)%H.length);return}if(e.key===`ArrowUp`){e.preventDefault(),ee(e=>(e-1+H.length)%H.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=H[U];t&&(L===`slash`?te(t):re(t));return}}if(e.key===`Enter`&&e.altKey&&!e.shiftKey){e.preventDefault();let t=T.trim();t&&!_&&W(t,!0)}},[U,_,D,h,ne,te,re,W,E,N,H,L,T,P,f]),ae=v&&v.id!==C,oe=y?.files??[],se=y?.images??[],ce=!!(L&&!D&&!_),le=(0,Z.useMemo)(()=>{if(L!==`slash`)return[];let e=new Map;for(let t of B){let n=t.category??`builtin`,r=e.get(n)??[];r.push(t),e.set(n,r)}let t={builtin:`Built-in`,extension:`Extensions`,prompt:`Prompts`,skill:`Skills`};return[...e.entries()].map(([e,n])=>({id:e,label:t[e]??e,items:n.map(e=>({...e,description:[e.description,uf(e)].filter(Boolean).join(` · `)}))}))},[B,L]),ue=(0,Z.useMemo)(()=>e.map(e=>({id:e.id,name:e.name,provider:e.provider,providerLabel:In(e.provider),modelId:e.modelId,icon:(0,Q.jsx)(Mn,{provider:e.provider,className:`size-4`}),disabled:e.available===!1,reasoning:e.reasoning,keywords:[e.provider,e.modelId,e.id],efforts:ti(e).map(e=>({id:e,name:ni(e)}))})),[e]);return{activeTriggerIndex:U,combinedPickerOpen:c===!0||u===!0,commandGroups:le,files:oe,handleCombinedPickerOpenChange:(0,Z.useCallback)(e=>{l?.(e),d?.(e)},[d,l]),handlePromptKeyDown:ie,handleSelectorModelChange:(0,Z.useCallback)(t=>{let a=e.find(e=>e.id===t);r(t),a&&i?.(Xr(n,ti(a)))},[e,r,i,n]),images:se,isStreaming:D,navigation:O,selectorModels:ue,selectCommand:te,selectWorkspaceReference:re,removeTriggerToken:ne,send:W,setActiveTriggerIndex:ee,setDismissedQuestionId:w,setValue:E,showQuestion:ae,triggerItems:H,triggerKind:L,triggerOpen:ce,slashMatch:N,slashQuery:F,workspaceMentionMatch:P,workspaceQuery:I,filteredCommands:B,filteredWorkspaceItems:V,value:T}}var ff=[{id:`agent`,label:`Agent`,icon:gr,description:`Default coding agent`},{id:`plan`,label:`Plan`,icon:$n,description:`Plan before executing`},{id:`harness`,label:`Harness`,icon:Xo,description:`Harness-aware turn`}],pf=[];function mf(e){return(0,Q.jsx)(hf,{...e})}function hf({modelKey:e,models:t,status:n,infoDescription:r,chatMode:i=`agent`,onChatModeChange:a,onModelChange:o,thinkingLevel:s,onThinkingLevelChange:c,onStop:l,onSend:u,onSlashCommandSelect:d,onLocalSlashSubmit:f,modelPickerOpen:p,onModelPickerOpenChange:m,effortPickerOpen:h,onEffortPickerOpenChange:g,workspaceReferences:_=pf,workspaceSuggestions:v,onWorkspaceReferenceSelect:y,onRemoveWorkspaceReference:b,controlled:x,disabled:S,autoFocus:C,placeholder:w,attachments:T,questionBar:E,slashCommands:D,className:O}){let{activeTriggerIndex:k,combinedPickerOpen:A,commandGroups:j,files:M,handleCombinedPickerOpenChange:N,handlePromptKeyDown:P,handleSelectorModelChange:F,images:I,isStreaming:L,navigation:R,filteredWorkspaceItems:z,removeTriggerToken:B,selectCommand:V,selectWorkspaceReference:U,selectorModels:ee,send:W,setActiveTriggerIndex:te,setDismissedQuestionId:ne,setValue:re,showQuestion:ie,slashMatch:ae,slashQuery:oe,triggerItems:se,triggerKind:ce,triggerOpen:le,value:ue,workspaceMentionMatch:de,workspaceQuery:fe}=df({models:t,status:n,thinkingLevel:s,onModelChange:o,onThinkingLevelChange:c,onSend:u,onSlashCommandSelect:d,onLocalSlashSubmit:f,modelPickerOpen:p,onModelPickerOpenChange:m,effortPickerOpen:h,onEffortPickerOpenChange:g,workspaceReferences:_,workspaceSuggestions:v,onWorkspaceReferenceSelect:y,onRemoveWorkspaceReference:b,controlled:x,disabled:S,questionBar:E,attachments:T,slashCommands:D});return(0,Q.jsx)(`div`,{className:q(`shrink-0 px-3 pb-3`,O),children:(0,Q.jsxs)(`div`,{className:`relative mx-auto w-full max-w-an`,children:[(0,Q.jsx)(kd,{label:r??void 0,isActive:L}),ie?(0,Q.jsx)(Kd,{questionBar:E,navigation:R,roundedTop:!0,onDismiss:ne}):null,(0,Q.jsx)(ef,{open:le,kind:ce??`slash`,query:ce===`slash`?oe:fe,items:ce===`mention`?z:void 0,groups:ce===`slash`?j:void 0,activeIndex:k,onActiveIndexChange:te,onSelect:e=>{ce===`slash`?V(e):U(e)},onClose:()=>re(B(ce===`slash`?ae:de)),title:ce===`slash`?`Commands`:`Workspace references`,listId:`fleet-composer-trigger-list`}),I.length>0||M.length>0?(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2 rounded-xl border bg-muted/40 p-2`,children:[I.map(e=>(0,Q.jsxs)(`div`,{className:`group relative`,children:[(0,Q.jsx)(`img`,{src:e.url,alt:e.filename,className:`size-16 rounded-lg border object-cover`}),(0,Q.jsx)(H,{type:`button`,variant:`outline`,size:`icon-xs`,"aria-label":`Remove ${e.filename}`,onClick:()=>T?.onRemoveImage?.(e.id),className:`absolute -right-1 -top-1 size-5 rounded-full bg-background opacity-0 shadow-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,Q.jsx)(ut,{"data-icon":`inline-start`,className:`size-3`})})]},e.id)),M.map(e=>(0,Q.jsx)(Sr,{id:e.id,filename:e.filename,size:e.size,onRemove:T?.onRemoveFile?()=>T.onRemoveFile?.(e.id):void 0},e.id))]}):null,_.length>0?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5 rounded-xl border bg-muted/40 p-2`,children:_.map(e=>(0,Q.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-lg border bg-background px-2 py-1 text-xs text-foreground/75`,children:[(0,Q.jsx)(qr,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`max-w-[min(28rem,70vw)] truncate`,children:[`@`,e.relativePath]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove workspace reference ${e.relativePath}`,onClick:()=>b?.(e.relativePath),className:`grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(ut,{className:`size-3`})})]},e.relativePath))}):null,(0,Q.jsx)(Dd,{id:`fleet-composer-prompt`,name:`prompt`,value:ue,onValueChange:re,onSubmit:e=>W(e),loading:L,submitWhileLoading:!0,onStop:l,disabled:S,autoFocus:C,placeholder:w??`Send a message…`,onPaste:T?.onPaste,"aria-controls":le?`fleet-composer-trigger-list`:void 0,"aria-expanded":le,"aria-haspopup":`listbox`,"aria-activedescendant":le&&se[k]?`fleet-composer-trigger-list-${se[k].id.replace(/[^a-zA-Z0-9_-]/g,`-`)}`:void 0,actions:T?.onAttach?[{value:`attach`,label:`Attach file`,description:`Add a file or image to this turn`,icon:(0,Q.jsx)(zo,{})}]:[],onAction:e=>{e===`attach`&&T?.onAttach?.()},onKeyDown:P,leadingAction:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qd,{modes:[...ff],value:i,onChange:e=>a?.(e)}),(0,Q.jsx)(af,{models:ee,value:e,effort:s,onModelChange:F,onEffortChange:e=>c?.(e),open:A,onOpenChange:N,placeholder:`Model`,className:`rounded-full`})]})})]})})}var gf=`Fleet Prime is not connected to the Prime Agent runtime. Start or reconnect the runtime, then try again.`;function _f(e){return e.code===`NETWORK_DISCONNECTED`||/Cannot send daemon command/i.test(e.message)||/Prime Agent daemon is not connected/i.test(e.message)||/not connected to the Prime Agent runtime/i.test(e.message)?{title:`Agent unavailable`,message:gf}:{title:`Request failed`,message:e.message.replace(/\s+(?:Socket|Daemon log):\s*[^\n]*(?:\s+(?:Socket|Daemon log):\s*[^\n]*)*/gi,``)}}var vf={dots:`rounded-full`,squares:`rounded-[1px]`,rounded:`rounded-[3px]`};function yf({label:e,tick:t,variant:n=`dots`,className:r,...i}){let a=Math.floor(t/3);return(0,Q.jsxs)(`div`,{"data-slot":`generation-loader`,className:q(`flex flex-col items-center gap-4`,r),...i,children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:`grid grid-cols-3 gap-1`,children:Array.from({length:9},(e,t)=>{let r=(t*2+a)%9<3;return(0,Q.jsx)(`span`,{className:q(`bg-foreground size-2 transition-opacity duration-300 motion-reduce:transition-none`,vf[n],r?`opacity-90`:`opacity-15`)},t)})}),(0,Q.jsx)(dr,{className:`text-foreground/55 relative inline-block text-sm`,children:e})]})}function bf({label:e,elapsed:t,className:n,...r}){return(0,Q.jsxs)(`div`,{"data-slot":`thinking-indicator`,className:q(`text-foreground/55 flex items-center gap-2.5 text-sm`,n),...r,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 animate-pulse rounded-full bg-blue-500 motion-reduce:animate-none dark:bg-blue-400`}),(0,Q.jsx)(dr,{className:`fade-in slide-in-from-bottom-1 animate-in relative inline-block leading-none duration-300`,children:e},e),t!==void 0&&(0,Q.jsx)(`span`,{className:q(`font-mono text-[11px] tracking-tight`,`text-foreground/30 tabular-nums`),children:t})]})}function xf({steps:e,visibleSteps:t,streaming:n,streamingLabel:r=`Thinking`,open:i,onOpenChange:a,restingLabel:o,elapsed:s,className:c}){let l=lr(e,t);return(0,Q.jsxs)(Jr,{"data-slot":`reasoning-panel`,open:i,onOpenChange:a,className:q(`w-full max-w-sm`,c),children:[(0,Q.jsxs)(Kr,{className:`group/trigger text-foreground/55 hover:text-foreground/90 flex items-center gap-1.5 py-1 text-[13.5px] transition-[color,scale] outline-none active:scale-[0.98]`,children:[(0,Q.jsxs)(er,{active:+!n,className:`text-start`,children:[(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(dr,{active:n,className:`relative inline-block leading-none`,children:r}),s!==void 0&&(0,Q.jsx)(`span`,{className:q(`font-mono text-[11px] tracking-tight`,`text-foreground/30 tabular-nums`),children:s})]}),(0,Q.jsx)(Q.Fragment,{children:o})]}),(0,Q.jsx)(yr,{className:`size-3.5 shrink-0 opacity-60 transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)] group-data-open/trigger:rotate-180 group-data-panel-open/trigger:rotate-180 motion-reduce:transition-none`})]}),(0,Q.jsx)(Wr,{className:q(tr,`outline-none`),children:(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4 pt-3 pb-1`,children:l.map((e,t)=>{let r=n&&t===l.length-1;return(0,Q.jsxs)(`li`,{className:`fade-in slide-in-from-bottom-1 animate-in fill-mode-both flex gap-3 duration-300`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-[7px] size-[5px] shrink-0 rounded-full transition-colors duration-300`,r?`animate-pulse bg-blue-500 dark:bg-blue-400`:`bg-foreground/20`)}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`p`,{className:`text-foreground/90 text-[13.5px] font-medium`,children:e.title}),(0,Q.jsx)(`p`,{className:`text-foreground/50 mt-0.5 text-[13px] leading-relaxed break-words`,children:e.body})]})]},e.id??`${e.title}-${t}`)})})})]})}function Sf({presentation:e,className:t,streamingOverride:n}){let[r,i]=(0,Z.useState)(void 0),a=n??e.streaming,o=r??a,s=(0,Z.useMemo)(()=>e.steps.map(e=>({id:e.id,title:e.title,body:e.body})),[e.steps]);if(!a&&s.length===0)return null;let c=Math.min(Math.max(0,e.visibleSteps),s.length),l=s.at(c-1),u=l?.title??Cf(e.phase),d=wf(e.elapsedMs);return(0,Q.jsxs)(`section`,{"data-slot":`fleet-reasoning-presentation`,"aria-label":`Safe reasoning progress`,className:q(`w-full max-w-xl rounded-xl border border-border/60 bg-muted/30 px-3 py-2.5 shadow-sm shadow-black/[0.02] dark:shadow-black/15`,t),children:[a?(0,Q.jsx)(`div`,{className:`mb-1.5 flex flex-col gap-1.5 border-b border-border/45 pb-2.5`,children:l?.body?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bf,{label:u,elapsed:d,className:`text-[13px]`}),(0,Q.jsx)(`p`,{className:`pl-4 text-xs font-normal text-muted-foreground`,children:l.body})]}):(0,Q.jsx)(yf,{label:u,tick:Math.floor((e.elapsedMs??0)/250),variant:`dots`,className:`items-start gap-2 px-1 py-1 text-left`})}):null,(0,Q.jsx)(xf,{steps:s,visibleSteps:c,streaming:a,streamingLabel:`Preparing response`,open:o,onOpenChange:i,restingLabel:e.restingLabel,elapsed:d,className:`max-w-none`})]})}function Cf(e){switch(e){case`waiting`:return`Preparing run`;case`context`:return`Reviewing workspace context`;case`planning`:return`Organising the response`;case`executing`:return`Completing requested work`;case`responding`:return`Writing the response`;case`recovering`:return`Recovering the run`;case`error`:return`Run needs attention`;case`complete`:return`Completed`;default:return`Working`}}function wf(e){if(e===void 0)return;let t=Math.max(0,Math.round(e/1e3));return t<60?String(t)+`s`:String(Math.floor(t/60))+`m `+String(t%60)+`s`}var Tf=[{key:`steering`,label:`Next`},{key:`followUp`,label:`After run`}];function Ef({queue:e,onDelete:t,className:n}){let r=e.steering.length+e.followUp.length;if(r===0)return null;let i=async(e,n,r)=>{try{await t?.(e,n,r)===!1&&vi.error(`Unable to remove queued message`)}catch{vi.error(`Unable to remove queued message`)}};return(0,Q.jsx)(`section`,{"aria-label":`Queued messages`,className:q(`mx-auto mb-2 w-full max-w-an px-3`,n),children:(0,Q.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-muted/30 p-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between px-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[r,` queued`]}),(0,Q.jsx)(`span`,{children:`Sent when the run reaches its lane`})]}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Tf.flatMap(({key:n,label:r})=>e[n].map((e,a)=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg bg-background/80 px-2 py-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:r}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:e}),t?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove queued message: ${e}`,onClick:()=>void i(n,a,e),className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(ut,{className:`size-3.5`})}):null]},`${n}:${a}:${e}`)))})]})})}var Df=(0,Z.lazy)(()=>Si(async()=>{let{FleetPiToolRenderer:e}=await import(`./fleet-pi-tool-renderer-BD_ZAjlG.js`);return{FleetPiToolRenderer:e}},__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])).then(({FleetPiToolRenderer:e})=>({default:e})));function Of(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`h-7 animate-pulse rounded-md bg-muted/40`,"aria-label":`Loading tool`}),children:(0,Q.jsx)(Df,{...e})})}function kf(e){return(e.parts??[]).flatMap(e=>typeof e==`object`&&e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`?[e.text]:[]).join(`
3
-
4
- `)}function Af(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function jf(e,...t){let n=Af(e);for(let e of t){let t=n?.[e];if(typeof t==`string`&&t.trim())return t}}function Mf(e){for(let t of[...e].reverse())for(let e of[...t.parts??[]].reverse()){let t=Af(e);if(t?.type!==`tool-FleetReasoning`)continue;let n=Af(t.input);if(!(typeof n?.runId!=`string`||typeof n.phase!=`string`||!Array.isArray(n.steps)||typeof n.visibleSteps!=`number`||typeof n.streaming!=`boolean`||typeof n.startedAt!=`number`||typeof n.restingLabel!=`string`))return n}}function Nf(e){return/^(.*)-a\d+$/.exec(e)?.[1]}function Pf(e,t){if(!e||t.length===0)return[];let n=new Set(t.map(e=>e.id)),r=new Set(t.flatMap(e=>(e.parts??[]).flatMap(e=>{let t=Af(e);return typeof t?.toolCallId==`string`&&t.toolCallId?[t.toolCallId]:[]}))),i=new Set(t.flatMap(e=>{let t=Nf(e.id);return t?[e.id,t]:[e.id]}));return e.flatMap(e=>e.artifacts).filter(e=>e.sourceMessageId?n.has(e.sourceMessageId):e.sourceToolCallId&&r.has(e.sourceToolCallId)||i.has(e.runId))}function Ff(e,t,n=[],r){let i=new Map,a=n.flatMap(e=>e.artifacts),o=e=>{let t=a.findIndex(t=>t.sourceToolCallId===e),n=t>=0?a[t]:void 0,i=n?.kind===`ipython`?`repl`:n?`artifacts`:void 0;if(!(!n||!i||!r))return{label:i===`repl`?`Open in REPL`:`Open in Artifacts`,ariaLabel:`Open ${n.title||`tool result`} artifact ${t+1}`,onClick:()=>r(n.id,i)}};for(let t of e)for(let[e,n]of(t.parts??[]).entries()){let r=Af(n),a=r?.type;if(typeof a!=`string`||!a.startsWith(`tool-`))continue;let s=r??{},c=a.slice(5),l=c.toLowerCase();if(l===`fleetreasoning`||l===`thinking`||l===`taskoutput`)continue;let u=String(s.toolCallId??s.id??`${t.id}-${l}-${e}`),d=Af(s.input)??Af(s.args);if(l===`websearch`||l===`grep`||l===`glob`){i.set(u,{id:u,type:`search`,query:jf(d,`query`,`pattern`,`path`)??c});continue}let f=l.includes(`edit`)||l.includes(`write`)?`edit`:l.includes(`read`)?`read`:`run`;i.set(u,{id:u,type:`tool`,action:f,target:jf(d,`path`,`filePath`,`command`,`cmd`,`code`)??c,openAction:o(u)})}let s=[];for(let e of t?.userBash??[])e.status===`running`&&s.push({id:e.id,type:`trace`,kind:`run`,label:`Bash`,detail:e.command||`User command`,action:o(e.runId)});for(let e of t?.rlmChildren??[])(e.status===`queued`||e.status===`running`)&&s.push({id:`rlm-${e.id}`,type:`trace`,kind:`run`,label:`RLM · ${e.label}`,detail:e.answerPreview||e.status,action:o(e.id)});return t?.goal?.active&&t.goal.status===`active`&&t.goal.objective&&s.push({id:`goal-${t.goal.goalId??`current`}`,type:`step`,label:t.goal.objective,status:t.goal.status===`active`?`active`:`complete`,meta:t.goal.status}),[...s,...Array.from(i.values())]}function If({messages:e,isLast:t,isStreaming:n,suppressQuestionTool:r,toolRenderers:i,onOpenUIAction:a,activityLabel:o,presentation:s,artifactRuns:c,onOpenArtifact:l,onOpenUIArtifactReady:u}){let d=t&&n,f=(0,Z.useMemo)(()=>e.flatMap((n,o)=>Dr(Fr((n.parts??[]).filter(e=>e.type!==`tool-FleetReasoning`&&e.type!==`tool-Thinking`)),{messageId:n.id,isLast:t&&o===e.length-1,isStreaming:d,suppressQuestionTool:r,suppressTextWhenPlanWrite:!0,ToolRendererComponent:Of,TextRendererComponent:Ar,toolRenderers:i,onOpenUIAction:a,onOpenUIArtifactReady:u,onOpenArtifact:l})),[t,d,e,l,a,u,r,i]),p=e.flatMap(e=>{let t=kf(e);return t?[t]:[]}).join(`
5
-
6
- `),m=(0,Z.useMemo)(()=>Ff(e,s,c,l),[c,e,l,s]),h=(0,Z.useMemo)(()=>Mf(e),[e]),g=(0,Z.useMemo)(()=>t?Pf(c,e):[],[c,t,e]),[_,v]=(0,Z.useState)(d),[y,b]=(0,Z.useState)(d);return y!==d&&(b(d),v(d)),(0,Q.jsx)(Cr,{from:`assistant`,animateIn:!d,children:(0,Q.jsx)(wr,{children:(0,Q.jsx)(Or,{variant:`ghost`,children:(0,Q.jsxs)(Er,{children:[h?(0,Q.jsx)(Sf,{presentation:h,className:`mb-2`}):null,t&&zf(o)?(0,Q.jsx)(id,{label:o,className:`mb-2`}):null,(0,Q.jsx)(kr,{messages:e,artifacts:g,streaming:d}),(0,Q.jsx)(Mu,{status:d?`streaming`:`complete`,copyText:p||void 0,announce:!1,contentClassName:`flex flex-col gap-3`,children:f}),m.length>0?(0,Q.jsx)($u,{items:m,status:d?`working`:`complete`,open:_,onOpenChange:v,activeLabel:Bf(m),summary:Vf(m),collapseOnComplete:!0,maxHeight:208,className:`mt-2 max-w-none`}):null,t&&s?(0,Q.jsx)(Mr,{children:s.rlmChildren,tree:s.rlmTree}):null]})})})})}function Lf(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Rf=(0,Z.memo)(function({turn:e,state:t,rendering:n,activity:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.user?(0,Q.jsx)(Cr,{from:`user`,animateIn:!t.isStreaming,children:(0,Q.jsx)(wr,{children:(0,Q.jsx)(Nr,{message:e.user})})}):null,e.assistants.length>0?(0,Q.jsx)(If,{messages:e.assistants,isLast:t.isLast,isStreaming:t.isStreaming,suppressQuestionTool:t.suppressQuestionTool,toolRenderers:n.toolRenderers,onOpenUIAction:n.onOpenUIAction,onOpenUIArtifactReady:n.onOpenUIArtifactReady,onOpenArtifact:n.onOpenArtifact,activityLabel:r.label,presentation:r.presentation,artifactRuns:r.artifactRuns}):null]})},(e,t)=>e.turn.user===t.turn.user&&Lf(e.turn.assistants,t.turn.assistants)&&e.state.isLast===t.state.isLast&&e.state.isStreaming===t.state.isStreaming&&e.state.suppressQuestionTool===t.state.suppressQuestionTool&&e.rendering.toolRenderers===t.rendering.toolRenderers&&e.rendering.onOpenUIAction===t.rendering.onOpenUIAction&&e.rendering.onOpenUIArtifactReady===t.rendering.onOpenUIArtifactReady&&e.rendering.onOpenArtifact===t.rendering.onOpenArtifact&&e.activity.label===t.activity.label&&e.activity.presentation===t.activity.presentation&&e.activity.artifactRuns===t.activity.artifactRuns);function zf(e){return e?/queued|steered|retry|compact|reset|recover|sign in/i.test(e):!1}function Bf(e){if(e.length===1){let t=e[0];if(t?.type===`search`)return`Checking a source…`;if(t?.type===`tool`)return`Working with `+t.action+`…`}return e.length>1?`Coordinating `+e.length+` active actions…`:`Working through the run…`}function Vf(e){let t=e.length;return t===1?`Completed 1 tracked action`:`Completed `+t+` tracked actions`}function Hf(e){return Array.isArray(e)?e:e?.items??[]}var Uf=[{id:`welcome-explore-codebase`,label:`Explore codebase`,value:`Explore this codebase and explain its architecture, important modules, and main entry points.`},{id:`welcome-review-changes`,label:`Review changes`,value:`Review my current changes for bugs, regressions, architecture issues, and code quality problems.`},{id:`welcome-fix-issue`,label:`Fix an issue`,value:`Help me investigate and fix an issue in this project.`},{id:`welcome-plan-feature`,label:`Plan a feature`,value:`Explore the relevant code and create an implementation plan for a new feature before making changes.`}];function Wf({disabled:e,onSelect:t,composer:n}){return(0,Q.jsxs)(`section`,{"aria-labelledby":`fleet-welcome-title`,className:`flex w-full max-w-an flex-col items-center text-center`,children:[(0,Q.jsx)(`h1`,{id:`fleet-welcome-title`,className:`text-2xl font-normal tracking-tight text-foreground sm:text-3xl`,children:`What should Fleet Prime Agent work on?`}),(0,Q.jsx)(`div`,{className:`mt-6 w-full`,children:n}),(0,Q.jsx)(`div`,{"aria-label":`Suggested prompts`,className:`mt-4 flex w-full flex-wrap justify-center gap-2`,children:Uf.map(n=>(0,Q.jsx)(`button`,{type:`button`,disabled:e||n.disabled,onClick:()=>t(n),className:`inline-flex min-h-8 items-center rounded-full border border-border/70 bg-background/70 px-4 py-1.5 text-center text-sm text-foreground/80 shadow-sm transition-colors hover:border-primary/40 hover:bg-primary/5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none`,children:n.label},n.id))})]})}function Gf({toolRenderers:e=ir,suggestions:t,status:n,onStop:r,onSend:i,inputBar:a,className:o,messages:s,error:c,suppressQuestionTool:l=!1,onOpenUIAction:u,activityLabel:d,presentation:f,artifactRuns:p,onOpenArtifact:m,onOpenUIArtifactReady:h,queue:g,onDeleteQueuedMessage:_}){let[v,y]=(0,Z.useState)(``),b=(0,Z.useMemo)(()=>Pr(s),[s]),x=Hf(t),S=(0,Z.useMemo)(()=>x.flatMap(e=>e.disabled?[]:[e.value??e.label]),[x]),C=S.join(`\0`),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(C);E!==C&&(D(C),T(null));let O=n===`streaming`||n===`submitted`,k=(0,Z.useMemo)(()=>({toolRenderers:e,onOpenUIAction:u,onOpenUIArtifactReady:h,onOpenArtifact:m}),[m,u,h,e]),A=(0,Z.useMemo)(()=>({isLast:!0,isStreaming:O,suppressQuestionTool:l}),[O,l]),j=(0,Z.useMemo)(()=>({isLast:!1,isStreaming:!1,suppressQuestionTool:l}),[l]),M=(0,Z.useMemo)(()=>({label:d,presentation:f,artifactRuns:p}),[d,p,f]),N=(0,Z.useMemo)(()=>({label:void 0,presentation:void 0,artifactRuns:void 0}),[]),P=b.length===0&&!c,F=c?_f(c):null,I=(0,Q.jsx)(mf,{...a,className:q(a.className,P&&`px-0 pb-0`),placeholder:P?`Ask Prime to build, investigate, or change something…`:a.placeholder,controlled:{value:v,onChange:y},status:n,suggestions:t,onSend:i,onStop:r});return(0,Q.jsxs)(`div`,{className:q(`fleet-pi-agent-chat flex h-full min-h-0 flex-col bg-background`,o),children:[(0,Q.jsxs)(jr,{className:`flex-1`,busy:O,followOutput:!0,smooth:O,contentClassName:q(`mx-auto flex w-full max-w-an flex-col gap-5 px-4`,P?`min-h-full items-center justify-center py-8`:`py-6`),children:[P?(0,Q.jsx)(Wf,{disabled:O,onSelect:e=>y(e.value??e.label),composer:I}):null,b.map((e,t)=>{let n=e.user?.id??`assistant-turn-${t}`,r=t===b.length-1;return(0,Q.jsx)(Rf,{turn:e,state:r?A:j,rendering:k,activity:r?M:N},n)}),F?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(Rr,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:F.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs opacity-90`,children:F.message})]})]}):null,b.length>0&&S.length>0&&!O&&!c?(0,Q.jsx)(ed,{suggestions:S,selectedSuggestion:w,cycle:b.length,onSuggestion:e=>{T(e),y(e)},className:`px-0`}):null]}),P?null:I,(0,Q.jsx)(Ef,{queue:g??{steering:[],followUp:[]},onDelete:_})]})}function Kf({messages:e,status:t,error:n,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onOpenArtifact:l,onOpenUIArtifactReady:u,inputSuggestionItems:d,suppressQuestionTool:f,inputBar:p,onSend:m,onOpenUIAction:h,onStop:g,onQuestionAnswer:_}){let v=(0,Z.useCallback)(e=>{m(e.content,e.altKey)},[m]),y=(0,Z.useCallback)(e=>{h(e)},[h]),b=(0,Z.useCallback)(({toolCallId:e,answer:t})=>{_({toolCallId:e,answer:t})},[_]),x=(0,Z.useMemo)(()=>({submitLabel:`Continue`,allowSkip:!0,onAnswer:b}),[b]);return(0,Q.jsx)(`div`,{className:`contents`,"data-fleet-chat-focus":!0,children:(0,Q.jsx)(Yi,{children:(0,Q.jsx)(Gf,{messages:e,status:t,onSend:v,onOpenUIAction:y,onStop:g,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,queue:s,onDeleteQueuedMessage:c,onOpenArtifact:l,onOpenUIArtifactReady:u,questionTool:x,suppressQuestionTool:f,error:n??void 0,emptyStatePosition:`default`,suggestions:d,inputBar:p})})})}var qf=[`/api/health`,`/api/chat`,`/api/projects`,`/api/workspace`];function Jf(){return``}function Yf(e){return qf.some(t=>e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`))}function Xf(e){let t=Jf();if(!t)return e;let[n]=e.split(`?`);return Yf(n)?`${t}${e}`:e}function Zf(e,t){return{modelKey:e.modelKey,models:e.models,infoDescription:e.infoDescription,slashCommands:e.slashCommands,questionBar:e.pendingQuestionBar,chatMode:e.chatMode,onChatModeChange:e.setChatMode,onModelChange:e.setModelKey,thinkingLevel:e.thinkingLevel,onThinkingLevelChange:e.setThinkingLevel,attachments:{onAttach:e.handleAttach,images:e.uploadedAttachments.flatMap(e=>e.mimeType.startsWith(`image/`)?[{id:e.attachmentId,filename:e.name,size:e.size,url:Xf(`/api/chat/session?sessionId=${encodeURIComponent(t??``)}&attachmentId=${encodeURIComponent(e.attachmentId)}`)}]:[]),files:e.uploadedAttachments.flatMap(e=>e.mimeType.startsWith(`image/`)?[]:[{id:e.attachmentId,filename:e.name,size:e.size}]),onRemoveImage:e.removeUploadedAttachment,onRemoveFile:e.removeUploadedAttachment},workspaceReferences:e.workspaceAttachments,workspaceSuggestions:e.workspaceReferenceSuggestions,onWorkspaceReferenceSelect:e.addWorkspaceAttachment,onRemoveWorkspaceReference:e.removeWorkspaceAttachment,onSlashCommandSelect:e.handleSlashCommandSelect,onLocalSlashSubmit:e.handleLocalSlashSubmit,modelPickerOpen:e.modelPickerOpen,onModelPickerOpenChange:e.setModelPickerOpen,effortPickerOpen:e.effortPickerOpen,onEffortPickerOpenChange:e.setEffortPickerOpen}}var Qf=(0,Z.lazy)(()=>Si(async()=>{let{ChatCommandPalette:e}=await import(`./chat-command-palette-C4sSf8Kg.js`);return{ChatCommandPalette:e}},__vite__mapDeps([32,1,2,3,33,34,7,35,6,8,9,15,36,11,37,38,39,40,27,17,18,41,42,43])).then(({ChatCommandPalette:e})=>({default:e}))),$f=(0,Z.lazy)(()=>Si(async()=>{let{SettingsDialog:e}=await import(`./settings-dialog-CkfpTKfM.js`);return{SettingsDialog:e}},__vite__mapDeps([44,1,2,3,35,7,6,8,9,45,13,34,15,46,11,12,40,47,36,21,48,22,26,49,43,39,50,16,27,51,41,52])).then(({SettingsDialog:e})=>({default:e}))),ep=(0,Z.lazy)(()=>Si(async()=>{let{ForkPickerDialog:e}=await import(`./fork-picker-dialog-C2cVJUbf.js`);return{ForkPickerDialog:e}},__vite__mapDeps([53,3,1,34,2,7,35,6,8,9,15])).then(({ForkPickerDialog:e})=>({default:e})));function tp({chrome:e,conversation:t,dialogs:n,panels:r,session:i}){return(0,Q.jsx)(Q.Fragment,{children:n.commandPaletteOpen?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Qf,{open:!0,onOpenChange:n.setCommandPaletteOpen,onNewSession:()=>void i.startNewSession(),onStop:t.stop,onResumeSession:e=>void i.resumeSession({sessionId:e.sessionId}),onSetRightPanel:r.setRightPanel,onThemeChange:e.handleThemePreferenceChange,sessions:i.sessions,isStreaming:t.status===`streaming`,themePreference:e.themePreference})}):null})}function np({dialogs:e}){let{forkFromEntry:t,forkPickerEntries:n,setForkPickerEntries:r,setSettingsDialogOpen:i,setSettingsInitialTab:a,settingsDialogOpen:o,settingsInitialTab:s}=e,c=(0,Z.useCallback)(e=>{i(e),e||a(void 0)},[i,a]);return(0,Q.jsxs)(Q.Fragment,{children:[o?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)($f,{open:!0,onOpenChange:c,initialTab:s})}):null,n?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ep,{entries:n,onOpenChange:e=>{e||r(null)},onPick:t})}):null]})}var rp=`fleet-prime:v1:panel-keybindings`,ip={toggleResources:{code:`Digit1`,ctrlOrMeta:!0,shift:!0},toggleWorkspace:{code:`Digit2`,ctrlOrMeta:!0,shift:!0},toggleArtifacts:{code:`Digit3`,ctrlOrMeta:!0,shift:!0},toggleRepl:{code:`Digit4`,ctrlOrMeta:!0,shift:!0},toggleSubagents:{code:`Digit5`,ctrlOrMeta:!0,shift:!0},toggleCommandPalette:{code:`KeyK`,ctrlOrMeta:!0},closePanel:{code:`Escape`},focusPanel:{code:`KeyP`,ctrlOrMeta:!0,shift:!0},focusChat:{code:`KeyC`,ctrlOrMeta:!0,shift:!0}};function ap(){try{let e=window.localStorage.getItem(rp);if(!e)return ip;let t=JSON.parse(e);return{...ip,...t}}catch{return ip}}function op(e,t){return e.code===t.code&&(e.ctrlKey||e.metaKey)===!!t.ctrlOrMeta&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}function sp(){document.querySelector(`[data-fleet-chat-focus] textarea, [data-fleet-chat-focus] [contenteditable='true'], [data-fleet-chat-focus] input`)?.focus({preventScroll:!0})}function cp({onCommandPaletteToggle:e,onClosePanel:t,rightPanel:n,setRightPanel:r}){(0,Z.useEffect)(()=>{let i=ap(),a=a=>{let o=e=>op(a,i[e]),s=!0;o(`toggleResources`)?r(n===`resources`?null:`resources`):o(`toggleWorkspace`)?r(n===`workspace`?null:`workspace`):o(`toggleArtifacts`)?r(n===`artifacts`?null:`artifacts`):o(`toggleRepl`)?r(n===`repl`?null:`repl`):o(`toggleSubagents`)?r(n===`subagents`?null:`subagents`):e&&o(`toggleCommandPalette`)?e():n&&o(`closePanel`)?t?t():(r(null),sp()):n&&o(`focusPanel`)?document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0}):o(`focusChat`)?sp():s=!1,s&&(a.preventDefault(),a.stopPropagation())};return document.addEventListener(`keydown`,a),()=>document.removeEventListener(`keydown`,a)},[e,t,n,r])}function lp(){return null}function up(){return null}async function dp(){}var fp=X({key:Y(),provider:Y(),id:Y(),name:Y(),version:Y().optional(),reasoning:Di(),input:J(Ai([`text`,`image`])),contextWindow:Mi().optional(),maxTokens:Mi().optional(),available:Di(),defaultThinkingLevel:Gi.optional(),thinkingLevels:J(Gi).optional()}).openapi({description:`Chat model info`}),pp=X({models:J(fp),selectedModelKey:Y().optional(),defaultProvider:Y().optional(),defaultModel:Y().optional(),defaultThinkingLevel:Gi.optional(),diagnostics:J(Y())}).openapi({description:`Chat models response`}),mp=X({providerId:Y().min(1).max(128)}).openapi({description:`Discover models for a provider`}),hp=X({providerId:Y(),models:J(fp)}).openapi({description:`Discovered models for a provider`}),gp=X({activationStatus:Ai([`active`,`staged`,`reload-required`]).optional(),name:Y(),description:Y().optional(),installedInWorkspace:Di().optional(),path:Y().optional(),source:Y().optional(),workspacePath:Y().optional(),argumentHint:Y().optional()}).openapi({description:`Chat resource info`}),_p=X({packages:J(gp),skills:J(gp),prompts:J(gp),extensions:J(gp),themes:J(gp),agentsFiles:J(gp),diagnostics:J(Y())}).openapi({description:`Chat resources response`}),vp=Oi(()=>X({name:Y(),path:Y(),type:Ai([`directory`,`file`]),children:J(vp).optional()})),yp=X({root:Y(),nodes:J(vp),diagnostics:J(Y())}).openapi({description:`Workspace tree response`}),bp=X({path:Y(),name:Y(),content:Y(),mediaType:Ai([`text/markdown`,`text/plain`,`application/octet-stream`]),size:Mi().optional(),status:Ai([`ok`,`too-large`,`unsupported`]).optional()}).openapi({description:`Workspace file preview response`}),xp=X({name:Y(),path:Y()}).openapi({description:`Directory entry in the project-folder picker`}),Sp=X({path:Y(),parent:Y().nullable(),entries:J(xp)}).openapi({description:`Workspace directory browse response`}),Cp=X({id:Y(),name:Y(),isConfigured:Di(),envVarName:Y(),authType:Ai([`apiKey`,`oauth`]).optional(),supportsOAuth:Di().optional(),providerFamily:Y().optional(),displayName:Y().optional(),api:Ai([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),baseUrl:Y().optional(),modelIds:J(Y().max(4096)).max(64).optional(),discoverable:Di().optional()}).openapi({description:`Chat provider info`}),wp=X({providers:J(Cp)}).openapi({description:`Chat providers response`}),Tp=X({providerId:Y(),apiKey:Y().max(4096),baseUrl:Y().max(4096).optional(),modelId:Y().max(4096).optional(),displayName:Y().max(256).optional(),createOccInstance:Di().optional(),api:Ai([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),models:J(Y().max(4096)).max(64).optional()}).openapi({description:`Chat provider update request`}),Ep=X({success:Di(),providers:J(Cp),reloadRequired:Di().optional()}).openapi({description:`Chat provider update response`}),Dp=X({providerId:Y()}).openapi({description:`Chat provider remove request`});Ep.openapi({description:`Chat provider remove response`});var Op=Ai([`waiting`,`success`,`error`]).openapi({description:`OAuth login status`}),kp=X({message:Y(),placeholder:Y().optional(),allowEmpty:Di().optional()}).openapi({description:`Interactive OAuth prompt`}),Ap=X({providerId:Y().min(1),loginId:Y().min(1).optional(),promptAnswer:Y().max(8192).optional(),cancel:Di().optional()}).openapi({description:`Chat provider OAuth login request`}),jp=X({status:Op,loginId:Y().optional(),authUrl:Y().optional(),userCode:Y().optional(),instructions:Y().optional(),prompt:kp.optional(),error:Y().optional(),providers:J(Cp).optional()}).openapi({description:`Chat provider OAuth login response`}),Mp=X({name:Y(),description:Y().optional(),argumentHint:Y().optional(),source:Ai([`builtin`,`extension`,`prompt`,`skill`]),passThrough:Di().optional()}).openapi({description:`Chat slash command info`}),Np=X({commands:J(Mp),diagnostics:J(Y())}).openapi({description:`Chat slash commands response`});X({message:Y()}).openapi({description:`Error response`}),X({status:ki(`ok`)}).openapi({description:`Health check response`});var Pp=X({compaction:X({enabled:Di(),reserveTokens:ea,keepRecentTokens:ea}),defaultModel:Y().optional(),defaultProvider:Y().optional(),defaultThinkingLevel:Gi.optional(),enableSkillCommands:Di(),enabledModels:J(Bi).optional(),extensions:J(Bi),followUpMode:zi,packages:J(Ji),prompts:J(Bi),retry:X({enabled:Di(),maxRetries:Fi,baseDelayMs:Fi}),skills:J(Bi),steeringMode:zi,themes:J(Bi),transport:Vi}).openapi({description:`Editable Pi settings`}),Fp=X({compaction:Pp.shape.compaction.partial().optional(),defaultModel:Y().optional(),defaultProvider:Y().optional(),defaultThinkingLevel:Gi.optional(),enableSkillCommands:Di().optional(),enabledModels:J(Bi).nullable().optional(),extensions:J(Bi).optional(),followUpMode:zi.optional(),packages:J(Ji).optional(),prompts:J(Bi).optional(),retry:Pp.shape.retry.partial().optional(),skills:J(Bi).optional(),steeringMode:zi.optional(),themes:J(Bi).optional(),transport:Vi.optional()}).strict().openapi({description:`Pi settings update`}),Ip=X({settings:Fp}).openapi({description:`Pi settings update request`}),Lp=X({diagnostics:J(Y()),effective:Pp,project:Fp,projectPath:Y(),updateImpact:X({newSessionRecommended:Di(),resourceReloadRequired:Di()})}).openapi({description:`Pi settings response`});function Rp(){return null}var zp=class extends Error{status;body;code;remediation;constructor(e,t){super(Hp(e,t)),this.name=`ChatRequestError`,this.status=e,this.body=t;let n=Vp(t);this.code=n?.code,this.remediation=n?.remediation}};function Bp(e){return typeof e==`object`&&!!e&&typeof e.action==`string`&&typeof e.label==`string`}function Vp(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(typeof e.code==`string`)return{code:e.code,remediation:Bp(e.remediation)?e.remediation:void 0}}catch{}return null}function Hp(e,t){let n=t.trim();if(!n)return`Request failed (${e})`;try{let e=JSON.parse(n);if(typeof e.message==`string`&&e.message.length>0)return e.message}catch{}return n}function Up(e){return(e instanceof zp?e.body:e instanceof Error?e.message:String(e)).includes(`Session belongs to another user`)}function Wp(e){return e instanceof zp&&e.status===404}function Gp(e){return e instanceof Error?e.code===`NETWORK_DISCONNECTED`||/daemon is not connected/i.test(e.message)||/cannot send daemon command/i.test(e.message):!1}function Kp(e){let t=Error(e.message);return e.code&&(t.code=e.code),t}async function qp(e){let t=new Headers(e?.headers),n=await Rp();return n&&t.set(`Authorization`,`Bearer ${n}`),t}async function Jp(e,t){let n=Xf(e),r=async e=>{let i=await qp(t),a=await fetch(n,{...t,headers:i});if(a.status===401&&e)return r(!1);if(!a.ok){let e=await a.text();throw new zp(a.status,e)}return await a.json()};return r(!0)}async function Yp(e,t,n){return Zp(t,await Jp(e,n),`Response from ${e}`)}async function Xp(e,t){let n=e.body?.getReader();if(!n)throw Error(`Chat response did not include a stream`);let r=new TextDecoder,i=``,a=new Map;function o(e,t,n){let r=a.get(`${e}:${t}`)??0;n>r+1&&console.warn(`[chat-sequence] Gap detected in ${t} sequence for session ${e}: expected ${r+1}, got ${n}`),a.set(`${e}:${t}`,n)}let s=e=>{let n=e.trim();if(!n)return;let r=JSON.parse(n),i=typeof r==`object`&&r?`type`in r&&r.type:void 0,a=typeof r==`object`&&r&&`sessionId`in r?String(r.sessionId):void 0,s=typeof r==`object`&&r&&`sequenceNumber`in r?Number(r.sequenceNumber):void 0;if(i===`start`||i===`done`||i===`error`||i===`plan`||i===`state`||i===`tool`||i===`queue`||i===`reasoning`||i===`compaction`||i===`retry`||i===`payload`){let e=Zp(Ri,r,`Chat stream event`);a&&s!==void 0&&o(a,String(e.type),s),t(e)}else t(r)};for(;;){let{value:e,done:t}=await n.read();if(t)break;let a=r.decode(e,{stream:!0});i+=a;let o=i.indexOf(`
7
- `);for(;o>=0;)s(i.slice(0,o)),i=i.slice(o+1),o=i.indexOf(`
8
- `)}i+=r.decode(),s(i)}function Zp(e,t,n){let r=e.safeParse(t);if(r.success)return r.data;throw Error(`${n} did not match the expected contract`)}function Qp(e){let t=new URLSearchParams;return e.sessionId&&t.set(`sessionId`,e.sessionId),e.projectId&&t.set(`projectId`,e.projectId),e.openUI&&t.set(`openUI`,`true`),t.toString()}function $p(e){switch(e){case`agent_start`:return`Working`;case`turn_start`:return`Waiting`;case`message_start`:return`Thinking`;case`message_end`:return`Writing`;case`tool_start`:case`tool_execution_start`:case`tool_execution`:return`Executing`;case`tool_end`:case`tool_execution_end`:return`Writing`;case`turn_end`:return`Turn finished`;case`agent_end`:return;default:return}}var em=X({project:ji}),tm={async abortSession(e){await Jp(`/api/chat/abort`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async answerQuestion(e){return Yp(`/api/chat/question`,Ii,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async deleteQueuedMessage(e){let t=qi.parse(e);return Yp(`/api/chat/session`,Zi,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async browseWorkspace(e,t){let n=new URLSearchParams;t&&n.set(`projectId`,t),e&&e.trim().length>0&&n.set(`path`,e);let r=n.toString();return Yp(`/api/workspace/browse${r?`?${r}`:``}`,Sp)},async createSession(e,t){return Yp(`/api/chat/new`,Wi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({openUI:!0,...e?{projectId:e}:{}}),signal:t})},async listProjects(){return Yp(`/api/projects`,Ei)},async createProject(e){let t=Ni.parse(e);return(await Yp(`/api/projects`,em,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).project},async renameProject(e,t){let n=Ti.parse({name:t});return(await Yp(`/api/projects?projectId=${encodeURIComponent(e)}`,em,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).project},async unregisterProject(e){return(await Yp(`/api/projects?projectId=${encodeURIComponent(e)}`,em,{method:`DELETE`})).project},async browseProjectDirectories(e){let t=new URLSearchParams;e?.path&&t.set(`path`,e.path),e?.token&&t.set(`token`,e.token);let n=t.toString();return Yp(`/api/projects/browse${n?`?${n}`:``}`,wi)},async forkSessionIntoProject(e,t){let n=ta.parse({sessionId:e,targetProjectId:t});return Yp(`/api/projects/fork`,Pi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})},async getModels(e){let t=new URLSearchParams;e?.scope===`all`&&t.set(`scope`,`all`),e?.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return Yp(`/api/chat/models${n?`?${n}`:``}`,pp)},async discoverModels(e){return Yp(`/api/chat/models/discover`,hp,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(mp.parse(e))})},async getResources(e){return Yp(`/api/chat/resources${e?`?projectId=${encodeURIComponent(e)}`:``}`,_p)},async getCommands(e){return Yp(`/api/chat/commands${e?`?projectId=${encodeURIComponent(e)}`:``}`,Np)},async getSettings(e){return Yp(`/api/chat/settings${e?`?projectId=${encodeURIComponent(e)}`:``}`,Lp)},async getWorkspaceTree(e){return Yp(`/api/workspace/tree${e?`?projectId=${encodeURIComponent(e)}`:``}`,yp)},async getWorkspaceFile(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`projectId`,t),Yp(`/api/workspace/file?${n}`,bp)},async listSessions(e){return(await Yp(`/api/chat/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`,$i)).sessions},async renameSession(e,t){await Jp(`/api/chat/sessions`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,title:t})})},async deleteSession(e){await Jp(`/api/chat/sessions`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})})},async uploadAttachments(e,t){let n=new FormData;n.set(`sessionId`,e);for(let e of t)n.append(`files`,e);let r=await fetch(Xf(`/api/chat/session`),{method:`POST`,body:n});if(!r.ok)throw new zp(r.status,await r.text());return X({attachments:J(Ci)}).parse(await r.json()).attachments},async loadSession(e){return Yp(`/api/chat/session?${Qp({...e,openUI:!0})}`,Wi)},async loadSubagentSession(e,t){return Yp(`/api/chat/session?${new URLSearchParams({parentSessionId:e,childId:t})}`,Wi)},async upsertPlanPresentation(e){let t=Hi.parse(e);return Yp(`/api/chat/session`,X({presentation:Xi}),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.presentation)},async upsertOpenUIArtifact(e){let t=Qi.parse(e);return Yp(`/api/chat/artifacts`,Ki,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async resumeSession(e){return Yp(`/api/chat/resume`,Wi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,openUI:!0})})},async updateSettings(e,t){let n=Ip.parse(e);return Yp(`/api/chat/settings${t?`?projectId=${encodeURIComponent(t)}`:``}`,Lp,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})},async streamMessage(e,t,n){let r=async i=>{let a=new Headers({"Content-Type":`application/json`}),o=await up();o&&a.set(`Authorization`,`Bearer ${o}`);let s=await fetch(Xf(`/api/chat`),{method:`POST`,headers:a,body:JSON.stringify(e),signal:n});if(s.status===401&&i)return r(!1);if(!s.ok){let e=await s.text();throw new zp(s.status,e)}await Xp(s,t)};await r(!0)},async getProviders(){return Yp(`/api/chat/providers`,wp)},async oauthLoginProvider(e){let t=Ap.parse(e);return Yp(`/api/chat/providers/oauth`,jp,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async updateProvider(e){let t=Tp.parse(e);return Yp(`/api/chat/providers`,Ep,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async removeProvider(e){let t=Dp.parse(e);return Yp(`/api/chat/providers`,Ep,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}},nm={models:e=>[`chat`,`models`,e??`default`],modelCatalog:e=>[`chat`,`models`,`catalog`,e??`default`],providers:[`chat`,`providers`],resources:e=>[`chat`,`resources`,e??`default`],commands:e=>[`chat`,`commands`,e??`default`],settings:e=>[`chat`,`settings`,e??`default`],workspace:e=>[`workspace`,`tree`,e??`default`],projects:[`projects`]};function rm(e){return Da({queryKey:nm.models(e),queryFn:()=>tm.getModels({projectId:e})})}function im(){return Da({queryKey:nm.projects,queryFn:()=>tm.listProjects(),staleTime:5e3})}function am(e){return Da({queryKey:nm.modelCatalog(e?.projectId),queryFn:()=>tm.getModels({scope:`all`,projectId:e?.projectId}),enabled:e?.enabled})}function om(){let e=s();return Oa({mutationFn:e=>tm.discoverModels({providerId:e}),onSuccess:()=>{e.invalidateQueries({queryKey:[`chat`,`models`]})}})}function sm(e){return Da({queryKey:nm.resources(e),queryFn:()=>tm.getResources(e)})}function cm(e){return Da({queryKey:nm.commands(e),queryFn:()=>tm.getCommands(e)})}function lm(e){return Da({queryKey:nm.settings(e),queryFn:()=>tm.getSettings(e)})}function um(){let e=s();return Oa({mutationFn:e=>tm.updateSettings(e.request,e.projectId),onSuccess:(t,n)=>{e.setQueryData(nm.settings(n.projectId),t),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`resources`]}),e.invalidateQueries({queryKey:[`chat`,`commands`]})}})}function dm(e,t){return Da({queryKey:nm.workspace(e),queryFn:()=>tm.getWorkspaceTree(e),enabled:t?.enabled})}function fm(){return Da({queryKey:nm.providers,queryFn:()=>tm.getProviders()})}function pm(){let e=s();return Oa({mutationFn:e=>tm.updateProvider(e),onSuccess:t=>{e.setQueryData(nm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function mm(){let e=s();return Oa({mutationFn:e=>tm.oauthLoginProvider(e),onSuccess:t=>{t.status!==`success`||!t.providers||(e.setQueryData(nm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]}))}})}function hm(){let e=s();return Oa({mutationFn:e=>tm.removeProvider(e),onSuccess:t=>{e.setQueryData(nm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function gm(e){if(e.type!==`tool-Question`||e.state===`output-available`||e.state===`output-error`)return!1;let t=e.output;return!t||!(t.answer!==void 0&&t.answer!==null||Array.isArray(t.answers)&&t.answers.length>0||typeof t.content==`string`&&t.content.length>0)}function _m(e){return e?.role!==`assistant`||!Array.isArray(e.parts)?!1:e.parts.some(e=>gm(e))}var vm=[{name:`settings`,description:`Open Settings`,source:`builtin`},{name:`model`,description:`Open the model picker`,argumentHint:`[provider/id]`,source:`builtin`},{name:`effort`,description:`Select reasoning/thinking level`,argumentHint:`[level]`,source:`builtin`},{name:`fast`,description:`Toggle OpenAI Fast mode`,source:`builtin`},{name:`scoped-models`,description:`Enable/disable models for cycling`,source:`builtin`},{name:`export`,description:`Export session (HTML default, or .html/.jsonl path)`,argumentHint:`[path]`,source:`builtin`},{name:`import`,description:`Import and resume a session from a JSONL file`,argumentHint:`<path.jsonl>`,source:`builtin`},{name:`share`,description:`Copy the transcript (Gist upload is TUI-only)`,source:`builtin`},{name:`copy`,description:`Copy last agent message to clipboard`,source:`builtin`},{name:`btw`,description:`Ask a side question without adding it to the session`,argumentHint:`<question>`,source:`builtin`},{name:`name`,description:`Set or show the session display name`,argumentHint:`[name]`,source:`builtin`},{name:`session`,description:`Show current session metadata`,source:`builtin`},{name:`system-prompt`,description:`Show the exact system prompt sent to the model`,source:`builtin`},{name:`logs`,description:`Show where daemon and client logs are saved`,source:`builtin`},{name:`traces`,description:`Preview, upload, or configure Fleet Prime traces`,argumentHint:`[status|on|off|preview|upload]`,source:`builtin`},{name:`context`,description:`Show token and context usage`,source:`builtin`},{name:`changelog`,description:`Show changelog entries`,source:`builtin`},{name:`hotkeys`,description:`Show keyboard shortcuts`,source:`builtin`},{name:`fork`,description:`Create a new fork from a previous user message`,argumentHint:`[message-entry-id]`,source:`builtin`},{name:`clone`,description:`Duplicate the current session at the current position`,source:`builtin`},{name:`tree`,description:`Show the session tree (switch branches)`,source:`builtin`},{name:`agents`,description:`List saved sessions (web stand-in for the TUI agent tray)`,source:`builtin`},{name:`login`,description:`Configure provider authentication`,source:`builtin`},{name:`logout`,description:`Remove provider authentication`,source:`builtin`},{name:`mcp`,description:`Open MCP connections in Settings`,argumentHint:`[list|login <name>|logout <name>]`,source:`builtin`},{name:`new`,description:`Start a new chat session`,source:`builtin`},{name:`compact`,description:`Compact the session context`,argumentHint:`[instructions]`,source:`builtin`},{name:`refine`,description:`Refine continual harness prompt notes, skills, and memory`,source:`builtin`},{name:`openui`,description:`Generate a durable OpenUI HTML artifact`,argumentHint:`<request>`,source:`builtin`},{name:`goal`,description:`Set or view a persistent goal`,argumentHint:`[objective]`,source:`builtin`},{name:`autonomous`,description:`Set or view autonomous mode`,argumentHint:`[status|on|off]`,source:`builtin`},{name:`rlm-max-depth`,description:`Set or view per-chat RLM max depth`,argumentHint:`[<int> [--global]]`,source:`builtin`},{name:`heartbeat`,description:`Set or view a persistent heartbeat`,argumentHint:`[status|pause|resume|stop]`,source:`builtin`},{name:`heartbeats`,description:`View user and agent heartbeats`,source:`builtin`},{name:`reload`,description:`Reload keybindings, extensions, skills, prompts, and themes`,source:`builtin`},{name:`update`,description:`Update Fleet Prime (TUI-only)`,source:`builtin`},{name:`fullscreen`,description:`Toggle fullscreen (TUI-only)`,source:`builtin`},{name:`quit`,description:`Quit (TUI-only; close this tab instead)`,source:`builtin`}],ym={clear:`new`,usage:`context`,thinking:`effort`,rename:`name`,side:`btw`};function bm(e){let t=Gi.safeParse(e.trim().toLowerCase());return t.success?t.data:void 0}function xm(e){return ym[e]??e}function Sm(e){let t=e.trim().match(/^\/(\S+)(?:\s+(.*))?$/);if(!t)return null;let[,n=``,r=``]=t;return{command:n,args:r.trim()}}function Cm(e){let t=e.trim();if(!t)return;let n=t[0];if(n!==`"`&&n!==`'`)return t;let r=t.indexOf(n,1);return r<0?void 0:t.slice(1,r)}function wm(e,t=``){let n=xm(e),r=t.trim();switch(n){case`model`:return{type:`open-model-picker`,modelKey:r?r.replace(/:[\w.-]+$/,``):void 0};case`effort`:{if(!r)return{type:`open-effort-picker`};let e=bm(r);return e?{type:`set-thinking-level`,level:e}:{type:`open-effort-picker`,unknownLevel:r}}case`models`:case`scoped-models`:return{type:`open-model-picker`};case`settings`:return{type:`open-settings`,tab:`appearance`};case`config`:return{type:`open-settings`,tab:`chat`};case`new`:return{type:`new-session`};case`openui`:return{type:`openui-request`,request:r};case`login`:return{type:`open-providers`};case`logout`:return{type:`open-logout`};case`session`:return{type:`session-info`};case`name`:return{type:`session-rename`,name:r||void 0};case`context`:return{type:`session-context`};case`system-prompt`:return{type:`session-system-prompt`};case`logs`:return{type:`session-logs`};case`export`:return{type:`session-export`,outputPath:Cm(r)};case`fork`:return{type:`session-fork`,args:r};case`clone`:return{type:`session-clone`};case`tree`:return{type:`session-tree`,args:r};case`share`:return{type:`session-share`};case`import`:return{type:`session-import`,path:r?Cm(r)??r:``};case`btw`:return{type:`session-btw`,question:r};case`fast`:return{type:`fast-toggle`};case`reload`:return{type:`reload-resources`};case`mcp`:return{type:`open-mcp`,args:r};case`rlm-max-depth`:return{type:`rlm-max-depth`,args:r};case`heartbeat`:return{type:`heartbeat-manage`,args:r};case`heartbeats`:return{type:`heartbeat-list`};case`traces`:return{type:`session-traces`};case`agents`:return{type:`session-agents`};case`changelog`:return{type:`show-changelog`};case`hotkeys`:return{type:`show-hotkeys`};case`copy`:return{type:`copy-last-reply`};case`update`:return{type:`update-check`,args:r};case`fullscreen`:return{type:`toggle-fullscreen`};case`quit`:return{type:`quit-app`};default:return null}}function Tm(e){let t=e.trim().replace(/\s+/g,`-`);return/^[\w.-]+$/.test(t)?t:``}function Em(e){return{id:e.name,label:`/${e.name}`,value:`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``} `,description:e.description,category:e.category??`builtin`}}function Dm(e,t,n){let r=new Map;for(let e of vm)r.set(e.name,Em(e));for(let e of n?.commands??[])r.has(e.name)||r.set(e.name,Em({...e,category:`extension`}));if(!t||!e)return Array.from(r.values());for(let[t,n]of[[`skill`,e.skills],[`prompt`,e.prompts]])for(let e of n){if(e.activationStatus&&e.activationStatus!==`active`)continue;let n=Tm(e.name);!n||r.has(n)||r.set(n,{id:n,label:`/${n}`,value:`/${n} `,description:e.description,category:t})}return Array.from(r.values())}var Om=`fleet-prime:v1:right-panel-width`,km=`fleet-prime:v1:theme-preference`,Am=320;function jm(){return typeof window>`u`?Am:Mm()}function Mm(){return typeof window>`u`?Am:Math.max(Am,Math.floor(window.innerWidth*ei))}function Nm(e){return Math.min(Mm(),Math.max(Am,Math.round(e)))}function Pm(){return ii(Om,jm(),Nm)}function Fm(e){ai(Om,Nm(e))}function Im(){if(typeof window>`u`)return`system`;let e=window.localStorage.getItem(km);return e===`light`||e===`dark`||e===`system`?e:`system`}function Lm(e){typeof window>`u`||window.localStorage.setItem(km,e)}function Rm(e){if(typeof window>`u`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches,n=e===`dark`||e===`system`&&t;document.documentElement.classList.toggle(`dark`,n),document.documentElement.dataset.theme=n?`dark`:`light`}function zm(e,t){let{sessionMetadata:n,setSessionMetadata:r}=t,i=(0,Z.useMemo)(()=>e?.models.map(ci)??[],[e]),[a,o]=(0,Z.useState)(),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(`workspace`),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(()=>Im()),[b,x]=(0,Z.useState)(()=>Pm());(0,Z.useEffect)(()=>{if(i.length===0)return;let t=e?.selectedModelKey??i[0].id;if(!a){o(t);return}let n=i.find(e=>e.id===a);(!n||n.available===!1)&&o(t)},[i,a,e]),(0,Z.useEffect)(()=>{let t=i.find(e=>e.id===a);if(!t)return;let n=ti(t);c(t=>Xr(t??e?.defaultThinkingLevel,n))},[i,a,e?.defaultThinkingLevel]),(0,Z.useEffect)(()=>{if(Rm(v),v!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>Rm(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[v]);let S=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=S.current;if(S.current=l,!l||e!==null)return;let t=jm();x(t),Fm(t)},[l]),(0,Z.useEffect)(()=>{l===null&&h(null)},[l]),(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{x(e=>{let t=Nm(e);return Fm(t),t})};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[l]);let C=(0,Z.useCallback)(e=>{y(e),Lm(e),Rm(e)},[]),w=(0,Z.useCallback)(e=>{si({event:e,startWidth:b,getNextWidth:(e,t,n)=>Nm(n-(e-t)),onWidthChange:e=>{x(e),Fm(e)}})},[b]),T=(0,Z.useCallback)(()=>{u(d.current)},[]),E=(0,Z.useCallback)(e=>{if(e!==null&&(d.current=e),u(e),e===null){p(null);return}h(t=>{if(!t)return t;let n=oa(t);return!n||n.panel===e?t:null})},[]),D=(0,Z.useCallback)((e,t=`artifacts`)=>{p(e),E(t)},[E]),O=(0,Z.useCallback)(e=>{let t=oa(e);t&&(E(t.panel),h(t.path))},[E]),k=(0,Z.useCallback)(e=>{let t=e.panel===`artifacts`&&e.relativePath?`workspace`:e.panel,n=t===`workspace`||t===`artifacts`;E(t),h(n?e.relativePath??null:null),e.focus&&window.requestAnimationFrame(()=>{document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0})})},[E]),A=(0,Z.useCallback)(e=>{r(e)},[r]),j=i.find(e=>e.id===a),M=Xr(s??e?.defaultThinkingLevel,ti(j)),N=(0,Z.useCallback)(e=>{let t=i.find(e=>e.id===a);c(Xr(e,ti(t)))},[a,i]);return{commandPaletteOpen:g,handleResourceCanvasResizeStart:w,handleThemePreferenceChange:C,initialSessionMetadata:n,modelKey:a,modelSelection:(0,Z.useMemo)(()=>Qr(j,M),[M,j]),models:i,openWorkspacePath:O,openPanelAction:k,persistSession:A,reopenRightPanel:T,resourceCanvasWidth:b,rightPanel:l,selectedArtifactId:f,selectedWorkspacePath:m,setCommandPaletteOpen:_,setModelKey:o,setRightPanel:E,openArtifact:D,setSelectedWorkspacePath:h,setThinkingLevel:N,themePreference:v,thinkingLevel:M}}var Bm=`fleet-prime:v1:chat-session`;function Vm(){let[e,t]=(0,Z.useState)(()=>Hm()),n=(0,Z.useCallback)(e=>{t(e)},[]);return(0,Z.useEffect)(()=>{Km(e)},[e]),{sessionMetadata:e,setSessionMetadata:n}}function Hm(){if(typeof window>`u`||!window.localStorage)return{};try{let e=window.localStorage.getItem(Bm);return e?Wm(JSON.parse(e)):Um()}catch{return Um()}}function Um(){if(typeof window>`u`||!window.localStorage)return{};let e=window.localStorage.getItem(`fleet-prime:v1:chat-sessions`);if(!e)return{};try{return Wm(JSON.parse(e)?.normal)}catch{return{}}}function Wm(e){let t=Li.safeParse(e);return t.success?t.data:{}}function Gm(){typeof window>`u`||!window.localStorage||(window.localStorage.removeItem(Bm),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`),window.localStorage.removeItem(`fleet-prime:v1:chat-mode`))}function Km(e){if(!(typeof window>`u`||!window.localStorage)){if(!e.sessionId&&!e.projectId){window.localStorage.removeItem(Bm),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`);return}window.localStorage.setItem(Bm,JSON.stringify(e))}}function qm({activeSessionId:e,messages:t,presentation:n,sessions:r}){return(0,Z.useMemo)(()=>Qm(e,r,t,n),[e,t,n,r])}function Jm({messages:e,resources:t,workspaceTree:n}){return(0,Z.useMemo)(()=>Ym({messages:e,resources:t,workspaceTree:n}),[e,t,n])}function Ym({messages:e,resources:t,workspaceTree:n}){let r=!!t?.agentsFiles.some(e=>e.name===`AGENTS.md`),i=e=>e.toLowerCase().includes(`frontend`),a=!!(t?.skills.some(e=>i(`${e.name} ${e.description??``}`))||n?.nodes.some(e=>i(JSON.stringify(e))));if(e.length===0)return[$(`overview`,`Summarize this project`),$(`frontend`,a?`Find a skill "frontend"`:`Explore available skills`),$(`docs`,r?`Read AGENTS.md`:`Tell me about this project`)];let o=[...e].reverse().find(e=>e.role===`assistant`),s=Zm([...e].reverse().find(e=>e.role===`user`)).toLowerCase(),c=Zm(o).toLowerCase(),l=new Set,u=[];if(o){for(let e of o.parts)if(e.type.startsWith(`tool-`)){l.add(e.type);let t=e.input,n=typeof t?.file_path==`string`?t.file_path:typeof t?.path==`string`?t.path:void 0;n&&u.push(n)}}if(l.has(`tool-Write`)||l.has(`tool-Edit`)){let e=u[u.length-1]??`the changed file`;return[$(`review-changes`,`Review the changes to ${e.split(`/`).pop()??e}`),$(`run-tests`,`Run the tests`),$(`explain-changes`,`Explain what was changed and why`)]}if(l.has(`tool-Read`)&&!l.has(`tool-Write`)){let e=u[u.length-1]??`the file`;return[$(`summarize-file`,`Summarize ${e.split(`/`).pop()??e}`),$(`suggest-improvements`,`Suggest improvements`),$(`find-related`,`Find related files`)]}return l.has(`tool-Bash`)?[$(`explain-output`,`Explain the output`),$(`fix-issues`,`Fix any issues found`),$(`run-again`,`Run it again with different options`)]:l.has(`tool-PlanWrite`)?[$(`execute-plan`,`Execute this plan`),$(`refine-plan`,`Refine the plan`),$(`explain-plan`,`Explain the plan in detail`)]:l.has(`tool-resource_install`)?[$(`use-resource`,`Use the installed resource`),$(`list-resources`,`List all available resources`),$(`workspace`,`Show workspace files`)]:Xm(o)?[$(`fix-error`,`Fix the error`),$(`explain-error`,`Explain what went wrong`),$(`suggest-alternative`,`Suggest an alternative approach`)]:s.includes(`what can you do`)||s.includes(`help`)?[$(`frontend`,`Find a skill "frontend"`),$(`agents`,r?`Read AGENTS.md`:`Read the repo docs`),$(`workspace`,`Show workspace files`)]:s.includes(`skill`)?[$(`frontend-skill`,`Find a skill "frontend"`),$(`memory-skill`,`Find a skill "memory"`),$(`skill-docs`,r?`Read AGENTS.md`:`Show workspace files`)]:c?[$(`go-deeper`,`Go deeper on this`),$(`next-steps`,`What should I do next?`),$(`workspace`,`Show workspace files`)]:[$(`overview`,`Summarize this project`),$(`workspace`,`Show workspace files`),$(`docs`,r?`Read AGENTS.md`:`Tell me about this project`)]}function Xm(e){return e?e.parts.some(e=>{if(e.type===`error`)return!0;if(!e.type.startsWith(`tool-`)||typeof e!=`object`||!e)return!1;let t=e;if(t.state===`output-error`||t.state===`error`||t.state===`failed`)return!0;let n=typeof t.output==`object`&&t.output!==null?t.output:void 0;return!!(t.error||n?.error)}):!1}function $(e,t){return{id:e,label:t,value:t}}function Zm(e){return e?e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}function Qm(e,t,n,r){if(r?.sessionName?.trim())return oi(r.sessionName);let i=t.find(t=>t.sessionId===e);if(i?.title.trim())return oi(i.title);let a=[...n].reverse().find(e=>e.role===`user`&&e.source!==`local`);return oi(Zm(a).trim())||(i?oi(i.title||i.firstMessage||i.sessionId.slice(0,8)):`Session`)}var $m=`https://docs.qredence.ai`;function eh({className:e}){return(0,Q.jsx)(`svg`,{width:`97`,height:`93`,viewBox:`0 0 97 93`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M53.72 0.17C53.27 0.24 52.22 0.43 51.40 0.60C50.58 0.78 49.27 1.11 48.49 1.36C47.71 1.61 46.34 2.17 45.43 2.60C44.52 3.03 43.18 3.79 42.44 4.29C41.71 4.78 40.62 5.62 40.06 6.14C39.47 6.65 38.58 7.54 38.06 8.12C37.53 8.69 36.68 9.81 36.16 10.59C35.65 11.36 34.92 12.65 34.56 13.42C34.20 14.20 33.73 15.38 33.50 16.04C33.29 16.69 32.98 17.83 32.83 18.57C32.67 19.31 32.46 20.65 32.35 21.56C32.26 22.49 32.22 24.04 32.26 25.14C32.31 26.22 32.52 28.03 32.73 29.17C32.93 30.32 33.31 31.97 33.55 32.83C33.79 33.70 34.29 35.24 34.68 36.27C35.07 37.30 35.77 38.97 36.26 40.00C36.76 41.03 37.64 42.67 38.22 43.66C38.80 44.64 39.73 46.12 40.28 46.94C40.83 47.76 41.76 49.05 42.31 49.79C42.88 50.55 44.06 51.99 44.92 53.00C45.79 54.02 46.95 55.36 47.52 55.97C48.07 56.59 50.28 58.93 52.43 61.18C54.58 63.42 58.20 67.08 60.48 69.32C64.30 73.02 64.62 73.38 64.36 73.56C64.21 73.68 63.57 74.02 62.94 74.35C62.30 74.67 61.26 75.14 60.63 75.40C59.99 75.65 58.90 76.04 58.20 76.28C57.49 76.50 56.28 76.83 55.51 77.00C54.73 77.16 53.39 77.41 52.52 77.53C51.57 77.68 49.92 77.77 48.31 77.77C46.65 77.77 45.03 77.68 43.98 77.53C43.06 77.40 41.41 77.07 40.35 76.80C39.29 76.53 37.74 76.07 36.92 75.76C36.10 75.44 34.70 74.83 33.79 74.37C32.87 73.92 31.58 73.20 30.87 72.77C30.17 72.34 28.96 71.49 28.19 70.89C27.41 70.28 26.07 69.08 25.20 68.22C24.33 67.35 23.05 65.87 22.35 64.93C21.65 63.99 20.77 62.71 20.39 62.10C20.02 61.48 19.48 60.51 19.18 59.93C18.90 59.35 18.41 58.27 18.11 57.54C17.80 56.81 17.35 55.53 17.11 54.70C16.85 53.88 16.50 52.48 16.30 51.57C16.11 50.66 15.87 48.88 15.77 47.61C15.63 45.87 15.63 44.73 15.75 42.98C15.85 41.72 16.06 39.97 16.24 39.10C16.42 38.24 16.74 36.92 16.94 36.19C17.15 35.46 17.59 34.18 17.91 33.36C18.24 32.53 18.89 31.13 19.35 30.22C19.81 29.31 20.57 28.01 21.04 27.31C21.48 26.61 22.29 25.50 22.81 24.85C23.33 24.19 24.48 22.92 25.36 22.01C26.31 21.02 27.11 20.05 27.34 19.57C27.56 19.16 27.84 18.38 27.96 17.87C28.08 17.35 28.19 16.56 28.19 16.11C28.19 15.66 28.08 14.86 27.95 14.31C27.83 13.78 27.53 12.98 27.28 12.53C27.04 12.08 26.53 11.38 26.14 10.98C25.74 10.57 25.10 10.02 24.68 9.75C24.27 9.48 23.53 9.11 23.04 8.94C22.54 8.77 21.66 8.59 21.09 8.54C20.40 8.49 19.72 8.55 19.05 8.71C18.48 8.84 17.65 9.12 17.18 9.35C16.59 9.63 15.79 10.26 14.63 11.41C13.69 12.30 12.38 13.71 11.72 14.53C11.05 15.33 10.05 16.60 9.51 17.37C8.97 18.11 8.17 19.29 7.73 19.99C7.30 20.69 6.48 22.13 5.93 23.20C5.37 24.28 4.64 25.80 4.31 26.61C3.97 27.40 3.43 28.85 3.09 29.80C2.76 30.77 2.30 32.34 2.06 33.28C1.82 34.22 1.45 35.94 1.25 37.09C1.04 38.24 0.81 39.95 0.72 40.89C0.64 41.84 0.57 43.75 0.57 45.15C0.57 46.55 0.64 48.46 0.72 49.40C0.81 50.35 1.00 51.96 1.18 52.99C1.34 54.02 1.75 55.87 2.06 57.09C2.37 58.33 2.94 60.21 3.33 61.27C3.72 62.33 4.42 64.05 4.88 65.08C5.34 66.11 6.14 67.65 6.61 68.52C7.09 69.38 8.02 70.86 8.64 71.80C9.29 72.74 10.36 74.22 11.06 75.08C11.75 75.95 12.85 77.22 13.50 77.91C14.14 78.59 15.38 79.80 16.24 80.58C17.11 81.35 18.45 82.49 19.23 83.07C20.01 83.67 21.45 84.68 22.44 85.33C23.42 85.97 25.17 86.98 26.32 87.58C27.47 88.16 29.32 89.01 30.43 89.46C31.53 89.91 33.11 90.48 33.93 90.73C34.76 90.98 36.10 91.36 36.92 91.57C37.74 91.76 39.19 92.07 40.13 92.24C41.07 92.40 42.92 92.64 44.24 92.78C45.55 92.90 47.40 93 48.34 93C49.28 93 51.10 92.90 52.37 92.78C53.64 92.66 55.49 92.42 56.48 92.24C57.46 92.07 58.94 91.76 59.76 91.55C60.58 91.36 61.90 90.98 62.67 90.73C63.45 90.48 64.93 89.94 65.96 89.54C66.99 89.13 68.71 88.36 69.77 87.82L69.80 87.80L69.80 87.80C70.85 87.27 71.95 86.71 72.23 86.54C72.51 86.37 73.47 85.77 74.36 85.21L75.96 84.19C78.34 86.36 80.13 88.00 81.49 89.25C83.14 90.76 84.26 91.67 84.92 92.01C85.46 92.30 86.32 92.64 86.86 92.76C87.40 92.90 88.13 93 88.50 93C88.88 93 89.58 92.90 90.07 92.78C90.56 92.64 91.37 92.34 91.86 92.10C92.36 91.87 93.03 91.45 93.34 91.18C93.67 90.91 94.24 90.28 94.59 89.79C94.95 89.30 95.37 88.54 95.54 88.12C95.68 87.69 95.88 86.88 95.97 86.33C96.06 85.67 96.06 84.95 95.97 84.31C95.88 83.74 95.61 82.85 95.36 82.30C95.10 81.73 94.71 81.04 94.49 80.76C94.25 80.47 92.44 78.74 90.46 76.92C88.49 75.08 86.86 73.56 86.86 73.52C86.86 73.47 87.47 72.52 88.22 71.40C88.97 70.26 90.12 68.26 90.77 66.95C91.44 65.63 92.31 63.74 92.70 62.74C93.10 61.72 93.67 60.11 93.95 59.15C94.25 58.18 94.65 56.69 94.85 55.82C95.04 54.96 95.31 53.64 95.43 52.91C95.57 52.18 95.76 50.49 95.89 49.18C96.01 47.87 96.12 46.12 96.12 45.30C96.12 44.48 96.01 42.70 95.89 41.34C95.77 39.98 95.54 38.10 95.36 37.16C95.19 36.22 94.89 34.77 94.68 33.95C94.48 33.13 94.07 31.73 93.77 30.82C93.49 29.91 93.00 28.53 92.68 27.76C92.37 26.98 91.83 25.73 91.50 24.99C91.16 24.26 90.43 22.84 89.88 21.86C89.34 20.87 88.32 19.23 87.62 18.20C86.94 17.17 85.73 15.53 84.95 14.54C84.16 13.56 82.53 11.77 81.34 10.57C80.14 9.38 78.47 7.84 77.60 7.15C76.74 6.47 75.23 5.38 74.25 4.72C73.26 4.08 71.72 3.18 70.81 2.75C69.90 2.30 68.56 1.73 67.83 1.48C67.09 1.21 65.94 0.88 65.29 0.72C64.63 0.57 63.36 0.35 62.45 0.21C61.35 0.06 59.78 -0.01 57.67 0.00C55.94 0.02 54.16 0.09 53.72 0.17ZM54.24 15.47C54.82 15.33 55.45 15.20 55.66 15.17C55.87 15.13 56.81 15.10 57.75 15.08C58.69 15.08 60.08 15.16 60.81 15.28C61.54 15.38 62.56 15.63 63.05 15.83C63.54 16.04 64.38 16.44 64.91 16.74C65.45 17.04 66.57 17.78 67.41 18.41C68.26 19.04 69.63 20.23 70.48 21.07C71.32 21.92 72.47 23.17 73.04 23.87C73.60 24.58 74.54 25.88 75.14 26.79C75.75 27.70 76.60 29.13 77.07 30.00C77.51 30.86 78.19 32.30 78.55 33.21C78.90 34.12 79.43 35.58 79.68 36.49C79.93 37.40 80.29 38.86 80.46 39.77C80.68 40.89 80.80 42.31 80.84 44.25C80.90 45.97 80.86 47.67 80.75 48.58C80.67 49.40 80.41 50.88 80.22 51.87C80.01 52.85 79.53 54.57 79.16 55.68C78.78 56.78 78.08 58.50 77.60 59.48C77.13 60.47 76.47 61.66 75.59 63.02L73.35 60.81C72.11 59.59 69.30 56.78 67.09 54.56C64.88 52.35 62.12 49.51 60.97 48.29C59.81 47.05 58.17 45.24 57.30 44.25C56.43 43.27 55.28 41.90 54.75 41.19C54.19 40.49 53.28 39.22 52.72 38.36C52.15 37.49 51.39 36.28 51.03 35.67C50.67 35.06 50.09 33.94 49.75 33.21C49.40 32.47 48.88 31.16 48.58 30.29C48.28 29.43 47.89 28.07 47.74 27.26C47.55 26.34 47.45 25.22 47.45 24.13C47.45 23.17 47.55 22.05 47.67 21.52C47.79 21.01 48.10 20.17 48.36 19.65C48.63 19.13 49.24 18.32 49.75 17.80C50.43 17.11 50.98 16.74 51.93 16.29C52.63 15.96 53.66 15.59 54.24 15.47Z`,fill:`currentColor`})})}function th({user:e,onSignOut:t,onOpenSettings:n,compact:r=!1,label:i=`Fleet Prime Agent`,className:a}){let o=`flex w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-label leading-4 text-foreground transition-colors hover:bg-foreground/6`;return(0,Q.jsx)(`div`,{className:q(`flex min-w-0 items-center gap-2`,a),children:(0,Q.jsx)(vl,{side:`bottom`,align:`start`,trigger:(0,Q.jsxs)(Fs,{ariaLabel:`Open account menu`,className:q(`min-w-0 border-transparent shadow-none`,r?`size-8 justify-center px-2`:`w-full justify-start`),children:[(0,Q.jsx)(eh,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:r?`sr-only`:`text-[13px] font-medium tracking-[-0.01em] whitespace-nowrap`,children:i}),(0,Q.jsx)(yr,{className:`size-3.5 shrink-0 text-foreground/35`})]}),children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-label leading-4 text-foreground/50`,children:e.name||e.email}),(0,Q.jsxs)(`button`,{type:`button`,className:o,children:[(0,Q.jsx)(eh,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Account`})]}),(0,Q.jsxs)(`a`,{href:$m,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(Qn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Q.jsx)(Rn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Settings`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:()=>void t(),children:[(0,Q.jsx)(mr,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Sign out`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`a`,{href:$m,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(Qn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Documentation`})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,className:o,onClick:n,children:[(0,Q.jsx)(Rn,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Settings`})]})]})})})}function nh({activeSessionId:e,activeSessionLabel:t,onNewSession:n,onResumeSession:r,sessions:i}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vl,{side:`bottom`,align:`center`,className:`w-[min(360px,calc(100vw-2rem))]`,overlay:!0,trigger:(0,Q.jsxs)(Fs,{ariaLabel:`Open conversations`,className:`w-28 justify-between sm:w-36 md:w-44 lg:w-52 xl:w-64`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Un,{className:`size-3 shrink-0 text-foreground/35`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:t})]}),(0,Q.jsx)(yr,{className:`size-3.5 shrink-0 text-foreground/35`})]}),children:i.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-2 text-label text-foreground/45`,children:`No saved conversations yet.`}):i.map(t=>{let n=oi(t.title),i=t.sessionId===e;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r({sessionId:t.sessionId}),className:`flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-label leading-4 transition-colors hover:bg-foreground/6 ${i?`bg-foreground/6 text-foreground`:`text-foreground`}`,children:[(0,Q.jsx)(Un,{className:`size-3 shrink-0 text-foreground/45`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]},t.sessionId)})}),(0,Q.jsx)(Fs,{ariaLabel:`New session`,onClick:n,children:(0,Q.jsx)(hi,{className:`size-3.5 shrink-0`})})]})}function rh(e){return null}function ih(e){return typeof e==`object`&&!!e&&typeof e.ok==`boolean`}function ah(e=15e3){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1,r=async()=>{try{let e=await fetch(Xf(`/api/health`));if(!e.ok)throw Error(`http-${e.status}`);let r=await e.json();if(!ih(r.kernel))throw Error(`invalid-response`);t||n(r.kernel)}catch(e){t||n({ok:!1,reason:e instanceof Error?e.message:`unreachable`})}};r();let i=setInterval(()=>void r(),e);return()=>{t=!0,clearInterval(i)}},[e]),t}function oh({activeSessionId:e,activeSessionLabel:t,sessions:n,onNewSession:r,onResumeSession:i,onOpenSettings:a}){let o=c(),s=lp(),l=ah();return{left:(0,Q.jsx)(fc,{"aria-label":`Toggle conversations`,className:`size-9 rounded-[10px] border border-border/70 bg-background shadow-sm`,children:(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-icon":`inline-start`,className:`block h-3.5 w-4 rounded-[3px] border border-current before:block before:h-full before:w-1 before:border-r before:border-current`})}),accountMenu:(0,Q.jsx)(th,{className:`w-full`,label:`Qredence`,user:s,onSignOut:async()=>{Gm(),await dp(),o({to:`/`})},onOpenSettings:a}),center:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nh,{activeSessionId:e,activeSessionLabel:t,sessions:n,onNewSession:r,onResumeSession:i}),(0,Q.jsx)(rh,{ok:l?.ok??null,reason:l?.reason})]}),right:(0,Q.jsx)(Is,{})}}function sh(e,t,n=crypto.randomUUID()){return{id:n,role:e,createdAt:Date.now(),parts:[{type:`text`,text:t}]}}function ch(e){return{...sh(`user`,e),optimistic:!0}}function lh(e,t){return e.filter(e=>e.id!==t||e.optimistic!==!0)}function uh(e,t){return e.map(e=>{if(e.id!==t||e.optimistic!==!0)return e;let n={...e};return delete n.optimistic,n})}function dh(e,t){let n=e.findIndex(e=>e.type===`text`);if(n===-1)return[...e,{type:`text`,text:t}];let r=[...e],i=r[n];return r[n]=i.type===`text`?{...i,text:`${i.text}${t}`}:i,r}function fh(e,t){let n=e.findIndex(e=>e.type===t.type&&`toolCallId`in e&&e.toolCallId===t.toolCallId);if(n===-1){let n=e.findIndex(e=>e.type===`text`);return n===-1?[...e,t]:[...e.slice(0,n),t,...e.slice(n)]}let r=[...e];return r[n]={...r[n],...t},r}function ph(e,t){let n=e.findIndex(e=>e.type===`payload`&&(e.id&&t.id?e.id===t.id:e.kind===t.kind&&e.title===t.title));if(n===-1)return[...e,t];let r=[...e];return r[n]={...r[n],...t},r}function mh({messageId:e,presentation:t}){return{type:`tool-FleetReasoning`,toolCallId:`${e}-reasoning`,state:t.streaming?`input-streaming`:`output-available`,input:t}}function hh(e,t,n){return e.map(e=>e.id===t?{...e,parts:dh(e.parts,n)}:e)}function gh(e,t,n){return e.map(e=>e.id===t?{...e,parts:fh(e.parts,n)}:e)}function _h(e,t,n){return e.map(e=>e.id===t?{...e,parts:ph(e.parts,n)}:e)}function vh(e,t,n){return gh(e,t,mh({messageId:t,presentation:n}))}function yh(e){if(e.role!==`assistant`)return e;let t=e.parts.filter(e=>e.type!==`tool-Thinking`);return t.length===e.parts.length?e:{...e,parts:t}}function bh(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var xh=`/api/chat/command`;function Sh(e){return e.sessionId?.trim()||void 0}function Ch({sessionId:e,name:t}){let n=e.trim()||`none`;return[t?`Session: ${t}`:`Session`,` id: ${n}`].join(`
9
- `)}function wh(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}function Th(e){let{entry:t}=e;if(t.type===`message`&&t.message){let e=t.message.role??`message`,n=wh(t.message.content).replace(/\s+/g,` `).trim();return`${e}: ${n.length>72?`${n.slice(0,72)}…`:n}`}return t.label??e.label??t.type}function Eh(e,t){let n=[],r=(e,i)=>{for(let a of e){let e=a.entry.id===t?`*`:` `,o=` `.repeat(i);n.push(`${o}${e} ${a.entry.id} ${Th(a)}`),r(a.children,i+1)}};return r(e,0),n}function Dh(e,t){let n=Eh(e,t);return n.length>0?n.join(`
10
- `):`(empty session tree)`}function Oh(e){let t=[],n=[],r=e=>{for(let i of e){if(i.entry.type===`message`){let e={id:i.entry.id,preview:Th(i)};t.push(e),i.entry.message?.role===`user`&&n.push(e)}r(i.children)}};return r(e),n.length>0?n:t}function kh(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role!==`assistant`||n.source===`local`)continue;let r=bh(n).trim();if(r)return r}}function Ah(e){return e.flatMap(e=>{if(e.source===`local`)return[];let t=bh(e).trim(),n=`**${e.role}**\n\n${t}`;return n.trim().length>0?[n]:[]}).join(`
11
-
12
- ---
13
-
14
- `)}function jh({appendLocalMessage:e,getMessages:t,getSessionMetadata:n,modelKey:r,models:i,onForkPicker:a,openSettings:o,onOpenUIRequest:s,resumeSession:c,sessions:l,setEffortPickerOpen:u,setModelKey:d,setModelPickerOpen:f,setThinkingLevel:p,startNewSession:m}){let h=(0,Z.useCallback)(async(e,t=``)=>{let r=Sh(n());if(!r)return{ok:!1,error:`No active session — start a new one first.`};try{let n=await fetch(xh,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:r,command:e,args:t})});if(!n.ok){let e=`HTTP ${n.status}`;try{let t=await n.json();typeof t.message==`string`&&(e=t.message)}catch{}return{ok:!1,error:e}}return{ok:!0,payload:await n.json()}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},[n]),g=(0,Z.useCallback)(async(t,n,r)=>{let i=await t;if(!i.ok){e(`${n} failed: ${i.error}`);return}let a={newSessionId:typeof i.payload.newSessionId==`string`?i.payload.newSessionId:`?`,selectedText:typeof i.payload.selectedText==`string`?i.payload.selectedText:`(none)`};if(vi.success(r(a)),a.newSessionId!==`?`){await c({sessionId:a.newSessionId});return}e(r(a))},[e,c]),_=(0,Z.useCallback)(c=>{switch(c.type){case`open-model-picker`:return c.modelKey&&i.some(e=>e.id===c.modelKey)?(d(c.modelKey),vi.success(`Model set to ${c.modelKey}`),!0):(u(!1),f(!0),!0);case`open-effort-picker`:return c.unknownLevel&&vi.error(`Unknown thinking level '${c.unknownLevel}'.`),f(!1),u(!0),!0;case`set-thinking-level`:{let e=i.find(e=>e.id===r),t=ti(e);return t.includes(c.level)?(p(c.level),vi.success(`Effort set to ${ni(c.level)}`),!0):(vi.error(`Unknown thinking level '${c.level}'. Available: ${t.join(`, `)}`),f(!1),u(!0),!0)}case`open-settings`:return o(c.tab),!0;case`new-session`:return m(),!0;case`openui-request`:return c.request?(s(c.request),!0):(e(`Usage: /openui <request>`),!0);case`session-info`:return(async()=>{let t=Sh(n()),r=await h(`session`);if(!r.ok||!t){e(Ch({sessionId:t??`none`,name:null}));return}e(Ch({sessionId:t,name:typeof r.payload.name==`string`?r.payload.name:null}))})(),!0;case`session-rename`:return c.name?((async()=>{let t=await h(`name`,c.name??``);e(t.ok?`Session renamed to "${c.name}".`:`Couldn't rename session: ${t.error}`)})(),!0):(e(`Usage: /name <display name>`),!0);case`session-context`:return(async()=>{let t=await h(`context`);if(!t.ok){e(`Couldn't load context: ${t.error}`);return}let n=t.payload.usage;if(!n){e(`Context usage isn't available yet — no model response on this branch.`);return}let{tokens:r,contextWindow:i,percent:a}=n;e(`Context usage: ~${r??`?`}/${i??`?`} tokens${typeof a==`number`?` (${a.toFixed(1)}%)`:``}`)})(),!0;case`session-system-prompt`:return(async()=>{let t=await h(`system-prompt`);if(!t.ok){e(`Couldn't load system prompt: ${t.error}`);return}e(typeof t.payload.systemPrompt==`string`?t.payload.systemPrompt:`(empty)`)})(),!0;case`session-logs`:return e("Daemon and client logs live at `~/.prime/agent/log/`. Use your OS's log viewer or `tail -f` there (TUI parity with /logs)."),!0;case`session-export`:return(async()=>{let t=await h(`export`,c.outputPath??``);if(!t.ok){e(`Export failed: ${t.error}`);return}e(`Session exported to ${typeof t.payload.path==`string`?t.payload.path:`(unknown path)`} (${typeof t.payload.format==`string`?t.payload.format:`html`})`)})(),!0;case`session-fork`:return c.args?(g(h(`fork`,c.args),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`),!0):((async()=>{let t=await h(`tree`);if(!t.ok){e(`Fork picker failed: ${t.error}`);return}let n=t.payload.tree,r=Array.isArray(n?.tree)?Oh(n.tree):[];if(r.length===0){e(`No fork points yet — send a user message first, then run /fork.`);return}a(r)})(),!0);case`session-clone`:return g(h(`clone`),`Clone`,e=>`Cloned → session ${e.newSessionId}.`),!0;case`session-tree`:return(async()=>{let t=await h(`tree`,c.args??``);if(!t.ok){e(`Tree failed: ${t.error}`);return}let n=t.payload.tree;if(!n||!Array.isArray(n.tree)){e(`(no session tree available)`);return}e(Dh(n.tree,n.leafId??null))})(),!0;case`session-share`:return(async()=>{let n=Ah(t());if(!n.trim()){e(`Nothing to share yet.`);return}await navigator.clipboard.writeText(n),vi.success(`Transcript copied`),e(`Copied the transcript to the clipboard. GitHub Gist upload is TUI-only in this port.`)})().catch(e=>{vi.error(`Share failed: ${e instanceof Error?e.message:String(e)}`)}),!0;case`session-import`:return e(c.path?`/import ${c.path} is not wired in the web port. Resume a saved conversation from the session picker instead.`:`Usage: /import <path.jsonl> — JSONL import is not wired in the web port. Use the session picker to resume.`),!0;case`session-btw`:return e(c.question?`/btw is not wired in the web port. Side question was not sent:\n${c.question}`:`Usage: /btw <question> — side questions are not wired in the web port.`),!0;case`session-traces`:return e(`Fleet Prime traces (preview / upload / login) are TUI-only. The web port does not upload traces.`),!0;case`session-agents`:return l.length===0?(e(`No saved sessions. The web port has no daemon agent tray — use the conversation picker in the header.`),!0):(e(`Saved sessions (web stand-in for /agents):\n${l.map(e=>`${e.sessionId} ${e.title}`).join(`
15
- `)}`),!0);case`open-providers`:return o(`providers`),!0;case`open-logout`:return e(`Provider sign-out is managed by Fleet Prime CLI commands.`),!0;case`open-mcp`:return o(`chat`),c.args&&e(`MCP: ${c.args}. Manage MCP connections with Fleet Prime CLI configuration.`),!0;case`fast-toggle`:return(async()=>{e("/fast toggles OpenAI Fast mode. The web port reads this from ~/.prime/agent/settings.json — flip `fastMode` there or in Settings.")})(),!0;case`reload-resources`:return(async()=>{let t=await h(`reload`);e(t.ok?`Reloaded keybindings, extensions, skills, prompts, and themes.`:`Reload failed: ${t.error}`)})(),!0;case`show-changelog`:return e(`Changelog lives at https://github.com/Qredence/fleet-prime-agent/blob/main/CHANGELOG.md`),!0;case`show-hotkeys`:return e(`Web port hotkeys: Enter=send, Alt+Enter=follow-up while streaming, / = slash menu, ⌘K=command palette.`),!0;case`copy-last-reply`:return(async()=>{let e=kh(t());if(!e){vi.error(`No assistant message to copy`);return}await navigator.clipboard.writeText(e),vi.success(`Last assistant message copied`)})().catch(e=>{vi.error(`Copy failed: ${e instanceof Error?e.message:String(e)}`)}),!0;case`update-check`:return e(`/update is TUI-only (pulls the latest Fleet Prime release). Use npm/pnpm in your shell to upgrade.`),!0;case`toggle-fullscreen`:return e(`/fullscreen is TUI-only (alternate screen rendering). In the browser, use your OS/browser fullscreen.`),!0;case`quit-app`:return e(`/quit is TUI-only (exits the agent loop). Close this browser tab instead.`),!0;case`rlm-max-depth`:return e(`/rlm-max-depth is not yet wired in the web port.`),!0;case`heartbeat-manage`:case`heartbeat-list`:return e(`/heartbeat(s) are not wired in the web port. Persistent heartbeats remain TUI/session-cron.`),!0;default:return!1}},[e,h,g,t,n,r,i,a,o,s,l,u,d,f,p,m]),v=(0,Z.useCallback)(e=>{if(e.id===`openui`)return!1;let t=wm(e.id);return t?_(t):!1},[_]),y=(0,Z.useCallback)(e=>{let t=Sm(e);if(!t)return!1;let n=wm(t.command,t.args);return n?_(n):!1},[_]);return{applyLocalSlashAction:_,forkFromEntry:(0,Z.useCallback)(e=>{g(h(`fork`,e),`Fork`,e=>`Forked → session ${e.newSessionId}. Selected text: ${e.selectedText}`)},[h,g]),handleLocalSlashSubmit:y,handleSlashCommandSelect:v}}function Mh({messages:e,answerQuestion:t}){let n=(0,Z.useRef)(new Map);return(0,Z.useMemo)(()=>{let r=Nh(e);if(!r){n.current.clear();return}let{part:i}=r,a=i.input?.questions??[];if(a.length===0){n.current.clear();return}let o=a.map((e,t)=>Ph(e,t)),s=i.toolCallId,c=s??`pending-question`;for(let e of Array.from(n.current.keys()))e!==c&&n.current.delete(e);let l=o.map((e,t)=>e.id??`question-${t+1}`);return{id:c,questions:o,submitLabel:`Continue`,allowSkip:!0,onSubmit:e=>{if(e.kind===`skip`){n.current.delete(c),t({toolCallId:s,answer:{kind:`skip`,...e.questionId?{questionId:e.questionId}:{}}});return}let r=n.current.get(c),i=r??new Map;r||n.current.set(c,i);let a=typeof e.questionId==`string`&&e.questionId?e.questionId:l.find(e=>!i.has(e));if(!a){t({toolCallId:s,answer:e});return}if(i.set(a,Fh(e)),!l.every(e=>i.has(e)))return;let o={};for(let e of l){let t=i.get(e);t!==void 0&&(o[e]=t)}n.current.delete(c),t({toolCallId:s,answer:{kind:`questions`,answers:o}})}}},[e,t])}function Nh(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.role!==`assistant`||!Array.isArray(n.parts)))for(let e=n.parts.length-1;e>=0;e--){let t=n.parts[e];if(t?.type===`tool-Question`&&gm(t))return{part:t}}}}function Ph(e,t){let n=(e.options??[]).map(e=>{let t=e.value??e.label;if(typeof t==`string`)return{id:t,value:t,label:e.label??t,description:e.description}}).filter(e=>e!==void 0),r=e.kind??(n.length>0?`single`:`text`);return{id:typeof e.id==`string`&&e.id.trim()?e.id:`question-${t+1}`,kind:r,title:e.question??e.prompt??e.title??``,options:n.length>0?n:void 0,allowCustom:e.allowOther??e.allowCustom}}function Fh(e){if(e.kind===`multi`){let t=Array.isArray(e.selectedIds)?[...e.selectedIds]:[];return typeof e.text==`string`&&e.text.trim()&&t.push(e.text.trim()),t}return e.kind===`text`?typeof e.text==`string`?e.text:``:e.selectedIds?.[0]??e.text??``}function Ih(e){Gp(e)||vi.error(e instanceof Error?e.message:String(e))}var Lh={steering:[],followUp:[]};function Rh(e){let t=e.sessionId?.trim()||void 0,n=e.projectId?.trim()||void 0;return t||n?{...t?{sessionId:t}:{},...n?{projectId:n}:{}}:{}}function zh(e,t){let n=t.sessionId?.trim()||e.sessionId,r=t.projectId?.trim()||e.projectId;return{...n?{sessionId:n}:{},...r?{projectId:r}:{}}}function Bh(e){return(e.parts??[]).some(e=>e.type!==`text`||typeof e.text==`string`&&e.text.trim().length>0)}function Vh(e,t){if(!t)return e;let{assistantId:n,snapshot:r}=e;if(n===t)return e;if(n){let e=r.messages.map(e=>e.id===n&&e.role===`assistant`?{...e,id:t}:e);return{assistantId:t,snapshot:{...r,messages:e}}}return{assistantId:t,snapshot:{...r,messages:[...r.messages,sh(`assistant`,``,t)]}}}function Hh(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]}function Uh(e,t,n){let r=[n?e.find(e=>e.id===n&&e.role===`assistant`):void 0,e.find(e=>e.id===t.id&&e.role===`assistant`)].filter(Boolean).flatMap(e=>e.parts.filter(e=>e.type===`tool-FleetReasoning`||e.type===`payload`));return r.length===0||t.parts.some(e=>e.type===`tool-FleetReasoning`||e.type===`payload`)?t:{...t,parts:[...r,...t.parts]}}function Wh(e,t,n){if(!Bh(t)){let r=[n?e.find(e=>e.id===n&&e.role===`assistant`):void 0,e.find(e=>e.id===t.id&&e.role===`assistant`)].filter(Boolean).find(e=>Bh(e));if(r)return Hh(e,{...t,parts:r.parts,createdAt:t.createdAt??r.createdAt})}return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):n&&n!==t.id&&e.some(e=>e.id===n&&e.role===`assistant`)?e.map(e=>e.id===n&&e.role===`assistant`?t:e):[...e,t]}function Gh(e,t){if(t.type===`done`&&t.sessionReset)return e;if(t.type===`presentation`){let n=e.snapshot.presentation?.revision??-1;return t.presentation.revision<=n?e:{...e,snapshot:{...e.snapshot,presentation:t.presentation}}}if(t.type===`message`){if(t.message.role===`user`){let n=e.snapshot.messages.findIndex(e=>e.id===t.message.id),r=n>=0?n:e.snapshot.messages.findIndex(e=>e.role===`user`&&e.optimistic===!0),i=r>=0?{...t.message,id:e.snapshot.messages[r].id}:t.message;return{...e,snapshot:{...e.snapshot,messages:r>=0?e.snapshot.messages.map((e,t)=>t===r?i:e):[...e.snapshot.messages,i]}}}let n=Vh(e,t.message.id);return{assistantId:n.assistantId,snapshot:{...n.snapshot,messages:Wh(n.snapshot.messages,t.message,n.assistantId)}}}if(t.type===`start`){let n=e.snapshot.messages.some(e=>e.id===t.id&&e.role===`assistant`);return{assistantId:t.id,snapshot:{...e.snapshot,adapterCapabilities:t.adapterCapabilities,activityLabel:t.sessionReset?`Started a fresh Pi session`:t.diagnostics?.[0],messages:n?e.snapshot.messages:[...e.snapshot.messages,sh(`assistant`,``,t.id)],sessionMetadata:zh(e.snapshot.sessionMetadata,{sessionId:t.sessionId})}}}if(t.type===`thinking`)return e;let n=t.type===`delta`||t.type===`reasoning`||t.type===`tool`||t.type===`payload`?Vh(e,t.messageId):e,{assistantId:r,snapshot:i}=n;if(t.type===`delta`&&r)return{assistantId:r,snapshot:{...i,messages:hh(i.messages,r,t.text)}};if(t.type===`error`)return n;if(t.type===`reasoning`&&r&&i.adapterCapabilities?.features.includes(`reasoning-summary-v1`))return{assistantId:r,snapshot:{...i,messages:vh(i.messages,r,t.presentation)}};if(t.type===`tool`&&r)return{assistantId:r,snapshot:{...i,messages:gh(i.messages,r,t.part)}};if(t.type===`payload`&&r)return{assistantId:r,snapshot:{...i,messages:_h(i.messages,r,t.part)}};if(t.type===`queue`)return{assistantId:r,snapshot:{...i,queue:{steering:t.steering,followUp:t.followUp}}};if(t.type===`plan`)return{assistantId:r,snapshot:{...i,planLabel:t.message}};if(t.type===`state`)return{assistantId:r,snapshot:{...i,activityLabel:$p(t.state.name)}};if(t.type===`compaction`)return{assistantId:r,snapshot:{...i,activityLabel:t.phase===`start`?`Compacting session`:`Compaction finished`}};if(t.type===`retry`)return{assistantId:r,snapshot:{...i,activityLabel:t.phase===`start`?`Retrying request ${t.attempt}/${t.maxAttempts}`:t.success?`Retry succeeded`:`Retry failed`}};if(t.type===`done`){let e=yh(t.message),n=Uh(i.messages,e,r),a=Wh(i.messages,n,r),o=t.presentation&&t.presentation.revision>(i.presentation?.revision??-1)?t.presentation:i.presentation;return{assistantId:null,snapshot:{...i,activityLabel:void 0,messages:a.map(e=>yh(e)),queue:Lh,presentation:o,sessionMetadata:zh(i.sessionMetadata,{sessionId:t.sessionId})}}}return n}function Kh(e){let t=e.replace(/\*{1,2}([^*]+)\*{1,2}/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^(Use|Run|Execute|Create|Write|Read|Check|Verify|Update|Modify|Add|Remove|Delete|Install)\s+(the\s+)?/i,``).replace(/\s+/g,` `).trim();return t.length>0&&(t=`${t.charAt(0).toUpperCase()}${t.slice(1)}`),t}function qh(e){let t=[],n=e.match(/\*{0,2}Plan:\*{0,2}\s*\n/i),r=n?e.slice(e.indexOf(n[0])+n[0].length):e;for(let e of r.matchAll(/^\s*(\d+)[.)]\s+\*{0,2}([^*\n]+)/gm)){let n=e[2].trim().replace(/\*{1,2}$/,``).trim();if(n.length>5&&!n.startsWith("`")&&!n.startsWith(`/`)&&!n.startsWith(`-`)){let e=Kh(n);e.length>3&&t.push({step:t.length+1,text:e,completed:!1})}}if(!n&&t.length<2){let t=0,n=Array.from(e.matchAll(/^\s*([A-Z][^:\n]{4,72}):\s+[^\n]+/gm)).flatMap(e=>{let n=Kh(e[1]??``);return n.length<=3?[]:(t+=1,[{step:t,text:n,completed:!1}])});if(n.length>=2)return n;let r=[...new Set(e.split(/\n+/).flatMap(e=>{let t=e.trim();if(t.length<=5||[`#`,`>`,`*`,`-`].includes(t.charAt(0)))return[];let n=Kh(t);return n.length>3?[n]:[]}))].slice(0,12).map((e,t)=>({step:t+1,text:e,completed:!1}));return r.length>=2?r:[]}return t}var Jh=`plan-mode-decision`;function Yh(){return{enabled:!1,executing:!1,todos:[],pendingDecision:!1,pendingDecisionToolCallId:void 0}}function Xh(e,t,n){let r=ig(e);return n===`execute`?(r.enabled=!1,r.executing=r.todos.some(e=>!e.completed),r.pendingDecision=!1,r.pendingDecisionToolCallId=void 0,r):n===`refine`||t===`plan`?(r.enabled=!0,r.executing=!1,r.pendingDecisionToolCallId=void 0,r):(r.enabled=!1,r.executing=!1,r.pendingDecision=!1,r.pendingDecisionToolCallId=void 0,r)}function Zh(e,t){if(!e.enabled)return{state:e,changed:!1};let n=qh(t);return n.length===0?{state:e,changed:!1}:{state:{...ig(e),todos:n,executing:!1,pendingDecision:!0,pendingDecisionToolCallId:void 0},changed:!0}}function Qh(e,t){return{enabled:e.mode===`plan`,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:e.pendingDecision,pendingDecisionToolCallId:e.pendingDecision?`${Jh}-${t}`:void 0}}function $h(e,t){return eg(e,Qh(t,e))}function eg(e,t){if(t.todos.length===0)return;let n=rg(t),r=t.pendingDecision?`awaiting_approval`:n.total>0&&n.completed===n.total?`completed`:`approved`;return{type:`tool-PlanWrite`,toolCallId:t.pendingDecisionToolCallId??`plan-mode-decision-${e}`,state:`output-available`,input:{action:t.pendingDecision?`create`:`update`,pendingDecision:t.pendingDecision,executing:t.executing,completed:n.completed,total:n.total,presentation:n,plan:{id:e,title:n.executing?`Executing plan`:`Execution plan`,summary:ag(t),status:r,todos:n.todos}}}}function tg(e){return!!e?.startsWith(Jh)}function ng(e,t){if(!e.pendingDecision)return e;let n=`${Jh}-${t}`;return e.pendingDecisionToolCallId===n?e:{...ig(e),pendingDecisionToolCallId:n}}function rg(e){let t=e.todos.filter(e=>e.completed).length,n=e.todos.length,r=e.enabled?`plan`:`agent`,i=e.executing?n>0?`Plan progress ${t}/${n}`:`Executing plan`:e.pendingDecision?`Plan ready for review`:e.enabled?`Plan mode`:void 0;return{mode:r,executing:e.executing,pendingDecision:!!e.pendingDecision,completed:t,total:n,todos:e.todos.map(e=>({...e})),message:i}}function ig(e){return{enabled:e.enabled,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:!!e.pendingDecision,pendingDecisionToolCallId:e.pendingDecisionToolCallId}}function ag(e){let t=rg(e),n=t.todos.map(e=>`${e.completed?`- [x]`:`- [ ]`} ${e.step}. ${e.text}`);return e.pendingDecision?n.push(``,`Review the steps, then execute, stay in plan mode, or refine.`):t.executing?n.push(``,`Progress: ${t.completed}/${t.total} completed.`):t.total>0&&t.completed===t.total&&n.push(``,`All plan steps are complete.`),n.join(`
16
- `)}function og(e,t){let n=new Map(t.map(e=>[e.assistantMessageId,e]));return e.map(e=>{if(e.role!==`assistant`)return e;let t=n.get(e.id),r=t?$h(e.id,t.state):void 0;return r?{...e,parts:fh(e.parts,r)}:e})}function sg(e,t){for(let n of e)for(let e of n.parts){if(e.type!==`tool-PlanWrite`||e.toolCallId!==t||!e.input||typeof e.input!=`object`)continue;let r=e.input.presentation;if(!r||typeof r!=`object`)continue;let i=r;if(!(!Array.isArray(i.todos)||i.mode!==`agent`&&i.mode!==`plan`&&i.mode!==`harness`))return{assistantMessageId:n.id,state:{...i,todos:i.todos.map(e=>({...e}))}}}}async function cg(e){e.setSessionMetadataSynced({}),e.setMessagesSynced([]),e.setQueueSynced(Lh),e.setActivityLabelSynced(void 0),e.setPlanLabelSynced(void 0),e.setPresentationSynced({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),e.setError(null),e.setStatus(`ready`);let t=await e.client.createSession(e.projectId);e.setSessionMetadataSynced(t.session),e.setMessagesSynced(t.messages),e.setPresentationSynced(t.presentation),e.setActivityLabelSynced(t.sessionReset?`Started a fresh Pi session`:void 0),await e.refreshSessions()}async function lg(e,t,n,r){if(!t(e))return!1;try{await n()}catch(e){let t=e instanceof Error?e:Error(String(e));r.setError(t),r.setStatus(`error`),Ih(t)}return!0}async function ug(e,t,n){return lg(e,Up,t,n)}async function dg(e,t,n){return lg(e,Wp,t,n)}function fg(){let e,t,n=!1,r=new Promise((n,r)=>{e=n,t=r});return r.catch(()=>void 0),{promise:r,resolve:()=>{n||(n=!0,e())},reject:e=>{n||(n=!0,t(e))}}}var pg=Promise.resolve();function mg({activityLabelRef:e,client:t,messagesRef:n,presentationRef:r,model:i,pendingSendControllerRef:a,projectId:o,planLabelRef:s,queueRef:c,recoverFromForbiddenSession:l,refreshSessions:u,sessionMetadataRef:d,streamControllersRef:f,setActivityLabelSynced:p,setError:m,setMessagesSynced:h,setPresentationSynced:g,setPlanLabelSynced:_,setQueueSynced:v,setSessionMetadataSynced:y,setStatus:b,status:x}){let S=(0,Z.useRef)(null),C=(0,Z.useRef)(new Set),w=(0,Z.useRef)(pg),T=(0,Z.useRef)(void 0),E=(0,Z.useCallback)(e=>{for(let t of C.current)if(t.sessionId===e)return t},[]),D=(0,Z.useCallback)(e=>{for(let t of[...C.current])t.sessionId===e&&(C.current.delete(t),t.reject(Error(`Chat stream stopped before admission`)))},[]),O=(0,Z.useCallback)(e=>{T.current=e},[]),k=(0,Z.useCallback)(async e=>{let[n,r]=await Promise.all([t.loadSession({sessionId:e}),u()]);if(d.current.sessionId!==e)return!1;n.messages.length>0&&h(og(n.messages,n.planPresentations)),g(n.presentation),y(n.session),v({steering:[],followUp:[]}),_(void 0);let i=r.find(t=>t.sessionId===e)?.status===`running`;return i||p(n.sessionReset?`Started a fresh Pi session`:void 0),i},[t,u,d,p,h,_,g,v,y]),A=(0,Z.useCallback)(async e=>{if(e?.aborted)throw Error(`Session creation was aborted`);let n=d.current;if(n.sessionId)return n;let r=S.current;if(r)return r;let i=t.createSession(o,e).then(t=>{if(e?.aborted)throw Error(`Session creation was aborted`);return y(t.session),g(t.presentation),d.current=t.session,u(),t.session}).finally(()=>{S.current===i&&(S.current=null)});return S.current=i,i},[t,o,u,d,g,y]),j=(0,Z.useCallback)((i,a,o,l)=>{if(i.type===`error`)throw Kp(i);if(i.type===`done`&&i.sessionReset){o!==d.current.sessionId&&u();return}let f;if(i.type===`done`&&l===`plan`){let e=Zh(Xh(Yh(),l),bh(i.message)),n=ng(e.state,i.message.id);f=e.changed?eg(i.message.id,n):void 0,f&&t.upsertPlanPresentation({sessionId:o,presentation:{assistantMessageId:i.message.id,state:rg(n)}}).catch(()=>void 0)}if(i.type===`start`){let e=E(o);e&&(C.current.delete(e),e.resolve())}if(o!==d.current.sessionId){i.type===`done`&&u();return}let m=Gh({assistantId:a.current,snapshot:{adapterCapabilities:T.current,activityLabel:e.current,messages:n.current,presentation:r.current,planLabel:s.current,queue:c.current,sessionMetadata:d.current}},i);a.current=m.assistantId,T.current=m.snapshot.adapterCapabilities,h(m.snapshot.messages),m.snapshot.presentation&&g(m.snapshot.presentation),y(m.snapshot.sessionMetadata),v(m.snapshot.queue),p(m.snapshot.activityLabel),_(m.snapshot.planLabel),f&&i.type===`done`&&h(e=>gh(e,i.message.id,f)),i.type===`start`&&b(`streaming`),i.type===`done`&&(b(`ready`),u())},[e,t,E,n,r,s,c,u,d,p,h,g,_,v,y,b]),M=(0,Z.useCallback)(async(e,n=`steer`,r)=>{let a=d.current.sessionId??(await A()).sessionId;if(!a)throw Error(`Unable to queue a message without a session`);let o=ch(e);h(e=>[...e,o]),m(null);let s=w.current,c=fg(),l=s.catch(()=>void 0).then(async()=>{try{await E(a)?.promise,await t.streamMessage({message:e,attachments:r?.attachments,openUI:r?.openUI,openUIArtifact:r?.openUIArtifact,model:i,planAction:r?.planAction,mode:r?.mode,sessionId:a,streamingBehavior:n},e=>{if(e.type===`start`&&e.requestKind===`session-command`&&c.resolve(),e.type===`done`&&e.requestKind===`session-command`){if(d.current.sessionId!==a)return;h(t=>uh(t.some(t=>t.id===e.message.id)?t:[...t,e.message],o.id));return}if(e.type===`queue`&&(c.resolve(),v({steering:e.steering,followUp:e.followUp}),p(n===`steer`?`Steered`:`Follow-up queued`)),e.type===`error`)throw Kp(e)}),c.resolve()}catch(e){throw c.reject(e),h(e=>lh(e,o.id)),e}try{await u()}catch{}});w.current=c.promise.catch(()=>void 0),await l},[t,A,E,i,u,d,p,m,h,v]);return{enqueueDuringStream:M,handleStreamEvent:j,resetStreamAdmission:D,sendMessage:(0,Z.useCallback)(async({text:e,attachments:r,openUI:o,openUIArtifact:s,planAction:c,mode:g,altKey:_})=>{let v=e.trim();if(!v)return;if(x===`submitted`||x===`streaming`||E(d.current.sessionId)!==void 0){try{await M(v,_?`followUp`:`steer`,{attachments:r,mode:g,openUI:o,openUIArtifact:s,planAction:c})}catch(e){let t=e instanceof Error?e:Error(String(e));m(t),Ih(t)}return}m(null),p(void 0),b(`submitted`),n.current.length===0&&(v.length,d.current.sessionId);let y=ch(v);h(e=>[...e,y]);let S={current:null},w=fg();w.sessionId=d.current.sessionId,C.current.add(w);let T=new AbortController;a.current=T;let D,O=!1;try{let e=await A(T.signal);if(T.signal.aborted)return;let a=e.sessionId;if(!a)throw Error(`Unable to start a session stream`);D=a,w.sessionId=a,f.current.set(a,T),await t.streamMessage({message:v,attachments:r,openUI:o,openUIArtifact:s,model:i,planAction:c,mode:g,sessionId:a,streamingBehavior:_?`followUp`:`steer`},e=>{e.type===`done`&&!e.sessionReset&&(O=!0),j(e,S,a,g),e.type===`done`&&e.requestKind===`session-command`&&d.current.sessionId===a&&h(e=>uh(e,y.id))},T.signal);let l=!1;try{l=await k(a)}catch{}d.current.sessionId===a&&(O||!l)&&b(`ready`),n.current.length}catch(e){if(C.current.delete(w)&&w.reject(e),h(e=>lh(e,y.id)),T.signal.aborted)return;if(D&&d.current.sessionId!==D){u();return}let t={setError:m,setStatus:b};if(await ug(e,l,t)||await dg(e,l,t))return;let n=e instanceof Error?e:Error(String(e));m(n),b(`error`),Ih(n)}finally{C.current.delete(w)&&w.reject(Error(`Chat stream ended before admission`)),T.signal.aborted&&h(e=>lh(e,y.id)),a.current===T&&(a.current=null),D&&T&&f.current.get(D)===T&&f.current.delete(D)}},[t,A,M,E,j,k,n,i,a,u,l,d,p,m,h,b,f,x]),setAdapterCapabilities:O}}function hg(e,t){if(!e||typeof e!=`object`)return;let n=e.presentation;if(!n||typeof n!=`object`)return n;let r=t.selectedIds?.[0],i=n,a=(Array.isArray(i.todos)?i.todos:[]).some(e=>!!(e&&typeof e==`object`&&!e.completed));return{...i,pendingDecision:!1,mode:r===`execute`?`agent`:`plan`,executing:r===`execute`&&a}}function gg(e,t,n){if(!tg(t))return e;let r=e.map(e=>{let r=e.parts.map(e=>e.type!==`tool-PlanWrite`||e.toolCallId!==t||!e.input||typeof e.input!=`object`?e:{...e,input:{...e.input,approved:n.selectedIds?.[0]===`execute`||n.selectedIds?.[0]===`stay`,pendingDecision:!1,executing:n.selectedIds?.[0]===`execute`,presentation:hg(e.input,n)}});return r.some((t,n)=>t!==e.parts[n])?{...e,parts:r}:e});return r.some((t,n)=>t!==e[n])?r:e}function _g(e,t){let n=e.map(e=>{let n=e.parts.map(e=>{if(e.type!==`tool-PlanWrite`||typeof e.toolCallId!=`string`||!e.input||typeof e.input!=`object`)return e;let n=e.input;return n.pendingDecision!==!0||typeof n.onExecute==`function`&&typeof n.onStay==`function`&&typeof n.onRefine==`function`?e:{...e,input:{...n,onExecute:()=>t({toolCallId:e.toolCallId,answer:{kind:`single`,selectedIds:[`execute`]}}),onStay:()=>t({toolCallId:e.toolCallId,answer:{kind:`single`,selectedIds:[`stay`]}}),onRefine:n=>t({toolCallId:e.toolCallId,answer:n&&n.trim().length>0?{kind:`text`,text:n.trim()}:{kind:`single`,selectedIds:[`refine`]}})}}});return n.some((t,n)=>t!==e.parts[n])?{...e,parts:n}:e});return n.some((t,n)=>t!==e[n])?n:e}function vg(e,t){let{client:n=tm,initialSessionMetadata:r,persistSession:i,projectId:a}=t,[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(`ready`),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(()=>r),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(),[v,y]=(0,Z.useState)(),[b,x]=(0,Z.useState)(Lh),[S,C]=(0,Z.useState)(()=>({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),w=(0,Z.useRef)(r),T=(0,Z.useRef)(o),E=(0,Z.useRef)(f),D=(0,Z.useRef)(g),O=(0,Z.useRef)(v),k=(0,Z.useRef)(b),A=(0,Z.useRef)(0),j=(0,Z.useRef)(Promise.resolve()),M=(0,Z.useRef)(S),N=(0,Z.useRef)(null),P=(0,Z.useRef)(new Map),F=(0,Z.useRef)(c),I=(0,Z.useRef)(!1),L=(0,Z.useRef)(()=>Promise.resolve()),R=(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(T.current):e;T.current=t,s(t)},[]),z=(0,Z.useCallback)(e=>{R(t=>[...t,{id:crypto.randomUUID(),role:`assistant`,source:`local`,createdAt:Date.now(),parts:[{type:`text`,text:e}]}])},[R]),B=(0,Z.useCallback)(e=>{let t=E.current,n=Rh(e);(t.sessionId!==n.sessionId||t.projectId!==n.projectId)&&(A.current+=1,E.current=n,p(n),i(n))},[i]),V=(0,Z.useCallback)(e=>{D.current=e,_(e)},[]),H=(0,Z.useCallback)(e=>{O.current=e,y(e)},[]),U=(0,Z.useCallback)(e=>{A.current+=1,k.current=e,x(e)},[]),ee=(0,Z.useCallback)(()=>{A.current+=1},[]),W=(0,Z.useCallback)(e=>{M.current=e,C(e)},[]),te=(0,Z.useCallback)(async e=>{let t=E.current.sessionId;if(!t)return;let r=await n.upsertOpenUIArtifact({sessionId:t,...e});return E.current.sessionId===t&&W(r.presentation),r.artifact.id},[n,W]),ne=(0,Z.useCallback)(async()=>{let e=await n.listSessions();return h(e),e},[n]),re=(0,Z.useCallback)(e=>cg({client:n,projectId:e??a,refreshSessions:ne,setActivityLabelSynced:V,setError:d,setMessagesSynced:R,setPlanLabelSynced:H,setPresentationSynced:W,setQueueSynced:U,setSessionMetadataSynced:B,setStatus:l}),[n,a,ne,V,R,H,W,U,B]),ie=(0,Z.useCallback)(async({toolCallId:e,answer:t})=>{if(tg(e)){let r=gg(T.current,e,t);R(r);let i=sg(r,e);i&&E.current.sessionId&&await n.upsertPlanPresentation({sessionId:E.current.sessionId,presentation:i}).catch(()=>void 0);let a=t.selectedIds?.[0];if(a===`execute`){await L.current({text:`Execute the approved plan.`,mode:`agent`,planAction:`execute`,openUI:!0});let t=sg(T.current,e);t&&E.current.sessionId&&await n.upsertPlanPresentation({sessionId:E.current.sessionId,presentation:{...t,state:{...t.state,executing:!1}}}).catch(()=>void 0),t&&R(t=>t.map(t=>t.role===`assistant`?{...t,parts:t.parts.map(t=>{if(t.type!==`tool-PlanWrite`||t.toolCallId!==e||!t.input||typeof t.input!=`object`)return t;let n=t.input,r=n.presentation;return!r||typeof r!=`object`?t:{...t,input:{...n,executing:!1,presentation:{...r,executing:!1}}}})}:t))}else(a===`refine`||t.text?.trim())&&await L.current({text:t.text?.trim()||`Refine the plan.`,mode:`plan`,planAction:`refine`,openUI:!0});return{ok:!0}}let r=await n.answerQuestion({sessionId:E.current.sessionId,toolCallId:e,answer:t});return r.message&&await L.current({text:r.message,planAction:r.planAction}),r},[n,R]),ae=(0,Z.useCallback)(e=>_g(e,ie),[ie]);(0,Z.useEffect)(()=>{E.current=f},[f]),(0,Z.useEffect)(()=>{F.current=c},[c]),(0,Z.useEffect)(()=>{w.current=r},[r]),(0,Z.useEffect)(()=>{let e=P.current;return()=>{N.current?.abort(),N.current=null;for(let t of e.values())t.abort();e.clear()}},[]),(0,Z.useEffect)(()=>{let e=!1;return ne().catch(t=>{if(e)return;let n=t instanceof Error?t:Error(String(t));d(n),Ih(n)}),()=>{e=!0}},[ne]),(0,Z.useEffect)(()=>{if(I.current)return;I.current=!0;let e=new AbortController;l(`ready`),d(null),U(Lh),V(void 0),H(void 0),R([]);let t=w.current;return ne().then(r=>{if(e.signal.aborted)return;let i=t.sessionId?r.find(e=>e.sessionId===t.sessionId):void 0,a=i??(t.projectId?r.find(e=>e.projectId===t.projectId):r[0]);if(!a){B(t.projectId?{projectId:t.projectId}:{});return}let o=i?t:{sessionId:a.sessionId,projectId:a.projectId};return n.loadSession(o)}).then(t=>{!t||e.signal.aborted||(B(t.session),R(og(t.messages,t.planPresentations)),W(t.presentation),V(t.sessionReset?`Started a fresh Pi session`:void 0))}).catch(async t=>{if(e.signal.aborted)return;let n={setError:d,setStatus:l};if(await ug(t,re,n)||await dg(t,re,n)||e.signal.aborted)return;let r=t instanceof Error?t:Error(String(t));d(r),l(`error`),Ih(r)}),()=>{e.abort()}},[n,V,R,H,W,U,B,ne,re]);let{resetStreamAdmission:oe,sendMessage:se,setAdapterCapabilities:ce}=mg({activityLabelRef:D,client:n,messagesRef:T,presentationRef:M,model:e,pendingSendControllerRef:N,projectId:a,planLabelRef:O,queueRef:k,recoverFromForbiddenSession:re,refreshSessions:ne,sessionMetadataRef:E,setActivityLabelSynced:V,setError:d,setMessagesSynced:R,setPresentationSynced:W,setPlanLabelSynced:H,setQueueSynced:U,setSessionMetadataSynced:B,setStatus:l,streamControllersRef:P,status:c}),le=(0,Z.useCallback)(()=>{let e=E.current;oe(e.sessionId),N.current?.abort(),N.current=null,e.sessionId&&n.abortSession(e).catch(()=>void 0),e.sessionId&&(P.current.get(e.sessionId)?.abort(),P.current.delete(e.sessionId)),ee(),l(`ready`),U(Lh),V(void 0)},[n,ee,oe,V,U]),ue=(0,Z.useCallback)((e,t,r)=>{let i=E.current.sessionId,a=A.current,o=(e===`steering`?k.current.steering:k.current.followUp).filter(e=>e===r).length,s=j.current.catch(()=>void 0).then(async()=>{if(!i||E.current.sessionId!==i)return!1;let s=k.current,c=e===`steering`?s.steering:s.followUp,l;if(A.current===a)l=c[t]===r?t:void 0;else{if(o!==1)return!1;let e=c.reduce((e,t,n)=>(t===r&&e.push(n),e),[]);l=e.length===1?e[0]:void 0}if(l===void 0)return!1;let u={...s,[e]:c.filter((e,t)=>t!==l)};U(u);let d=A.current;try{let t=await n.deleteQueuedMessage({sessionId:i,lane:e,index:l,expectedText:r});return E.current.sessionId!==i||A.current!==d||U(t.queue),t.status===`applied`}catch(e){throw E.current.sessionId===i&&A.current===d&&k.current===u&&U(s),e}});return j.current=s.then(()=>void 0,()=>void 0),s},[n,U]),de=(0,Z.useCallback)(async e=>{e?.preserveRunning===!1?le():(ee(),l(`ready`));let t=await n.createSession(e?.projectId??a);B(t.session),R([]),W(t.presentation),U(Lh),V(void 0),H(void 0),vi.success(`New session started`),await ne()},[n,ne,V,R,W,H,U,B,ee,le,a]),fe=(0,Z.useCallback)(async(e,t)=>{ee();try{t?.preserveRunning===!1&&le();let r=await n.resumeSession(e);return B(r.session),R(og(r.messages,r.planPresentations)),W(r.presentation),U(Lh),V(r.sessionReset?`Started a fresh Pi session`:void 0),H(void 0),l(P.current.has(r.session.sessionId??``)?`streaming`:`ready`),await ne(),!0}catch(t){let n={setError:d,setStatus:l},r=()=>re(e.projectId);if(await ug(t,r,n)||await dg(t,r,n))return!1;let i=t instanceof Error?t:Error(String(t));return d(i),l(`error`),Ih(i),!1}},[n,re,ne,V,R,W,H,U,B,ee,le]),pe=(0,Z.useCallback)(async(e,t)=>t?fe({sessionId:t,projectId:e},{preserveRunning:!0}):(ee(),B({projectId:e}),R([]),W({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),U(Lh),V(void 0),H(void 0),l(`ready`),!0),[fe,V,R,H,W,U,B,ee]);(0,Z.useEffect)(()=>{L.current=se},[se]),(0,Z.useEffect)(()=>{let e=f.sessionId;if(!e||typeof window>`u`)return;let t=`pi:sse:last-event-id:${e}`,r={current:void 0},i=Number.parseInt(window.sessionStorage.getItem(t)??`0`,10);Number.isNaN(i)&&(i=0);let a=null,o=null,s=!1,c=t=>{let i;try{i=JSON.parse(t.data)}catch{return}if(i.type===`presentation`){i.presentation.revision>(M.current?.revision??-1)&&W(i.presentation);return}let a=F.current;if(a===`streaming`||a===`submitted`)return;let o=i;if(o.type===`connected`){let e=o.adapterCapabilities;r.current=e,ce(e);return}if(i.type===`reasoning`){let e=r.current,t=i.messageId;if(!e?.features.includes(`reasoning-summary-v1`)||!t)return;R(e=>vh(e,t,i.presentation));return}if(i.type===`tool`&&i.part?.type===`tool-Question`){R(e=>{let t=i.part.toolCallId??``;if(e.findIndex(e=>e.parts.some(e=>e.type!==`text`&&e.type!==`error`&&`toolCallId`in e&&e.toolCallId===t))!==-1)return e;let n={...i.part,type:`tool-Question`};return[...e,{id:crypto.randomUUID(),role:`assistant`,parts:[n],createdAt:new Date().toISOString()}]});return}if(i.type===`state`){if(V(typeof i.state?.message==`string`?i.state.message:void 0),i.state?.name===`agent_settled`){let t=e;n.loadSession({sessionId:t}).then(e=>{E.current.sessionId===t&&(R(og(e.messages,e.planPresentations)),W(e.presentation),B(e.session),U(Lh))}).catch(()=>void 0)}return}if(i.type===`queue`){U({steering:i.steering,followUp:i.followUp});return}},l=()=>{let n=new URLSearchParams({sessionId:e});i>0&&n.set(`lastEventId`,String(i));let r=Xf(`/api/chat/events?${n}`);a?.close(),a=new EventSource(r),a.onmessage=e=>{let n=Number.parseInt(e.lastEventId??``,10);!Number.isNaN(n)&&n>0&&(i=n,window.sessionStorage.setItem(t,String(n))),c(e)},a.onerror=()=>{a?.close(),!s&&(o&&clearTimeout(o),o=setTimeout(l,2e3))}};return l(),()=>{s=!0,a?.close(),o&&clearTimeout(o)}},[n,f.sessionId,V,R,U,W,B,ce]);let me=(0,Z.useMemo)(()=>ae(o),[o,ae]),he=(0,Z.useCallback)(async(e,t)=>{await n.renameSession(e,t),await ne()},[n,ne]),ge=(0,Z.useCallback)(async e=>{let t=E.current.sessionId===e;t&&le(),await n.deleteSession(e),t&&(B({}),R([]),W({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),await ne()},[n,ne,R,W,B,le]),_e=ie,ve=(0,Z.useCallback)(()=>E.current,[]);return{activityLabel:g,answerQuestion:_e,appendLocalMessage:z,deleteQueuedMessage:ue,deleteSession:ge,error:u,getMessages:(0,Z.useCallback)(()=>T.current,[]),getSessionMetadata:ve,messages:me,planLabel:v,presentation:S,persistOpenUIArtifact:te,queue:b,renameSession:he,refreshSessions:ne,resumeSession:fe,sendMessage:se,sessionMetadata:f,sessions:m,setError:d,startNewSession:de,status:c,stop:le,switchProject:pe}}function yg({activityLabel:e,artifactRuns:t,chatMode:n,handleThemePreferenceChange:r,isLoadingProviders:i,isUpdatingProvider:a,loadSession:o,loadSubagentSession:s,loadWorkspaceFile:c,messages:l,modelKey:u,models:d,modelCatalog:f,onDiscoverModels:p,onOAuthLogin:m,onRemoveProvider:h,onUpdateProvider:g,openWorkspacePath:_,planLabel:v,presentation:y,providers:b,queue:x,refreshResources:S,refreshWorkspace:C,resources:w,resourcesError:T,resourcesLoading:E,rightPanel:D,reopenRightPanel:O,saveSettings:k,selectedArtifactId:A,sessionId:j,selectedWorkspacePath:M,setRightPanel:N,setSelectedWorkspacePath:P,settings:F,settingsError:I,settingsLoading:L,status:R,thinkingLevel:z,themePreference:B,workspaceError:V,workspaceLoading:H,workspaceTree:U}){let ee=(0,Z.useMemo)(()=>({activityLabel:e,artifactRuns:t,chatMode:n,loadSession:o,loadSubagentSession:s,messages:l,models:d,planLabel:v,presentation:y,queue:x,refreshResources:S,resources:w,resourcesError:T,resourcesLoading:E,reopenRightPanel:O,rightPanel:D,selectedModelKey:u,selectedArtifactId:A,sessionId:j,setRightPanel:N,status:R,thinkingLevel:z}),[e,t,n,o,s,l,d,v,y,x,S,w,T,E,O,D,u,A,j,N,R,z]),W=(0,Z.useMemo)(()=>({loadWorkspaceFile:c,openWorkspacePath:_,refreshWorkspace:C,selectedWorkspacePath:M,setSelectedWorkspacePath:P,workspaceError:V,workspaceLoading:H,workspaceTree:U}),[c,_,C,M,P,V,H,U]);return{chatPanelData:ee,settingsActions:(0,Z.useMemo)(()=>({isLoadingProviders:i,isUpdatingProvider:a,modelCatalog:f,onDiscoverModels:p,onOAuthLogin:m,onRemoveProvider:h,onThemePreferenceChange:r,onUpdateProvider:g,providers:b,saveSettings:k,settings:F,settingsError:I,settingsLoading:L,themePreference:B}),[r,i,a,f,p,m,h,g,b,k,F,I,L,B]),workspaceTreeContext:W}}var bg=`workspace:`;function xg(e,t=[]){for(let n of e)t.push(n),n.children&&xg(n.children,t);return t}function Sg(e){return e?xg(e.nodes).map(e=>({id:`${bg}${e.path}`,label:e.path,description:e.type===`directory`?`Folder`:`Workspace file`,keywords:[e.name,e.path],metadata:{kind:e.type===`directory`?`folder`:`file`}})):[]}function Cg(e){if(!e.id.startsWith(bg))return null;let t=e.id.slice(10);if(!t)return null;let n=Ui.safeParse(t);return n.success?n.data:null}async function wg(e,t){return tm.getWorkspaceFile(e,t)}function Tg(e,t){return e.sessionId!==t.sessionId||e.projectId!==t.projectId}function Eg(e,t){return!!e.sessionId||t!==void 0&&t!==e.projectId}function Dg(e,t){let{defaultProvider:n,defaultModel:r}=t.effective;return e.find(e=>e.provider===n&&e.modelId===r)?.id??(n&&r?`${n}/${r}`:void 0)}function Og(){let e=lp(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(void 0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`agent`),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(null),_=Vm(),[v,y]=(0,Z.useState)(_.sessionMetadata.projectId??void 0);(0,Z.useEffect)(()=>{},[e]);let{data:b,isLoading:x}=fm(),{data:S,refetch:C}=im(),{mutateAsync:w,isPending:T}=pm(),{mutateAsync:E}=mm(),{mutateAsync:D,isPending:O}=hm(),{data:k}=rm(v),{data:A}=am({enabled:t,projectId:v}),j=om(),{commandPaletteOpen:M,handleResourceCanvasResizeStart:N,handleThemePreferenceChange:P,initialSessionMetadata:F,modelKey:I,modelSelection:L,models:R,openArtifact:z,openWorkspacePath:B,openPanelAction:V,persistSession:H,reopenRightPanel:U,resourceCanvasWidth:ee,rightPanel:W,selectedArtifactId:te,selectedWorkspacePath:ne,setCommandPaletteOpen:re,setModelKey:ie,setRightPanel:ae,setSelectedWorkspacePath:oe,setThinkingLevel:se,themePreference:ce,thinkingLevel:le}=zm(k,_);(0,Z.useEffect)(()=>{if(F.projectId&&F.projectId!==v){y(F.projectId);return}!v&&S?.projects[0]&&(y(S.projects[0].projectId),H({projectId:S.projects[0].projectId}))},[v,F.projectId,H,S?.projects]);let{data:ue,isLoading:de,error:fe,refetch:pe}=sm(v),{data:me}=cm(v),{data:he,isLoading:ge,error:_e}=lm(v),ve=um(),{data:ye,isLoading:be,error:xe,refetch:Se}=dm(v,{enabled:!0}),Ce=ue??null,we=ye??null,Te=(0,Z.useCallback)(()=>{pe()},[pe]),Ee=(0,Z.useCallback)(async e=>{let t=await ve.mutateAsync({request:{settings:e},projectId:v}),n=Dg(R,t);return n&&ie(n),t},[v,R,ie,ve]),De=(0,Z.useCallback)(()=>{Se()},[Se]),{activityLabel:Oe,answerQuestion:ke,appendLocalMessage:Ae,deleteQueuedMessage:je,deleteSession:Me,error:Ne,getMessages:Pe,getSessionMetadata:Fe,messages:G,planLabel:Ie,persistOpenUIArtifact:Le,presentation:Re,queue:ze,renameSession:Be,resumeSession:Ve,sendMessage:He,sessionMetadata:K,sessions:Ue,startNewSession:We,switchProject:Ge,status:Ke,stop:qe}=vg(L,{initialSessionMetadata:F,projectId:v,persistSession:H}),Je=(0,Z.useMemo)(()=>aa(G,Re,Ke),[G,Re,Ke]),Ye=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{if(!Re.thinkingLevel)return;let e=`${K.sessionId}:${Re.thinkingLevel}`;Ye.current!==e&&(Ye.current=e,se(Re.thinkingLevel))},[Re.thinkingLevel,K.sessionId,se]);let Xe=(0,Z.useCallback)(()=>{f([]),m([])},[]),Ze=(0,Z.useCallback)(async e=>{let t=Fe(),n=e?.projectId??v,r=Eg({...t,projectId:t.projectId??v},n);await We(e),r&&Xe()},[v,Xe,Fe,We]),Qe=(0,Z.useCallback)(async(e,t)=>{let n=e.projectId===void 0&&v?{...e,projectId:v}:e,r=Tg(Fe(),n),i=await Ve(n,t);return i&&r&&Xe(),i},[v,Xe,Fe,Ve]),$e=(0,Z.useCallback)(async(e,t)=>{await Qe(e,t)},[Qe]),et=(0,Z.useCallback)(async e=>{let t=Ue.filter(t=>t.projectId===e).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))[0],n=Tg(Fe(),{sessionId:t?.sessionId,projectId:e});y(e),oe(null),await Ge(e,t?.sessionId)&&n&&Xe(),await C()},[Xe,Fe,C,oe,Ue,Ge]),tt=(0,Z.useCallback)(async e=>{y(e),oe(null),await Ze({projectId:e}),await C()},[C,oe,Ze]),nt=(0,Z.useCallback)(async e=>{let t=Fe().sessionId===e;await Me(e),t&&Xe()},[Xe,Me,Fe]),rt=(0,Z.useCallback)(async e=>{let t=await tm.createProject(e);await C(),await et(t.projectId)},[C,et]),it=(0,Z.useCallback)(async(e,t)=>{await tm.renameProject(e,t),await C()},[C]),at=(0,Z.useCallback)(async e=>{await tm.unregisterProject(e);let t=await C();if(v===e){let n=t.data?.projects.find(t=>t.projectId!==e);n?await et(n.projectId):(y(void 0),oe(null),await Ge(``,void 0)&&Xe())}},[v,Xe,C,et,oe,Ge]),ot=(0,Z.useCallback)(e=>tm.browseProjectDirectories(e),[]),st=(0,Z.useCallback)(async(e,t)=>{await tm.forkSessionIntoProject(e,t),await C()},[C]);(0,Z.useEffect)(()=>{K.sessionId&&C()},[C,K.sessionId]),K.sessionId;let ct=Zr(ze)??Oe??Ie,lt=(0,Z.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`image/*,text/*,application/json,application/pdf`,e.onchange=()=>{(async()=>{let t=Array.from(e.files??[]);if(t.length===0)return;Fe().sessionId||await Ze();let n=Fe().sessionId;if(!n)throw Error(`Unable to create a session for attachments`);let r=await tm.uploadAttachments(n,t);f(e=>[...e,...r])})().catch(e=>{Ih(e)})},e.click()},[Fe,Ze]),ut=(0,Z.useCallback)(e=>{f(t=>t.filter(t=>t.attachmentId!==e))},[]),dt=(0,Z.useCallback)(()=>f([]),[]),ft=(0,Z.useCallback)(()=>m([]),[]),pt=(0,Z.useCallback)(e=>{let t=Cg(e);t&&m(e=>e.some(e=>e.relativePath===t)?e:[...e,{kind:`workspace`,relativePath:t,name:t.split(`/`).pop()||t}])},[]),mt=(0,Z.useCallback)(e=>{m(t=>t.filter(t=>t.relativePath!==e))},[]),ht=(0,Z.useCallback)(({toolCallId:e,answer:t})=>{ke({toolCallId:e,answer:t}).catch(e=>{Ih(e)})},[ke]),gt=Mh({messages:G,answerQuestion:ht}),_t=qm({activeSessionId:K.sessionId,messages:G,presentation:Re,sessions:Ue}),vt=Jm({messages:G,resources:Ce,workspaceTree:we}),yt=(0,Z.useMemo)(()=>{if(G.length===0||Ke===`streaming`||Ke===`submitted`)return!1;let e=G[G.length-1];return e.role===`assistant`&&!_m(e)},[G,Ke]),bt=(0,Z.useMemo)(()=>yt?vt:[],[yt,vt]),xt=(0,Z.useMemo)(()=>Dm(Ce,he?.effective.enableSkillCommands??!1,me),[me,Ce,he]),St=(0,Z.useMemo)(()=>Sg(we),[we]),Ct=(0,Z.useCallback)(e=>{if(e.projectId&&e.projectId!==v){vi.error(`This panel action targets a different project.`);return}V(e)},[v,V]),wt=(0,Z.useCallback)(e=>{if(!e.projectId||e.projectId===v){V(e);return}et(e.projectId).then(()=>V(e)).catch(e=>Ih(e))},[v,V,et]),Tt=(0,Z.useCallback)(e=>{i(e),n(!0)},[]),{forkFromEntry:Et,handleLocalSlashSubmit:Dt,handleSlashCommandSelect:Ot}=jh({appendLocalMessage:Ae,getMessages:Pe,getSessionMetadata:Fe,modelKey:I,models:R,onForkPicker:g,onOpenUIRequest:(0,Z.useCallback)(e=>{let t=[...p,...d];return dt(),ft(),He({text:e,altKey:!1,mode:l,openUI:!0,openUIArtifact:!0,attachments:t})},[l,dt,ft,He,d,p]),openSettings:Tt,resumeSession:$e,sessions:Ue,setEffortPickerOpen:c,setModelKey:ie,setModelPickerOpen:o,setThinkingLevel:se,startNewSession:Ze}),kt=(0,Z.useMemo)(()=>A?.models.map(ci)??R,[A,R]),At=(0,Z.useCallback)(e=>wg(e,v),[v]),jt=(0,Z.useCallback)(e=>tm.loadSession(e),[]),Mt=(0,Z.useCallback)((e,t)=>tm.loadSubagentSession(e,t),[]),Nt=(0,Z.useCallback)(async e=>(await j.mutateAsync(e)).models.map(ci),[j]),{chatPanelData:Pt,settingsActions:Ft,workspaceTreeContext:It}=yg({activityLabel:Oe,artifactRuns:Je,chatMode:l,handleThemePreferenceChange:P,isLoadingProviders:x,isUpdatingProvider:T||O,loadSession:jt,loadSubagentSession:Mt,loadWorkspaceFile:At,messages:G,modelKey:I,models:R,modelCatalog:kt,onDiscoverModels:Nt,onOAuthLogin:E,onRemoveProvider:D,onUpdateProvider:w,openWorkspacePath:B,planLabel:Ie,presentation:Re,providers:b?.providers??[],queue:ze,refreshResources:Te,refreshWorkspace:De,resources:Ce,resourcesError:fe,resourcesLoading:de,reopenRightPanel:U,rightPanel:W,saveSettings:Ee,selectedArtifactId:te,sessionId:K.sessionId,selectedWorkspacePath:ne,setRightPanel:ae,setSelectedWorkspacePath:oe,settings:he??null,settingsError:_e,settingsLoading:ge||ve.isPending,status:Ke,thinkingLevel:le,themePreference:ce,workspaceError:xe,workspaceLoading:be,workspaceTree:we}),Lt=oh({activeSessionId:K.sessionId,activeSessionLabel:_t,sessions:Ue,onNewSession:()=>void Ze(),onResumeSession:e=>void $e(e),onOpenSettings:()=>Tt()});return{session:{activeSessionId:K.sessionId,activeProjectId:v,openPanelAction:wt,projects:S?.projects??[],projectSessions:Ue,sessions:Ue,browseProjectDirectories:ot,createProject:rt,deleteSession:nt,forkSessionIntoProject:st,renameProject:it,renameSession:Be,resumeSession:$e,selectProject:et,startNewSession:Ze,startNewSessionInProject:tt,unregisterProject:at},conversation:{activityLabel:Oe,artifactRuns:Je,deleteQueuedMessage:je,error:Ne,messages:G,openArtifact:z,openPanelAction:Ct,persistOpenUIArtifact:Le,presentation:Re,queue:ze,sendMessage:He,status:Ke,stop:qe},composer:{answerQuestion:ke,chatMode:l,clearUploadedAttachments:dt,clearWorkspaceAttachments:ft,effortPickerOpen:s,handleAttach:lt,handleLocalSlashSubmit:Dt,handleQuestionAnswer:ht,handleSlashCommandSelect:Ot,infoDescription:ct,inputSuggestionItems:bt,workspaceReferenceSuggestions:St,modelKey:I,modelPickerOpen:a,models:R,pendingQuestionBar:gt,removeUploadedAttachment:ut,removeWorkspaceAttachment:mt,addWorkspaceAttachment:pt,setChatMode:u,setEffortPickerOpen:c,setModelKey:ie,setModelPickerOpen:o,setThinkingLevel:se,slashCommands:xt,thinkingLevel:le,uploadedAttachments:d,workspaceAttachments:p},panels:{chatPanelData:Pt,handleResourceCanvasResizeStart:N,resourceCanvasWidth:ee,rightPanel:W,setRightPanel:ae,settingsActions:Ft,workspaceTreeContext:It},dialogs:{commandPaletteOpen:M,forkFromEntry:Et,forkPickerEntries:h,setCommandPaletteOpen:re,setForkPickerEntries:g,setSettingsDialogOpen:n,setSettingsInitialTab:i,settingsDialogOpen:t,settingsInitialTab:r},chrome:{handleThemePreferenceChange:P,header:Lt,themePreference:ce}}}function kg(){let{session:e,conversation:t,composer:n,panels:r,dialogs:i,chrome:a}=Og(),o=(0,Z.useCallback)(()=>{i.setCommandPaletteOpen(e=>!e)},[i.setCommandPaletteOpen]),s=(0,Z.useCallback)(()=>{r.setRightPanel(null),window.requestAnimationFrame(()=>sp())},[r.setRightPanel]);cp({onCommandPaletteToggle:o,onClosePanel:s,rightPanel:r.rightPanel,setRightPanel:r.setRightPanel});let c=e.projects.find(t=>t.projectId===e.activeProjectId)?.name,l=(0,Z.useCallback)((e,r)=>{let i=[...n.workspaceAttachments,...n.uploadedAttachments];n.clearUploadedAttachments(),n.clearWorkspaceAttachments(),(async()=>{await t.sendMessage({text:e,altKey:r,mode:n.chatMode,openUI:!0,attachments:i})})()},[n.chatMode,n.clearUploadedAttachments,n.clearWorkspaceAttachments,n.uploadedAttachments,n.workspaceAttachments,t.sendMessage]),u=(0,Z.useCallback)(e=>{let r=na(e);if(r){t.openPanelAction(r);return}t.sendMessage({text:e,altKey:!1,mode:n.chatMode,openUI:!0})},[n.chatMode,t.openPanelAction,t.sendMessage]),d=(0,Z.useCallback)(async e=>{try{return await t.persistOpenUIArtifact(e)}catch(e){vi.error(`Artifact persistence failed: ${e instanceof Error?e.message:String(e)}`);return}},[t.persistOpenUIArtifact]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(tp,{chrome:a,conversation:t,dialogs:i,panels:r,session:e}),(0,Q.jsxs)(pi,{chatPanelData:r.chatPanelData,onOpenUIAction:u,settingsActions:r.settingsActions,workspaceTree:r.workspaceTreeContext,children:[(0,Q.jsxs)(xc,{className:`h-svh min-h-0 rounded-none border-0`,sidebarWidth:`17.5rem`,children:[(0,Q.jsx)(ku,{data:{sessions:e.sessions,projects:e.projects,projectSessions:e.projectSessions,activeProjectId:e.activeProjectId,activeSessionId:e.activeSessionId},sessionActions:{onNewSession:()=>void e.startNewSession(),onNewSessionInProject:e.startNewSessionInProject,onResumeSession:t=>void e.resumeSession({sessionId:t.sessionId}),onRenameSession:(t,n)=>void e.renameSession(t,n),onDeleteSession:t=>void e.deleteSession(t)},projectActions:{onProjectSelect:e.selectProject,onCreateProject:e.createProject,onRenameProject:e.renameProject,onUnregisterProject:e.unregisterProject,onForkSessionIntoProject:e.forkSessionIntoProject},navigationActions:{onOpenPanelAction:e.openPanelAction,onBrowseDirectories:e.browseProjectDirectories,onOpenSettings:()=>i.setSettingsDialogOpen(!0)},slots:{accountMenu:a.header.accountMenu}}),(0,Q.jsx)(mc,{className:`h-svh min-h-0 overflow-hidden`,children:(0,Q.jsx)(Ws,{headerLeft:a.header.left,headerCenter:a.header.center,headerRight:a.header.right,panel:(0,Q.jsx)(Yi,{children:(0,Q.jsx)(Hs,{handleResourceCanvasResizeStart:r.handleResourceCanvasResizeStart,onClose:s,resourceCanvasWidth:r.resourceCanvasWidth})}),children:(0,Q.jsx)(Kf,{messages:t.messages,status:t.status,error:t.error??void 0,workspaceName:c,activityLabel:t.activityLabel,presentation:t.presentation,artifactRuns:t.artifactRuns,queue:t.queue,onDeleteQueuedMessage:t.deleteQueuedMessage,onOpenArtifact:t.openArtifact,onOpenUIArtifactReady:d,inputSuggestionItems:n.inputSuggestionItems,suppressQuestionTool:!!n.pendingQuestionBar,inputBar:Zf(n,e.activeSessionId),onSend:l,onOpenUIAction:u,onStop:t.stop,onQuestionAnswer:n.handleQuestionAnswer})})})]}),(0,Q.jsx)(np,{dialogs:i})]})]})}var Ag=kg;export{Ag as component};