nextclaw 0.19.31-beta.7 → 0.19.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/package.json +16 -16
  2. package/ui-dist/assets/{channels-list-page-D-tv11dc.js → channels-list-page-DXH1qYLs.js} +1 -1
  3. package/ui-dist/assets/{chat-page-MyXEZI8R.js → chat-page-Cpo0AFHb.js} +1 -1
  4. package/ui-dist/assets/{desktop-update-config-oZpIKKtS.js → desktop-update-config-Be8x1jNy.js} +1 -1
  5. package/ui-dist/assets/doc-browser-BI7HSaMK.js +3 -0
  6. package/ui-dist/assets/doc-browser-yTfN7UBH.js +1 -0
  7. package/ui-dist/assets/{index-D2H2CKYR.js → index-GVTiCf1s.js} +4 -4
  8. package/ui-dist/assets/{mcp-marketplace-page-CegP14Hl.js → mcp-marketplace-page-DDjeHd1I.js} +1 -1
  9. package/ui-dist/assets/mcp-marketplace-page-WUkc7n94.js +1 -0
  10. package/ui-dist/assets/{model-config-fIE_Asps.js → model-config-BjXMpU9U.js} +1 -1
  11. package/ui-dist/assets/{provider-scoped-model-input-D4zRsGZ6.js → provider-scoped-model-input-t1tCP5y5.js} +1 -1
  12. package/ui-dist/assets/{providers-list-CqsOk2hr.js → providers-list-C1D5p9kK.js} +1 -1
  13. package/ui-dist/assets/remote-BHeENKxL.js +1 -0
  14. package/ui-dist/assets/{runtime-config-page-BJ86cC8a.js → runtime-config-page--O0Wq01S.js} +1 -1
  15. package/ui-dist/assets/{search-config-TbCPlRE7.js → search-config-Dzpizo-_.js} +1 -1
  16. package/ui-dist/assets/{secrets-config-DBIEKP_V.js → secrets-config-D1AUSEXX.js} +1 -1
  17. package/ui-dist/index.html +2 -2
  18. package/ui-dist/assets/doc-browser-B2OFjScU.js +0 -3
  19. package/ui-dist/assets/doc-browser-BrUQEZ1j.js +0 -1
  20. package/ui-dist/assets/mcp-marketplace-page-MjpFEEkY.js +0 -1
  21. package/ui-dist/assets/remote-BMWQUPDW.js +0 -1
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-BrUQEZ1j.js","assets/doc-browser-B2OFjScU.js","assets/react-B2X_ph0a.js","assets/createLucideIcon-Br1EFMEr.js","assets/search-CdhgFNwf.js","assets/book-open-cPX0Za7Z.js","assets/wrench-qVIwShTF.js","assets/external-link-C3usm3se.js","assets/plus-BcIC8dG1.js","assets/x-Chb07O-Y.js","assets/doc-browser-context-DB6TTHeE.js","assets/doc-browser-route-registry.utils-x5ijvk0u.js","assets/model-config-fIE_Asps.js","assets/api-DruAcori.js","assets/provider-scoped-model-input-D4zRsGZ6.js","assets/config-hints-CY1lg9IE.js","assets/chat-page-MyXEZI8R.js","assets/confirm-dialog-B0TP-vPd.js","assets/dist-rzakR_bu.js","assets/dist-CpwDZDtv.js","assets/mcp-marketplace-page-CegP14Hl.js","assets/tag-chip-ix15P-r4.js","assets/play-CqNi0u02.js","assets/tabs-custom-BBXu1OGs.js","assets/search-config-TbCPlRE7.js","assets/config-split-page-BFh_Qixx.js","assets/providers-list-CqsOk2hr.js","assets/setting-row-8VkukJoH.js","assets/channels-list-page-D-tv11dc.js","assets/runtime-config-page-BJ86cC8a.js","assets/save-D10M5vQg.js","assets/desktop-update-config-oZpIKKtS.js","assets/secrets-config-DBIEKP_V.js","assets/mcp-marketplace-page-MjpFEEkY.js"])))=>i.map(i=>d[i]);
2
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g}from"./react-B2X_ph0a.js";import{$ as _,At as v,B as y,Ct as b,Dt as x,Et as S,F as C,Ft as w,G as T,H as E,I as ee,It as D,J as O,K as k,L as te,Lt as A,M as ne,Mt as j,N as re,Nt as M,Ot as ie,P as ae,Pt as oe,Q as se,R as ce,Rt as le,St as ue,Tt as de,U as fe,V as pe,W as me,X as he,Xt as ge,Y as _e,Yt as ve,Z as ye,_ as be,_t as xe,a as Se,at as Ce,c as we,d as Te,dt as Ee,f as De,g as Oe,gt as ke,h as Ae,i as je,it as Me,jt as Ne,kt as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,o as Be,on as Ve,ot as N,p as He,pt as Ue,q as We,r as Ge,rt as Ke,s as qe,st as Je,t as Ye,u as Xe,ut as Ze,v as Qe,vt as $e,wt as et,xt as tt,y as nt,yt as rt,z as it,zt as at}from"./api-DruAcori.js";import{a as ot,c as st,d as ct,f as lt,i as ut,l as dt,m as ft,n as pt,o as mt,r as ht,s as gt,u as _t}from"./doc-browser-B2OFjScU.js";import{C as vt,S as yt,_ as bt,a as xt,b as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,l as kt,m as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,t as It,u as Lt,v as Rt,w as zt,y as Bt}from"./dist-rzakR_bu.js";import{t as Vt}from"./dist-CpwDZDtv.js";import{a as Ht,c as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-B0TP-vPd.js";import{t as P}from"./createLucideIcon-Br1EFMEr.js";import{n as Xt,t as Zt}from"./search-CdhgFNwf.js";import{t as Qt}from"./book-open-cPX0Za7Z.js";import{n as $t,t as en}from"./wrench-qVIwShTF.js";import{t as tn}from"./external-link-C3usm3se.js";import{t as nn}from"./plus-BcIC8dG1.js";import{t as rn}from"./x-Chb07O-Y.js";import{l as an,n as on,r as sn,t as cn}from"./doc-browser-route-registry.utils-x5ijvk0u.js";import{i as ln,n as un,r as dn,t as fn}from"./doc-browser-context-DB6TTHeE.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pn=a((e=>{var t=Ve();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),mn=P(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),hn=P(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),gn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),_n=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),vn=P(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),yn=P(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),bn=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),xn=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Sn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Cn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),wn=P(`CircleHelp`,[[`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`}]]),Tn=P(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),En=P(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Dn=P(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),On=P(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),kn=P(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),An=P(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),jn=P(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Mn=P(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Nn=P(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Pn=P(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 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:`fq0c9t`}],[`path`,{d:`M8 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:`4gibmv`}]]),Fn=P(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),In=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Ln=P(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Rn=P(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),zn=P(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Bn=P(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Vn=P(`FolderTree`,[[`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`}]]),Hn=P(`FolderUp`,[[`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`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),Un=P(`FolderX`,[[`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`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Wn=P(`Folder`,[[`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`}]]),Gn=P(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Kn=P(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),qn=P(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),Jn=P(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Yn=P(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Xn=P(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Zn=P(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qn=P(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),$n=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),er=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),tr=P(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),nr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),rr=P(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),ir=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),ar=P(`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`}]]),or=P(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),sr=P(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),cr=P(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),lr=P(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),ur=P(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),dr=P(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),fr=P(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),pr=P(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),mr=P(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),hr=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),gr=P(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),_r=P(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),vr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),yr=P(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),br=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),xr=P(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Sr=P(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Cr=P(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),wr=P(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),F=g(o(),1),Tr=pn(),I=l(),Er={active:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},ready:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},inactive:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},setup:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},warning:{dot:`bg-amber-400`,text:`text-amber-600`,bg:`bg-amber-50`}};function Dr({status:e,label:t,className:n}){let i=Er[e];return(0,I.jsxs)(`div`,{className:r(`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5`,i.bg,n),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,i.dot)}),(0,I.jsx)(`span`,{className:r(`text-[11px] font-medium`,i.text),children:t})]})}function Or(){return at({queryKey:jr,queryFn:Se,staleTime:5e3,refetchOnWindowFocus:!0})}function kr(e){let{label:t,muted:n,value:r}=e;return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,I.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function Ar(){let e=ko(),t=Or(),n=t.data,r=zr(e=>e.actionLabel),i=(0,F.useMemo)(()=>Gr(n),[n]),a=!!r,o=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||s(`remoteDeviceNameAuto`),c=!!(n?.account.loggedIn&&Rr(n)),{hero:l,issueHint:d}=i;return(0,F.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,I.jsx)(`div`,{className:`p-8 text-gray-400`,children:s(`remoteLoading`)}):(0,I.jsxs)(v,{className:`space-y-6`,children:[(0,I.jsx)(Pe,{title:s(`remotePageTitle`),description:s(`remotePageDescription`)}),(0,I.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(ie,{children:l.title}),(0,I.jsx)(Dr,{status:l.badgeStatus,label:l.badgeLabel})]}),(0,I.jsx)(S,{children:l.description})]}),(0,I.jsxs)(de,{className:`space-y-5`,children:[(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(kr,{label:s(`remoteSignedInAccount`),value:n?.account.email}),(0,I.jsx)(kr,{label:s(`remoteDeviceName`),value:o}),(0,I.jsx)(kr,{label:s(`remoteConnectionStatus`),value:l.badgeLabel}),(0,I.jsx)(kr,{label:s(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?u(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.primaryAction?(0,I.jsxs)(M,{onClick:()=>{if(i.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(i.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:a,children:[i.primaryAction.showRefreshIcon?(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}):null,r||i.primaryAction.label]}):null,(0,I.jsxs)(M,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:a||!c,children:[(0,I.jsx)(_r,{className:`mr-2 h-4 w-4`}),s(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,I.jsx)(M,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:a,children:s(`remoteDisable`)}):null]}),i.shouldShowIssueHint&&d?(0,I.jsx)(Gt,{tone:`warning`,title:d.title,description:d.body}):null,(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:s(`remoteOpenWebHint`)})]})]}),(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{children:[(0,I.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Xn,{className:`h-4 w-4 text-primary`}),s(`remoteDeviceSectionTitle`)]}),(0,I.jsx)(S,{children:s(`remoteDeviceSectionDescription`)})]}),(0,I.jsxs)(de,{className:`space-y-5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(Dr,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?s(`remoteAccountConnected`):s(`remoteAccountNotConnected`)}),(0,I.jsx)(Dr,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?s(`remoteEnabled`):s(`remoteStateDisabled`)}),(0,I.jsx)(Dr,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?s(`remoteServiceRunning`):s(`remoteServiceStopped`)})]}),(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(kr,{label:s(`remoteDeviceName`),value:o}),(0,I.jsx)(kr,{label:s(`remoteConnectionStatus`),value:l.badgeLabel}),(0,I.jsx)(kr,{label:s(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?u(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsx)(Gt,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?s(`remoteOpenWebHint`):s(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var jr=[`remote-status`],Mr=`https://platform.nextclaw.io`,Nr=`https://nextclaw-platform-console.pages.dev`,Pr=async()=>await w.fetchQuery({queryKey:jr,queryFn:Se,staleTime:5e3}),Fr=async()=>(await w.invalidateQueries({queryKey:jr}),await Pr()),Ir=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function Lr(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return Mr;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return Nr}var Rr=e=>Lr(e?.account.apiBase)||Lr(e?.settings.platformApiBase)||Lr(e?.platformBase)||Lr(e?.account.platformBase)||void 0,zr=m(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),Br=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=zr.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{zr.getState().setEnabled(e)},this.setDeviceName=e=>{zr.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{zr.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{zr.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await Fr(),n=zr.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await Fr();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await Fr(),n=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:s(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await Ge(n);let e=await Fr();this.hydrateDraftFromStatus(e)},successMessage:s(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await Fr(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:zr.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await Fr(),n=zr.getState();await this.runManagedAction({actionLabel:s(`remoteActionSavingAdvanced`),job:async()=>{await Xe({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await Fr();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?s(`remoteSettingsSaved`):s(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:s(`remoteDoctorRunning`),job:async()=>{let e=await je();zr.getState().setDoctor(e)},successMessage:s(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,s(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,s(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,s(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let n=zr.getState();await this.runManagedAction({actionLabel:s(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await Xe({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await Fr();this.hydrateDraftFromStatus(r),e?await Ge(r.service.running?`restart`:`start`):t.service.running&&await Ge(`restart`);let i=await Fr();this.hydrateDraftFromStatus(i)},successMessage:s(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await Ge(e),n=await Fr();this.hydrateDraftFromStatus(n),A.success(t.message)}})},this.hydrateDraftFromStatus=e=>{zr.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:n,successMessage:r}=e;zr.getState().beginAction(t);try{await n(),r&&A.success(r)}catch(e){let t=e instanceof Error?e.message:s(`error`);throw A.error(t),e}finally{zr.getState().finishAction()}}}},Vr=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function Hr(e){return e?.runtime?.lastError?.trim()||``}function Ur(e){let t=s(`remoteStatusIssueDetailGeneric`),n=Hr(e);return n?`${t} (${n})`:t}function Wr(e){if(!e?.settings.enabled)return!1;let t=Hr(e);return Vr.some(e=>e.test(t))}function Gr(e){return Wr(e)?{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteStateReauthorizationRequired`),title:s(`remoteStatusReauthorizationTitle`),description:s(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:s(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:s(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:s(`statusReady`),title:s(`remoteStatusReadyTitle`),description:s(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:s(`connecting`),title:s(`remoteStatusConnectingTitle`),description:s(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteStateDisconnected`),title:s(`remoteStatusIssueTitle`),description:s(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:Ur(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteServiceStopped`),title:s(`remoteStatusNeedsServiceTitle`),description:s(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:s(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:s(`statusInactive`),title:s(`remoteStatusNeedsEnable`),description:s(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:s(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:s(`statusSetup`),title:s(`remoteStatusNeedsSignIn`),description:s(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:s(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Kr=m(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function qr({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,I.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Jr(e){let{email:t,username:n,role:r,canSubmitUsername:i,savingUsername:a,usernameDraft:o,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Gt,{tone:`success`,title:s(`accountPanelSignedInTitle`),description:s(`accountPanelSignedInDescription`)}),(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(qr,{label:s(`remoteAccountEmail`),value:t}),(0,I.jsx)(qr,{label:s(`remoteAccountUsername`),value:n}),(0,I.jsx)(qr,{label:s(`remoteAccountRole`),value:r})]}),n?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:s(`remoteAccountUsernameLockedHelp`)}):(0,I.jsxs)(Gt,{tone:`warning`,title:s(`remoteAccountUsernameRequiredTitle`),description:s(`remoteAccountUsernameRequiredDescription`),children:[(0,I.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,I.jsx)(Ne,{htmlFor:`account-panel-username`,children:s(`remoteAccountUsername`)}),(0,I.jsx)(j,{id:`account-panel-username`,value:o,onChange:e=>c(e.target.value),placeholder:s(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,I.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,I.jsx)(M,{disabled:!i,onClick:()=>void l(),children:s(a?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsxs)(M,{onClick:()=>void u(),children:[(0,I.jsx)(_r,{className:`mr-2 h-4 w-4`}),s(`remoteOpenDeviceList`)]}),(0,I.jsxs)(M,{variant:`outline`,onClick:()=>void d(),children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4`}),s(`remoteLogout`)]})]})]})}function Yr(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:r,authVerificationUri:i,onStartBrowserSignIn:a,onResumeBrowserSignIn:o}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Gt,{tone:`neutral`,title:s(`accountPanelSignedOutTitle`),description:s(`accountPanelSignedOutDescription`),children:t?(0,I.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,I.jsx)(qr,{label:s(`remoteBrowserAuthSession`),value:t}),(0,I.jsx)(qr,{label:s(`remoteBrowserAuthExpiresAt`),value:n?u(n):`-`})]}):null}),r?(0,I.jsx)(`p`,{className:`text-sm text-gray-600`,children:r}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsx)(M,{onClick:()=>void a(),children:s(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),i?(0,I.jsx)(M,{variant:`outline`,onClick:o,children:s(`remoteBrowserAuthResume`)}):null]})]})}function Xr(){let e=ko(),t=Or(),n=Kr(e=>e.panelOpen),r=Kr(e=>e.authSessionId),i=Kr(e=>e.authVerificationUri),a=Kr(e=>e.authExpiresAt),o=Kr(e=>e.authStatusMessage),c=t.data,[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(!1);(0,F.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,I.jsx)(qt,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,I.jsxs)(Wt,{className:`max-w-xl`,children:[(0,I.jsxs)(Jt,{children:[(0,I.jsxs)(Ut,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Jn,{className:`h-5 w-5 text-primary`}),s(`accountPanelTitle`)]}),(0,I.jsx)(Ht,{children:s(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,I.jsx)(Jr,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,I.jsx)(Yr,{authSessionId:r,authExpiresAt:a,authStatusMessage:o,authVerificationUri:i,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Zr({username:e}){let t=Ee(),[n,r]=(0,F.useState)(e??``),[i,a]=(0,F.useState)(``),o=n.trim().length>0&&i.length>0&&!t.isPending;return(0,I.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,I.jsxs)(et,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,I.jsxs)(x,{children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:s(`authBrand`)}),(0,I.jsx)(ie,{className:`text-2xl`,children:s(`authLoginTitle`)}),(0,I.jsx)(S,{children:s(`authLoginDescription`)})]}),(0,I.jsx)(de,{children:(0,I.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),o&&t.mutate({username:n.trim(),password:i})},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:s(`authUsername`)}),(0,I.jsx)(j,{value:n,onChange:e=>r(e.target.value),placeholder:s(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:s(`authPassword`)}),(0,I.jsx)(j,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:s(`authPasswordPlaceholder`)})]}),(0,I.jsx)(M,{type:`submit`,className:`w-full`,disabled:!o,children:t.isPending?s(`authLoggingIn`):s(`authLoginAction`)})]})})]})})}var Qr=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{Kr.getState().openPanel()},this.closeAccountPanel=()=>{Kr.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),Kr.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await Pr();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,n=await we({apiBase:Ir(e?.status??await Pr(),t)});Kr.getState().beginBrowserAuth({sessionId:n.sessionId,verificationUri:n.verificationUri,expiresAt:n.expiresAt,intervalMs:n.intervalMs,statusMessage:s(`remoteBrowserAuthWaiting`)}),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`)||Kr.getState().setAuthStatusMessage(s(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:s(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),A.error(`${s(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Kr.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await Be(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),Kr.getState().clearBrowserAuth(),await Fr(),A.success(s(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:s(`remoteLogoutFailed`);A.error(`${s(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await Fe({username:e.trim()}),await Fr(),A.success(s(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:s(`remoteAccountUsernameSetFailed`);A.error(`${s(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=Rr(await Pr());if(!t){A.error(s(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(n,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Kr.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Kr.getState();if(e.authSessionId)try{let t=await Pr(),n=await qe({sessionId:e.authSessionId,apiBase:Ir(t)});if(n.status===`pending`){Kr.getState().updateBrowserAuth({statusMessage:s(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(n.message||s(`remoteBrowserAuthExpired`))),Kr.getState().clearBrowserAuth(),A.error(n.message||s(`remoteBrowserAuthExpired`));return}Kr.getState().setAuthStatusMessage(s(`remoteBrowserAuthCompleted`));let r=await Fr();this.clearPollTimer(),this.resolveBrowserSignIn(r),Kr.getState().clearBrowserAuth(),A.success(s(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),Kr.getState().clearBrowserAuth();let t=e instanceof Error?e.message:s(`remoteBrowserAuthPollFailed`);A.error(`${s(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=Kr.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?u(e.authExpiresAt):`-`}}}},$r=`Popover`,[ei,ti]=yt($r,[Ft]),ni=Ft(),[ri,ii]=ei($r),ai=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ni(t),c=F.useRef(null),[l,u]=F.useState(!1),[d,f]=Rt({prop:r,defaultProp:i??!1,onChange:a,caller:$r});return(0,I.jsx)(Mt,{...s,children:(0,I.jsx)(ri,{scope:t,contentId:Bt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:F.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:F.useCallback(()=>u(!0),[]),onCustomAnchorRemove:F.useCallback(()=>u(!1),[]),modal:o,children:n})})};ai.displayName=$r;var oi=`PopoverAnchor`,si=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(oi,n),a=ni(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return F.useEffect(()=>(o(),()=>s()),[o,s]),(0,I.jsx)(Pt,{...a,...r,ref:t})});si.displayName=oi;var ci=`PopoverTrigger`,li=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(ci,n),a=ni(n),o=vt(t,i.triggerRef),s=(0,I.jsx)(Dt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":wi(i.open),...r,ref:o,onClick:zt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,I.jsx)(Pt,{asChild:!0,...a,children:s})});li.displayName=ci;var ui=`PopoverPortal`,[di,fi]=ei(ui,{forceMount:void 0}),pi=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ii(ui,t);return(0,I.jsx)(di,{scope:t,forceMount:n,children:(0,I.jsx)(Vt,{present:n||a.open,children:(0,I.jsx)(wt,{asChild:!0,container:i,children:r})})})};pi.displayName=ui;var mi=`PopoverContent`,hi=F.forwardRef((e,t)=>{let n=fi(mi,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=ii(mi,e.__scopePopover);return(0,I.jsx)(Vt,{present:r||a.open,children:a.modal?(0,I.jsx)(_i,{...i,ref:t}):(0,I.jsx)(vi,{...i,ref:t})})});hi.displayName=mi;var gi=Et(`PopoverContent.RemoveScroll`),_i=F.forwardRef((e,t)=>{let n=ii(mi,e.__scopePopover),r=F.useRef(null),i=vt(t,r),a=F.useRef(!1);return F.useEffect(()=>{let e=r.current;if(e)return Ct(e)},[]),(0,I.jsx)(kt,{as:gi,allowPinchZoom:!0,children:(0,I.jsx)(yi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:zt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:zt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),vi=F.forwardRef((e,t)=>{let n=ii(mi,e.__scopePopover),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(yi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),yi=F.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=ii(mi,n),p=ni(n);return Lt(),(0,I.jsx)(Tt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,I.jsx)(xt,{"data-state":wi(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),bi=`PopoverClose`,xi=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(bi,n);return(0,I.jsx)(Dt.button,{type:`button`,...r,ref:t,onClick:zt(e.onClick,()=>i.onOpenChange(!1))})});xi.displayName=bi;var Si=`PopoverArrow`,Ci=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ni(n);return(0,I.jsx)(Ot,{...i,...r,ref:t})});Ci.displayName=Si;function wi(e){return e?`open`:`closed`}var Ti=ai,Ei=si,Di=li,Oi=pi,ki=hi,Ai=Ti,ji=Di,Mi=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...i},a)=>(0,I.jsx)(Oi,{children:(0,I.jsx)(ki,{ref:a,sideOffset:t,align:n,className:r(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...i})}));Mi.displayName=ki.displayName;function Ni({deletePending:e,entry:t,favoritePending:n,onDelete:r,onOpen:i,onToggleFavorite:a}){let[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=t.favorite?s(`panelAppsUnfavorite`):s(`panelAppsFavorite`),f=t.lastOpenedAt?`${s(`panelAppsLastOpened`)} ${Fi(t.lastOpenedAt)}`:`${s(`panelAppsUpdated`)} ${Fi(t.updatedAt)}`,p=e=>{e.stopPropagation(),a()},m=()=>{c(!1),u(!0)};return(0,I.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,I.jsx)(Ii,{icon:t.icon,title:t.title})}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,I.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,I.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:p,disabled:n,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,I.jsx)(yr,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,I.jsxs)(Ai,{open:o,onOpenChange:c,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":s(`panelAppsMoreActions`),disabled:e,children:(0,I.jsx)(kn,{className:`h-4 w-4`})})}),(0,I.jsx)(Mi,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,I.jsx)(Pi,{destructive:!0,disabled:e,icon:xr,label:s(`panelAppsDelete`),onClick:m})})]})]})]}),(0,I.jsx)(Yt,{open:l,onOpenChange:u,title:s(`panelAppsDeleteConfirmTitle`),description:`${s(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:s(`delete`),variant:`destructive`,onConfirm:r,onCancel:()=>void 0})]})}function Pi({destructive:e=!1,disabled:t=!1,icon:n,label:i,onClick:a}){return(0,I.jsxs)(`button`,{type:`button`,className:r(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:t,onClick:a,children:[(0,I.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:i})]})}function Fi(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=p(d()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function Ii({icon:e,title:t}){return e?Li(e)?(0,I.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,I.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,I.jsx)(hn,{className:`h-4 w-4`})}function Li(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Ri=[`panel-apps`];function zi(){return at({queryKey:Ri,queryFn:()=>N.panelApps.listPanelApps(),staleTime:0})}function Bi(){let e=ge();return le({mutationFn:({id:e,preferences:t})=>N.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Vi(){let e=ge();return le({mutationFn:e=>N.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Hi(){let e=ge();return le({mutationFn:e=>N.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Ui(e,t){return t===`favorites`?Wi(e.filter(e=>e.favorite),`smart`):Wi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function Wi(e,t){return[...e].sort((e,n)=>Gi(e,n,t))}function Gi(e,t,n){return n===`recent-open`?Yi(e.lastOpenedAt,t.lastOpenedAt)||Ki(e,t):n===`updated`?Yi(e.updatedAt,t.updatedAt)||Ki(e,t):n===`name`?Ki(e,t):qi(e,t)||Number(t.favorite)-Number(e.favorite)||Ki(e,t)}function Ki(e,t){return e.title.localeCompare(t.title)}function qi(e,t){return Ji(t)-Ji(e)}function Ji(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Yi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var Xi=F.createContext(null);function Zi({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,I.jsx)(Xi.Provider,{value:{value:t,onValueChange:n},children:r})}function Qi({children:e,className:t}){return(0,I.jsx)(`div`,{className:r(`inline-flex h-9 items-center justify-center rounded-xl bg-gray-100/80 p-1 text-gray-500`,t),children:e})}function $i({value:e,children:t,className:n}){let i=F.useContext(Xi);if(!i)throw Error(`TabsTrigger must be used within Tabs`);let a=i.value===e;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>i.onValueChange(e),"aria-pressed":a,"data-state":a?`active`:`inactive`,className:r(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium ring-offset-white transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,a?`bg-white text-gray-900 shadow-sm`:`hover:bg-white/50 hover:text-gray-800 text-gray-600`,n),children:t})}function ea({value:e,children:t,className:n}){let i=F.useContext(Xi);if(!i)throw Error(`TabsContent must be used within Tabs`);return i.value===e?(0,I.jsx)(`div`,{className:r(`mt-2 animate-fade-in`,n),children:t}):null}var[ta,na]=yt(`Tooltip`,[Ft]),ra=Ft(),ia=`TooltipProvider`,aa=700,oa=`tooltip.open`,[sa,ca]=ta(ia),la=e=>{let{__scopeTooltip:t,delayDuration:n=aa,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(sa,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:F.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};la.displayName=ia;var ua=`Tooltip`,[da,fa]=ta(ua),pa=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ca(ua,e.__scopeTooltip),l=ra(t),[u,d]=F.useState(null),f=Bt(),p=F.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=F.useRef(!1),[_,v]=Rt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(oa))):c.onClose(),a?.(e)},caller:ua}),y=F.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=F.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return F.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,I.jsx)(Mt,{...l,children:(0,I.jsx)(da,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:F.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:F.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};pa.displayName=ua;var ma=`TooltipTrigger`,ha=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=fa(ma,n),a=ca(ma,n),o=ra(n),s=vt(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Pt,{asChild:!0,...o,children:(0,I.jsx)(Dt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:zt(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:zt(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:zt(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:zt(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:zt(e.onBlur,i.onClose),onClick:zt(e.onClick,i.onClose)})})});ha.displayName=ma;var ga=`TooltipPortal`,[_a,va]=ta(ga,{forceMount:void 0}),ya=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=fa(ga,t);return(0,I.jsx)(_a,{scope:t,forceMount:n,children:(0,I.jsx)(Vt,{present:n||a.open,children:(0,I.jsx)(wt,{asChild:!0,container:i,children:r})})})};ya.displayName=ga;var ba=`TooltipContent`,xa=F.forwardRef((e,t)=>{let n=va(ba,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=fa(ba,e.__scopeTooltip);return(0,I.jsx)(Vt,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(Ea,{side:i,...a,ref:t}):(0,I.jsx)(Sa,{side:i,...a,ref:t})})}),Sa=F.forwardRef((e,t)=>{let n=fa(ba,e.__scopeTooltip),r=ca(ba,e.__scopeTooltip),i=F.useRef(null),a=vt(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Aa(r,ka(r,n.getBoundingClientRect())),a=ja(t.getBoundingClientRect());s(Na([...i,...a])),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Ma(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(Ea,{...e,ref:a})}),[Ca,wa]=ta(ua,{isInside:!1}),Ta=bt(`TooltipContent`),Ea=F.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=fa(ba,n),l=ra(n),{onClose:u}=c;return F.useEffect(()=>(document.addEventListener(oa,u),()=>document.removeEventListener(oa,u)),[u]),F.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,I.jsxs)(xt,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(Ta,{children:r}),(0,I.jsx)(Ca,{scope:n,isInside:!0,children:(0,I.jsx)(It,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});xa.displayName=ba;var Da=`TooltipArrow`,Oa=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ra(n);return wa(Da,n).isInside?null:(0,I.jsx)(Ot,{...i,...r,ref:t})});Oa.displayName=Da;function ka(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Aa(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ja(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Ma(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Na(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Pa(t)}function Pa(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Fa=la,Ia=pa,La=ha,Ra=ya,za=xa,Ba=Fa,Va=Ia,Ha=La,Ua=F.forwardRef(({className:e,sideOffset:t=4,...n},i)=>(0,I.jsx)(Ra,{children:(0,I.jsx)(za,{ref:i,sideOffset:t,className:r(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...n})}));Ua.displayName=za.displayName;function Wa({headerContent:e,onOpenPanelApp:t}){let n=zi(),r=Hi(),i=Bi(),a=Vi(),[o,c]=(0,F.useState)(`smart`),l=(0,F.useMemo)(()=>Ui(n.data?.entries??[],o),[n.data?.entries,o]),u=async e=>{try{t(await a.mutateAsync(e.id))}catch{t(e)}},d=e=>{i.mutate({id:e.id,preferences:{favorite:!e.favorite}})},f=e=>{r.mutate(e.id)};return n.isLoading?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:s(`panelAppsLoading`)}):n.isError?(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:n.error instanceof Error?n.error.message:s(`panelAppsLoadFailed`)}):(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:s(`panelAppsTitle`)}),n.data?.panelsPath?(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":s(`panelAppsTitle`),children:(0,I.jsx)(wn,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(Ua,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:n.data.panelsPath})]})}):null]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void n.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`panelAppsRefresh`),"aria-label":s(`panelAppsRefresh`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,I.jsx)(Zi,{value:o,onValueChange:e=>c(e),children:(0,I.jsxs)(Qi,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsx)($i,{value:`smart`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortSmart`)}),(0,I.jsx)($i,{value:`favorites`,className:`px-2 py-1 text-xs`,children:s(`panelAppsFavorites`)}),(0,I.jsx)($i,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortRecentOpen`)}),(0,I.jsx)($i,{value:`updated`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortUpdated`)}),(0,I.jsx)($i,{value:`name`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortName`)})]})})}),l.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:s(`panelAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,I.jsx)(Ni,{entry:e,deletePending:r.isPending,favoritePending:i.isPending,onDelete:()=>f(e),onOpen:()=>void u(e),onToggleFavorite:()=>d(e)},e.id))})})]})}var Ga=class{constructor(e){this.authorizationManager=e,this.sessions=new Map,this.handleIframeMessage=({event:e,iframe:t,tab:n})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,tab:n},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=await this.getSession(e),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await N.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await N.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await N.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof ue)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await N.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await N.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof ue)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await N.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await N.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof ue)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await N.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}))throw new ue({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await N.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.findAction(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:r?.title,actionDescription:r?.description,risk:r?.risk,inputPreview:this.createInputPreview(n)}))throw new ue({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await N.serviceApps.grantServiceAction(t,{bridgeSessionToken:e.token})},this.findAction=async(e,t)=>(await N.serviceApps.listServiceActions({bridgeSessionToken:e.token})).actions.find(e=>e.id===t),this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getSession=async e=>{let t=this.readPanelAppId(e.tab.currentUrl),n=`${e.tab.id}:${t}`,r=this.sessions.get(n);return r||(r=N.panelApps.createBridgeSession({panelAppId:t,tabId:e.tab.id}),this.sessions.set(n,r)),await r},this.readPanelAppId=e=>{let t=new URL(e,window.location.origin),n=/^\/api\/panel-apps\/([^/]+)\/content$/.exec(t.pathname);if(!n?.[1])throw Error(`Current tab is not a Panel App.`);return decodeURIComponent(n[1])},this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof ue?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function Ka(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var qa=m((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:Ka(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Ja(){let e=qa(e=>e.pending),t=qa(e=>e.resolveAuthorization);return(0,I.jsx)(qt,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,I.jsxs)(Wt,{className:`[&>:last-child]:hidden`,children:[(0,I.jsxs)(Jt,{children:[(0,I.jsxs)(Ut,{className:`flex items-center gap-2`,children:[(0,I.jsx)(fr,{className:`h-4 w-4 text-amber-600`}),s(`serviceActionAuthorizationTitle`)]}),(0,I.jsx)(Ht,{children:s(`serviceActionAuthorizationDescription`)})]}),e?(0,I.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationAction`),value:e.actionTitle??e.actionId}),e.actionDescription?(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationPurpose`),value:e.actionDescription}):null,(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationRisk`),value:e.risk??`dangerous`}),e.inputPreview?(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,I.jsxs)(Kt,{className:`gap-2 sm:gap-0`,children:[(0,I.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:s(`serviceActionAuthorizationReject`)}),(0,I.jsx)(M,{type:`button`,onClick:()=>t(!0),children:s(`serviceActionAuthorizationAllow`)})]})]})})}function Ya({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,I.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Xa=class{constructor(){this.requestAuthorization=async e=>await qa.getState().requestAuthorization(e)}},Za=[`service-apps`],Qa=[`service-actions`],$a=[`service-action-grants`];function eo(){return at({queryKey:Za,queryFn:()=>N.serviceApps.listServiceApps()})}function to(){return at({queryKey:Qa,queryFn:()=>N.serviceApps.listServiceActions()})}function no(){return at({queryKey:$a,queryFn:()=>N.serviceApps.listServiceActionGrants()})}function ro(){let e=ge();return le({mutationFn:e=>N.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Za}),e.invalidateQueries({queryKey:Qa})])}})}function io(){let e=ge();return le({mutationFn:e=>N.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Za})}})}function ao(){let e=ge();return le({mutationFn:e=>N.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Qa}),e.invalidateQueries({queryKey:$a})])}})}function oo({headerContent:e}){let t=eo(),n=to(),r=no(),i=ro(),a=io(),o=ao(),[c,l]=(0,F.useState)({}),u=()=>{t.refetch(),n.refetch(),r.refetch()};if(t.isLoading||n.isLoading||r.isLoading)return(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:s(`serviceAppsLoading`)});if(t.isError||n.isError||r.isError){let e=t.error??n.error??r.error;return(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:s(`serviceAppsLoadFailed`)})}let d=t.data?.entries??[],f=n.data?.actions??[],p=r.data?.grants??[],m=e=>{a.mutateAsync(e).then(t=>{l(n=>({...n,[e]:t.actions}))})};return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ur,{className:`h-4 w-4 text-primary`}),(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:s(`serviceAppsTitle`)})]})}),(0,I.jsx)(`button`,{type:`button`,onClick:u,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`serviceAppsRefresh`),"aria-label":s(`serviceAppsRefresh`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]}),d.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:s(`serviceAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,I.jsx)(so,{app:e,actions:c[e.id]??f.filter(t=>t.appId===e.id),grants:p,isDiscovering:a.isPending,onDiscover:m,onRestart:e=>void i.mutate(e),onRevoke:e=>void o.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function so({app:e,actions:t,grants:n,isDiscovering:r,onDiscover:i,onRestart:a,onRevoke:o}){return(0,I.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`span`,{className:`rounded bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.status})]}),e.description?(0,I.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,I.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,title:s(`serviceAppsDiscoverActions`),"aria-label":s(`serviceAppsDiscoverActions`),children:(0,I.jsx)(Zt,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`serviceAppsRestart`),"aria-label":s(`serviceAppsRestart`),children:(0,I.jsx)(lr,{className:`h-3.5 w-3.5`})})]})]}),(0,I.jsx)(co,{app:e}),(0,I.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,I.jsx)(uo,{action:e,grants:n.filter(t=>t.actionId===e.id),onRevoke:o},e.id))})]})}function co({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),n=[{label:s(`serviceAppsCommand`),value:t},{label:s(`serviceAppsCwd`),value:e.cwd},{label:s(`serviceAppsManifest`),value:e.manifestPath},{label:s(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:s(`serviceAppsLastReady`),value:e.lastReadyAt},{label:s(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return n.length===0?null:(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:n.map(e=>(0,I.jsx)(lo,{label:e.label,value:e.value},e.label))})}function lo({label:e,value:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,I.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function uo({action:e,grants:t,onRevoke:n}){return(0,I.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(en,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,I.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,I.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:s(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,I.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,I.jsx)(pr,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[s(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:s(`serviceAppsRevokeGrant`),"aria-label":s(`serviceAppsRevokeGrant`),children:(0,I.jsx)(xr,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function fo({activeTab:e,onActiveTabChange:t,onOpenPanelApp:n}){let r=(0,I.jsx)(Zi,{value:e,onValueChange:e=>t(e),children:(0,I.jsxs)(Qi,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsxs)($i,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,I.jsx)(hn,{className:`h-3.5 w-3.5`}),s(`panelAppsTitle`)]}),(0,I.jsxs)($i,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,I.jsx)(ur,{className:`h-3.5 w-3.5`}),s(`serviceAppsTitle`)]})]})});return(0,I.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,I.jsx)(Wa,{headerContent:r,onOpenPanelApp:n}):(0,I.jsx)(oo,{headerContent:r})})}function po({onOpenApps:e,onRefresh:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),s(`appsTitle`)]}),(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`panelAppsRefreshCurrent`),"aria-label":s(`panelAppsRefreshCurrent`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]})}var mo=cn,ho=`panel-app`,go=`panel-apps`,_o=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function vo(e){return e===`panel-apps`||e===`service-apps`}function yo(e=go){return e===go?on:sn}function bo(e){try{let t=new URL(e).searchParams.get(`tab`);return vo(t)?t:go}catch{return go}}function xo(e){e.open(yo(),{kind:mo,title:s(`appsTitle`),dedupeKey:`apps`})}var So={[mo]:{getTitle:()=>s(`appsTitle`),renderIcon:()=>(0,I.jsx)($t,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t})=>(0,I.jsx)(fo,{activeTab:bo(e),onActiveTabChange:e=>t(yo(e),{activate:!1,kind:mo,title:s(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>t(e.contentPath,{kind:ho,title:e.title,dedupeKey:`panel-app:${e.id}`})})},[ho]:{getIframeSandbox:()=>_o,getTitle:e=>e.title||s(`panelAppsTitle`),onIframeMessage:e=>Eo().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,I.jsx)(hn,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,I.jsx)(po,{onOpenApps:()=>xo({open:e}),onRefresh:t})}},Co=class{constructor(){this.accountManager=new Qr,this.serviceActionAuthorizationManager=new Xa,this.panelAppBridgeManager=new Ga(this.serviceActionAuthorizationManager),this.remoteAccessManager=new Br({accountManager:this.accountManager})}},wo=null;function To(){return wo??=new Co,wo}function Eo(){return To()}var Do=(0,F.createContext)(null);function Oo({children:e}){let t=(0,F.useMemo)(()=>To(),[]);return(0,I.jsx)(Do.Provider,{value:t,children:e})}function ko(){let e=(0,F.useContext)(Do);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}function Ao(){let e=un();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;an(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}var jo=(0,F.createContext)(null);function Mo({children:e}){let[t,r]=(0,F.useState)(()=>n());(0,F.useEffect)(()=>h(e=>{r(e)}),[]);let i=(0,F.useCallback)(e=>{c(e),r(d())},[]),a=(0,F.useCallback)(()=>{i(t===`en`?`zh`:`en`)},[t,i]),o=(0,F.useMemo)(()=>({language:t,setLanguage:i,toggleLanguage:a}),[t,i,a]);return(0,I.jsx)(jo.Provider,{value:o,children:e})}function No(){let e=(0,F.useContext)(jo);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function Po(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function Fo(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:Po(e),width:e}}var Io=m(()=>Fo()),Lo=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>Io.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Io.setState(Fo())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Io.setState({width:e,mode:Po(e)})}}};function Ro(){return(0,F.useEffect)(()=>Lo.attach(),[]),{isMobile:Io(e=>e.mode)===`mobile`}}var zo=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Bo=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}zo.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();zo.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){zo.setState({supported:!0,initialized:!0,busyAction:null}),A.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{zo.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));zo.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return zo.setState({supported:!0,initialized:!0,snapshot:n}),A.success(s(`runtimePresenceSaved`)),n}catch(e){throw A.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{zo.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Vo=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){Vo.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Vo.setState({supported:!0,initialized:!0,snapshot:e})}),Vo.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Vo.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Vo.setState({supported:!0,initialized:!0}),A.error(`${s(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,s(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){A.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){A.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){A.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&A.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,s(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&A.success(s(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,s(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,s(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(Vo.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,s(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){A.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}A.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Vo.setState({busyAction:e});try{let e=await n(r);return Vo.setState({snapshot:e}),e}catch(e){throw A.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Vo.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`),this.getChannelLabel=e=>s(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function Ho(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Uo(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function Wo(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Go(e){return[{target:`/chat`,label:e(`chat`),icon:$n},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:ht},{target:`/agents`,label:e(`agentsPageTitle`),icon:vn},{target:`/settings`,label:e(`settings`),icon:dr}]}function Ko(e){return[{target:`/model`,label:e(`model`),icon:Dn},{target:`/providers`,label:e(`providers`),icon:gr},{target:`/channels`,label:e(`channels`),icon:tr},{target:`/search`,label:e(`searchChannels`),icon:Zt},{target:`/runtime`,label:e(`runtime`),icon:Dn},{target:`/updates`,label:e(`updates`),icon:On},{target:`/remote`,label:e(`remote`),icon:wr},{target:`/security`,label:e(`security`),icon:mr},{target:`/secrets`,label:e(`secrets`),icon:Jn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:en}]}function qo(e){return[{target:`/language`,label:e(`language`),icon:Yn},...Ko(e)]}function Jo(e){let t=e.toLowerCase();return t===`/settings`?!0:qo(e=>e).some(e=>Ho(t,e.target))}function Yo(e,t){let n=e.toLowerCase(),r=qo(t);if(Wo(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(Ho(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var Xo=`nextclaw.ui.theme`,Zo=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Qo=`warm`,$o=!1,es=new Set;function ts(e){return e===`warm`||e===`cool`}function ns(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function rs(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Xo);if(ts(e))return e}catch{}return`warm`}function is(){return $o||=(Qo=rs(),ns(Qo),!0),Qo}function as(){return $o?Qo:is()}function os(e){if(is(),e!==Qo){if(Qo=e,ns(Qo),typeof window<`u`)try{window.localStorage.setItem(Xo,Qo)}catch{}es.forEach(e=>e(Qo))}}function ss(e){return es.add(e),()=>{es.delete(e)}}function cs(){return at({queryKey:[`config`],queryFn:te,staleTime:3e4,refetchOnWindowFocus:!0})}function ls(){return at({queryKey:[`app-meta`],queryFn:ee,staleTime:1/0})}function us(){return at({queryKey:[`config-meta`],queryFn:ce,staleTime:1/0})}function ds(){return at({queryKey:[`config-schema`],queryFn:it,staleTime:1/0})}function fs(){let e=ge();return le({mutationFn:_e,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ps(){let e=ge();return le({mutationFn:({data:e})=>se(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ms(){let e=ge();return le({mutationFn:({provider:e,data:t})=>he(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function hs(){let e=ge();return le({mutationFn:({data:e})=>ne(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function gs(){let e=ge();return le({mutationFn:({provider:e})=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function _s(){return le({mutationFn:({provider:e,data:t})=>We(e,t)})}function vs(){return le({mutationFn:({provider:e,data:t})=>k(e,t)})}function ys(){return le({mutationFn:({provider:e,data:t})=>fe(e,t)})}function bs(){return le({mutationFn:({provider:e})=>E(e)})}function xs(){let e=ge();return le({mutationFn:({channel:e,data:t})=>O(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSavedApplying`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function Ss(){let e=ge();return le({mutationFn:({data:e})=>ye(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function Cs(){let e=ge();return le({mutationFn:({data:e})=>_(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ws(){return le({mutationFn:({actionId:e,data:t})=>C(e,t),onError:e=>{A.error(s(`error`)+`: `+e.message)}})}function Ts(e){return at({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>be(e),staleTime:5e3,retry:!1})}function Es(e){return at({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>Oe(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ds(e={all:!0}){return at({queryKey:[`cron`,e],queryFn:()=>y(e),staleTime:1e4})}function Os(){let e=ge();return le({mutationFn:({id:e})=>re(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ks(){let e=ge();return le({mutationFn:({id:e,enabled:t})=>T(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function As(){let e=ge();return le({mutationFn:({id:e,force:t})=>me(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}var js={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function Ms(){let e=ke(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=async()=>{if(t)try{let e=await rt.runRuntimeControlAction(`restart-service`);A.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);A.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(Ai,{children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,js[e.tone])})})}),(0,I.jsxs)(Mi,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,I.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,I.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s(`runtimeStatusActionHint`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?s(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function Ns({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=ls(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(Ms,{}),l=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,u=t===`chrome`;return(0,I.jsxs)(`div`,{className:r(e??`flex min-w-0 items-center gap-2`,l&&`pl-[58px]`),children:[(0,I.jsx)(`div`,{className:r(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,I.jsx)(`img`,{src:`/logo.svg`,alt:a,className:`h-full w-full object-contain`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:r(`shrink-0 font-semibold text-gray-800`,u?`text-[15px]`:`text-[14px]`),children:a}),s?(0,I.jsx)(Ps,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Fs,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Ps({versionLabel:e,density:t}){let[n,i]=(0,F.useState)(!1);return(0,I.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[(0,I.jsx)(`span`,{tabIndex:0,"aria-label":e,className:r(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,I.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function Fs(){let{supported:e,busyAction:t,snapshot:n}=Re();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Is,{snapshot:n}):n.status===`downloaded`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void Ue.applyDownloadedUpdate(),children:s(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void Ue.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Is({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Ls,{snapshot:e});let t=e.status===`downloading`?Rs(e):null;return t?(0,I.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:s(`updates`),children:t}):null}function Ls({snapshot:e}){let t=e.status===`failed`?s(`desktopUpdatesStatusFailed`):s(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?s(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
3
- `);return(0,I.jsx)(`span`,{role:`img`,"aria-label":t,title:i,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function Rs(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var zs=g(Ve(),1);function Bs(e,[t,n]){return Math.min(n,Math.max(t,e))}function Vs(e){let t=e+`CollectionProvider`,[n,r]=yt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Et(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:vt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Et(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=vt(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Hs=F.createContext(void 0);function Us(e){let t=F.useContext(Hs);return e||t||`ltr`}function Ws(e){let t=F.useRef({value:e,previous:e});return F.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Gs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ks=[` `,`Enter`],qs=`Select`,[Js,Ys,Xs]=Vs(qs),[Zs,Qs]=yt(qs,[Xs,Ft]),$s=Ft(),[ec,tc]=Zs(qs),[nc,rc]=Zs(qs),ic=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=$s(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Us(l),[C,w]=Rt({prop:r,defaultProp:i??!1,onChange:a,caller:qs}),[T,E]=Rt({prop:o,defaultProp:s,onChange:c,caller:qs}),ee=F.useRef(null),D=g?m||!!g.closest(`form`):!0,[O,k]=F.useState(new Set),te=Array.from(O).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)(ec,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Bt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:ee,disabled:f,children:[(0,I.jsx)(Js.Provider,{scope:t,children:(0,I.jsx)(nc,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{k(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{k(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),D?(0,I.jsxs)($c,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,I.jsx)(`option`,{value:``}):null,Array.from(O)]},te):null]})})};ic.displayName=qs;var ac=`SelectTrigger`,oc=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=$s(n),o=tc(ac,n),s=o.disabled||r,c=vt(t,o.onTriggerChange),l=Ys(n),u=F.useRef(`touch`),[d,f,p]=tl(e=>{let t=l().filter(e=>!e.disabled),n=nl(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,I.jsx)(Pt,{asChild:!0,...a,children:(0,I.jsx)(Dt.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":el(o.value)?``:void 0,...i,ref:c,onClick:zt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:zt(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:zt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Gs.includes(e.key)&&(m(),e.preventDefault())})})})});oc.displayName=ac;var sc=`SelectValue`,cc=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=tc(sc,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=vt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Dt.span,{...s,ref:d,style:{pointerEvents:`none`},children:el(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});cc.displayName=sc;var lc=`SelectIcon`,uc=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Dt.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});uc.displayName=lc;var dc=`SelectPortal`,fc=e=>(0,I.jsx)(wt,{asChild:!0,...e});fc.displayName=dc;var pc=`SelectContent`,mc=F.forwardRef((e,t)=>{let n=tc(pc,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?zs.createPortal((0,I.jsx)(gc,{scope:e.__scopeSelect,children:(0,I.jsx)(Js.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(bc,{...e,ref:t})});mc.displayName=pc;var hc=10,[gc,_c]=Zs(pc),vc=`SelectContentImpl`,yc=Et(`SelectContent.RemoveScroll`),bc=F.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=tc(pc,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=vt(t,e=>b(e)),[w,T]=F.useState(null),[E,ee]=F.useState(null),D=Ys(n),[O,k]=F.useState(!1),te=F.useRef(!1);F.useEffect(()=>{if(y)return Ct(y)},[y]),Lt();let A=F.useCallback(e=>{let[t,...n]=D().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[D,x]),ne=F.useCallback(()=>A([w,y]),[A,w,y]);F.useEffect(()=>{O&&ne()},[O,ne]);let{onOpenChange:j,triggerPointerDownPosRef:re}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(re.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(re.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||j(!1),document.removeEventListener(`pointermove`,t),re.current=null};return re.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,j,re]),F.useEffect(()=>{let e=()=>j(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[j]);let[M,ie]=tl(e=>{let t=D().filter(e=>!e.disabled),n=nl(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!te.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(te.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!te.current&&!n;(v.value!==void 0&&v.value===t||r)&&ee(e)},[v.value]),ce=r===`popper`?wc:Sc,le=ce===wc?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(gc,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:ne,selectedItemText:E,position:r,isPositioned:O,searchRef:M,children:(0,I.jsx)(kt,{as:yc,allowPinchZoom:!0,children:(0,I.jsx)(Tt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:zt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,I.jsx)(ce,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...le,onPlaced:()=>k(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:zt(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ie(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=D().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>A(t)),e.preventDefault()}})})})})})})});bc.displayName=vc;var xc=`SelectItemAlignedPosition`,Sc=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=tc(pc,n),o=_c(pc,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=vt(t,e=>u(e)),f=Ys(n),p=F.useRef(!1),m=F.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=F.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-hc,d=Bs(a,[hc,Math.max(hc,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-hc,d=Bs(a,[hc,Math.max(hc,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-hc*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-hc,ee=c-E,D=g.offsetHeight/2,O=g.offsetTop+D,k=m+v+O,te=x-k;if(k<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+D)+te;s.style.height=t+`px`,h.scrollTop=k-E+h.offsetTop}s.style.margin=`${hc}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);St(()=>y(),[y]);let[b,x]=F.useState();return St(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,I.jsx)(Tc,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:F.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,I.jsx)(Dt.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Sc.displayName=xc;var Cc=`SelectPopperPosition`,wc=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=hc,...a}=e,o=$s(n);return(0,I.jsx)(xt,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});wc.displayName=Cc;var[Tc,Ec]=Zs(pc,{}),Dc=`SelectViewport`,Oc=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=_c(Dc,n),o=Ec(Dc,n),s=vt(t,a.onViewportChange),c=F.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(Js.Slot,{scope:n,children:(0,I.jsx)(Dt.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:zt(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-hc*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Oc.displayName=Dc;var kc=`SelectGroup`,[Ac,jc]=Zs(kc),Mc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Bt();return(0,I.jsx)(Ac,{scope:n,id:i,children:(0,I.jsx)(Dt.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Mc.displayName=kc;var Nc=`SelectLabel`,Pc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=jc(Nc,n);return(0,I.jsx)(Dt.div,{id:i.id,...r,ref:t})});Pc.displayName=Nc;var Fc=`SelectItem`,[Ic,Lc]=Zs(Fc),Rc=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=tc(Fc,n),c=_c(Fc,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=vt(t,e=>c.itemRefCallback?.(e,r,i)),h=Bt(),g=F.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,I.jsx)(Ic,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(Js.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Dt.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:zt(o.onFocus,()=>p(!0)),onBlur:zt(o.onBlur,()=>p(!1)),onClick:zt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:zt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:zt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:zt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:zt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:zt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Ks.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Rc.displayName=Fc;var zc=`SelectItemText`,Bc=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=tc(zc,n),s=_c(zc,n),c=Lc(zc,n),l=rc(zc,n),[u,d]=F.useState(null),f=vt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=F.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return St(()=>(h(m),()=>g(m)),[h,g,m]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Dt.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?zs.createPortal(a.children,o.valueNode):null]})});Bc.displayName=zc;var Vc=`SelectItemIndicator`,Hc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Lc(Vc,n).isSelected?(0,I.jsx)(Dt.span,{"aria-hidden":!0,...r,ref:t}):null});Hc.displayName=Vc;var Uc=`SelectScrollUpButton`,Wc=F.forwardRef((e,t)=>{let n=_c(Uc,e.__scopeSelect),r=Ec(Uc,e.__scopeSelect),[i,a]=F.useState(!1),o=vt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(qc,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Wc.displayName=Uc;var Gc=`SelectScrollDownButton`,Kc=F.forwardRef((e,t)=>{let n=_c(Gc,e.__scopeSelect),r=Ec(Gc,e.__scopeSelect),[i,a]=F.useState(!1),o=vt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(qc,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Kc.displayName=Gc;var qc=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=_c(`SelectScrollButton`,n),o=F.useRef(null),s=Ys(n),c=F.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return F.useEffect(()=>()=>c(),[c]),St(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(Dt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:zt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:zt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:zt(i.onPointerLeave,()=>{c()})})}),Jc=`SelectSeparator`,Yc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Dt.div,{"aria-hidden":!0,...r,ref:t})});Yc.displayName=Jc;var Xc=`SelectArrow`,Zc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=$s(n),a=tc(Xc,n),o=_c(Xc,n);return a.open&&o.position===`popper`?(0,I.jsx)(Ot,{...i,...r,ref:t}):null});Zc.displayName=Xc;var Qc=`SelectBubbleInput`,$c=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=vt(r,i),o=Ws(t);return F.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,I.jsx)(Dt.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});$c.displayName=Qc;function el(e){return e===``||e===void 0}function tl(e){let t=At(e),n=F.useRef(``),r=F.useRef(0),i=F.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=F.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return F.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function nl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=rl(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function rl(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var il=ic,al=oc,ol=cc,sl=uc,cl=fc,ll=mc,ul=Oc,dl=Mc,fl=Pc,pl=Rc,ml=Bc,hl=Hc,gl=Wc,_l=Kc,vl=Yc,yl=il,bl=ol,xl=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(al,{ref:a,className:r(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 bg-white`,e),...i,children:[t,(0,I.jsx)(sl,{asChild:!0,children:n??(0,I.jsx)(xn,{className:`h-4 w-4 opacity-50`})})]}));xl.displayName=al.displayName;var Sl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(gl,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Cn,{className:`h-4 w-4`})}));Sl.displayName=gl.displayName;var Cl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_l,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(xn,{className:`h-4 w-4`})}));Cl.displayName=_l.displayName;var wl=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(cl,{children:(0,I.jsxs)(ll,{ref:o,className:r(`relative z-[var(--z-popover,50)] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 bg-white`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...a,children:[(0,I.jsx)(Sl,{}),(0,I.jsx)(ul,{className:r(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,i),children:t}),(0,I.jsx)(Cl,{})]})}));wl.displayName=ll.displayName;var Tl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fl,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));Tl.displayName=fl.displayName;var El=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(pl,{ref:i,className:r(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(hl,{children:(0,I.jsx)(bn,{className:`h-4 w-4`})})}),(0,I.jsx)(ml,{children:t})]}));El.displayName=pl.displayName;var Dl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vl,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Dl.displayName=vl.displayName;var Ol={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function kl(e){return Ol[e]}function Al({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=kl(i);return(0,I.jsx)(gt,{to:e,className:({isActive:e})=>r(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:r(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function jl({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=kl(i);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:r(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,I.jsx)(t,{className:r(d.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:r(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,I.jsx)(`span`,{className:r(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function Ml({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=kl(o);return(0,I.jsxs)(yl,{value:n,onValueChange:a,children:[(0,I.jsxs)(xl,{className:r(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,I.jsxs)(`div`,{className:r(`flex min-w-0 items-center`,c.gap),children:[(0,I.jsx)(t,{className:r(c.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:r(`ml-auto text-gray-500`,c.value),children:i})]}),(0,I.jsx)(wl,{children:s})]})}var Nl=`nextclaw-pwa-install-banner-dismissed`,Pl=`nextclaw-pwa-install-banner-dismissed-until`;function Fl(){let e=Rl();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:zl(e):!1}function Il(){let e=Rl();e?.setItem(Nl,`1`),e?.removeItem(Pl)}function Ll(){let e=Rl();e?.removeItem(Nl),e?.removeItem(Pl)}function Rl(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function zl(e){let t=e.getItem(Pl);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Pl),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Nl,`1`),!0)}function Bl(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Fl(),updateAvailable:!1,registrationFailed:!1}}var Vl=m(()=>Bl()),Hl=`nextclaw-pwa-dev-sw-reset`,Ul=new class{constructor(){this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{let e=await navigator.serviceWorker.register(`/sw.js`);this.registration=e,this.bindRegistration(e),navigator.serviceWorker.addEventListener(`controllerchange`,this.handleControllerChange),await this.syncUpdateAvailability()}catch{Vl.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){Vl.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;Vl.setState({updateAvailable:this.shouldSurfaceUpdate(e)})},this.applyUpdate=async()=>{let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;if(!e){window.location.reload();return}e.waiting||await e.update();let t=e.waiting;if(!t){window.location.reload();return}this.reloadWhenControllerChanges=!0,t.postMessage({type:`SKIP_WAIT`})},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(navigator.serviceWorker.removeEventListener(`controllerchange`,this.handleControllerChange),this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1)},this.bindRegistration=e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&this.syncUpdateAvailability()})})},this.handleControllerChange=()=>{this.reloadWhenControllerChanges&&(this.reloadWhenControllerChanges=!1,window.location.reload())},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.shouldSurfaceUpdate=e=>!e?.waiting||!navigator.serviceWorker.controller?!1:Vl.getState().installability===`installed`,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));if(e.length===0){this.clearDevResetMarker();return}if(await Promise.all(e.map(async e=>await e.unregister())),await this.clearNextClawCaches(),navigator.serviceWorker.controller&&!this.hasDevResetMarker()){this.setDevResetMarker(),window.location.reload();return}this.clearDevResetMarker()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))},this.hasDevResetMarker=()=>{try{return window.sessionStorage.getItem(Hl)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(Hl,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(Hl)}catch{}}}},Wl=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),Vl.setState(Bl())},this.refreshState=()=>{let e=this.resolveInstallability();Vl.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Fl()})),Ul.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Il(),Vl.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(Ll(),this.refreshState(),A.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Ll(),Vl.setState({dismissedInstallPrompt:!0}),A.success(s(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function Gl(){let e=Vl(e=>e.installability);return(0,I.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Kl(e)})}function Kl(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function ql(e,t,n){return s(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function Jl(){let e=Vl(e=>e.installability),t=Vl(e=>e.installMethod),n=Vl(e=>e.blockedReason);return(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(ie,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(S,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Gl,{})]}),(0,I.jsxs)(de,{className:`space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:ql(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(M,{type:`button`,className:`gap-2`,onClick:()=>{Wl.promptInstall()},children:[(0,I.jsx)(On,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:s(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,I.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,I.jsx)(hr,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallManualHint`)})]}):null]})]})}function Yl(){let e=Vl(e=>e.installability),t=Vl(e=>e.installMethod),n=Vl(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,I.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":s(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Wl.dismissInstallPrompt()},children:(0,I.jsx)(rn,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(M,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Wl.promptInstall()},children:[(0,I.jsx)(On,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Wl.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}function Xl(){let e=Vl(e=>e.updateAvailable),t=Vl(e=>e.installability);return!e||t!==`installed`?null:(0,I.jsxs)(`div`,{className:`fixed top-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaUpdateBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaUpdateBannerDescription`)})]})}),(0,I.jsx)(`div`,{className:`mt-4`,children:(0,I.jsxs)(M,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Ul.applyUpdate()},children:[(0,I.jsx)(cr,{className:`h-4 w-4`}),s(`pwaUpdateAction`)]})})]})}var Zl=!1;function Ql(){Zl||typeof window>`u`||(Zl=!0,Wl.start(),Ul.start())}var $l={warm:`#F9F8F5`,cool:`#F8FAFB`},eu=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=$l[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},tu=(0,F.createContext)(null);function nu({children:e}){let[t,n]=(0,F.useState)(()=>is());(0,F.useEffect)(()=>{eu.syncTheme(t)},[t]),(0,F.useEffect)(()=>ss(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{os(e),n(as())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(tu.Provider,{value:i,children:e})}function ru(){let e=(0,F.useContext)(tu);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function iu(){let{language:e,setLanguage:n}=No();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,F.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}function au(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=iu();return(0,I.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(Yn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:s(`language`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,I.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(t.value),className:r(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,I.jsx)(bn,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function ou({mode:e}){let t=ko(),n=un(),i=Or(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=iu(),{theme:u,setTheme:d}=ru(),f=e===`settings`,p=s(Zo.find(e=>e.value===u)?.labelKey??`themeWarm`),m=i.data?.account.email?.trim(),h=!!i.data?.account.loggedIn,g=e=>{u!==e&&d(e)},_=[{target:`/chat`,label:s(`chat`),icon:$n},{target:`/chat/cron`,label:s(`cron`),icon:mn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:ht},{target:`/agents`,label:s(`agentsPageTitle`),icon:vn}],v=Ko(s),y=f?v:_,b=f?`compact`:`default`;return(0,I.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 pb-6`,children:[f?(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,I.jsxs)(gt,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:s(`backToMain`)})]}),(0,I.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,I.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:s(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(Ns,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,I.jsx)(`ul`,{className:r(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Al,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:r(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,I.jsx)(jl,{onClick:()=>t.accountManager.openAccountPanel(),icon:Jn,label:s(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:h?m||s(`remoteAccountEntryConnected`):s(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Al,{to:`/settings`,label:s(`settings`),icon:dr})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Ml,{value:u,onValueChange:e=>g(e),icon:rr,label:s(`theme`),valueLabel:p,density:b,children:Zo.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Ml,{value:a,onValueChange:e=>l(e),icon:Yn,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(jl,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var su=[{action:`minimize`,label:`Minimize`,icon:nr},{action:`close`,label:`Close`,icon:rn,variant:`danger`}];function cu(){let e=uu()?{action:`toggle-maximize`,label:`Restore`,icon:En}:{action:`toggle-maximize`,label:`Maximize`,icon:vr};return(0,I.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 bg-secondary after:absolute after:bottom-0 after:left-[var(--desktop-sidebar-width)] after:right-0 after:border-b after:border-[#ebe7dc]/80`,"data-testid":`desktop-window-chrome`,children:[(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,I.jsx)(`div`,{className:`desktop-window-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary pl-4 pr-3 text-secondary-foreground`,"data-testid":`desktop-window-chrome-sidebar`,children:(0,I.jsx)(Ns,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:[su[0],e,su[1]].map(e=>(0,I.jsx)(lu,{control:e},e.action))})]})}function lu({control:e}){let t=e.icon;return(0,I.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,I.jsx)(t,{className:`h-3.5 w-3.5`})})}function uu(){let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{let e=!0,n=window.nextclawDesktop;n?.getWindowState?.().then(n=>{e&&t(n.isMaximized)});let r=n?.onWindowStateChanged?.(e=>{t(e.isMaximized)});return()=>{e=!1,r?.()}},[]),e}function du(){return typeof window>`u`?null:pu()??window.nextclawDesktop?.platform??null}function fu(){return du()===`win32`}function pu(){return null}function mu(e,t){if(t===`/settings`)return Jo(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function hu(){let{pathname:e}=ct(),t=Go(s);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":s(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,I.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=mu(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(ot,{to:t.target,"aria-current":n?`page`:void 0,className:r(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,I.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:r(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,I.jsx)(t.icon,{className:r(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,I.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function gu({leadingInset:e}){let t=lt(),{pathname:n}=ct(),r=Yo(n,s);return(0,I.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,I.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 py-1.5 pl-3 pr-3`,style:{paddingLeft:e?`calc(${e} + 0.75rem)`:void 0},children:[r.backTarget?(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(r.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":r.backLabel??s(`backToMain`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:r.title})}),r.backTarget?(0,I.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var _u=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DocBrowser:e}=await import(`./doc-browser-BrUQEZ1j.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function vu({pathname:e,isDocBrowserOpen:t,docBrowserRenderers:n={},topbarLeadingInset:r,children:i}){let a=Uo(e),o=!Wo(e),s=!Wo(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[o?(0,I.jsx)(gu,{leadingInset:r}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:a?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:i}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:i})})}),s?(0,I.jsx)(hu,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(_u,{customTabRenderers:n,displayMode:`fullscreen`})}):null]})}function yu(){let e=qo(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(gt,{to:e.target,className:({isActive:e})=>r(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(e.icon,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function bu({isProjectFirstView:e,onSelectMode:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:r(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:s(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:r(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:s(`chatSidebarViewProject`)})]})}var xu={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,email:`email.svg`};function Su(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function Cu(e){return Su(xu,e)}var wu={wx:`weixin`,lark:`feishu`},Tu={cron:{icon:`cron`}},Eu={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Du(e){return e?.trim().toLowerCase()??``}function Ou(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function ku(e,t){let n=Du(e);if(!n||n===`native`)return null;let r=t.find(e=>Du(e.value)===n);return r?.label.trim()?r.label.trim():Ou(n)}function Au(e,t){let n=Du(e);return!n||n===`native`?null:t.find(e=>Du(e.value)===n)??null}function ju(e){let t=Du(e);if(!t)return null;let n=wu[t]??t;return Cu(n)?n:null}function Mu(e,t){let n=ju(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Tu[Du(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Du(e.sessionType),a=Au(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=Eu[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||ku(e.sessionType,t)}}var Nu=`app://`;function Pu(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Fu(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Nu))return t;let n=Pu(t.slice(6));return n?`/${n}`:null}function Iu({name:e,src:t,className:n,imgClassName:i,fallback:a}){let[o,s]=(0,F.useState)(!1),c=!!t&&!o;return(0,I.jsx)(`div`,{className:r(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:c?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:r(`block h-6 w-6 object-contain`,i),onError:()=>s(!0),draggable:!1}):a??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Lu({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Ru,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Fu(e.src);return(0,I.jsx)(Iu,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(vn,{className:r(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(mn,{className:r(`h-3.5 w-3.5`,t)})}function Ru({channel:e,className:t}){return(0,I.jsx)(Iu,{name:e,src:Cu(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(vn,{className:`h-3 w-3 text-gray-500`})})}function zu(e){let{option:t,onSelect:n}=e,i=t.ready===!1?t.reasonMessage?.trim()||s(`statusSetup`):null;return(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,I.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,I.jsx)(Lu,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,I.jsx)(vn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,I.jsxs)(`span`,{className:r(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?s(`statusSetup`):s(`statusReady`)]})]}),i?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:i}):null]})]})})})}function Bu(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Vu(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Bu(n,r),[n,r]),u=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${s(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,I.jsxs)(Ai,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,I.jsx)(nn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(zu,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(nn,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var Hu=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Uu(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Wu({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=Hu[Uu(e)%Hu.length]??Hu[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:r(`rounded-full object-cover`,i)}):(0,I.jsx)(`div`,{className:r(`rounded-full flex items-center justify-center font-semibold`,o,s,i),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(vn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Gu({status:e,className:t}){let n=s(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:r(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,I.jsx)(Zn,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ku(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function qu(e){let t=e.activityPreview;return t?t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null:null}function Ju(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Yu(e,t){return e.getFullYear()===t.getFullYear()}function Xu(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Yu(e,t)?n:`${e.getFullYear()}年${n}`}function Zu(e,t=d(),n=new Date){if(!e)return`-`;let r=e instanceof Date?e:new Date(e);if(Number.isNaN(r.getTime()))return typeof e==`string`?e:`-`;let i=p(t),a=Ju(r),o=Ju(n),c=Math.floor((o-a)/864e5);if(c===0)return new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r);if(c===1)return s(`chatSidebarYesterday`,t);if(c>1&&c<7)return new Intl.DateTimeFormat(i,{weekday:`long`}).format(r);if(t===`zh`)return Xu(r,n);let l=Yu(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Qu(e){return e.trim().toLowerCase()}function $u(e,t){let n=Qu(t);return n?[e.key,Ku(e),e.projectRoot??``,e.projectName??``].map(Qu).some(e=>e.includes(n)):!0}function ed({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(j,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:s(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(M,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":s(`save`),children:(0,I.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(M,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":s(`cancel`),children:(0,I.jsx)(rn,{className:`h-3.5 w-3.5`})})]})]})]})}function td({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:c,agentLabel:l,agentAvatarUrl:u,childSessionCount:d=0,onSelect:f,onOpenChildSessions:p,onStartEditing:m}){let h=d>0&&p?`pr-14`:`pr-6`,g=qu(e),_=`${l?.trim()?`${l} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:r(`flex min-w-0 items-start`,h),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.trim()&&c.trim().toLowerCase()!==`main`?(0,I.jsx)(Wu,{agentId:c,displayName:l,avatarUrl:u,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:o}),a.label?(0,I.jsx)(`span`,{className:r(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:a.label}):null,a.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)(Lu,{icon:a.icon,className:t?`text-gray-700`:`text-gray-500`})}):null]})}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:g??_}),n?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:Zu(e.lastMessageAt??e.createdAt)})]})]}),d>0&&p?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:r(`absolute right-6 top-0 inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(Gn,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:d})]}):null,i?(0,I.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,I.jsx)(Gu,{status:i})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:r(`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-md text-gray-400 transition-all hover:bg-white hover:text-gray-900`,`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`edit`),children:(0,I.jsx)(ar,{className:`h-3 w-3`})})]})}function nd({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,childSessionCount:u,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:r(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,I.jsx)(ed,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(td,{session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,onSelect:m,childSessionCount:u,onOpenChildSessions:h,onStartEditing:g})})}var rd=[{icon:$n,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:ht,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:mn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function id({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(vn,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:s(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:s(`chatWelcomeSubtitle`)}),(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:s(`chatDraftAgentTitle`)}),(0,I.jsxs)(yl,{value:n,onValueChange:r,children:[(0,I.jsxs)(xl,{"aria-label":s(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:s(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(Wu,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(wl,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(El,{value:e.id,className:`rounded-lg pr-10`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(Wu,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:rd.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:s(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:s(t.descKey)})]},t.titleKey)})})]})})}var ad=(0,F.createContext)(null);function od({presenter:e,children:t}){return(0,I.jsx)(ad.Provider,{value:e,children:t})}function sd(){let e=(0,F.useContext)(ad);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var cd=e=>`[data-item-index="${e}"]`;function ld(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??cd;(0,F.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function ud(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function L(...e){return i(f(e))}var dd=F.forwardRef(({className:e,type:t,...n},r)=>(0,I.jsx)(`input`,{type:t,className:L(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));dd.displayName=`ChatInput`;var fd=Ti,pd=Di,md=Ei,hd=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(Oi,{children:(0,I.jsx)(ki,{ref:i,sideOffset:t,align:n,className:L(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...r})}));hd.displayName=ki.displayName;var gd=il,_d=dl,vd=ol,yd=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(al,{ref:r,className:L(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,I.jsx)(sl,{asChild:!0,children:(0,I.jsx)(xn,{className:`h-4 w-4 opacity-50`})})]}));yd.displayName=al.displayName;var bd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(gl,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Cn,{className:`h-4 w-4`})}));bd.displayName=gl.displayName;var xd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_l,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(xn,{className:`h-4 w-4`})}));xd.displayName=_l.displayName;var Sd=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(cl,{children:(0,I.jsxs)(ll,{ref:i,className:L(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,I.jsx)(bd,{}),(0,I.jsx)(ul,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,I.jsx)(xd,{})]})}));Sd.displayName=ll.displayName;var Cd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fl,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Cd.displayName=fl.displayName;var wd=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(pl,{ref:r,className:L(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(hl,{children:(0,I.jsx)(bn,{className:`h-4 w-4`})})}),(0,I.jsx)(ml,{children:t})]}));wd.displayName=pl.displayName;var Td=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vl,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Td.displayName=vl.displayName;var Ed=Fa,Dd=Ia,Od=La,kd=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Ra,{children:(0,I.jsx)(za,{ref:r,sideOffset:t,className:L(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...n})}));kd.displayName=za.displayName;var Ad={Popover:fd,PopoverAnchor:md,PopoverContent:hd,PopoverTrigger:pd,Input:dd,Select:gd,SelectContent:Sd,SelectGroup:_d,SelectItem:wd,SelectLabel:Cd,SelectSeparator:Td,SelectTrigger:yd,SelectValue:vd,Tooltip:Dd,TooltipContent:kd,TooltipProvider:Ed,TooltipTrigger:Od},jd=680,Md=.82,Nd=560;function Pd(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Ad,{elementRef:i,width:a}=ud(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onDetailsPointerDown:h,onSetActiveIndex:g}=e,_=(0,F.useMemo)(()=>{if(a)return Math.min(a>Nd?a*Md:a,jd)},[a]);return ld({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,I.jsxs)(t,{open:s,onOpenChange:m,children:[(0,I.jsx)(n,{asChild:!0,children:(0,I.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,I.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:_?{width:`${_}px`}:void 0,children:(0,I.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,I.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,I.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,I.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>g(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,I.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,I.jsx)(`div`,{className:`min-w-0 p-2.5`,onPointerDown:h,children:d?(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,I.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,I.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,I.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var Fd=oe(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),Id=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Fd({variant:t,size:n,className:e})),ref:i,...r}));Id.displayName=`ChatButton`;var Ld=120;function Rd(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Ld?t:`${t.slice(0,Ld-1)}…`}function zd(){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function Bd({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Ad,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,I.jsx)(r,{delayDuration:0,children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":e.label,title:e.label,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(#9ca3af ${o}deg, #e5e7eb 0deg)`}}),(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-white`})]})}),(0,I.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-gray-800`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-gray-600`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`font-medium text-gray-800`,children:e.value})]},e.label))]})})]})})}function Vd({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=Ad,y=e?.trim()??``,b=y?Rd(y):``,x=t?.trim()||`Details`;return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,I.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,I.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,I.jsxs)(f,{children:[(0,I.jsx)(m,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,I.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,I.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,I.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,I.jsx)(Bd,{contextWindow:l}):null,n?r?(0,I.jsx)(Id,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(zd,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Id,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(zd,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Id,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(_n,{className:`h-5 w-5`})})]})]})}function Hd(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Ud(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Ad,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,F.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,F.useMemo)(()=>h?h.flatMap(e=>e.options):Hd(a.options,c),[h,a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),ld({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,I.jsxs)(n,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,I.jsx)(ht,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Zt,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,I.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,I.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,I.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,I.jsxs)(`div`,{children:[e.label?(0,I.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,I.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,I.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,I.jsx)(or,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,I.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,I.jsx)(bn,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,I.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,I.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,I.jsx)(tn,{className:`h-3 w-3`})]})}):null]})]})}function Wd({icon:e}){return e===`sparkles`?(0,I.jsx)(gr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(yn,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Gd({icon:e}){return e===`paperclip`?(0,I.jsx)(ir,{className:`h-4 w-4`}):(0,I.jsx)(Wd,{icon:e})}var Kd={model:`min-w-0 flex-1 sm:min-w-[220px] sm:flex-none`,"session-type":`shrink-0`,thinking:`shrink-0`},qd={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Jd(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Yd({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Ad,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0),d=Jd(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${Kd[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Wd,{icon:e.icon}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700 sm:hidden`,children:d}),(0,I.jsx)(`span`,{className:`hidden truncate text-xs font-semibold text-gray-700 sm:inline`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:qd[e.key]??``,children:[u?null:e.loading?(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,I.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,I.jsxs)(`div`,{children:[t>0?(0,I.jsx)(o,{}):null,(0,I.jsxs)(r,{children:[e.label?(0,I.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,I.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,I.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function Xd({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Ad;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Ud,{picker:r}):null,n.map(e=>(0,I.jsx)(Yd,{item:e},e.key)),t?.map(e=>{let t=(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,I.jsx)(Gd,{icon:e.icon}),e.iconOnly?null:(0,I.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,I.jsx)(o,{children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:e.disabled?(0,I.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,I.jsx)(a,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,I.jsx)(`div`,{children:t},e.key)})]}),(0,I.jsx)(Vd,{...e})]})}var Zd=(0,F.createContext)(null);function Qd(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function $d(){let e=(0,F.useContext)(Zd);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function R(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ef(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var tf=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,nf=tf&&`documentMode`in document?document.documentMode:null,rf=tf&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),af=tf&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),of=!(!tf||!(`InputEvent`in window)||nf)&&`getTargetRanges`in new window.InputEvent(`input`),sf=tf&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,cf=tf&&/Android/.test(navigator.userAgent),lf=tf&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!cf,uf=tf&&/^(?=.*Chrome).*/i.test(navigator.userAgent),df=tf&&cf&&uf,ff=tf&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&rf&&!uf,pf=0,mf=1,hf=2,gf=1,_f=2,vf=3,yf=4,bf=5,xf=6,Sf=lf||sf||ff?`\xA0`:`​`,Cf=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-yTfN7UBH.js","assets/doc-browser-BI7HSaMK.js","assets/react-B2X_ph0a.js","assets/createLucideIcon-Br1EFMEr.js","assets/search-CdhgFNwf.js","assets/book-open-cPX0Za7Z.js","assets/wrench-qVIwShTF.js","assets/external-link-C3usm3se.js","assets/plus-BcIC8dG1.js","assets/x-Chb07O-Y.js","assets/doc-browser-context-DB6TTHeE.js","assets/doc-browser-route-registry.utils-x5ijvk0u.js","assets/model-config-BjXMpU9U.js","assets/api-DruAcori.js","assets/provider-scoped-model-input-t1tCP5y5.js","assets/config-hints-CY1lg9IE.js","assets/chat-page-Cpo0AFHb.js","assets/confirm-dialog-B0TP-vPd.js","assets/dist-rzakR_bu.js","assets/dist-CpwDZDtv.js","assets/mcp-marketplace-page-DDjeHd1I.js","assets/tag-chip-ix15P-r4.js","assets/play-CqNi0u02.js","assets/tabs-custom-BBXu1OGs.js","assets/search-config-Dzpizo-_.js","assets/config-split-page-BFh_Qixx.js","assets/providers-list-C1D5p9kK.js","assets/setting-row-8VkukJoH.js","assets/channels-list-page-DXH1qYLs.js","assets/runtime-config-page--O0Wq01S.js","assets/save-D10M5vQg.js","assets/desktop-update-config-Be8x1jNy.js","assets/secrets-config-D1AUSEXX.js","assets/mcp-marketplace-page-WUkc7n94.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g}from"./react-B2X_ph0a.js";import{$ as _,At as v,B as y,Ct as b,Dt as x,Et as S,F as C,Ft as w,G as T,H as E,I as ee,It as D,J as O,K as k,L as te,Lt as A,M as ne,Mt as j,N as re,Nt as M,Ot as ie,P as ae,Pt as oe,Q as se,R as ce,Rt as le,St as ue,Tt as de,U as fe,V as pe,W as me,X as he,Xt as ge,Y as _e,Yt as ve,Z as ye,_ as be,_t as xe,a as Se,at as Ce,c as we,d as Te,dt as Ee,f as De,g as Oe,gt as ke,h as Ae,i as je,it as Me,jt as Ne,kt as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,o as Be,on as Ve,ot as N,p as He,pt as Ue,q as We,r as Ge,rt as Ke,s as qe,st as Je,t as Ye,u as Xe,ut as Ze,v as Qe,vt as $e,wt as et,xt as tt,y as nt,yt as rt,z as it,zt as at}from"./api-DruAcori.js";import{a as ot,c as st,d as ct,f as lt,i as ut,l as dt,m as ft,n as pt,o as mt,r as ht,s as gt,u as _t}from"./doc-browser-BI7HSaMK.js";import{C as vt,S as yt,_ as bt,a as xt,b as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,l as kt,m as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,t as It,u as Lt,v as Rt,w as zt,y as Bt}from"./dist-rzakR_bu.js";import{t as Vt}from"./dist-CpwDZDtv.js";import{a as Ht,c as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-B0TP-vPd.js";import{t as P}from"./createLucideIcon-Br1EFMEr.js";import{n as Xt,t as Zt}from"./search-CdhgFNwf.js";import{t as Qt}from"./book-open-cPX0Za7Z.js";import{n as $t,t as en}from"./wrench-qVIwShTF.js";import{t as tn}from"./external-link-C3usm3se.js";import{t as nn}from"./plus-BcIC8dG1.js";import{t as rn}from"./x-Chb07O-Y.js";import{l as an,n as on,r as sn,t as cn}from"./doc-browser-route-registry.utils-x5ijvk0u.js";import{i as ln,n as un,r as dn,t as fn}from"./doc-browser-context-DB6TTHeE.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pn=a((e=>{var t=Ve();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),mn=P(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),hn=P(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),gn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),_n=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),vn=P(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),yn=P(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),bn=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),xn=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Sn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Cn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),wn=P(`CircleHelp`,[[`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`}]]),Tn=P(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),En=P(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Dn=P(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),On=P(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),kn=P(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),An=P(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),jn=P(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Mn=P(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Nn=P(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Pn=P(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 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:`fq0c9t`}],[`path`,{d:`M8 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:`4gibmv`}]]),Fn=P(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),In=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Ln=P(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Rn=P(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),zn=P(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Bn=P(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Vn=P(`FolderTree`,[[`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`}]]),Hn=P(`FolderUp`,[[`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`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),Un=P(`FolderX`,[[`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`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Wn=P(`Folder`,[[`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`}]]),Gn=P(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Kn=P(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),qn=P(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),Jn=P(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Yn=P(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Xn=P(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Zn=P(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qn=P(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),$n=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),er=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),tr=P(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),nr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),rr=P(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),ir=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),ar=P(`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`}]]),or=P(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),sr=P(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),cr=P(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),lr=P(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),ur=P(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),dr=P(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),fr=P(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),pr=P(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),mr=P(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),hr=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),gr=P(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),_r=P(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),vr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),yr=P(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),br=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),xr=P(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Sr=P(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Cr=P(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),wr=P(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),F=g(o(),1),Tr=pn(),I=l(),Er={active:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},ready:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},inactive:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},setup:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},warning:{dot:`bg-amber-400`,text:`text-amber-600`,bg:`bg-amber-50`}};function Dr({status:e,label:t,className:n}){let i=Er[e];return(0,I.jsxs)(`div`,{className:r(`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5`,i.bg,n),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,i.dot)}),(0,I.jsx)(`span`,{className:r(`text-[11px] font-medium`,i.text),children:t})]})}function Or(){return at({queryKey:jr,queryFn:Se,staleTime:5e3,refetchOnWindowFocus:!0})}function kr(e){let{label:t,muted:n,value:r}=e;return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,I.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function Ar(){let e=ko(),t=Or(),n=t.data,r=zr(e=>e.actionLabel),i=(0,F.useMemo)(()=>Gr(n),[n]),a=!!r,o=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||s(`remoteDeviceNameAuto`),c=!!(n?.account.loggedIn&&Rr(n)),{hero:l,issueHint:d}=i;return(0,F.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,I.jsx)(`div`,{className:`p-8 text-gray-400`,children:s(`remoteLoading`)}):(0,I.jsxs)(v,{className:`space-y-6`,children:[(0,I.jsx)(Pe,{title:s(`remotePageTitle`),description:s(`remotePageDescription`)}),(0,I.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(ie,{children:l.title}),(0,I.jsx)(Dr,{status:l.badgeStatus,label:l.badgeLabel})]}),(0,I.jsx)(S,{children:l.description})]}),(0,I.jsxs)(de,{className:`space-y-5`,children:[(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(kr,{label:s(`remoteSignedInAccount`),value:n?.account.email}),(0,I.jsx)(kr,{label:s(`remoteDeviceName`),value:o}),(0,I.jsx)(kr,{label:s(`remoteConnectionStatus`),value:l.badgeLabel}),(0,I.jsx)(kr,{label:s(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?u(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.primaryAction?(0,I.jsxs)(M,{onClick:()=>{if(i.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(i.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:a,children:[i.primaryAction.showRefreshIcon?(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}):null,r||i.primaryAction.label]}):null,(0,I.jsxs)(M,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:a||!c,children:[(0,I.jsx)(_r,{className:`mr-2 h-4 w-4`}),s(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,I.jsx)(M,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:a,children:s(`remoteDisable`)}):null]}),i.shouldShowIssueHint&&d?(0,I.jsx)(Gt,{tone:`warning`,title:d.title,description:d.body}):null,(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:s(`remoteOpenWebHint`)})]})]}),(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{children:[(0,I.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Xn,{className:`h-4 w-4 text-primary`}),s(`remoteDeviceSectionTitle`)]}),(0,I.jsx)(S,{children:s(`remoteDeviceSectionDescription`)})]}),(0,I.jsxs)(de,{className:`space-y-5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(Dr,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?s(`remoteAccountConnected`):s(`remoteAccountNotConnected`)}),(0,I.jsx)(Dr,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?s(`remoteEnabled`):s(`remoteStateDisabled`)}),(0,I.jsx)(Dr,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?s(`remoteServiceRunning`):s(`remoteServiceStopped`)})]}),(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(kr,{label:s(`remoteDeviceName`),value:o}),(0,I.jsx)(kr,{label:s(`remoteConnectionStatus`),value:l.badgeLabel}),(0,I.jsx)(kr,{label:s(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?u(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsx)(Gt,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?s(`remoteOpenWebHint`):s(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var jr=[`remote-status`],Mr=`https://platform.nextclaw.io`,Nr=`https://nextclaw-platform-console.pages.dev`,Pr=async()=>await w.fetchQuery({queryKey:jr,queryFn:Se,staleTime:5e3}),Fr=async()=>(await w.invalidateQueries({queryKey:jr}),await Pr()),Ir=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function Lr(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return Mr;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return Nr}var Rr=e=>Lr(e?.account.apiBase)||Lr(e?.settings.platformApiBase)||Lr(e?.platformBase)||Lr(e?.account.platformBase)||void 0,zr=m(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),Br=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=zr.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{zr.getState().setEnabled(e)},this.setDeviceName=e=>{zr.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{zr.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{zr.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await Fr(),n=zr.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await Fr();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await Fr(),n=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:s(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await Ge(n);let e=await Fr();this.hydrateDraftFromStatus(e)},successMessage:s(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await Fr(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:zr.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await Fr(),n=zr.getState();await this.runManagedAction({actionLabel:s(`remoteActionSavingAdvanced`),job:async()=>{await Xe({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await Fr();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?s(`remoteSettingsSaved`):s(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:s(`remoteDoctorRunning`),job:async()=>{let e=await je();zr.getState().setDoctor(e)},successMessage:s(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,s(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,s(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,s(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let n=zr.getState();await this.runManagedAction({actionLabel:s(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await Xe({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await Fr();this.hydrateDraftFromStatus(r),e?await Ge(r.service.running?`restart`:`start`):t.service.running&&await Ge(`restart`);let i=await Fr();this.hydrateDraftFromStatus(i)},successMessage:s(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await Ge(e),n=await Fr();this.hydrateDraftFromStatus(n),A.success(t.message)}})},this.hydrateDraftFromStatus=e=>{zr.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:n,successMessage:r}=e;zr.getState().beginAction(t);try{await n(),r&&A.success(r)}catch(e){let t=e instanceof Error?e.message:s(`error`);throw A.error(t),e}finally{zr.getState().finishAction()}}}},Vr=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function Hr(e){return e?.runtime?.lastError?.trim()||``}function Ur(e){let t=s(`remoteStatusIssueDetailGeneric`),n=Hr(e);return n?`${t} (${n})`:t}function Wr(e){if(!e?.settings.enabled)return!1;let t=Hr(e);return Vr.some(e=>e.test(t))}function Gr(e){return Wr(e)?{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteStateReauthorizationRequired`),title:s(`remoteStatusReauthorizationTitle`),description:s(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:s(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:s(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:s(`statusReady`),title:s(`remoteStatusReadyTitle`),description:s(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:s(`connecting`),title:s(`remoteStatusConnectingTitle`),description:s(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteStateDisconnected`),title:s(`remoteStatusIssueTitle`),description:s(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:Ur(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:s(`remoteServiceStopped`),title:s(`remoteStatusNeedsServiceTitle`),description:s(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:s(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:s(`remoteStatusRecoveryTitle`),body:s(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:s(`statusInactive`),title:s(`remoteStatusNeedsEnable`),description:s(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:s(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:s(`statusSetup`),title:s(`remoteStatusNeedsSignIn`),description:s(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:s(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Kr=m(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function qr({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,I.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Jr(e){let{email:t,username:n,role:r,canSubmitUsername:i,savingUsername:a,usernameDraft:o,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Gt,{tone:`success`,title:s(`accountPanelSignedInTitle`),description:s(`accountPanelSignedInDescription`)}),(0,I.jsxs)(Gt,{tone:`neutral`,children:[(0,I.jsx)(qr,{label:s(`remoteAccountEmail`),value:t}),(0,I.jsx)(qr,{label:s(`remoteAccountUsername`),value:n}),(0,I.jsx)(qr,{label:s(`remoteAccountRole`),value:r})]}),n?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:s(`remoteAccountUsernameLockedHelp`)}):(0,I.jsxs)(Gt,{tone:`warning`,title:s(`remoteAccountUsernameRequiredTitle`),description:s(`remoteAccountUsernameRequiredDescription`),children:[(0,I.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,I.jsx)(Ne,{htmlFor:`account-panel-username`,children:s(`remoteAccountUsername`)}),(0,I.jsx)(j,{id:`account-panel-username`,value:o,onChange:e=>c(e.target.value),placeholder:s(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,I.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,I.jsx)(M,{disabled:!i,onClick:()=>void l(),children:s(a?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsxs)(M,{onClick:()=>void u(),children:[(0,I.jsx)(_r,{className:`mr-2 h-4 w-4`}),s(`remoteOpenDeviceList`)]}),(0,I.jsxs)(M,{variant:`outline`,onClick:()=>void d(),children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4`}),s(`remoteLogout`)]})]})]})}function Yr(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:r,authVerificationUri:i,onStartBrowserSignIn:a,onResumeBrowserSignIn:o}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Gt,{tone:`neutral`,title:s(`accountPanelSignedOutTitle`),description:s(`accountPanelSignedOutDescription`),children:t?(0,I.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,I.jsx)(qr,{label:s(`remoteBrowserAuthSession`),value:t}),(0,I.jsx)(qr,{label:s(`remoteBrowserAuthExpiresAt`),value:n?u(n):`-`})]}):null}),r?(0,I.jsx)(`p`,{className:`text-sm text-gray-600`,children:r}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsx)(M,{onClick:()=>void a(),children:s(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),i?(0,I.jsx)(M,{variant:`outline`,onClick:o,children:s(`remoteBrowserAuthResume`)}):null]})]})}function Xr(){let e=ko(),t=Or(),n=Kr(e=>e.panelOpen),r=Kr(e=>e.authSessionId),i=Kr(e=>e.authVerificationUri),a=Kr(e=>e.authExpiresAt),o=Kr(e=>e.authStatusMessage),c=t.data,[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(!1);(0,F.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,I.jsx)(qt,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,I.jsxs)(Wt,{className:`max-w-xl`,children:[(0,I.jsxs)(Jt,{children:[(0,I.jsxs)(Ut,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Jn,{className:`h-5 w-5 text-primary`}),s(`accountPanelTitle`)]}),(0,I.jsx)(Ht,{children:s(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,I.jsx)(Jr,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,I.jsx)(Yr,{authSessionId:r,authExpiresAt:a,authStatusMessage:o,authVerificationUri:i,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Zr({username:e}){let t=Ee(),[n,r]=(0,F.useState)(e??``),[i,a]=(0,F.useState)(``),o=n.trim().length>0&&i.length>0&&!t.isPending;return(0,I.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,I.jsxs)(et,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,I.jsxs)(x,{children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:s(`authBrand`)}),(0,I.jsx)(ie,{className:`text-2xl`,children:s(`authLoginTitle`)}),(0,I.jsx)(S,{children:s(`authLoginDescription`)})]}),(0,I.jsx)(de,{children:(0,I.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),o&&t.mutate({username:n.trim(),password:i})},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:s(`authUsername`)}),(0,I.jsx)(j,{value:n,onChange:e=>r(e.target.value),placeholder:s(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:s(`authPassword`)}),(0,I.jsx)(j,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:s(`authPasswordPlaceholder`)})]}),(0,I.jsx)(M,{type:`submit`,className:`w-full`,disabled:!o,children:t.isPending?s(`authLoggingIn`):s(`authLoginAction`)})]})})]})})}var Qr=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{Kr.getState().openPanel()},this.closeAccountPanel=()=>{Kr.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),Kr.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await Pr();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,n=await we({apiBase:Ir(e?.status??await Pr(),t)});Kr.getState().beginBrowserAuth({sessionId:n.sessionId,verificationUri:n.verificationUri,expiresAt:n.expiresAt,intervalMs:n.intervalMs,statusMessage:s(`remoteBrowserAuthWaiting`)}),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`)||Kr.getState().setAuthStatusMessage(s(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:s(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),A.error(`${s(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Kr.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await Be(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),Kr.getState().clearBrowserAuth(),await Fr(),A.success(s(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:s(`remoteLogoutFailed`);A.error(`${s(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await Fe({username:e.trim()}),await Fr(),A.success(s(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:s(`remoteAccountUsernameSetFailed`);A.error(`${s(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=Rr(await Pr());if(!t){A.error(s(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(n,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Kr.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Kr.getState();if(e.authSessionId)try{let t=await Pr(),n=await qe({sessionId:e.authSessionId,apiBase:Ir(t)});if(n.status===`pending`){Kr.getState().updateBrowserAuth({statusMessage:s(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(n.message||s(`remoteBrowserAuthExpired`))),Kr.getState().clearBrowserAuth(),A.error(n.message||s(`remoteBrowserAuthExpired`));return}Kr.getState().setAuthStatusMessage(s(`remoteBrowserAuthCompleted`));let r=await Fr();this.clearPollTimer(),this.resolveBrowserSignIn(r),Kr.getState().clearBrowserAuth(),A.success(s(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),Kr.getState().clearBrowserAuth();let t=e instanceof Error?e.message:s(`remoteBrowserAuthPollFailed`);A.error(`${s(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=Kr.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?u(e.authExpiresAt):`-`}}}},$r=`Popover`,[ei,ti]=yt($r,[Ft]),ni=Ft(),[ri,ii]=ei($r),ai=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ni(t),c=F.useRef(null),[l,u]=F.useState(!1),[d,f]=Rt({prop:r,defaultProp:i??!1,onChange:a,caller:$r});return(0,I.jsx)(Mt,{...s,children:(0,I.jsx)(ri,{scope:t,contentId:Bt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:F.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:F.useCallback(()=>u(!0),[]),onCustomAnchorRemove:F.useCallback(()=>u(!1),[]),modal:o,children:n})})};ai.displayName=$r;var oi=`PopoverAnchor`,si=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(oi,n),a=ni(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return F.useEffect(()=>(o(),()=>s()),[o,s]),(0,I.jsx)(Pt,{...a,...r,ref:t})});si.displayName=oi;var ci=`PopoverTrigger`,li=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(ci,n),a=ni(n),o=vt(t,i.triggerRef),s=(0,I.jsx)(Dt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":wi(i.open),...r,ref:o,onClick:zt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,I.jsx)(Pt,{asChild:!0,...a,children:s})});li.displayName=ci;var ui=`PopoverPortal`,[di,fi]=ei(ui,{forceMount:void 0}),pi=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ii(ui,t);return(0,I.jsx)(di,{scope:t,forceMount:n,children:(0,I.jsx)(Vt,{present:n||a.open,children:(0,I.jsx)(wt,{asChild:!0,container:i,children:r})})})};pi.displayName=ui;var mi=`PopoverContent`,hi=F.forwardRef((e,t)=>{let n=fi(mi,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=ii(mi,e.__scopePopover);return(0,I.jsx)(Vt,{present:r||a.open,children:a.modal?(0,I.jsx)(_i,{...i,ref:t}):(0,I.jsx)(vi,{...i,ref:t})})});hi.displayName=mi;var gi=Et(`PopoverContent.RemoveScroll`),_i=F.forwardRef((e,t)=>{let n=ii(mi,e.__scopePopover),r=F.useRef(null),i=vt(t,r),a=F.useRef(!1);return F.useEffect(()=>{let e=r.current;if(e)return Ct(e)},[]),(0,I.jsx)(kt,{as:gi,allowPinchZoom:!0,children:(0,I.jsx)(yi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:zt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:zt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),vi=F.forwardRef((e,t)=>{let n=ii(mi,e.__scopePopover),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(yi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),yi=F.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=ii(mi,n),p=ni(n);return Lt(),(0,I.jsx)(Tt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,I.jsx)(xt,{"data-state":wi(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),bi=`PopoverClose`,xi=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ii(bi,n);return(0,I.jsx)(Dt.button,{type:`button`,...r,ref:t,onClick:zt(e.onClick,()=>i.onOpenChange(!1))})});xi.displayName=bi;var Si=`PopoverArrow`,Ci=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ni(n);return(0,I.jsx)(Ot,{...i,...r,ref:t})});Ci.displayName=Si;function wi(e){return e?`open`:`closed`}var Ti=ai,Ei=si,Di=li,Oi=pi,ki=hi,Ai=Ti,ji=Di,Mi=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...i},a)=>(0,I.jsx)(Oi,{children:(0,I.jsx)(ki,{ref:a,sideOffset:t,align:n,className:r(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...i})}));Mi.displayName=ki.displayName;function Ni({deletePending:e,entry:t,favoritePending:n,onDelete:r,onOpen:i,onToggleFavorite:a}){let[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=t.favorite?s(`panelAppsUnfavorite`):s(`panelAppsFavorite`),f=t.lastOpenedAt?`${s(`panelAppsLastOpened`)} ${Fi(t.lastOpenedAt)}`:`${s(`panelAppsUpdated`)} ${Fi(t.updatedAt)}`,p=e=>{e.stopPropagation(),a()},m=()=>{c(!1),u(!0)};return(0,I.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,I.jsx)(Ii,{icon:t.icon,title:t.title})}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,I.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,I.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:p,disabled:n,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,I.jsx)(yr,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,I.jsxs)(Ai,{open:o,onOpenChange:c,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":s(`panelAppsMoreActions`),disabled:e,children:(0,I.jsx)(kn,{className:`h-4 w-4`})})}),(0,I.jsx)(Mi,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,I.jsx)(Pi,{destructive:!0,disabled:e,icon:xr,label:s(`panelAppsDelete`),onClick:m})})]})]})]}),(0,I.jsx)(Yt,{open:l,onOpenChange:u,title:s(`panelAppsDeleteConfirmTitle`),description:`${s(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:s(`delete`),variant:`destructive`,onConfirm:r,onCancel:()=>void 0})]})}function Pi({destructive:e=!1,disabled:t=!1,icon:n,label:i,onClick:a}){return(0,I.jsxs)(`button`,{type:`button`,className:r(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:t,onClick:a,children:[(0,I.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:i})]})}function Fi(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=p(d()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function Ii({icon:e,title:t}){return e?Li(e)?(0,I.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,I.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,I.jsx)(hn,{className:`h-4 w-4`})}function Li(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Ri=[`panel-apps`];function zi(){return at({queryKey:Ri,queryFn:()=>N.panelApps.listPanelApps(),staleTime:0})}function Bi(){let e=ge();return le({mutationFn:({id:e,preferences:t})=>N.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Vi(){let e=ge();return le({mutationFn:e=>N.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Hi(){let e=ge();return le({mutationFn:e=>N.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ri})}})}function Ui(e,t){return t===`favorites`?Wi(e.filter(e=>e.favorite),`smart`):Wi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function Wi(e,t){return[...e].sort((e,n)=>Gi(e,n,t))}function Gi(e,t,n){return n===`recent-open`?Yi(e.lastOpenedAt,t.lastOpenedAt)||Ki(e,t):n===`updated`?Yi(e.updatedAt,t.updatedAt)||Ki(e,t):n===`name`?Ki(e,t):qi(e,t)||Number(t.favorite)-Number(e.favorite)||Ki(e,t)}function Ki(e,t){return e.title.localeCompare(t.title)}function qi(e,t){return Ji(t)-Ji(e)}function Ji(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Yi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var Xi=F.createContext(null);function Zi({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,I.jsx)(Xi.Provider,{value:{value:t,onValueChange:n},children:r})}function Qi({children:e,className:t}){return(0,I.jsx)(`div`,{className:r(`inline-flex h-9 items-center justify-center rounded-xl bg-gray-100/80 p-1 text-gray-500`,t),children:e})}function $i({value:e,children:t,className:n}){let i=F.useContext(Xi);if(!i)throw Error(`TabsTrigger must be used within Tabs`);let a=i.value===e;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>i.onValueChange(e),"aria-pressed":a,"data-state":a?`active`:`inactive`,className:r(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium ring-offset-white transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,a?`bg-white text-gray-900 shadow-sm`:`hover:bg-white/50 hover:text-gray-800 text-gray-600`,n),children:t})}function ea({value:e,children:t,className:n}){let i=F.useContext(Xi);if(!i)throw Error(`TabsContent must be used within Tabs`);return i.value===e?(0,I.jsx)(`div`,{className:r(`mt-2 animate-fade-in`,n),children:t}):null}var[ta,na]=yt(`Tooltip`,[Ft]),ra=Ft(),ia=`TooltipProvider`,aa=700,oa=`tooltip.open`,[sa,ca]=ta(ia),la=e=>{let{__scopeTooltip:t,delayDuration:n=aa,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(sa,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:F.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};la.displayName=ia;var ua=`Tooltip`,[da,fa]=ta(ua),pa=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ca(ua,e.__scopeTooltip),l=ra(t),[u,d]=F.useState(null),f=Bt(),p=F.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=F.useRef(!1),[_,v]=Rt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(oa))):c.onClose(),a?.(e)},caller:ua}),y=F.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=F.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return F.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,I.jsx)(Mt,{...l,children:(0,I.jsx)(da,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:F.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:F.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};pa.displayName=ua;var ma=`TooltipTrigger`,ha=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=fa(ma,n),a=ca(ma,n),o=ra(n),s=vt(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Pt,{asChild:!0,...o,children:(0,I.jsx)(Dt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:zt(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:zt(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:zt(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:zt(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:zt(e.onBlur,i.onClose),onClick:zt(e.onClick,i.onClose)})})});ha.displayName=ma;var ga=`TooltipPortal`,[_a,va]=ta(ga,{forceMount:void 0}),ya=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=fa(ga,t);return(0,I.jsx)(_a,{scope:t,forceMount:n,children:(0,I.jsx)(Vt,{present:n||a.open,children:(0,I.jsx)(wt,{asChild:!0,container:i,children:r})})})};ya.displayName=ga;var ba=`TooltipContent`,xa=F.forwardRef((e,t)=>{let n=va(ba,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=fa(ba,e.__scopeTooltip);return(0,I.jsx)(Vt,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(Ea,{side:i,...a,ref:t}):(0,I.jsx)(Sa,{side:i,...a,ref:t})})}),Sa=F.forwardRef((e,t)=>{let n=fa(ba,e.__scopeTooltip),r=ca(ba,e.__scopeTooltip),i=F.useRef(null),a=vt(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Aa(r,ka(r,n.getBoundingClientRect())),a=ja(t.getBoundingClientRect());s(Na([...i,...a])),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Ma(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(Ea,{...e,ref:a})}),[Ca,wa]=ta(ua,{isInside:!1}),Ta=bt(`TooltipContent`),Ea=F.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=fa(ba,n),l=ra(n),{onClose:u}=c;return F.useEffect(()=>(document.addEventListener(oa,u),()=>document.removeEventListener(oa,u)),[u]),F.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,I.jsxs)(xt,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(Ta,{children:r}),(0,I.jsx)(Ca,{scope:n,isInside:!0,children:(0,I.jsx)(It,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});xa.displayName=ba;var Da=`TooltipArrow`,Oa=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ra(n);return wa(Da,n).isInside?null:(0,I.jsx)(Ot,{...i,...r,ref:t})});Oa.displayName=Da;function ka(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Aa(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ja(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Ma(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Na(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Pa(t)}function Pa(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Fa=la,Ia=pa,La=ha,Ra=ya,za=xa,Ba=Fa,Va=Ia,Ha=La,Ua=F.forwardRef(({className:e,sideOffset:t=4,...n},i)=>(0,I.jsx)(Ra,{children:(0,I.jsx)(za,{ref:i,sideOffset:t,className:r(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...n})}));Ua.displayName=za.displayName;function Wa({headerContent:e,onOpenPanelApp:t}){let n=zi(),r=Hi(),i=Bi(),a=Vi(),[o,c]=(0,F.useState)(`smart`),l=(0,F.useMemo)(()=>Ui(n.data?.entries??[],o),[n.data?.entries,o]),u=async e=>{try{t(await a.mutateAsync(e.id))}catch{t(e)}},d=e=>{i.mutate({id:e.id,preferences:{favorite:!e.favorite}})},f=e=>{r.mutate(e.id)};return n.isLoading?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:s(`panelAppsLoading`)}):n.isError?(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:n.error instanceof Error?n.error.message:s(`panelAppsLoadFailed`)}):(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:s(`panelAppsTitle`)}),n.data?.panelsPath?(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":s(`panelAppsTitle`),children:(0,I.jsx)(wn,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(Ua,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:n.data.panelsPath})]})}):null]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void n.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`panelAppsRefresh`),"aria-label":s(`panelAppsRefresh`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,I.jsx)(Zi,{value:o,onValueChange:e=>c(e),children:(0,I.jsxs)(Qi,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsx)($i,{value:`smart`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortSmart`)}),(0,I.jsx)($i,{value:`favorites`,className:`px-2 py-1 text-xs`,children:s(`panelAppsFavorites`)}),(0,I.jsx)($i,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortRecentOpen`)}),(0,I.jsx)($i,{value:`updated`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortUpdated`)}),(0,I.jsx)($i,{value:`name`,className:`px-2 py-1 text-xs`,children:s(`panelAppsSortName`)})]})})}),l.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:s(`panelAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,I.jsx)(Ni,{entry:e,deletePending:r.isPending,favoritePending:i.isPending,onDelete:()=>f(e),onOpen:()=>void u(e),onToggleFavorite:()=>d(e)},e.id))})})]})}var Ga=class{constructor(e){this.authorizationManager=e,this.sessions=new Map,this.handleIframeMessage=({event:e,iframe:t,iframeInstanceId:n,tab:r})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,iframeInstanceId:n,tab:r},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=await this.getSession(e),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await N.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await N.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await N.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof ue)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await N.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await N.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof ue)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await N.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await N.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof ue)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await N.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}))throw new ue({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await N.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.findAction(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:r?.title,actionDescription:r?.description,risk:r?.risk,inputPreview:this.createInputPreview(n)}))throw new ue({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await N.serviceApps.grantServiceAction(t,{bridgeSessionToken:e.token})},this.findAction=async(e,t)=>(await N.serviceApps.listServiceActions({bridgeSessionToken:e.token})).actions.find(e=>e.id===t),this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getSession=async e=>{let t=this.readPanelAppId(e.tab.currentUrl),n=`${e.iframeInstanceId}:${t}`,r=this.sessions.get(n);return r||(r=N.panelApps.createBridgeSession({panelAppId:t,tabId:e.tab.id}),this.sessions.set(n,r)),await r},this.readPanelAppId=e=>{let t=new URL(e,window.location.origin),n=/^\/api\/panel-apps\/([^/]+)\/content$/.exec(t.pathname);if(!n?.[1])throw Error(`Current tab is not a Panel App.`);return decodeURIComponent(n[1])},this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof ue?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function Ka(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var qa=m((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:Ka(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Ja(){let e=qa(e=>e.pending),t=qa(e=>e.resolveAuthorization);return(0,I.jsx)(qt,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,I.jsxs)(Wt,{className:`[&>:last-child]:hidden`,children:[(0,I.jsxs)(Jt,{children:[(0,I.jsxs)(Ut,{className:`flex items-center gap-2`,children:[(0,I.jsx)(fr,{className:`h-4 w-4 text-amber-600`}),s(`serviceActionAuthorizationTitle`)]}),(0,I.jsx)(Ht,{children:s(`serviceActionAuthorizationDescription`)})]}),e?(0,I.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationAction`),value:e.actionTitle??e.actionId}),e.actionDescription?(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationPurpose`),value:e.actionDescription}):null,(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationRisk`),value:e.risk??`dangerous`}),e.inputPreview?(0,I.jsx)(Ya,{label:s(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,I.jsxs)(Kt,{className:`gap-2 sm:gap-0`,children:[(0,I.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:s(`serviceActionAuthorizationReject`)}),(0,I.jsx)(M,{type:`button`,onClick:()=>t(!0),children:s(`serviceActionAuthorizationAllow`)})]})]})})}function Ya({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,I.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Xa=class{constructor(){this.requestAuthorization=async e=>await qa.getState().requestAuthorization(e)}},Za=[`service-apps`],Qa=[`service-actions`],$a=[`service-action-grants`];function eo(){return at({queryKey:Za,queryFn:()=>N.serviceApps.listServiceApps()})}function to(){return at({queryKey:Qa,queryFn:()=>N.serviceApps.listServiceActions()})}function no(){return at({queryKey:$a,queryFn:()=>N.serviceApps.listServiceActionGrants()})}function ro(){let e=ge();return le({mutationFn:e=>N.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Za}),e.invalidateQueries({queryKey:Qa})])}})}function io(){let e=ge();return le({mutationFn:e=>N.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Za})}})}function ao(){let e=ge();return le({mutationFn:e=>N.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Qa}),e.invalidateQueries({queryKey:$a})])}})}function oo({headerContent:e}){let t=eo(),n=to(),r=no(),i=ro(),a=io(),o=ao(),[c,l]=(0,F.useState)({}),u=()=>{t.refetch(),n.refetch(),r.refetch()};if(t.isLoading||n.isLoading||r.isLoading)return(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:s(`serviceAppsLoading`)});if(t.isError||n.isError||r.isError){let e=t.error??n.error??r.error;return(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:s(`serviceAppsLoadFailed`)})}let d=t.data?.entries??[],f=n.data?.actions??[],p=r.data?.grants??[],m=e=>{a.mutateAsync(e).then(t=>{l(n=>({...n,[e]:t.actions}))})};return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ur,{className:`h-4 w-4 text-primary`}),(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:s(`serviceAppsTitle`)})]})}),(0,I.jsx)(`button`,{type:`button`,onClick:u,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`serviceAppsRefresh`),"aria-label":s(`serviceAppsRefresh`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]}),d.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:s(`serviceAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,I.jsx)(so,{app:e,actions:c[e.id]??f.filter(t=>t.appId===e.id),grants:p,isDiscovering:a.isPending,onDiscover:m,onRestart:e=>void i.mutate(e),onRevoke:e=>void o.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function so({app:e,actions:t,grants:n,isDiscovering:r,onDiscover:i,onRestart:a,onRevoke:o}){return(0,I.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`span`,{className:`rounded bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.status})]}),e.description?(0,I.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,I.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,title:s(`serviceAppsDiscoverActions`),"aria-label":s(`serviceAppsDiscoverActions`),children:(0,I.jsx)(Zt,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`serviceAppsRestart`),"aria-label":s(`serviceAppsRestart`),children:(0,I.jsx)(lr,{className:`h-3.5 w-3.5`})})]})]}),(0,I.jsx)(co,{app:e}),(0,I.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,I.jsx)(uo,{action:e,grants:n.filter(t=>t.actionId===e.id),onRevoke:o},e.id))})]})}function co({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),n=[{label:s(`serviceAppsCommand`),value:t},{label:s(`serviceAppsCwd`),value:e.cwd},{label:s(`serviceAppsManifest`),value:e.manifestPath},{label:s(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:s(`serviceAppsLastReady`),value:e.lastReadyAt},{label:s(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return n.length===0?null:(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:n.map(e=>(0,I.jsx)(lo,{label:e.label,value:e.value},e.label))})}function lo({label:e,value:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,I.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function uo({action:e,grants:t,onRevoke:n}){return(0,I.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(en,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,I.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,I.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:s(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,I.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,I.jsx)(pr,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[s(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:s(`serviceAppsRevokeGrant`),"aria-label":s(`serviceAppsRevokeGrant`),children:(0,I.jsx)(xr,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function fo({activeTab:e,onActiveTabChange:t,onOpenPanelApp:n}){let r=(0,I.jsx)(Zi,{value:e,onValueChange:e=>t(e),children:(0,I.jsxs)(Qi,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsxs)($i,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,I.jsx)(hn,{className:`h-3.5 w-3.5`}),s(`panelAppsTitle`)]}),(0,I.jsxs)($i,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,I.jsx)(ur,{className:`h-3.5 w-3.5`}),s(`serviceAppsTitle`)]})]})});return(0,I.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,I.jsx)(Wa,{headerContent:r,onOpenPanelApp:n}):(0,I.jsx)(oo,{headerContent:r})})}function po({onOpenApps:e,onRefresh:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),s(`appsTitle`)]}),(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:s(`panelAppsRefreshCurrent`),"aria-label":s(`panelAppsRefreshCurrent`),children:(0,I.jsx)(cr,{className:`h-3.5 w-3.5`})})]})}var mo=cn,ho=`panel-app`,go=`panel-apps`,_o=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function vo(e){return e===`panel-apps`||e===`service-apps`}function yo(e=go){return e===go?on:sn}function bo(e){try{let t=new URL(e).searchParams.get(`tab`);return vo(t)?t:go}catch{return go}}function xo(e){e.open(yo(),{kind:mo,title:s(`appsTitle`),dedupeKey:`apps`})}var So={[mo]:{getTitle:()=>s(`appsTitle`),renderIcon:()=>(0,I.jsx)($t,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t})=>(0,I.jsx)(fo,{activeTab:bo(e),onActiveTabChange:e=>t(yo(e),{activate:!1,kind:mo,title:s(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>t(e.contentPath,{kind:ho,title:e.title,dedupeKey:`panel-app:${e.id}`})})},[ho]:{getIframeSandbox:()=>_o,getTitle:e=>e.title||s(`panelAppsTitle`),onIframeMessage:e=>Eo().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,I.jsx)(hn,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,I.jsx)(po,{onOpenApps:()=>xo({open:e}),onRefresh:t})}},Co=class{constructor(){this.accountManager=new Qr,this.serviceActionAuthorizationManager=new Xa,this.panelAppBridgeManager=new Ga(this.serviceActionAuthorizationManager),this.remoteAccessManager=new Br({accountManager:this.accountManager})}},wo=null;function To(){return wo??=new Co,wo}function Eo(){return To()}var Do=(0,F.createContext)(null);function Oo({children:e}){let t=(0,F.useMemo)(()=>To(),[]);return(0,I.jsx)(Do.Provider,{value:t,children:e})}function ko(){let e=(0,F.useContext)(Do);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}function Ao(){let e=un();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;an(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}var jo=(0,F.createContext)(null);function Mo({children:e}){let[t,r]=(0,F.useState)(()=>n());(0,F.useEffect)(()=>h(e=>{r(e)}),[]);let i=(0,F.useCallback)(e=>{c(e),r(d())},[]),a=(0,F.useCallback)(()=>{i(t===`en`?`zh`:`en`)},[t,i]),o=(0,F.useMemo)(()=>({language:t,setLanguage:i,toggleLanguage:a}),[t,i,a]);return(0,I.jsx)(jo.Provider,{value:o,children:e})}function No(){let e=(0,F.useContext)(jo);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function Po(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function Fo(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:Po(e),width:e}}var Io=m(()=>Fo()),Lo=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>Io.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Io.setState(Fo())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Io.setState({width:e,mode:Po(e)})}}};function Ro(){return(0,F.useEffect)(()=>Lo.attach(),[]),{isMobile:Io(e=>e.mode)===`mobile`}}var zo=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Bo=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}zo.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();zo.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){zo.setState({supported:!0,initialized:!0,busyAction:null}),A.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{zo.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));zo.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return zo.setState({supported:!0,initialized:!0,snapshot:n}),A.success(s(`runtimePresenceSaved`)),n}catch(e){throw A.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{zo.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Vo=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){Vo.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Vo.setState({supported:!0,initialized:!0,snapshot:e})}),Vo.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Vo.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Vo.setState({supported:!0,initialized:!0}),A.error(`${s(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,s(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){A.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){A.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){A.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&A.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,s(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&A.success(s(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,s(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,s(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(Vo.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,s(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){A.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}A.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Vo.setState({busyAction:e});try{let e=await n(r);return Vo.setState({snapshot:e}),e}catch(e){throw A.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Vo.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`),this.getChannelLabel=e=>s(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function Ho(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Uo(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function Wo(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Go(e){return[{target:`/chat`,label:e(`chat`),icon:$n},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:ht},{target:`/agents`,label:e(`agentsPageTitle`),icon:vn},{target:`/settings`,label:e(`settings`),icon:dr}]}function Ko(e){return[{target:`/model`,label:e(`model`),icon:Dn},{target:`/providers`,label:e(`providers`),icon:gr},{target:`/channels`,label:e(`channels`),icon:tr},{target:`/search`,label:e(`searchChannels`),icon:Zt},{target:`/runtime`,label:e(`runtime`),icon:Dn},{target:`/updates`,label:e(`updates`),icon:On},{target:`/remote`,label:e(`remote`),icon:wr},{target:`/security`,label:e(`security`),icon:mr},{target:`/secrets`,label:e(`secrets`),icon:Jn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:en}]}function qo(e){return[{target:`/language`,label:e(`language`),icon:Yn},...Ko(e)]}function Jo(e){let t=e.toLowerCase();return t===`/settings`?!0:qo(e=>e).some(e=>Ho(t,e.target))}function Yo(e,t){let n=e.toLowerCase(),r=qo(t);if(Wo(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(Ho(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var Xo=`nextclaw.ui.theme`,Zo=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Qo=`warm`,$o=!1,es=new Set;function ts(e){return e===`warm`||e===`cool`}function ns(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function rs(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Xo);if(ts(e))return e}catch{}return`warm`}function is(){return $o||=(Qo=rs(),ns(Qo),!0),Qo}function as(){return $o?Qo:is()}function os(e){if(is(),e!==Qo){if(Qo=e,ns(Qo),typeof window<`u`)try{window.localStorage.setItem(Xo,Qo)}catch{}es.forEach(e=>e(Qo))}}function ss(e){return es.add(e),()=>{es.delete(e)}}function cs(){return at({queryKey:[`config`],queryFn:te,staleTime:3e4,refetchOnWindowFocus:!0})}function ls(){return at({queryKey:[`app-meta`],queryFn:ee,staleTime:1/0})}function us(){return at({queryKey:[`config-meta`],queryFn:ce,staleTime:1/0})}function ds(){return at({queryKey:[`config-schema`],queryFn:it,staleTime:1/0})}function fs(){let e=ge();return le({mutationFn:_e,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ps(){let e=ge();return le({mutationFn:({data:e})=>se(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ms(){let e=ge();return le({mutationFn:({provider:e,data:t})=>he(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function hs(){let e=ge();return le({mutationFn:({data:e})=>ne(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function gs(){let e=ge();return le({mutationFn:({provider:e})=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSaved`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function _s(){return le({mutationFn:({provider:e,data:t})=>We(e,t)})}function vs(){return le({mutationFn:({provider:e,data:t})=>k(e,t)})}function ys(){return le({mutationFn:({provider:e,data:t})=>fe(e,t)})}function bs(){return le({mutationFn:({provider:e})=>E(e)})}function xs(){let e=ge();return le({mutationFn:({channel:e,data:t})=>O(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),A.success(s(`configSavedApplying`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function Ss(){let e=ge();return le({mutationFn:({data:e})=>ye(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function Cs(){let e=ge();return le({mutationFn:({data:e})=>_(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ws(){return le({mutationFn:({actionId:e,data:t})=>C(e,t),onError:e=>{A.error(s(`error`)+`: `+e.message)}})}function Ts(e){return at({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>be(e),staleTime:5e3,retry:!1})}function Es(e){return at({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>Oe(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ds(e={all:!0}){return at({queryKey:[`cron`,e],queryFn:()=>y(e),staleTime:1e4})}function Os(){let e=ge();return le({mutationFn:({id:e})=>re(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function ks(){let e=ge();return le({mutationFn:({id:e,enabled:t})=>T(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function As(){let e=ge();return le({mutationFn:({id:e,force:t})=>me(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}var js={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function Ms(){let e=ke(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=async()=>{if(t)try{let e=await rt.runRuntimeControlAction(`restart-service`);A.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);A.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(Ai,{children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,js[e.tone])})})}),(0,I.jsxs)(Mi,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,I.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,I.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s(`runtimeStatusActionHint`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?s(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function Ns({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=ls(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(Ms,{}),l=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,u=t===`chrome`;return(0,I.jsxs)(`div`,{className:r(e??`flex min-w-0 items-center gap-2`,l&&`pl-[58px]`),children:[(0,I.jsx)(`div`,{className:r(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,I.jsx)(`img`,{src:`/logo.svg`,alt:a,className:`h-full w-full object-contain`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:r(`shrink-0 font-semibold text-gray-800`,u?`text-[15px]`:`text-[14px]`),children:a}),s?(0,I.jsx)(Ps,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Fs,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Ps({versionLabel:e,density:t}){let[n,i]=(0,F.useState)(!1);return(0,I.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[(0,I.jsx)(`span`,{tabIndex:0,"aria-label":e,className:r(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,I.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function Fs(){let{supported:e,busyAction:t,snapshot:n}=Re();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Is,{snapshot:n}):n.status===`downloaded`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void Ue.applyDownloadedUpdate(),children:s(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void Ue.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Is({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Ls,{snapshot:e});let t=e.status===`downloading`?Rs(e):null;return t?(0,I.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:s(`updates`),children:t}):null}function Ls({snapshot:e}){let t=e.status===`failed`?s(`desktopUpdatesStatusFailed`):s(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?s(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
3
+ `);return(0,I.jsx)(`span`,{role:`img`,"aria-label":t,title:i,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function Rs(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var zs=g(Ve(),1);function Bs(e,[t,n]){return Math.min(n,Math.max(t,e))}function Vs(e){let t=e+`CollectionProvider`,[n,r]=yt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Et(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:vt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Et(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=vt(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Hs=F.createContext(void 0);function Us(e){let t=F.useContext(Hs);return e||t||`ltr`}function Ws(e){let t=F.useRef({value:e,previous:e});return F.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Gs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ks=[` `,`Enter`],qs=`Select`,[Js,Ys,Xs]=Vs(qs),[Zs,Qs]=yt(qs,[Xs,Ft]),$s=Ft(),[ec,tc]=Zs(qs),[nc,rc]=Zs(qs),ic=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=$s(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Us(l),[C,w]=Rt({prop:r,defaultProp:i??!1,onChange:a,caller:qs}),[T,E]=Rt({prop:o,defaultProp:s,onChange:c,caller:qs}),ee=F.useRef(null),D=g?m||!!g.closest(`form`):!0,[O,k]=F.useState(new Set),te=Array.from(O).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)(ec,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Bt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:ee,disabled:f,children:[(0,I.jsx)(Js.Provider,{scope:t,children:(0,I.jsx)(nc,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{k(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{k(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),D?(0,I.jsxs)($c,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,I.jsx)(`option`,{value:``}):null,Array.from(O)]},te):null]})})};ic.displayName=qs;var ac=`SelectTrigger`,oc=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=$s(n),o=tc(ac,n),s=o.disabled||r,c=vt(t,o.onTriggerChange),l=Ys(n),u=F.useRef(`touch`),[d,f,p]=tl(e=>{let t=l().filter(e=>!e.disabled),n=nl(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,I.jsx)(Pt,{asChild:!0,...a,children:(0,I.jsx)(Dt.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":el(o.value)?``:void 0,...i,ref:c,onClick:zt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:zt(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:zt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Gs.includes(e.key)&&(m(),e.preventDefault())})})})});oc.displayName=ac;var sc=`SelectValue`,cc=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=tc(sc,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=vt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Dt.span,{...s,ref:d,style:{pointerEvents:`none`},children:el(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});cc.displayName=sc;var lc=`SelectIcon`,uc=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Dt.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});uc.displayName=lc;var dc=`SelectPortal`,fc=e=>(0,I.jsx)(wt,{asChild:!0,...e});fc.displayName=dc;var pc=`SelectContent`,mc=F.forwardRef((e,t)=>{let n=tc(pc,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?zs.createPortal((0,I.jsx)(gc,{scope:e.__scopeSelect,children:(0,I.jsx)(Js.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(bc,{...e,ref:t})});mc.displayName=pc;var hc=10,[gc,_c]=Zs(pc),vc=`SelectContentImpl`,yc=Et(`SelectContent.RemoveScroll`),bc=F.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=tc(pc,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=vt(t,e=>b(e)),[w,T]=F.useState(null),[E,ee]=F.useState(null),D=Ys(n),[O,k]=F.useState(!1),te=F.useRef(!1);F.useEffect(()=>{if(y)return Ct(y)},[y]),Lt();let A=F.useCallback(e=>{let[t,...n]=D().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[D,x]),ne=F.useCallback(()=>A([w,y]),[A,w,y]);F.useEffect(()=>{O&&ne()},[O,ne]);let{onOpenChange:j,triggerPointerDownPosRef:re}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(re.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(re.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||j(!1),document.removeEventListener(`pointermove`,t),re.current=null};return re.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,j,re]),F.useEffect(()=>{let e=()=>j(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[j]);let[M,ie]=tl(e=>{let t=D().filter(e=>!e.disabled),n=nl(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!te.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(te.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!te.current&&!n;(v.value!==void 0&&v.value===t||r)&&ee(e)},[v.value]),ce=r===`popper`?wc:Sc,le=ce===wc?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(gc,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:ne,selectedItemText:E,position:r,isPositioned:O,searchRef:M,children:(0,I.jsx)(kt,{as:yc,allowPinchZoom:!0,children:(0,I.jsx)(Tt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:zt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(Nt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,I.jsx)(ce,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...le,onPlaced:()=>k(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:zt(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ie(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=D().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>A(t)),e.preventDefault()}})})})})})})});bc.displayName=vc;var xc=`SelectItemAlignedPosition`,Sc=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=tc(pc,n),o=_c(pc,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=vt(t,e=>u(e)),f=Ys(n),p=F.useRef(!1),m=F.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=F.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-hc,d=Bs(a,[hc,Math.max(hc,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-hc,d=Bs(a,[hc,Math.max(hc,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-hc*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-hc,ee=c-E,D=g.offsetHeight/2,O=g.offsetTop+D,k=m+v+O,te=x-k;if(k<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+D)+te;s.style.height=t+`px`,h.scrollTop=k-E+h.offsetTop}s.style.margin=`${hc}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);St(()=>y(),[y]);let[b,x]=F.useState();return St(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,I.jsx)(Tc,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:F.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,I.jsx)(Dt.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Sc.displayName=xc;var Cc=`SelectPopperPosition`,wc=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=hc,...a}=e,o=$s(n);return(0,I.jsx)(xt,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});wc.displayName=Cc;var[Tc,Ec]=Zs(pc,{}),Dc=`SelectViewport`,Oc=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=_c(Dc,n),o=Ec(Dc,n),s=vt(t,a.onViewportChange),c=F.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(Js.Slot,{scope:n,children:(0,I.jsx)(Dt.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:zt(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-hc*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Oc.displayName=Dc;var kc=`SelectGroup`,[Ac,jc]=Zs(kc),Mc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Bt();return(0,I.jsx)(Ac,{scope:n,id:i,children:(0,I.jsx)(Dt.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Mc.displayName=kc;var Nc=`SelectLabel`,Pc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=jc(Nc,n);return(0,I.jsx)(Dt.div,{id:i.id,...r,ref:t})});Pc.displayName=Nc;var Fc=`SelectItem`,[Ic,Lc]=Zs(Fc),Rc=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=tc(Fc,n),c=_c(Fc,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=vt(t,e=>c.itemRefCallback?.(e,r,i)),h=Bt(),g=F.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,I.jsx)(Ic,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(Js.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Dt.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:zt(o.onFocus,()=>p(!0)),onBlur:zt(o.onBlur,()=>p(!1)),onClick:zt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:zt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:zt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:zt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:zt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:zt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Ks.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Rc.displayName=Fc;var zc=`SelectItemText`,Bc=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=tc(zc,n),s=_c(zc,n),c=Lc(zc,n),l=rc(zc,n),[u,d]=F.useState(null),f=vt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=F.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return St(()=>(h(m),()=>g(m)),[h,g,m]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Dt.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?zs.createPortal(a.children,o.valueNode):null]})});Bc.displayName=zc;var Vc=`SelectItemIndicator`,Hc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Lc(Vc,n).isSelected?(0,I.jsx)(Dt.span,{"aria-hidden":!0,...r,ref:t}):null});Hc.displayName=Vc;var Uc=`SelectScrollUpButton`,Wc=F.forwardRef((e,t)=>{let n=_c(Uc,e.__scopeSelect),r=Ec(Uc,e.__scopeSelect),[i,a]=F.useState(!1),o=vt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(qc,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Wc.displayName=Uc;var Gc=`SelectScrollDownButton`,Kc=F.forwardRef((e,t)=>{let n=_c(Gc,e.__scopeSelect),r=Ec(Gc,e.__scopeSelect),[i,a]=F.useState(!1),o=vt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(qc,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Kc.displayName=Gc;var qc=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=_c(`SelectScrollButton`,n),o=F.useRef(null),s=Ys(n),c=F.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return F.useEffect(()=>()=>c(),[c]),St(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(Dt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:zt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:zt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:zt(i.onPointerLeave,()=>{c()})})}),Jc=`SelectSeparator`,Yc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Dt.div,{"aria-hidden":!0,...r,ref:t})});Yc.displayName=Jc;var Xc=`SelectArrow`,Zc=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=$s(n),a=tc(Xc,n),o=_c(Xc,n);return a.open&&o.position===`popper`?(0,I.jsx)(Ot,{...i,...r,ref:t}):null});Zc.displayName=Xc;var Qc=`SelectBubbleInput`,$c=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=vt(r,i),o=Ws(t);return F.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,I.jsx)(Dt.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});$c.displayName=Qc;function el(e){return e===``||e===void 0}function tl(e){let t=At(e),n=F.useRef(``),r=F.useRef(0),i=F.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=F.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return F.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function nl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=rl(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function rl(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var il=ic,al=oc,ol=cc,sl=uc,cl=fc,ll=mc,ul=Oc,dl=Mc,fl=Pc,pl=Rc,ml=Bc,hl=Hc,gl=Wc,_l=Kc,vl=Yc,yl=il,bl=ol,xl=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(al,{ref:a,className:r(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 bg-white`,e),...i,children:[t,(0,I.jsx)(sl,{asChild:!0,children:n??(0,I.jsx)(xn,{className:`h-4 w-4 opacity-50`})})]}));xl.displayName=al.displayName;var Sl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(gl,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Cn,{className:`h-4 w-4`})}));Sl.displayName=gl.displayName;var Cl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_l,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(xn,{className:`h-4 w-4`})}));Cl.displayName=_l.displayName;var wl=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(cl,{children:(0,I.jsxs)(ll,{ref:o,className:r(`relative z-[var(--z-popover,50)] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 bg-white`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...a,children:[(0,I.jsx)(Sl,{}),(0,I.jsx)(ul,{className:r(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,i),children:t}),(0,I.jsx)(Cl,{})]})}));wl.displayName=ll.displayName;var Tl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fl,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));Tl.displayName=fl.displayName;var El=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(pl,{ref:i,className:r(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(hl,{children:(0,I.jsx)(bn,{className:`h-4 w-4`})})}),(0,I.jsx)(ml,{children:t})]}));El.displayName=pl.displayName;var Dl=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vl,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Dl.displayName=vl.displayName;var Ol={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function kl(e){return Ol[e]}function Al({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=kl(i);return(0,I.jsx)(gt,{to:e,className:({isActive:e})=>r(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:r(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function jl({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=kl(i);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:r(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,I.jsx)(t,{className:r(d.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:r(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,I.jsx)(`span`,{className:r(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function Ml({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=kl(o);return(0,I.jsxs)(yl,{value:n,onValueChange:a,children:[(0,I.jsxs)(xl,{className:r(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,I.jsxs)(`div`,{className:r(`flex min-w-0 items-center`,c.gap),children:[(0,I.jsx)(t,{className:r(c.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:r(`ml-auto text-gray-500`,c.value),children:i})]}),(0,I.jsx)(wl,{children:s})]})}var Nl=`nextclaw-pwa-install-banner-dismissed`,Pl=`nextclaw-pwa-install-banner-dismissed-until`;function Fl(){let e=Rl();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:zl(e):!1}function Il(){let e=Rl();e?.setItem(Nl,`1`),e?.removeItem(Pl)}function Ll(){let e=Rl();e?.removeItem(Nl),e?.removeItem(Pl)}function Rl(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function zl(e){let t=e.getItem(Pl);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Pl),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Nl,`1`),!0)}function Bl(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Fl(),updateAvailable:!1,registrationFailed:!1}}var Vl=m(()=>Bl()),Hl=`nextclaw-pwa-dev-sw-reset`,Ul=new class{constructor(){this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{let e=await navigator.serviceWorker.register(`/sw.js`);this.registration=e,this.bindRegistration(e),navigator.serviceWorker.addEventListener(`controllerchange`,this.handleControllerChange),await this.syncUpdateAvailability()}catch{Vl.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){Vl.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;Vl.setState({updateAvailable:this.shouldSurfaceUpdate(e)})},this.applyUpdate=async()=>{let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;if(!e){window.location.reload();return}e.waiting||await e.update();let t=e.waiting;if(!t){window.location.reload();return}this.reloadWhenControllerChanges=!0,t.postMessage({type:`SKIP_WAIT`})},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(navigator.serviceWorker.removeEventListener(`controllerchange`,this.handleControllerChange),this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1)},this.bindRegistration=e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&this.syncUpdateAvailability()})})},this.handleControllerChange=()=>{this.reloadWhenControllerChanges&&(this.reloadWhenControllerChanges=!1,window.location.reload())},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.shouldSurfaceUpdate=e=>!e?.waiting||!navigator.serviceWorker.controller?!1:Vl.getState().installability===`installed`,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));if(e.length===0){this.clearDevResetMarker();return}if(await Promise.all(e.map(async e=>await e.unregister())),await this.clearNextClawCaches(),navigator.serviceWorker.controller&&!this.hasDevResetMarker()){this.setDevResetMarker(),window.location.reload();return}this.clearDevResetMarker()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))},this.hasDevResetMarker=()=>{try{return window.sessionStorage.getItem(Hl)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(Hl,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(Hl)}catch{}}}},Wl=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),Vl.setState(Bl())},this.refreshState=()=>{let e=this.resolveInstallability();Vl.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Fl()})),Ul.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Il(),Vl.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(Ll(),this.refreshState(),A.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Ll(),Vl.setState({dismissedInstallPrompt:!0}),A.success(s(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function Gl(){let e=Vl(e=>e.installability);return(0,I.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Kl(e)})}function Kl(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function ql(e,t,n){return s(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function Jl(){let e=Vl(e=>e.installability),t=Vl(e=>e.installMethod),n=Vl(e=>e.blockedReason);return(0,I.jsxs)(et,{children:[(0,I.jsxs)(x,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(ie,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(S,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Gl,{})]}),(0,I.jsxs)(de,{className:`space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:ql(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(M,{type:`button`,className:`gap-2`,onClick:()=>{Wl.promptInstall()},children:[(0,I.jsx)(On,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:s(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,I.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,I.jsx)(hr,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallManualHint`)})]}):null]})]})}function Yl(){let e=Vl(e=>e.installability),t=Vl(e=>e.installMethod),n=Vl(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,I.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":s(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Wl.dismissInstallPrompt()},children:(0,I.jsx)(rn,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(M,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Wl.promptInstall()},children:[(0,I.jsx)(On,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Wl.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}function Xl(){let e=Vl(e=>e.updateAvailable),t=Vl(e=>e.installability);return!e||t!==`installed`?null:(0,I.jsxs)(`div`,{className:`fixed top-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaUpdateBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaUpdateBannerDescription`)})]})}),(0,I.jsx)(`div`,{className:`mt-4`,children:(0,I.jsxs)(M,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Ul.applyUpdate()},children:[(0,I.jsx)(cr,{className:`h-4 w-4`}),s(`pwaUpdateAction`)]})})]})}var Zl=!1;function Ql(){Zl||typeof window>`u`||(Zl=!0,Wl.start(),Ul.start())}var $l={warm:`#F9F8F5`,cool:`#F8FAFB`},eu=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=$l[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},tu=(0,F.createContext)(null);function nu({children:e}){let[t,n]=(0,F.useState)(()=>is());(0,F.useEffect)(()=>{eu.syncTheme(t)},[t]),(0,F.useEffect)(()=>ss(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{os(e),n(as())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(tu.Provider,{value:i,children:e})}function ru(){let e=(0,F.useContext)(tu);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function iu(){let{language:e,setLanguage:n}=No();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,F.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}function au(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=iu();return(0,I.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(Yn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:s(`language`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,I.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(t.value),className:r(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,I.jsx)(bn,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function ou({mode:e}){let t=ko(),n=un(),i=Or(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=iu(),{theme:u,setTheme:d}=ru(),f=e===`settings`,p=s(Zo.find(e=>e.value===u)?.labelKey??`themeWarm`),m=i.data?.account.email?.trim(),h=!!i.data?.account.loggedIn,g=e=>{u!==e&&d(e)},_=[{target:`/chat`,label:s(`chat`),icon:$n},{target:`/chat/cron`,label:s(`cron`),icon:mn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:ht},{target:`/agents`,label:s(`agentsPageTitle`),icon:vn}],v=Ko(s),y=f?v:_,b=f?`compact`:`default`;return(0,I.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 pb-6`,children:[f?(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,I.jsxs)(gt,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:s(`backToMain`)})]}),(0,I.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,I.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:s(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(Ns,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,I.jsx)(`ul`,{className:r(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Al,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:r(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,I.jsx)(jl,{onClick:()=>t.accountManager.openAccountPanel(),icon:Jn,label:s(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:h?m||s(`remoteAccountEntryConnected`):s(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Al,{to:`/settings`,label:s(`settings`),icon:dr})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Ml,{value:u,onValueChange:e=>g(e),icon:rr,label:s(`theme`),valueLabel:p,density:b,children:Zo.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Ml,{value:a,onValueChange:e=>l(e),icon:Yn,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(jl,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var su=[{action:`minimize`,label:`Minimize`,icon:nr},{action:`close`,label:`Close`,icon:rn,variant:`danger`}];function cu(){let e=uu()?{action:`toggle-maximize`,label:`Restore`,icon:En}:{action:`toggle-maximize`,label:`Maximize`,icon:vr};return(0,I.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 bg-secondary after:absolute after:bottom-0 after:left-[var(--desktop-sidebar-width)] after:right-0 after:border-b after:border-[#ebe7dc]/80`,"data-testid":`desktop-window-chrome`,children:[(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,I.jsx)(`div`,{className:`desktop-window-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary pl-4 pr-3 text-secondary-foreground`,"data-testid":`desktop-window-chrome-sidebar`,children:(0,I.jsx)(Ns,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:[su[0],e,su[1]].map(e=>(0,I.jsx)(lu,{control:e},e.action))})]})}function lu({control:e}){let t=e.icon;return(0,I.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,I.jsx)(t,{className:`h-3.5 w-3.5`})})}function uu(){let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{let e=!0,n=window.nextclawDesktop;n?.getWindowState?.().then(n=>{e&&t(n.isMaximized)});let r=n?.onWindowStateChanged?.(e=>{t(e.isMaximized)});return()=>{e=!1,r?.()}},[]),e}function du(){return typeof window>`u`?null:pu()??window.nextclawDesktop?.platform??null}function fu(){return du()===`win32`}function pu(){return null}function mu(e,t){if(t===`/settings`)return Jo(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function hu(){let{pathname:e}=ct(),t=Go(s);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":s(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,I.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=mu(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(ot,{to:t.target,"aria-current":n?`page`:void 0,className:r(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,I.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:r(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,I.jsx)(t.icon,{className:r(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,I.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function gu({leadingInset:e}){let t=lt(),{pathname:n}=ct(),r=Yo(n,s);return(0,I.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,I.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 py-1.5 pl-3 pr-3`,style:{paddingLeft:e?`calc(${e} + 0.75rem)`:void 0},children:[r.backTarget?(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(r.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":r.backLabel??s(`backToMain`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:r.title})}),r.backTarget?(0,I.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var _u=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yTfN7UBH.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function vu({pathname:e,isDocBrowserOpen:t,docBrowserRenderers:n={},topbarLeadingInset:r,children:i}){let a=Uo(e),o=!Wo(e),s=!Wo(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[o?(0,I.jsx)(gu,{leadingInset:r}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:a?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:i}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:i})})}),s?(0,I.jsx)(hu,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(_u,{customTabRenderers:n,displayMode:`fullscreen`})}):null]})}function yu(){let e=qo(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(gt,{to:e.target,className:({isActive:e})=>r(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(e.icon,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function bu({isProjectFirstView:e,onSelectMode:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:r(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:s(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:r(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:s(`chatSidebarViewProject`)})]})}var xu={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,email:`email.svg`};function Su(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function Cu(e){return Su(xu,e)}var wu={wx:`weixin`,lark:`feishu`},Tu={cron:{icon:`cron`}},Eu={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Du(e){return e?.trim().toLowerCase()??``}function Ou(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function ku(e,t){let n=Du(e);if(!n||n===`native`)return null;let r=t.find(e=>Du(e.value)===n);return r?.label.trim()?r.label.trim():Ou(n)}function Au(e,t){let n=Du(e);return!n||n===`native`?null:t.find(e=>Du(e.value)===n)??null}function ju(e){let t=Du(e);if(!t)return null;let n=wu[t]??t;return Cu(n)?n:null}function Mu(e,t){let n=ju(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Tu[Du(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Du(e.sessionType),a=Au(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=Eu[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||ku(e.sessionType,t)}}var Nu=`app://`;function Pu(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Fu(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Nu))return t;let n=Pu(t.slice(6));return n?`/${n}`:null}function Iu({name:e,src:t,className:n,imgClassName:i,fallback:a}){let[o,s]=(0,F.useState)(!1),c=!!t&&!o;return(0,I.jsx)(`div`,{className:r(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:c?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:r(`block h-6 w-6 object-contain`,i),onError:()=>s(!0),draggable:!1}):a??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Lu({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Ru,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Fu(e.src);return(0,I.jsx)(Iu,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(vn,{className:r(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(mn,{className:r(`h-3.5 w-3.5`,t)})}function Ru({channel:e,className:t}){return(0,I.jsx)(Iu,{name:e,src:Cu(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(vn,{className:`h-3 w-3 text-gray-500`})})}function zu(e){let{option:t,onSelect:n}=e,i=t.ready===!1?t.reasonMessage?.trim()||s(`statusSetup`):null;return(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,I.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,I.jsx)(Lu,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,I.jsx)(vn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,I.jsxs)(`span`,{className:r(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?s(`statusSetup`):s(`statusReady`)]})]}),i?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:i}):null]})]})})})}function Bu(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Vu(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Bu(n,r),[n,r]),u=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${s(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,I.jsxs)(Ai,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,I.jsx)(nn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(zu,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(nn,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var Hu=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Uu(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Wu({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=Hu[Uu(e)%Hu.length]??Hu[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:r(`rounded-full object-cover`,i)}):(0,I.jsx)(`div`,{className:r(`rounded-full flex items-center justify-center font-semibold`,o,s,i),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(vn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Gu({status:e,className:t}){let n=s(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:r(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,I.jsx)(Zn,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ku(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function qu(e){let t=e.activityPreview;return t?t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null:null}function Ju(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Yu(e,t){return e.getFullYear()===t.getFullYear()}function Xu(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Yu(e,t)?n:`${e.getFullYear()}年${n}`}function Zu(e,t=d(),n=new Date){if(!e)return`-`;let r=e instanceof Date?e:new Date(e);if(Number.isNaN(r.getTime()))return typeof e==`string`?e:`-`;let i=p(t),a=Ju(r),o=Ju(n),c=Math.floor((o-a)/864e5);if(c===0)return new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r);if(c===1)return s(`chatSidebarYesterday`,t);if(c>1&&c<7)return new Intl.DateTimeFormat(i,{weekday:`long`}).format(r);if(t===`zh`)return Xu(r,n);let l=Yu(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Qu(e){return e.trim().toLowerCase()}function $u(e,t){let n=Qu(t);return n?[e.key,Ku(e),e.projectRoot??``,e.projectName??``].map(Qu).some(e=>e.includes(n)):!0}function ed({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(j,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:s(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(M,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":s(`save`),children:(0,I.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(M,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":s(`cancel`),children:(0,I.jsx)(rn,{className:`h-3.5 w-3.5`})})]})]})]})}function td({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:c,agentLabel:l,agentAvatarUrl:u,childSessionCount:d=0,onSelect:f,onOpenChildSessions:p,onStartEditing:m}){let h=d>0&&p?`pr-14`:`pr-6`,g=qu(e),_=`${l?.trim()?`${l} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:r(`flex min-w-0 items-start`,h),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.trim()&&c.trim().toLowerCase()!==`main`?(0,I.jsx)(Wu,{agentId:c,displayName:l,avatarUrl:u,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:o}),a.label?(0,I.jsx)(`span`,{className:r(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:a.label}):null,a.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)(Lu,{icon:a.icon,className:t?`text-gray-700`:`text-gray-500`})}):null]})}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:g??_}),n?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:Zu(e.lastMessageAt??e.createdAt)})]})]}),d>0&&p?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:r(`absolute right-6 top-0 inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(Gn,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:d})]}):null,i?(0,I.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,I.jsx)(Gu,{status:i})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:r(`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-md text-gray-400 transition-all hover:bg-white hover:text-gray-900`,`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`edit`),children:(0,I.jsx)(ar,{className:`h-3 w-3`})})]})}function nd({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,childSessionCount:u,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:r(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,I.jsx)(ed,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(td,{session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,onSelect:m,childSessionCount:u,onOpenChildSessions:h,onStartEditing:g})})}var rd=[{icon:$n,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:ht,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:mn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function id({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(vn,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:s(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:s(`chatWelcomeSubtitle`)}),(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:s(`chatDraftAgentTitle`)}),(0,I.jsxs)(yl,{value:n,onValueChange:r,children:[(0,I.jsxs)(xl,{"aria-label":s(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:s(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(Wu,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(wl,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(El,{value:e.id,className:`rounded-lg pr-10`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(Wu,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:rd.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:s(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:s(t.descKey)})]},t.titleKey)})})]})})}var ad=(0,F.createContext)(null);function od({presenter:e,children:t}){return(0,I.jsx)(ad.Provider,{value:e,children:t})}function sd(){let e=(0,F.useContext)(ad);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var cd=e=>`[data-item-index="${e}"]`;function ld(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??cd;(0,F.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function ud(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function L(...e){return i(f(e))}var dd=F.forwardRef(({className:e,type:t,...n},r)=>(0,I.jsx)(`input`,{type:t,className:L(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));dd.displayName=`ChatInput`;var fd=Ti,pd=Di,md=Ei,hd=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(Oi,{children:(0,I.jsx)(ki,{ref:i,sideOffset:t,align:n,className:L(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...r})}));hd.displayName=ki.displayName;var gd=il,_d=dl,vd=ol,yd=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(al,{ref:r,className:L(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,I.jsx)(sl,{asChild:!0,children:(0,I.jsx)(xn,{className:`h-4 w-4 opacity-50`})})]}));yd.displayName=al.displayName;var bd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(gl,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Cn,{className:`h-4 w-4`})}));bd.displayName=gl.displayName;var xd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_l,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(xn,{className:`h-4 w-4`})}));xd.displayName=_l.displayName;var Sd=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(cl,{children:(0,I.jsxs)(ll,{ref:i,className:L(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,I.jsx)(bd,{}),(0,I.jsx)(ul,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,I.jsx)(xd,{})]})}));Sd.displayName=ll.displayName;var Cd=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fl,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Cd.displayName=fl.displayName;var wd=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(pl,{ref:r,className:L(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(hl,{children:(0,I.jsx)(bn,{className:`h-4 w-4`})})}),(0,I.jsx)(ml,{children:t})]}));wd.displayName=pl.displayName;var Td=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vl,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Td.displayName=vl.displayName;var Ed=Fa,Dd=Ia,Od=La,kd=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Ra,{children:(0,I.jsx)(za,{ref:r,sideOffset:t,className:L(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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`,e),...n})}));kd.displayName=za.displayName;var Ad={Popover:fd,PopoverAnchor:md,PopoverContent:hd,PopoverTrigger:pd,Input:dd,Select:gd,SelectContent:Sd,SelectGroup:_d,SelectItem:wd,SelectLabel:Cd,SelectSeparator:Td,SelectTrigger:yd,SelectValue:vd,Tooltip:Dd,TooltipContent:kd,TooltipProvider:Ed,TooltipTrigger:Od},jd=680,Md=.82,Nd=560;function Pd(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Ad,{elementRef:i,width:a}=ud(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onDetailsPointerDown:h,onSetActiveIndex:g}=e,_=(0,F.useMemo)(()=>{if(a)return Math.min(a>Nd?a*Md:a,jd)},[a]);return ld({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,I.jsxs)(t,{open:s,onOpenChange:m,children:[(0,I.jsx)(n,{asChild:!0,children:(0,I.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,I.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:_?{width:`${_}px`}:void 0,children:(0,I.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,I.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,I.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,I.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>g(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,I.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,I.jsx)(`div`,{className:`min-w-0 p-2.5`,onPointerDown:h,children:d?(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,I.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,I.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,I.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var Fd=oe(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),Id=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Fd({variant:t,size:n,className:e})),ref:i,...r}));Id.displayName=`ChatButton`;var Ld=120;function Rd(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Ld?t:`${t.slice(0,Ld-1)}…`}function zd(){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function Bd({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Ad,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,I.jsx)(r,{delayDuration:0,children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":e.label,title:e.label,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(#9ca3af ${o}deg, #e5e7eb 0deg)`}}),(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-white`})]})}),(0,I.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-gray-800`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-gray-600`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`font-medium text-gray-800`,children:e.value})]},e.label))]})})]})})}function Vd({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=Ad,y=e?.trim()??``,b=y?Rd(y):``,x=t?.trim()||`Details`;return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,I.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,I.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,I.jsxs)(f,{children:[(0,I.jsx)(m,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,I.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,I.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,I.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,I.jsx)(Bd,{contextWindow:l}):null,n?r?(0,I.jsx)(Id,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(zd,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Id,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(zd,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Id,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(_n,{className:`h-5 w-5`})})]})]})}function Hd(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Ud(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Ad,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,F.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,F.useMemo)(()=>h?h.flatMap(e=>e.options):Hd(a.options,c),[h,a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),ld({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,I.jsxs)(n,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,I.jsx)(ht,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Zt,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,I.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,I.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,I.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,I.jsxs)(`div`,{children:[e.label?(0,I.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,I.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,I.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,I.jsx)(or,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,I.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,I.jsx)(bn,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,I.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,I.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,I.jsx)(tn,{className:`h-3 w-3`})]})}):null]})]})}function Wd({icon:e}){return e===`sparkles`?(0,I.jsx)(gr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(yn,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Gd({icon:e}){return e===`paperclip`?(0,I.jsx)(ir,{className:`h-4 w-4`}):(0,I.jsx)(Wd,{icon:e})}var Kd={model:`min-w-0 flex-1 sm:min-w-[220px] sm:flex-none`,"session-type":`shrink-0`,thinking:`shrink-0`},qd={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Jd(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Yd({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Ad,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0),d=Jd(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${Kd[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Wd,{icon:e.icon}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700 sm:hidden`,children:d}),(0,I.jsx)(`span`,{className:`hidden truncate text-xs font-semibold text-gray-700 sm:inline`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:qd[e.key]??``,children:[u?null:e.loading?(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,I.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,I.jsxs)(`div`,{children:[t>0?(0,I.jsx)(o,{}):null,(0,I.jsxs)(r,{children:[e.label?(0,I.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,I.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,I.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function Xd({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Ad;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Ud,{picker:r}):null,n.map(e=>(0,I.jsx)(Yd,{item:e},e.key)),t?.map(e=>{let t=(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,I.jsx)(Gd,{icon:e.icon}),e.iconOnly?null:(0,I.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,I.jsx)(o,{children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:e.disabled?(0,I.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,I.jsx)(a,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,I.jsx)(`div`,{children:t},e.key)})]}),(0,I.jsx)(Vd,{...e})]})}var Zd=(0,F.createContext)(null);function Qd(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function $d(){let e=(0,F.useContext)(Zd);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function R(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ef(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var tf=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,nf=tf&&`documentMode`in document?document.documentMode:null,rf=tf&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),af=tf&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),of=!(!tf||!(`InputEvent`in window)||nf)&&`getTargetRanges`in new window.InputEvent(`input`),sf=tf&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,cf=tf&&/Android/.test(navigator.userAgent),lf=tf&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!cf,uf=tf&&/^(?=.*Chrome).*/i.test(navigator.userAgent),df=tf&&cf&&uf,ff=tf&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&rf&&!uf,pf=0,mf=1,hf=2,gf=1,_f=2,vf=3,yf=4,bf=5,xf=6,Sf=lf||sf||ff?`\xA0`:`​`,Cf=`
4
4
 
5
5
  `,wf=af?`\xA0`:Sf,Tf={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Ef={directionless:1,unmergeable:2},Df={center:2,end:6,justify:4,left:1,right:3,start:5},Of={[_f]:`center`,[xf]:`end`,[yf]:`justify`,[gf]:`left`,[vf]:`right`,[bf]:`start`},kf={normal:0,segmented:2,token:1},Af={[pf]:`normal`,[hf]:`segmented`,[mf]:`token`},jf=`$config`;function Mf(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(U(o)&&Mf(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var Nf=!1,Pf=0;function Ff(e){Pf=e.timeStamp}function If(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&N_(e,n)!==void 0}function Lf(e,t,n){let r=Sv(mv(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&K_(t,o,i,a,!1)}function Rf(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return S_(t)&&n.isAttached()}function zf(e,t,n,r){for(let i=e;i&&!Lv(i);i=cv(i)){let e=N_(i,t);if(e!==void 0){let t=j_(e,n);if(t)return Ug(t)||!wv(i)?void 0:[i,t]}else if(i===r)return[r,R_(n)]}}function Bf(e,t,n){Nf=!0;let r=performance.now()-Pf>100;try{Lg(e,()=>{let i=H()||function(e){return e.getEditorState().read(()=>{let e=H();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=zf(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&B(g)&&S_(p)&&Rf(i,p,g)&&Lf(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=M_(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!If(r,a,e)){if(af){let e=(wv(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(If(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||If(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&z_(i),af&&ov(e)&&i.insertRawText(u))})}finally{Nf=!1}}function Vf(e){let t=e._observer;t!==null&&Bf(e,t.takeRecords(),t)}function Hf(e){(function(e){Pf===0&&mv(e).addEventListener(`textInput`,Ff,!0)})(e),e._observer=new MutationObserver((t,n)=>{Bf(e,t,n)})}var Uf=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Xf).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Wf(e,t){return new Uf(e,t)}function Gf(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=zv(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var Kf=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Yf(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Yf(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function qf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Kf(t,Jf(t));return t.__state=n,n}function Jf(e){return e.__state?e.__state.sharedNodeState:d_(Av(),e.getType()).sharedNodeState}function Yf(e){if(e)for(let t in e)return e}function Xf(e){return e}function Zf(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Qf(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function $f(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function ep(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&Zf(n,e,t)||t&&Zf(n,t,e)||e&&Qf(n,e,t)||t&&Qf(n,t,e))}(c,l))}function tp(e,t){let n=e.mergeWithSibling(t),r=wg()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function np(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&B(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(ep(t,r)){r=tp(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(ep(r,n)){r=tp(r,n);break}break}n.remove()}}else r.remove()}function rp(e){return ip(e.anchor),ip(e.focus),e}function ip(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),B(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!U(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp=``,gp=null,_p=null,vp=!1,yp=!1;function bp(e,t){let n=dp.get(e);if(t!==null){let n=Rp(e);n.parentNode===t&&t.removeChild(n)}if(fp.has(e)||op._keyToDOMMap.delete(e),U(n)){let e=Mp(n,dp);xp(e,0,e.length-1,null)}n!==void 0&&rv(mp,sp,cp,n,`destroyed`)}function xp(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&bp(t,r)}}function Sp(e,t){e.setProperty(`text-align`,t)}var Cp=`40px`;function wp(e,t){let n=ap.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(op._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||Cp;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function Tp(e,t){let n=e.style;t===0?Sp(n,``):t===1?Sp(n,`left`):t===2?Sp(n,`center`):t===3?Sp(n,`right`):t===4?Sp(n,`justify`):t===5?Sp(n,`start`):t===6&&Sp(n,`end`)}function Ep(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Gg(e))return null;let n=e.getParentOrThrow();return Gg(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Dp(e,t){let n=fp.get(e);n===void 0&&R(60);let r=n.createDOM(ap,op);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,op),B(n)?r.setAttribute(`data-lexical-text`,`true`):Ug(n)&&r.setAttribute(`data-lexical-decorator`,`true`),U(n)){let e=n.__indent,t=n.__size;if(Ep(r,n),e!==0&&wp(r,e),t!==0){let e=t-1;Op(Mp(n,fp),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&Tp(r,i),n.isInline()||Ap(null,n,r)}else{let t=n.getTextContent();if(Ug(n)){let t=n.decorate(op,ap);t!==null&&Pp(e,t),r.contentEditable=`false`}hp+=t}return t!==null&&t.insertChild(r),rv(mp,sp,cp,n,`created`),r}function Op(e,t,n,r,i){let a=hp;hp=``;let o=n;for(;o<=r;++o){Dp(e[o],i);let t=fp.get(e[o]);t!==null&&B(t)?gp===null&&(gp=t.getFormat(),_p=t.getStyle()):U(t)&&o<r&&!t.isInline()&&(hp+=Cf)}i.element.__lexicalTextContent=hp,hp=a+hp}function kp(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return hh(e)?`line-break`:Ug(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function Ap(e,t,n){let r=kp(e,dp),i=kp(t,fp);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function jp(e,t,n){var r;gp=null,_p=null,function(e,t,n){let r=hp,i=e.__size,a=t.__size;hp=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)Np(n,o);else{let e=Rp(n),t=Dp(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}bp(n,null)}let i=fp.get(r);B(i)&&gp===null&&(gp=i.getFormat(),_p=i.getStyle())}else{let r=Mp(e,dp),s=Mp(t,fp);if(r.length!==i&&R(227),s.length!==a&&R(228),i===0)a!==0&&Op(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;xp(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=Fp(Np(r,a.element)),d++,f++;else{if(l===void 0&&(l=Ip(n,f)),c===void 0)c=Ip(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=Fp(Rp(e)),bp(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=sv(op,r);e!==u&&a.withBefore(u).insertChild(e),u=Fp(Np(r,a.element)),d++,f++}else Dp(r,a.withBefore(u)),f++}let i=fp.get(r);i!==null&&B(i)?gp===null&&(gp=i.getFormat(),_p=i.getStyle()):U(i)&&f<=s&&!i.isInline()&&(hp+=Cf)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:op.getElementByKey(e);Op(n,0,f,s,a.withBefore(t))}else m&&!p&&xp(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=hp,hp=r+hp}(e,t,t.getDOMSlot(n)),r=t,gp==null||gp===r.__textFormat||yp||r.setTextFormat(gp),function(e){_p==null||_p===e.__textStyle||yp||e.setTextStyle(_p)}(t)}function Mp(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&R(101),n.push(r),r=e.__next}return n}function Np(e,t){let n=dp.get(e),r=fp.get(e);n!==void 0&&r!==void 0||R(61);let i=vp||up.has(e)||lp.has(e),a=sv(op,e);if(n===r&&!i){let e;if(U(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return hp+=e,a}if(n!==r&&i&&rv(mp,sp,cp,r,`updated`),r.updateDOM(n,a,ap)){let n=Dp(e,null);return t===null&&R(62),t.replaceChild(n,a),bp(e,null),n}if(U(n)){U(r)||R(334,e);let t=r.__indent;(vp||t!==n.__indent)&&wp(a,t);let o=r.__format;if((vp||o!==n.__format)&&Tp(a,o),i)jp(n,r,a),Gg(r)||r.isInline()||Ap(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),hp+=t}if((vp||r.__dir!==n.__dir)&&(Ep(a,r),Gg(r)&&!vp))for(let e of r.getChildren())U(e)&&Ep(sv(op,e.getKey()),e)}else{let t=r.getTextContent();if(Ug(r)){let t=r.decorate(op,ap);t!==null&&Pp(e,t)}hp+=t}if(!yp&&Gg(r)&&r.__cachedText!==hp){let e=r.getWritable();e.__cachedText=hp,r=e}return a}function Pp(e,t){let n=op._pendingDecorators,r=op._decorators;if(n===null){if(r[e]===t)return;n=F_(op)}n[e]=t}function Fp(e){let t=e.nextSibling;return t!==null&&t===op._blockCursorElement&&(t=t.nextSibling),t}function Ip(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Lp(e,t,n,r,i,a){hp=``,vp=r===2,op=n,ap=n._config,sp=n._nodes,cp=op._listeners.mutation,lp=i,up=a,dp=e._nodeMap,fp=t._nodeMap,yp=t._readOnly,pp=new Map(n._keyToDOMMap);let o=new Map;return mp=o,Np(`root`,null),op=void 0,sp=void 0,lp=void 0,up=void 0,dp=void 0,fp=void 0,ap=void 0,pp=void 0,mp=void 0,o}function Rp(e){let t=pp.get(e);return t===void 0&&R(75,e),t}function z(e){return{type:e}}var zp=z(`SELECTION_CHANGE_COMMAND`),Bp=z(`CLICK_COMMAND`),Vp=z(`BEFORE_INPUT_COMMAND`),Hp=z(`INPUT_COMMAND`),Up=z(`COMPOSITION_START_COMMAND`),Wp=z(`COMPOSITION_END_COMMAND`),Gp=z(`DELETE_CHARACTER_COMMAND`),Kp=z(`INSERT_LINE_BREAK_COMMAND`),qp=z(`INSERT_PARAGRAPH_COMMAND`),Jp=z(`CONTROLLED_TEXT_INSERTION_COMMAND`),Yp=z(`PASTE_COMMAND`),Xp=z(`REMOVE_TEXT_COMMAND`),Zp=z(`DELETE_WORD_COMMAND`),Qp=z(`DELETE_LINE_COMMAND`),$p=z(`FORMAT_TEXT_COMMAND`),em=z(`UNDO_COMMAND`),tm=z(`REDO_COMMAND`),nm=z(`KEYDOWN_COMMAND`),rm=z(`KEY_ARROW_RIGHT_COMMAND`),im=z(`MOVE_TO_END`),am=z(`KEY_ARROW_LEFT_COMMAND`),om=z(`MOVE_TO_START`),sm=z(`KEY_ARROW_UP_COMMAND`),cm=z(`KEY_ARROW_DOWN_COMMAND`),lm=z(`KEY_ENTER_COMMAND`),um=z(`KEY_SPACE_COMMAND`),dm=z(`KEY_BACKSPACE_COMMAND`),fm=z(`KEY_ESCAPE_COMMAND`),pm=z(`KEY_DELETE_COMMAND`),mm=z(`KEY_TAB_COMMAND`),hm=z(`DROP_COMMAND`),gm=z(`DRAGSTART_COMMAND`),_m=z(`DRAGOVER_COMMAND`),vm=z(`DRAGEND_COMMAND`),ym=z(`COPY_COMMAND`),bm=z(`CUT_COMMAND`),xm=z(`SELECT_ALL_COMMAND`),Sm=z(`FOCUS_COMMAND`),Cm=z(`BLUR_COMMAND`),wm=z(`KEY_MODIFIER_COMMAND`),Tm=Object.freeze({}),Em=[[`keydown`,function(e,t){Dm=e.timeStamp,Om=e.key,!t.isComposing()&&W(t,nm,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;Tv(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Lg(t,()=>{m_(n)||(Pm=!0)})}],[`compositionstart`,function(e,t){W(t,Up,e)}],[`compositionend`,function(e,t){af?Im=!0:sf||!lf&&!ff?W(t,Wp,e):(Lm=!0,Rm=e.data)}],[`input`,function(e,t){e.stopPropagation(),Lg(t,()=>{t.dispatchCommand(Hp,e)},{event:e}),Am=null}],[`click`,function(e,t){Lg(t,()=>{let n=H(),r=Sv(mv(t)),i=rg();if(r){if(V(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Gg(a)&&L_().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=Vv(a,e=>U(e)&&!e.isInline());U(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(wv(n)||S_(n))&&z_(ng(i,r,t,e))}}W(t,Bp,e)})}],[`cut`,Tm],[`copy`,Tm],[`dragstart`,Tm],[`dragover`,Tm],[`dragend`,Tm],[`paste`,Tm],[`focus`,Tm],[`blur`,Tm],[`drop`,Tm]];of&&Em.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||af&&ov(t)||n!==`insertCompositionText`&&W(t,Vp,e)}(e,t)]);var Dm=0,Om=null,km=0,Am=null,jm=new WeakMap,Mm=new WeakMap,Nm=!1,Pm=!1,Fm=!1,Im=!1,Lm=!1,Rm=``,zm=null,Bm=[0,``,0,`root`,0];function Vm(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=wg(),l=Sv(mv(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!B(s)||(!i&&(!of||km<r+50)||s.isDirty()&&p<2||V_(n))&&a.offset!==o.offset&&!s.isComposing()||x_(s)||s.isDirty()&&p>1||(i||!of)&&f!==null&&!s.isComposing()&&u!==w_(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=b_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(B(t)||U(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function Hm(e,t){return S_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Um(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;Nm&&(Nm=!1,Hm(r,i)&&Hm(a,o)&&!zm)||Lg(t,()=>{if(!n)return void z_(null);if(!g_(t,r,a))return;let s=H();if(zm&&V(s)&&s.isCollapsed()){let e=s.anchor,t=zm.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=zm.clone(),z_(s))}if(zm=null,V(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=mv(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=Bm,f=L_(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Wm(s,o,c);else if(n.type===`text`)B(r)||R(141),Gm(s,r);else if(n.type===`element`&&!p){U(r)||R(259);let e=n.getNode();e.isEmpty()?function(e,t){Wm(e,t.getTextFormat(),t.getTextStyle())}(s,e):Wm(s,s.format,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(B(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}W(t,zp,void 0)})}function Wm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Gm(e,t){Wm(e,t.getFormat(),t.getStyle())}function Km(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function qm(e){let t=e.inputType,n=Km(e),r=wg(),i=H();if(t===`deleteContentBackward`){if(i===null){let e=rg();if(!V(e))return!0;z_(e.clone())}if(V(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,Om===`MediaLast`&&a<Dm+30&&r.isComposing()&&t){if(k_(null),Dm=0,setTimeout(()=>{Lg(r,()=>{k_(null)})},30),V(i)){let e=i.anchor.getNode();e.markDirty(),B(e)||R(142),Gm(i,e)}}else{k_(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=df&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!Ug(av(i.anchor,!0))),!c){W(r,Gp,!0);let e=H();df&&V(e)&&e.isCollapsed()&&(zm=e,setTimeout(()=>zm=null))}}return!0}}var a;if(!V(i))return!0;let o=e.data;Am!==null&&G_(!1,r,Am),i.dirty&&Am===null||!i.isCollapsed()||Gg(i.anchor.getNode())||n===null||i.applyDOMRange(n),Am=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
6
6
  `)e.preventDefault(),W(r,Kp,!1);else if(o===Cf)e.preventDefault(),W(r,qp,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&Vm(i,n,o,e.timeStamp,!0)?(e.preventDefault(),W(r,Jp,o)):Am=o;return km=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:W(r,Jp,e);break;case`insertFromComposition`:k_(null),W(r,Jp,e);break;case`insertLineBreak`:k_(null),W(r,Kp,!1);break;case`insertParagraph`:k_(null),Fm&&!sf?(Fm=!1,W(r,Kp,!1)):W(r,qp,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:W(r,Yp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!b_(e)||!b_(t)})(l,u)&&W(r,Xp,e);break;case`deleteByDrag`:case`deleteByCut`:W(r,Xp,e);break;case`deleteContent`:W(r,Gp,!1);break;case`deleteWordBackward`:W(r,Zp,!0);break;case`deleteWordForward`:W(r,Zp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:W(r,Qp,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:W(r,Qp,!1);break;case`formatStrikeThrough`:W(r,$p,`strikethrough`);break;case`formatBold`:W(r,$p,`bold`);break;case`formatItalic`:W(r,$p,`italic`);break;case`formatUnderline`:W(r,$p,`underline`);break;case`historyUndo`:W(r,em,void 0);break;case`historyRedo`:W(r,tm,void 0)}return!0}function Jm(e){if(wv(e.target)&&m_(e.target))return!0;let t=wg(),n=H(),r=e.data,i=Km(e);if(r!=null&&V(n)&&Vm(n,i,r,e.timeStamp,!1)){Im&&=(Zm(t,r),!1);let i=n.anchor.getNode(),a=Sv(mv(t));if(a===null)return!0;let o=n.isBackward(),s=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;of&&!n.isCollapsed()&&B(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===W_(a.anchorNode)||W(t,Jp,r);let l=r.length;af&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),df&&t.isComposing()&&(Dm=0,k_(null))}else G_(!1,t,r===null?void 0:r),Im&&=(Zm(t,r||void 0),!1);return function(){xg(),Vf(wg())}(),!0}function Ym(e){let t=wg(),n=H();if(V(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();k_(r.key),uv(uh),(e.timeStamp<Dm+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||B(i)&&i.getStyle()!==n.style)&&W(t,Jp,wf)}return!0}function Xm(e){return Zm(wg(),e.data),uv(dh),!0}function Zm(e,t){let n=e._compositionKey;if(k_(null),n!==null&&t!=null){if(t===``){let t=j_(n),r=w_(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&B(t)){let n=Sv(mv(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),K_(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
@@ -98,4 +98,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
98
98
 
99
99
  `):void 0}function az(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=ZR(o);if(s){let e=XR(s.status)?.toLowerCase(),t=tz(s,a),o=rz(s),c=XR(s.sessionId),l=QL({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...XR(s.title)?{label:s.title.trim()}:{},...XR(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:ez(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:ez(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:ez(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=QR(o);if(!c)return null;let l=nz(c,a),u=iz(c),d=XR(c.sessionId),f=QL({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...XR(c.title)?{label:c.title.trim()}:{},...XR(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:ez(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function oz(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e.error:null;return typeof t==`object`&&t&&!Array.isArray(t)&&t.code===`invalid_tool_arguments`?t:null}function sz(e,t){let n=RL(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function cz(e,t){let n=e.mimeType.startsWith(`image/`),r=VL(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function lz(e,t){let n=e.toolInvocation,r=UL(n.result,t);if(r)return r;let i=az({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:WL(i,t)};let a=GL({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=oz(n.result),s=Array.isArray(o?.issues)?o.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,c=JR({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),l=s?`Invalid arguments: ${s}`:c?.summary??wL(n.parsedArgs??n.args),u=c?void 0:qL(n.args,n.parsedArgs),d=s||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:SL(n.result).trim()),f=!n.error&&HL(n.result),p=(!c?.fileOperation||!!n.error)&&!f,m=QL(n);return{type:`tool-card`,card:WL({kind:a.kind,name:n.toolName,...m?{agentId:m}:{},detail:l,...u?{input:u}:{},text:p&&d?d:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:o?`error`:a.statusTone,statusLabel:o?t.toolStatusFailedLabel:a.statusLabel,...c?.fileOperation?{fileOperation:c.fileOperation}:{}},t)}}function uz(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:SL(e)}}function dz(e){return e.type===`text`&&typeof e.text==`string`}function fz(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function pz(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function mz(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function hz(e){let{inlineTokens:t,part:n,texts:r}=e;return dz(n)?LL(n,t):fz(n)?sz(n,r):pz(n)?cz(n,r):mz(n)?lz(n,r):uz(n,r)}function gz(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function _z(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function vz(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function yz(e,t){return{id:e.id,role:vz(e.role),roleLabel:_z(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(gz(e)),status:e.meta?.status,parts:e.parts.map(n=>hz({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var bz=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function xz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Sz(e){return xz(e)}function Cz(e){let t=xz(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function wz(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function Tz(e){let t=wz(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function Ez(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function Dz(e){let t=Tz(e.path),n=Tz(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function Oz(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function kz(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function Az(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?Dz({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=Cz(i)??i.trim();c=Oz({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=Ez(o);c=Oz({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:kz({line:n,column:t}),truncated:a,segments:c}}var jz=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),Mz=new Set([`running`,`completed`,`failed`,`idle`]);function Nz(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function Pz(e){return`${tt}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function Fz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Iz(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function Lz(e){let t=Iz(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=Fz(n.timestamp);if(!Mz.has(r)||!i)return null;let a=Fz(n.statusText),o=Fz(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function Rz(e){let t=Iz(e);return t?Fz(t.preferred_model)??Fz(t.preferredModel)??Fz(t.model):null}function zz(e){let t=Iz(e);if(!t)return null;let n=Fz(t.preferred_thinking)??Fz(t.thinking)??Fz(t.thinking_level)??Fz(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return jz.has(r)?r:null}function Bz(e){let t=Iz(e);return t?Fz(t.label):null}function Vz(e){let t=Iz(e);return t?Sz(t.project_root??t.projectRoot):null}function Hz(e){let t=Iz(e);return t?Fz(t.ui_last_read_at):null}function Uz(e){let t=Iz(e);return t?Fz(t.runtime)??Fz(t.session_type)??Fz(t.sessionType)??`native`:`native`}function Wz(e){let t=Iz(e);return t?Fz(t.parent_session_id)??Fz(t.parentSessionId):null}function Gz(e){let t=Iz(e);return t?Fz(t.spawned_by_request_id)??Fz(t.spawnedByRequestId):null}function Kz(e){let t=Iz(e);return t?t.child_session_promoted===!0:!1}function qz(e){if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function Jz(e){return e.state===`cancelled`?bz.CANCELLED:e.state===`result`?bz.RESULT:e.state===`partial-call`?bz.PARTIAL_CALL:bz.CALL}function Yz(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:Pz(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:Jz(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:Nz(n.args),result:n.result}})}return t}function Xz(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function Zz(e){return{id:e.id,role:Xz(e.role),parts:Yz(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function Qz(e){let t=Bz(e),n=Rz(e),r=zz(e),i=Vz(e),a=Hz(e),o=Fz(e.lastMessageAt),s=Cz(i),c=qz(e.sessionId),l=Wz(e),u=Gz(e),d=Kz(e),f=Lz(e);return{key:e.sessionId,createdAt:e.createdAt??e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:Uz(e),sessionTypeMutable:!1,status:e.status??`idle`,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},...f?{activityPreview:f}:{},messageCount:e.messageCount}}function $z(e){return e.map(Qz)}function eB(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function tB(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function nB(e){return e===!0}function rB(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=tB(n.usedContextTokens),i=tB(n.totalContextTokens),a=tB(n.prunedUsedContextTokens),o=eB(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=tB(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:tB(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:tB(n.droppedHistoryCount)??0,truncatedToolResultCount:tB(n.truncatedToolResultCount)??0,truncatedSystemPrompt:nB(n.truncatedSystemPrompt),truncatedUserMessage:nB(n.truncatedUserMessage),compacted:nB(n.compacted),...eB(n.checkpointId)?{checkpointId:eB(n.checkpointId)??void 0}:{},compactedMessageCount:tB(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function iB(e){let{metadata:t}=e;if(!t||t.nextclaw_timeline_kind!==`context_compaction`)return null;let n=t.checkpoint&&typeof t.checkpoint==`object`&&!Array.isArray(t.checkpoint)?t.checkpoint:null;if(!n)return null;let r=eB(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=eB(n.summary),o=tB(n.coveredMessageCount),s=tB(n.coveredSessionMessageCount),c=tB(n.originalEstimatedTokens),l=tB(n.projectedEstimatedTokens),u=eB(n.createdAt),d=eB(n.updatedAt);return!r||!i||!a||o===null||s===null||c===null||l===null||!u||!d?null:{id:r,status:i,summary:a,coveredMessageCount:o,coveredSessionMessageCount:s,originalEstimatedTokens:c,projectedEstimatedTokens:l,createdAt:u,updatedAt:d}}function aB(){return at({queryKey:[`agents`],queryFn:Me,staleTime:3e4})}function oB(){let e=ge();return le({mutationFn:({agentId:e,data:t})=>Ce(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function sB(){let e=ge();return le({mutationFn:({agentId:e})=>Ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),A.success(s(`configSavedApplied`))},onError:e=>{A.error(s(`configSaveFailed`)+`: `+e.message)}})}function cB(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function lB(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=aB(),i=(0,F.useMemo)(()=>cB(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,F.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function uB({agentId:e,className:t}){let n=lB(e);return n?(0,I.jsx)(Wu,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var dB=new WeakMap;function fB(e){return{roleLabels:{user:s(`chatRoleUser`),assistant:s(`chatRoleAssistant`),tool:s(`chatRoleTool`),system:s(`chatRoleSystem`),fallback:s(`chatRoleMessage`)},reasoningLabel:s(`chatReasoning`),toolCallLabel:s(`chatToolCall`),toolResultLabel:s(`chatToolResult`),toolInputLabel:s(`chatToolInput`),toolNoOutputLabel:s(`chatToolNoOutput`),toolOutputLabel:s(`chatToolOutput`),toolStatusPreparingLabel:s(`chatToolStatusPreparing`),toolStatusRunningLabel:s(`chatToolStatusRunning`),toolStatusCompletedLabel:s(`chatToolStatusCompleted`),toolStatusFailedLabel:s(`chatToolStatusFailed`),toolStatusCancelledLabel:s(`chatToolStatusCancelled`),imageAttachmentLabel:s(`chatImageAttachment`),fileAttachmentLabel:s(`chatFileAttachment`),unknownPartLabel:s(`chatUnknownPart`)}}function pB(e){return{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`),copyMessageLabel:s(`chatMessageCopy`),copiedMessageLabel:s(`chatMessageCopied`),typingLabel:s(`chatTyping`),attachmentOpenLabel:s(`chatAttachmentOpen`),attachmentAttachedLabel:s(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:s(`chatAttachmentCategoryArchive`),audio:s(`chatAttachmentCategoryAudio`),code:s(`chatAttachmentCategoryCode`),data:s(`chatAttachmentCategoryData`),document:s(`chatAttachmentCategoryDocument`),generic:s(`chatAttachmentCategoryGeneric`),image:s(`chatAttachmentCategoryImage`),pdf:s(`chatAttachmentCategoryPdf`),sheet:s(`chatAttachmentCategorySheet`),video:s(`chatAttachmentCategoryVideo`)}}}function mB({checkpoint:e}){return(0,I.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-gray-500`,title:[`${s(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${s(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${s(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
100
100
  `),children:[(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`}),(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-gray-200 bg-gray-50 px-3 py-1`,children:[e.status===`compressing`?(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}):(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-300`}),(0,I.jsx)(`span`,{children:e.status===`compressing`?s(`chatContextCompactionCompressing`):s(`chatContextCompactionCompressed`)})]}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`})]})}function hB(e){let{normalRawMessages:t,rawMessageId:n,rawMessages:r}=e,i=r.findIndex(e=>e.id===n);return i<0?t.length-1:r.slice(0,i).filter(e=>!iB(e)).length-1}function gB(e){let t=e.rawMessages.filter(e=>!iB(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:iB(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:hB({rawMessages:e.rawMessages,normalRawMessages:t,rawMessageId:n.rawMessageId})})).sort((e,t)=>e.boundaryIndex-t.boundaryIndex),r=[],i=[],a=0,o=e=>{i.length!==0&&(r.push({kind:`messages`,key:e,messages:i}),i=[])};for(t.forEach((t,s)=>{let c=e.messages[s];for(c&&i.push(c);a<n.length&&n[a]?.boundaryIndex<=s;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}});a<n.length;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}return o(`messages-final`),r.length===0&&r.push({kind:`messages`,key:`messages-empty`,messages:[]}),r}function _B({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=No(),o=(0,F.useMemo)(()=>fB(a),[a]),s=(0,F.useMemo)(()=>e.flatMap(e=>{if(iB(e))return[];let t=dB.get(e);if(t&&t.language===a)return[t.viewModel];let n=Zz(e),r=yz({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:jL(e.metadata)},parts:n.parts},{formatTimestamp:e=>u(e,a),texts:o});return dB.set(e,{language:a,viewModel:r}),[r]}),[a,e,o]),c=(0,F.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),l=(0,F.useMemo)(()=>pB(a),[a]),d=(0,F.useMemo)(()=>gB({rawMessages:e,messages:s}),[s,e]);return(0,I.jsx)(`div`,{className:n,children:d.map((e,n)=>e.kind===`compaction`?(0,I.jsx)(mB,{checkpoint:e.checkpoint},e.key):(0,I.jsx)(TF,{messages:e.messages,isSending:n===d.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,I.jsx)(uB,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function vB(){let e=ge();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{He(e,await Qe(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),A.success(i??s(`configSavedApplied`))}catch(e){throw A.error(s(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function yB(){let e=vB();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=s(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),A.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function bB({icon:e,label:t,onClick:n,disabled:i=!1,destructive:a=!1}){return(0,I.jsxs)(`button`,{type:`button`,className:r(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:i,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:t})]})}function xB(e){return at({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>Ye({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var SB=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsx)(`div`,{ref:i,className:r(`overflow-auto`,e),...n,children:t}));SB.displayName=`ScrollArea`;function CB({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:d}){let[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(``);(0,F.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),h(n),_(``)},[t,e]);let v=xB({path:m,enabled:e});(0,F.useEffect)(()=>{!e||!v.data||f.trim().length===0&&p(v.data.currentPath)},[v.data,f,e]);let y=f.trim(),b=y.length===0||n,x=(0,F.useMemo)(()=>v.error?v.error instanceof Error?v.error.message:String(v.error):null,[v.error]),S=g.trim().toLowerCase(),C=(0,F.useMemo)(()=>{let e=v.data?.entries??[];return S.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(S)||n.includes(S)})},[v.data?.entries,S]),w=e=>{h(e),_(``),e&&p(e)};return(0,I.jsx)(qt,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(Wt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(Jt,{children:[(0,I.jsx)(Ut,{children:a}),o?(0,I.jsx)(Ht,{children:o}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!b&&i(y)},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Ne,{htmlFor:`server-path-picker-input`,children:c}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(j,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,I.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>w(y||null),disabled:n,children:s(`openPath`)})]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,I.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,I.jsx)(qn,{className:`mr-1 h-4 w-4`}),s(`homeDirectory`)]}),(0,I.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,I.jsx)(Hn,{className:`mr-1 h-4 w-4`}),s(`parentDirectory`)]}),(0,I.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,I.jsx)(sr,{className:`mr-1 h-4 w-4`}),s(`chatRefresh`)]})]}),(0,I.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:s(`currentDirectory`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:v.data?.breadcrumbs.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>w(e.path),disabled:n,children:e.label}),t<v.data.breadcrumbs.length-1?(0,I.jsx)(Sn,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Zt,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:g,onChange:e=>_(e.target.value),placeholder:s(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,I.jsx)(SB,{className:`min-h-0 flex-1 px-2 py-2`,children:v.isLoading?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`loading`)}):x?(0,I.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[s(`pathBrowseFailed`),`: `,x]}):v.data&&C.length>0?(0,I.jsx)(`div`,{className:`space-y-1`,children:C.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>w(e.path),disabled:n,children:[(0,I.jsx)(Wn,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):v.data&&v.data.entries.length>0?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`pathPickerSearchEmpty`)}):(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`emptyDirectory`)})})]}),d?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,I.jsxs)(Kt,{children:[(0,I.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:s(`cancel`)}),(0,I.jsx)(M,{type:`submit`,disabled:b,children:n?s(`saving`):u})]})]})]})})}function wB({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(CB,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:s(`chatSessionProjectDialogTitle`),description:s(`chatSessionProjectDialogDescription`),pathLabel:s(`chatSessionProjectPathLabel`),pathPlaceholder:s(`chatSessionProjectPathPlaceholder`),confirmLabel:s(`chatSessionSetProject`),hint:s(`chatSessionProjectUpdateHint`)})}var TB=`flex shrink-0 items-center gap-1.5`,EB=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function DB({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:c,onDeleteSession:l}){let u=yB(),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(!1),_=n||h,v=async n=>{let r=t;g(!0);try{await u({sessionKey:e,projectRoot:n,persistToServer:r}),m(!1),f(!1)}finally{g(!1)}};return(0,I.jsxs)(`div`,{className:TB,children:[i>0&&o?(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:EB,"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,I.jsx)(Gn,{className:`h-4 w-4`})}):null,a>0&&c?(0,I.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:EB,"aria-label":s(`chatSessionOpenCronJobs`),title:s(`chatSessionOpenCronJobs`),onClick:c,disabled:_,children:(0,I.jsx)(mn,{className:`h-4 w-4`})}):null,(0,I.jsxs)(Ai,{open:d,onOpenChange:f,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{variant:`ghost`,size:`icon`,className:EB,"aria-label":s(`chatSessionMoreActions`),disabled:_,children:(0,I.jsx)(kn,{className:`h-4 w-4`})})}),(0,I.jsx)(Mi,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(bB,{icon:Bn,label:s(`chatSessionSetProject`),onClick:()=>{f(!1),m(!0)},disabled:_}),(0,I.jsx)(bB,{icon:xr,label:s(`chatDeleteSession`),onClick:()=>{f(!1),l()},disabled:!t||_,destructive:!0})]})})]}),(0,I.jsx)(wB,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function OB({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=yB(),[a,o]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),o(!1)}finally{d(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Ai,{open:a,onOpenChange:o,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":s(`chatSessionSetProject`),disabled:u,children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(Bn,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(xn,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(Mi,{align:`start`,className:`w-72 p-2`,children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,I.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(bB,{icon:ar,label:s(`chatSessionSetProject`),onClick:()=>{o(!1),l(!0)},disabled:u}),(0,I.jsx)(bB,{icon:Un,label:s(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,I.jsx)(wB,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function kB({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,I.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsxs)(`span`,{children:[s(`chatBackToParent`),n?` · ${n}`:``]})]})})}function AB({snapshot:e,childSessionCount:t,sessionCronJobCount:n,layoutMode:i,normalizedAgentId:a,sessionHeaderTitle:o,shouldShowHeaderAgentAvatar:c,shouldShowSessionHeader:l,onBackToList:u,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}){let m=i===`mobile`;return(0,I.jsxs)(`div`,{className:r(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-colors duration-200`,m?`px-3 sm:px-3`:`px-4 sm:px-5`,l?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,l&&(m?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:m&&l?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[m&&u?(0,I.jsx)(`button`,{type:`button`,onClick:u,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chat`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,c?(0,I.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(Wu,{agentId:a,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:o}),e.sessionTypeLabel?(0,I.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,I.jsx)(Lu,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,I.jsx)(OB,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,I.jsx)(DB,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}):null]})}var jB=`native`;function MB(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:jB}function NB(e,t=jB){return MB(e?.runtime?.trim()||e?.engine?.trim()||t)}function PB(e,t){return e===`native`?s(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function FB(e){let t=new Map;for(let n of e){let e=MB(n.value);t.set(e,{value:e,label:n.label?.trim()||PB(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(jB,{value:jB,label:PB(jB),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function IB(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,F.useMemo)(()=>FB(i?.options??[]),[i?.options]),o=(0,F.useMemo)(()=>{let e=[...a],n=MB(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:PB(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),c=(0,F.useMemo)(()=>MB(i?.defaultType??`native`),[i?.defaultType]),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>MB(t?.sessionType??n??c),[c,n,t?.sessionType]),d=(0,F.useMemo)(()=>o.find(e=>e.value===u)??null,[u,o]);(0,F.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=MB(n);(e.length===0||l.current===i||l.current===null&&i===`native`)&&(l.current=c,i!==c&&r(c))},[c,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,F.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:o,selectedSessionTypeOption:d,defaultSessionType:c,selectedSessionType:u,canEditSessionType:f,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!p.has(MB(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!p.has(MB(t.sessionType))?`${PB(u)} ${s(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}function LB(e,t){return e.label?.trim()?e.label.trim():t?Ku(t):e.sessionKey}function RB(e){let t=Ts({limit:200}),n=(0,F.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,F.useMemo)(()=>{let e=$z(n);return new Map(e.map(e=>[e.key,e]))},[n]);return(0,F.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:LB(e,t),agentId:n,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:t?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?PB(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function zB(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
101
- `)}}async function*BB(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=VB(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=VB(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function VB(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=zB(e);t&&i.push(t)}if(t&&r.trim()){let e=zB(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var HB=`/ncp/agent`,UB=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function WB(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function GB(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function KB(e){let t=(e??`/ncp/agent`).trim();if(!t)return HB;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function qB(e){try{return(await e.text()).trim()}catch{return``}}function JB(e){if(QB(e))return e.ncpError;if(XB(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:eV(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function YB(e,t={}){return new UB(e,t.alreadyPublished??!1)}function XB(e){return ZB(e)&&typeof e.code==`string`&&typeof e.message==`string`}function ZB(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function QB(e){return e instanceof UB}var $B={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function eV(e){if(!e)return`runtime-error`;let t=$B[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function tV(e){let t=rV(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function nV(e){let t=rV(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=eV(n),i=ZB(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function rV(e){try{let t=JSON.parse(e);return ZB(t)?t:null}catch{return null}}var iV=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],aV=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=WB(e.baseUrl),this.basePath=KB(e.basePath),this.fetchImpl=GB(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:iV,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:EF.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await qB(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(QB(e))throw e;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await qB(n)}`)}catch(e){if(t.signal.aborted)return;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await qB(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of BB(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(QB(e))throw e;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=tV(e.data);if(!t){this.publish({type:EF.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=nV(e.data);throw this.publish({type:EF.EndpointError,payload:t}),YB(t,{alreadyPublished:!0})}}};function oV(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function sV(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function cV(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function lV(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw rt.reportTransportFailure(sV(n)),cV(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${oV(e)}: ${sV(n)}`,n)}}}var uV=300,dV=`ncp agent unavailable during startup`;function fV(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function pV(e){return e?.trim().toLowerCase().includes(dV)??!1}function mV(){return new aV({baseUrl:tt,basePath:`/api/ncp/agent`,fetchImpl:lV()})}async function hV(e,t,n=uV){t.throwIfAborted();try{let r=await Ae(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!fV(e))throw e;return{messages:[],status:`idle`}}}function gV(e,t){let n=(0,F.useRef)(null),r=(0,F.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,F.useEffect)(()=>{r(e)},[e,r])}function _V(e,t={}){let[n]=(0,F.useState)(()=>mV()),r=xe(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??uV;(0,F.useEffect)(()=>{s(null)},[e]);let l=iI({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await hV(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return gV(e&&r.phase===`ready`&&pV(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}function vV(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function yV(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function bV({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Mn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(uB,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(er,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function xV({tab:e}){return(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsxs)(`div`,{className:r(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,I.jsx)(bV,{kind:e.kind,agentId:e.agentId}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,I.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:s(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,I.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:r(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":s(`chatWorkspaceCloseFile`),children:(0,I.jsx)(rn,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(Ua,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function SV({tabs:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,I.jsx)(xV,{tab:e},e.key))})})}function CV({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:r(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function wV({breadcrumb:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,I.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(`span`,{className:r(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,I.jsx)(Vn,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Mn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Sn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,I.jsx)(CV,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(CV,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function TV(e){let t=e.path?.trim()??``;return at({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>ze({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function EV(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function DV(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:aR({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function OV(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=lR({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function kV({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:r(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function AV({diffBlock:e}){return e?(0,I.jsx)(jV,{block:e}):(0,I.jsx)(kV,{text:s(`chatWorkspaceDiffEmpty`)})}function jV({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(BP,{block:e,layout:`workspace`})})}function MV({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(kV,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(kV,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(kV,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,I.jsx)(AN,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(jV,{block:t}):(0,I.jsx)(kV,{text:s(`chatWorkspacePreviewEmpty`)})}function NV({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=TV({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?OV(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=EV({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:DV({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsx)(wV,{breadcrumb:(0,F.useMemo)(()=>Az({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,I.jsx)(AV,{diffBlock:a}):(0,I.jsx)(MV,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var PV={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function FV(){let[e,t]=(0,F.useState)(PV),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??s(`confirm`),cancelLabel:e.cancelLabel??s(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,F.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,F.useCallback)(()=>(0,I.jsx)(Yt,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function IV(e){return u(e??void 0)}function LV(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function RV(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function zV(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${RV(t.everyMs)}`:t.kind===`at`?`at ${LV(t.atMs)}`:`-`}function BV(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function VV(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function HV(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function UV({jobs:e}){let t=Os(),{confirm:n,ConfirmDialog:r}=FV(),i=async e=>{await n({title:`${s(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:s(`delete`)})&&t.mutate({id:e.id})};return(0,I.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:s(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[s(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:s(`chatWorkspaceCronJobEmpty`)}):(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,I.jsxs)(M,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,I.jsx)(xr,{className:`h-3.5 w-3.5`}),s(`delete`)]})]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronScheduleLabel`),`:`]}),` `,zV(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,IV(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,IV(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronDeliverTo`),`:`]}),` `,BV(e)]})]}),(0,I.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,I.jsx)(r,{})]})}function WV({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=_V(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=hP({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,I.jsx)(Zn,{className:`mr-2 h-4 w-4 animate-spin`}),s(`chatChildSessionLoading`)]}):r.hydrateError?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:s(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(_B,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function GV({value:e}){return(0,I.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,I.jsx)(`span`,{className:`truncate`,children:e})})}function KV({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,I.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,I.jsx)(GV,{value:e},e))}):null,e.projectRoot?(0,I.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function qV({tab:e}){return(0,I.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,I.jsx)(uB,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(zn,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(KV,{tab:e})]})}function JV(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:c,onCloseFile:l,onSelectCronJobs:u}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:ZI({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:vV(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>c(e.key),onClose:()=>l(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:s(`chatWorkspaceSessionCronJobs`),tooltip:s(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:u}]:[];return[...d,...f,...p]}function YV({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:c=[],sessionProjectRoot:l,displayMode:u=`docked`}){let d=sd(),f=RB(t),p=tL(e=>e.optimisticReadAtBySessionKey),m=yV({activeChildSessionKey:n,activeWorkspaceFileKey:a,activePanelKind:o,childSessionTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length}),h=f.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(m?.kind!==`child-session`||m.tab.runStatus===`running`)return;let e=m.tab.lastMessageAt?.trim()??null;e&&d.chatSessionListManager.markSessionRead(m.tab.sessionKey,e,m.tab.readAt??null)},[m,d]);let g=(0,F.useMemo)(()=>JV({resolvedChildTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length,activeSelection:m,optimisticReadAtBySessionKey:p,onSelectSession:d.chatThreadManager.selectChildSessionDetail,onSelectFile:d.chatThreadManager.selectWorkspaceFile,onCloseFile:d.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&d.chatThreadManager.openSessionCronPanel(e)}}),[m,p,d.chatThreadManager,f,e,i,c.length]);return m?(0,I.jsxs)(pt,{className:r(u===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:u===`overlay`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:d.chatThreadManager.goToParentSession,className:r(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!h&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:s(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:d.chatThreadManager.closeWorkspacePanel,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chatWorkspaceClosePanel`),children:(0,I.jsx)(rn,{className:`h-4 w-4`})})]}),(0,I.jsx)(SV,{tabs:g}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:m.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qV,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(WV,{sessionKey:m.tab.sessionKey,onToolAction:d.chatThreadManager.openSessionFromToolAction,onFileOpen:d.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,I.jsx)(NV,{file:m.file,sessionProjectRoot:l,onFileOpen:d.chatThreadManager.openFilePreview}):(0,I.jsx)(UV,{jobs:c})})]}):null}function XV({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var ZV=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function QV(){return(0,I.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,I.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(XV,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:ZV.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(XV,{"data-testid":`chat-conversation-skeleton-bubble`,className:r(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,I.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(XV,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(XV,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,I.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,I.jsx)(XV,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(XV,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(XV,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(XV,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(XV,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(XV,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function $V(){let e=sd(),t=Q(e=>e.snapshot);return(0,I.jsxs)(I.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,I.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:s(`chatModelNoOptions`)}),(0,I.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:s(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,I.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function eH(){let e=sd(),t=Z(e=>e.snapshot.defaultSessionType),n=Q(e=>e.snapshot),r=(0,F.useRef)(null),i=n.threadRef??r,a=n.availableAgents??[],o=!n.canDeleteSession&&!n.hasSubmittedDraftMessage&&n.messages.length===0&&!n.isSending,s=n.isHistoryLoading&&n.messages.length===0&&!n.isSending&&!n.isAwaitingAssistantOutput,c=e=>a.find(t=>t.id===e)??null,l=()=>{let r=NB(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(NB(c(n),t))},{onScroll:d}=hP({scrollRef:i,resetKey:n.sessionKey,isLoading:n.isHistoryLoading,hasContent:n.messages.length>0,contentVersion:n.messages[n.messages.length-1]??null}),f=n.messages.length>0,p=f&&n.isSending&&n.isAwaitingAssistantOutput;return(0,I.jsx)(`div`,{ref:i,onScroll:d,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:o?(0,I.jsx)(id,{onCreateSession:l,agents:a,selectedAgentId:n.agentId??`main`,onSelectAgent:u}):s||!f?null:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,I.jsx)(_B,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function tH(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function nH(e){let t=(0,F.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,F.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=Ds({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>HV(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:tH(e,t,n,i.length)}}function rH(){let e=sd(),t=Q(e=>e.snapshot);return(0,I.jsx)(kB,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function iH({layoutMode:e,onBackToList:t}){let n=sd(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=nH(r),o=!!(r.sessionKey||r.sessionTypeLabel),c=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||s(`chatSidebarNewTask`),l=r.agentId?.trim()??``,u=l.length>0&&l.toLowerCase()!==`main`;return(0,I.jsx)(AB,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:l,sessionHeaderTitle:c,shouldShowHeaderAgentAvatar:u,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function aH({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=nH(t);return a?(0,I.jsx)(YV,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function oH({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsx)(rH,{}),(0,I.jsx)(iH,{layoutMode:e,onBackToList:t}),(0,I.jsx)($V,{}),(0,I.jsx)(eH,{}),(0,I.jsx)(_L,{})]}),(0,I.jsx)(aH,{layoutMode:e})]}):(0,I.jsx)(QV,{})}var sH={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function cH({status:e,className:t}){let n=sH[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":i,className:r(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)(Zn,{className:r(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:r(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(Ua,{side:`bottom`,className:`text-xs`,children:i})]})})}function lH(){let e=vB();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function uH(){let e=lH(),[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function dH(e,t){return e.filter(e=>$u(e,t))}function fH(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function pH(e={}){let t=tL(e=>e.snapshot.query),n=Ts({limit:e.limit??200}),r=(0,F.useMemo)(()=>dH($z(n.data?.sessions??[]).filter(fH),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function mH(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,I.jsx)(nd,{session:g,active:y,showUnreadDot:ZI({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Mu(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function hH(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function gH(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(M,{variant:`primary`,className:r(`min-w-0 rounded-xl`,i.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{o(!1),c(n)},children:[(0,I.jsx)(nn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(Ai,{open:a,onOpenChange:o,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(xn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,I.jsx)(zu,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Zt,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function _H(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=hH({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=u.length>1;return(0,I.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,I.jsx)(Zt,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,I.jsxs)(Ai,{open:a,onOpenChange:o,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),children:(0,I.jsx)(nn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:s(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,I.jsx)(zu,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(M,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,I.jsx)(nn,{className:`h-4 w-4`})})]})})}function vH({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:c,languageOptions:l,onSelectLanguage:u,onOpenDocs:d,onOpenApps:f}){let p=()=>{d(),t(!1)},m=()=>{f(),t(!1)};return(0,I.jsxs)(Ai,{open:e,onOpenChange:t,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,I.jsx)(dr,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:s(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,c]})]})}),(0,I.jsxs)(Mi,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(gt,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(dr,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`settings`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(Qt,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`docBrowserHelp`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:m,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)($t,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`appsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(yH,{icon:rr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(yH,{icon:Yn,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function yH({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(yl,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(xl,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,I.jsx)(Sn,{className:`h-4 w-4 text-gray-400`}),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`text-left`,children:t})]}),(0,I.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,I.jsx)(wl,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function bH(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function xH(e){return[...e].sort((e,t)=>bH(t)-bH(e))}function SH(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],c=[],l=[];for(let t of e){let e=bH(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:s(`chatSidebarToday`),items:a}),o.length>0&&u.push({label:s(`chatSidebarYesterday`),items:o}),c.length>0&&u.push({label:s(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:s(`chatSidebarOlder`),items:l}),u}function CH(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=bH(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||Cz(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:xH(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function wH(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>bH(t)-bH(e));return t}function TH(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var EH=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:mn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:ht},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:vn}];function DH(e,t,n){let r=tL(e=>e.optimisticReadAtBySessionKey);return(0,F.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r||r.runStatus===`running`)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function OH({variant:e=`desktop`}){let n=e===`mobile`,i=sd(),a=un(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=tL(e=>e.snapshot),p=xe(),m=aB(),{isLoading:h,items:g}=pH(),{language:_,setLanguage:v}=No(),{theme:y,setTheme:b}=ru(),x=s(Zo.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Zo.map(e=>({value:e.value,label:s(e.labelKey)})),[]),w=(0,F.useMemo)(()=>t.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),E=(0,F.useMemo)(()=>xH(g),[g]),ee=(0,F.useMemo)(()=>wH(g),[g]),D=(0,F.useMemo)(()=>SH(E),[E]),O=(0,F.useMemo)(()=>CH(E),[E]),k=d.defaultSessionType||`native`,te=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==k),[k,d.sessionTypeOptions]),A=f.listMode===`project-first`,ne=DH(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:j,draftLabel:re,savingSessionKey:M,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:oe,saveSessionLabel:se}=uH(),ce=e=>{_!==e&&(v(e),window.location.reload())},le=e=>(0,I.jsx)(mH,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:ne,agentsById:T,childSessionsByParentKey:ee,editingSessionKey:j,draftLabel:re,savingSessionKey:M,sessionTitle:TH,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:se,onCancelEditingSessionLabel:oe},e.session.key),ue=(e,t)=>{i.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:r(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!n&&!fu()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Ns,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(cH,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(_H,{query:f.query,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:ue,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(gH,{query:f.query,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:ue,onQueryChange:i.chatSessionListManager.setQuery}),n?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:EH.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Al,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,I.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:s(`chatSidebarTaskRecords`)}),(0,I.jsx)(bu,{isProjectFirstView:A,onSelectMode:i.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:s(`sessionsLoading`)}):A?O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(er,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(Vu,{groups:O,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:le,onCreateSession:ue}):D.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(er,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(le)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(vH,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:ce,onOpenDocs:()=>a.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),onOpenApps:()=>xo(a)})})]})}function kH(){return at({queryKey:[`ncp-session-types`],queryFn:pe,staleTime:1e4,retry:!1})}function AH(e){let t=e.trim();return t.length>0?t:null}function jH(e){return e??null}var MH=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=tL.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:AH(e.selectedModel),preferredThinking:jH(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},NH=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new MH(Qe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>oL(rt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=FI(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:AI(e),selectedSkills:jI(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:AI(e),selectedSkills:jI(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(kI(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=PI(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=PI(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=tL.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=II(e.composerNodes,i);if(GI({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(OI()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=MB(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(NI(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),zI.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{BI.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},PH=`sid_`,FH=`/chat/draft`,IH=FH.slice(6);function LH(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${PH}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function RH(e){if(!e.startsWith(PH))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function zH(e){if(!e||e===IH)return null;let t=RH(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function BH(e){return`/chat/${LH(e)}`}var VH=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=tL.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=tL.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=tL.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=tL.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(tL.getState().markSessionRead(r,i),Qe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=Sz(t);this.streamActionsManager.resetStreamState(),tL.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(FH)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=tL.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=tL.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({query:n})}}},HH=async()=>{},UH=()=>{},WH=class{constructor(){this.actions={sendMessage:HH,stopCurrentRun:HH,resumeRun:HH,resetStreamState:UH,applyHistoryMessages:UH},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},GH=async e=>!1,KH=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:GH},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`||this.state.pathname===`/chat/draft`,this.goToSession=(e,t)=>{this.navigateTo(BH(e),t)}}},qH=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{tL.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(tL.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=tL.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||tL.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>Lo.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=tL.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await Le(e),De(w,e),w.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},JH=class{constructor(){this.chatUiManager=new KH,this.chatStreamActionsManager=new WH,this.chatSessionListManager=new VH(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new NH(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new qH(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function YH(e){return e?.trim().toLowerCase()||`native`}function XH(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function ZH(e,t){return typeof t==`string`&&e.includes(t)}function QH(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function $H(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function eU(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:$H({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>XH(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function tU(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:$H({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>ZH(t,e),firstAvailableValue:QH(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function nU(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=YH(r),o,s=-1/0;for(let e of t){if(e.key===n||YH(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function rU(e){return e.map(e=>e==null?``:String(e)).join(``)}function iU(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,F.useRef)(void 0),l=(0,F.useRef)(s),u=(0,F.useRef)(n);l.current=s,(0,F.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function aU(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;iU({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:rU([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>eU({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function oU(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;iU({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:rU([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>tU({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function sU(){let{pathname:e}=ct(),t=lt();return Wo(e)?(0,I.jsx)(oH,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(OH,{variant:`mobile`})}var cU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DocBrowser:e}=await import(`./doc-browser-BrUQEZ1j.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function lU({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserRenderers:a={},children:o}){let s=Uo(e),c=t&&!Wo(e),l=fu();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,l?`rounded-[10px]`:null),style:l?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":s?`280px`:`240px`}:void 0,children:[l?(0,I.jsx)(cu,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!s&&(0,I.jsx)(ou,{mode:`settings`}),(0,I.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,I.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:s?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:o}):(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:o})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(cU,{customTabRenderers:a})}):null]})]}),c?(0,I.jsx)(hu,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(cU,{customTabRenderers:a})}):null]})}var uU=`NextClaw`,dU=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function fU(e,t){return e===t||e.startsWith(`${t}/`)}function pU(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of dU)if(fU(t,e))return s(n);return s(`settings`)}function mU(e){return`${uU} - ${pU(e)}`}function hU({children:e}){let{isOpen:t,mode:n}=un();Ao();let{pathname:r}=ct(),{language:i}=No(),{isMobile:a}=Ro(),o=du();return(0,F.useEffect)(()=>{document.title=mU(r)},[r,i]),a&&o!==`win32`?(0,I.jsx)(vu,{pathname:r,isDocBrowserOpen:t,docBrowserRenderers:So,topbarLeadingInset:o===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(lU,{pathname:r,isMobileLayout:a,isDocBrowserOpen:t,docBrowserMode:n,docBrowserRenderers:So,children:e})}function gU({children:e}){return(0,I.jsx)(fn,{children:(0,I.jsx)(hU,{children:e})})}function _U(){let{isMobile:e}=Ro();return e?(0,I.jsx)(yu,{}):(0,I.jsx)(st,{to:`/model`,replace:!0})}function vU(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function yU(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function bU(e,t){e&&vU(t)&&e.invalidateQueries({queryKey:[`config`]}),yU(e,t)}function xU(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=N.eventBus.on(b.connectionOpen,()=>{rt.handleConnectionRestored(),Ue.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=N.eventBus.on(b.connectionClose,()=>{rt.handleConnectionInterrupted(null),t.current=!0}),i=N.eventBus.on(b.connectionError,e=>{rt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=N.eventBus.on(b.configUpdated,({path:t})=>{bU(e,t)}),o=N.eventBus.on(b.runtimeUpdateSnapshot,e=>{Ue.reportSnapshot(e)}),s=N.eventBus.on(b.sessionRunStatus,t=>{Te(e,{type:`session.run-status`,payload:t})}),c=N.eventBus.on(b.sessionSummaryUpsert,t=>{Te(e,{type:`session.summary.upsert`,payload:t})}),l=N.eventBus.on(b.sessionSummaryDelete,t=>{Te(e,{type:`session.summary.delete`,payload:t})}),u=N.eventBus.on(b.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var SU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ModelConfig:e}=await import(`./model-config-fIE_Asps.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,5,3,14,10,11,15]))).ModelConfig})),CU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ChatPage:e}=await import(`./chat-page-MyXEZI8R.js`);return{ChatPage:e}},__vite__mapDeps([16,2,1,3,4,5,6,7,8,9,10,11,17,18,13,19,20,21,14,22,23]))).ChatPage})),wU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SearchConfig:e}=await import(`./search-config-TbCPlRE7.js`);return{SearchConfig:e}},__vite__mapDeps([24,2,13,4,3,7,25]))).SearchConfig})),TU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ProvidersList:e}=await import(`./providers-list-CqsOk2hr.js`);return{ProvidersList:e}},__vite__mapDeps([26,2,13,3,4,8,9,25,27,23,15]))).ProvidersList})),EU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-D-tv11dc.js`);return{ChannelsList:e}},__vite__mapDeps([28,2,13,3,4,5,7,9,25,23,21,15]))).ChannelsList})),DU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-BJ86cC8a.js`);return{RuntimeConfig:e}},__vite__mapDeps([29,2,17,18,13,19,9,3,22,8,30,27]))).RuntimeConfig})),OU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-oZpIKKtS.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([31,2,13,7,3]))).DesktopUpdateConfig})),kU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SecurityConfig:e}=await import(`./api-DruAcori.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),AU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-DBIEKP_V.js`);return{SecretsConfig:e}},__vite__mapDeps([32,2,13,8,3,30]))).SecretsConfig})),jU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{RemoteAccessPage:e}=await import(`./remote-BMWQUPDW.js`);return{RemoteAccessPage:e}},[])).RemoteAccessPage})),MU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-MjpFEEkY.js`);return{McpMarketplacePage:e}},__vite__mapDeps([33,20,2,17,18,13,19,9,3,10,11,21]))).McpMarketplacePage}));function NU(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function PU({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(NU,{}),children:e})}function FU(e){return(0,I.jsx)(PU,{children:e})}var IU=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:FU((0,I.jsx)(CU,{view:`chat`}))},{path:`/agents`,element:FU((0,I.jsx)(CU,{view:`agents`}))},{path:`/skills`,element:FU((0,I.jsx)(CU,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:FU((0,I.jsx)(CU,{view:`skills`}))},{path:`/cron`,element:FU((0,I.jsx)(CU,{view:`cron`}))},{path:`/model`,element:FU((0,I.jsx)(SU,{}))},{path:`/search`,element:FU((0,I.jsx)(wU,{}))},{path:`/providers`,element:FU((0,I.jsx)(TU,{}))},{path:`/channels`,element:FU((0,I.jsx)(EU,{}))},{path:`/runtime`,element:FU((0,I.jsx)(DU,{}))},{path:`/updates`,element:FU((0,I.jsx)(OU,{}))},{path:`/remote`,element:FU((0,I.jsx)(jU,{}))},{path:`/security`,element:FU((0,I.jsx)(kU,{}))},{path:`/secrets`,element:FU((0,I.jsx)(AU,{}))},{path:`/language`,element:(0,I.jsx)(au,{})},{path:`/settings`,element:(0,I.jsx)(_U,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:FU((0,I.jsx)(MU,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function LU(e){return`redirectTo`in e?(0,I.jsx)(dt,{path:e.path,element:(0,I.jsx)(st,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(dt,{path:e.path,element:e.element},e.path)}function RU(){return(0,I.jsx)(_t,{children:IU.map(LU)})}function zU(){return xU(w),$e(),(0,F.useEffect)(()=>(Ue.start(),()=>{Ue.stop()}),[]),(0,I.jsxs)(Oo,{children:[(0,I.jsx)(gU,{children:(0,I.jsx)(RU,{})}),(0,I.jsx)(Xr,{}),(0,I.jsx)(Ja,{})]})}function BU(){let e=Ze(),t=e.isError&&Ie(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(zU,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(Zr,{username:e.data.username}):(0,I.jsx)(zU,{})}function VU(){return(0,F.useEffect)(()=>{Ql()},[]),(0,I.jsxs)(ve,{client:w,children:[(0,I.jsx)(BU,{}),(0,I.jsx)(Yl,{}),(0,I.jsx)(Xl,{}),(0,I.jsx)(D,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var HU=window.nextclawDesktop?.platform===`win32`?mt:ut;(0,Tr.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(nu,{children:(0,I.jsx)(Mo,{children:(0,I.jsx)(HU,{children:(0,I.jsx)(VU,{})})})})}));export{ds as $,ar as $t,Sz as A,$i as At,Ku as B,Fr as Bt,aB as C,Va as Ct,$z as D,Zi as Dt,rB as E,Ha as Et,tL as F,Wr as Ft,Jl as G,Dr as Gt,Wu as H,Rr as Ht,Z as I,Br as It,El as J,gr as Jt,yl as K,xr as Kt,lI as L,zr as Lt,AL as M,Mi as Mt,oL as N,ji as Nt,Qz as O,ea as Ot,cL as P,Gr as Pt,us as Q,cr as Qt,od as R,jr as Rt,IB as S,No as St,oB as T,Ba as Tt,Iu as U,Ar as Ut,$u as V,Ir as Vt,Cu as W,Or as Wt,bl as X,dr as Xt,xl as Y,pr as Yt,cs as Z,lr as Zt,_V as _,ps as _t,JH as a,Kn as an,bs as at,NB as b,zo as bt,OH as c,Dn as cn,ys as ct,BV as d,vn as dn,_s as dt,tr as en,hs as et,zV as f,mn as fn,ks as ft,pV as g,Ss as gt,FV as h,ms as ht,oU as i,qn as in,ws as it,TL as j,Ai as jt,Cz as k,Qi as kt,oH as l,xn as ln,As as lt,IV as m,fs as mt,nU as n,Zn as nn,Os as nt,zH as o,Wn as on,Es as ot,VV as p,xs as pt,wl as q,vr as qt,aU as r,Jn as rn,gs as rt,kH as s,On as sn,Ts as st,sU as t,$n as tn,Ds as tt,XV as u,bn as un,vs as ut,FB as v,Cs as vt,sB as w,Ua as wt,PB as x,Ro as xt,MB as y,Bo as yt,sd as z,Pr as zt};
101
+ `)}}async function*BB(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=VB(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=VB(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function VB(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=zB(e);t&&i.push(t)}if(t&&r.trim()){let e=zB(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var HB=`/ncp/agent`,UB=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function WB(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function GB(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function KB(e){let t=(e??`/ncp/agent`).trim();if(!t)return HB;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function qB(e){try{return(await e.text()).trim()}catch{return``}}function JB(e){if(QB(e))return e.ncpError;if(XB(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:eV(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function YB(e,t={}){return new UB(e,t.alreadyPublished??!1)}function XB(e){return ZB(e)&&typeof e.code==`string`&&typeof e.message==`string`}function ZB(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function QB(e){return e instanceof UB}var $B={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function eV(e){if(!e)return`runtime-error`;let t=$B[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function tV(e){let t=rV(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function nV(e){let t=rV(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=eV(n),i=ZB(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function rV(e){try{let t=JSON.parse(e);return ZB(t)?t:null}catch{return null}}var iV=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],aV=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=WB(e.baseUrl),this.basePath=KB(e.basePath),this.fetchImpl=GB(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:iV,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:EF.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await qB(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(QB(e))throw e;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await qB(n)}`)}catch(e){if(t.signal.aborted)return;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await qB(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of BB(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(QB(e))throw e;let n=JB(e);throw this.publish({type:EF.EndpointError,payload:n}),YB(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=tV(e.data);if(!t){this.publish({type:EF.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=nV(e.data);throw this.publish({type:EF.EndpointError,payload:t}),YB(t,{alreadyPublished:!0})}}};function oV(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function sV(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function cV(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function lV(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw rt.reportTransportFailure(sV(n)),cV(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${oV(e)}: ${sV(n)}`,n)}}}var uV=300,dV=`ncp agent unavailable during startup`;function fV(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function pV(e){return e?.trim().toLowerCase().includes(dV)??!1}function mV(){return new aV({baseUrl:tt,basePath:`/api/ncp/agent`,fetchImpl:lV()})}async function hV(e,t,n=uV){t.throwIfAborted();try{let r=await Ae(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!fV(e))throw e;return{messages:[],status:`idle`}}}function gV(e,t){let n=(0,F.useRef)(null),r=(0,F.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,F.useEffect)(()=>{r(e)},[e,r])}function _V(e,t={}){let[n]=(0,F.useState)(()=>mV()),r=xe(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??uV;(0,F.useEffect)(()=>{s(null)},[e]);let l=iI({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await hV(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return gV(e&&r.phase===`ready`&&pV(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}function vV(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function yV(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function bV({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Mn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(uB,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(er,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function xV({tab:e}){return(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsxs)(`div`,{className:r(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,I.jsx)(bV,{kind:e.kind,agentId:e.agentId}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,I.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:s(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,I.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:r(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":s(`chatWorkspaceCloseFile`),children:(0,I.jsx)(rn,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(Ua,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function SV({tabs:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,I.jsx)(xV,{tab:e},e.key))})})}function CV({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:r(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function wV({breadcrumb:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,I.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(`span`,{className:r(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,I.jsx)(Vn,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Mn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Sn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,I.jsx)(CV,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(CV,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function TV(e){let t=e.path?.trim()??``;return at({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>ze({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function EV(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function DV(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:aR({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function OV(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=lR({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function kV({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:r(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function AV({diffBlock:e}){return e?(0,I.jsx)(jV,{block:e}):(0,I.jsx)(kV,{text:s(`chatWorkspaceDiffEmpty`)})}function jV({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(BP,{block:e,layout:`workspace`})})}function MV({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(kV,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(kV,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(kV,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,I.jsx)(AN,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(jV,{block:t}):(0,I.jsx)(kV,{text:s(`chatWorkspacePreviewEmpty`)})}function NV({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=TV({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?OV(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=EV({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:DV({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsx)(wV,{breadcrumb:(0,F.useMemo)(()=>Az({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,I.jsx)(AV,{diffBlock:a}):(0,I.jsx)(MV,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var PV={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function FV(){let[e,t]=(0,F.useState)(PV),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??s(`confirm`),cancelLabel:e.cancelLabel??s(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,F.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,F.useCallback)(()=>(0,I.jsx)(Yt,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function IV(e){return u(e??void 0)}function LV(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function RV(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function zV(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${RV(t.everyMs)}`:t.kind===`at`?`at ${LV(t.atMs)}`:`-`}function BV(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function VV(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function HV(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function UV({jobs:e}){let t=Os(),{confirm:n,ConfirmDialog:r}=FV(),i=async e=>{await n({title:`${s(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:s(`delete`)})&&t.mutate({id:e.id})};return(0,I.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:s(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[s(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:s(`chatWorkspaceCronJobEmpty`)}):(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,I.jsxs)(M,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,I.jsx)(xr,{className:`h-3.5 w-3.5`}),s(`delete`)]})]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronScheduleLabel`),`:`]}),` `,zV(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,IV(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,IV(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronDeliverTo`),`:`]}),` `,BV(e)]})]}),(0,I.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,I.jsx)(r,{})]})}function WV({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=_V(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=hP({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,I.jsx)(Zn,{className:`mr-2 h-4 w-4 animate-spin`}),s(`chatChildSessionLoading`)]}):r.hydrateError?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:s(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(_B,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function GV({value:e}){return(0,I.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,I.jsx)(`span`,{className:`truncate`,children:e})})}function KV({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,I.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,I.jsx)(GV,{value:e},e))}):null,e.projectRoot?(0,I.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function qV({tab:e}){return(0,I.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,I.jsx)(uB,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(zn,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(KV,{tab:e})]})}function JV(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:c,onCloseFile:l,onSelectCronJobs:u}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:ZI({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:vV(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>c(e.key),onClose:()=>l(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:s(`chatWorkspaceSessionCronJobs`),tooltip:s(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:u}]:[];return[...d,...f,...p]}function YV({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:c=[],sessionProjectRoot:l,displayMode:u=`docked`}){let d=sd(),f=RB(t),p=tL(e=>e.optimisticReadAtBySessionKey),m=yV({activeChildSessionKey:n,activeWorkspaceFileKey:a,activePanelKind:o,childSessionTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length}),h=f.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(m?.kind!==`child-session`||m.tab.runStatus===`running`)return;let e=m.tab.lastMessageAt?.trim()??null;e&&d.chatSessionListManager.markSessionRead(m.tab.sessionKey,e,m.tab.readAt??null)},[m,d]);let g=(0,F.useMemo)(()=>JV({resolvedChildTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length,activeSelection:m,optimisticReadAtBySessionKey:p,onSelectSession:d.chatThreadManager.selectChildSessionDetail,onSelectFile:d.chatThreadManager.selectWorkspaceFile,onCloseFile:d.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&d.chatThreadManager.openSessionCronPanel(e)}}),[m,p,d.chatThreadManager,f,e,i,c.length]);return m?(0,I.jsxs)(pt,{className:r(u===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:u===`overlay`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:d.chatThreadManager.goToParentSession,className:r(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!h&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:s(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:d.chatThreadManager.closeWorkspacePanel,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chatWorkspaceClosePanel`),children:(0,I.jsx)(rn,{className:`h-4 w-4`})})]}),(0,I.jsx)(SV,{tabs:g}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:m.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qV,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(WV,{sessionKey:m.tab.sessionKey,onToolAction:d.chatThreadManager.openSessionFromToolAction,onFileOpen:d.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,I.jsx)(NV,{file:m.file,sessionProjectRoot:l,onFileOpen:d.chatThreadManager.openFilePreview}):(0,I.jsx)(UV,{jobs:c})})]}):null}function XV({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var ZV=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function QV(){return(0,I.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,I.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(XV,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:ZV.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(XV,{"data-testid":`chat-conversation-skeleton-bubble`,className:r(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,I.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(XV,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(XV,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,I.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,I.jsx)(XV,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(XV,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(XV,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(XV,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(XV,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(XV,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function $V(){let e=sd(),t=Q(e=>e.snapshot);return(0,I.jsxs)(I.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,I.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:s(`chatModelNoOptions`)}),(0,I.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:s(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,I.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function eH(){let e=sd(),t=Z(e=>e.snapshot.defaultSessionType),n=Q(e=>e.snapshot),r=(0,F.useRef)(null),i=n.threadRef??r,a=n.availableAgents??[],o=!n.canDeleteSession&&!n.hasSubmittedDraftMessage&&n.messages.length===0&&!n.isSending,s=n.isHistoryLoading&&n.messages.length===0&&!n.isSending&&!n.isAwaitingAssistantOutput,c=e=>a.find(t=>t.id===e)??null,l=()=>{let r=NB(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(NB(c(n),t))},{onScroll:d}=hP({scrollRef:i,resetKey:n.sessionKey,isLoading:n.isHistoryLoading,hasContent:n.messages.length>0,contentVersion:n.messages[n.messages.length-1]??null}),f=n.messages.length>0,p=f&&n.isSending&&n.isAwaitingAssistantOutput;return(0,I.jsx)(`div`,{ref:i,onScroll:d,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:o?(0,I.jsx)(id,{onCreateSession:l,agents:a,selectedAgentId:n.agentId??`main`,onSelectAgent:u}):s||!f?null:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,I.jsx)(_B,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function tH(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function nH(e){let t=(0,F.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,F.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=Ds({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>HV(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:tH(e,t,n,i.length)}}function rH(){let e=sd(),t=Q(e=>e.snapshot);return(0,I.jsx)(kB,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function iH({layoutMode:e,onBackToList:t}){let n=sd(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=nH(r),o=!!(r.sessionKey||r.sessionTypeLabel),c=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||s(`chatSidebarNewTask`),l=r.agentId?.trim()??``,u=l.length>0&&l.toLowerCase()!==`main`;return(0,I.jsx)(AB,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:l,sessionHeaderTitle:c,shouldShowHeaderAgentAvatar:u,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function aH({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=nH(t);return a?(0,I.jsx)(YV,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function oH({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsx)(rH,{}),(0,I.jsx)(iH,{layoutMode:e,onBackToList:t}),(0,I.jsx)($V,{}),(0,I.jsx)(eH,{}),(0,I.jsx)(_L,{})]}),(0,I.jsx)(aH,{layoutMode:e})]}):(0,I.jsx)(QV,{})}var sH={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function cH({status:e,className:t}){let n=sH[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(Ba,{delayDuration:250,children:(0,I.jsxs)(Va,{children:[(0,I.jsx)(Ha,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":i,className:r(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)(Zn,{className:r(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:r(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(Ua,{side:`bottom`,className:`text-xs`,children:i})]})})}function lH(){let e=vB();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function uH(){let e=lH(),[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function dH(e,t){return e.filter(e=>$u(e,t))}function fH(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function pH(e={}){let t=tL(e=>e.snapshot.query),n=Ts({limit:e.limit??200}),r=(0,F.useMemo)(()=>dH($z(n.data?.sessions??[]).filter(fH),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function mH(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,I.jsx)(nd,{session:g,active:y,showUnreadDot:ZI({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Mu(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function hH(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function gH(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(M,{variant:`primary`,className:r(`min-w-0 rounded-xl`,i.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{o(!1),c(n)},children:[(0,I.jsx)(nn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(Ai,{open:a,onOpenChange:o,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(xn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,I.jsx)(zu,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Zt,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function _H(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=hH({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=u.length>1;return(0,I.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,I.jsx)(Zt,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,I.jsxs)(Ai,{open:a,onOpenChange:o,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsx)(M,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),children:(0,I.jsx)(nn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Mi,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:s(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,I.jsx)(zu,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(M,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,I.jsx)(nn,{className:`h-4 w-4`})})]})})}function vH({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:c,languageOptions:l,onSelectLanguage:u,onOpenDocs:d,onOpenApps:f}){let p=()=>{d(),t(!1)},m=()=>{f(),t(!1)};return(0,I.jsxs)(Ai,{open:e,onOpenChange:t,children:[(0,I.jsx)(ji,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,I.jsx)(dr,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:s(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,c]})]})}),(0,I.jsxs)(Mi,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(gt,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(dr,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`settings`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(Qt,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`docBrowserHelp`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:m,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)($t,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`appsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(yH,{icon:rr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(yH,{icon:Yn,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function yH({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(yl,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(xl,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,I.jsx)(Sn,{className:`h-4 w-4 text-gray-400`}),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`text-left`,children:t})]}),(0,I.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,I.jsx)(wl,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,I.jsx)(El,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function bH(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function xH(e){return[...e].sort((e,t)=>bH(t)-bH(e))}function SH(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],c=[],l=[];for(let t of e){let e=bH(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:s(`chatSidebarToday`),items:a}),o.length>0&&u.push({label:s(`chatSidebarYesterday`),items:o}),c.length>0&&u.push({label:s(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:s(`chatSidebarOlder`),items:l}),u}function CH(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=bH(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||Cz(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:xH(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function wH(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>bH(t)-bH(e));return t}function TH(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var EH=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:mn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:ht},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:vn}];function DH(e,t,n){let r=tL(e=>e.optimisticReadAtBySessionKey);return(0,F.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r||r.runStatus===`running`)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function OH({variant:e=`desktop`}){let n=e===`mobile`,i=sd(),a=un(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=tL(e=>e.snapshot),p=xe(),m=aB(),{isLoading:h,items:g}=pH(),{language:_,setLanguage:v}=No(),{theme:y,setTheme:b}=ru(),x=s(Zo.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Zo.map(e=>({value:e.value,label:s(e.labelKey)})),[]),w=(0,F.useMemo)(()=>t.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),E=(0,F.useMemo)(()=>xH(g),[g]),ee=(0,F.useMemo)(()=>wH(g),[g]),D=(0,F.useMemo)(()=>SH(E),[E]),O=(0,F.useMemo)(()=>CH(E),[E]),k=d.defaultSessionType||`native`,te=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==k),[k,d.sessionTypeOptions]),A=f.listMode===`project-first`,ne=DH(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:j,draftLabel:re,savingSessionKey:M,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:oe,saveSessionLabel:se}=uH(),ce=e=>{_!==e&&(v(e),window.location.reload())},le=e=>(0,I.jsx)(mH,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:ne,agentsById:T,childSessionsByParentKey:ee,editingSessionKey:j,draftLabel:re,savingSessionKey:M,sessionTitle:TH,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:se,onCancelEditingSessionLabel:oe},e.session.key),ue=(e,t)=>{i.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:r(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!n&&!fu()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Ns,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(cH,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(_H,{query:f.query,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:ue,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(gH,{query:f.query,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:ue,onQueryChange:i.chatSessionListManager.setQuery}),n?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:EH.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Al,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,I.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:s(`chatSidebarTaskRecords`)}),(0,I.jsx)(bu,{isProjectFirstView:A,onSelectMode:i.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:s(`sessionsLoading`)}):A?O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(er,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(Vu,{groups:O,defaultSessionType:k,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:le,onCreateSession:ue}):D.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(er,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(le)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(vH,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:ce,onOpenDocs:()=>a.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),onOpenApps:()=>xo(a)})})]})}function kH(){return at({queryKey:[`ncp-session-types`],queryFn:pe,staleTime:1e4,retry:!1})}function AH(e){let t=e.trim();return t.length>0?t:null}function jH(e){return e??null}var MH=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=tL.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:AH(e.selectedModel),preferredThinking:jH(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},NH=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new MH(Qe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>oL(rt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=FI(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:AI(e),selectedSkills:jI(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:AI(e),selectedSkills:jI(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(kI(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=PI(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=PI(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=tL.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=II(e.composerNodes,i);if(GI({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(OI()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=MB(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(NI(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),zI.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{BI.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},PH=`sid_`,FH=`/chat/draft`,IH=FH.slice(6);function LH(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${PH}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function RH(e){if(!e.startsWith(PH))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function zH(e){if(!e||e===IH)return null;let t=RH(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function BH(e){return`/chat/${LH(e)}`}var VH=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=tL.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=tL.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=tL.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=tL.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(tL.getState().markSessionRead(r,i),Qe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=Sz(t);this.streamActionsManager.resetStreamState(),tL.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(FH)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=tL.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=tL.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&tL.getState().setSnapshot({query:n})}}},HH=async()=>{},UH=()=>{},WH=class{constructor(){this.actions={sendMessage:HH,stopCurrentRun:HH,resumeRun:HH,resetStreamState:UH,applyHistoryMessages:UH},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},GH=async e=>!1,KH=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:GH},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`||this.state.pathname===`/chat/draft`,this.goToSession=(e,t)=>{this.navigateTo(BH(e),t)}}},qH=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{tL.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(tL.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=tL.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||tL.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>Lo.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=tL.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await Le(e),De(w,e),w.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},JH=class{constructor(){this.chatUiManager=new KH,this.chatStreamActionsManager=new WH,this.chatSessionListManager=new VH(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new NH(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new qH(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function YH(e){return e?.trim().toLowerCase()||`native`}function XH(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function ZH(e,t){return typeof t==`string`&&e.includes(t)}function QH(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function $H(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function eU(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:$H({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>XH(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function tU(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:$H({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>ZH(t,e),firstAvailableValue:QH(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function nU(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=YH(r),o,s=-1/0;for(let e of t){if(e.key===n||YH(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function rU(e){return e.map(e=>e==null?``:String(e)).join(``)}function iU(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,F.useRef)(void 0),l=(0,F.useRef)(s),u=(0,F.useRef)(n);l.current=s,(0,F.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function aU(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;iU({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:rU([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>eU({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function oU(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;iU({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:rU([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>tU({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function sU(){let{pathname:e}=ct(),t=lt();return Wo(e)?(0,I.jsx)(oH,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(OH,{variant:`mobile`})}var cU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yTfN7UBH.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function lU({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserRenderers:a={},children:o}){let s=Uo(e),c=t&&!Wo(e),l=fu();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,l?`rounded-[10px]`:null),style:l?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":s?`280px`:`240px`}:void 0,children:[l?(0,I.jsx)(cu,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!s&&(0,I.jsx)(ou,{mode:`settings`}),(0,I.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,I.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:s?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:o}):(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:o})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(cU,{customTabRenderers:a})}):null]})]}),c?(0,I.jsx)(hu,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(cU,{customTabRenderers:a})}):null]})}var uU=`NextClaw`,dU=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function fU(e,t){return e===t||e.startsWith(`${t}/`)}function pU(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of dU)if(fU(t,e))return s(n);return s(`settings`)}function mU(e){return`${uU} - ${pU(e)}`}function hU({children:e}){let{isOpen:t,mode:n}=un();Ao();let{pathname:r}=ct(),{language:i}=No(),{isMobile:a}=Ro(),o=du();return(0,F.useEffect)(()=>{document.title=mU(r)},[r,i]),a&&o!==`win32`?(0,I.jsx)(vu,{pathname:r,isDocBrowserOpen:t,docBrowserRenderers:So,topbarLeadingInset:o===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(lU,{pathname:r,isMobileLayout:a,isDocBrowserOpen:t,docBrowserMode:n,docBrowserRenderers:So,children:e})}function gU({children:e}){return(0,I.jsx)(fn,{children:(0,I.jsx)(hU,{children:e})})}function _U(){let{isMobile:e}=Ro();return e?(0,I.jsx)(yu,{}):(0,I.jsx)(st,{to:`/model`,replace:!0})}function vU(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function yU(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function bU(e,t){e&&vU(t)&&e.invalidateQueries({queryKey:[`config`]}),yU(e,t)}function xU(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=N.eventBus.on(b.connectionOpen,()=>{rt.handleConnectionRestored(),Ue.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=N.eventBus.on(b.connectionClose,()=>{rt.handleConnectionInterrupted(null),t.current=!0}),i=N.eventBus.on(b.connectionError,e=>{rt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=N.eventBus.on(b.configUpdated,({path:t})=>{bU(e,t)}),o=N.eventBus.on(b.runtimeUpdateSnapshot,e=>{Ue.reportSnapshot(e)}),s=N.eventBus.on(b.sessionRunStatus,t=>{Te(e,{type:`session.run-status`,payload:t})}),c=N.eventBus.on(b.sessionSummaryUpsert,t=>{Te(e,{type:`session.summary.upsert`,payload:t})}),l=N.eventBus.on(b.sessionSummaryDelete,t=>{Te(e,{type:`session.summary.delete`,payload:t})}),u=N.eventBus.on(b.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var SU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ModelConfig:e}=await import(`./model-config-BjXMpU9U.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,5,3,14,10,11,15]))).ModelConfig})),CU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ChatPage:e}=await import(`./chat-page-Cpo0AFHb.js`);return{ChatPage:e}},__vite__mapDeps([16,2,1,3,4,5,6,7,8,9,10,11,17,18,13,19,20,21,14,22,23]))).ChatPage})),wU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SearchConfig:e}=await import(`./search-config-Dzpizo-_.js`);return{SearchConfig:e}},__vite__mapDeps([24,2,13,4,3,7,25]))).SearchConfig})),TU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ProvidersList:e}=await import(`./providers-list-C1D5p9kK.js`);return{ProvidersList:e}},__vite__mapDeps([26,2,13,3,4,8,9,25,27,23,15]))).ProvidersList})),EU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-DXH1qYLs.js`);return{ChannelsList:e}},__vite__mapDeps([28,2,13,3,4,5,7,9,25,23,21,15]))).ChannelsList})),DU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page--O0Wq01S.js`);return{RuntimeConfig:e}},__vite__mapDeps([29,2,17,18,13,19,9,3,22,8,30,27]))).RuntimeConfig})),OU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-Be8x1jNy.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([31,2,13,7,3]))).DesktopUpdateConfig})),kU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SecurityConfig:e}=await import(`./api-DruAcori.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),AU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-D1AUSEXX.js`);return{SecretsConfig:e}},__vite__mapDeps([32,2,13,8,3,30]))).SecretsConfig})),jU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{RemoteAccessPage:e}=await import(`./remote-BHeENKxL.js`);return{RemoteAccessPage:e}},[])).RemoteAccessPage})),MU=(0,F.lazy)(async()=>({default:(await ft(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-WUkc7n94.js`);return{McpMarketplacePage:e}},__vite__mapDeps([33,20,2,17,18,13,19,9,3,10,11,21]))).McpMarketplacePage}));function NU(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function PU({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(NU,{}),children:e})}function FU(e){return(0,I.jsx)(PU,{children:e})}var IU=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:FU((0,I.jsx)(CU,{view:`chat`}))},{path:`/agents`,element:FU((0,I.jsx)(CU,{view:`agents`}))},{path:`/skills`,element:FU((0,I.jsx)(CU,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:FU((0,I.jsx)(CU,{view:`skills`}))},{path:`/cron`,element:FU((0,I.jsx)(CU,{view:`cron`}))},{path:`/model`,element:FU((0,I.jsx)(SU,{}))},{path:`/search`,element:FU((0,I.jsx)(wU,{}))},{path:`/providers`,element:FU((0,I.jsx)(TU,{}))},{path:`/channels`,element:FU((0,I.jsx)(EU,{}))},{path:`/runtime`,element:FU((0,I.jsx)(DU,{}))},{path:`/updates`,element:FU((0,I.jsx)(OU,{}))},{path:`/remote`,element:FU((0,I.jsx)(jU,{}))},{path:`/security`,element:FU((0,I.jsx)(kU,{}))},{path:`/secrets`,element:FU((0,I.jsx)(AU,{}))},{path:`/language`,element:(0,I.jsx)(au,{})},{path:`/settings`,element:(0,I.jsx)(_U,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:FU((0,I.jsx)(MU,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function LU(e){return`redirectTo`in e?(0,I.jsx)(dt,{path:e.path,element:(0,I.jsx)(st,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(dt,{path:e.path,element:e.element},e.path)}function RU(){return(0,I.jsx)(_t,{children:IU.map(LU)})}function zU(){return xU(w),$e(),(0,F.useEffect)(()=>(Ue.start(),()=>{Ue.stop()}),[]),(0,I.jsxs)(Oo,{children:[(0,I.jsx)(gU,{children:(0,I.jsx)(RU,{})}),(0,I.jsx)(Xr,{}),(0,I.jsx)(Ja,{})]})}function BU(){let e=Ze(),t=e.isError&&Ie(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(zU,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(Zr,{username:e.data.username}):(0,I.jsx)(zU,{})}function VU(){return(0,F.useEffect)(()=>{Ql()},[]),(0,I.jsxs)(ve,{client:w,children:[(0,I.jsx)(BU,{}),(0,I.jsx)(Yl,{}),(0,I.jsx)(Xl,{}),(0,I.jsx)(D,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var HU=window.nextclawDesktop?.platform===`win32`?mt:ut;(0,Tr.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(nu,{children:(0,I.jsx)(Mo,{children:(0,I.jsx)(HU,{children:(0,I.jsx)(VU,{})})})})}));export{ds as $,ar as $t,Sz as A,$i as At,Ku as B,Fr as Bt,aB as C,Va as Ct,$z as D,Zi as Dt,rB as E,Ha as Et,tL as F,Wr as Ft,Jl as G,Dr as Gt,Wu as H,Rr as Ht,Z as I,Br as It,El as J,gr as Jt,yl as K,xr as Kt,lI as L,zr as Lt,AL as M,Mi as Mt,oL as N,ji as Nt,Qz as O,ea as Ot,cL as P,Gr as Pt,us as Q,cr as Qt,od as R,jr as Rt,IB as S,No as St,oB as T,Ba as Tt,Iu as U,Ar as Ut,$u as V,Ir as Vt,Cu as W,Or as Wt,bl as X,dr as Xt,xl as Y,pr as Yt,cs as Z,lr as Zt,_V as _,ps as _t,JH as a,Kn as an,bs as at,NB as b,zo as bt,OH as c,Dn as cn,ys as ct,BV as d,vn as dn,_s as dt,tr as en,hs as et,zV as f,mn as fn,ks as ft,pV as g,Ss as gt,FV as h,ms as ht,oU as i,qn as in,ws as it,TL as j,Ai as jt,Cz as k,Qi as kt,oH as l,xn as ln,As as lt,IV as m,fs as mt,nU as n,Zn as nn,Os as nt,zH as o,Wn as on,Es as ot,VV as p,xs as pt,wl as q,vr as qt,aU as r,Jn as rn,gs as rt,kH as s,On as sn,Ts as st,sU as t,$n as tn,Ds as tt,XV as u,bn as un,vs as ut,FB as v,Cs as vt,sB as w,Ua as wt,PB as x,Ro as xt,MB as y,Bo as yt,sd as z,Pr as zt};