@qredence/fleet 0.1.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +8 -1
- package/dist/web/client/assets/artifacts-panel-CX62LQ13.js +1 -0
- package/dist/web/client/assets/artifacts-utils-N_kUFbz2.js +1 -0
- package/dist/web/client/assets/bot-Bs7QWJ2q.js +1 -0
- package/dist/web/client/assets/{chat-C64Sv6V-.js → chat-CsepBQwy.js} +5 -5
- package/dist/web/client/assets/{chat-command-palette-HpsmKfLO.js → chat-command-palette-C4sSf8Kg.js} +1 -1
- package/dist/web/client/assets/collapsible-DmyYcezk.js +1 -0
- package/dist/web/client/assets/command-CB6emP8m.js +2 -0
- package/dist/web/client/assets/conversation-turns-ByFoWPXe.js +6 -0
- package/dist/web/client/assets/ease-vFBiNFNK.js +9 -0
- package/dist/web/client/assets/{fleet-pi-tool-renderer-ZKiX6Ob_.js → fleet-pi-tool-renderer-BD_ZAjlG.js} +28 -30
- package/dist/web/client/assets/globals-CqqQdk2S.css +2 -0
- package/dist/web/client/assets/horizontal-resize-C1TpRLNC.js +1 -0
- package/dist/web/client/assets/index-DweoFRMs.js +12 -0
- package/dist/web/client/assets/{input-Clyn18XG.js → input-CqC82Agz.js} +1 -1
- package/dist/web/client/assets/{input-group-MxDAWX3j.js → input-group-H0TG-mkU.js} +1 -1
- package/dist/web/client/assets/ipython-tool-BfeIa0nK.js +3 -0
- package/dist/web/client/assets/markdown-DG7pUdsX.js +2 -0
- package/dist/web/client/assets/{markdown-code-pIaEVDUU.js → markdown-code-BgMzpy7O.js} +1 -1
- package/dist/web/client/assets/notify-Duj26eeZ.js +1 -0
- package/dist/web/client/assets/{openui-renderer-NLUpAS3h.js → openui-renderer-DlUo6ehT.js} +5 -5
- package/dist/web/client/assets/openui-utils-DawGoQNp.js +1 -0
- package/dist/web/client/assets/prime-agent-artifacts-CHGb5V_j.js +5 -0
- package/dist/web/client/assets/{provider-catalog-Gx9qaHBM.js → provider-catalog-BZhZuKSz.js} +1 -1
- package/dist/web/client/assets/provider-label-jKm8v18u.js +1 -0
- package/dist/web/client/assets/range-vSJ7Ux_5.js +2 -0
- package/dist/web/client/assets/repl-panel-DiGS6uCw.js +1 -0
- package/dist/web/client/assets/resource-helpers-ULlyU8qK.js +2 -0
- package/dist/web/client/assets/resources-panel-DSU7VGX2.js +1 -0
- package/dist/web/client/assets/routes-CxlNCi_v.js +16 -0
- package/dist/web/client/assets/session-insights-panel-DwmwiikS.js +1 -0
- package/dist/web/client/assets/settings-dialog-CkfpTKfM.js +1 -0
- package/dist/web/client/assets/skeleton-loaders-fStjEeRP.js +1 -0
- package/dist/web/client/assets/square-terminal-BYTN_I86.js +1 -0
- package/dist/web/client/assets/subagents-panel-DGnsK6Nx.js +1 -0
- package/dist/web/client/assets/{switch-ojzdMno9.js → switch-BFEBpUEU.js} +1 -1
- package/dist/web/client/assets/{tool-result-QvhjpNGX.js → tool-result-CBzwwUE9.js} +3 -3
- package/dist/web/client/assets/ui-preferences-DUEFuJFj.js +1 -0
- package/dist/web/client/assets/workspace-panel-CjdXlEvd.js +1 -0
- package/dist/web/client/assets/workspace-path-nav-C0AQNZyy.js +1 -0
- package/dist/web/server/{_tanstack-start-manifest_v-puvdGuy--7AY277Z5.js → _tanstack-start-manifest_v-bDUlyKY0-KFW35JRO.js} +25 -18
- package/dist/web/server/{artifacts-panel-knpQvJ-q-WJLZ76QB.js → artifacts-panel-D9w1DHAN-FGRDCYU2.js} +37 -70
- package/dist/web/server/{chat-command-palette-CPv5GmGJ-22J32S6P.js → chat-command-palette-BaenPkCN-BHSOPGU4.js} +16 -14
- package/dist/web/server/{chunk-OADQILSQ.js → chunk-2U7PWSJX.js} +49 -47
- package/dist/web/server/{chunk-ZX3XOSYO.js → chunk-3GSFXWL5.js} +2 -2
- package/dist/web/server/{chunk-IFV5M33X.js → chunk-3IKSPTYI.js} +12 -26
- package/dist/web/server/{chunk-W7LNJCRJ.js → chunk-44IVTHDV.js} +18 -10
- package/dist/web/server/{chunk-I3FDTJFO.js → chunk-46VQY7SG.js} +6 -87
- package/dist/web/server/{chunk-WTYNN6EV.js → chunk-54II5QXQ.js} +23 -1
- package/dist/web/server/{chunk-PRT4QYOB.js → chunk-5AVQZ4AZ.js} +1 -35
- package/dist/web/server/chunk-6GMKRR3C.js +161 -0
- package/dist/web/server/chunk-74QOI457.js +45 -0
- package/dist/web/server/chunk-AQ66E5OW.js +33 -0
- package/dist/web/server/{chunk-TTQ75CXC.js → chunk-AZZHUVJR.js} +88 -23
- package/dist/web/server/{chunk-KAWYGHDN.js → chunk-B2F6MLVZ.js} +23 -1
- package/dist/web/server/{chunk-C7EKOPZU.js → chunk-DO3TVNGA.js} +87 -87
- package/dist/web/server/chunk-EIVNRYP3.js +48 -0
- package/dist/web/server/{chunk-UBUXV2TW.js → chunk-FBOO3G67.js} +6 -6
- package/dist/web/server/{chunk-MK3P3OBZ.js → chunk-FVWDJNXR.js} +5 -5
- package/dist/web/server/chunk-G5BCQQ5N.js +34 -0
- package/dist/web/server/{chunk-4KFMONRT.js → chunk-H64JLONZ.js} +9 -9
- package/dist/web/server/{chunk-KDSISV4P.js → chunk-HBZ6YKRB.js} +2 -50
- package/dist/web/server/{chunk-5277VI3D.js → chunk-KPNGZR2R.js} +12 -74
- package/dist/web/server/chunk-M2FGGPNA.js +376 -0
- package/dist/web/server/{chunk-KVHPE5XH.js → chunk-MDYA4NXK.js} +22 -8
- package/dist/web/server/chunk-NFRJDPB3.js +52 -0
- package/dist/web/server/chunk-P66QQWUM.js +67 -0
- package/dist/web/server/{fleet-pi-tool-renderer-5vYFNeZS-IHKMLT7W.js → chunk-PCJ5EKFE.js} +40 -392
- package/dist/web/server/{chunk-APN3LVRT.js → chunk-PWK2HJIV.js} +27 -30
- package/dist/web/server/{chunk-XXNFEXDU.js → chunk-QJBEWT4E.js} +2 -70
- package/dist/web/server/{chunk-JD6EWZCU.js → chunk-VHCAD46L.js} +48 -48
- package/dist/web/server/chunk-Y6LJ4WBI.js +1797 -0
- package/dist/web/server/{chunk-NGI44XRR.js → chunk-ZEVZFLIY.js} +1 -1
- package/dist/web/server/fleet-pi-tool-renderer-lJvZWmBJ-4M5YI6VS.js +35 -0
- package/dist/web/server/{fork-picker-dialog-BZzfxdQd-C6SPHFAW.js → fork-picker-dialog-BZzfxdQd-Y725VJ7G.js} +2 -2
- package/dist/web/server/{markdown-Ct_q4D-z-VFWZRBTY.js → markdown-Boni3lHk-AZGKDNAR.js} +1 -1
- package/dist/web/server/{markdown-code-C_ih1bX1-5CIWT3CH.js → markdown-code-BrWukbg3-D2GN4Y77.js} +2 -2
- package/dist/web/server/{openui-renderer-BT5jL0Yf-XYLLN5U6.js → openui-renderer-Cg4RSE9k-7BTJIYZJ.js} +12 -11
- package/dist/web/server/repl-panel-BEQrC2ef-V3YEZ7EO.js +117 -0
- package/dist/web/server/{resources-panel-DNCVHTIg-PJYMXVGE.js → resources-panel-CwKh4U9f-D3VDEMDW.js} +6 -6
- package/dist/web/server/{router-DDxOMz3K-HRBXILHM.js → router-CEahIUpn-SRG7XKIH.js} +131 -21
- package/dist/web/server/{routes-BX4Tv-6R-FHIZYUWW.js → routes-BznemByz-F4DJAYIM.js} +1371 -2499
- package/dist/web/server/server.js +2 -2
- package/dist/web/server/{session-insights-panel-gYkkAE8H-W4O74Z7H.js → session-insights-panel-JfeTHE0d-3HZB3ZWI.js} +2 -2
- package/dist/web/server/{settings-dialog-BTBFLQ1P-ZENQ4KWK.js → settings-dialog-DgeBMORv-7SRSENPM.js} +47 -61
- package/dist/web/server/subagents-panel-CzZe3co7-2VZ5JTWF.js +332 -0
- package/dist/web/server/{chunk-5SZXUN3Y.js → workspace-panel-y54P79_B-VPIYUXF6.js} +29 -16
- package/package.json +11 -3
- package/dist/web/client/assets/artifacts-panel-8TyrNBM_.js +0 -1
- package/dist/web/client/assets/collapsible-WCSnxhr2.js +0 -1
- package/dist/web/client/assets/command-DgfiCKcY.js +0 -2
- package/dist/web/client/assets/globals-BmxtUHFx.css +0 -2
- package/dist/web/client/assets/horizontal-resize-B76jjn5v.js +0 -1
- package/dist/web/client/assets/index-0pBr_bKy.js +0 -12
- package/dist/web/client/assets/markdown-BXWmNJo7.js +0 -2
- package/dist/web/client/assets/prime-agent-artifacts-k9JiTDZM.js +0 -5
- package/dist/web/client/assets/provider-brand-icon-VCebsuTD.js +0 -1
- package/dist/web/client/assets/range-KAaLzImH.js +0 -2
- package/dist/web/client/assets/resources-panel-BWuKeyrb.js +0 -1
- package/dist/web/client/assets/routes-BPRw0UzV.js +0 -20
- package/dist/web/client/assets/session-insights-panel-CPymkzZT.js +0 -1
- package/dist/web/client/assets/settings-dialog-6p8mjg8t.js +0 -1
- package/dist/web/client/assets/shared-DAI9OAw0.js +0 -2
- package/dist/web/client/assets/skeleton-loaders-qxIkJKCA.js +0 -1
- package/dist/web/client/assets/workspace-panel-C67-fqw4.js +0 -1
- package/dist/web/client/assets/workspace-path-nav-BrQHo6es.js +0 -9
- package/dist/web/server/chunk-KJ4UUAEU.js +0 -83
- package/dist/web/server/workspace-panel-BNAXF57q-EQCBPEG4.js +0 -28
- package/dist/web/server/{chunk-AQWTGP35.js → chunk-FE4KN6T2.js} +5 -5
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/openui-renderer-NLUpAS3h.js","assets/rolldown-runtime-hePW80VL.js","assets/bundle-mjs-DKHVkVWu.js","assets/react-dom-Bwxum3ti.js","assets/jsx-runtime-NZYk81nU.js","assets/button-0At5xSyU.js","assets/x-BgciQ7_C.js","assets/createLucideIcon-DwxZHm0M.js","assets/utils-Eg7xtNmV.js","assets/dialog-DZ44tBtH.js","assets/useBaseUiId-B9f7fokB.js","assets/provider-catalog-Gx9qaHBM.js","assets/useControlled-CoY1jSuL.js","assets/chevron-down-BEVGmnSb.js","assets/input-Clyn18XG.js","assets/safe-external-url-Bl_78dpZ.js","assets/card-BKl76a3R.js","assets/chunk-BO2N2NFS-BnzHCiyQ.js","assets/preload-helper-Czpn1I53.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/chat-C64Sv6V-.js","assets/switch-ojzdMno9.js","assets/dist-MNgIFxqY.js","assets/markdown-BXWmNJo7.js","assets/cn-C8c0S2mI.js","assets/fleet-pi-tool-renderer-ZKiX6Ob_.js","assets/workspace-path-nav-BrQHo6es.js","assets/layout-gyLzPvVv.js","assets/tool-result-QvhjpNGX.js","assets/loader-circle-6JG5RwxH.js","assets/collapsible-WCSnxhr2.js","assets/rotate-ccw-WNFNkKQD.js","assets/range-KAaLzImH.js","assets/sparkles-C5H3Jtgf.js","assets/chevron-right-DrJxToLs.js","assets/file-text-BhQ0ZnoU.js","assets/eye-B0DFz5hL.js","assets/search-eWVnAJsb.js","assets/dist-H-qlGkmT.js","assets/chat-command-palette-HpsmKfLO.js","assets/command-DgfiCKcY.js","assets/folder-BC5p7qK7.js","assets/package-CdcJFPf2.js","assets/input-group-MxDAWX3j.js","assets/skeleton-CkR2VmWc.js","assets/sun-BWiZFty0.js","assets/settings-dialog-6p8mjg8t.js","assets/toast-C4s7FYYa.js","assets/provider-brand-icon-VCebsuTD.js","assets/plug-Dt6VN0zF.js","assets/hard-drive-CHqgr7VQ.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 ee,x as U,z as te}from"./button-0At5xSyU.js";import{$ as ne,C as re,G as ie,H as ae,I as oe,J as se,K as ce,L as le,M as ue,N as de,P as fe,Q as pe,U as me,V as he,W as ge,X as _e,Y as ve,Z as ye,at as be,ct as xe,et as Se,h as Ce,it as we,j as Te,m as Ee,nt as De,ot as Oe,q as ke,rt as Ae,tt as je,y as Me,z as Ne}from"./layout-gyLzPvVv.js";import{_ as Pe,a as Fe,b as Ie,c as Le,d as Re,f as ze,g as W,h as Be,i as Ve,l as He,m as G,n as Ue,o as We,p as Ge,u as Ke,v as qe,y as Je}from"./workspace-path-nav-BrQHo6es.js";import{M as Ye,S as Xe,T as Ze,a as Qe,c as $e,ct as et,f as tt,g as nt,it as rt,k as it,l as at,n as ot,p as st,q as ct,rt as lt,s as ut,st as dt,t as ft,tt as pt,w as mt,x as ht,y as gt}from"./x-BgciQ7_C.js";import{r as _t}from"./toast-C4s7FYYa.js";import{$ as vt,A as yt,B as bt,C as xt,D as St,E as Ct,F as wt,G as Tt,H as Et,I as Dt,J as Ot,K as kt,L as At,M as jt,N as Mt,O as Nt,P as Pt,Q as Ft,R as It,S as Lt,U as Rt,V as zt,W as Bt,X as Vt,Z as Ht,_ as Ut,a as Wt,b as Gt,et as Kt,g as qt,h as Jt,i as Yt,j as Xt,n as Zt,o as Qt,q as $t,r as en,t as tn,w as nn,x as rn,y as an}from"./dialog-DZ44tBtH.js";import{A as on,_ as sn,b as cn,d as ln,g as un,h as dn,l as fn,o as pn,p as mn,u as hn,v as gn,y as _n}from"./provider-catalog-Gx9qaHBM.js";import{t as vn}from"./useBaseUiId-B9f7fokB.js";import{A as yn,D as bn,E as xn,F as Sn,M as Cn,N as wn,S as Tn,T as En,a as Dn,c as On,d as kn,f as An,g as jn,h as Mn,i as Nn,j as Pn,k as Fn,l as In,m as Ln,n as Rn,o as zn,p as Bn,s as Vn,t as Hn,u as Un,w as Wn}from"./provider-brand-icon-VCebsuTD.js";import{t as K}from"./utils-Eg7xtNmV.js";import{t as q}from"./createLucideIcon-DwxZHm0M.js";import{a as Gn,d as Kn,f as qn,i as Jn,l as Yn,o as Xn,p as Zn,r as Qn,s as $n,t as er,u as tr}from"./command-DgfiCKcY.js";import{_ as nr,a as rr,b as ir,d as ar,f as or,g as sr,h as cr,i as lr,l as ur,m as dr,o as fr,p as pr,r as mr,s as hr,u as gr,v as _r,x as vr,y as yr}from"./range-KAaLzImH.js";import{a as br,i as xr,r as Sr}from"./shared-DAI9OAw0.js";import{n as Cr,t as wr}from"./useControlled-CoY1jSuL.js";import{t as Tr}from"./chevron-down-BEVGmnSb.js";import{t as Er}from"./chevron-right-DrJxToLs.js";import{n as Dr,t as Or}from"./safe-external-url-Bl_78dpZ.js";import{n as kr,t as Ar}from"./file-text-BhQ0ZnoU.js";import{t as jr}from"./loader-circle-6JG5RwxH.js";import{a as Mr,c as Nr,i as Pr,l as Fr,n as Ir,o as Lr,r as Rr,s as zr,t as Br}from"./collapsible-WCSnxhr2.js";import{t as Vr}from"./sparkles-C5H3Jtgf.js";import{a as Hr,c as Ur,d as Wr,f as Gr,h as Kr,i as qr,l as Jr,m as Yr,n as Xr,r as Zr,s as Qr,t as $r,u as ei,v as ti,y as ni}from"./horizontal-resize-B76jjn5v.js";import{t as ri}from"./folder-BC5p7qK7.js";import{t as ii}from"./package-CdcJFPf2.js";import{a as ai,c as oi,l as si,o as ci}from"./input-group-MxDAWX3j.js";import{t as li}from"./rotate-ccw-WNFNkKQD.js";import{t as ui}from"./search-eWVnAJsb.js";import{t as di}from"./preload-helper-Czpn1I53.js";import{A as fi,C as pi,E as mi,F as hi,G as gi,I as _i,K as vi,L as J,M as Y,N as yi,O as bi,P as xi,S as Si,T as Ci,_ as wi,a as Ti,b as Ei,c as Di,d as Oi,f as ki,g as Ai,h as ji,i as Mi,k as Ni,l as Pi,m as Fi,n as Ii,o as Li,p as Ri,r as zi,s as Bi,t as Vi,u as Hi,w as Ui,x as Wi,z as X}from"./chat-C64Sv6V-.js";import{i as Gi,r as Ki,t as qi}from"./prime-agent-artifacts-k9JiTDZM.js";import"./cn-C8c0S2mI.js";import{t as Ji}from"./input-Clyn18XG.js";var Yi=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),Zi(this.#t,this.options)?this.#m():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qi(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&&$i(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 ta(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&&Zi(e,t),o=i&&$i(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:ea(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 Xi(e,t){return a(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||a(t.retryOnMount,e)!==!1)}function Zi(e,t){return Xi(e,t)||e.state.data!==void 0&&Qi(e,t,t.refetchOnMount)}function Qi(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&&ea(e,t)}return!1}function $i(e,t,n,r){return(e!==t||a(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ea(e,n)}function ea(e,t){return a(t.enabled,e)!==!1&&e.isStaleByTime(d(t.staleTime,e))}function ta(e,t){return!h(e.getCurrentResult(),t)}var na=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),ra=Z.createContext(!1),ia=()=>Z.useContext(ra);ra.Provider;var Q=r();function aa(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oa=Z.createContext(aa()),sa=()=>Z.useContext(oa),ca=(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))},la=e=>{Z.useEffect(()=>{e.clearReset()},[e])},ua=({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])),da=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))}},fa=(e,t)=>e?.suspense&&t.isPending,pa=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ma(e,t,n){let r=ia(),i=sa(),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,da(o),ca(o,i,c),la(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]),fa(o,d))throw pa(o,u,i);if(ua({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function ha(e,t){return ma(e,Yi,t)}function ga(e,t){let n=s(t),[r]=Z.useState(()=>new na(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 _a=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function va(e,t){return Se(e)?e[_a(0,e.length,t)]:e}var ya=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 ba(this.animations,`duration`)}get iterationDuration(){return ba(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 ba(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 xa=class extends ya{then(e,t){return this.finished.finally(e).then(()=>{})}};function Sa(...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=se(i,a,o);return t?s(r):s}function Ca(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=Ta(e.get()),r=Ta(a);if(t===r){c();return}let s=i?i.getGeneratorVelocity():e.getVelocity();c(),i=new ie({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(wa(e,s)),ne.postRender(u)},c),Ne(t)){let r=n.skipInitialAnimation===!0,i=t.on(`change`,t=>{r?(r=!1,e.jump(wa(t,s),!1)):e.set(wa(t,s))}),a=e.on(`destroy`,i);return()=>{i(),a()}}return c}function wa(e,t){return t?e+t:e}function Ta(e){return typeof e==`number`?e:parseFloat(e)}function Ea(e,t){return e in t}var Da=class extends re{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(Ea(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 ue()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},Oa=e=>!e.isLayoutDirty&&e.willUpdate(!1);function ka(){let e=new Set,t=new WeakMap,n=()=>e.forEach(Oa);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 Aa=(0,Z.createContext)(null);function ja(){let e=(0,Z.useRef)(!1);return Je(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ma(){let e=ja(),[t,n]=(0,Z.useState)(0),r=(0,Z.useCallback)(()=>{e.current&&n(t+1)},[t]);return[(0,Z.useCallback)(()=>ne.postRender(r),[r]),t]}var Na=e=>e===!0,Pa=e=>Na(e===!0)||e===`id`,Fa=({children:e,id:t,inherit:n=!0})=>{let r=(0,Z.useContext)(xe),i=(0,Z.useContext)(Aa),[a,o]=Ma(),s=(0,Z.useRef)(null),c=r.id||i;s.current===null&&(Pa(n)&&c&&(t=t?c+`-`+t:c),s.current={id:t,group:Na(n)&&r.group||ka()});let l=(0,Z.useMemo)(()=>({...s.current,forceRender:a}),[o]);return(0,Q.jsx)(xe.Provider,{value:l,children:e})};function Ia({children:e,...t}){let n=(0,Z.useContext)(qe);t={...n,...t},t.transition=he(t.transition,n.transition),t.isStatic=Ie(()=>t.isStatic);let r=(0,Z.useMemo)(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return(0,Q.jsx)(qe.Provider,{value:r,children:e})}function La(e){let t=Ie(()=>me(e)),{isStatic:n}=(0,Z.useContext)(qe);if(n){let[,n]=(0,Z.useState)(e);(0,Z.useEffect)(()=>t.on(`change`,n),[])}return t}function Ra(e,t){let n=La(t()),r=()=>n.set(t());return r(),Je(()=>{let t=()=>ne.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),pe(r)}}),n}function za(e){ae.current=[],e();let t=Ra(ae.current,e);return ae.current=void 0,t}function Ba(e,t,n,r){if(typeof e==`function`)return za(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Ha(e,t,n,r);let i=typeof t==`function`?t:Sa(t,n,r),a=Array.isArray(e)?Va(e,i):Va([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 Va(e,t){let n=Ie(()=>[]);return Ra(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Ha(e,t,n,r){let i=Ie(()=>Object.keys(n)),a=Ie(()=>({}));for(let o of i)a[o]=Ba(e,t,n[o],r);return a}function Ua(e,t={}){let{isStatic:n}=(0,Z.useContext)(qe),r=()=>Ne(e)?e.get():e;if(n)return Ba(r);let i=La(r());return(0,Z.useInsertionEffect)(()=>Ca(i,e,t),[i,JSON.stringify(t)]),i}function Wa(e,t={}){return Ua(e,{type:`spring`,...t})}function Ga(e){return typeof e==`object`&&!Array.isArray(e)}function Ka(e,t,n,r){return e==null?[]:typeof e==`string`&&Ga(t)?oe(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>e!=null):[e]}function qa(e,t,n){return e*(t+1)+n*t}function Ja(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 Ya(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(Oe(e,i),r--)}}function Xa(e,t,n,r,i,a){Ya(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:ye(i,a,r[o]),easing:va(n,o)})}function Za(e,t,n=0){let r=t+1+t*n;for(let t=0;t<e.length;t++)e[t]=e[t]/r}function Qa(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var $a=`easeInOut`,eo=20;function to(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,Ja(d,o.at,u,l));continue}let[p,m,h={}]=o;h.at!==void 0&&(d=Ja(d,h.at,u,l));let g=0,_=(e,n,r,o=0,s=0)=>{let c=io(e),{delay:l=0,times:u=ce(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=ge(p)?p:i?.[p||`keyframes`];if(S<=2&&C){let e=100;if(S===2&&so(c)){let t=c[1]-c[0];e=Math.abs(t)}let n={...t,...v};b!==void 0&&(n.duration=De(b));let r=_e(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&&ke(u,T),c.length===1&&c.unshift(null),m&&be(m<eo,`Sequence segments can't repeat ${m} times — ignoring repeat option. Use a value below ${eo} or apply repeat at the sequence level instead.`),m&&m<eo){let e=b>0?_/b:0;b=qa(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`?je(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`:va(f,e-1))}Za(u,m,e)}let E=w+b;Xa(r,c,y,u,w,E),g=Math.max(x+b,g),f=Math.max(E,f)};if(Ne(p)){let e=no(p,s);_(m,h,ro(`default`,e))}else{let e=Ka(p,m,r,c),t=e.length;for(let n=0;n<t;n++){m=m,h=h;let r=e[n],i=no(r,s);for(let e in m)_(m[e],ao(h,e),ro(e,i),n,t)}}u=d,d+=g}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(Qa);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(Ae(0,f,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift($a)),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 no(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function ro(e,t){return t[e]||(t[e]=[]),t[e]}function io(e){return Array.isArray(e)?e:[e]}function ao(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var oo=e=>typeof e==`number`,so=e=>e.every(oo);function co(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=fe(e)&&!de(e)?new Ce(t):new Me(t);n.mount(e),Te.set(e,n)}function lo(e){let t=new Da({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),Te.set(e,t)}function uo(e,t){return Ne(e)||typeof e==`number`||typeof e==`string`&&!Ga(t)}function fo(e,t,n,r){let i=[];if(uo(e,t))i.push(Ee(e,Ga(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;let a=Ka(e,t,r),o=a.length;we(!!o,`No valid elements provided.`,`no-valid-elements`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?co:lo;Te.has(r)||s(r);let c=Te.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...le(c,{...t,transition:l},{}))}}return i}function po(e,t,n){let r=[];return to(e.map(e=>{if(Array.isArray(e)&&typeof e[0]==`function`){let t=e[0],n=me(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:ve}).forEach(({keyframes:e,transition:t},n)=>{r.push(...fo(n,e,t))}),r}function mo(e){return Array.isArray(e)&&e.some(Array.isArray)}function ho(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),mo(e)){let{onComplete:n,...r}=i||{};typeof n==`function`&&(s=n),o=po(e,{...c,...r},t)}else{let{onComplete:n,...r}=a||{};typeof n==`function`&&(s=n),o=fo(e,i,{...c,...r},t)}let l=new xa(o);return s&&l.finished.then(s),t&&(t.animations.push(l),l.finished.then(()=>{Oe(t.animations,l)})),l}return i}var go=ho(),_o=q(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),vo=q(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),yo=q(`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`}]]),bo=q(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),xo=q(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),So=q(`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`}]]),Co=q(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),wo=q(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),To=q(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Eo=q(`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`}]]),Do=q(`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`}]]),Oo=q(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),ko=q(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),Ao=q(`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`}]]),jo=q(`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`}]]),Mo=q(`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`}]]),No=q(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Po=q(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Fo=q(`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`}]]),Io=q(`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`}]]),Lo=q(`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`}]]),Ro=q(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),zo=q(`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`}]]),Bo=q(`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`}]]),Vo=q(`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`}]]),Ho=q(`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`}]]),Uo=q(`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`}]]),Wo=q(`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`}]]),Go=q(`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`}]]),Ko=q(`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 qo({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=W(),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)(Pe,{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)(xn,{"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)(ft,{"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 Jo=Z.createContext(void 0);function Yo(){let e=Z.useContext(Jo);if(e===void 0)throw Error(lt(64));return e}var Xo={tabActivationDirection:e=>({"data-activation-direction":e})},Zo=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]=wr({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=>Qo(_,e),[_]),[x,S]=Z.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=$o(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;rt(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=pt((e,t)=>{t.activationDirection=$o(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),A=pt((e,t)=>{i?.(e,ot(t,void 0,void 0,{activationDirection:`none`}))}),j=pt((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);rt(()=>{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,tt);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=tt;r?i=at:t&&(i=Qe),e(n,i);return}r&&F!=null&&(A(m,at),L.current=!1)},[I,g,A,F,h,_,m]);let V=it(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:Xo});return(0,Q.jsx)(Jo.Provider,{value:P,children:(0,Q.jsx)(un,{elementsRef:d,children:V})})});function Qo(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function $o(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=Qo(r,e),c=Qo(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 es=`data-composite-item-active`;function ts(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Xe(),{ref:i,index:a}=dn(e),o=n===a,s=Z.useRef(null),c=Ye(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 ns=Z.createContext(void 0);function rs(){let e=Z.useContext(ns);if(e===void 0)throw Error(lt(65));return e}var is=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}=Yo(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=rs(),{highlightedIndex:v,onHighlightedIndexChange:y}=Xe(),b=vn(o),{compositeProps:x,compositeRef:S,index:C}=ts({metadata:Z.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),w=a===u,E=Z.useRef(!1),D=Z.useRef(null),O=pt(e=>{D.current?.(),D.current=e?g(e):null});rt(()=>{if(E.current){E.current=!1;return}if(!(w&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=te(P(e));if(t&&T(e,t))return}r||y(C)},[w,C,v,y,r,_]);let{getButtonProps:k,buttonRef:A}=gt({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=Z.useRef(!1),N=Z.useRef(!1);function F(e){f(a,ot(st,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 it(`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,[es]:w?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:Xo})}),as=[];function os(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=as}=e,[p,m]=Z.useState(0),h=r!=null,g=Z.useRef(null),_=Ye(g,c),v=Z.useRef([]),y=Z.useRef(!1),b=o??p,x=pt((e,t=!1)=>{if((s??m)(e),t){let t=v.current[e];Nt(g.current,t,a,n)}}),S=pt(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)}Nt(g.current,r,a,n)});rt(()=>{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=pt((e,t,n)=>i?i(e,t,n,v):n),T=pt(e=>{let o=e.key===`Home`||e.key===`End`;if(!nn.has(e.key)||!l&&o||ss(e,f)||!g.current)return;let s=a===`rtl`,c=s?rn:Lt,p=s?Lt:rn,m=n===`vertical`?Gt:c,_=n===`vertical`?xt:p,y=j(e.nativeEvent);if(y!=null&&St(y)&&!mn(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||!St(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:b,onHighlightedIndexChange:x,elementsRef:v,onMapChange:S,relayKeyboardEvent:T}}function ss(e,t){for(let n of Ct)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function cs(e){let{render:t,className:n,style:r,refs:i=dt,props:a=dt,state:o=et,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}=os({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:cn(),disabledIndices:v,modifierKeys:y}),k=it(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)(ht.Provider,{value:A,children:(0,Q.jsx)(un,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var ls=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}=Yo(),[d,f]=Z.useState(0),[p,m]=Z.useState(null),h=Z.useRef(new Set),g=Z.useRef(new Set),_=Z.useRef(null);rt(()=>{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=pt(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=pt(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)(ns.Provider,{value:S,children:(0,Q.jsx)(cs,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:Xo,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:dt})})});function us({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(Zo,{"data-slot":`tabs`,"data-orientation":t,className:K(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var ds=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 fs({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(ls,{"data-slot":`tabs-list`,"data-variant":t,className:K(ds({variant:t}),e),...n})}function ps({className:e,...t}){return(0,Q.jsx)(is,{"data-slot":`tabs-trigger`,className:K(`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 ms(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 hs={normal:`'wght' 400, 'opsz' 14`,medium:`'wght' 450, 'opsz' 15`,semibold:`'wght' 550, 'opsz' 20`,bold:`'wght' 700, 'opsz' 25`},gs={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}}},_s=`bg-background shadow-sm`,vs=`rounded-full border border-border/70 bg-sidebar p-0.5 shadow-sm backdrop-blur`,ys=`rounded-full`;function bs(e,t){return t?e?`text-foreground/75`:`text-foreground`:e?`text-foreground/55`:`text-muted-foreground`}var xs=(0,Z.createContext)(null);function Ss(){let e=(0,Z.useContext)(xs);if(!e)throw Error(`useTabsSubtle must be used within a TabsSubtle`);return e}function Cs({selectedRect:e,hoverRect:t,focusRect:n,isHovering:r,isHoveringSelected:i}){let a=W()?{duration:0}:void 0;return(0,Q.jsxs)(b,{features:v,children:[e?(0,Q.jsx)(G.div,{className:K(`pointer-events-none absolute`,_s,ys),layout:!0,initial:!1,style:{left:e.left,top:e.top,width:e.width,height:e.height},animate:{opacity:r?.8:1},transition:a??{...gs.moderate.enter,opacity:{duration:.08}}}):null,(0,Q.jsx)(Pe,{children:t&&!i?(0,Q.jsx)(G.div,{className:K(`pointer-events-none absolute`,_s,ys),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??gs.fast.exit},transition:a??{...gs.fast.enter,opacity:{duration:.08}}}):null}),(0,Q.jsx)(Pe,{children:n?(0,Q.jsx)(G.div,{className:K(`pointer-events-none absolute z-20 border border-ring`,ys),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??gs.fast.exit},transition:a??{...gs.fast.enter,opacity:{duration:.08}}}):null})]})}var ws=(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:_}=ms(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)(xs.Provider,{value:O,children:(0,Q.jsx)(us,{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)(fs,{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:K(`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?vs:`-mx-1 -my-1 px-1 py-1`,o),...s,children:[(0,Q.jsx)(Cs,{selectedRect:C,hoverRect:w,focusRect:T,isHovering:D,isHoveringSelected:E}),e]})})})});ws.displayName=`TabsSubtle`;var Ts=(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}=Ss();(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=bs(C,y),T=a??(x&&!S?t:void 0),E=(0,Q.jsxs)(`span`,{className:K(`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:hs.semibold},"aria-hidden":`true`,children:t}),(0,Q.jsx)(`span`,{className:K(`col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]`,w),style:{fontVariationSettings:_?hs.semibold:hs.normal},children:t})]});return(0,Q.jsxs)(ps,{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:K(`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`,ys,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:K(`shrink-0 transition-[color,stroke-width] duration-80`,w)}),r===void 0?null:(0,Q.jsx)(`span`,{className:K(`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)(Pe,{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:{...gs.fast.enter,opacity:{duration:.06}},children:E},`label`):null})})]})});Ts.displayName=`TabsSubtleItem`;var Es=(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:K(`outline-none`,i),...a,children:s?r:null})});Es.displayName=`TabsSubtlePanel`;function Ds({active:e=!1,ariaLabel:t,className:n,title:r,...i}){return(0,Q.jsx)(H,{...i,type:`button`,variant:`ghost`,size:`sm`,className:K(Mn,e?Ln:jn,n),"aria-label":t,title:r??t})}function Os(){let{reopenRightPanel:e,rightPanel:t}=ci();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`min-[960px]:hidden`,children:(0,Q.jsx)(ks,{idPrefix:`right-panel-mobile`})}),(0,Q.jsx)(`div`,{className:`hidden min-[960px]:block`,children:t===null?(0,Q.jsx)(As,{onOpen:e}):null})]})}function ks({idPrefix:e=`right-panel`}){let{artifactRuns:t,messages:n,rightPanel:r,setRightPanel:i,resources:a}=ci(),{workspaceTree:o}=oi();return(0,Q.jsx)(js,{activePanel:r,onPanelChange:i,resources:a,sessionBlocks:Ki(n).length,technicalArtifacts:t.flatMap(e=>e.artifacts).length,workspace:o,idPrefix:e})}function As({onOpen:e}){return(0,Q.jsx)(Ds,{ariaLabel:`Open side panel`,className:`size-9 justify-center px-0`,onClick:e,children:(0,Q.jsx)(Ro,{className:`size-4`})})}function js({activePanel:e,onPanelChange:t,resources:n,sessionBlocks:r=0,technicalArtifacts:i=0,workspace:a,idPrefix:o=`right-panel`}){let s=br(n,a).reduce((e,t)=>e+t.items.length,0),c=(0,Z.useMemo)(()=>{let e=(()=>{if(!a)return 0;let e=xr(a.nodes,Gi(a.root));return e?.children?.length?Sr(e.children):0})()+r+i;return e>0?e:void 0},[r,i,a]),l=(0,Z.useMemo)(()=>Yn.map(e=>({...e,badge:e.badgeSource===`resources`?s||void 0:e.badgeSource===`artifacts`?c:void 0})),[c,s]),u=l.findIndex(t=>t.id===e);return(0,Q.jsx)(ws,{activeLabel:!0,className:`w-fit max-w-full`,"data-testid":`right-panel-inline-launcher`,"data-active-panel":e??`closed`,idPrefix:o,selectedIndex:u,onSelect:n=>{let r=l.at(n)?.id;r&&t(r===e?null:r)},children:l.map((e,t)=>(0,Q.jsx)(Ts,{index:t,icon:e.icon,label:e.title,badge:e.badge,"aria-label":e.ariaLabel},e.id))})}function Ms({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 ${Tn} backdrop:bg-black/20 ${Yr}`,"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)(ft,{"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 Ns({handleResourceCanvasResizeStart:e,resourceCanvasWidth:t}){let n=ci(),r=oi(),{rightPanel:i,setRightPanel:a}=n,o=i!==null,s=i?tr(i):null,c=s?.component,l=s?.loadingSource===`resources`?n.resourcesLoading:s?.loadingSource===`workspace`&&r.workspaceLoading,u=s?.refreshSource===`resources`?n.refreshResources:s?.refreshSource===`workspace`?r.refreshWorkspace:void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ms,{dataTestid:s?.mobileDataTestid,icon:s?.icon,onClose:()=>a(null),open:o,title:s?.title??``,children:c?(0,Q.jsx)(c,{}):null}),(0,Q.jsx)(qo,{dataTestid:s?.dataTestid,headerLeading:(0,Q.jsx)(ks,{idPrefix:`right-panel-desktop`}),loading:l,onClose:()=>a(null),onRefresh:u,onResizeStart:e,open:o,title:s?.title??``,titleIcon:s?.icon??Zn,width:t,children:c?(0,Q.jsx)(c,{}):null})]})}var Ps={"--chat-chrome-top":`56px`,"--chat-header-height":`36px`,"--chat-header-top":`12px`};function Fs({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:Ps,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:K(Bn,`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 Is=e(n(),1),Ls=`(max-width: 767px)`,Rs=`b`,zs={duration:.36,ease:Ve},Bs={type:`spring`,stiffness:380,damping:35,mass:.75},Vs={duration:.18,ease:We},Hs={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:We,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:We,staggerChildren:.045}}},Us={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:Vs}},Ws={duration:.16,ease:We},Gs=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function Ks(e){let t=window.matchMedia(Ls);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function qs(){return window.matchMedia(Ls).matches}function Js(){return!1}function Ys(){return(0,Z.useSyncExternalStore)(Ks,qs,Js)}var Xs=(0,Z.createContext)(null),Zs=(0,Z.createContext)(null);function Qs(){let e=(0,Z.useContext)(Xs);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function $s(){let e=(0,Z.useContext)(Zs);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function ec({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=Ys(),h=W()??!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()===Rs&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]),(0,Q.jsx)(Xs.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:K(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function tc({ariaLabel:e,children:t,className:n,side:r}){let i=Qs(),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(Gs)??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,Is.createPortal)((0,Q.jsxs)(`div`,{className:K(`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?Ws:zs,onClick:()=>i.setOpenMobile(!1),className:K(`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?Ws:zs,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(Gs)):[];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:K(`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)(Zs.Provider,{value:c,children:t})})]}),document.body):null}var nc=(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=Qs(),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)(tc,{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}:Bs,layout:`size`,style:{...s,width:m},className:K(`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?Ws:zs,className:K(`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)(Zs.Provider,{value:h,children:i})})})}),rc=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=Qs(),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:K(`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=Qs();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:K(`focus-visible:ring-2 focus-visible:ring-ring`,e)})});var ic=(0,Z.forwardRef)(function({className:e,onClick:t,type:n=`button`,...r},i){let a=Qs(),o=$s();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:K(`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)})}),ac=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(G.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:K(`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)})}),oc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:K(`flex shrink-0 flex-col gap-2 p-3`,e)})}),sc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:K(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})}),cc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:K(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})}),lc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:K(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})}),uc=(0,Z.forwardRef)(function({children:e,className:t,...n},r){let{collapsed:i}=$s();return(0,Q.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:K(`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})}),dc=(0,Z.forwardRef)(function({className:e,...t},n){return(0,Q.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:K(`w-full min-w-0`,e)})});(0,Z.forwardRef)(function({children:e,className:t,...n},r){return(0,Q.jsx)(Gr,{...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:K(`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:K(`relative`,e)})}),(0,Z.forwardRef)(function({open:e,children:t,className:n,...r},i){let a=Qs(),o=$s();return(0,Q.jsx)(Pe,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,Z.createElement)(G.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:Hs,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:K(`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:Us,"data-slot":`sidebar-menu-sub-item`,className:K(`relative min-w-0`,e)})});function fc({children:e,className:t,sidebarWidth:n=`17rem`,style:r,...i}){return(0,Q.jsx)(ec,{...i,style:{...r,"--sidebar-width":n},className:K(`min-h-0 w-full overflow-hidden rounded-2xl border border-border bg-background`,t),children:e})}var pc=`https://docs.qredence.ai`,mc=`fleet-prime:v1:sidebar-expanded-projects`,hc=[],gc=`new-session:`,_c=`project:`,vc=`session:`;function yc(e){return`${_c}${e}`}function bc(e){return`${vc}${e}`}function xc(e){return`${gc}${e}`}function Sc(e,t){return e.startsWith(t)?e.slice(t.length):null}function Cc(e){return Qr(e.title||e.firstMessage||e.sessionId.slice(0,8))}function wc(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 Tc(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 Ec(e){return e.hasChildren?`${e.name}/`:e.name}function Dc(e,t){return e instanceof Error&&e.message.trim()?e.message:t}function Oc(e){if(typeof window>`u`)return e?[yc(e)]:[];let t=window.localStorage.getItem(mc);if(!t)return e?[yc(e)]:[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return e?[yc(e)]:[]}}function kc(e,t){return t.type===`update`?t.update(e):{...e,[t.field.key]:t.field.value}}function Ac(e){let[t,n]=(0,Z.useReducer)(kc,e,e=>({brandMenuOpen:!1,projectActionsOpen:!1,searchOpen:!1,query:``,expandedProjectIds:Oc(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 jc(e,t){return e.filter(e=>e.messageCount>0||e.sessionId===t)}function Mc(e){return e.toSorted((e,t)=>Date.parse(t.updatedAt)-Date.parse(e.updatedAt))}function Nc(e,t,n){let r=Mc(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 Pc(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 Fc=[[`resources`,`Open Resources`,Zn],[`workspace`,`Open Workspace`,ri],[`artifacts`,`Open Artifacts`,ii]];function Ic({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 Lc({sessions:e,projects:t=hc,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(Dc(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)(()=>Pc(t,n),[n,t]);(0,Z.useEffect)(()=>{if(!r)return;let e=yc(r);g(t=>t.includes(e)?t:[...t,e])},[r,g]),(0,Z.useEffect)(()=>{window.localStorage.setItem(mc,JSON.stringify(m))},[m]);let ee=(0,Z.useMemo)(()=>{let e=H.map(e=>{let t=jc(n.filter(t=>t.projectId===e.projectId),i),r=h.has(e.projectId),a=Nc(t,i,r).map(e=>({id:bc(e.sessionId),label:Cc(e),kind:`file`}));return t.length===0?a.push({id:xc(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:yc(e.projectId),label:e.name,kind:`project`,children:a}}),t=Mc(jc(n.filter(e=>!e.projectId),i));if(t.length>0){let n=Nc(t,i,h.has(`unassigned`)).map(e=>({id:bc(e.sessionId),label:Cc(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]),U=(0,Z.useCallback)(e=>{o?o(e):(s?.(e),a())},[a,o,s]);return{loadDirectories:B,projectById:V,sortedProjects:H,sidebarItems:ee,resumeResource:(0,Z.useCallback)(e=>{let t=Sc(e,`toggle:`);if(t){_(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});return}let r=Sc(e,gc);if(r){U(r);return}let i=Sc(e,vc);if(!i)return;let a=n.find(e=>e.sessionId===i);a&&c(a)},[U,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=Sc(e,`search-project:`);if(t){let e=yc(t);g(t=>t.includes(e)?t:[...t,e]),s?.(t),v(!1);return}let r=Sc(e,`search-session:`),i=r?n.find(e=>e.sessionId===r):void 0;if(i){if(i.projectId){let e=yc(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=Sc(e.id,vc),a=Sc(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)(Ic,{icon:Bo,label:`Rename`,onClick:()=>{r.close(),w(e),T(Cc(e))}}),u&&t.length>1?(0,Q.jsx)(Ic,{icon:Mo,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`}),Fc.map(([e,t,n])=>(0,Q.jsx)(Ic,{icon:n,label:t,onClick:()=>{r.close(),d({panel:e,projectId:a,focus:!0})}},e))]}):null,(0,Q.jsx)(Ic,{icon:Wn,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)(Ic,{icon:Bo,label:`Rename project`,onClick:()=>{r.close(),k(e),A(e.name)}}),(0,Q.jsx)(Ic,{icon:Ko,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`}),Fc.map(([e,t,n])=>(0,Q.jsx)(Ic,{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(Dc(e,`Could not add this project.`))}finally{R(!1)}}}}}var Rc=Z.createContext(void 0);function zc(e){let t=Z.useContext(Rc);if(t===void 0&&!e)throw Error(lt(47));return t}var Bc={...wt,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},Vc=class extends z{constructor(e,t,n){let r=new Dt;super(Hc(e,r,t,n),Uc(r),Bc)}setOpen=(e,t)=>{let n=t.reason===nt,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=bt(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};Et(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Is.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Hc(e,t,n,r=!1){let i={...Mt(),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=Pt(t,n,r),i}function Uc(e){return{popupRef:Z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),stickIfOpenTimeout:new O,triggerElements:e}}function Wc({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=Kc(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),$t(u,d),Rt(u);let{forceUnmount:m}=Bt(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,ot($e))}),[m,u]);let h=d||f;return(0,Q.jsxs)(Rc.Provider,{value:u,children:[s&&(0,Q.jsx)(It,{handle:s,store:u}),h&&(0,Q.jsx)(qc,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function Gc(e){return zc(!0)?(0,Q.jsx)(Wc,{props:e}):(0,Q.jsx)(vt,{children:(0,Q.jsx)(Wc,{props:e})})}function Kc(e,t){let n=kt((e,n)=>new Vc(t,e,n));return Z.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function qc({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=Vt(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return Tt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}function Jc(e,t){let n=Z.useRef(null);function r(t){Is.flushSync(()=>{e.setOpen(!1,ot(ut,t.nativeEvent,t.currentTarget))}),U(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&k(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{Is.flushSync(()=>{e.setOpen(!1,ot(ut,n.nativeEvent,n.currentTarget))});let i=M(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&T(r,i);){let e=i;if(i=ee(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var Yc=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=zc(!0),h=Sn(s)??m;if(!h)throw Error(lt(74));let g=vn(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}=Ot(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=Cn(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:Pn(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=on(v,{stickIfOpen:T}),A=ln(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:P}=gt({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?Xt.open(e):jt.open(e)}},{preFocusGuardRef:I,handlePreFocusGuardFocus:R,handleFocusTargetFocus:z}=Jc(h,x),B=it(`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}),Xc=Z.createContext(void 0);function Zc(){let e=Z.useContext(Xc);if(e===void 0)throw Error(lt(45));return e}var Qc=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return zc().useState(`mounted`)||n?(0,Q.jsx)(Xc.Provider,{value:n,children:(0,Q.jsx)(V,{ref:t,...r})}):null}),$c=Z.createContext(void 0);function el(){let e=Z.useContext($c);if(!e)throw Error(lt(46));return e}var tl=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=zc(),y=Zc(),b=Kt(),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=Ze(O),P=_n({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`);rt(()=>{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`;hn(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=sn(e,z,{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,R],hidden:!S,inert:!C});return(0,Q.jsxs)($c.Provider,{value:P,children:[S&&L&&(0,Q.jsx)(an,{inert:B(!C),cutout:T}),(0,Q.jsx)(Ft,{id:b,children:V})]})}),nl=Z.createContext(void 0);function rl(){let[e,t]=Z.useState(0),n=pt(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var il=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=zc(),l=el(),u=fn(!0)!=null,{context:d,hasClosePart:f}=rl(),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`);mt({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),wn(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?zt(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=it(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...At,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&nn.has(e.key)&&e.stopPropagation()}},gn(g),s],stateAttributesMapping:yt});return(0,Q.jsx)(Ht,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ct(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Q.jsx)(nl.Provider,{value:d,children:N})})}),al=2;function ol({...e}){return(0,Q.jsx)(Gc,{"data-slot":`popover`,...e})}function sl({...e}){return(0,Q.jsx)(Yc,{"data-slot":`popover-trigger`,...e})}function cl({className:e,children:t,align:n=`center`,alignOffset:r=0,side:i=`bottom`,sideOffset:a=4,...o}){let s=qt(),c=Math.min(s+al,8);return(0,Q.jsx)(Qc,{children:(0,Q.jsx)(tl,{align:n,alignOffset:r,side:i,sideOffset:a,className:`isolate z-50`,children:(0,Q.jsx)(il,{"data-slot":`popover-content`,className:K(`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`,Ut(c,3),e),...o,children:(0,Q.jsx)(Jt,{value:c,children:t})})})})}function ll({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)(ol,{open:h,onOpenChange:e=>{r===void 0&&m(e),a?.(e)},children:[(0,Z.isValidElement)(e)?(0,Q.jsx)(sl,{render:e,"aria-controls":f,className:`inline-flex`}):(0,Q.jsx)(sl,{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)(cl,{id:f,side:o,align:s,sideOffset:c,className:K(`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 ul({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:K(`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)(Vo,{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:K(sr,`flex w-full max-w-sm flex-col gap-1.5 rounded-2xl p-3`,a),...o,children:[(0,Q.jsxs)(`div`,{className:K(pr,`flex items-center gap-2 rounded-xl px-2.5 py-1.5`),children:[(0,Q.jsx)(ui,{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:K(`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:K(cr,`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 dl(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 fl(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=>dl(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 pl(){return()=>{}}function ml(){return!0}function hl(){return!1}function gl(){return(0,Z.useSyncExternalStore)(pl,ml,hl)}var _l=(0,Z.createContext)(null);function vl(e){let t=(0,Z.useContext)(_l);if(!t)throw Error(`${e} must be used within <MorphPopover>`);return t}function yl({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)(_l.Provider,{value:g,children:(0,Q.jsx)(`div`,{ref:o,className:K(`relative inline-flex`,i),children:e})})}function bl(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function xl({children:e}){let t=vl(`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:bl(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 Sl=(e,t)=>`${e===`bottom`?`top`:`bottom`} ${t===`end`?`right`:`left`}`;function Cl(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 wl=e=>`inset(0% 0% 0% 0% round ${e}px)`,Tl={duration:.32,ease:We};function El({children:e,side:t=`bottom`,align:n=`end`,sideOffset:r=8,radius:i=16,className:a}){let o=vl(`MorphPopoverContent`),s=W()??!1,c=gl(),l=fl(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:Re},show:{opacity:1,scale:1,transition:Re}},p=s?void 0:{hidden:{clipPath:Cl(t,n,i),transition:Tl},show:{clipPath:wl(i),transition:Tl}};return c?(0,Is.createPortal)((0,Q.jsx)(Pe,{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:Sl(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:K(`overflow-hidden border border-border bg-background`,a),children:e})}):null}),document.body):null}var Dl={duration:.16,ease:We},Ol=[],kl=[];function Al(e){return e.kind===`folder`||e.kind===`project`}function jl(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,...jl(e.children,t,n+1,e.id)]})}function Ml(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?Ml(n.children,t):void 0;if(e)return e}}function Nl(e,t){return e.id===t||e.children?.some(e=>Nl(e,t))===!0}function Pl(e,t){let n,r=[];for(let i of e){if(i.id===t){n=i;continue}if(i.children?.length){let e=Pl(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 Fl(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:Fl(a.children,t,n,r)}):i.push(a)}return i}function Il(e,t){let n=Ml(e,t.itemId);if(!n||n.disabled||t.targetId&&Nl(n,t.targetId))return null;let r=t.targetId?Ml(e,t.targetId):void 0;if(t.position===`inside`&&(!r||r.disabled||!Al(r)))return null;let i=Pl(e,t.itemId);return i.removed?Fl(i.items,i.removed,t.targetId,t.position):null}function Ll(e,t,n){return e.map(e=>({...e,label:e.id===t?n:e.label,children:e.children?Ll(e.children,t,n):void 0}))}function Rl(e,t){if(e.kind===`action`)return null;let n=e.kind===`folder`||e.kind===`project`?t?ti:ri:e.kind===`bookmark`?yo:Ar;return(0,Q.jsx)(n,{className:`size-4`})}function zl({active:e,children:t}){let n=W()??!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}:Dl,children:[(0,Q.jsx)(`span`,{ref:i,children:t}),s?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:t}):null]})})}function Bl({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=W()??!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=Al(e.item),F=S?.(e.item),I=F===void 0?Rl(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)(Bo,{"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:K(`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)(zl,{active:D||s,children:e.item.label}),c?null:C?.(e.item),!c&&!e.item.disabled&&e.item.kind!==`action`?(0,Q.jsxs)(yl,{open:s,onOpenChange:h,children:[(0,Q.jsx)(xl,{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)(Do,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(El,{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 Vl({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:K(`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)(Pe,{initial:!1,children:e.map(e=>(0,Q.jsx)(Bl,{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 Hl({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&&Al(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`&&Al(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(),Al(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 Ul({items:e,defaultItems:t=Ol,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=kl,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 ee=(0,Z.useMemo)(()=>jl(B,H),[H,B]);(0,Z.useEffect)(()=>{E&&ee.some(e=>e.item.id===E)||D(ee[0]?.item.id??null)},[ee,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 U=(0,Z.useCallback)(e=>{x(e),n?.(e)},[n]),te=(0,Z.useCallback)(async e=>{if(z.current){L(`Wait for the current move to finish.`);return}let t=B,n=Il(t,e);if(!n||n===t)return;z.current=!0,U(n),j(null),k(null);let a=Ml(t,e.itemId),o=e.targetId?Ml(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){U(t),L(`Move failed. ${a?.label??`Item`} was restored.`),i?.(n,e)}finally{z.current=!1}},[r,i,B,U]),ne=(0,Z.useCallback)(e=>{D(e),requestAnimationFrame(()=>R.current.get(e)?.focus())},[]),re=(0,Z.useCallback)(e=>{s===void 0&&C(e),u?.(e)},[s,u]),ie=(0,Z.useCallback)(e=>{let t=e(new Set(H));f===void 0&&T(t),m?.([...t])},[f,H,m]),ae=(0,Z.useCallback)(e=>{ie(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[ie]),oe=Hl({expandedIds:H,flat:ee,focusRow:ne,onContainerSelect:d,performMove:te,select:re,setMenuOpenId:N,setRenamingId:F,toggle:ae,updateExpandedIds:ie});return(0,Q.jsx)(Vl,{flat:ee,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:re,onContainerSelect:e=>{d?d(e):ae(e)},onKeyDown:oe,onRenameStart:F,onRenameCancel:()=>F(null),onRenameCommit:(e,t)=>{let n=t.trim();if(F(null),!n||n===e.item.label)return;let r=B;U(Ll(r,e.item.id,n)),Promise.resolve(o?.(e.item,n)).catch(()=>{U(r),L(`Rename failed. ${e.item.label} was restored.`)})},onMenuOpenChange:(e,t)=>{N(t?e:null),t||ne(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=Ml(B,O);if(n&&Nl(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&&Al(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&&te({itemId:O,targetId:A.id,position:A.position})},setRef:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}})}var Wl=5,Gl=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Kl(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 ql({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:K(`fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center`,a&&`pointer-events-none`),children:[(0,Q.jsx)(Pe,{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)(Pe,{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)(ft,{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 Jl({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=W(),g=ur(),_=(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=gl(),[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,Wl),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]),ee=(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(),ee();return}if(e.key!==`Tab`||!w.current)return;let t=Array.from(w.current.querySelectorAll(Gl)).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 U=()=>{j(!1),B(!0),z(!0),d?.()},te=(0,Q.jsx)(ql,{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)(Fa,{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:U,whileTap:h||f?void 0:{scale:.98},transition:h?{duration:0}:ze,className:K(`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)(Pe,{initial:!1,children:P?null:I.map((e,t)=>{let n=Kl(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,Is.createPortal)(te,document.body):null]})}function Yl(e){return e?.status===`running`?(0,Q.jsx)(jr,{className:`size-3.5 animate-spin`}):e?.status===`failed`?(0,Q.jsx)(_t,{className:`size-3.5 text-destructive`}):e?.status===`interrupted`?(0,Q.jsx)(Co,{className:`size-3.5 text-muted-foreground`}):null}function Xl({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)(sc,{className:`gap-0 px-2 pb-1 pt-2`,children:(0,Q.jsxs)(lc,{className:`p-0`,children:[(0,Q.jsxs)(`div`,{className:`relative mb-1 h-8`,children:[(0,Q.jsx)(uc,{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)(ll,{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)(Do,{"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)(jo,{"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)(Tr,{"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)(si,{"aria-hidden":`true`,className:`size-3.5`})}):null]})]}),(0,Q.jsx)(dc,{children:a.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-4`,children:(0,Q.jsx)(Jl,{title:`Add a project`,description:`Choose a local directory for Fleet Prime.`,count:0,itemLabel:`session`,previews:[{id:`empty-project`,content:(0,Q.jsx)(jo,{className:`size-5 text-muted-foreground`})}],onClick:()=>i(!0),ariaLabel:`Add a project`,className:`w-full`})}):(0,Q.jsx)(Ul,{items:s,activeId:l?bc(l):null,activeContainerId:c?yc(c):null,expandedIds:n,onExpandedIdsChange:r,onActiveChange:h,onContainerSelect:g,onRename:(e,t)=>{let n=Sc(e.id,vc);n&&p(n,t)},renderMenu:_,renderIcon:e=>{if(Sc(e.id,`project:`))return(0,Q.jsx)(ri,{className:`size-4`});if(e.kind===`action`)return null;let t=Sc(e.id,vc);return Yl(o.find(e=>e.sessionId===t))},renderSecondaryAction:e=>{let t=Sc(e.id,_c);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)(Io,{"data-icon":`inline-start`,className:`size-3.5`})})},allowMove:!1,ariaLabel:`Projects and sessions`,className:`px-0`})})]})})}var Zl=`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 Ql({icon:e,label:t,onClick:n,href:r}){return r?(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:Zl,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:Zl,children:[(0,Q.jsx)(e,{className:`size-3.5`}),t]})}function $l({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 eu({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)(()=>Mc(f).map(e=>({id:e.sessionId,title:Cc(e),preview:wc(e,h),group:Tc(e.updatedAt),keywords:e.firstMessage?[Qr(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)(nc,{ariaLabel:`Fleet projects and sessions`,collapsible:`offcanvas`,variant:`floating`,className:`text-sidebar-foreground`,children:(0,Q.jsxs)(Jt,{value:2,children:[(0,Q.jsxs)(oc,{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)(ll,{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)(Tr,{className:`size-3.5 text-muted-foreground`})]}),className:`w-52 p-1`,children:[S?(0,Q.jsx)(Ql,{icon:jo,label:`Add project`,onClick:()=>{t(!1),u(!0)}}):null,(0,Q.jsx)(Ql,{icon:En,label:`Settings`,onClick:()=>{t(!1),C?.()}}),(0,Q.jsx)(Ql,{icon:vr,label:`Documentation`,href:pc})]}),(0,Q.jsx)(ll,{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)(ui,{"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)(ul,{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)(ri,{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)($l,{children:`↑`}),(0,Q.jsx)($l,{children:`↓`}),`navigate`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)($l,{children:`↵`}),`open`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)($l,{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)(Uo,{className:`size-4 shrink-0 text-muted-foreground`}),`New chat`]})]}),(0,Q.jsx)(Xl,{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)(cc,{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:pc,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)(So,{className:`size-4`})})]}),(0,Q.jsx)(ic,{})]})})}var tu=(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},nu=(0,Z.createContext)(null),ru=(0,Z.createContext)(null);function iu(e){let t=(0,Z.useContext)(nu);if(!t)throw Error(`${e} must be used within <Combobox>`);return t}function au(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&typeof n==`object`&&(n.current=t)}}function ou({children:e,value:t,defaultValue:n,onValueChange:r,open:i,defaultOpen:a=!1,onOpenChange:o,query:s,defaultQuery:c=``,onQueryChange:l,filter:u=tu,disabled:d=!1,className:f}){let p=W()??!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]),ee=(0,Z.useMemo)(()=>new Set(B.map(e=>e.groupId)),[B]),U=(0,Z.useCallback)(e=>{D.get(e)?.disabled||(k||b(e),r?.(e),I(!1,!0))},[D,r,I,k]),te=(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]),ne=(0,Z.useCallback)(()=>{T&&U(T)},[T,U]);(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 re=T?D.get(T):void 0,ie=(0,Z.useMemo)(()=>({open:N,setOpen:I,value:M,select:U,query:P,setQuery:F,activeValue:T,setActiveValue:E,moveActive:te,selectActive:ne,registerItem:R,unregisterItem:z,labelFor:e=>e===void 0?void 0:D.get(e)?.label,isVisible:e=>!P.trim()||H.has(e),hasVisibleItems:e=>ee.has(e),visibleCount:B.length,activeItemId:re?.id,triggerId:`${m}-trigger`,listId:`${m}-list`,inputId:`${m}-input`,disabled:d,reduce:p,triggerRef:g,contentRef:_,inputRef:v,activeLayoutId:`${m}-active`}),[re?.id,T,m,d,D,te,N,P,p,R,U,ne,z,I,F,M,B.length,ee,H]);return(0,Q.jsx)(nu.Provider,{value:ie,children:(0,Q.jsx)(`div`,{ref:h,className:K(`relative w-full`,f),children:e})})}var su={type:`spring`,duration:.5,bounce:.22},cu=8;function lu({children:e,side:t=`bottom`,align:n=`start`,sideOffset:r=6,avoidCollisions:i=!0,className:a}){let o=iu(`ComboboxContent`),s=(0,Z.useRef)(null),c=gl(),[l,u]=(0,Z.useState)(t),[d,f]=(0,Z.useState)(!1),p=qt(),m=Math.min(p+2,8),h=fl(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(cu,window.innerWidth-v-cu),x=Math.min(Math.max(y,cu),b),S=h?.content.height??0;return(0,Is.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}:su,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:K(`fixed z-[9999] w-(--combobox-trigger-width) overflow-hidden rounded-xl text-popover-foreground outline-none will-change-[height,transform]`,Ut(m,3),a),children:(0,Q.jsx)(Jt,{value:m,children:(0,Q.jsx)(G.div,{ref:s,initial:!1,animate:{opacity:+!!o.open},transition:o.reduce||!d?{duration:0}:su,children:e})})}),document.body)}function uu({children:e,ariaLabel:t=`Options`,className:n}){let r=iu(`ComboboxList`);return(0,Q.jsx)(`div`,{id:r.listId,role:`listbox`,"aria-label":t,className:K(`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 du({children:e,className:t}){let n=iu(`ComboboxGroup`),r=(0,Z.useId)();return(0,Q.jsx)(ru.Provider,{value:r,children:(0,Q.jsx)(`fieldset`,{hidden:!n.hasVisibleItems(r),className:K(`m-0 min-w-0 border-0 p-0 py-0.5`,t),children:e})})}function fu({children:e,className:t}){let n=(0,Z.useContext)(ru),r=K(`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 pu({value:e,children:t,textValue:n,keywords:r=[],disabled:i=!1,onSelect:a,className:o}){let s=iu(`ComboboxItem`),c=(0,Z.useContext)(ru),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:K(`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:We},className:`grid size-5 shrink-0 place-items-center text-foreground`,children:(0,Q.jsx)(Cr,{className:`size-4`})})]}):null}function mu({children:e=`No options found.`,className:t}){return iu(`ComboboxEmpty`).visibleCount>0?null:(0,Q.jsx)(`div`,{role:`status`,className:K(`px-3 py-8 text-center text-sm text-muted-foreground`,t),children:e})}function hu({children:e,className:t,showIndicator:n=!0}){let r=iu(`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:K(`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)(xo,{className:`size-4`})}):null]})}function gu({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=iu(`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:K(`flex min-w-0 flex-1 items-center gap-2`,n),children:[(0,Q.jsx)(ui,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`input`,{...u,ref:au(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:K(`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 _u({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)(tn,{open:e,onOpenChange:e=>{e?t(!0):T()},children:(0,Q.jsxs)(Zt,{className:`sm:max-w-xl`,children:[(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Qt,{children:`Add project`}),(0,Q.jsx)(en,{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)(Ji,{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)(Ji,{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)(An,{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)(ti,{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)(vo,{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)(An,{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)(ou,{value:c,onValueChange:e=>{n.entries.find(t=>t.directoryToken===e)&&m({token:e})},children:[(0,Q.jsx)(hu,{className:`h-10 bg-background`,children:(0,Q.jsx)(gu,{"aria-label":`Search child directories`,placeholder:`Choose a child directory…`,className:`text-xs`})}),(0,Q.jsx)(lu,{className:`w-[min(32rem,calc(100vw-3rem))]`,children:(0,Q.jsxs)(uu,{ariaLabel:`Child directories`,children:[(0,Q.jsxs)(du,{children:[(0,Q.jsx)(fu,{children:`Child directories`}),n.entries.map(e=>(0,Q.jsx)(pu,{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)(Mo,{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:Ec(e)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,title:e.pathLabel,children:e.pathLabel})]})]})},e.directoryToken))]}),(0,Q.jsx)(mu,{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)(ti,{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)(_t,{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)(Yt,{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)(An,{className:`size-3.5`}),`Adding project…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jo,{className:`size-3.5`}),`Add project`]})})]})]})})}function vu({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:ri}]),[v?.projectId,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dn,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,Q.jsxs)(On,{children:[(0,Q.jsx)(kn,{children:`Rename session`}),(0,Q.jsx)(In,{children:`Choose a local display title for this Fleet Prime session.`}),(0,Q.jsx)(Ji,{value:c,onChange:e=>l(e.target.value),"aria-label":`Session title`,autoFocus:!0}),(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Vn,{children:`Cancel`}),(0,Q.jsx)(zn,{disabled:!c.trim(),onClick:()=>{o&&c.trim()&&(t(o.sessionId,c.trim()),s(null))},children:`Rename`})]})]})}),(0,Q.jsx)(Dn,{open:u!==null,onOpenChange:e=>!e&&d(null),children:(0,Q.jsxs)(On,{children:[(0,Q.jsx)(kn,{children:`Rename project`}),(0,Q.jsx)(In,{children:`This changes the display name only. The registered directory stays the same.`}),(0,Q.jsx)(Ji,{value:f,onChange:e=>p(e.target.value),"aria-label":`Project name`,autoFocus:!0}),(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Vn,{children:`Cancel`}),(0,Q.jsx)(zn,{disabled:!f.trim()||!r,onClick:()=>{u&&f.trim()&&(r?.(u.projectId,f.trim()),d(null))},children:`Rename`})]})]})}),(0,Q.jsx)(Dn,{open:m!==null,onOpenChange:e=>!e&&h(null),children:(0,Q.jsxs)(On,{children:[(0,Q.jsx)(kn,{children:`Delete session?`}),(0,Q.jsx)(In,{children:`This removes the Fleet Prime session and its managed session artifacts. This cannot be undone.`}),(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Vn,{children:`Cancel`}),(0,Q.jsx)(zn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{m&&n(m.sessionId),h(null)},children:`Delete`})]})]})}),(0,Q.jsx)(Dn,{open:g!==null,onOpenChange:e=>!e&&_(null),children:(0,Q.jsxs)(On,{children:[(0,Q.jsx)(kn,{children:`Unregister project?`}),(0,Q.jsx)(In,{children:`The directory and its sessions remain intact. Existing sessions will move to Unassigned until the directory is registered again.`}),(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Vn,{children:`Cancel`}),(0,Q.jsx)(zn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{g&&i?.(g.projectId),_(null)},children:`Unregister`})]})]})}),(0,Q.jsx)(tn,{open:v!==null,onOpenChange:e=>!e&&y(null),children:(0,Q.jsxs)(Zt,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Qt,{children:`Fork session into project`}),(0,Q.jsx)(en,{children:`Create a new Fleet Prime session in another registered project.`})]}),(0,Q.jsx)(`div`,{className:`py-2`,children:(0,Q.jsx)(pn,{value:b??null,onValueChange:e=>x(e),options:S,placeholder:`Select a project…`,"aria-label":`Target project`})}),(0,Q.jsxs)(Yt,{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 yu(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_u,{...e}),(0,Q.jsx)(vu,{...e})]})}function bu({data:e,sessionActions:t,projectActions:n={},navigationActions:r={},slots:i={}}){let{sessions:a,projects:o=hc,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=Ac(c),{loadDirectories:T,projectById:E,sortedProjects:D,sidebarItems:O,resumeResource:k,toggleProjectResource:A,selectSearchResult:j,renderMenu:M,submitCreate:N}=Lc({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)(eu,{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)(yu,{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 xu=(0,Z.createContext)(void 0),Su=(0,Z.createContext)({animateIn:!0,variant:`soft`}),Cu=(0,Z.createContext)(()=>{});function wu(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&(n.current=t)}}var Tu={duration:.12,ease:We,delay:.04},Eu={type:`spring`,stiffness:520,damping:27,mass:.52};function Du({variant:e=`soft`,align:t,animateIn:n=!1,className:r,children:i,initial:a,animate:o,exit:s,transition:c,layout:l,...u}){let d=W()??!1,f=(0,Z.useContext)(xu),p=t??f??`start`,m=(0,Z.useMemo)(()=>({align:p,animateIn:n,variant:e}),[n,p,e]);return(0,Q.jsx)(Su.Provider,{value:m,children:(0,Q.jsx)(G.div,{"data-slot":`message-bubble`,"data-align":p,"data-variant":e,layout:l,initial:a??!1,animate:o,exit:s??(d?{opacity:0}:{opacity:0,y:-3,scale:.99}),transition:c??(d?{duration:.12}:He),className:K(`group/bubble flex w-full flex-col`,p===`end`?`items-end`:`items-start`,r),...u,children:i})})}function Ou(e,t){return K(`relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-sm leading-6 text-foreground`,`[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5`,e===`solid`&&`text-background`,e===`ghost`&&`w-full max-w-none rounded-none px-0 py-0`,e===`danger`&&`text-destructive`,t&&`cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]`)}function ku(e,t){return K(`pointer-events-none absolute inset-0 -z-10 rounded-[inherit]`,t===`end`?`origin-bottom-right`:`origin-bottom-left`,e===`solid`&&`bg-foreground`,e===`soft`&&`bg-muted`,e===`tint`&&`bg-primary/10`,e===`outline`&&`border border-border/70 bg-background`,e===`danger`&&`bg-destructive/10`)}function Au({render:e,className:t,children:n,ref:r,...i}){let a=W()??!1,{align:o=`start`,animateIn:s,variant:c}=(0,Z.useContext)(Su),[l,u]=(0,Z.useState)(0),d=(0,Z.useCallback)(()=>u(e=>e+1),[]),f=e?.type===`button`||e?.type===`a`,p=K(Ou(c,f),t),m=(0,Q.jsxs)(Q.Fragment,{children:[c===`ghost`?null:(0,Q.jsx)(G.span,{"aria-hidden":`true`,layout:!a&&`size`,layoutDependency:l,initial:s&&!a?{opacity:0,scale:.92}:!1,animate:{opacity:1,scale:1},transition:a?{duration:0}:{opacity:{duration:.12,ease:We},scale:Eu,layout:He},className:ku(c,o)}),(0,Q.jsx)(Cu.Provider,{value:d,children:(0,Q.jsx)(G.div,{initial:s?{opacity:0}:!1,animate:{opacity:1},transition:a?{duration:.12,ease:We}:Tu,className:`relative`,children:n})})]});if(e){let t=e;return(0,Z.cloneElement)(t,{...i,ref:wu(t.props.ref,r),className:K(p,t.props.className),children:m,"data-slot":`message-bubble-content`})}return(0,Q.jsx)(`div`,{ref:r,"data-slot":`message-bubble-content`,className:p,...i,children:m})}function ju({item:e}){return(0,Q.jsxs)(`div`,{"data-slot":`preview-rail-card`,className:`rounded-2xl border border-border bg-card p-4 shadow-sm`,children:[(0,Q.jsx)(`p`,{"data-slot":`preview-rail-title`,className:`font-medium text-card-foreground`,children:e.label}),e.description?(0,Q.jsx)(`div`,{"data-slot":`preview-rail-description`,className:`mt-1 text-sm leading-6 text-muted-foreground`,children:e.description}):null]})}function Mu({items:e,label:t=`Section navigation`,orientation:n=`vertical`,activeId:r,defaultActiveId:i,onActiveChange:a,onItemSelect:o,renderPreview:s,showPreview:c=!0,previewSide:l=`after`,highlightActive:u=!1,itemSize:d=24,children:f,className:p,railClassName:m,previewContainerClassName:h,previewClassName:g}){let _=(0,Z.useId)(),v=W(),y=ur(),[b,x]=(0,Z.useState)(i??e[0]?.id??``),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=r??b,D=e.some(e=>e.id===E)?E:e[0]?.id??``,O=S??w??``,k=O||(u?D:``),A=e.findIndex(e=>e.id===k),j=e.length?`repeat(${e.length}, ${d}px)`:void 0,M=n===`horizontal`,N=e=>{r===void 0&&x(e),a?.(e)};return(0,Q.jsxs)(G.div,{layoutRoot:!0,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||T(null)},className:K(`isolate relative flex w-full overflow-visible`,M?`min-h-64 flex-col items-center justify-center`:`min-h-80`,p),children:[(0,Q.jsx)(`nav`,{"aria-label":t,onPointerLeave:()=>C(null),style:M?{gridTemplateColumns:j}:{gridTemplateRows:j},className:K(`relative z-10 grid shrink-0`,M?`h-12 w-fit max-w-full self-center justify-center`:`w-12 content-center`,m),children:e.map((e,t)=>{let n=e.id===D,r=e.id===k,i=A<0?1/0:Math.abs(t-A),a=r?1:i===1?.68:i===2?.44:.25,s=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(G.span,{"data-slot":`preview-rail-tick`,"aria-hidden":`true`,animate:M?{scaleY:a}:{scaleX:a},transition:v?{duration:0}:He,className:K(`block bg-current`,M?`h-12 w-0.5 origin-bottom`:`h-0.5 w-12 origin-left`,r?`text-foreground`:void 0)})}),c=K(`relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,M?`h-12 w-6 items-end justify-center`:`h-6 w-12 items-center`),l=M?{width:d}:{height:d},u=()=>{y&&C(e.id)},f=t=>{t.matches(`:focus-visible`)&&T(e.id)},p=()=>{N(e.id),o?.(e)};return e.href?(0,Q.jsx)(`a`,{"data-slot":`preview-rail-item`,href:e.href,target:e.target,rel:e.rel??(e.target===`_blank`?`noreferrer noopener`:void 0),"aria-label":e.ariaLabel??e.label,"aria-current":n?`page`:void 0,onPointerEnter:u,onMouseEnter:u,onPointerDown:()=>T(null),onFocus:e=>f(e.currentTarget),onClick:p,style:l,className:c,children:s},e.id):(0,Q.jsx)(`button`,{"data-slot":`preview-rail-item`,type:`button`,"aria-label":e.ariaLabel??e.label,"aria-current":n?`location`:void 0,onPointerEnter:u,onMouseEnter:u,onPointerDown:()=>T(null),onFocus:e=>f(e.currentTarget),onClick:p,style:l,className:c,children:s},e.id)})}),c?(0,Q.jsx)(`div`,{"aria-hidden":`true`,style:M?{gridTemplateColumns:j}:{gridTemplateRows:j},className:K(`pointer-events-none absolute z-50 grid`,M?`top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center`:l===`before`?`inset-y-0 right-16 left-4 content-center`:`inset-y-0 right-4 left-16 content-center`,h),children:e.map(e=>(0,Q.jsx)(`div`,{style:M?{width:d}:{height:d},className:K(`relative flex items-center`,M?`justify-center`:void 0),children:(0,Q.jsx)(Pe,{mode:`wait`,initial:!1,children:e.id===O?(0,Q.jsx)(G.div,{initial:v?{opacity:0}:{opacity:0,y:4,filter:`blur(6px)`},animate:v?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:v?{opacity:0}:{opacity:0,y:-2,filter:`blur(4px)`,transition:{duration:.12,ease:We}},transition:{duration:v?0:.18,ease:We},className:K(M?`absolute bottom-12 left-1/2 w-72 -translate-x-1/2`:K(`w-full max-w-sm`,l===`before`&&`ml-auto`),g),children:(0,Q.jsx)(G.div,{layoutId:`preview-rail-card-${_}`,transition:v?{duration:0}:He,children:s?s(e):(0,Q.jsx)(ju,{item:e})})},e.id):null})},e.id))}):null,f?(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:f}):null]})}var Nu=56,Pu=88;function Fu(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.lastIndexOf(` `);return`${n.slice(0,r>t*.65?r:t).trim()}…`}function Iu(e){return((e.querySelector(`[data-slot="message-bubble-content"]`)??e.querySelector(`[data-slot="message-content"]`)??e).textContent??``).replace(/\s+/g,` `).trim()}function Lu(e,t){let n=Iu(e);if(!n)return{label:`Message`,description:void 0};if(n.length<=Nu){let e=t?Iu(t):``;return{label:n,description:e?Fu(e,Pu):void 0}}let r=n.slice(0,Nu).lastIndexOf(` `),i=r>Nu*.65?r:Nu,a=`${n.slice(0,i).trim()}…`,o=t?Iu(t):n.slice(i).trim();return{label:a,description:o?Fu(o,Pu):void 0}}function Ru({navigation:e,followThreshold:t,contentRef:n,viewportRef:r,reduce:i,smooth:a,scrollToEnd:o,setFollowing:s,markProgrammaticScroll:c}){let l=(0,Z.useRef)(void 0),u=(0,Z.useRef)(new WeakMap),d=(0,Z.useRef)(0),f=(0,Z.useRef)(new Map),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),y=(0,Z.useCallback)(()=>{if(e!==`rail`)return;let n=r.current,i=[...f.current.entries()];if(!n||i.length===0)return;let a=n.getBoundingClientRect();if(n.scrollTop<=t){let e=i[0]?.[0]??``;g(t=>t===e?t:e);return}if(n.scrollHeight-n.scrollTop-n.clientHeight<=t){let e=i.at(-1)?.[0]??``;g(t=>t===e?t:e);return}let o=a.top+a.height/2,s=i[0]?.[0]??``,c=1/0;for(let[e,t]of i){let n=t.getBoundingClientRect(),r=Math.abs(n.top+n.height/2-o);r<c&&(c=r,s=e)}g(e=>e===s?e:s)},[t,e,r]),b=(0,Z.useCallback)(()=>{if(e!==`rail`)return;let t=n.current,i=r.current;if(!t||!i)return;let a=Array.from(t.querySelectorAll(`[data-slot="message"]`)),o=new Map,s=a.map((e,t)=>{let n=u.current.get(e);n||(d.current+=1,n=`message-rail-${d.current}`,u.current.set(e,n)),o.set(n,e);let r=e.dataset.from??`conversation`,i=Lu(e,r===`user`?a.slice(t+1).find(e=>e.dataset.from===`assistant`):void 0);return{id:n,label:i.label,description:i.description,ariaLabel:`Go to ${r} message ${t+1} of ${a.length}`}});f.current=o,m(e=>e.length===s.length&&e.every((e,t)=>e.id===s[t]?.id&&e.label===s[t]?.label&&e.description===s[t]?.description&&e.ariaLabel===s[t]?.ariaLabel)?e:s),v(i.scrollHeight>i.clientHeight+1&&a.length>1)},[n,e,r]),x=(0,Z.useCallback)(()=>{e===`rail`&&(l.current&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{b(),y()}))},[e,b,y]);return(0,Z.useEffect)(()=>{if(e!==`rail`){f.current.clear(),m([]),v(!1);return}let t=n.current,i=r.current;if(!t||!i)return;x();let a=typeof MutationObserver>`u`?null:new MutationObserver(x);a?.observe(t,{childList:!0,characterData:!0,subtree:!0});let o=typeof ResizeObserver>`u`?null:new ResizeObserver(x);return o?.observe(t),o?.observe(i),()=>{a?.disconnect(),o?.disconnect()}},[n,e,x,r]),(0,Z.useEffect)(()=>()=>{l.current&&cancelAnimationFrame(l.current)},[]),{activeRailId:h,railItems:p,railOverflowing:_,scheduleRailSync:x,scrollToRailItem:(0,Z.useCallback)(e=>{let t=r.current,n=f.current.get(e.id);if(!t||!n)return;let l=p.at(-1)?.id===e.id;if(g(e.id),l){s(!0),o(i||!a?`auto`:`smooth`);return}s(!1),c(i||!a?`auto`:`smooth`);let u=t.getBoundingClientRect(),d=n.getBoundingClientRect(),m=t.scrollTop+d.top-u.top-(t.clientHeight-d.height)/2,h=i||!a?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({top:m,behavior:h}):t.scrollTop=m},[c,p,i,o,s,a,r])}}function zu({followOutput:e=!0,followThreshold:t=56,smooth:n=!0,onFollowChange:r,label:i=`Conversation`,busy:a,navigation:o,navigationLabel:s=`Message navigation`,viewportClassName:c,contentClassName:l,railClassName:u,viewportRef:d,viewportProps:f,contentProps:p,className:m,children:h,...g}){let _=W()??!1,v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(e),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(void 0),C=(0,Z.useRef)(void 0),{onScroll:w,onWheel:T,onTouchStart:E,onKeyDown:D,...O}=f??{},k=(0,Z.useCallback)(e=>{v.current=e,typeof d==`function`?d(e):d&&(d.current=e)},[d]),A=(0,Z.useCallback)(e=>{b.current!==e&&(b.current=e,r?.(e))},[r]),j=(0,Z.useCallback)(e=>{x.current=!0,S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{x.current=!1},e===`smooth`?320:0)},[]),M=(0,Z.useCallback)(e=>{let t=v.current;t&&(j(e),typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)},[j]),{activeRailId:N,railItems:P,railOverflowing:F,scheduleRailSync:I,scrollToRailItem:L}=Ru({navigation:o,followThreshold:t,contentRef:y,viewportRef:v,reduce:_,smooth:n,scrollToEnd:M,setFollowing:A,markProgrammaticScroll:j}),R=(0,Z.useEffectEvent)(I),z=(0,Z.useEffectEvent)(M),B=(0,Z.useCallback)(()=>{let e=v.current;if(!e||x.current)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight;A(n<=t),I()},[t,I,A]),V=(0,Z.useCallback)(()=>{x.current=!1},[]);(0,Z.useLayoutEffect)(()=>{if(b.current=e,e)return C.current=requestAnimationFrame(()=>z(`auto`)),()=>{C.current&&cancelAnimationFrame(C.current)}},[e]),(0,Z.useEffect)(()=>{let t=y.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{R(),!(!e||!b.current)&&z(_||!n?`auto`:`smooth`)});return r.observe(t),()=>r.disconnect()},[e,_,n]),(0,Z.useEffect)(()=>()=>{S.current&&window.clearTimeout(S.current),C.current&&cancelAnimationFrame(C.current)},[]);let H=(0,Q.jsx)(`section`,{ref:k,"aria-label":i,...O,onScroll:e=>{B(),w?.(e)},onWheel:e=>{V(),T?.(e)},onTouchStart:e=>{V(),E?.(e)},onKeyDown:e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)&&V(),D?.(e)},className:K(`h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,o===`rail`?`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`[scrollbar-gutter:stable]`,c,o===`rail`&&F&&`pr-10`),children:(0,Q.jsx)(`div`,{ref:y,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-busy":a,className:l,...p,children:h})});return(0,Q.jsx)(`div`,{"data-slot":`message-scroller`,className:K(`min-h-0`,m),...g,children:o===`rail`?(0,Q.jsx)(Mu,{items:F?P:[],label:s,activeId:N,onItemSelect:L,previewSide:`before`,highlightActive:!0,itemSize:14,className:`h-full min-h-0 overflow-hidden`,previewContainerClassName:`right-8 left-3`,previewClassName:`mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4`,railClassName:K(`absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right`,F?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`,u),children:H}):H})}var Bu=(0,Z.createContext)({from:`assistant`}),Vu={type:`spring`,stiffness:480,damping:32,mass:.62};function Hu({from:e,animateIn:t=!1,children:n,className:r,initial:i,animate:a,transition:o,exit:s,style:c,...l}){let u=W()??!1,d=(0,Z.useMemo)(()=>({from:e}),[e]);return(0,Q.jsx)(xu.Provider,{value:e===`user`?`end`:`start`,children:(0,Q.jsx)(Bu.Provider,{value:d,children:(0,Q.jsx)(G.article,{"data-slot":`message`,"data-from":e,"aria-label":l[`aria-label`]??`${e} message`,initial:i??(t&&!u?{opacity:0,transform:`translateY(8px) scale(0.95)`}:!1),animate:a??(t&&!u?{opacity:1,transform:`translateY(0px) scale(1)`}:{opacity:1}),exit:s??(u?{opacity:0}:{opacity:0,transform:`translateY(-3px) scale(0.99)`}),transition:o??(u?{duration:.12}:Vu),style:{transformOrigin:e===`user`?`100% 100%`:`0% 100%`,...c},className:K(`group/message flex w-full items-start gap-2`,e===`user`?`flex-row-reverse`:`flex-row`,r),...l,children:n})})})}function Uu({className:e,...t}){let{from:n}=(0,Z.useContext)(Bu);return(0,Q.jsx)(`div`,{"data-slot":`message-content`,className:K(`flex min-w-0 flex-1 flex-col gap-1.5`,n===`user`?`items-end`:`items-start`,e),...t})}var Wu=[];function Gu({label:e,active:t=!1,onClick:n,children:r}){let i=W()??!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:K(`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 Ku({children:e,status:t=`streaming`,copyText:n,onCopy:r,onRetry:i,sources:a=Wu,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=W()??!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:K(`w-full`,h),children:[(0,Q.jsx)(`div`,{"aria-live":p?`polite`:`off`,className:K(`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)(Pe,{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:We},className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:K(`flex items-center gap-0.5`,_),children:[j?(0,Q.jsx)(Gu,{label:b?`Copied`:`Copy response`,onClick:I,children:b?(0,Q.jsx)(Cr,{className:`size-3.5`}):(0,Q.jsx)(Fr,{className:`size-3.5`})}):null,i?(0,Q.jsx)(Gu,{label:`Retry response`,onClick:i,children:(0,Q.jsx)(li,{className:`size-3.5`})}):null,A?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gu,{label:`Helpful`,active:D===`up`,onClick:()=>L(`up`),children:(0,Q.jsx)(Go,{className:`size-3.5`})}),(0,Q.jsx)(Gu,{label:`Not helpful`,active:D===`down`,onClick:()=>L(`down`),children:(0,Q.jsx)(Wo,{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)(hr,{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}:Ge,className:`text-muted-foreground/50 group-hover:text-muted-foreground`,children:(0,Q.jsx)(Tr,{className:`size-3`})})]}):null]}),M?(0,Q.jsx)(Mr,{id:P,open:O,children:(0,Q.jsx)(fr,{citations:a,idPrefix:F,className:`mt-2 rounded-xl bg-muted p-2`})}):null]}):null})]})}var qu=`@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}}`,Ju=`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 Yu(e){return{animation:`beui-text-shimmer ${e}s linear infinite`}}function Xu({children:e,as:t=`span`,duration:n=2.5,className:r}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`style`,{children:qu}),(0,Q.jsx)(t,{style:Yu(n),className:K(`inline-block`,Ju,r),children:e})]})}function Zu({children:e=`Thinking…`,duration:t=1.8,className:n}){return(0,Q.jsx)(Xu,{as:`span`,duration:t,className:K(`font-medium`,n),children:e})}function Qu({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)(Cr,{className:`size-4`,strokeWidth:1.8}):t===`active`?(0,Q.jsxs)(`span`,{className:`relative grid size-3 place-items-center`,children:[(0,Q.jsx)(Be.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)(wo,{className:`size-3`,strokeWidth:1.5})}),(0,Q.jsx)(`span`,{className:K(`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 $u({item:e}){return(0,Q.jsx)(`div`,{className:`rounded-md px-1.5 py-1 leading-5 text-muted-foreground`,children:e.content})}function ed({result:e}){let t=e.url&&Or(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)(ir,{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=K(`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 td({item:e}){let t=W()??!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:We},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)(ui,{"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)(Pe,{initial:!0,mode:`popLayout`,children:e.results.map(e=>(0,Q.jsx)(Be.div,{layout:`position`,initial:n,animate:r,exit:i,transition:a,children:(0,Q.jsx)(ed,{result:e})},e.id))})}):null,(0,Q.jsx)(Pe,{initial:!0,children:e.moreCount?(0,Q.jsxs)(Be.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 nd({action:e}){return e===`read`?(0,Q.jsx)(Ar,{className:`size-4`}):e===`edit`||e===`write`?(0,Q.jsx)(zo,{className:`size-4`}):e===`run`?(0,Q.jsx)(zr,{className:`size-4`}):(0,Q.jsx)(Lr,{className:`size-4`})}function rd({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 id({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)(nd,{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)(rd,{action:e.openAction}):null]}):null]})}function ad({kind:e}){return e===`thinking`?(0,Q.jsx)(Vr,{className:`size-4`}):e===`message`?(0,Q.jsx)(bn,{className:`size-4`}):e===`write`?(0,Q.jsx)(zo,{className:`size-4`}):e===`run`?(0,Q.jsx)(zr,{className:`size-4`}):e===`read`?(0,Q.jsx)(Po,{className:`size-4`}):(0,Q.jsx)(Lr,{className:`size-4`})}function od({item:e}){let t=e.kind===`thinking`;return(0,Q.jsxs)(`div`,{className:K(`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)(ad,{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:K(`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)(rd,{action:e.action}):null]})}function sd({item:e}){return e.type===`text`?(0,Q.jsx)($u,{item:e}):e.type===`search`?(0,Q.jsx)(td,{item:e}):e.type===`tool`?(0,Q.jsx)(id,{item:e}):e.type===`trace`?(0,Q.jsx)(od,{item:e}):(0,Q.jsx)(Qu,{item:e})}function cd(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 ld({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 ud(e){let t=e[0]?.type;return t&&e.every(e=>e.type===t)?t:`mixed`}function dd(e){return e===`search`?`Searching the web…`:e===`tool`?`Running tools…`:e===`trace`?`Working through the run…`:e===`mixed`?`Working through it…`:`Thinking…`}function fd(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:cd(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 pd({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=W()??!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]=ld({open:i,defaultOpen:a,onOpenChange:o}),E=n===`working`,D=E||w,O=e.length?ud(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??dd(O),P=l??fd(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:K(`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)(Zu,{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)(Be.span,{"aria-hidden":`true`,animate:{rotate:D?180:0},transition:h?{duration:0}:Ge,className:`inline-flex shrink-0 text-muted-foreground/70 group-hover:text-foreground`,children:(0,Q.jsx)(Tr,{className:`size-3.5`})})]}),(0,Q.jsx)(Mr,{id:v,role:`region`,"aria-labelledby":_,open:D,openHeight:k,children:(0,Q.jsx)(`div`,{ref:b,className:K(`scrollbar-hide pr-1`,A&&D&&!E?`overflow-y-auto`:`overflow-y-hidden`),style:{height:k,maskImage:F,WebkitMaskImage:F},children:(0,Q.jsx)(Be.div,{ref:y,role:`list`,initial:!1,animate:{y:j},transition:h?{duration:0}:He,className:K(`space-y-0.5 py-2`,m),children:(0,Q.jsx)(Pe,{mode:`popLayout`,children:e.map(e=>(0,Q.jsx)(Be.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:We},y:He,layout:He},children:(0,Q.jsx)(sd,{item:e})},e.id))})})})})]})}function md({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:K(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:K(sr,`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 hd=(0,Z.memo)(function({title:e=`Something went wrong`,message:t,className:n}){return(0,Q.jsx)(`div`,{className:K(`flex justify-start`,n),children:(0,Q.jsxs)(`div`,{className:`rounded-[8px] border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm text-an-foreground`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-an-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-an-foreground-muted`,children:t})]})})});function gd(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function _d({part:e}){let t=gd(e.payload);return(0,Q.jsxs)(`section`,{"data-payload-kind":e.kind,className:`w-full min-w-0 overflow-hidden rounded-xl border border-border/60 bg-muted/40 text-sm`,children:[(0,Q.jsx)(`div`,{className:`border-b border-border/50 px-3 py-2 text-xs font-medium text-muted-foreground`,children:e.title}),e.text?(0,Q.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words px-3 py-3 font-mono text-xs leading-5 text-foreground/80`,children:e.text}):null,t?(0,Q.jsxs)(`details`,{open:!0,className:`border-t border-border/50 px-3 py-2`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted-foreground`,children:`Payload`}),(0,Q.jsx)(`pre`,{className:`m-0 mt-2 max-w-full whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground/70`,children:t})]}):null]})}function vd(e){return typeof e==`object`&&!!e}function yd(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;try{let n=JSON.parse(t);return vd(n)||Array.isArray(n)?n:e}catch{return e}}function bd(e){if(!vd(e)||typeof e.type!=`string`||!e.type.startsWith(`tool-`))return e;let t=yd(e.input),n=yd(e.output),r=yd(e.result),i=t!==e.input,a=n!==e.output,o=r!==e.result;if(!i&&!a&&!o)return e;let s={...e};return i&&(s.input=t),a&&(s.output=n),o&&(s.result=r),s}function xd(e){let t=!1,n=e.map(e=>{let n=bd(e);return n!==e&&(t=!0),n});return t?n:e}var Sd=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),Cd=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`});function wd(e){let t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()?Sd.format(e):Cd.format(e)}function Td({text:e,onCopied:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>()=>{i.current&&window.clearTimeout(i.current)},[]),(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":n?`Copied`:`Copy message`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{r(!1),i.current=null},2e3),Nn.success(`Copied to clipboard`),t?.()}catch{Nn.error(`Failed to copy to clipboard`)}},onPointerDown:e=>{e.stopPropagation()},onMouseDown:e=>e.stopPropagation(),className:K(`flex size-6 items-center justify-center rounded-md transition-[background-color,opacity,transform] duration-150 ease-out active:scale-[0.97]`,`bg-transparent opacity-50 hover:bg-an-foreground/10 hover:opacity-100`),children:(0,Q.jsxs)(`div`,{className:`relative h-3.5 w-3.5`,children:[(0,Q.jsx)(Fr,{className:K(`absolute inset-0 h-3.5 w-3.5 text-an-foreground-muted transition-[opacity,transform] duration-150 ease-out`,n?`scale-50 opacity-0`:`scale-100 opacity-100`)}),(0,Q.jsx)(Cr,{className:K(`absolute inset-0 h-3.5 w-3.5 text-an-foreground-muted transition-[opacity,transform] duration-150 ease-out`,n?`scale-100 opacity-100`:`scale-50 opacity-0`)})]})})}function Ed({text:e,timestamp:t,heightClass:n,hoverClass:r,isVisible:i,alignClass:a,onCopied:o}){return(0,Q.jsxs)(`div`,{className:K(`pointer-events-none flex items-center gap-1 pt-1 text-xs text-an-foreground-muted/70 opacity-0 transition-opacity duration-100`,n,a,r,i&&`pointer-events-auto opacity-100`),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[t&&(0,Q.jsx)(`span`,{children:t}),e&&(0,Q.jsx)(Td,{text:e,onCopied:o})]})}function Dd(e){return typeof e==`object`&&!!e}function Od(e){return Dd(e)&&e.type===`text`&&typeof e.text==`string`}function kd(e){return Dd(e)&&e.type===`error`&&typeof e.message==`string`}function Ad(e){return Dd(e)&&e.type===`payload`&&typeof e.kind==`string`&&typeof e.title==`string`}function jd(e){if(!Dd(e))return!1;let t=e.type;return t===`dynamic-tool`||typeof t==`string`&&t.startsWith(`tool-`)}function Md(e,t){let n=[];for(let t of e)Od(t)&&n.push(t.text);return n.join(t)}(0,Z.memo)(function(e){let{message:t,UserMessageComponent:n,userMessageClassName:r,onCopied:i,display:a}=e,{enableImagePreview:o,showCopyToolbar:s,isMounted:c,isCopyVisible:l}=a,u=Md(t.parts??[],``),d=(t.parts??[]).length>0;if(!u&&!d)return null;let f=t?.createdAt,p=`user-${t.id}`,m=c&&f?wd(new Date(f)):void 0;return(0,Q.jsxs)(`div`,{className:`group/user-message`,children:[(0,Q.jsx)(n,{message:t,className:r,enableImagePreview:o}),(s&&!!u||!!m)&&(0,Q.jsx)(Ed,{text:s?u:``,timestamp:m,heightClass:`h-[28px]`,hoverClass:`group-hover/user-message:opacity-100 group-hover/user-message:pointer-events-auto`,isVisible:l,alignClass:`justify-end`,onCopied:()=>i(p)})]})}),(0,Z.memo)(function(e){let{assistantMsgs:t,turnKey:n,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c,onCopied:l,stream:u,copy:d,display:f}=e,{isLast:p,isStreaming:m}=u,{enabled:h,isVisible:g}=d,{suppressQuestionTool:_}=f,v=Md(t.flatMap(e=>e.parts??[]),`
|
|
3
|
-
|
|
4
|
-
`),y=m&&p,b=h&&!!v.trim()&&!y,x=`assistant-${n}-all`,S=h?v:``;return(0,Q.jsxs)(`div`,{className:`group/assistant-turn`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:t.map((e,n)=>{let l=p&&n===t.length-1;return(0,Q.jsx)(Ld,{msg:e,isLast:l,isStreaming:m,suppressQuestionTool:_,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c},e.id)})}),(b||g)&&(0,Q.jsx)(Ed,{text:S,heightClass:`h-[48px] flex items-start w-full`,hoverClass:`group-hover/assistant-turn:opacity-100 group-hover/assistant-turn:pointer-events-auto`,isVisible:g,alignClass:`justify-start`,onCopied:()=>l(x)})]})});var Nd=`tool-call:`,Pd=`unkeyed-tool:`;function Fd(e,t,n){return t.toolCallId?`${Nd}${t.toolCallId}`:`${Pd}${e}:${t.type}:${n}`}function Id(e,t){let{messageId:n,isLast:r,isStreaming:i,suppressQuestionTool:a,suppressTextWhenPlanWrite:o=!1,ToolRendererComponent:s,TextRendererComponent:c,toolRenderers:l,onOpenUIAction:u,onOpenUIArtifactReady:d,onOpenArtifact:f}=t,p=[],m=[],h=o&&e.some(e=>jd(e)&&e.type===`tool-PlanWrite`),g=new Set(e.filter(e=>jd(e)&&(e.type===`tool-Task`||e.type===`tool-Agent`)&&typeof e.toolCallId==`string`).map(e=>e.toolCallId)),_=new Map,v=new Set,y=new Map;for(let t of e){if(!jd(t)||t.type===`tool-TaskOutput`||!t.toolCallId||!t.toolCallId.includes(`:`))continue;let e=t.toolCallId.split(`:`)[0];g.has(e)&&(_.has(e)||_.set(e,[]),_.get(e).push(t),v.add(t.toolCallId))}let b=0;for(;b<e.length;){let t=e[b];if(jd(t)&&t.type===`tool-TaskOutput`){b++;continue}if(Od(t)){let e=t.text;e&&!h&&m.push(e),b++;continue}if(kd(t)){p.push((0,Q.jsx)(hd,{title:t.title,message:t.message},`${n}-error-${t.title}-${t.message}`)),b++;continue}if(Ad(t)){p.push((0,Q.jsx)(_d,{part:t},`${n}-payload-${b}`)),b++;continue}if(jd(t)){if(a&&t.type===`tool-Question`){b++;continue}if(t.toolCallId&&v.has(t.toolCallId)){b++;continue}let e=r&&i?`streaming`:void 0,o=t.toolCallId,c=(t.type===`tool-Task`||t.type===`tool-Agent`)&&o?_.get(o)||[]:void 0,u=t.toolCallId?0:y.get(t.type)??0;t.toolCallId||y.set(t.type,u+1),p.push((0,Q.jsx)(s,{part:t,nestedTools:c,chatStatus:e,toolRenderers:l},Fd(n,t,u))),b++;continue}b++}let x=m.join(`
|
|
5
|
-
|
|
6
|
-
`);return x&&p.push((0,Q.jsx)(`div`,{className:`group/assistant-text text-[14px]`,children:(0,Q.jsx)(c,{content:x,isStreaming:i,messageId:n,onOpenUIAction:u,onOpenUIArtifactReady:d,onOpenArtifact:f,className:`leading-relaxed [&_p]:leading-relaxed`})},`${n}-text-final`)),p}function Ld({msg:e,isLast:t,isStreaming:n,suppressQuestionTool:r,ToolRendererComponent:i,TextRendererComponent:a,toolRenderers:o,onOpenUIAction:s,onOpenUIArtifactReady:c,onOpenArtifact:l}){let u=(0,Z.useMemo)(()=>xd(e.parts??[]),[e.parts]),d=(0,Z.useMemo)(()=>Id(u,{messageId:e.id,isLast:t,isStreaming:n,suppressQuestionTool:r,ToolRendererComponent:i,TextRendererComponent:a,toolRenderers:o,onOpenUIAction:s,onOpenUIArtifactReady:c,onOpenArtifact:l}),[u,e.id,t,n,r,i,a,o,s,c,l]);return d.length>1?(0,Q.jsx)(`div`,{className:`group/assistant-turn flex flex-col gap-3`,children:d}):(0,Q.jsx)(`div`,{className:`group/assistant-turn`,children:d})}function Rd({open:e,onClose:t,images:n,initialIndex:r=0}){let[i,a]=(0,Z.useState)(r),o=n.length>1;(0,Z.useEffect)(()=>{e&&a(r)},[e,r]);let s=(0,Z.useCallback)(e=>{e?.stopPropagation(),a(e=>e>0?e-1:n.length-1)},[n.length]),c=(0,Z.useCallback)(e=>{e?.stopPropagation(),a(e=>e<n.length-1?e+1:0)},[n.length]),l=(0,Z.useEffectEvent)(e=>{switch(e.key){case`ArrowLeft`:e.preventDefault(),o&&s();break;case`ArrowRight`:e.preventDefault(),o&&c()}});(0,Z.useEffect)(()=>{if(!e)return;let t=e=>l(e);return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let u=(0,Z.useRef)(null),d=(0,Z.useEffectEvent)(e=>{u.current&&e.target===u.current&&t()});if((0,Z.useEffect)(()=>{if(!e)return;let t=u.current;if(!t)return;t.open||t.showModal();let n=e=>d(e);return t.addEventListener(`click`,n),()=>{t.removeEventListener(`click`,n),t.open&&t.close()}},[e]),typeof document>`u`||!e)return null;let f=n[i]??n[0];return f?.url?(0,Is.createPortal)((0,Q.jsxs)(`dialog`,{ref:u,"aria-label":`Image viewer`,onClose:()=>t(),className:`fixed inset-0 z-50 m-0 flex h-full max-h-none w-full max-w-none items-center justify-center border-0 bg-black/90 p-0 backdrop:bg-transparent`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close fullscreen (Esc)`,className:`absolute top-4 right-4 z-10 inline-flex size-9 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,Q.jsx)(ft,{className:`size-5`})}),o&&(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Previous image (←)`,className:`absolute top-1/2 left-4 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,Q.jsx)(bo,{className:`size-6`})}),(0,Q.jsx)(`img`,{src:f.url,alt:f.filename??`Image preview`,className:`max-h-[85vh] max-w-[90vw] object-contain select-none`,onClick:e=>e.stopPropagation(),draggable:!1}),o&&(0,Q.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Next image (→)`,className:`absolute top-1/2 right-4 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,Q.jsx)(Er,{className:`size-6`})}),o&&(0,Q.jsxs)(`div`,{className:`absolute bottom-6 left-1/2 flex -translate-x-1/2 flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex gap-2`,children:n.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(t)},"aria-label":`Go to image ${t+1}`,className:K(`size-2 rounded-full transition-all`,t===i?`scale-125 bg-white`:`bg-white/40 hover:bg-white/60`)},e.url))}),(0,Q.jsxs)(`span`,{className:`text-sm text-white/70`,children:[i+1,` / `,n.length]})]})]}),document.body):null}function zd(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Bd(e,t){if(t)return`image`;let n=e.split(`.`).pop()?.toLowerCase();return[`js`,`ts`,`jsx`,`tsx`,`py`,`rb`,`go`,`rs`,`java`,`kt`,`swift`,`c`,`cpp`,`h`,`hpp`,`cs`,`php`].includes(n||``)?`code`:[`json`,`yaml`,`yml`,`xml`].includes(n||``)?`data`:`text`}function Vd(e){switch(e){case`image`:return(0,Q.jsx)(Po,{className:`size-4 text-muted-foreground`});case`code`:return(0,Q.jsx)(ko,{className:`size-4 text-muted-foreground`});case`data`:return(0,Q.jsx)(Oo,{className:`size-4 text-muted-foreground`});default:return(0,Q.jsx)(Ar,{className:`size-4 text-muted-foreground`})}}function Hd({id:e,filename:t,size:n,isImage:r,url:i,onRemove:a,className:o,display:s=`chip`,enableImagePreview:c=!0}){let[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=Bd(t,r),m=s===`image-only`&&r&&!!i,h=!!(c&&r&&i),g=e=>{e?.stopPropagation(),f(!0)};return(0,Q.jsxs)(`div`,{className:K(`relative rounded-[calc(var(--an-input-border-radius)-var(--an-context-padding))] bg-muted/50`,m?`flex size-10 items-center justify-center`:`flex max-w-[200px] min-w-[120px] items-center gap-2 py-1 pr-2 pl-1`,o),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:[m?(0,Q.jsx)(`div`,{className:K(`size-8 shrink-0 overflow-hidden rounded-[calc(var(--an-input-border-radius)-var(--an-context-padding)-2px)]`,h&&`cursor-pointer`),onClick:h?g:void 0,role:h?`button`:void 0,tabIndex:h?0:void 0,"aria-label":h?`Preview ${t}`:void 0,onKeyDown:h?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g())}:void 0,children:(0,Q.jsx)(`img`,{src:i,alt:t,className:`h-full w-full object-cover`})}):(0,Q.jsxs)(Q.Fragment,{children:[r&&i?(0,Q.jsx)(`div`,{className:K(`w-8 shrink-0 self-stretch overflow-hidden rounded-[calc(var(--an-input-border-radius)-var(--an-context-padding)-2px)]`,h&&`cursor-pointer`),onClick:h?g:void 0,role:h?`button`:void 0,tabIndex:h?0:void 0,"aria-label":h?`Preview ${t}`:void 0,onKeyDown:h?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g())}:void 0,children:(0,Q.jsx)(`img`,{src:i,alt:t,className:`aspect-square h-full w-full object-cover`})}):(0,Q.jsx)(`div`,{className:`flex w-8 shrink-0 items-center justify-center self-stretch rounded-[calc(var(--an-input-border-radius)-var(--an-context-padding)-2px)] bg-muted`,children:Vd(p)}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,title:t,children:t}),n!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:zd(n)})]})]}),a&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},"aria-label":`Remove ${t}`,className:`absolute -top-1.5 -right-1.5 z-10 flex size-4 items-center justify-center rounded-full border border-border bg-background text-muted-foreground transition-[opacity,transform] duration-150 ease-out hover:text-foreground active:scale-[0.97] ${l?`opacity-100`:`opacity-0`}`,type:`button`,children:(0,Q.jsx)(ft,{className:`size-3`})}),h&&i&&(0,Q.jsx)(Rd,{open:d,onClose:()=>f(!1),images:[{id:e,url:i,filename:t}]})]})}function Ud(e){return typeof e==`object`&&!!e}function Wd(e){if(!Ud(e))return null;let t=e.type;if(typeof t!=`string`)return null;if(t===`image`){let t=e;return t.url??t.image??null}if(t===`data-image`)return e.data?.url??null;if(t===`file`){let t=e;if(t.mimeType?.startsWith(`image/`)){if(t.url)return t.url;if(t.data)return`data:${t.mimeType};base64,${t.data}`}}return null}function Gd(e){if(!Ud(e)||e.type!==`file`)return null;let t=e,n=t.filename||t.name||t.fileName||`Attachment`;return t.mimeType?.startsWith(`image/`)??!1?null:{filename:n,size:t.size}}var Kd=(0,Z.memo)(function({message:e,className:t,enableImagePreview:n=!0}){let[r,i]=(0,Z.useState)(null),a=(e.parts?.filter(Od)??[]).map(e=>e.text).join(``),o=[],s=[];for(let t of e.parts??[]){let e=Wd(t);e&&o.push(e);let n=Gd(t);n&&s.push(n)}if(Ud(e)&&Array.isArray(e.experimental_attachments))for(let t of e.experimental_attachments)t.contentType?.startsWith(`image/`)&&t.url&&o.push(t.url);if(!a&&o.length===0&&s.length===0)return null;let c=o.map((t,n)=>({id:`${e.id}-img-${n}`,url:t,filename:`image-${n+1}`}));return(0,Q.jsxs)(`div`,{className:K(`flex flex-col items-end gap-1`,t),children:[o.length>0&&o.map((e,t)=>(0,Q.jsx)(`div`,{className:K(`max-w-[200px] rounded-an-message bg-an-foreground/4 p-1.5`,n&&`cursor-pointer`),onClick:n?()=>i(t):void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(t))}:void 0,children:(0,Q.jsx)(`img`,{src:e,alt:`attachment`,className:`block max-h-[120px] max-w-[184px] rounded-an-message-inner object-cover`})},e)),n&&c.length>0&&(0,Q.jsx)(Rd,{open:r!==null,onClose:()=>i(null),images:c,initialIndex:r??0}),s.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-col items-end gap-2`,children:s.map((e,t)=>(0,Q.jsx)(Hd,{id:`${e.filename}-${t}`,filename:e.filename,size:e.size},`${e.filename}-${e.size}`))}),a&&(0,Q.jsx)(`div`,{className:`ms-[70px] max-w-[calc(95%-40px)]`,children:(0,Q.jsx)(`div`,{className:`rounded-an-message bg-an-user-message-bg px-3.5 py-1.5 text-sm text-an-user-message-text transition-colors`,children:(0,Q.jsx)(`p`,{className:`leading-5 wrap-break-word whitespace-pre-wrap`,children:a})})})]})}),qd=(0,Z.lazy)(()=>di(async()=>{let{GenerativeTextRenderer:e}=await import(`./openui-renderer-NLUpAS3h.js`).then(e=>e.n);return{GenerativeTextRenderer: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])).then(({GenerativeTextRenderer:e})=>({default:e})));function Jd({className:e,content:t}){return(0,Q.jsx)(`div`,{className:e?`${e} whitespace-pre-wrap`:`whitespace-pre-wrap`,children:t})}function Yd(e){return(0,Z.useMemo)(()=>gi(e.content).some(e=>e.type===`openui`),[e.content])?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Jd,{className:e.className,content:e.content}),children:(0,Q.jsx)(qd,{...e})}):(0,Q.jsx)(rr,{className:e.className,content:e.content})}var Xd=[{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 Zd(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 Qd({label:e=`Churning`,elapsedSeconds:t,initialSeconds:n=0,running:r=!0,className:i}){let a=W()??!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:K(`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:Xd.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:Fe,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:Zd(c)})]})}function $d({label:e,className:t}){let n=W();if(!e?.trim())return null;let{kind:r,title:i,detail:a}=ef(e),o=tf(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:K(`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)(Qd,{label:i,running:!0,className:`min-w-0 text-xs`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(o,{className:K(`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 ef(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 tf(e){switch(e){case`queue`:return Fo;case`retry`:return li;case`compaction`:return No;case`recovery`:return kr;default:return To}}var nf={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`},rf={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`},af=(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=W(),u=ur(),[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:K(`inline-flex items-center justify-center font-medium select-none`,`transition-colors`,`disabled:pointer-events-none disabled:opacity-50`,r&&`relative overflow-hidden`,nf[e],rf[t],i),...s,children:[(0,Q.jsx)(`span`,{className:K(`pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]`,!r&&`hidden`),children:(0,Q.jsx)(Pe,{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:We},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=W(),c=ur();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:K(`inline-flex items-center justify-center font-medium select-none`,`transition-colors`,nf[e],rf[t],r),...a,children:i})});function of({children:e,strength:t=.35,className:n}){let r=(0,Z.useRef)(null),i=W(),a=ur(),o=!i&&a,s=La(0),c=La(0),l=Wa(s,Ke),u=Wa(c,Ke);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:K(`inline-block`,n),children:e})}(0,Z.forwardRef)(function({strength:e=.25,magneticClassName:t,children:n,...r},i){return(0,Q.jsx)(of,{strength:e,className:t,children:(0,Q.jsx)(af,{ref:i,...r,children:n})})});var sf=.025,cf=`blur(6px)`,lf={initial:{opacity:0,y:`105%`,filter:cf},animate:(e=0)=>({opacity:1,y:`0%`,filter:`blur(0px)`,transition:{...Ge,delay:e}}),exit:(e=0)=>({opacity:0,y:`-105%`,filter:cf,transition:{duration:.16,ease:We,delay:e*.5}})},uf={initial:{opacity:0,width:0,scale:.7,filter:cf},animate:{opacity:1,width:`1.5rem`,scale:1,filter:`blur(0px)`,transition:Ge},exit:{opacity:0,width:0,scale:.7,filter:cf,transition:{duration:.16,ease:We}}};function df({keyId:e,children:t}){let n=W();return(0,Q.jsx)(G.span,{variants:uf,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 ff({value:e,children:t}){let n=W(),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}:Ge,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)(Pe,{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*sf,variants:lf,className:`inline-block whitespace-pre`,children:e},t))},`cascade-${e}`):(0,Q.jsx)(G.span,{initial:n?{opacity:0}:{opacity:0,y:14,filter:cf},animate:n?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:n?{opacity:0}:{opacity:0,y:-14,filter:cf},transition:n?{duration:.15}:Ge,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)(af,{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)(Pe,{initial:!1,children:[e===`loading`?(0,Q.jsx)(df,{keyId:`loading-icon`,children:(0,Q.jsx)(jr,{className:`h-4 w-4 animate-spin`})}):null,e===`success`?(0,Q.jsx)(df,{keyId:`success-icon`,children:(0,Q.jsx)(Cr,{className:`h-4 w-4`})}):null,e===`error`?(0,Q.jsx)(df,{keyId:`error-icon`,children:(0,Q.jsx)(ft,{className:`h-4 w-4`})}):null]}),(0,Q.jsx)(ff,{value:d,children:u}),(0,Q.jsx)(Pe,{initial:!1,children:e===`idle`&&a?(0,Q.jsx)(df,{keyId:`idle-icon`,children:a}):null})]})})});var pf={duration:0},mf={type:`spring`,duration:.4,bounce:.3},hf={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},gf={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},_f=(0,Z.createContext)(null);function vf(e){let t=(0,Z.useContext)(_f);if(!t)throw Error(`${e} must be used within <AnimatedSelect>`);return t}function yf({value:e,defaultValue:t,onValueChange:n,disabled:r=!1,className:i,children:a}){let o=W()??!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)(_f.Provider,{value:S,children:(0,Q.jsx)(`div`,{ref:c,className:K(`relative`,i),children:a})})}function bf({className:e,children:t}){let n=vf(`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:We}:{duration:.42,times:[0,.5,1],ease:We};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:pf,borderTopRightRadius:r?a:pf,borderBottomLeftRadius:r?pf:a,borderBottomRightRadius:r?pf:a},className:K(`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}:mf,className:`text-muted-foreground`,children:(0,Q.jsx)(Tr,{className:`h-4 w-4`})})]})}function xf({className:e,children:t}){let n=vf(`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:We,delay:.14}:{duration:.16,ease:We};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:We,delay:.14},marginTop:c?pf:d,marginBottom:c?d:pf,borderTopLeftRadius:c?pf:f,borderTopRightRadius:c?pf:f,borderBottomLeftRadius:c?f:pf,borderBottomRightRadius:c?f:pf},style:{transformOrigin:c?`bottom`:`top`,overflow:`hidden`,pointerEvents:o?`auto`:`none`},className:K(`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:hf,initial:!1,animate:o?`show`:`hidden`,className:`p-1`,children:t})})}function Sf({value:e,disabled:t=!1,className:n,children:r}){let i=vf(`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:gf,children:(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,disabled:t,onClick:()=>i.select(e),className:K(`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)(Cr,{className:`h-3.5 w-3.5 shrink-0`}):null]})})}function Cf({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=W()??!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:K(`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)(yl,{open:k,onOpenChange:A,children:[(0,Q.jsx)(xl,{children:(0,Q.jsx)(af,{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}:Ge,children:(0,Q.jsx)(si,{className:`size-4`})})})}),(0,Q.jsx)(El,{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)(yf,{value:M,onValueChange:L,disabled:_||u,className:`min-w-0`,children:[(0,Q.jsx)(bf,{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)(xf,{className:`right-auto w-52 shadow-none`,children:r.map(e=>(0,Q.jsx)(Sf,{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)(af,{type:`button`,size:`icon`,"aria-label":`Stop generating`,onClick:f,className:`ml-auto size-8 rounded-full`,children:(0,Q.jsx)(Kn,{className:`size-3 fill-current`})}):null,!u||P?(0,Q.jsx)(af,{type:`submit`,size:`icon`,disabled:!P,"aria-label":u?`Steer current run`:`Send prompt`,className:K(`size-8 rounded-full`,!u&&`ml-auto`),children:(0,Q.jsx)(Pe,{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}:Ge,className:`grid place-items-center`,children:(0,Q.jsx)(vo,{className:`size-4`})},`send`)})}):null]})]})}var wf=[`·`,`•`,`●`,`•`];function Tf({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:K(`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:wf[a%wf.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 Ef=`M5 13l4 4L19 7`,Df=`M6 12h12`;function Of({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=W(),f=e||r,p=r?Df:Ef;return(0,Q.jsxs)(`label`,{htmlFor:u,className:K(`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:K(`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)(Pe,{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:We},"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:We,delay:.04}})]},r?`indeterminate`:`checked`):null})}),i?(0,Q.jsx)(`span`,{className:K(`select-none text-sm text-foreground`,n&&`opacity-60`),children:i}):null]})}var kf=(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=W(),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||go(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:K(`flex flex-col gap-1.5`,u,d?.root),children:[e?(0,Q.jsx)(`label`,{htmlFor:v,className:K(`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:K(`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:K(`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:K(`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:K(`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:K(`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)(Pe,{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:K(`px-1 text-xs text-destructive`,d?.errorMessage),children:O}):null})]})}),Af=(0,Z.createContext)(null);function jf(){let e=(0,Z.useContext)(Af);if(!e)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);return e}function Mf({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=W(),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)(Ia,{transition:l?{duration:0}:He,children:(0,Q.jsx)(Af.Provider,{value:p,children:(0,Q.jsx)(`div`,{role:`radiogroup`,className:K(`flex gap-3`,a===`vertical`?`flex-col`:`flex-row flex-wrap`,i),children:r})})})}function Nf({value:e,label:t,disabled:n,className:r,id:i}){let{value:a,setValue:o,layoutId:s}=jf(),c=(0,Z.useId)(),l=i??c,u=W(),d=a===e;return(0,Q.jsxs)(`label`,{htmlFor:l,className:K(`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:K(`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:K(`select-none text-sm text-foreground`,n&&`opacity-60`),children:t}):null]})}var Pf={selected:[],custom:``};function Ff(e){return e===`submitting`?`Submitting`:e===`approved`?`Approved`:e===`rejected`?`Rejected`:e===`changes-requested`?`Changes requested`:e===`answered`?`Response submitted`:`Input required`}function If(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 Lf(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 Rf(e){return e.selected.length>0||!!e.custom?.trim()}function zf({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)(Of,{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)(Mf,{value:t.selected[0]??``,onValueChange:e=>{r({selected:[e],custom:``}),i?.()},className:`gap-0.5`,children:e.options.map(e=>(0,Q.jsx)(Nf,{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)(kf,{value:a,disabled:n,placeholder:e.customPlaceholder??`Add another response…`,onChange:n=>r({selected:e.multiple?t.selected:[],custom:n}),className:K(`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 Bf({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:Ge,className:`size-1.5 rounded-full bg-foreground`},t))]})}function Vf({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=W()??!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]??Pf:Pf,P=O?.title??e,F=O?.id??String(i),I=Ff(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:K(`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:K(`grid size-5 shrink-0 place-items-center text-muted-foreground`,If(i)),children:j?(0,Q.jsx)(jr,{className:K(`size-4`,!b&&`animate-spin`)}):M?k?(0,Q.jsx)(So,{className:`size-4`}):(0,Q.jsx)(Lo,{className:`size-4`}):i===`rejected`?(0,Q.jsx)(ft,{className:`size-4`}):(0,Q.jsx)(Cr,{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)(Pr,{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:K(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors`,Lf(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)(ft,{className:`size-4`})}):null]}),(0,Q.jsxs)(Mr,{open:M,children:[(0,Q.jsx)(Pe,{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:We},children:[O.description?(0,Q.jsx)(`p`,{className:`mt-1 leading-5 text-muted-foreground`,children:O.description}):null,(0,Q.jsx)(zf,{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)(af,{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)(Bf,{current:D,ids:r.map(e=>e.id)}),(0,Q.jsx)(af,{size:D===r.length-1?`sm`:`icon`,"aria-label":D===r.length-1?`Submit response`:`Next question`,disabled:j||!Rf(N),onClick:()=>{if(D<r.length-1){z(D+1);return}d?.(E)},className:`ml-auto rounded-full`,children:j?(0,Q.jsx)(jr,{className:K(`size-4`,!b&&`animate-spin`)}):D===r.length-1?(0,Q.jsxs)(Q.Fragment,{children:[_,(0,Q.jsx)(_o,{className:`size-3.5`})]}):(0,Q.jsx)(_o,{className:`size-4`})})]}):(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(af,{size:`sm`,disabled:j,onClick:f,className:`rounded-full`,children:g}),m?(0,Q.jsx)(af,{variant:`secondary`,size:`sm`,disabled:j,onClick:m,className:`rounded-full`,children:`Request changes`}):null,p?(0,Q.jsx)(af,{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 Hf({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:K(`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)(nr,{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)(Dr,{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)(Tr,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsx)(Vf,{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 Uf=(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:K(`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)(Tr,{className:`size-3 text-foreground/40`})]});return m?(0,Q.jsx)(ll,{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:K(`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)(Cr,{className:`mt-0.5 size-3.5 shrink-0 text-foreground/60`})]},e.id)})}):h});Array.from({length:14},(e,t)=>t);function Wf(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 Gf(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 Kf({open:e,align:t=`start`,className:n,...r}){return(0,Q.jsx)(`div`,{"data-slot":`composer-menu`,"data-open":e||void 0,className:K(dr,`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 qf({active:e=!1,className:t,...n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`composer-menu-item`,"data-active":e||void 0,className:K(`flex w-full items-center gap-2.5 rounded-[10px] px-2.5 py-2 text-[13.5px] transition-colors`,e?pr:`hover:bg-foreground/[0.04]`,t),...n})}function Jf(e,t){return t.icon?t.icon:e===`mention`?t.metadata?.kind===`folder`?(0,Q.jsx)(ri,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(ni,{"aria-hidden":`true`,className:`size-4`}):(0,Q.jsx)(Eo,{"aria-hidden":`true`,className:`size-4`})}function Yf(e,t){return e&&e.length>0?e.flatMap(e=>e.items):t?[...t]:[]}var Xf=(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)(()=>Yf(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)(qf,{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:K(`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:Jf(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)(Er,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):null]},e.id)};return e?(0,Q.jsxs)(Kf,{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:K(`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)(bo,{"aria-hidden":`true`,className:`size-3.5`})}):null,(0,Q.jsx)(Vr,{"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 Zf(e,t,n){return Math.min(n,Math.max(t,e))}function Qf({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),_=Zf(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+Zf((e-r.left)/r.width,0,1)*(h-n);return Zf(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(Zf(_+i*g,n,h))),r&&e.stopPropagation()};return(0,Q.jsx)(`div`,{className:K(`relative w-full touch-none`,s&&`opacity-50`,c),...l,children:(0,Q.jsxs)(`div`,{className:K(`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:Le},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:Le}),(0,Q.jsx)(G.div,{"aria-hidden":`true`,className:K(`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:Le}),(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:Le,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:Le,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 $f(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 ep=(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)(()=>$f(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:K(`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)(Tr,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]});return(0,Q.jsx)(ll,{contentId:p,open:m,onOpenChange:h,side:`top`,align:`start`,className:K(`w-[min(24rem,calc(100vw-2rem))] max-h-[min(55vh,28rem)] overflow-hidden p-0`,u),trigger:y,children:(0,Q.jsxs)(er,{className:`min-h-0 max-h-[min(55vh,28rem)] bg-transparent`,shouldFilter:!0,children:[(0,Q.jsx)(Gn,{placeholder:`Search models…`,"aria-label":`Search models`}),(0,Q.jsxs)($n,{className:`min-h-0 flex-1 p-1.5`,children:[(0,Q.jsx)(Qn,{children:`No matching models`}),_.map(([e,t])=>(0,Q.jsx)(Jn,{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)(Xn,{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)(No,{"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)(Cr,{"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)(Qf,{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 tp(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 np=[];function rp(e){return e?Array.isArray(e)?e:e.items:[]}function ip(e){return(e.value??e.id).trim().replace(/^\/+/,``).split(/\s+/,1)[0]??e.id}function ap(e){return(e.value?.trim()??``).match(/^\/\S+\s+(.+)$/)?.[1]}function op({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=np,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=tp(v),k=rp(b),A=rp(p),j=(0,Z.useMemo)(()=>k.map(e=>({name:ip(e),description:[e.description,ap(e)].filter(Boolean).join(` `),icon:Vr})),[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=Wf(T,j),z=Gf(T,M),B=(0,Z.useMemo)(()=>{let e=new Set(R.map(e=>e.name));return k.filter(t=>e.has(ip(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,[ee,U]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{U(0)},[L,F,I,H.length]);let te=(0,Z.useCallback)((e,t=!1)=>{if(s?.(e)===!0){E(``);return}a({role:`user`,content:e,altKey:t}),E(``)},[s,a,E]),ne=(0,Z.useCallback)(e=>{if(o?.(e)===!0){E(``);return}E(e.value??e.label)},[o,E]),re=(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]),ie=(0,Z.useCallback)(e=>{m?.(e),E(re(P))},[m,re,E,P]),ae=(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(re(L===`slash`?N:P));return}if(t&&H.length>0){if(e.key===`ArrowDown`){e.preventDefault(),U(e=>(e+1)%H.length);return}if(e.key===`ArrowUp`){e.preventDefault(),U(e=>(e-1+H.length)%H.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=H[ee];t&&(L===`slash`?ne(t):ie(t));return}}if(e.key===`Enter`&&e.altKey&&!e.shiftKey){e.preventDefault();let t=T.trim();t&&!_&&te(t,!0)}},[ee,_,D,h,re,ne,ie,te,E,N,H,L,T,P,f]),oe=v&&v.id!==C,se=y?.files??[],ce=y?.images??[],le=!!(L&&!D&&!_),ue=(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,ap(e)].filter(Boolean).join(` · `)}))}))},[B,L]),de=(0,Z.useMemo)(()=>e.map(e=>({id:e.id,name:e.name,provider:e.provider,providerLabel:Rn(e.provider),modelId:e.modelId,icon:(0,Q.jsx)(Hn,{provider:e.provider,className:`size-4`}),disabled:e.available===!1,reasoning:e.reasoning,keywords:[e.provider,e.modelId,e.id],efforts:qr(e).map(e=>({id:e,name:Jr(e)}))})),[e]);return{activeTriggerIndex:ee,combinedPickerOpen:c===!0||u===!0,commandGroups:ue,files:se,handleCombinedPickerOpenChange:(0,Z.useCallback)(e=>{l?.(e),d?.(e)},[d,l]),handlePromptKeyDown:ae,handleSelectorModelChange:(0,Z.useCallback)(t=>{let a=e.find(e=>e.id===t);r(t),a&&i?.(Hr(n,qr(a)))},[e,r,i,n]),images:ce,isStreaming:D,navigation:O,selectorModels:de,selectCommand:ne,selectWorkspaceReference:ie,removeTriggerToken:re,send:te,setActiveTriggerIndex:U,setDismissedQuestionId:w,setValue:E,showQuestion:oe,triggerItems:H,triggerKind:L,triggerOpen:le,slashMatch:N,slashQuery:F,workspaceMentionMatch:P,workspaceQuery:I,filteredCommands:B,filteredWorkspaceItems:V,value:T}}function sp(e){return e}var cp=[{id:`agent`,label:`Agent`,icon:Fn,description:`Default coding agent`},{id:`plan`,label:`Plan`,icon:yr,description:`Plan before executing`},{id:`harness`,label:`Harness`,icon:Ho,description:`Harness-aware turn`}],lp=[];function up(e){return(0,Q.jsx)(dp,{...e})}function dp({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:_=lp,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:ee,selectorModels:U,send:te,setActiveTriggerIndex:ne,setDismissedQuestionId:re,setValue:ie,showQuestion:ae,slashMatch:oe,slashQuery:se,triggerItems:ce,triggerKind:le,triggerOpen:ue,value:de,workspaceMentionMatch:fe,workspaceQuery:pe}=op({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:K(`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)(Tf,{label:r??void 0,isActive:L}),ae?(0,Q.jsx)(Hf,{questionBar:E,navigation:R,roundedTop:!0,onDismiss:re}):null,(0,Q.jsx)(Xf,{open:ue,kind:le??`slash`,query:le===`slash`?se:pe,items:le===`mention`?z:void 0,groups:le===`slash`?j:void 0,activeIndex:k,onActiveIndexChange:ne,onSelect:e=>{le===`slash`?V(e):ee(e)},onClose:()=>ie(B(le===`slash`?oe:fe)),title:le===`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)(ft,{"data-icon":`inline-start`,className:`size-3`})})]},e.id)),M.map(e=>(0,Q.jsx)(Hd,{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)(Nr,{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)(ft,{className:`size-3`})})]},e.relativePath))}):null,(0,Q.jsx)(Cf,{id:`fleet-composer-prompt`,name:`prompt`,value:de,onValueChange:ie,onSubmit:e=>te(e),loading:L,submitWhileLoading:!0,onStop:l,disabled:S,autoFocus:C,placeholder:w??`Send a message…`,onPaste:T?.onPaste,"aria-controls":ue?`fleet-composer-trigger-list`:void 0,"aria-expanded":ue,"aria-haspopup":`listbox`,"aria-activedescendant":ue&&ce[k]?`fleet-composer-trigger-list-${ce[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)(Ao,{})}]:[],onAction:e=>{e===`attach`&&T?.onAttach?.()},onKeyDown:P,leadingAction:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Uf,{modes:[...cp],value:i,onChange:e=>a?.(e)}),(0,Q.jsx)(ep,{models:U,value:e,effort:s,onModelChange:F,onEffortChange:e=>c?.(e),open:A,onOpenChange:N,placeholder:`Model`,className:`rounded-full`})]})})]})})}var fp=`Fleet Prime is not connected to the Prime Agent runtime. Start or reconnect the runtime, then try again.`,pp={dots:`rounded-full`,squares:`rounded-[1px]`,rounded:`rounded-[3px]`};function mp({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:K(`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:K(`bg-foreground size-2 transition-opacity duration-300 motion-reduce:transition-none`,pp[n],r?`opacity-90`:`opacity-15`)},t)})}),(0,Q.jsx)(gr,{className:`text-foreground/55 relative inline-block text-sm`,children:e})]})}function hp({label:e,elapsed:t,className:n,...r}){return(0,Q.jsxs)(`div`,{"data-slot":`thinking-indicator`,className:K(`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)(gr,{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:K(`font-mono text-[11px] tracking-tight`,`text-foreground/30 tabular-nums`),children:t})]})}function gp({steps:e,visibleSteps:t,streaming:n,streamingLabel:r=`Thinking`,open:i,onOpenChange:a,restingLabel:o,elapsed:s,className:c}){let l=mr(e,t);return(0,Q.jsxs)(Br,{"data-slot":`reasoning-panel`,open:i,onOpenChange:a,className:K(`w-full max-w-sm`,c),children:[(0,Q.jsxs)(Rr,{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)(ar,{active:+!n,className:`text-start`,children:[(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gr,{active:n,className:`relative inline-block leading-none`,children:r}),s!==void 0&&(0,Q.jsx)(`span`,{className:K(`font-mono text-[11px] tracking-tight`,`text-foreground/30 tabular-nums`),children:s})]}),(0,Q.jsx)(Q.Fragment,{children:o})]}),(0,Q.jsx)(Tr,{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)(Ir,{className:K(or,`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:K(`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 _p({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??vp(e.phase),d=yp(e.elapsedMs);return(0,Q.jsxs)(`section`,{"data-slot":`fleet-reasoning-presentation`,"aria-label":`Safe reasoning progress`,className:K(`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)(hp,{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)(mp,{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)(gp,{steps:s,visibleSteps:c,streaming:a,streamingLabel:`Preparing response`,open:o,onOpenChange:i,restingLabel:e.restingLabel,elapsed:d,className:`max-w-none`})]})}function vp(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 yp(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 bp=(0,Z.lazy)(()=>di(async()=>{let{FleetPiToolRenderer:e}=await import(`./fleet-pi-tool-renderer-ZKiX6Ob_.js`);return{FleetPiToolRenderer:e}},__vite__mapDeps([26,1,2,4,27,28,6,3,7,8,29,12,13,30,31,10,32,18,33,15,34,35,36,37,38,39,19,20,25])).then(({FleetPiToolRenderer:e})=>({default:e})));function xp(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)(bp,{...e})})}function Sp(e){let t=[],n;for(let r of e){if(r.role===`user`){n&&t.push(n),n={user:r,assistants:[]};continue}if(r.role===`assistant`){if(!n||r.source===`local`){n&&t.push(n),n={assistants:[r]};continue}n.assistants.push(r)}}return n&&t.push(n),t}function Cp(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(`
|
|
7
|
-
|
|
8
|
-
`)}function wp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Tp(e,...t){let n=wp(e);for(let e of t){let t=n?.[e];if(typeof t==`string`&&t.trim())return t}}function Ep(e){for(let t of[...e].reverse())for(let e of[...t.parts??[]].reverse()){let t=wp(e);if(t?.type!==`tool-FleetReasoning`)continue;let n=wp(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 Dp(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;return n&&r?{label:`Open in Artifacts`,ariaLabel:`Open ${n.title||`tool result`} artifact ${t+1}`,onClick:()=>r(n.id)}:void 0};for(let t of e)for(let[e,n]of(t.parts??[]).entries()){let r=wp(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=wp(s.input)??wp(s.args);if(l===`websearch`||l===`grep`||l===`glob`){i.set(u,{id:u,type:`search`,query:Tp(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:Tp(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 Op({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)=>Id(xd((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:xp,TextRendererComponent:Yd,toolRenderers:i,onOpenUIAction:a,onOpenUIArtifactReady:u,onOpenArtifact:l})),[t,d,e,l,a,u,r,i]),p=e.flatMap(e=>{let t=Cp(e);return t?[t]:[]}).join(`
|
|
9
|
-
|
|
10
|
-
`),m=(0,Z.useMemo)(()=>Dp(e,s,c,l),[c,e,l,s]),h=(0,Z.useMemo)(()=>Ep(e),[e]),[g,_]=(0,Z.useState)(d),[v,y]=(0,Z.useState)(d);return v!==d&&(y(d),_(d)),(0,Q.jsx)(Hu,{from:`assistant`,animateIn:!d,children:(0,Q.jsx)(Uu,{children:(0,Q.jsx)(Du,{variant:`ghost`,children:(0,Q.jsxs)(Au,{children:[h?(0,Q.jsx)(_p,{presentation:h,className:`mb-2`}):null,t&&jp(o)?(0,Q.jsx)($d,{label:o,className:`mb-2`}):null,(0,Q.jsx)(Ku,{status:d?`streaming`:`complete`,copyText:p||void 0,announce:!1,contentClassName:`flex flex-col gap-3`,children:f}),m.length>0?(0,Q.jsx)(pd,{items:m,status:d?`working`:`complete`,open:g,onOpenChange:_,activeLabel:Mp(m),summary:Np(m),collapseOnComplete:!0,maxHeight:208,className:`mt-2 max-w-none`}):null]})})})})}function kp(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Ap=(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)(Hu,{from:`user`,animateIn:!t.isStreaming,children:(0,Q.jsx)(Uu,{children:(0,Q.jsx)(Kd,{message:e.user})})}):null,e.assistants.length>0?(0,Q.jsx)(Op,{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&&kp(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 jp(e){return e?/queued|steered|retry|compact|reset|recover|sign in/i.test(e):!1}function Mp(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 Np(e){let t=e.length;return t===1?`Completed 1 tracked action`:`Completed `+t+` tracked actions`}function Pp(e){return Array.isArray(e)?e:e?.items??[]}function Fp(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:fp}:{title:`Request failed`,message:e.message.replace(/\s+(?:Socket|Daemon log):\s*[^\n]*(?:\s+(?:Socket|Daemon log):\s*[^\n]*)*/gi,``)}}var Ip=[{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 Lp({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:Ip.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 Rp({toolRenderers:e=lr,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}){let[g,_]=(0,Z.useState)(``),v=(0,Z.useMemo)(()=>Sp(s),[s]),y=sp(t),b=Pp(y),x=(0,Z.useMemo)(()=>b.flatMap(e=>e.disabled?[]:[e.value??e.label]),[b]),S=x.join(`\0`),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(S);T!==S&&(E(S),w(null));let D=n===`streaming`||n===`submitted`,O=v.length===0&&!c,k=c?Fp(c):null,A=(0,Q.jsx)(up,{...a,className:K(a.className,O&&`px-0 pb-0`),placeholder:O?`Ask Prime to build, investigate, or change something…`:a.placeholder,controlled:{value:g,onChange:_},status:n,suggestions:y,onSend:i,onStop:r});return(0,Q.jsxs)(`div`,{className:K(`fleet-pi-agent-chat flex h-full min-h-0 flex-col bg-background`,o),children:[(0,Q.jsxs)(zu,{className:`flex-1`,busy:D,followOutput:!0,smooth:D,contentClassName:K(`mx-auto flex w-full max-w-an flex-col gap-5 px-4`,O?`min-h-full items-center justify-center py-8`:`py-6`),children:[O?(0,Q.jsx)(Lp,{disabled:D,onSelect:e=>_(e.value??e.label),composer:A}):null,v.map((t,n)=>{let r=t.user?.id??`assistant-turn-${n}`,i=n===v.length-1;return(0,Q.jsx)(Ap,{turn:t,state:{isLast:i,isStreaming:i&&D,suppressQuestionTool:l},rendering:{toolRenderers:e,onOpenUIAction:u,onOpenUIArtifactReady:h,onOpenArtifact:m},activity:{label:i?d:void 0,presentation:i?f:void 0,artifactRuns:i?p:void 0}},r)}),k?(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)(kr,{className:`mt-0.5 size-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:k.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs opacity-90`,children:k.message})]})]}):null,v.length>0&&x.length>0&&!D&&!c?(0,Q.jsx)(md,{suggestions:x,selectedSuggestion:C,cycle:v.length,onSuggestion:e=>{w(e),_(e)},className:`px-0`}):null]}),O?null:A]})}function zp({messages:e,status:t,error:n,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,onOpenArtifact:s,onOpenUIArtifactReady:c,inputSuggestionItems:l,suppressQuestionTool:u,inputBar:d,onSend:f,onOpenUIAction:p,onStop:m,onQuestionAnswer:h}){let g=(0,Z.useCallback)(e=>{f(e.content,e.altKey)},[f]),_=(0,Z.useCallback)(e=>{p(e)},[p]),v=(0,Z.useCallback)(({toolCallId:e,answer:t})=>{h({toolCallId:e,answer:t})},[h]),y=(0,Z.useMemo)(()=>({submitLabel:`Continue`,allowSkip:!0,onAnswer:v}),[v]);return(0,Q.jsx)(`div`,{className:`contents`,"data-fleet-chat-focus":!0,children:(0,Q.jsx)(vi,{children:(0,Q.jsx)(Rp,{messages:e,status:t,onSend:g,onOpenUIAction:_,onStop:m,workspaceName:r,activityLabel:i,presentation:a,artifactRuns:o,onOpenArtifact:s,onOpenUIArtifactReady:c,questionTool:y,suppressQuestionTool:u,error:n??void 0,emptyStatePosition:`default`,suggestions:l,inputBar:d})})})}var Bp=[`/api/health`,`/api/chat`,`/api/projects`,`/api/workspace`];function Vp(){return``}function Hp(e){return Bp.some(t=>e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`))}function Up(e){let t=Vp();if(!t)return e;let[n]=e.split(`?`);return Hp(n)?`${t}${e}`:e}function Wp(){return null}function Gp(){return null}async function Kp(){}var qp=J({key:X(),provider:X(),id:X(),name:X(),version:X().optional(),reasoning:yi(),input:Y(fi([`text`,`image`])),contextWindow:_i().optional(),maxTokens:_i().optional(),available:yi(),defaultThinkingLevel:ki.optional(),thinkingLevels:Y(ki).optional()}).openapi({description:`Chat model info`}),Jp=J({models:Y(qp),selectedModelKey:X().optional(),defaultProvider:X().optional(),defaultModel:X().optional(),defaultThinkingLevel:ki.optional(),diagnostics:Y(X())}).openapi({description:`Chat models response`}),Yp=J({providerId:X().min(1).max(128)}).openapi({description:`Discover models for a provider`}),Xp=J({providerId:X(),models:Y(qp)}).openapi({description:`Discovered models for a provider`}),Zp=J({activationStatus:fi([`active`,`staged`,`reload-required`]).optional(),name:X(),description:X().optional(),installedInWorkspace:yi().optional(),path:X().optional(),source:X().optional(),workspacePath:X().optional(),argumentHint:X().optional()}).openapi({description:`Chat resource info`}),Qp=J({packages:Y(Zp),skills:Y(Zp),prompts:Y(Zp),extensions:Y(Zp),themes:Y(Zp),agentsFiles:Y(Zp),diagnostics:Y(X())}).openapi({description:`Chat resources response`}),$p=xi(()=>J({name:X(),path:X(),type:fi([`directory`,`file`]),children:Y($p).optional()})),em=J({root:X(),nodes:Y($p),diagnostics:Y(X())}).openapi({description:`Workspace tree response`}),tm=J({path:X(),name:X(),content:X(),mediaType:fi([`text/markdown`,`text/plain`,`application/octet-stream`]),size:_i().optional(),status:fi([`ok`,`too-large`,`unsupported`]).optional()}).openapi({description:`Workspace file preview response`}),nm=J({name:X(),path:X()}).openapi({description:`Directory entry in the project-folder picker`}),rm=J({path:X(),parent:X().nullable(),entries:Y(nm)}).openapi({description:`Workspace directory browse response`}),im=J({id:X(),name:X(),isConfigured:yi(),envVarName:X(),authType:fi([`apiKey`,`oauth`]).optional(),supportsOAuth:yi().optional(),providerFamily:X().optional(),displayName:X().optional(),api:fi([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),baseUrl:X().optional(),modelIds:Y(X().max(4096)).max(64).optional(),discoverable:yi().optional()}).openapi({description:`Chat provider info`}),am=J({providers:Y(im)}).openapi({description:`Chat providers response`}),om=J({providerId:X(),apiKey:X().max(4096),baseUrl:X().max(4096).optional(),modelId:X().max(4096).optional(),displayName:X().max(256).optional(),createOccInstance:yi().optional(),api:fi([`openai-completions`,`openai-responses`,`anthropic-messages`,`google-genai`]).optional(),models:Y(X().max(4096)).max(64).optional()}).openapi({description:`Chat provider update request`}),sm=J({success:yi(),providers:Y(im),reloadRequired:yi().optional()}).openapi({description:`Chat provider update response`}),cm=J({providerId:X()}).openapi({description:`Chat provider remove request`});sm.openapi({description:`Chat provider remove response`});var lm=fi([`waiting`,`success`,`error`]).openapi({description:`OAuth login status`}),um=J({message:X(),placeholder:X().optional(),allowEmpty:yi().optional()}).openapi({description:`Interactive OAuth prompt`}),dm=J({providerId:X().min(1),loginId:X().min(1).optional(),promptAnswer:X().max(8192).optional(),cancel:yi().optional()}).openapi({description:`Chat provider OAuth login request`}),fm=J({status:lm,loginId:X().optional(),authUrl:X().optional(),userCode:X().optional(),instructions:X().optional(),prompt:um.optional(),error:X().optional(),providers:Y(im).optional()}).openapi({description:`Chat provider OAuth login response`}),pm=J({name:X(),description:X().optional(),argumentHint:X().optional(),source:fi([`builtin`,`extension`,`prompt`,`skill`]),passThrough:yi().optional()}).openapi({description:`Chat slash command info`}),mm=J({commands:Y(pm),diagnostics:Y(X())}).openapi({description:`Chat slash commands response`});J({message:X()}).openapi({description:`Error response`}),J({status:hi(`ok`)}).openapi({description:`Health check response`});var hm=J({compaction:J({enabled:yi(),reserveTokens:Ai,keepRecentTokens:Ai}),defaultModel:X().optional(),defaultProvider:X().optional(),defaultThinkingLevel:ki.optional(),enableSkillCommands:yi(),enabledModels:Y(Fi).optional(),extensions:Y(Fi),followUpMode:Hi,packages:Y(Oi),prompts:Y(Fi),retry:J({enabled:yi(),maxRetries:ji,baseDelayMs:ji}),skills:Y(Fi),steeringMode:Hi,themes:Y(Fi),transport:Ri}).openapi({description:`Editable Pi settings`}),gm=J({compaction:hm.shape.compaction.partial().optional(),defaultModel:X().optional(),defaultProvider:X().optional(),defaultThinkingLevel:ki.optional(),enableSkillCommands:yi().optional(),enabledModels:Y(Fi).nullable().optional(),extensions:Y(Fi).optional(),followUpMode:Hi.optional(),packages:Y(Oi).optional(),prompts:Y(Fi).optional(),retry:hm.shape.retry.partial().optional(),skills:Y(Fi).optional(),steeringMode:Hi.optional(),themes:Y(Fi).optional(),transport:Ri.optional()}).strict().openapi({description:`Pi settings update`}),_m=J({settings:gm}).openapi({description:`Pi settings update request`}),vm=J({diagnostics:Y(X()),effective:hm,project:gm,projectPath:X(),updateImpact:J({newSessionRecommended:yi(),resourceReloadRequired:yi()})}).openapi({description:`Pi settings response`});function ym(){return null}var bm=class extends Error{status;body;code;remediation;constructor(e,t){super(Cm(e,t)),this.name=`ChatRequestError`,this.status=e,this.body=t;let n=Sm(t);this.code=n?.code,this.remediation=n?.remediation}};function xm(e){return typeof e==`object`&&!!e&&typeof e.action==`string`&&typeof e.label==`string`}function Sm(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:xm(e.remediation)?e.remediation:void 0}}catch{}return null}function Cm(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 wm(e){return(e instanceof bm?e.body:e instanceof Error?e.message:String(e)).includes(`Session belongs to another user`)}function Tm(e){return e instanceof bm&&e.status===404}function Em(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 Dm(e){let t=Error(e.message);return e.code&&(t.code=e.code),t}async function Om(e){let t=new Headers(e?.headers),n=await ym();return n&&t.set(`Authorization`,`Bearer ${n}`),t}async function km(e,t){let n=Up(e),r=async e=>{let i=await Om(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 bm(a.status,e)}return await a.json()};return r(!0)}async function Am(e,t,n){return Mm(t,await km(e,n),`Response from ${e}`)}async function jm(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=Mm(Pi,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(`
|
|
11
|
-
`);for(;o>=0;)s(i.slice(0,o)),i=i.slice(o+1),o=i.indexOf(`
|
|
12
|
-
`)}i+=r.decode(),s(i)}function Mm(e,t,n){let r=e.safeParse(t);if(r.success)return r.data;throw Error(`${n} did not match the expected contract`)}function Nm(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 Pm(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 Fm=J({project:mi}),Im={async abortSession(e){await km(`/api/chat/abort`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},async answerQuestion(e){return Am(`/api/chat/question`,Ti,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})},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 Am(`/api/workspace/browse${r?`?${r}`:``}`,rm)},async createSession(e,t){return Am(`/api/chat/new`,Bi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({openUI:!0,...e?{projectId:e}:{}}),signal:t})},async listProjects(){return Am(`/api/projects`,Ui)},async createProject(e){let t=Ei.parse(e);return(await Am(`/api/projects`,Fm,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).project},async renameProject(e,t){let n=Ci.parse({name:t});return(await Am(`/api/projects?projectId=${encodeURIComponent(e)}`,Fm,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})).project},async unregisterProject(e){return(await Am(`/api/projects?projectId=${encodeURIComponent(e)}`,Fm,{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 Am(`/api/projects/browse${n?`?${n}`:``}`,Wi)},async forkSessionIntoProject(e,t){let n=Si.parse({sessionId:e,targetProjectId:t});return Am(`/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 Am(`/api/chat/models${n?`?${n}`:``}`,Jp)},async discoverModels(e){return Am(`/api/chat/models/discover`,Xp,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Yp.parse(e))})},async getResources(e){return Am(`/api/chat/resources${e?`?projectId=${encodeURIComponent(e)}`:``}`,Qp)},async getCommands(e){return Am(`/api/chat/commands${e?`?projectId=${encodeURIComponent(e)}`:``}`,mm)},async getSettings(e){return Am(`/api/chat/settings${e?`?projectId=${encodeURIComponent(e)}`:``}`,vm)},async getWorkspaceTree(e){return Am(`/api/workspace/tree${e?`?projectId=${encodeURIComponent(e)}`:``}`,em)},async getWorkspaceFile(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`projectId`,t),Am(`/api/workspace/file?${n}`,tm)},async listSessions(e){return(await Am(`/api/chat/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`,Di)).sessions},async renameSession(e,t){await km(`/api/chat/sessions`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e,title:t})})},async deleteSession(e){await km(`/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(Up(`/api/chat/session`),{method:`POST`,body:n});if(!r.ok)throw new bm(r.status,await r.text());return J({attachments:Y(bi)}).parse(await r.json()).attachments},async loadSession(e){return Am(`/api/chat/session?${Nm({...e,openUI:!0})}`,Bi)},async upsertPlanPresentation(e){let t=Mi.parse(e);return Am(`/api/chat/session`,J({presentation:zi}),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.presentation)},async upsertOpenUIArtifact(e){let t=Vi.parse(e);return Am(`/api/chat/artifacts`,Ii,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async resumeSession(e){return Am(`/api/chat/resume`,Bi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,openUI:!0})})},async updateSettings(e,t){let n=_m.parse(e);return Am(`/api/chat/settings${t?`?projectId=${encodeURIComponent(t)}`:``}`,vm,{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 Gp();o&&a.set(`Authorization`,`Bearer ${o}`);let s=await fetch(Up(`/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 bm(s.status,e)}await jm(s,t)};await r(!0)},async getProviders(){return Am(`/api/chat/providers`,am)},async oauthLoginProvider(e){let t=dm.parse(e);return Am(`/api/chat/providers/oauth`,fm,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async updateProvider(e){let t=om.parse(e);return Am(`/api/chat/providers`,sm,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})},async removeProvider(e){let t=cm.parse(e);return Am(`/api/chat/providers`,sm,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}},Lm={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 ha({queryKey:Lm.models(e),queryFn:()=>Im.getModels({projectId:e})})}function zm(){return ha({queryKey:Lm.projects,queryFn:()=>Im.listProjects(),staleTime:5e3})}function Bm(e){return ha({queryKey:Lm.modelCatalog(e?.projectId),queryFn:()=>Im.getModels({scope:`all`,projectId:e?.projectId}),enabled:e?.enabled})}function Vm(){let e=s();return ga({mutationFn:e=>Im.discoverModels({providerId:e}),onSuccess:()=>{e.invalidateQueries({queryKey:[`chat`,`models`]})}})}function Hm(e){return ha({queryKey:Lm.resources(e),queryFn:()=>Im.getResources(e)})}function Um(e){return ha({queryKey:Lm.commands(e),queryFn:()=>Im.getCommands(e)})}function Wm(e){return ha({queryKey:Lm.settings(e),queryFn:()=>Im.getSettings(e)})}function Gm(){let e=s();return ga({mutationFn:e=>Im.updateSettings(e.request,e.projectId),onSuccess:(t,n)=>{e.setQueryData(Lm.settings(n.projectId),t),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`resources`]}),e.invalidateQueries({queryKey:[`chat`,`commands`]})}})}function Km(e,t){return ha({queryKey:Lm.workspace(e),queryFn:()=>Im.getWorkspaceTree(e),enabled:t?.enabled})}function qm(){return ha({queryKey:Lm.providers,queryFn:()=>Im.getProviders()})}function Jm(){let e=s();return ga({mutationFn:e=>Im.updateProvider(e),onSuccess:t=>{e.setQueryData(Lm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Ym(){let e=s();return ga({mutationFn:e=>Im.oauthLoginProvider(e),onSuccess:t=>{t.status!==`success`||!t.providers||(e.setQueryData(Lm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]}))}})}function Xm(){let e=s();return ga({mutationFn:e=>Im.removeProvider(e),onSuccess:t=>{e.setQueryData(Lm.providers,{providers:t.providers}),e.invalidateQueries({queryKey:[`chat`,`models`]}),e.invalidateQueries({queryKey:[`chat`,`settings`]})}})}function Zm(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 Qm(e){return e?.role!==`assistant`||!Array.isArray(e.parts)?!1:e.parts.some(e=>Zm(e))}var $m=[{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`}],eh={clear:`new`,usage:`context`,thinking:`effort`,rename:`name`,side:`btw`};function th(e){let t=ki.safeParse(e.trim().toLowerCase());return t.success?t.data:void 0}function nh(e){return eh[e]??e}function rh(e){let t=e.trim().match(/^\/(\S+)(?:\s+(.*))?$/);if(!t)return null;let[,n=``,r=``]=t;return{command:n,args:r.trim()}}function ih(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 ah(e,t=``){let n=nh(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=th(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:ih(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?ih(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 oh(e){let t=e.trim().replace(/\s+/g,`-`);return/^[\w.-]+$/.test(t)?t:``}function sh(e){return{id:e.name,label:`/${e.name}`,value:`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``} `,description:e.description,category:e.category??`builtin`}}function ch(e,t,n){let r=new Map;for(let e of $m)r.set(e.name,sh(e));for(let e of n?.commands??[])r.has(e.name)||r.set(e.name,sh({...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=oh(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 lh=`fleet-prime:v1:right-panel-width`,uh=`fleet-prime:v1:theme-preference`,dh=320;function fh(){return typeof window>`u`?dh:ph()}function ph(){return typeof window>`u`?dh:Math.max(dh,Math.floor(window.innerWidth*Kr))}function mh(e){return Math.min(ph(),Math.max(dh,Math.round(e)))}function hh(){return Xr(lh,fh(),mh)}function gh(e){Zr(lh,mh(e))}function _h(){if(typeof window>`u`)return`system`;let e=window.localStorage.getItem(uh);return e===`light`||e===`dark`||e===`system`?e:`system`}function vh(e){typeof window>`u`||window.localStorage.setItem(uh,e)}function yh(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 bh(e,t){let{sessionMetadata:n,setSessionMetadata:r}=t,i=(0,Z.useMemo)(()=>e?.models.map(ei)??[],[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)(()=>_h()),[b,x]=(0,Z.useState)(()=>hh());(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=qr(t);c(t=>Hr(t??e?.defaultThinkingLevel,n))},[i,a,e?.defaultThinkingLevel]),(0,Z.useEffect)(()=>{if(yh(v),v!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>yh(`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=fh();x(t),gh(t)},[l]),(0,Z.useEffect)(()=>{l===null&&h(null)},[l]),(0,Z.useEffect)(()=>{if(!l)return;let e=()=>{x(e=>{let t=mh(e);return gh(t),t})};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[l]);let C=(0,Z.useCallback)(e=>{y(e),vh(e),yh(e)},[]),w=(0,Z.useCallback)(e=>{$r({event:e,startWidth:b,getNextWidth:(e,t,n)=>mh(n-(e-t)),onWidthChange:e=>{x(e),gh(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=Ue(t);return!n||n.panel===e?t:null})},[]),D=(0,Z.useCallback)(e=>{p(e),E(`artifacts`)},[E]),O=(0,Z.useCallback)(e=>{let t=Ue(e);t&&(E(t.panel),h(t.path))},[E]),k=(0,Z.useCallback)(e=>{let t=e.panel===`workspace`||e.panel===`artifacts`;E(e.panel),h(t?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=Hr(s??e?.defaultThinkingLevel,qr(j)),N=(0,Z.useCallback)(e=>{let t=i.find(e=>e.id===a);c(Hr(e,qr(t)))},[a,i]);return{commandPaletteOpen:g,handleResourceCanvasResizeStart:w,handleThemePreferenceChange:C,initialSessionMetadata:n,modelKey:a,modelSelection:(0,Z.useMemo)(()=>Wr(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 xh=`fleet-prime:v1:chat-session`;function Sh(){let[e,t]=(0,Z.useState)(()=>Ch()),n=(0,Z.useCallback)(e=>{t(e)},[]);return(0,Z.useEffect)(()=>{Dh(e)},[e]),{sessionMetadata:e,setSessionMetadata:n}}function Ch(){if(typeof window>`u`||!window.localStorage)return{};try{let e=window.localStorage.getItem(xh);return e?Th(JSON.parse(e)):wh()}catch{return wh()}}function wh(){if(typeof window>`u`||!window.localStorage)return{};let e=window.localStorage.getItem(`fleet-prime:v1:chat-sessions`);if(!e)return{};try{return Th(JSON.parse(e)?.normal)}catch{return{}}}function Th(e){let t=Li.safeParse(e);return t.success?t.data:{}}function Eh(){typeof window>`u`||!window.localStorage||(window.localStorage.removeItem(xh),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`),window.localStorage.removeItem(`fleet-prime:v1:chat-mode`))}function Dh(e){if(!(typeof window>`u`||!window.localStorage)){if(!e.sessionId&&!e.projectId){window.localStorage.removeItem(xh),window.localStorage.removeItem(`fleet-prime:v1:chat-sessions`);return}window.localStorage.setItem(xh,JSON.stringify(e))}}function Oh({activeSessionId:e,messages:t,presentation:n,sessions:r}){return(0,Z.useMemo)(()=>Nh(e,r,t,n),[e,t,n,r])}function kh({messages:e,resources:t,workspaceTree:n}){return(0,Z.useMemo)(()=>Ah({messages:e,resources:t,workspaceTree:n}),[e,t,n])}function Ah({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=Mh([...e].reverse().find(e=>e.role===`user`)).toLowerCase(),c=Mh(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`)]:jh(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 jh(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 Mh(e){return e?e.parts.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(` `):``}function Nh(e,t,n,r){if(r?.sessionName?.trim())return Qr(r.sessionName);let i=t.find(t=>t.sessionId===e);if(i?.title.trim())return Qr(i.title);let a=[...n].reverse().find(e=>e.role===`user`&&e.source!==`local`);return Qr(Mh(a).trim())||(i?Qr(i.title||i.firstMessage||i.sessionId.slice(0,8)):`Session`)}var Ph=`https://docs.qredence.ai`;function Fh({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 Ih({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:K(`flex min-w-0 items-center gap-2`,a),children:(0,Q.jsx)(ll,{side:`bottom`,align:`start`,trigger:(0,Q.jsxs)(Ds,{ariaLabel:`Open account menu`,className:K(`min-w-0 border-transparent shadow-none`,r?`size-8 justify-center px-2`:`w-full justify-start`),children:[(0,Q.jsx)(Fh,{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)(Tr,{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)(Fh,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Account`})]}),(0,Q.jsxs)(`a`,{href:Ph,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(vr,{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)(En,{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)(_r,{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:Ph,target:`_blank`,rel:`noreferrer`,className:o,children:[(0,Q.jsx)(vr,{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)(En,{className:`size-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Settings`})]})]})})})}function Lh({activeSessionId:e,activeSessionLabel:t,onNewSession:n,onResumeSession:r,sessions:i}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ll,{side:`bottom`,align:`center`,className:`w-[min(360px,calc(100vw-2rem))]`,overlay:!0,trigger:(0,Q.jsxs)(Ds,{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)(qn,{className:`size-3 shrink-0 text-foreground/35`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:t})]}),(0,Q.jsx)(Tr,{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=Qr(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)(qn,{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)(Ds,{ariaLabel:`New session`,onClick:n,children:(0,Q.jsx)(si,{className:`size-3.5 shrink-0`})})]})}function Rh(e){return null}function zh(e){return typeof e==`object`&&!!e&&typeof e.ok==`boolean`}function Bh(e=15e3){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1,r=async()=>{try{let e=await fetch(Up(`/api/health`));if(!e.ok)throw Error(`http-${e.status}`);let r=await e.json();if(!zh(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 Vh({activeSessionId:e,activeSessionLabel:t,sessions:n,onNewSession:r,onResumeSession:i,onOpenSettings:a}){let o=c(),s=Wp(),l=Bh();return{left:(0,Q.jsx)(rc,{"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)(Ih,{className:`w-full`,label:`Qredence`,user:s,onSignOut:async()=>{Eh(),await Kp(),o({to:`/`})},onOpenSettings:a}),center:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Lh,{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)(Os,{})}}function Hh(e,t,n=crypto.randomUUID()){return{id:n,role:e,createdAt:Date.now(),parts:[{type:`text`,text:t}]}}function Uh(e){return{...Hh(`user`,e),optimistic:!0}}function Wh(e,t){return e.filter(e=>e.id!==t||e.optimistic!==!0)}function Gh(e,t){return e.map(e=>{if(e.id!==t||e.optimistic!==!0)return e;let n={...e};return delete n.optimistic,n})}function Kh(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 qh(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 Jh(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 Yh({messageId:e,presentation:t}){return{type:`tool-FleetReasoning`,toolCallId:`${e}-reasoning`,state:t.streaming?`input-streaming`:`output-available`,input:t}}function Xh(e,t,n){return e.map(e=>e.id===t?{...e,parts:Kh(e.parts,n)}:e)}function Zh(e,t,n){return e.map(e=>e.id===t?{...e,parts:qh(e.parts,n)}:e)}function Qh(e,t,n){return e.map(e=>e.id===t?{...e,parts:Jh(e.parts,n)}:e)}function $h(e,t,n){return Zh(e,t,Yh({messageId:t,presentation:n}))}function eg(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 tg(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var ng=`/api/chat/command`;function rg(e){return e.sessionId?.trim()||void 0}function ig({sessionId:e,name:t}){let n=e.trim()||`none`;return[t?`Session: ${t}`:`Session`,` id: ${n}`].join(`
|
|
13
|
-
`)}function ag(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 og(e){let{entry:t}=e;if(t.type===`message`&&t.message){let e=t.message.role??`message`,n=ag(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 sg(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} ${og(a)}`),r(a.children,i+1)}};return r(e,0),n}function cg(e,t){let n=sg(e,t);return n.length>0?n.join(`
|
|
14
|
-
`):`(empty session tree)`}function lg(e){let t=[],n=[],r=e=>{for(let i of e){if(i.entry.type===`message`){let e={id:i.entry.id,preview:og(i)};t.push(e),i.entry.message?.role===`user`&&n.push(e)}r(i.children)}};return r(e),n.length>0?n:t}function ug(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role!==`assistant`||n.source===`local`)continue;let r=tg(n).trim();if(r)return r}}function dg(e){return e.flatMap(e=>{if(e.source===`local`)return[];let t=tg(e).trim(),n=`**${e.role}**\n\n${t}`;return n.trim().length>0?[n]:[]}).join(`
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
`)}function fg({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=rg(n());if(!r)return{ok:!1,error:`No active session — start a new one first.`};try{let n=await fetch(ng,{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(Nn.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),Nn.success(`Model set to ${c.modelKey}`),!0):(u(!1),f(!0),!0);case`open-effort-picker`:return c.unknownLevel&&Nn.error(`Unknown thinking level '${c.unknownLevel}'.`),f(!1),u(!0),!0;case`set-thinking-level`:{let e=i.find(e=>e.id===r),t=qr(e);return t.includes(c.level)?(p(c.level),Nn.success(`Effort set to ${Jr(c.level)}`),!0):(Nn.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=rg(n()),r=await h(`session`);if(!r.ok||!t){e(ig({sessionId:t??`none`,name:null}));return}e(ig({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)?lg(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(cg(n.tree,n.leafId??null))})(),!0;case`session-share`:return(async()=>{let n=dg(t());if(!n.trim()){e(`Nothing to share yet.`);return}await navigator.clipboard.writeText(n),Nn.success(`Transcript copied`),e(`Copied the transcript to the clipboard. GitHub Gist upload is TUI-only in this port.`)})().catch(e=>{Nn.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(`
|
|
19
|
-
`)}`),!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=ug(t());if(!e){Nn.error(`No assistant message to copy`);return}await navigator.clipboard.writeText(e),Nn.success(`Last assistant message copied`)})().catch(e=>{Nn.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=ah(e.id);return t?_(t):!1},[_]),y=(0,Z.useCallback)(e=>{let t=rh(e);if(!t)return!1;let n=ah(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 pg({messages:e,answerQuestion:t}){let n=(0,Z.useRef)(new Map);return(0,Z.useMemo)(()=>{let r=mg(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)=>hg(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,gg(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 mg(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`&&Zm(t))return{part:t}}}}function hg(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 gg(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 _g(e){Em(e)||Nn.error(e instanceof Error?e.message:String(e))}var vg={steering:[],followUp:[]};function yg(e){let t=e.sessionId?.trim()||void 0,n=e.projectId?.trim()||void 0;return t||n?{...t?{sessionId:t}:{},...n?{projectId:n}:{}}:{}}function bg(e,t){let n=t.sessionId?.trim()||e.sessionId,r=t.projectId?.trim()||e.projectId;return{...n?{sessionId:n}:{},...r?{projectId:r}:{}}}function xg(e){return(e.parts??[]).some(e=>e.type!==`text`||typeof e.text==`string`&&e.text.trim().length>0)}function Sg(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,Hh(`assistant`,``,t)]}}}function Cg(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]}function wg(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 Tg(e,t,n){if(!xg(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=>xg(e));if(r)return Cg(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 Eg(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=Sg(e,t.message.id);return{assistantId:n.assistantId,snapshot:{...n.snapshot,messages:Tg(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,Hh(`assistant`,``,t.id)],sessionMetadata:bg(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`?Sg(e,t.messageId):e,{assistantId:r,snapshot:i}=n;if(t.type===`delta`&&r)return{assistantId:r,snapshot:{...i,messages:Xh(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:$h(i.messages,r,t.presentation)}};if(t.type===`tool`&&r)return{assistantId:r,snapshot:{...i,messages:Zh(i.messages,r,t.part)}};if(t.type===`payload`&&r)return{assistantId:r,snapshot:{...i,messages:Qh(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:Pm(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=eg(t.message),n=wg(i.messages,e,r),a=Tg(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=>eg(e)),queue:vg,presentation:o,sessionMetadata:bg(i.sessionMetadata,{sessionId:t.sessionId})}}}return n}function Dg(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 Og(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=Dg(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=Dg(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=Dg(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 kg=`plan-mode-decision`;function Ag(){return{enabled:!1,executing:!1,todos:[],pendingDecision:!1,pendingDecisionToolCallId:void 0}}function jg(e,t,n){let r=zg(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 Mg(e,t){if(!e.enabled)return{state:e,changed:!1};let n=Og(t);return n.length===0?{state:e,changed:!1}:{state:{...zg(e),todos:n,executing:!1,pendingDecision:!0,pendingDecisionToolCallId:void 0},changed:!0}}function Ng(e,t){return{enabled:e.mode===`plan`,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:e.pendingDecision,pendingDecisionToolCallId:e.pendingDecision?`${kg}-${t}`:void 0}}function Pg(e,t){return Fg(e,Ng(t,e))}function Fg(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:Bg(t),status:r,todos:n.todos}}}}function Ig(e){return!!e?.startsWith(kg)}function Lg(e,t){if(!e.pendingDecision)return e;let n=`${kg}-${t}`;return e.pendingDecisionToolCallId===n?e:{...zg(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 zg(e){return{enabled:e.enabled,executing:e.executing,todos:e.todos.map(e=>({...e})),pendingDecision:!!e.pendingDecision,pendingDecisionToolCallId:e.pendingDecisionToolCallId}}function Bg(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(`
|
|
20
|
-
`)}function Vg(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?Pg(e.id,t.state):void 0;return r?{...e,parts:qh(e.parts,r)}:e})}function Hg(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 Ug(e){e.setSessionMetadataSynced({}),e.setMessagesSynced([]),e.setQueueSynced(vg),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 Wg(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`),_g(t)}return!0}async function Gg(e,t,n){return Wg(e,wm,t,n)}async function Kg(e,t,n){return Wg(e,Tm,t,n)}function qg(){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 Jg=Promise.resolve();function Yg({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)(Jg),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(Vg(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 Dm(i);if(i.type===`done`&&i.sessionReset){o!==d.current.sessionId&&u();return}let f;if(i.type===`done`&&l===`plan`){let e=Mg(jg(Ag(),l),tg(i.message)),n=Lg(e.state,i.message.id);f=e.changed?Fg(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=Eg({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=>Zh(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=Uh(e);h(e=>[...e,o]),m(null);let s=w.current,c=qg(),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=>Gh(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 Dm(e)}),c.resolve()}catch(e){throw c.reject(e),h(e=>Wh(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),_g(t)}return}m(null),p(void 0),b(`submitted`),n.current.length===0&&(v.length,d.current.sessionId);let y=Uh(v);h(e=>[...e,y]);let S={current:null},w=qg();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=>Gh(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=>Wh(e,y.id)),T.signal.aborted)return;if(D&&d.current.sessionId!==D){u();return}let t={setError:m,setStatus:b};if(await Gg(e,l,t)||await Kg(e,l,t))return;let n=e instanceof Error?e:Error(String(e));m(n),b(`error`),_g(n)}finally{C.current.delete(w)&&w.reject(Error(`Chat stream ended before admission`)),T.signal.aborted&&h(e=>Wh(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 Xg(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 Zg(e,t,n){if(!Ig(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:Xg(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 Qg(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 $g(e,t){let{client:n=Im,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)(vg),[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)(S),j=(0,Z.useRef)(null),M=(0,Z.useRef)(new Map),N=(0,Z.useRef)(c),P=(0,Z.useRef)(!1),F=(0,Z.useRef)(()=>Promise.resolve()),I=(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(T.current):e;T.current=t,s(t)},[]),L=(0,Z.useCallback)(e=>{I(t=>[...t,{id:crypto.randomUUID(),role:`assistant`,source:`local`,createdAt:Date.now(),parts:[{type:`text`,text:e}]}])},[I]),R=(0,Z.useCallback)(e=>{let t=E.current,n=yg(e);(t.sessionId!==n.sessionId||t.projectId!==n.projectId)&&(E.current=n,p(n),i(n))},[i]),z=(0,Z.useCallback)(e=>{D.current=e,_(e)},[]),B=(0,Z.useCallback)(e=>{O.current=e,y(e)},[]),V=(0,Z.useCallback)(e=>{k.current=e,x(e)},[]),H=(0,Z.useCallback)(e=>{A.current=e,C(e)},[]),ee=(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&&H(r.presentation),r.artifact.id},[n,H]),U=(0,Z.useCallback)(async()=>{let e=await n.listSessions();return h(e),e},[n]),te=(0,Z.useCallback)(e=>Ug({client:n,projectId:e??a,refreshSessions:U,setActivityLabelSynced:z,setError:d,setMessagesSynced:I,setPlanLabelSynced:B,setPresentationSynced:H,setQueueSynced:V,setSessionMetadataSynced:R,setStatus:l}),[n,a,U,z,I,B,H,V,R]),ne=(0,Z.useCallback)(async({toolCallId:e,answer:t})=>{if(Ig(e)){let r=Zg(T.current,e,t);I(r);let i=Hg(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 F.current({text:`Execute the approved plan.`,mode:`agent`,planAction:`execute`,openUI:!0});let t=Hg(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&&I(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 F.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 F.current({text:r.message,planAction:r.planAction}),r},[n,I]),re=(0,Z.useCallback)(e=>Qg(e,ne),[ne]);(0,Z.useEffect)(()=>{E.current=f},[f]),(0,Z.useEffect)(()=>{N.current=c},[c]),(0,Z.useEffect)(()=>{w.current=r},[r]),(0,Z.useEffect)(()=>{let e=M.current;return()=>{j.current?.abort(),j.current=null;for(let t of e.values())t.abort();e.clear()}},[]),(0,Z.useEffect)(()=>{let e=!1;return U().catch(t=>{if(e)return;let n=t instanceof Error?t:Error(String(t));d(n),_g(n)}),()=>{e=!0}},[U]),(0,Z.useEffect)(()=>{if(P.current)return;P.current=!0;let e=new AbortController;l(`ready`),d(null),V(vg),z(void 0),B(void 0),I([]);let t=w.current;return U().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){R(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||(R(t.session),I(Vg(t.messages,t.planPresentations)),H(t.presentation),z(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 Gg(t,te,n)||await Kg(t,te,n)||e.signal.aborted)return;let r=t instanceof Error?t:Error(String(t));d(r),l(`error`),_g(r)}),()=>{e.abort()}},[n,z,I,B,H,V,R,U,te]);let{resetStreamAdmission:ie,sendMessage:ae,setAdapterCapabilities:oe}=Yg({activityLabelRef:D,client:n,messagesRef:T,presentationRef:A,model:e,pendingSendControllerRef:j,projectId:a,planLabelRef:O,queueRef:k,recoverFromForbiddenSession:te,refreshSessions:U,sessionMetadataRef:E,setActivityLabelSynced:z,setError:d,setMessagesSynced:I,setPresentationSynced:H,setPlanLabelSynced:B,setQueueSynced:V,setSessionMetadataSynced:R,setStatus:l,streamControllersRef:M,status:c}),se=(0,Z.useCallback)(()=>{let e=E.current;ie(e.sessionId),j.current?.abort(),j.current=null,e.sessionId&&n.abortSession(e).catch(()=>void 0),e.sessionId&&(M.current.get(e.sessionId)?.abort(),M.current.delete(e.sessionId)),l(`ready`),V(vg),z(void 0)},[n,ie,z,V]),ce=(0,Z.useCallback)(async e=>{e?.preserveRunning===!1?se():l(`ready`);let t=await n.createSession(e?.projectId??a);R(t.session),I([]),H(t.presentation),V(vg),z(void 0),B(void 0),Nn.success(`New session started`),await U()},[n,U,z,I,H,B,V,R,se,a]),le=(0,Z.useCallback)(async(e,t)=>{try{t?.preserveRunning===!1&&se();let r=await n.resumeSession(e);return R(r.session),I(Vg(r.messages,r.planPresentations)),H(r.presentation),V(vg),z(r.sessionReset?`Started a fresh Pi session`:void 0),B(void 0),l(M.current.has(r.session.sessionId??``)?`streaming`:`ready`),await U(),!0}catch(t){let n={setError:d,setStatus:l},r=()=>te(e.projectId);if(await Gg(t,r,n)||await Kg(t,r,n))return!1;let i=t instanceof Error?t:Error(String(t));return d(i),l(`error`),_g(i),!1}},[n,te,U,z,I,H,B,V,R,se]),ue=(0,Z.useCallback)(async(e,t)=>t?le({sessionId:t,projectId:e},{preserveRunning:!0}):(R({projectId:e}),I([]),H({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]}),V(vg),z(void 0),B(void 0),l(`ready`),!0),[le,z,I,B,H,V,R]);(0,Z.useEffect)(()=>{F.current=ae},[ae]),(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>(A.current?.revision??-1)&&H(i.presentation);return}let a=N.current;if(a===`streaming`||a===`submitted`)return;let o=i;if(o.type===`connected`){let e=o.adapterCapabilities;r.current=e,oe(e);return}if(i.type===`reasoning`){let e=r.current,t=i.messageId;if(!e?.features.includes(`reasoning-summary-v1`)||!t)return;I(e=>$h(e,t,i.presentation));return}if(i.type===`tool`&&i.part?.type===`tool-Question`){I(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(z(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&&(I(Vg(e.messages,e.planPresentations)),H(e.presentation),R(e.session),V(vg))}).catch(()=>void 0)}return}if(i.type===`queue`){V({steering:i.steering,followUp:i.followUp});return}},l=()=>{let n=new URLSearchParams({sessionId:e});i>0&&n.set(`lastEventId`,String(i));let r=Up(`/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,z,I,V,H,R,oe]);let de=(0,Z.useMemo)(()=>re(o),[o,re]),fe=(0,Z.useCallback)(async(e,t)=>{await n.renameSession(e,t),await U()},[n,U]),pe=(0,Z.useCallback)(async e=>{let t=E.current.sessionId===e;t&&se(),await n.deleteSession(e),t&&(R({}),I([]),H({revision:0,userBash:[],rlmChildren:[],refinements:[],artifactRuns:[]})),await U()},[n,U,I,H,R,se]),me=ne,he=(0,Z.useCallback)(()=>E.current,[]);return{activityLabel:g,answerQuestion:me,appendLocalMessage:L,deleteSession:pe,error:u,getMessages:(0,Z.useCallback)(()=>T.current,[]),getSessionMetadata:he,messages:de,planLabel:v,presentation:S,persistOpenUIArtifact:ee,queue:b,renameSession:fe,refreshSessions:U,resumeSession:le,sendMessage:ae,sessionMetadata:f,sessions:m,setError:d,startNewSession:ce,status:c,stop:se,switchProject:ue}}function e_({activityLabel:e,artifactRuns:t,chatMode:n,handleThemePreferenceChange:r,isLoadingProviders:i,isUpdatingProvider:a,loadWorkspaceFile:o,messages:s,modelKey:c,models:l,modelCatalog:u,onDiscoverModels:d,onOAuthLogin:f,onRemoveProvider:p,onUpdateProvider:m,openWorkspacePath:h,planLabel:g,presentation:_,providers:v,queue:y,refreshResources:b,refreshWorkspace:x,resources:S,resourcesError:C,resourcesLoading:w,rightPanel:T,reopenRightPanel:E,saveSettings:D,selectedArtifactId:O,sessionId:k,selectedWorkspacePath:A,setRightPanel:j,setSelectedWorkspacePath:M,settings:N,settingsError:P,settingsLoading:F,status:I,thinkingLevel:L,themePreference:R,workspaceError:z,workspaceLoading:B,workspaceTree:V}){let H=(0,Z.useMemo)(()=>({activityLabel:e,artifactRuns:t,chatMode:n,messages:s,models:l,planLabel:g,presentation:_,queue:y,refreshResources:b,resources:S,resourcesError:C,resourcesLoading:w,reopenRightPanel:E,rightPanel:T,selectedModelKey:c,selectedArtifactId:O,sessionId:k,setRightPanel:j,status:I,thinkingLevel:L}),[e,t,n,s,l,g,_,y,b,S,C,w,E,T,c,O,k,j,I,L]),ee=(0,Z.useMemo)(()=>({loadWorkspaceFile:o,openWorkspacePath:h,refreshWorkspace:x,selectedWorkspacePath:A,setSelectedWorkspacePath:M,workspaceError:z,workspaceLoading:B,workspaceTree:V}),[o,h,x,A,M,z,B,V]);return{chatPanelData:H,settingsActions:(0,Z.useMemo)(()=>({isLoadingProviders:i,isUpdatingProvider:a,modelCatalog:u,onDiscoverModels:d,onOAuthLogin:f,onRemoveProvider:p,onThemePreferenceChange:r,onUpdateProvider:m,providers:v,saveSettings:D,settings:N,settingsError:P,settingsLoading:F,themePreference:R}),[r,i,a,u,d,f,p,m,v,D,N,P,F,R]),workspaceTreeContext:ee}}var t_=`workspace:`;function n_(e,t=[]){for(let n of e)t.push(n),n.children&&n_(n.children,t);return t}function r_(e){return e?n_(e.nodes).map(e=>({id:`${t_}${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 i_(e){if(!e.id.startsWith(t_))return null;let t=e.id.slice(10);if(!t)return null;let n=Ni.safeParse(t);return n.success?n.data:null}async function a_(e,t){return Im.getWorkspaceFile(e,t)}function o_(e,t){return e.sessionId!==t.sessionId||e.projectId!==t.projectId}function s_(e,t){return!!e.sessionId||t!==void 0&&t!==e.projectId}function c_(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 l_(){let e=Wp(),[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),_=Sh(),[v,y]=(0,Z.useState)(_.sessionMetadata.projectId??void 0);(0,Z.useEffect)(()=>{},[e]);let{data:b,isLoading:x}=qm(),{data:S,refetch:C}=zm(),{mutateAsync:w,isPending:T}=Jm(),{mutateAsync:E}=Ym(),{mutateAsync:D,isPending:O}=Xm(),{data:k}=Rm(v),{data:A}=Bm({enabled:t,projectId:v}),j=Vm(),{commandPaletteOpen:M,handleResourceCanvasResizeStart:N,handleThemePreferenceChange:P,initialSessionMetadata:F,modelKey:I,modelSelection:L,models:R,openArtifact:z,openWorkspacePath:B,openPanelAction:V,persistSession:H,reopenRightPanel:ee,resourceCanvasWidth:U,rightPanel:te,selectedArtifactId:ne,selectedWorkspacePath:re,setCommandPaletteOpen:ie,setModelKey:ae,setRightPanel:oe,setSelectedWorkspacePath:se,setThinkingLevel:ce,themePreference:le,thinkingLevel:ue}=bh(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:de,isLoading:fe,error:pe,refetch:me}=Hm(v),{data:he}=Um(v),{data:ge,isLoading:_e,error:ve}=Wm(v),ye=Gm(),{data:be,isLoading:xe,error:Se,refetch:Ce}=Km(v,{enabled:!0}),we=de??null,Te=be??null,Ee=(0,Z.useCallback)(()=>{me()},[me]),De=(0,Z.useCallback)(async e=>{let t=await ye.mutateAsync({request:{settings:e},projectId:v}),n=c_(R,t);return n&&ae(n),t},[v,R,ae,ye]),Oe=(0,Z.useCallback)(()=>{Ce()},[Ce]),{activityLabel:ke,answerQuestion:Ae,appendLocalMessage:je,deleteSession:Me,error:Ne,getMessages:Pe,getSessionMetadata:Fe,messages:Ie,planLabel:Le,persistOpenUIArtifact:Re,presentation:ze,queue:W,renameSession:Be,resumeSession:Ve,sendMessage:He,sessionMetadata:G,sessions:Ue,startNewSession:We,switchProject:Ge,status:Ke,stop:qe}=$g(L,{initialSessionMetadata:F,projectId:v,persistSession:H}),Je=(0,Z.useMemo)(()=>qi(Ie,ze,Ke),[Ie,ze,Ke]),Ye=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{if(!ze.thinkingLevel)return;let e=`${G.sessionId}:${ze.thinkingLevel}`;Ye.current!==e&&(Ye.current=e,ce(ze.thinkingLevel))},[ze.thinkingLevel,G.sessionId,ce]);let Xe=(0,Z.useCallback)(()=>{f([]),m([])},[]),Ze=(0,Z.useCallback)(async e=>{let t=Fe(),n=e?.projectId??v,r=s_({...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=o_(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=o_(Fe(),{sessionId:t?.sessionId,projectId:e});y(e),se(null),await Ge(e,t?.sessionId)&&n&&Xe(),await C()},[Xe,Fe,C,se,Ue,Ge]),tt=(0,Z.useCallback)(async e=>{y(e),se(null),await Ze({projectId:e}),await C()},[C,se,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 Im.createProject(e);await C(),await et(t.projectId)},[C,et]),it=(0,Z.useCallback)(async(e,t)=>{await Im.renameProject(e,t),await C()},[C]),at=(0,Z.useCallback)(async e=>{await Im.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),se(null),await Ge(``,void 0)&&Xe())}},[v,Xe,C,et,se,Ge]),ot=(0,Z.useCallback)(e=>Im.browseProjectDirectories(e),[]),st=(0,Z.useCallback)(async(e,t)=>{await Im.forkSessionIntoProject(e,t),await C()},[C]);(0,Z.useEffect)(()=>{G.sessionId&&C()},[C,G.sessionId]),G.sessionId;let ct=Ur(W)??ke??Le,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 Im.uploadAttachments(n,t);f(e=>[...e,...r])})().catch(e=>{_g(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=i_(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})=>{Ae({toolCallId:e,answer:t}).catch(e=>{_g(e)})},[Ae]),gt=pg({messages:Ie,answerQuestion:ht}),_t=Oh({activeSessionId:G.sessionId,messages:Ie,presentation:ze,sessions:Ue}),vt=kh({messages:Ie,resources:we,workspaceTree:Te}),yt=(0,Z.useMemo)(()=>{if(Ie.length===0||Ke===`streaming`||Ke===`submitted`)return!1;let e=Ie[Ie.length-1];return e.role===`assistant`&&!Qm(e)},[Ie,Ke]),bt=(0,Z.useMemo)(()=>yt?vt:[],[yt,vt]),xt=(0,Z.useMemo)(()=>ch(we,ge?.effective.enableSkillCommands??!1,he),[he,we,ge]),St=(0,Z.useMemo)(()=>r_(Te),[Te]),Ct=(0,Z.useCallback)(e=>{if(e.projectId&&e.projectId!==v){Nn.error(`This panel action targets a different project.`);return}V(e)},[v,V]),wt=(0,Z.useCallback)(e=>{i(e),n(!0)},[]),{forkFromEntry:Tt,handleLocalSlashSubmit:Et,handleSlashCommandSelect:Dt}=fg({appendLocalMessage:je,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:wt,resumeSession:$e,sessions:Ue,setEffortPickerOpen:c,setModelKey:ae,setModelPickerOpen:o,setThinkingLevel:ce,startNewSession:Ze}),Ot=(0,Z.useMemo)(()=>A?.models.map(ei)??R,[A,R]),kt=(0,Z.useCallback)(e=>a_(e,v),[v]),At=(0,Z.useCallback)(async e=>(await j.mutateAsync(e)).models.map(ei),[j]),{chatPanelData:jt,settingsActions:Mt,workspaceTreeContext:Nt}=e_({activityLabel:ke,artifactRuns:Je,chatMode:l,handleThemePreferenceChange:P,isLoadingProviders:x,isUpdatingProvider:T||O,loadWorkspaceFile:kt,messages:Ie,modelKey:I,models:R,modelCatalog:Ot,onDiscoverModels:At,onOAuthLogin:E,onRemoveProvider:D,onUpdateProvider:w,openWorkspacePath:B,planLabel:Le,presentation:ze,providers:b?.providers??[],queue:W,refreshResources:Ee,refreshWorkspace:Oe,resources:we,resourcesError:pe,resourcesLoading:fe,reopenRightPanel:ee,rightPanel:te,saveSettings:De,selectedArtifactId:ne,sessionId:G.sessionId,selectedWorkspacePath:re,setRightPanel:oe,setSelectedWorkspacePath:se,settings:ge??null,settingsError:ve,settingsLoading:_e||ye.isPending,status:Ke,thinkingLevel:ue,themePreference:le,workspaceError:Se,workspaceLoading:xe,workspaceTree:Te}),Pt=Vh({activeSessionId:G.sessionId,activeSessionLabel:_t,sessions:Ue,onNewSession:()=>void Ze(),onResumeSession:e=>void $e(e),onOpenSettings:()=>wt()});return{session:{activeSessionId:G.sessionId,activeProjectId:v,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:ke,artifactRuns:Je,error:Ne,messages:Ie,openArtifact:z,openPanelAction:Ct,persistOpenUIArtifact:Re,presentation:ze,sendMessage:He,status:Ke,stop:qe},composer:{answerQuestion:Ae,chatMode:l,clearUploadedAttachments:dt,clearWorkspaceAttachments:ft,effortPickerOpen:s,handleAttach:lt,handleLocalSlashSubmit:Et,handleQuestionAnswer:ht,handleSlashCommandSelect:Dt,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:ae,setModelPickerOpen:o,setThinkingLevel:ce,slashCommands:xt,thinkingLevel:ue,uploadedAttachments:d,workspaceAttachments:p},panels:{chatPanelData:jt,handleResourceCanvasResizeStart:N,resourceCanvasWidth:U,rightPanel:te,setRightPanel:oe,settingsActions:Mt,workspaceTreeContext:Nt},dialogs:{commandPaletteOpen:M,forkFromEntry:Tt,forkPickerEntries:h,setCommandPaletteOpen:ie,setForkPickerEntries:g,setSettingsDialogOpen:n,setSettingsInitialTab:i,settingsDialogOpen:t,settingsInitialTab:r},chrome:{handleThemePreferenceChange:P,header:Pt,themePreference:le}}}var u_=`fleet-prime:v1:panel-keybindings`,d_={toggleResources:{code:`Digit1`,ctrlOrMeta:!0,shift:!0},toggleWorkspace:{code:`Digit2`,ctrlOrMeta:!0,shift:!0},toggleArtifacts:{code:`Digit3`,ctrlOrMeta:!0,shift:!0},closePanel:{code:`Escape`},focusPanel:{code:`KeyP`,ctrlOrMeta:!0,shift:!0},focusChat:{code:`KeyC`,ctrlOrMeta:!0,shift:!0}};function f_(){try{let e=window.localStorage.getItem(u_);if(!e)return d_;let t=JSON.parse(e);return{...d_,...t}}catch{return d_}}function p_(e,t){return e.code===t.code&&(e.ctrlKey||e.metaKey)===!!t.ctrlOrMeta&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}function m_(){document.querySelector(`[data-fleet-chat-focus] textarea, [data-fleet-chat-focus] [contenteditable='true'], [data-fleet-chat-focus] input`)?.focus({preventScroll:!0})}function h_({rightPanel:e,setRightPanel:t}){(0,Z.useEffect)(()=>{let n=f_(),r=r=>{let i=e=>p_(r,n[e]),a=!0;i(`toggleResources`)?t(e===`resources`?null:`resources`):i(`toggleWorkspace`)?t(e===`workspace`?null:`workspace`):i(`toggleArtifacts`)?t(e===`artifacts`?null:`artifacts`):e&&i(`closePanel`)?(t(null),m_()):e&&i(`focusPanel`)?document.querySelector(`[data-fleet-panel-focus]`)?.focus({preventScroll:!0}):i(`focusChat`)?m_():a=!1,a&&(r.preventDefault(),r.stopPropagation())};return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)},[e,t])}var g_=(0,Z.lazy)(()=>di(async()=>{let{ChatCommandPalette:e}=await import(`./chat-command-palette-HpsmKfLO.js`);return{ChatCommandPalette:e}},__vite__mapDeps([40,1,2,4,41,9,3,5,6,7,8,10,12,42,43,44,14,38,18,45,23,46])).then(({ChatCommandPalette:e})=>({default:e}))),__=(0,Z.lazy)(()=>di(async()=>{let{SettingsDialog:e}=await import(`./settings-dialog-6p8mjg8t.js`);return{SettingsDialog:e}},__vite__mapDeps([47,1,2,4,5,3,6,7,8,48,30,9,10,11,12,13,14,49,34,50,35,37,51,46,44,32,38,45,22])).then(({SettingsDialog:e})=>({default:e}))),v_=(0,Z.lazy)(()=>di(async()=>{let{ForkPickerDialog:e}=await import(`./fork-picker-dialog-C2cVJUbf.js`);return{ForkPickerDialog:e}},__vite__mapDeps([52,4,1,9,2,3,5,6,7,8,10])).then(({ForkPickerDialog:e})=>({default:e})));function y_(){let{session:{activeSessionId:e,browseProjectDirectories:t,createProject:n,deleteSession:r,forkSessionIntoProject:i,activeProjectId:a,projects:o,projectSessions:s,selectProject:c,renameProject:l,unregisterProject:u,renameSession:d,resumeSession:f,sessions:p,startNewSession:m,startNewSessionInProject:h},conversation:{activityLabel:g,artifactRuns:_,error:v,messages:y,openArtifact:b,openPanelAction:x,persistOpenUIArtifact:S,presentation:C,sendMessage:w,status:T,stop:E},composer:{chatMode:D,clearUploadedAttachments:O,clearWorkspaceAttachments:k,effortPickerOpen:A,handleLocalSlashSubmit:j,handleAttach:M,handleQuestionAnswer:N,handleSlashCommandSelect:P,infoDescription:F,inputSuggestionItems:I,workspaceReferenceSuggestions:L,modelKey:R,modelPickerOpen:z,models:B,uploadedAttachments:V,workspaceAttachments:H,addWorkspaceAttachment:ee,removeUploadedAttachment:U,removeWorkspaceAttachment:te,pendingQuestionBar:ne,setChatMode:re,setEffortPickerOpen:ie,setModelKey:ae,setModelPickerOpen:oe,setThinkingLevel:se,slashCommands:ce,thinkingLevel:le},panels:{chatPanelData:ue,handleResourceCanvasResizeStart:de,resourceCanvasWidth:fe,rightPanel:pe,setRightPanel:me,settingsActions:he,workspaceTreeContext:ge},dialogs:{commandPaletteOpen:_e,forkFromEntry:ve,forkPickerEntries:ye,setCommandPaletteOpen:be,setForkPickerEntries:xe,setSettingsDialogOpen:Se,setSettingsInitialTab:Ce,settingsDialogOpen:we,settingsInitialTab:Te},chrome:{handleThemePreferenceChange:Ee,header:De,themePreference:Oe}}=l_(),ke=(0,Z.useEffectEvent)(e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),be(!_e))});(0,Z.useEffect)(()=>{let e=e=>ke(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),h_({rightPanel:pe,setRightPanel:me});let Ae=o.find(e=>e.projectId===a)?.name,je=(0,Z.useCallback)((e,t)=>{let n=[...H,...V];O(),k(),(async()=>{await w({text:e,altKey:t,mode:D,openUI:!0,attachments:n})})()},[D,O,k,w,V,H]),Me=(0,Z.useCallback)(e=>{let t=wi(e);if(t){x(t);return}w({text:e,altKey:!1,mode:D,openUI:!0})},[D,x,w]),Ne=(0,Z.useCallback)(async e=>{try{return await S(e)}catch(e){Nn.error(`Artifact persistence failed: ${e instanceof Error?e.message:String(e)}`);return}},[S]),Pe=(0,Z.useCallback)(e=>{Se(e),e||Ce(void 0)},[Se,Ce]);return(0,Q.jsxs)(Q.Fragment,{children:[_e?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(g_,{open:!0,onOpenChange:be,onNewSession:()=>void m(),onStop:E,onResumeSession:e=>void f({sessionId:e.sessionId}),onSetRightPanel:me,onThemeChange:Ee,sessions:p,isStreaming:T===`streaming`,themePreference:Oe})}):null,(0,Q.jsxs)(ai,{chatPanelData:ue,onOpenUIAction:Me,settingsActions:he,workspaceTree:ge,children:[(0,Q.jsxs)(fc,{className:`h-svh min-h-0 rounded-none border-0`,sidebarWidth:`17.5rem`,children:[(0,Q.jsx)(bu,{data:{sessions:p,projects:o,projectSessions:s,activeProjectId:a,activeSessionId:e},sessionActions:{onNewSession:()=>void m(),onNewSessionInProject:h,onResumeSession:e=>void f({sessionId:e.sessionId}),onRenameSession:(e,t)=>void d(e,t),onDeleteSession:e=>void r(e)},projectActions:{onProjectSelect:c,onCreateProject:n,onRenameProject:l,onUnregisterProject:u,onForkSessionIntoProject:i},navigationActions:{onOpenPanelAction:x,onBrowseDirectories:t,onOpenSettings:()=>Se(!0)},slots:{accountMenu:De.accountMenu}}),(0,Q.jsx)(ac,{className:`h-svh min-h-0 overflow-hidden`,children:(0,Q.jsx)(Fs,{headerLeft:De.left,headerCenter:De.center,headerRight:De.right,panel:(0,Q.jsx)(vi,{children:(0,Q.jsx)(Ns,{handleResourceCanvasResizeStart:de,resourceCanvasWidth:fe})}),children:(0,Q.jsx)(zp,{messages:y,status:T,error:v??void 0,workspaceName:Ae,activityLabel:g,presentation:C,artifactRuns:_,onOpenArtifact:b,onOpenUIArtifactReady:Ne,inputSuggestionItems:I,suppressQuestionTool:!!ne,inputBar:{modelKey:R,models:B,infoDescription:F,slashCommands:ce,questionBar:ne,chatMode:D,onChatModeChange:re,onModelChange:ae,thinkingLevel:le,onThinkingLevelChange:se,attachments:{onAttach:M,images:V.flatMap(t=>t.mimeType.startsWith(`image/`)?[{id:t.attachmentId,filename:t.name,size:t.size,url:Up(`/api/chat/session?sessionId=${encodeURIComponent(e??``)}&attachmentId=${encodeURIComponent(t.attachmentId)}`)}]:[]),files:V.flatMap(e=>e.mimeType.startsWith(`image/`)?[]:[{id:e.attachmentId,filename:e.name,size:e.size}]),onRemoveImage:U,onRemoveFile:U},workspaceReferences:H,workspaceSuggestions:L,onWorkspaceReferenceSelect:ee,onRemoveWorkspaceReference:te,onSlashCommandSelect:P,onLocalSlashSubmit:j,modelPickerOpen:z,onModelPickerOpenChange:oe,effortPickerOpen:A,onEffortPickerOpenChange:ie},onSend:je,onOpenUIAction:Me,onStop:E,onQuestionAnswer:N})})})]}),we?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(__,{open:!0,onOpenChange:Pe,initialTab:Te})}):null,ye?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(v_,{entries:ye,onOpenChange:e=>{e||xe(null)},onPick:ve})}):null]})]})}var b_=y_;export{b_ as component};
|