@nextclaw/ui 0.13.9 → 0.13.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/assets/{api-CIJxdHmy.js → api-CA2udGyv.js} +3 -3
  3. package/dist/assets/app-presenter-provider-B9ChYida.js +3 -0
  4. package/dist/assets/arrow-left-CI0Ocu9p.js +1 -0
  5. package/dist/assets/{channels-list-page-C_Xe0CNX.js → channels-list-page-PrT4a9g4.js} +1 -1
  6. package/dist/assets/{chat-page-CXRtoQR2.js → chat-page-CImtIhmN.js} +1 -1
  7. package/dist/assets/{config-split-page-DBAcw9mJ.js → config-split-page-bO0K6uQv.js} +1 -1
  8. package/dist/assets/{confirm-dialog-DwPTxq8C.js → confirm-dialog-l4FYdzga.js} +1 -1
  9. package/dist/assets/{desktop-update-config-BqABa_1C.js → desktop-update-config-p3rJIgRg.js} +1 -1
  10. package/dist/assets/{dist-BfcibKyv.js → dist-DQoV-62W.js} +1 -1
  11. package/dist/assets/{dist-WjhKB-pc.js → dist-T6rf86Nf.js} +1 -1
  12. package/dist/assets/{doc-browser-8EEDwGCJ.js → doc-browser-CTFB6ACN.js} +1 -1
  13. package/dist/assets/{doc-browser-context-DLJOy6Am.js → doc-browser-context-CP2tI-Br.js} +1 -1
  14. package/dist/assets/doc-browser-yi02ASOL.js +1 -0
  15. package/dist/assets/{ellipsis-H-4aNwgt.js → ellipsis-B7CbNPNr.js} +1 -1
  16. package/dist/assets/{es2015-B5k1IpKX.js → es2015-BSPOGpH4.js} +1 -1
  17. package/dist/assets/{external-link-BN1wd-eI.js → external-link-CefT35zP.js} +1 -1
  18. package/dist/assets/{index-WJt0X9wC.js → index-DFC_DdT1.js} +4 -4
  19. package/dist/assets/{key-round-D-7IaAQS.js → key-round-BpM3GZn4.js} +1 -1
  20. package/dist/assets/{loader-circle-CB38Q7Ws.js → loader-circle-_edjOFsw.js} +1 -1
  21. package/dist/assets/mcp-marketplace-page-DNHSmfDf.js +1 -0
  22. package/dist/assets/{mcp-marketplace-page-ju1KH3TG.js → mcp-marketplace-page-DhqcnhZc.js} +1 -1
  23. package/dist/assets/{model-config-CgS6dp65.js → model-config-C9ydDDFh.js} +1 -1
  24. package/dist/assets/{notice-card-DW9BLKpG.js → notice-card-BfXlhPjX.js} +1 -1
  25. package/dist/assets/play-DD0bg50i.js +1 -0
  26. package/dist/assets/plus-zZ2GC_AJ.js +1 -0
  27. package/dist/assets/{popover-ofN845gZ.js → popover-D_pJfOlM.js} +1 -1
  28. package/dist/assets/{provider-scoped-model-input-DaDqi8Zy.js → provider-scoped-model-input-CkeEyTfO.js} +1 -1
  29. package/dist/assets/{providers-list-CZNQXY4n.js → providers-list-9eOBQFUn.js} +1 -1
  30. package/dist/assets/{react-Bq34NL59.js → react-Bl8iJUcF.js} +1 -1
  31. package/dist/assets/{refresh-cw-DJttSXS8.js → refresh-cw-CqfS1EhK.js} +1 -1
  32. package/dist/assets/remote-fGlxrJI_.js +1 -0
  33. package/dist/assets/rotate-cw-C7EvaSlb.js +1 -0
  34. package/dist/assets/{runtime-config-page-gUjM6Z_A.js → runtime-config-page-B30PC6bx.js} +1 -1
  35. package/dist/assets/{save-DtAFbS7x.js → save-CQERCODg.js} +1 -1
  36. package/dist/assets/search-C0b2yzmt.js +1 -0
  37. package/dist/assets/{search-config-C04PrmHj.js → search-config-RN01uPJQ.js} +1 -1
  38. package/dist/assets/{secrets-config-DvxHdz9h.js → secrets-config-CTZ_TGoA.js} +1 -1
  39. package/dist/assets/{status-dot-D4jbKDLB.js → status-dot-DY0xUUvK.js} +1 -1
  40. package/dist/assets/{tabs-Ca2vw7YQ.js → tabs-C77i1w90.js} +1 -1
  41. package/dist/assets/{tabs-custom-DzGDjYxf.js → tabs-custom-CFpR54-m.js} +1 -1
  42. package/dist/assets/{tag-chip-CW-_pHjH.js → tag-chip-Dnb2VuWh.js} +1 -1
  43. package/dist/assets/{tooltip-Cq2mERPk.js → tooltip-fs7VQG7d.js} +1 -1
  44. package/dist/assets/{trash-2-rumaEu9l.js → trash-2-Bb8mTTLl.js} +1 -1
  45. package/dist/assets/x-BV4iiea8.js +1 -0
  46. package/dist/index.html +24 -24
  47. package/package.json +8 -8
  48. package/src/features/panel-apps/components/panel-app-list-item.test.tsx +4 -0
  49. package/src/features/panel-apps/components/panel-apps-list.tsx +27 -1
  50. package/src/features/panel-apps/hooks/use-panel-apps.ts +10 -0
  51. package/src/features/panel-apps/managers/panel-app-bridge.manager.test.ts +18 -40
  52. package/src/features/panel-apps/managers/panel-app-bridge.manager.ts +24 -36
  53. package/src/features/panel-apps/utils/panel-app-view.utils.test.ts +4 -0
  54. package/src/features/right-panel-resources/utils/right-panel-resource-uri.utils.test.ts +4 -0
  55. package/src/features/service-apps/components/service-apps-panel.tsx +3 -3
  56. package/src/shared/lib/api/index.ts +1 -1
  57. package/src/shared/lib/api/{ncp-session-query-cache.test.ts → ncp-session-query-cache.utils.test.ts} +23 -0
  58. package/src/shared/lib/api/{ncp-session-query-cache.ts → ncp-session-query-cache.utils.ts} +9 -11
  59. package/src/shared/lib/api/types.ts +4 -0
  60. package/src/shared/lib/i18n/runtime/doc-browser-labels.utils.ts +5 -0
  61. package/dist/assets/app-presenter-provider-CKZqZfv5.js +0 -3
  62. package/dist/assets/arrow-left-DHcD-tbC.js +0 -1
  63. package/dist/assets/doc-browser-DlT90zQD.js +0 -1
  64. package/dist/assets/mcp-marketplace-page-CmZwt64F.js +0 -1
  65. package/dist/assets/play-DGpH8jeI.js +0 -1
  66. package/dist/assets/plus-CkcQjwuH.js +0 -1
  67. package/dist/assets/remote-CYmsM9DD.js +0 -1
  68. package/dist/assets/rotate-cw-D_xslHna.js +0 -1
  69. package/dist/assets/search-CNMRwAFx.js +0 -1
  70. package/dist/assets/x-DGqjdMUt.js +0 -1
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-DlT90zQD.js","assets/doc-browser-8EEDwGCJ.js","assets/react-Bq34NL59.js","assets/dist-WjhKB-pc.js","assets/tooltip-Cq2mERPk.js","assets/dist-BfcibKyv.js","assets/arrow-left-DHcD-tbC.js","assets/external-link-BN1wd-eI.js","assets/plus-CkcQjwuH.js","assets/search-CNMRwAFx.js","assets/x-DGqjdMUt.js","assets/doc-browser-context-DLJOy6Am.js","assets/model-config-CgS6dp65.js","assets/api-CIJxdHmy.js","assets/loader-circle-CB38Q7Ws.js","assets/provider-scoped-model-input-DaDqi8Zy.js","assets/provider-models-C_yOh6DE.js","assets/config-hints-Ceiol9x4.js","assets/chat-page-CXRtoQR2.js","assets/app-presenter-provider-CKZqZfv5.js","assets/confirm-dialog-DwPTxq8C.js","assets/es2015-B5k1IpKX.js","assets/popover-ofN845gZ.js","assets/key-round-D-7IaAQS.js","assets/refresh-cw-DJttSXS8.js","assets/trash-2-rumaEu9l.js","assets/notice-card-DW9BLKpG.js","assets/status-dot-D4jbKDLB.js","assets/tabs-Ca2vw7YQ.js","assets/mcp-marketplace-page-ju1KH3TG.js","assets/tag-chip-CW-_pHjH.js","assets/ellipsis-H-4aNwgt.js","assets/play-DGpH8jeI.js","assets/tabs-custom-DzGDjYxf.js","assets/search-config-C04PrmHj.js","assets/config-split-page-DBAcw9mJ.js","assets/providers-list-CZNQXY4n.js","assets/channels-list-page-C_Xe0CNX.js","assets/runtime-config-page-gUjM6Z_A.js","assets/rotate-cw-D_xslHna.js","assets/save-DtAFbS7x.js","assets/desktop-update-config-BqABa_1C.js","assets/secrets-config-DvxHdz9h.js","assets/remote-CYmsM9DD.js","assets/mcp-marketplace-page-CmZwt64F.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,y as _}from"./react-Bq34NL59.js";import{A as v,C as y,E as b,F as x,I as S,L as C,M as w,N as T,O as E,P as D,S as O,T as k,a as A,c as ee,i as j,j as te,k as M,l as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce,x as le,z as ue}from"./app-presenter-provider-CKZqZfv5.js";import{$ as de,At as fe,B as pe,Bt as me,Ct as he,Dt as ge,Et as _e,F as ve,Ft as ye,G as be,H as xe,I as Se,It as Ce,J as we,K as Te,L as Ee,Lt as De,M as Oe,N as ke,Nt as Ae,Ot as je,P as Me,Pt as Ne,Q as Pe,Qt as Fe,R as Ie,Rt as Le,Tt as Re,U as ze,V as Be,Vt as Ve,W as He,X as Ue,Y as We,Z as Ge,Zt as Ke,_ as qe,at as Je,bt as Ye,ct as Xe,d as Ze,dt as Qe,et as $e,f as et,ft as tt,g as nt,gt as rt,h as it,ht as at,kt as ot,lt as st,m as ct,n as lt,ot as ut,p as dt,q as ft,st as pt,t as mt,tt as ht,v as gt,vt as _t,xt as vt,y as yt,yt as bt,z as xt,zt as N}from"./api-CIJxdHmy.js";import{_ as St,a as Ct,b as wt,c as P,d as Tt,f as Et,g as Dt,h as Ot,i as kt,l as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,u as It,x as Lt,y as Rt}from"./dist-WjhKB-pc.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./es2015-B5k1IpKX.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-DwPTxq8C.js";import{t as Xt}from"./arrow-left-DHcD-tbC.js";import{n as Zt}from"./doc-browser-8EEDwGCJ.js";import{n as Qt,t as $t}from"./loader-circle-CB38Q7Ws.js";import{a as en,c as tn,i as nn,l as rn,n as an,o as on,r as sn,s as cn,t as ln,u as un}from"./tooltip-Cq2mERPk.js";import{t as dn}from"./external-link-BN1wd-eI.js";import{t as fn}from"./key-round-D-7IaAQS.js";import{t as pn}from"./plus-CkcQjwuH.js";import{t as mn}from"./refresh-cw-DJttSXS8.js";import{t as hn}from"./search-CNMRwAFx.js";import{t as gn}from"./trash-2-rumaEu9l.js";import{t as _n}from"./x-DGqjdMUt.js";import{a as vn,c as yn,i as bn,n as xn,o as Sn,r as Cn,s as wn,t as Tn}from"./popover-ofN845gZ.js";import{c as En,m as Dn,n as On,s as kn,t as An}from"./doc-browser-context-DLJOy6Am.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 jn=e((e=>{var t=o();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`}]]),Nn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Pn=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Fn=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`}]]),In=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`}]]),Ln=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Rn=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),zn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Bn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Vn=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`}]]),Hn=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`}]]),Un=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`}]]),Wn=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`}]]),Gn=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`}]]),Kn=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`}]]),qn=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`}]]),Jn=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`}]]),Yn=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`}]]),Xn=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`}]]),Zn=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`}]]),Qn=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`}]]),$n=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`}]]),er=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`}]]),tr=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`}]]),nr=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`}]]),rr=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`}]]),ir=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`}]]),ar=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`}]]),or=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`}]]),sr=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`}]]),cr=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`}]]),lr=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`}]]),ur=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),dr=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`}]]),fr=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`}]]),pr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),mr=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`}]]),hr=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`}]]),gr=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`}]]),_r=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`}]]),vr=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`}]]),yr=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`}]]),br=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),xr=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`}]]),Sr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Cr=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),wr=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`}]]),Tr=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`}]]),Er=jn(),F=_(a(),1);function Dr(){let e=On();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;Dn(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 I=l(),Or=(0,F.createContext)(null);function kr({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)(Or.Provider,{value:o,children:e})}function Ar(){let e=(0,F.useContext)(Or);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function jr(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function Mr(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:jr(e),width:e}}var Nr=m(()=>Mr()),Pr=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=()=>Nr.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Nr.setState(Mr())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Nr.setState({width:e,mode:jr(e)})}}};function Fr(){return(0,F.useEffect)(()=>Pr.attach(),[]),{isMobile:Nr(e=>e.mode)===`mobile`}}var Ir=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Lr=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Ir.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Ir.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Ir.setState({supported:!0,initialized:!0,busyAction:null}),N.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Ir.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));Ir.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return Ir.setState({supported:!0,initialized:!0,snapshot:n}),N.success(s(`runtimePresenceSaved`)),n}catch(e){throw N.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Ir.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Rr=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){Rr.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Rr.setState({supported:!0,initialized:!0,snapshot:e})}),Rr.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Rr.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Rr.setState({supported:!0,initialized:!0}),N.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`){N.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){N.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){N.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&N.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`&&N.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(Rr.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){N.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}N.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Rr.setState({busyAction:e});try{let e=await n(r);return Rr.setState({snapshot:e}),e}catch(e){throw N.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Rr.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 zr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Br(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 Vr(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Hr(e){return[{target:`/chat`,label:e(`chat`),icon:ur},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:e(`agentsPageTitle`),icon:Fn},{target:`/settings`,label:e(`settings`),icon:vr}]}function Ur(e){return[{target:`/model`,label:e(`model`),icon:Un},{target:`/providers`,label:e(`providers`),icon:xr},{target:`/channels`,label:e(`channels`),icon:fr},{target:`/search`,label:e(`searchChannels`),icon:hn},{target:`/runtime`,label:e(`runtime`),icon:Un},{target:`/updates`,label:e(`updates`),icon:Wn},{target:`/remote`,label:e(`remote`),icon:Tr},{target:`/security`,label:e(`security`),icon:yr},{target:`/secrets`,label:e(`secrets`),icon:fn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:O}]}function Wr(e){return[{target:`/language`,label:e(`language`),icon:lr},...Ur(e)]}function Gr(e){let t=e.toLowerCase();return t===`/settings`?!0:Wr(e=>e).some(e=>zr(t,e.target))}function Kr(e,t){let n=e.toLowerCase(),r=Wr(t);if(Vr(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(zr(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var qr=`nextclaw.ui.theme`,Jr=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Yr=`warm`,Xr=!1,Zr=new Set;function Qr(e){return e===`warm`||e===`cool`}function $r(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function ei(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(qr);if(Qr(e))return e}catch{}return`warm`}function ti(){return Xr||=(Yr=ei(),$r(Yr),!0),Yr}function ni(){return Xr?Yr:ti()}function ri(e){if(ti(),e!==Yr){if(Yr=e,$r(Yr),typeof window<`u`)try{window.localStorage.setItem(qr,Yr)}catch{}Zr.forEach(e=>e(Yr))}}function ii(e){return Zr.add(e),()=>{Zr.delete(e)}}function ai(){return Ve({queryKey:[`config`],queryFn:Ee,staleTime:3e4,refetchOnWindowFocus:!0})}function oi(){return Ve({queryKey:[`app-meta`],queryFn:Se,staleTime:1/0})}function si(){return Ve({queryKey:[`config-meta`],queryFn:Ie,staleTime:1/0})}function ci(){return Ve({queryKey:[`providers`],queryFn:ze,staleTime:3e4,refetchOnWindowFocus:!0})}function li(){return Ve({queryKey:[`provider-templates`],queryFn:xe,staleTime:1/0})}function ui(){return Ve({queryKey:[`config-schema`],queryFn:xt,staleTime:1/0})}function di(){let e=Fe();return me({mutationFn:Ge,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function fi(){let e=Fe();return me({mutationFn:({data:e})=>$e(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function pi(){let e=Fe();return me({mutationFn:({provider:e,data:t})=>Pe(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),n.silentSuccess||N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function mi(){let e=Fe();return me({mutationFn:({data:e})=>Oe(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function hi(){let e=Fe();return me({mutationFn:({provider:e})=>Me(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function gi(){return me({mutationFn:({provider:e,data:t})=>We(e,t)})}function _i(){return me({mutationFn:({provider:e,data:t})=>we(e,t)})}function vi(){return me({mutationFn:({provider:e,data:t})=>be(e,t)})}function yi(){return me({mutationFn:({provider:e})=>He(e)})}function bi(){let e=Fe();return me({mutationFn:({channel:e,data:t})=>Ue(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplying`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function xi(){let e=Fe();return me({mutationFn:({data:e})=>de(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Si(){let e=Fe();return me({mutationFn:({data:e})=>ht(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Ci(){return me({mutationFn:({actionId:e,data:t})=>ve(e,t),onError:e=>{N.error(s(`error`)+`: `+e.message)}})}function wi(e){return Ve({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>qe(e),staleTime:5e3,retry:!1})}function Ti(e){return Ve({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>nt(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ei(e={all:!0}){return Ve({queryKey:[`cron`,e],queryFn:()=>pe(e),staleTime:1e4})}function Di(){let e=Fe();return me({mutationFn:({id:e})=>ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Oi(){let e=Fe();return me({mutationFn:({id:e,enabled:t})=>ft(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function ki(){let e=Fe();return me({mutationFn:({id:e,force:t})=>Te(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}var Ai={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 ji(){let e=_t(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=()=>{e.tone!==`healthy`&&vt.requestRuntimeBootstrapProbeNow()},i=async()=>{if(t)try{let e=await vt.runRuntimeControlAction(`restart-service`);N.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);N.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(Tn,{children:[(0,I.jsx)(Cn,{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`,onClick:n,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,Ai[e.tone])})})}),(0,I.jsxs)(xn,{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 i(),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 Mi({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=oi(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(ji,{}),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)(Ni,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Pi,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Ni({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 Pi(){let{supported:e,busyAction:t,snapshot:n}=rt();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Fi,{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 at.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 at.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Fi({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Ii,{snapshot:e});let t=e.status===`downloading`?Li(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 Ii({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 Li(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Ri=_(o(),1);function zi(e,[t,n]){return Math.min(n,Math.max(t,e))}function Bi(e){let t=e+`CollectionProvider`,[n,r]=Rt(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=Nt(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:wt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Nt(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=wt(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 Vi=F.createContext(void 0);function Hi(e){let t=F.useContext(Vi);return e||t||`ltr`}function Ui(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 Wi=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Gi=[` `,`Enter`],Ki=`Select`,[qi,Ji,Yi]=Bi(Ki),[Xi,Zi]=Rt(Ki,[Yi,Ft]),Qi=Ft(),[$i,ea]=Xi(Ki),[ta,na]=Xi(Ki),ra=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=Qi(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Hi(l),[C,w]=Ot({prop:r,defaultProp:i??!1,onChange:a,caller:Ki}),[T,E]=Ot({prop:o,defaultProp:s,onChange:c,caller:Ki}),D=F.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=F.useState(new Set),ee=Array.from(k).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)($i,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Dt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,I.jsx)(qi.Provider,{scope:t,children:(0,I.jsx)(ta,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,I.jsxs)(Qa,{"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(k)]},ee):null]})})};ra.displayName=Ki;var ia=`SelectTrigger`,aa=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Qi(n),o=ea(ia,n),s=o.disabled||r,c=wt(t,o.onTriggerChange),l=Ji(n),u=F.useRef(`touch`),[d,f,p]=eo(e=>{let t=l().filter(e=>!e.disabled),n=to(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)(Et.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":$a(o.value)?``:void 0,...i,ref:c,onClick:Lt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Lt(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:Lt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Wi.includes(e.key)&&(m(),e.preventDefault())})})})});aa.displayName=ia;var oa=`SelectValue`,sa=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=ea(oa,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=wt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Et.span,{...s,ref:d,style:{pointerEvents:`none`},children:$a(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});sa.displayName=oa;var ca=`SelectIcon`,la=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Et.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});la.displayName=ca;var ua=`SelectPortal`,da=e=>(0,I.jsx)(At,{asChild:!0,...e});da.displayName=ua;var fa=`SelectContent`,pa=F.forwardRef((e,t)=>{let n=ea(fa,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Ri.createPortal((0,I.jsx)(ha,{scope:e.__scopeSelect,children:(0,I.jsx)(qi.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(ya,{...e,ref:t})});pa.displayName=fa;var ma=10,[ha,ga]=Xi(fa),_a=`SelectContentImpl`,va=Nt(`SelectContent.RemoveScroll`),ya=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=ea(fa,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=wt(t,e=>b(e)),[w,T]=F.useState(null),[E,D]=F.useState(null),O=Ji(n),[k,A]=F.useState(!1),ee=F.useRef(!1);F.useEffect(()=>{if(y)return Ht(y)},[y]),Vt();let j=F.useCallback(e=>{let[t,...n]=O().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},[O,x]),te=F.useCallback(()=>j([w,y]),[j,w,y]);F.useEffect(()=>{k&&te()},[k,te]);let{onOpenChange:M,triggerPointerDownPosRef:ne}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ne.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ne.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||M(!1),document.removeEventListener(`pointermove`,t),ne.current=null};return ne.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,M,ne]),F.useEffect(()=>{let e=()=>M(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[M]);let[re,ie]=eo(e=>{let t=O().filter(e=>!e.disabled),n=to(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(ee.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ce=r===`popper`?Ca:xa,le=ce===Ca?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(ha,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:te,selectedItemText:E,position:r,isPositioned:k,searchRef:re,children:(0,I.jsx)(Bt,{as:va,allowPinchZoom:!0,children:(0,I.jsx)(zt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Lt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(It,{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:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Lt(_.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=O().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(()=>j(t)),e.preventDefault()}})})})})})})});ya.displayName=_a;var ba=`SelectItemAlignedPosition`,xa=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=ea(fa,n),o=ga(fa,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=wt(t,e=>u(e)),f=Ji(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-ma,d=zi(a,[ma,Math.max(ma,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-ma,d=zi(a,[ma,Math.max(ma,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-ma*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-ma,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,ee=x-A;if(A<=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=A+Math.max(D,O+(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)+O)+ee;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${ma}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)(wa,{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)(Et.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});xa.displayName=ba;var Sa=`SelectPopperPosition`,Ca=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=ma,...a}=e,o=Qi(n);return(0,I.jsx)(Ct,{...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)`}})});Ca.displayName=Sa;var[wa,Ta]=Xi(fa,{}),Ea=`SelectViewport`,Da=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ga(Ea,n),o=Ta(Ea,n),s=wt(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)(qi.Slot,{scope:n,children:(0,I.jsx)(Et.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Lt(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-ma*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})})})]})});Da.displayName=Ea;var Oa=`SelectGroup`,[ka,Aa]=Xi(Oa),ja=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Dt();return(0,I.jsx)(ka,{scope:n,id:i,children:(0,I.jsx)(Et.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ja.displayName=Oa;var Ma=`SelectLabel`,Na=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Aa(Ma,n);return(0,I.jsx)(Et.div,{id:i.id,...r,ref:t})});Na.displayName=Ma;var Pa=`SelectItem`,[Fa,Ia]=Xi(Pa),La=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=ea(Pa,n),c=ga(Pa,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=wt(t,e=>c.itemRefCallback?.(e,r,i)),h=Dt(),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)(Fa,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(qi.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Et.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:Lt(o.onFocus,()=>p(!0)),onBlur:Lt(o.onBlur,()=>p(!1)),onClick:Lt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Lt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Lt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Lt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Lt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Gi.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});La.displayName=Pa;var Ra=`SelectItemText`,za=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=ea(Ra,n),s=ga(Ra,n),c=Ia(Ra,n),l=na(Ra,n),[u,d]=F.useState(null),f=wt(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)(Et.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ri.createPortal(a.children,o.valueNode):null]})});za.displayName=Ra;var Ba=`SelectItemIndicator`,Va=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Ia(Ba,n).isSelected?(0,I.jsx)(Et.span,{"aria-hidden":!0,...r,ref:t}):null});Va.displayName=Ba;var Ha=`SelectScrollUpButton`,Ua=F.forwardRef((e,t)=>{let n=ga(Ha,e.__scopeSelect),r=Ta(Ha,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(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)(Ka,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ua.displayName=Ha;var Wa=`SelectScrollDownButton`,Ga=F.forwardRef((e,t)=>{let n=ga(Wa,e.__scopeSelect),r=Ta(Wa,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(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)(Ka,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ga.displayName=Wa;var Ka=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ga(`SelectScrollButton`,n),o=F.useRef(null),s=Ji(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)(Et.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Lt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Lt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Lt(i.onPointerLeave,()=>{c()})})}),qa=`SelectSeparator`,Ja=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Et.div,{"aria-hidden":!0,...r,ref:t})});Ja.displayName=qa;var Ya=`SelectArrow`,Xa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Qi(n),a=ea(Ya,n),o=ga(Ya,n);return a.open&&o.position===`popper`?(0,I.jsx)(kt,{...i,...r,ref:t}):null});Xa.displayName=Ya;var Za=`SelectBubbleInput`,Qa=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=wt(r,i),o=Ui(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)(Et.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});Qa.displayName=Za;function $a(e){return e===``||e===void 0}function eo(e){let t=Tt(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 to(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=no(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 no(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ro=ra,io=aa,ao=sa,oo=la,so=da,co=pa,lo=Da,uo=ja,fo=Na,po=La,mo=za,ho=Va,go=Ua,_o=Ga,vo=Ja,yo=ro,bo=ao,xo=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(io,{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)(oo,{asChild:!0,children:n??(0,I.jsx)(Rn,{className:`h-4 w-4 opacity-50`})})]}));xo.displayName=io.displayName;var So=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Bn,{className:`h-4 w-4`})}));So.displayName=go.displayName;var Co=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Rn,{className:`h-4 w-4`})}));Co.displayName=_o.displayName;var wo=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(so,{children:(0,I.jsxs)(co,{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)(So,{}),(0,I.jsx)(lo,{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)(Co,{})]})}));wo.displayName=co.displayName;var To=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fo,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));To.displayName=fo.displayName;var Eo=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(po,{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)(ho,{children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsx)(mo,{children:t})]}));Eo.displayName=po.displayName;var Do=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vo,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Do.displayName=vo.displayName;var Oo={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 ko(e){return Oo[e]}function Ao({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=ko(i);return(0,I.jsx)(w,{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 jo({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=ko(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 Mo({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=ko(o);return(0,I.jsxs)(yo,{value:n,onValueChange:a,children:[(0,I.jsxs)(xo,{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)(wo,{children:s})]})}var No=`nextclaw-pwa-install-banner-dismissed`,Po=`nextclaw-pwa-install-banner-dismissed-until`;function Fo(){let e=Ro();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:zo(e):!1}function Io(){let e=Ro();e?.setItem(No,`1`),e?.removeItem(Po)}function Lo(){let e=Ro();e?.removeItem(No),e?.removeItem(Po)}function Ro(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function zo(e){let t=e.getItem(Po);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Po),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(No,`1`),!0)}function Bo(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Fo(),updateAvailable:!1,registrationFailed:!1}}var Vo=m(()=>Bo()),Ho=`nextclaw-pwa-dev-sw-reset`,Uo=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{Vo.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){Vo.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;Vo.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:Vo.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(Ho)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(Ho,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(Ho)}catch{}}}},Wo=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(),Vo.setState(Bo())},this.refreshState=()=>{let e=this.resolveInstallability();Vo.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Fo()})),Uo.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Io(),Vo.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`?(Lo(),this.refreshState(),N.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Lo(),Vo.setState({dismissedInstallPrompt:!0}),N.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 Go(){let e=Vo(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:Ko(e)})}function Ko(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function qo(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 Jo(){let e=Vo(e=>e.installability),t=Vo(e=>e.installMethod),n=Vo(e=>e.blockedReason);return(0,I.jsxs)(_e,{children:[(0,I.jsxs)(ot,{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)(fe,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(je,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Go,{})]}),(0,I.jsxs)(ge,{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:qo(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,className:`gap-2`,onClick:()=>{Wo.promptInstall()},children:[(0,I.jsx)(Wn,{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)(br,{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 Yo(){let e=Vo(e=>e.installability),t=Vo(e=>e.installMethod),n=Vo(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:()=>{Wo.dismissInstallPrompt()},children:(0,I.jsx)(_n,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Wo.promptInstall()},children:[(0,I.jsx)(Wn,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(ye,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Wo.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}function Xo(){let e=Vo(e=>e.updateAvailable),t=Vo(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)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Uo.applyUpdate()},children:[(0,I.jsx)(mn,{className:`h-4 w-4`}),s(`pwaUpdateAction`)]})})]})}var Zo=!1;function Qo(){Zo||typeof window>`u`||(Zo=!0,Wo.start(),Uo.start())}var $o={warm:`#F9F8F5`,cool:`#F8FAFB`},es=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=$o[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)}}},ts=(0,F.createContext)(null);function ns({children:e}){let[t,n]=(0,F.useState)(()=>ti());(0,F.useEffect)(()=>{es.syncTheme(t)},[t]),(0,F.useEffect)(()=>ii(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{ri(e),n(ni())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(ts.Provider,{value:i,children:e})}function rs(){let e=(0,F.useContext)(ts);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function is(){let{language:e,setLanguage:n}=Ar();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 as(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=is();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)(lr,{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)(Ln,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function os({mode:e}){let t=re(),n=On(),i=le(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=is(),{theme:u,setTheme:d}=rs(),f=e===`settings`,p=s(Jr.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:ur},{target:`/chat/cron`,label:s(`cron`),icon:Mn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:s(`agentsPageTitle`),icon:Fn}],v=Ur(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)(w,{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)(Mi,{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)(Ao,{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)(jo,{onClick:()=>t.accountManager.openAccountPanel(),icon:fn,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)(Ao,{to:`/settings`,label:s(`settings`),icon:vr})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Mo,{value:u,onValueChange:e=>g(e),icon:mr,label:s(`theme`),valueLabel:p,density:b,children:Jr.map(e=>(0,I.jsx)(Eo,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Mo,{value:a,onValueChange:e=>l(e),icon:lr,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(Eo,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(jo,{onClick:()=>n.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var ss=[{action:`minimize`,label:`Minimize`,icon:pr},{action:`close`,label:`Close`,icon:_n,variant:`danger`}];function cs(){let e=us()?{action:`toggle-maximize`,label:`Restore`,icon:Hn}:{action:`toggle-maximize`,label:`Maximize`,icon:Sr};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)(Mi,{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:[ss[0],e,ss[1]].map(e=>(0,I.jsx)(ls,{control:e},e.action))})]})}function ls({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 us(){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 ds(){return typeof window>`u`?null:ps()??window.nextclawDesktop?.platform??null}function fs(){return ds()===`win32`}function ps(){return null}function ms(e,t){if(t===`/settings`)return Gr(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function hs(){let{pathname:e}=S(),t=Hr(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=ms(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(v,{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 gs({leadingInset:e}){let t=C(),{pathname:n}=S(),r=Kr(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 _s=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DlT90zQD.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function vs({pathname:e,isDocBrowserOpen:t,docBrowserDockControls:n,docBrowserRenderers:r={},topbarLeadingInset:i,children:a}){let o=Br(e),s=!Vr(e),c=!Vr(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[s?(0,I.jsx)(gs,{leadingInset:i}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:o?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:a}):(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:a})})}),c?(0,I.jsx)(hs,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(_s,{customTabRenderers:r,displayMode:`fullscreen`,dockControls:n})}):null]})}function ys(){let e=Wr(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(w,{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 bs({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 xs={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 Ss(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function Cs(e){return Ss(xs,e)}var ws={wx:`weixin`,lark:`feishu`},Ts={cron:{icon:`cron`}},Es={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Ds(e){return e?.trim().toLowerCase()??``}function Os(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function ks(e,t){let n=Ds(e);if(!n||n===`native`)return null;let r=t.find(e=>Ds(e.value)===n);return r?.label.trim()?r.label.trim():Os(n)}function As(e,t){let n=Ds(e);return!n||n===`native`?null:t.find(e=>Ds(e.value)===n)??null}function js(e){let t=Ds(e);if(!t)return null;let n=ws[t]??t;return Cs(n)?n:null}function Ms(e,t){let n=js(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Ts[Ds(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Ds(e.sessionType),a=As(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=Es[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||ks(e.sessionType,t)}}var Ns=`app://`;function Ps(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 Fs(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Ns))return t;let n=Ps(t.slice(6));return n?`/${n}`:null}function Is({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 Ls({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Rs,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Fs(e.src);return(0,I.jsx)(Is,{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)(Fn,{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 Rs({channel:e,className:t}){return(0,I.jsx)(Is,{name:e,src:Cs(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Fn,{className:`h-3 w-3 text-gray-500`})})}function zs(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)(Ls,{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)(Fn,{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 Bs(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Vs(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Bs(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)(Tn,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{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)(pn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(xn,{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)(zs,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(ye,{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)(pn,{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 Hs=[[`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 Us(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 Ws({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=Hs[Us(e)%Hs.length]??Hs[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)(Fn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Gs({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)($t,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ks(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function qs(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 Js(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Ys(e,t){return e.getFullYear()===t.getFullYear()}function Xs(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Ys(e,t)?n:`${e.getFullYear()}年${n}`}function Zs(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=Js(r),o=Js(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 Xs(r,n);let l=Ys(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Qs(e){return e.trim().toLowerCase()}function $s(e,t){let n=Qs(t);return n?[e.key,Ks(e),e.projectRoot??``,e.projectName??``].map(Qs).some(e=>e.includes(n)):!0}function ec({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)(Ne,{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)(ye,{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)(Ln,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ye,{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)(_n,{className:`h-3.5 w-3.5`})})]})]})]})}function tc({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=qs(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)(Ws,{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)(Ls,{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:Zs(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)(or,{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)(Gs,{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)(gr,{className:`h-3 w-3`})})]})}function nc({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)(ec,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(tc,{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 rc=[{icon:ur,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:E,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:Mn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function ic({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`min-h-full flex items-center justify-center px-4 py-6 sm:p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full min-w-0 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)(Fn,{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)(yo,{value:n,onValueChange:r,children:[(0,I.jsxs)(xo,{"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)(Ws,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(wo,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(Eo,{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)(Ws,{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-[repeat(auto-fit,minmax(min(100%,9.5rem),1fr))] gap-3`,children:rc.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`min-w-0 rounded-2xl border border-gray-200 bg-white p-3 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer sm:p-4`,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 ac=(0,F.createContext)(null);function oc({presenter:e,children:t}){return(0,I.jsx)(ac.Provider,{value:e,children:t})}function sc(){let e=(0,F.useContext)(ac);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var cc=e=>`[data-item-index="${e}"]`;function lc(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??cc;(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 uc(){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 dc=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}));dc.displayName=`ChatInput`;var fc=wn,pc=yn,mc=bn,hc=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(Sn,{children:(0,I.jsx)(vn,{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})}));hc.displayName=vn.displayName;var gc=ro,_c=uo,vc=ao,yc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(io,{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)(oo,{asChild:!0,children:(0,I.jsx)(Rn,{className:`h-4 w-4 opacity-50`})})]}));yc.displayName=io.displayName;var bc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Bn,{className:`h-4 w-4`})}));bc.displayName=go.displayName;var xc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Rn,{className:`h-4 w-4`})}));xc.displayName=_o.displayName;var Sc=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(so,{children:(0,I.jsxs)(co,{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)(bc,{}),(0,I.jsx)(lo,{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)(xc,{})]})}));Sc.displayName=co.displayName;var Cc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fo,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Cc.displayName=fo.displayName;var wc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(po,{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)(ho,{children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsx)(mo,{children:t})]}));wc.displayName=po.displayName;var Tc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vo,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Tc.displayName=vo.displayName;var Ec=cn,Dc=tn,Oc=rn,kc=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(on,{children:(0,I.jsx)(en,{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})}));kc.displayName=en.displayName;var Ac={Popover:fc,PopoverAnchor:mc,PopoverContent:hc,PopoverTrigger:pc,Input:dc,Select:gc,SelectContent:Sc,SelectGroup:_c,SelectItem:wc,SelectLabel:Cc,SelectSeparator:Tc,SelectTrigger:yc,SelectValue:vc,Tooltip:Dc,TooltipContent:kc,TooltipProvider:Ec,TooltipTrigger:Oc},jc=680,Mc=.82,Nc=560;function Pc(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Ac,{elementRef:i,width:a}=uc(),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>Nc?a*Mc:a,jc)},[a]);return lc({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 Fc=Ce(`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`}}),Ic=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Fc({variant:t,size:n,className:e})),ref:i,...r}));Ic.displayName=`ChatButton`;var Lc=120;function Rc(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Lc?t:`${t.slice(0,Lc-1)}…`}function zc(){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 Bc({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Ac,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 Vc({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}=Ac,y=e?.trim()??``,b=y?Rc(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)(Bc,{contextWindow:l}):null,n?r?(0,I.jsx)(Ic,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(zc,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Ic,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(zc,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Ic,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(Pn,{className:`h-5 w-5`})})]})]})}function Hc(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 Uc(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Ac,{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):Hc(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]),lc({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)(E,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`nextclaw-chat-skill-picker-label hidden sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,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)(hn,{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)(_r,{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)(Ln,{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)(dn,{className:`h-3 w-3`})]})}):null]})]})}function Wc({icon:e}){return e===`sparkles`?(0,I.jsx)(xr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(In,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Gc({icon:e}){return e===`paperclip`?(0,I.jsx)(hr,{className:`h-4 w-4`}):(0,I.jsx)(Wc,{icon:e})}var Kc={model:`min-w-0 max-w-full flex-1 basis-[12rem] sm:max-w-[320px]`,"session-type":`shrink-0`,thinking:`shrink-0`},qc={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Jc(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Yc({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Ac,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=Jc(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,title:e.selectedLabel,className:`nextclaw-chat-toolbar-select-trigger 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 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${Kc[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Wc,{icon:e.icon}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-mobile-label truncate text-xs font-semibold text-gray-700 sm:hidden [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:d}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-label hidden truncate text-xs font-semibold text-gray-700 sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,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:qc[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 Xc({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Ac;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[12rem] flex-1 flex-wrap items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Uc,{picker:r}):null,n.map(e=>(0,I.jsx)(Yc,{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)(Gc,{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)(Vc,{...e})]})}var Zc=(0,F.createContext)(null);function Qc(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function $c(){let e=(0,F.useContext)(Zc);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 el(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 tl=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,nl=tl&&`documentMode`in document?document.documentMode:null,rl=tl&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),il=tl&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),al=!(!tl||!(`InputEvent`in window)||nl)&&`getTargetRanges`in new window.InputEvent(`input`),ol=tl&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,sl=tl&&/Android/.test(navigator.userAgent),cl=tl&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!sl,ll=tl&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ul=tl&&sl&&ll,dl=tl&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&rl&&!ll,fl=0,pl=1,ml=2,hl=1,gl=2,_l=3,vl=4,yl=5,bl=6,xl=cl||ol||dl?`\xA0`:`​`,Sl=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-yi02ASOL.js","assets/doc-browser-CTFB6ACN.js","assets/react-Bl8iJUcF.js","assets/dist-T6rf86Nf.js","assets/tooltip-fs7VQG7d.js","assets/dist-DQoV-62W.js","assets/arrow-left-CI0Ocu9p.js","assets/external-link-CefT35zP.js","assets/plus-zZ2GC_AJ.js","assets/search-C0b2yzmt.js","assets/x-BV4iiea8.js","assets/doc-browser-context-CP2tI-Br.js","assets/model-config-C9ydDDFh.js","assets/api-CA2udGyv.js","assets/loader-circle-_edjOFsw.js","assets/provider-scoped-model-input-CkeEyTfO.js","assets/provider-models-C_yOh6DE.js","assets/config-hints-Ceiol9x4.js","assets/chat-page-CImtIhmN.js","assets/app-presenter-provider-B9ChYida.js","assets/confirm-dialog-l4FYdzga.js","assets/es2015-BSPOGpH4.js","assets/popover-D_pJfOlM.js","assets/key-round-BpM3GZn4.js","assets/refresh-cw-CqfS1EhK.js","assets/trash-2-Bb8mTTLl.js","assets/notice-card-BfXlhPjX.js","assets/status-dot-DY0xUUvK.js","assets/tabs-C77i1w90.js","assets/mcp-marketplace-page-DhqcnhZc.js","assets/tag-chip-Dnb2VuWh.js","assets/ellipsis-B7CbNPNr.js","assets/play-DD0bg50i.js","assets/tabs-custom-CFpR54-m.js","assets/search-config-RN01uPJQ.js","assets/config-split-page-bO0K6uQv.js","assets/providers-list-9eOBQFUn.js","assets/channels-list-page-PrT4a9g4.js","assets/runtime-config-page-B30PC6bx.js","assets/rotate-cw-C7EvaSlb.js","assets/save-CQERCODg.js","assets/desktop-update-config-p3rJIgRg.js","assets/secrets-config-CTZ_TGoA.js","assets/remote-fGlxrJI_.js","assets/mcp-marketplace-page-DNHSmfDf.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,y as _}from"./react-Bl8iJUcF.js";import{A as v,C as y,E as b,F as x,I as S,L as C,M as w,N as T,O as E,P as D,S as O,T as k,a as A,c as ee,i as j,j as te,k as M,l as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce,x as le,z as ue}from"./app-presenter-provider-B9ChYida.js";import{$ as de,At as fe,B as pe,Bt as me,Ct as he,Dt as ge,Et as _e,F as ve,Ft as ye,G as be,H as xe,I as Se,It as Ce,J as we,K as Te,L as Ee,Lt as De,M as Oe,N as ke,Nt as Ae,Ot as je,P as Me,Pt as Ne,Q as Pe,Qt as Fe,R as Ie,Rt as Le,Tt as Re,U as ze,V as Be,Vt as Ve,W as He,X as Ue,Y as We,Z as Ge,Zt as Ke,_ as qe,at as Je,bt as Ye,ct as Xe,d as Ze,dt as Qe,et as $e,f as et,ft as tt,g as nt,gt as rt,h as it,ht as at,kt as ot,lt as st,m as ct,n as lt,ot as ut,p as dt,q as ft,st as pt,t as mt,tt as ht,v as gt,vt as _t,xt as vt,y as yt,yt as bt,z as xt,zt as N}from"./api-CA2udGyv.js";import{_ as St,a as Ct,b as wt,c as P,d as Tt,f as Et,g as Dt,h as Ot,i as kt,l as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,u as It,x as Lt,y as Rt}from"./dist-T6rf86Nf.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./es2015-BSPOGpH4.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-l4FYdzga.js";import{t as Xt}from"./arrow-left-CI0Ocu9p.js";import{n as Zt}from"./doc-browser-CTFB6ACN.js";import{n as Qt,t as $t}from"./loader-circle-_edjOFsw.js";import{a as en,c as tn,i as nn,l as rn,n as an,o as on,r as sn,s as cn,t as ln,u as un}from"./tooltip-fs7VQG7d.js";import{t as dn}from"./external-link-CefT35zP.js";import{t as fn}from"./key-round-BpM3GZn4.js";import{t as pn}from"./plus-zZ2GC_AJ.js";import{t as mn}from"./refresh-cw-CqfS1EhK.js";import{t as hn}from"./search-C0b2yzmt.js";import{t as gn}from"./trash-2-Bb8mTTLl.js";import{t as _n}from"./x-BV4iiea8.js";import{a as vn,c as yn,i as bn,n as xn,o as Sn,r as Cn,s as wn,t as Tn}from"./popover-D_pJfOlM.js";import{c as En,m as Dn,n as On,s as kn,t as An}from"./doc-browser-context-CP2tI-Br.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 jn=e((e=>{var t=o();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`}]]),Nn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Pn=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Fn=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`}]]),In=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`}]]),Ln=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Rn=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),zn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Bn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Vn=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`}]]),Hn=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`}]]),Un=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`}]]),Wn=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`}]]),Gn=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`}]]),Kn=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`}]]),qn=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`}]]),Jn=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`}]]),Yn=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`}]]),Xn=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`}]]),Zn=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`}]]),Qn=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`}]]),$n=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`}]]),er=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`}]]),tr=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`}]]),nr=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`}]]),rr=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`}]]),ir=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`}]]),ar=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`}]]),or=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`}]]),sr=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`}]]),cr=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`}]]),lr=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`}]]),ur=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),dr=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`}]]),fr=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`}]]),pr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),mr=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`}]]),hr=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`}]]),gr=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`}]]),_r=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`}]]),vr=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`}]]),yr=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`}]]),br=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),xr=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`}]]),Sr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Cr=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),wr=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`}]]),Tr=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`}]]),Er=jn(),F=_(a(),1);function Dr(){let e=On();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;Dn(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 I=l(),Or=(0,F.createContext)(null);function kr({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)(Or.Provider,{value:o,children:e})}function Ar(){let e=(0,F.useContext)(Or);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function jr(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function Mr(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:jr(e),width:e}}var Nr=m(()=>Mr()),Pr=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=()=>Nr.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Nr.setState(Mr())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Nr.setState({width:e,mode:jr(e)})}}};function Fr(){return(0,F.useEffect)(()=>Pr.attach(),[]),{isMobile:Nr(e=>e.mode)===`mobile`}}var Ir=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Lr=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Ir.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Ir.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Ir.setState({supported:!0,initialized:!0,busyAction:null}),N.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Ir.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));Ir.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return Ir.setState({supported:!0,initialized:!0,snapshot:n}),N.success(s(`runtimePresenceSaved`)),n}catch(e){throw N.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Ir.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Rr=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){Rr.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Rr.setState({supported:!0,initialized:!0,snapshot:e})}),Rr.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Rr.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Rr.setState({supported:!0,initialized:!0}),N.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`){N.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){N.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){N.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&N.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`&&N.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(Rr.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){N.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}N.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Rr.setState({busyAction:e});try{let e=await n(r);return Rr.setState({snapshot:e}),e}catch(e){throw N.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Rr.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 zr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Br(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 Vr(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Hr(e){return[{target:`/chat`,label:e(`chat`),icon:ur},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:e(`agentsPageTitle`),icon:Fn},{target:`/settings`,label:e(`settings`),icon:vr}]}function Ur(e){return[{target:`/model`,label:e(`model`),icon:Un},{target:`/providers`,label:e(`providers`),icon:xr},{target:`/channels`,label:e(`channels`),icon:fr},{target:`/search`,label:e(`searchChannels`),icon:hn},{target:`/runtime`,label:e(`runtime`),icon:Un},{target:`/updates`,label:e(`updates`),icon:Wn},{target:`/remote`,label:e(`remote`),icon:Tr},{target:`/security`,label:e(`security`),icon:yr},{target:`/secrets`,label:e(`secrets`),icon:fn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:O}]}function Wr(e){return[{target:`/language`,label:e(`language`),icon:lr},...Ur(e)]}function Gr(e){let t=e.toLowerCase();return t===`/settings`?!0:Wr(e=>e).some(e=>zr(t,e.target))}function Kr(e,t){let n=e.toLowerCase(),r=Wr(t);if(Vr(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(zr(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var qr=`nextclaw.ui.theme`,Jr=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Yr=`warm`,Xr=!1,Zr=new Set;function Qr(e){return e===`warm`||e===`cool`}function $r(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function ei(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(qr);if(Qr(e))return e}catch{}return`warm`}function ti(){return Xr||=(Yr=ei(),$r(Yr),!0),Yr}function ni(){return Xr?Yr:ti()}function ri(e){if(ti(),e!==Yr){if(Yr=e,$r(Yr),typeof window<`u`)try{window.localStorage.setItem(qr,Yr)}catch{}Zr.forEach(e=>e(Yr))}}function ii(e){return Zr.add(e),()=>{Zr.delete(e)}}function ai(){return Ve({queryKey:[`config`],queryFn:Ee,staleTime:3e4,refetchOnWindowFocus:!0})}function oi(){return Ve({queryKey:[`app-meta`],queryFn:Se,staleTime:1/0})}function si(){return Ve({queryKey:[`config-meta`],queryFn:Ie,staleTime:1/0})}function ci(){return Ve({queryKey:[`providers`],queryFn:ze,staleTime:3e4,refetchOnWindowFocus:!0})}function li(){return Ve({queryKey:[`provider-templates`],queryFn:xe,staleTime:1/0})}function ui(){return Ve({queryKey:[`config-schema`],queryFn:xt,staleTime:1/0})}function di(){let e=Fe();return me({mutationFn:Ge,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function fi(){let e=Fe();return me({mutationFn:({data:e})=>$e(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function pi(){let e=Fe();return me({mutationFn:({provider:e,data:t})=>Pe(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),n.silentSuccess||N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function mi(){let e=Fe();return me({mutationFn:({data:e})=>Oe(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function hi(){let e=Fe();return me({mutationFn:({provider:e})=>Me(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function gi(){return me({mutationFn:({provider:e,data:t})=>We(e,t)})}function _i(){return me({mutationFn:({provider:e,data:t})=>we(e,t)})}function vi(){return me({mutationFn:({provider:e,data:t})=>be(e,t)})}function yi(){return me({mutationFn:({provider:e})=>He(e)})}function bi(){let e=Fe();return me({mutationFn:({channel:e,data:t})=>Ue(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplying`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function xi(){let e=Fe();return me({mutationFn:({data:e})=>de(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Si(){let e=Fe();return me({mutationFn:({data:e})=>ht(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Ci(){return me({mutationFn:({actionId:e,data:t})=>ve(e,t),onError:e=>{N.error(s(`error`)+`: `+e.message)}})}function wi(e){return Ve({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>qe(e),staleTime:5e3,retry:!1})}function Ti(e){return Ve({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>nt(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ei(e={all:!0}){return Ve({queryKey:[`cron`,e],queryFn:()=>pe(e),staleTime:1e4})}function Di(){let e=Fe();return me({mutationFn:({id:e})=>ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Oi(){let e=Fe();return me({mutationFn:({id:e,enabled:t})=>ft(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function ki(){let e=Fe();return me({mutationFn:({id:e,force:t})=>Te(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}var Ai={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 ji(){let e=_t(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=()=>{e.tone!==`healthy`&&vt.requestRuntimeBootstrapProbeNow()},i=async()=>{if(t)try{let e=await vt.runRuntimeControlAction(`restart-service`);N.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);N.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(Tn,{children:[(0,I.jsx)(Cn,{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`,onClick:n,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,Ai[e.tone])})})}),(0,I.jsxs)(xn,{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 i(),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 Mi({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=oi(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(ji,{}),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)(Ni,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Pi,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Ni({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 Pi(){let{supported:e,busyAction:t,snapshot:n}=rt();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Fi,{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 at.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 at.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Fi({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Ii,{snapshot:e});let t=e.status===`downloading`?Li(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 Ii({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 Li(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Ri=_(o(),1);function zi(e,[t,n]){return Math.min(n,Math.max(t,e))}function Bi(e){let t=e+`CollectionProvider`,[n,r]=Rt(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=Nt(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:wt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Nt(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=wt(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 Vi=F.createContext(void 0);function Hi(e){let t=F.useContext(Vi);return e||t||`ltr`}function Ui(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 Wi=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Gi=[` `,`Enter`],Ki=`Select`,[qi,Ji,Yi]=Bi(Ki),[Xi,Zi]=Rt(Ki,[Yi,Ft]),Qi=Ft(),[$i,ea]=Xi(Ki),[ta,na]=Xi(Ki),ra=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=Qi(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Hi(l),[C,w]=Ot({prop:r,defaultProp:i??!1,onChange:a,caller:Ki}),[T,E]=Ot({prop:o,defaultProp:s,onChange:c,caller:Ki}),D=F.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=F.useState(new Set),ee=Array.from(k).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)($i,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Dt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,I.jsx)(qi.Provider,{scope:t,children:(0,I.jsx)(ta,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,I.jsxs)(Qa,{"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(k)]},ee):null]})})};ra.displayName=Ki;var ia=`SelectTrigger`,aa=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Qi(n),o=ea(ia,n),s=o.disabled||r,c=wt(t,o.onTriggerChange),l=Ji(n),u=F.useRef(`touch`),[d,f,p]=eo(e=>{let t=l().filter(e=>!e.disabled),n=to(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)(Et.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":$a(o.value)?``:void 0,...i,ref:c,onClick:Lt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Lt(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:Lt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Wi.includes(e.key)&&(m(),e.preventDefault())})})})});aa.displayName=ia;var oa=`SelectValue`,sa=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=ea(oa,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=wt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Et.span,{...s,ref:d,style:{pointerEvents:`none`},children:$a(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});sa.displayName=oa;var ca=`SelectIcon`,la=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Et.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});la.displayName=ca;var ua=`SelectPortal`,da=e=>(0,I.jsx)(At,{asChild:!0,...e});da.displayName=ua;var fa=`SelectContent`,pa=F.forwardRef((e,t)=>{let n=ea(fa,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Ri.createPortal((0,I.jsx)(ha,{scope:e.__scopeSelect,children:(0,I.jsx)(qi.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(ya,{...e,ref:t})});pa.displayName=fa;var ma=10,[ha,ga]=Xi(fa),_a=`SelectContentImpl`,va=Nt(`SelectContent.RemoveScroll`),ya=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=ea(fa,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=wt(t,e=>b(e)),[w,T]=F.useState(null),[E,D]=F.useState(null),O=Ji(n),[k,A]=F.useState(!1),ee=F.useRef(!1);F.useEffect(()=>{if(y)return Ht(y)},[y]),Vt();let j=F.useCallback(e=>{let[t,...n]=O().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},[O,x]),te=F.useCallback(()=>j([w,y]),[j,w,y]);F.useEffect(()=>{k&&te()},[k,te]);let{onOpenChange:M,triggerPointerDownPosRef:ne}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ne.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ne.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||M(!1),document.removeEventListener(`pointermove`,t),ne.current=null};return ne.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,M,ne]),F.useEffect(()=>{let e=()=>M(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[M]);let[re,ie]=eo(e=>{let t=O().filter(e=>!e.disabled),n=to(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(ee.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ce=r===`popper`?Ca:xa,le=ce===Ca?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(ha,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:te,selectedItemText:E,position:r,isPositioned:k,searchRef:re,children:(0,I.jsx)(Bt,{as:va,allowPinchZoom:!0,children:(0,I.jsx)(zt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Lt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(It,{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:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Lt(_.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=O().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(()=>j(t)),e.preventDefault()}})})})})})})});ya.displayName=_a;var ba=`SelectItemAlignedPosition`,xa=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=ea(fa,n),o=ga(fa,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=wt(t,e=>u(e)),f=Ji(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-ma,d=zi(a,[ma,Math.max(ma,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-ma,d=zi(a,[ma,Math.max(ma,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-ma*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-ma,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,ee=x-A;if(A<=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=A+Math.max(D,O+(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)+O)+ee;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${ma}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)(wa,{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)(Et.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});xa.displayName=ba;var Sa=`SelectPopperPosition`,Ca=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=ma,...a}=e,o=Qi(n);return(0,I.jsx)(Ct,{...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)`}})});Ca.displayName=Sa;var[wa,Ta]=Xi(fa,{}),Ea=`SelectViewport`,Da=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ga(Ea,n),o=Ta(Ea,n),s=wt(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)(qi.Slot,{scope:n,children:(0,I.jsx)(Et.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Lt(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-ma*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})})})]})});Da.displayName=Ea;var Oa=`SelectGroup`,[ka,Aa]=Xi(Oa),ja=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Dt();return(0,I.jsx)(ka,{scope:n,id:i,children:(0,I.jsx)(Et.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ja.displayName=Oa;var Ma=`SelectLabel`,Na=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Aa(Ma,n);return(0,I.jsx)(Et.div,{id:i.id,...r,ref:t})});Na.displayName=Ma;var Pa=`SelectItem`,[Fa,Ia]=Xi(Pa),La=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=ea(Pa,n),c=ga(Pa,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=wt(t,e=>c.itemRefCallback?.(e,r,i)),h=Dt(),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)(Fa,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(qi.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Et.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:Lt(o.onFocus,()=>p(!0)),onBlur:Lt(o.onBlur,()=>p(!1)),onClick:Lt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Lt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Lt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Lt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Lt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Gi.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});La.displayName=Pa;var Ra=`SelectItemText`,za=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=ea(Ra,n),s=ga(Ra,n),c=Ia(Ra,n),l=na(Ra,n),[u,d]=F.useState(null),f=wt(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)(Et.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ri.createPortal(a.children,o.valueNode):null]})});za.displayName=Ra;var Ba=`SelectItemIndicator`,Va=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Ia(Ba,n).isSelected?(0,I.jsx)(Et.span,{"aria-hidden":!0,...r,ref:t}):null});Va.displayName=Ba;var Ha=`SelectScrollUpButton`,Ua=F.forwardRef((e,t)=>{let n=ga(Ha,e.__scopeSelect),r=Ta(Ha,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(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)(Ka,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ua.displayName=Ha;var Wa=`SelectScrollDownButton`,Ga=F.forwardRef((e,t)=>{let n=ga(Wa,e.__scopeSelect),r=Ta(Wa,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(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)(Ka,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ga.displayName=Wa;var Ka=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ga(`SelectScrollButton`,n),o=F.useRef(null),s=Ji(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)(Et.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Lt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Lt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Lt(i.onPointerLeave,()=>{c()})})}),qa=`SelectSeparator`,Ja=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Et.div,{"aria-hidden":!0,...r,ref:t})});Ja.displayName=qa;var Ya=`SelectArrow`,Xa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Qi(n),a=ea(Ya,n),o=ga(Ya,n);return a.open&&o.position===`popper`?(0,I.jsx)(kt,{...i,...r,ref:t}):null});Xa.displayName=Ya;var Za=`SelectBubbleInput`,Qa=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=wt(r,i),o=Ui(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)(Et.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});Qa.displayName=Za;function $a(e){return e===``||e===void 0}function eo(e){let t=Tt(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 to(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=no(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 no(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ro=ra,io=aa,ao=sa,oo=la,so=da,co=pa,lo=Da,uo=ja,fo=Na,po=La,mo=za,ho=Va,go=Ua,_o=Ga,vo=Ja,yo=ro,bo=ao,xo=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(io,{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)(oo,{asChild:!0,children:n??(0,I.jsx)(Rn,{className:`h-4 w-4 opacity-50`})})]}));xo.displayName=io.displayName;var So=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Bn,{className:`h-4 w-4`})}));So.displayName=go.displayName;var Co=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Rn,{className:`h-4 w-4`})}));Co.displayName=_o.displayName;var wo=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(so,{children:(0,I.jsxs)(co,{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)(So,{}),(0,I.jsx)(lo,{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)(Co,{})]})}));wo.displayName=co.displayName;var To=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fo,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));To.displayName=fo.displayName;var Eo=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(po,{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)(ho,{children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsx)(mo,{children:t})]}));Eo.displayName=po.displayName;var Do=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vo,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Do.displayName=vo.displayName;var Oo={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 ko(e){return Oo[e]}function Ao({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=ko(i);return(0,I.jsx)(w,{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 jo({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=ko(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 Mo({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=ko(o);return(0,I.jsxs)(yo,{value:n,onValueChange:a,children:[(0,I.jsxs)(xo,{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)(wo,{children:s})]})}var No=`nextclaw-pwa-install-banner-dismissed`,Po=`nextclaw-pwa-install-banner-dismissed-until`;function Fo(){let e=Ro();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:zo(e):!1}function Io(){let e=Ro();e?.setItem(No,`1`),e?.removeItem(Po)}function Lo(){let e=Ro();e?.removeItem(No),e?.removeItem(Po)}function Ro(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function zo(e){let t=e.getItem(Po);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Po),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(No,`1`),!0)}function Bo(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Fo(),updateAvailable:!1,registrationFailed:!1}}var Vo=m(()=>Bo()),Ho=`nextclaw-pwa-dev-sw-reset`,Uo=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{Vo.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){Vo.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;Vo.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:Vo.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(Ho)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(Ho,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(Ho)}catch{}}}},Wo=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(),Vo.setState(Bo())},this.refreshState=()=>{let e=this.resolveInstallability();Vo.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Fo()})),Uo.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Io(),Vo.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`?(Lo(),this.refreshState(),N.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Lo(),Vo.setState({dismissedInstallPrompt:!0}),N.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 Go(){let e=Vo(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:Ko(e)})}function Ko(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function qo(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 Jo(){let e=Vo(e=>e.installability),t=Vo(e=>e.installMethod),n=Vo(e=>e.blockedReason);return(0,I.jsxs)(_e,{children:[(0,I.jsxs)(ot,{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)(fe,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(je,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Go,{})]}),(0,I.jsxs)(ge,{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:qo(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,className:`gap-2`,onClick:()=>{Wo.promptInstall()},children:[(0,I.jsx)(Wn,{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)(br,{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 Yo(){let e=Vo(e=>e.installability),t=Vo(e=>e.installMethod),n=Vo(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:()=>{Wo.dismissInstallPrompt()},children:(0,I.jsx)(_n,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Wo.promptInstall()},children:[(0,I.jsx)(Wn,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(ye,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Wo.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}function Xo(){let e=Vo(e=>e.updateAvailable),t=Vo(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)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Uo.applyUpdate()},children:[(0,I.jsx)(mn,{className:`h-4 w-4`}),s(`pwaUpdateAction`)]})})]})}var Zo=!1;function Qo(){Zo||typeof window>`u`||(Zo=!0,Wo.start(),Uo.start())}var $o={warm:`#F9F8F5`,cool:`#F8FAFB`},es=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=$o[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)}}},ts=(0,F.createContext)(null);function ns({children:e}){let[t,n]=(0,F.useState)(()=>ti());(0,F.useEffect)(()=>{es.syncTheme(t)},[t]),(0,F.useEffect)(()=>ii(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{ri(e),n(ni())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(ts.Provider,{value:i,children:e})}function rs(){let e=(0,F.useContext)(ts);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function is(){let{language:e,setLanguage:n}=Ar();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 as(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=is();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)(lr,{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)(Ln,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function os({mode:e}){let t=re(),n=On(),i=le(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=is(),{theme:u,setTheme:d}=rs(),f=e===`settings`,p=s(Jr.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:ur},{target:`/chat/cron`,label:s(`cron`),icon:Mn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:s(`agentsPageTitle`),icon:Fn}],v=Ur(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)(w,{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)(Mi,{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)(Ao,{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)(jo,{onClick:()=>t.accountManager.openAccountPanel(),icon:fn,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)(Ao,{to:`/settings`,label:s(`settings`),icon:vr})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Mo,{value:u,onValueChange:e=>g(e),icon:mr,label:s(`theme`),valueLabel:p,density:b,children:Jr.map(e=>(0,I.jsx)(Eo,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Mo,{value:a,onValueChange:e=>l(e),icon:lr,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(Eo,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(jo,{onClick:()=>n.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var ss=[{action:`minimize`,label:`Minimize`,icon:pr},{action:`close`,label:`Close`,icon:_n,variant:`danger`}];function cs(){let e=us()?{action:`toggle-maximize`,label:`Restore`,icon:Hn}:{action:`toggle-maximize`,label:`Maximize`,icon:Sr};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)(Mi,{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:[ss[0],e,ss[1]].map(e=>(0,I.jsx)(ls,{control:e},e.action))})]})}function ls({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 us(){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 ds(){return typeof window>`u`?null:ps()??window.nextclawDesktop?.platform??null}function fs(){return ds()===`win32`}function ps(){return null}function ms(e,t){if(t===`/settings`)return Gr(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function hs(){let{pathname:e}=S(),t=Hr(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=ms(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(v,{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 gs({leadingInset:e}){let t=C(),{pathname:n}=S(),r=Kr(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 _s=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yi02ASOL.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function vs({pathname:e,isDocBrowserOpen:t,docBrowserDockControls:n,docBrowserRenderers:r={},topbarLeadingInset:i,children:a}){let o=Br(e),s=!Vr(e),c=!Vr(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[s?(0,I.jsx)(gs,{leadingInset:i}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:o?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:a}):(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:a})})}),c?(0,I.jsx)(hs,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(_s,{customTabRenderers:r,displayMode:`fullscreen`,dockControls:n})}):null]})}function ys(){let e=Wr(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(w,{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 bs({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 xs={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 Ss(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function Cs(e){return Ss(xs,e)}var ws={wx:`weixin`,lark:`feishu`},Ts={cron:{icon:`cron`}},Es={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Ds(e){return e?.trim().toLowerCase()??``}function Os(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function ks(e,t){let n=Ds(e);if(!n||n===`native`)return null;let r=t.find(e=>Ds(e.value)===n);return r?.label.trim()?r.label.trim():Os(n)}function As(e,t){let n=Ds(e);return!n||n===`native`?null:t.find(e=>Ds(e.value)===n)??null}function js(e){let t=Ds(e);if(!t)return null;let n=ws[t]??t;return Cs(n)?n:null}function Ms(e,t){let n=js(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Ts[Ds(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Ds(e.sessionType),a=As(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=Es[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||ks(e.sessionType,t)}}var Ns=`app://`;function Ps(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 Fs(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Ns))return t;let n=Ps(t.slice(6));return n?`/${n}`:null}function Is({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 Ls({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Rs,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Fs(e.src);return(0,I.jsx)(Is,{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)(Fn,{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 Rs({channel:e,className:t}){return(0,I.jsx)(Is,{name:e,src:Cs(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Fn,{className:`h-3 w-3 text-gray-500`})})}function zs(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)(Ls,{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)(Fn,{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 Bs(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Vs(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Bs(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)(Tn,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{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)(pn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(xn,{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)(zs,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(ye,{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)(pn,{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 Hs=[[`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 Us(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 Ws({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=Hs[Us(e)%Hs.length]??Hs[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)(Fn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Gs({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)($t,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ks(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function qs(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 Js(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Ys(e,t){return e.getFullYear()===t.getFullYear()}function Xs(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Ys(e,t)?n:`${e.getFullYear()}年${n}`}function Zs(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=Js(r),o=Js(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 Xs(r,n);let l=Ys(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Qs(e){return e.trim().toLowerCase()}function $s(e,t){let n=Qs(t);return n?[e.key,Ks(e),e.projectRoot??``,e.projectName??``].map(Qs).some(e=>e.includes(n)):!0}function ec({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)(Ne,{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)(ye,{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)(Ln,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ye,{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)(_n,{className:`h-3.5 w-3.5`})})]})]})]})}function tc({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=qs(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)(Ws,{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)(Ls,{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:Zs(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)(or,{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)(Gs,{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)(gr,{className:`h-3 w-3`})})]})}function nc({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)(ec,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(tc,{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 rc=[{icon:ur,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:E,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:Mn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function ic({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`min-h-full flex items-center justify-center px-4 py-6 sm:p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full min-w-0 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)(Fn,{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)(yo,{value:n,onValueChange:r,children:[(0,I.jsxs)(xo,{"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)(Ws,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(wo,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(Eo,{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)(Ws,{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-[repeat(auto-fit,minmax(min(100%,9.5rem),1fr))] gap-3`,children:rc.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`min-w-0 rounded-2xl border border-gray-200 bg-white p-3 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer sm:p-4`,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 ac=(0,F.createContext)(null);function oc({presenter:e,children:t}){return(0,I.jsx)(ac.Provider,{value:e,children:t})}function sc(){let e=(0,F.useContext)(ac);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var cc=e=>`[data-item-index="${e}"]`;function lc(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??cc;(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 uc(){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 dc=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}));dc.displayName=`ChatInput`;var fc=wn,pc=yn,mc=bn,hc=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(Sn,{children:(0,I.jsx)(vn,{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})}));hc.displayName=vn.displayName;var gc=ro,_c=uo,vc=ao,yc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(io,{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)(oo,{asChild:!0,children:(0,I.jsx)(Rn,{className:`h-4 w-4 opacity-50`})})]}));yc.displayName=io.displayName;var bc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Bn,{className:`h-4 w-4`})}));bc.displayName=go.displayName;var xc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Rn,{className:`h-4 w-4`})}));xc.displayName=_o.displayName;var Sc=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(so,{children:(0,I.jsxs)(co,{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)(bc,{}),(0,I.jsx)(lo,{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)(xc,{})]})}));Sc.displayName=co.displayName;var Cc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(fo,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Cc.displayName=fo.displayName;var wc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(po,{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)(ho,{children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsx)(mo,{children:t})]}));wc.displayName=po.displayName;var Tc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(vo,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Tc.displayName=vo.displayName;var Ec=cn,Dc=tn,Oc=rn,kc=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(on,{children:(0,I.jsx)(en,{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})}));kc.displayName=en.displayName;var Ac={Popover:fc,PopoverAnchor:mc,PopoverContent:hc,PopoverTrigger:pc,Input:dc,Select:gc,SelectContent:Sc,SelectGroup:_c,SelectItem:wc,SelectLabel:Cc,SelectSeparator:Tc,SelectTrigger:yc,SelectValue:vc,Tooltip:Dc,TooltipContent:kc,TooltipProvider:Ec,TooltipTrigger:Oc},jc=680,Mc=.82,Nc=560;function Pc(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Ac,{elementRef:i,width:a}=uc(),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>Nc?a*Mc:a,jc)},[a]);return lc({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 Fc=Ce(`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`}}),Ic=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Fc({variant:t,size:n,className:e})),ref:i,...r}));Ic.displayName=`ChatButton`;var Lc=120;function Rc(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Lc?t:`${t.slice(0,Lc-1)}…`}function zc(){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 Bc({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Ac,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 Vc({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}=Ac,y=e?.trim()??``,b=y?Rc(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)(Bc,{contextWindow:l}):null,n?r?(0,I.jsx)(Ic,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(zc,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Ic,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(zc,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Ic,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(Pn,{className:`h-5 w-5`})})]})]})}function Hc(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 Uc(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Ac,{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):Hc(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]),lc({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)(E,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`nextclaw-chat-skill-picker-label hidden sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,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)(hn,{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)(_r,{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)(Ln,{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)(dn,{className:`h-3 w-3`})]})}):null]})]})}function Wc({icon:e}){return e===`sparkles`?(0,I.jsx)(xr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(In,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Gc({icon:e}){return e===`paperclip`?(0,I.jsx)(hr,{className:`h-4 w-4`}):(0,I.jsx)(Wc,{icon:e})}var Kc={model:`min-w-0 max-w-full flex-1 basis-[12rem] sm:max-w-[320px]`,"session-type":`shrink-0`,thinking:`shrink-0`},qc={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Jc(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Yc({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Ac,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=Jc(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,title:e.selectedLabel,className:`nextclaw-chat-toolbar-select-trigger 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 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${Kc[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Wc,{icon:e.icon}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-mobile-label truncate text-xs font-semibold text-gray-700 sm:hidden [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:d}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-label hidden truncate text-xs font-semibold text-gray-700 sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,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:qc[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 Xc({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Ac;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[12rem] flex-1 flex-wrap items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Uc,{picker:r}):null,n.map(e=>(0,I.jsx)(Yc,{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)(Gc,{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)(Vc,{...e})]})}var Zc=(0,F.createContext)(null);function Qc(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function $c(){let e=(0,F.useContext)(Zc);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 el(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 tl=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,nl=tl&&`documentMode`in document?document.documentMode:null,rl=tl&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),il=tl&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),al=!(!tl||!(`InputEvent`in window)||nl)&&`getTargetRanges`in new window.InputEvent(`input`),ol=tl&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,sl=tl&&/Android/.test(navigator.userAgent),cl=tl&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!sl,ll=tl&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ul=tl&&sl&&ll,dl=tl&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&rl&&!ll,fl=0,pl=1,ml=2,hl=1,gl=2,_l=3,vl=4,yl=5,bl=6,xl=cl||ol||dl?`\xA0`:`​`,Sl=`
4
4
 
5
5
  `,Cl=il?`\xA0`:xl,wl={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Tl={directionless:1,unmergeable:2},El={center:2,end:6,justify:4,left:1,right:3,start:5},Dl={[gl]:`center`,[bl]:`end`,[vl]:`justify`,[hl]:`left`,[_l]:`right`,[yl]:`start`},Ol={normal:0,segmented:2,token:1},kl={[fl]:`normal`,[ml]:`segmented`,[pl]:`token`},Al=`$config`;function jl(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(U(o)&&jl(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var Ml=!1,Nl=0;function Pl(e){Nl=e.timeStamp}function Fl(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&Nm(e,n)!==void 0}function Il(e,t,n){let r=Sh(mh(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&Km(t,o,i,a,!1)}function Ll(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return Sm(t)&&n.isAttached()}function Rl(e,t,n,r){for(let i=e;i&&!Lh(i);i=ch(i)){let e=Nm(i,t);if(e!==void 0){let t=jm(e,n);if(t)return Up(t)||!wh(i)?void 0:[i,t]}else if(i===r)return[r,Rm(n)]}}function zl(e,t,n){Ml=!0;let r=performance.now()-Nl>100;try{Lp(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=Rl(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&B(g)&&Sm(p)&&Ll(i,p,g)&&Il(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=Mm(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!Fl(r,a,e)){if(il){let e=(wh(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];(Fl(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`||Fl(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&zm(i),il&&oh(e)&&i.insertRawText(u))})}finally{Ml=!1}}function Bl(e){let t=e._observer;t!==null&&zl(e,t.takeRecords(),t)}function Vl(e){(function(e){Nl===0&&mh(e).addEventListener(`textInput`,Pl,!0)})(e),e._observer=new MutationObserver((t,n)=>{zl(e,t,n)})}var Hl=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Yl).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Ul(e,t){return new Hl(e,t)}function Wl(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}=zh(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 Gl=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 Jl(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=Jl(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 Kl(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Gl(t,ql(t));return t.__state=n,n}function ql(e){return e.__state?e.__state.sharedNodeState:dm(Ah(),e.getType()).sharedNodeState}function Jl(e){if(e)for(let t in e)return e}function Yl(e){return e}function Xl(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 Zl(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 Ql(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function $l(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&&Xl(n,e,t)||t&&Xl(n,t,e)||e&&Zl(n,e,t)||t&&Zl(n,t,e))}(c,l))}function eu(e,t){let n=e.mergeWithSibling(t),r=wp()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function tu(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($l(t,r)){r=eu(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if($l(r,n)){r=eu(r,n);break}break}n.remove()}}else r.remove()}function nu(e){return ru(e.anchor),ru(e.focus),e}function ru(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 iu,au,ou,su,cu,lu,uu,du,fu,pu,mu=``,hu=null,gu=null,_u=!1,vu=!1;function yu(e,t){let n=uu.get(e);if(t!==null){let n=Lu(e);n.parentNode===t&&t.removeChild(n)}if(du.has(e)||au._keyToDOMMap.delete(e),U(n)){let e=ju(n,uu);bu(e,0,e.length-1,null)}n!==void 0&&rh(pu,ou,su,n,`destroyed`)}function bu(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&yu(t,r)}}function xu(e,t){e.setProperty(`text-align`,t)}var Su=`40px`;function Cu(e,t){let n=iu.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(au._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||Su;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function wu(e,t){let n=e.style;t===0?xu(n,``):t===1?xu(n,`left`):t===2?xu(n,`center`):t===3?xu(n,`right`):t===4?xu(n,`justify`):t===5?xu(n,`start`):t===6&&xu(n,`end`)}function Tu(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Gp(e))return null;let n=e.getParentOrThrow();return Gp(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Eu(e,t){let n=du.get(e);n===void 0&&R(60);let r=n.createDOM(iu,au);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,au),B(n)?r.setAttribute(`data-lexical-text`,`true`):Up(n)&&r.setAttribute(`data-lexical-decorator`,`true`),U(n)){let e=n.__indent,t=n.__size;if(Tu(r,n),e!==0&&Cu(r,e),t!==0){let e=t-1;Du(ju(n,du),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&wu(r,i),n.isInline()||ku(null,n,r)}else{let t=n.getTextContent();if(Up(n)){let t=n.decorate(au,iu);t!==null&&Nu(e,t),r.contentEditable=`false`}mu+=t}return t!==null&&t.insertChild(r),rh(pu,ou,su,n,`created`),r}function Du(e,t,n,r,i){let a=mu;mu=``;let o=n;for(;o<=r;++o){Eu(e[o],i);let t=du.get(e[o]);t!==null&&B(t)?hu===null&&(hu=t.getFormat(),gu=t.getStyle()):U(t)&&o<r&&!t.isInline()&&(mu+=Sl)}i.element.__lexicalTextContent=mu,mu=a+mu}function Ou(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return hf(e)?`line-break`:Up(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function ku(e,t,n){let r=Ou(e,uu),i=Ou(t,du);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Au(e,t,n){var r;hu=null,gu=null,function(e,t,n){let r=mu,i=e.__size,a=t.__size;mu=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)Mu(n,o);else{let e=Lu(n),t=Eu(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}yu(n,null)}let i=du.get(r);B(i)&&hu===null&&(hu=i.getFormat(),gu=i.getStyle())}else{let r=ju(e,uu),s=ju(t,du);if(r.length!==i&&R(227),s.length!==a&&R(228),i===0)a!==0&&Du(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;bu(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=Pu(Mu(r,a.element)),d++,f++;else{if(l===void 0&&(l=Fu(n,f)),c===void 0)c=Fu(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=Pu(Lu(e)),yu(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=sh(au,r);e!==u&&a.withBefore(u).insertChild(e),u=Pu(Mu(r,a.element)),d++,f++}else Eu(r,a.withBefore(u)),f++}let i=du.get(r);i!==null&&B(i)?hu===null&&(hu=i.getFormat(),gu=i.getStyle()):U(i)&&f<=s&&!i.isInline()&&(mu+=Sl)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:au.getElementByKey(e);Du(n,0,f,s,a.withBefore(t))}else m&&!p&&bu(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=mu,mu=r+mu}(e,t,t.getDOMSlot(n)),r=t,hu==null||hu===r.__textFormat||vu||r.setTextFormat(hu),function(e){gu==null||gu===e.__textStyle||vu||e.setTextStyle(gu)}(t)}function ju(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 Mu(e,t){let n=uu.get(e),r=du.get(e);n!==void 0&&r!==void 0||R(61);let i=_u||lu.has(e)||cu.has(e),a=sh(au,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 mu+=e,a}if(n!==r&&i&&rh(pu,ou,su,r,`updated`),r.updateDOM(n,a,iu)){let n=Eu(e,null);return t===null&&R(62),t.replaceChild(n,a),yu(e,null),n}if(U(n)){U(r)||R(334,e);let t=r.__indent;(_u||t!==n.__indent)&&Cu(a,t);let o=r.__format;if((_u||o!==n.__format)&&wu(a,o),i)Au(n,r,a),Gp(r)||r.isInline()||ku(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),mu+=t}if((_u||r.__dir!==n.__dir)&&(Tu(a,r),Gp(r)&&!_u))for(let e of r.getChildren())U(e)&&Tu(sh(au,e.getKey()),e)}else{let t=r.getTextContent();if(Up(r)){let t=r.decorate(au,iu);t!==null&&Nu(e,t)}mu+=t}if(!vu&&Gp(r)&&r.__cachedText!==mu){let e=r.getWritable();e.__cachedText=mu,r=e}return a}function Nu(e,t){let n=au._pendingDecorators,r=au._decorators;if(n===null){if(r[e]===t)return;n=Fm(au)}n[e]=t}function Pu(e){let t=e.nextSibling;return t!==null&&t===au._blockCursorElement&&(t=t.nextSibling),t}function Fu(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Iu(e,t,n,r,i,a){mu=``,_u=r===2,au=n,iu=n._config,ou=n._nodes,su=au._listeners.mutation,cu=i,lu=a,uu=e._nodeMap,du=t._nodeMap,vu=t._readOnly,fu=new Map(n._keyToDOMMap);let o=new Map;return pu=o,Mu(`root`,null),au=void 0,ou=void 0,cu=void 0,lu=void 0,uu=void 0,du=void 0,iu=void 0,fu=void 0,pu=void 0,o}function Lu(e){let t=fu.get(e);return t===void 0&&R(75,e),t}function z(e){return{type:e}}var Ru=z(`SELECTION_CHANGE_COMMAND`),zu=z(`CLICK_COMMAND`),Bu=z(`BEFORE_INPUT_COMMAND`),Vu=z(`INPUT_COMMAND`),Hu=z(`COMPOSITION_START_COMMAND`),Uu=z(`COMPOSITION_END_COMMAND`),Wu=z(`DELETE_CHARACTER_COMMAND`),Gu=z(`INSERT_LINE_BREAK_COMMAND`),Ku=z(`INSERT_PARAGRAPH_COMMAND`),qu=z(`CONTROLLED_TEXT_INSERTION_COMMAND`),Ju=z(`PASTE_COMMAND`),Yu=z(`REMOVE_TEXT_COMMAND`),Xu=z(`DELETE_WORD_COMMAND`),Zu=z(`DELETE_LINE_COMMAND`),Qu=z(`FORMAT_TEXT_COMMAND`),$u=z(`UNDO_COMMAND`),ed=z(`REDO_COMMAND`),td=z(`KEYDOWN_COMMAND`),nd=z(`KEY_ARROW_RIGHT_COMMAND`),rd=z(`MOVE_TO_END`),id=z(`KEY_ARROW_LEFT_COMMAND`),ad=z(`MOVE_TO_START`),od=z(`KEY_ARROW_UP_COMMAND`),sd=z(`KEY_ARROW_DOWN_COMMAND`),cd=z(`KEY_ENTER_COMMAND`),ld=z(`KEY_SPACE_COMMAND`),ud=z(`KEY_BACKSPACE_COMMAND`),dd=z(`KEY_ESCAPE_COMMAND`),fd=z(`KEY_DELETE_COMMAND`),pd=z(`KEY_TAB_COMMAND`),md=z(`DROP_COMMAND`),hd=z(`DRAGSTART_COMMAND`),gd=z(`DRAGOVER_COMMAND`),_d=z(`DRAGEND_COMMAND`),vd=z(`COPY_COMMAND`),yd=z(`CUT_COMMAND`),bd=z(`SELECT_ALL_COMMAND`),xd=z(`FOCUS_COMMAND`),Sd=z(`BLUR_COMMAND`),Cd=z(`KEY_MODIFIER_COMMAND`),wd=Object.freeze({}),Td=[[`keydown`,function(e,t){Ed=e.timeStamp,Dd=e.key,!t.isComposing()&&W(t,td,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;Th(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Lp(t,()=>{mm(n)||(Nd=!0)})}],[`compositionstart`,function(e,t){W(t,Hu,e)}],[`compositionend`,function(e,t){il?Fd=!0:ol||!cl&&!dl?W(t,Uu,e):(Id=!0,Ld=e.data)}],[`input`,function(e,t){e.stopPropagation(),Lp(t,()=>{t.dispatchCommand(Vu,e)},{event:e}),kd=null}],[`click`,function(e,t){Lp(t,()=>{let n=H(),r=Sh(mh(t)),i=rp();if(r){if(V(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Gp(a)&&Lm().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=Vh(a,e=>U(e)&&!e.isInline());U(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(wh(n)||Sm(n))&&zm(np(i,r,t,e))}}W(t,zu,e)})}],[`cut`,wd],[`copy`,wd],[`dragstart`,wd],[`dragover`,wd],[`dragend`,wd],[`paste`,wd],[`focus`,wd],[`blur`,wd],[`drop`,wd]];al&&Td.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||il&&oh(t)||n!==`insertCompositionText`&&W(t,Bu,e)}(e,t)]);var Ed=0,Dd=null,Od=0,kd=null,Ad=new WeakMap,jd=new WeakMap,Md=!1,Nd=!1,Pd=!1,Fd=!1,Id=!1,Ld=``,Rd=null,zd=[0,``,0,`root`,0];function Bd(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=wp(),l=Sh(mh(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!B(s)||(!i&&(!al||Od<r+50)||s.isDirty()&&p<2||Vm(n))&&a.offset!==o.offset&&!s.isComposing()||xm(s)||s.isDirty()&&p>1||(i||!al)&&f!==null&&!s.isComposing()&&u!==wm(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=bm(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 Vd(e,t){return Sm(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Hd(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;Md&&(Md=!1,Vd(r,i)&&Vd(a,o)&&!Rd)||Lp(t,()=>{if(!n)return void zm(null);if(!gm(t,r,a))return;let s=H();if(Rd&&V(s)&&s.isCollapsed()){let e=s.anchor,t=Rd.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=Rd.clone(),zm(s))}if(Rd=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=mh(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=zd,f=Lm(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Ud(s,o,c);else if(n.type===`text`)B(r)||R(141),Wd(s,r);else if(n.type===`element`&&!p){U(r)||R(259);let e=n.getNode();e.isEmpty()?function(e,t){Ud(e,t.getTextFormat(),t.getTextStyle())}(s,e):Ud(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,Ru,void 0)})}function Ud(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Wd(e,t){Ud(e,t.getFormat(),t.getStyle())}function Gd(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Kd(e){let t=e.inputType,n=Gd(e),r=wp(),i=H();if(t===`deleteContentBackward`){if(i===null){let e=rp();if(!V(e))return!0;zm(e.clone())}if(V(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,Dd===`MediaLast`&&a<Ed+30&&r.isComposing()&&t){if(km(null),Ed=0,setTimeout(()=>{Lp(r,()=>{km(null)})},30),V(i)){let e=i.anchor.getNode();e.markDirty(),B(e)||R(142),Wd(i,e)}}else{km(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=ul&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!Up(ah(i.anchor,!0))),!c){W(r,Wu,!0);let e=H();ul&&V(e)&&e.isCollapsed()&&(Rd=e,setTimeout(()=>Rd=null))}}return!0}}var a;if(!V(i))return!0;let o=e.data;kd!==null&&Gm(!1,r,kd),i.dirty&&kd===null||!i.isCollapsed()||Gp(i.anchor.getNode())||n===null||i.applyDOMRange(n),kd=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,Gu,!1);else if(o===Sl)e.preventDefault(),W(r,Ku,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&Bd(i,n,o,e.timeStamp,!0)?(e.preventDefault(),W(r,qu,o)):kd=o;return Od=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:W(r,qu,e);break;case`insertFromComposition`:km(null),W(r,qu,e);break;case`insertLineBreak`:km(null),W(r,Gu,!1);break;case`insertParagraph`:km(null),Pd&&!ol?(Pd=!1,W(r,Gu,!1)):W(r,Ku,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:W(r,Ju,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!bm(e)||!bm(t)})(l,u)&&W(r,Yu,e);break;case`deleteByDrag`:case`deleteByCut`:W(r,Yu,e);break;case`deleteContent`:W(r,Wu,!1);break;case`deleteWordBackward`:W(r,Xu,!0);break;case`deleteWordForward`:W(r,Xu,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:W(r,Zu,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:W(r,Zu,!1);break;case`formatStrikeThrough`:W(r,Qu,`strikethrough`);break;case`formatBold`:W(r,Qu,`bold`);break;case`formatItalic`:W(r,Qu,`italic`);break;case`formatUnderline`:W(r,Qu,`underline`);break;case`historyUndo`:W(r,$u,void 0);break;case`historyRedo`:W(r,ed,void 0)}return!0}function qd(e){if(wh(e.target)&&mm(e.target))return!0;let t=wp(),n=H(),r=e.data,i=Gd(e);if(r!=null&&V(n)&&Bd(n,i,r,e.timeStamp,!1)){Fd&&=(Xd(t,r),!1);let i=n.anchor.getNode(),a=Sh(mh(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;al&&!n.isCollapsed()&&B(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===Wm(a.anchorNode)||W(t,qu,r);let l=r.length;il&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),ul&&t.isComposing()&&(Ed=0,km(null))}else Gm(!1,t,r===null?void 0:r),Fd&&=(Xd(t,r||void 0),!1);return function(){xp(),Bl(wp())}(),!0}function Jd(e){let t=wp(),n=H();if(V(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();km(r.key),uh(uf),(e.timeStamp<Ed+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||B(i)&&i.getStyle()!==n.style)&&W(t,qu,Cl)}return!0}function Yd(e){return Xd(wp(),e.data),uh(df),!0}function Xd(e,t){let n=e._compositionKey;if(km(null),n!==null&&t!=null){if(t===``){let t=jm(n),r=wm(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&B(t)){let n=Sh(mh(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),Km(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 aI(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=ZF(o);if(s){let e=XF(s.status)?.toLowerCase(),t=tI(s,a),o=rI(s),c=XF(s.sessionId),l=QP({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...XF(s.title)?{label:s.title.trim()}:{},...XF(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:eI(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:eI(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:eI(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=QF(o);if(!c)return null;let l=nI(c,a),u=iI(c),d=XF(c.sessionId),f=QP({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...XF(c.title)?{label:c.title.trim()}:{},...XF(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:eI(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function oI(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 sI(e,t){let n=RP(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function cI(e,t){let n=e.mimeType.startsWith(`image/`),r=VP(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 lI(e,t){let n=e.toolInvocation,r=UP(n.result,t);if(r)return r;let i=aI({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:WP(i,t)};let a=GP({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=oI(n.result),s=Array.isArray(o?.issues)?o.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,c=JF({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??wP(n.parsedArgs??n.args),u=c?void 0:qP(n.args,n.parsedArgs),d=s||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:SP(n.result).trim()),f=!n.error&&HP(n.result),p=(!c?.fileOperation||!!n.error)&&!f,m=QP(n);return{type:`tool-card`,card:WP({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 uI(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:SP(e)}}function dI(e){return e.type===`text`&&typeof e.text==`string`}function fI(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function pI(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function mI(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 hI(e){let{inlineTokens:t,part:n,texts:r}=e;return dI(n)?LP(n,t):fI(n)?sI(n,r):pI(n)?cI(n,r):mI(n)?lI(n,r):uI(n,r)}function gI(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function _I(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function vI(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function yI(e,t){return{id:e.id,role:vI(e.role),roleLabel:_I(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(gI(e)),status:e.meta?.status,parts:e.parts.map(n=>hI({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var bI=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function xI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function SI(e){return xI(e)}function CI(e){let t=xI(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 wI(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function TI(e){let t=wI(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function EI(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 DI(e){let t=TI(e.path),n=TI(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 OI(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 kI(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function AI(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?DI({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=CI(i)??i.trim();c=OI({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=EI(o);c=OI({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:kI({line:n,column:t}),truncated:a,segments:c}}var jI=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),MI=new Set([`running`,`completed`,`failed`,`idle`]);function NI(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function PI(e){return`${he}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function FI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function II(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function LI(e){let t=II(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=FI(n.timestamp);if(!MI.has(r)||!i)return null;let a=FI(n.statusText),o=FI(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function RI(e){let t=II(e);return t?FI(t.preferred_model)??FI(t.preferredModel)??FI(t.model):null}function zI(e){let t=II(e);if(!t)return null;let n=FI(t.preferred_thinking)??FI(t.thinking)??FI(t.thinking_level)??FI(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return jI.has(r)?r:null}function BI(e){let t=II(e);return t?FI(t.label):null}function VI(e){let t=II(e);return t?SI(t.project_root??t.projectRoot):null}function HI(e){let t=II(e);return t?FI(t.ui_last_read_at):null}function UI(e){let t=II(e);return t?FI(t.runtime)??FI(t.session_type)??FI(t.sessionType)??`native`:`native`}function WI(e){let t=II(e);return t?FI(t.parent_session_id)??FI(t.parentSessionId):null}function GI(e){let t=II(e);return t?FI(t.spawned_by_request_id)??FI(t.spawnedByRequestId):null}function KI(e){let t=II(e);return t?t.child_session_promoted===!0:!1}function qI(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 JI(e){return e.state===`cancelled`?bI.CANCELLED:e.state===`result`?bI.RESULT:e.state===`partial-call`?bI.PARTIAL_CALL:bI.CALL}function YI(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:PI(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:JI(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:NI(n.args),result:n.result}})}return t}function XI(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function ZI(e){return{id:e.id,role:XI(e.role),parts:YI(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function QI(e){let t=BI(e),n=RI(e),r=zI(e),i=VI(e),a=HI(e),o=FI(e.lastMessageAt),s=CI(i),c=qI(e.sessionId),l=WI(e),u=GI(e),d=KI(e),f=LI(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:UI(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 $I(e){return e.map(QI)}function eL(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function tL(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function nL(e){return e===!0}function rL(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=tL(n.usedContextTokens),i=tL(n.totalContextTokens),a=tL(n.prunedUsedContextTokens),o=eL(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=tL(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:tL(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:tL(n.droppedHistoryCount)??0,truncatedToolResultCount:tL(n.truncatedToolResultCount)??0,truncatedSystemPrompt:nL(n.truncatedSystemPrompt),truncatedUserMessage:nL(n.truncatedUserMessage),compacted:nL(n.compacted),...eL(n.checkpointId)?{checkpointId:eL(n.checkpointId)??void 0}:{},compactedMessageCount:tL(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function iL(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=eL(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=eL(n.summary),o=tL(n.coveredMessageCount),s=tL(n.coveredSessionMessageCount),c=tL(n.originalEstimatedTokens),l=tL(n.projectedEstimatedTokens),u=eL(n.createdAt),d=eL(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 aL(){return Ve({queryKey:[`agents`],queryFn:ut,staleTime:3e4})}function oL(){let e=Fe();return me({mutationFn:({agentId:e,data:t})=>pt(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function sL(){let e=Fe();return me({mutationFn:({agentId:e})=>Je(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function cL(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function lL(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=aL(),i=(0,F.useMemo)(()=>cL(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 uL({agentId:e,className:t}){let n=lL(e);return n?(0,I.jsx)(Ws,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var dL=new WeakMap;function fL(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 pL(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 mL({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 hL(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=>!iL(e)).length-1}function gL(e){let t=e.rawMessages.filter(e=>!iL(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:iL(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:hL({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 _L({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=Ar(),o=(0,F.useMemo)(()=>fL(a),[a]),s=(0,F.useMemo)(()=>e.flatMap(e=>{if(iL(e))return[];let t=dL.get(e);if(t&&t.language===a)return[t.viewModel];let n=ZI(e),r=yI({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:jP(e.metadata)},parts:n.parts},{formatTimestamp:e=>u(e,a),texts:o});return dL.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)(()=>pL(a),[a]),d=(0,F.useMemo)(()=>gL({rawMessages:e,messages:s}),[s,e]);return(0,I.jsx)(`div`,{className:n,children:d.map((e,n)=>e.kind===`compaction`?(0,I.jsx)(mL,{checkpoint:e.checkpoint},e.key):(0,I.jsx)(TM,{messages:e.messages,isSending:n===d.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,I.jsx)(uL,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function vL(){let e=Fe();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{dt(e,await gt(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),N.success(i??s(`configSavedApplied`))}catch(e){throw N.error(s(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function yL(){let e=vL();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}),N.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function bL({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 xL(e){return Ve({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>mt({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var SL=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsx)(`div`,{ref:i,className:r(`overflow-auto`,e),...n,children:t}));SL.displayName=`ScrollArea`;function CL({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=xL({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)(Gt,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(qt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(Kt,{children:[(0,I.jsx)(Jt,{children:a}),o?(0,I.jsx)(Wt,{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)(Ae,{htmlFor:`server-path-picker-input`,children:c}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(Ne,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,I.jsx)(ye,{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)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,I.jsx)(cr,{className:`mr-1 h-4 w-4`}),s(`homeDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,I.jsx)(rr,{className:`mr-1 h-4 w-4`}),s(`parentDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,I.jsx)(k,{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)(zn,{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)(hn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{value:g,onChange:e=>_(e.target.value),placeholder:s(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,I.jsx)(SL,{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)(ar,{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)(Ut,{children:[(0,I.jsx)(ye,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:s(`cancel`)}),(0,I.jsx)(ye,{type:`submit`,disabled:b,children:n?s(`saving`):u})]})]})]})})}function wL({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(CL,{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 TL=`flex shrink-0 items-center gap-1.5`,EL=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function DL({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:c,onDeleteSession:l}){let u=yL(),[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:TL,children:[i>0&&o?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:EL,"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,I.jsx)(or,{className:`h-4 w-4`})}):null,a>0&&c?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:EL,"aria-label":s(`chatSessionOpenCronJobs`),title:s(`chatSessionOpenCronJobs`),onClick:c,disabled:_,children:(0,I.jsx)(Mn,{className:`h-4 w-4`})}):null,(0,I.jsxs)(Tn,{open:d,onOpenChange:f,children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:EL,"aria-label":s(`chatSessionMoreActions`),disabled:_,children:(0,I.jsx)(b,{className:`h-4 w-4`})})}),(0,I.jsx)(xn,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(bL,{icon:tr,label:s(`chatSessionSetProject`),onClick:()=>{f(!1),m(!0)},disabled:_}),(0,I.jsx)(bL,{icon:gn,label:s(`chatDeleteSession`),onClick:()=>{f(!1),l()},disabled:!t||_,destructive:!0})]})})]}),(0,I.jsx)(wL,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function OL({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=yL(),[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)(Tn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Cn,{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)(tr,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(Rn,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(xn,{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)(bL,{icon:gr,label:s(`chatSessionSetProject`),onClick:()=>{o(!1),l(!0)},disabled:u}),(0,I.jsx)(bL,{icon:ir,label:s(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,I.jsx)(wL,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function kL({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 AL({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)(Ws,{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)(Ls,{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)(OL,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,I.jsx)(DL,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}):null]})}var jL=`native`;function ML(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:jL}function NL(e,t=jL){return ML(e?.runtime?.trim()||e?.engine?.trim()||t)}function PL(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 FL(e){let t=new Map;for(let n of e){let e=ML(n.value);t.set(e,{value:e,label:n.label?.trim()||PL(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(jL,{value:jL,label:PL(jL),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 IL(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,F.useMemo)(()=>FL(i?.options??[]),[i?.options]),o=(0,F.useMemo)(()=>{let e=[...a],n=ML(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:PL(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)(()=>ML(i?.defaultType??`native`),[i?.defaultType]),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>ML(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=ML(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(ML(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!p.has(ML(t.sessionType))?`${PL(u)} ${s(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}function LL(e,t){return e.label?.trim()?e.label.trim():t?Ks(t):e.sessionKey}function RL(e){let t=wi({limit:200}),n=(0,F.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,F.useMemo)(()=>{let e=$I(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:LL(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?PL(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function zL(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*BL(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}=VL(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=VL(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function VL(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=zL(e);t&&i.push(t)}if(t&&r.trim()){let e=zL(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var HL=`/ncp/agent`,UL=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function WL(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function GL(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 KL(e){let t=(e??`/ncp/agent`).trim();if(!t)return HL;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function qL(e){try{return(await e.text()).trim()}catch{return``}}function JL(e){if(QL(e))return e.ncpError;if(XL(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:eR(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function YL(e,t={}){return new UL(e,t.alreadyPublished??!1)}function XL(e){return ZL(e)&&typeof e.code==`string`&&typeof e.message==`string`}function ZL(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function QL(e){return e instanceof UL}var $L={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function eR(e){if(!e)return`runtime-error`;let t=$L[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 tR(e){let t=rR(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function nR(e){let t=rR(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=eR(n),i=ZL(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 rR(e){try{let t=JSON.parse(e);return ZL(t)?t:null}catch{return null}}var iR=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],aR=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=WL(e.baseUrl),this.basePath=KL(e.basePath),this.fetchImpl=GL(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:iR,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:EM.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 qL(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(QL(e))throw e;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(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 qL(n)}`)}catch(e){if(t.signal.aborted)return;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(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 qL(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of BL(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(QL(e))throw e;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=tR(e.data);if(!t){this.publish({type:EM.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=nR(e.data);throw this.publish({type:EM.EndpointError,payload:t}),YL(t,{alreadyPublished:!0})}}};function oR(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function sR(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 cR(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function lR(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw vt.reportTransportFailure(sR(n)),cR(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${oR(e)}: ${sR(n)}`,n)}}}var uR=300,dR=`ncp agent unavailable during startup`;function fR(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function pR(e){return e?.trim().toLowerCase().includes(dR)??!1}function mR(){return new aR({baseUrl:he,basePath:`/api/ncp/agent`,fetchImpl:lR()})}async function hR(e,t,n=uR){t.throwIfAborted();try{let r=await it(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!fR(e))throw e;return{messages:[],status:`idle`}}}function gR(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 _R(e,t={}){let[n]=(0,F.useState)(()=>mR()),r=bt(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??uR;(0,F.useEffect)(()=>{s(null)},[e]);let l=iN({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await hR(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 gR(e&&r.phase===`ready`&&pR(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 vR(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function yR(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 bR({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)(qn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(uL,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(dr,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function xR({tab:e}){return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{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)(bR,{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)(_n,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(an,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function SR({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)(xR,{tab:e},e.key))})})}function CR({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 wR({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)(nr,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(qn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(zn,{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)(CR,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(CR,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function TR(e){let t=e.path?.trim()??``;return Ve({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>lt({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function ER(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function DR(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:aF({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function OR(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=lF({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 kR({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 AR({diffBlock:e}){return e?(0,I.jsx)(jR,{block:e}):(0,I.jsx)(kR,{text:s(`chatWorkspaceDiffEmpty`)})}function jR({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(Bj,{block:e,layout:`workspace`})})}function MR({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(kR,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(kR,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(kR,{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)(AA,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(jR,{block:t}):(0,I.jsx)(kR,{text:s(`chatWorkspacePreviewEmpty`)})}function NR({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=TR({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?OR(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=ER({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:DR({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)(wR,{breadcrumb:(0,F.useMemo)(()=>AI({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)(AR,{diffBlock:a}):(0,I.jsx)(MR,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var PR={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function FR(){let[e,t]=(0,F.useState)(PR),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 IR(e){return u(e??void 0)}function LR(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function RR(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 zR(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${RR(t.everyMs)}`:t.kind===`at`?`at ${LR(t.atMs)}`:`-`}function BR(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function VR(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function HR({jobs:e}){let t=Di(),{confirm:n,ConfirmDialog:r}=FR(),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)(ye,{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)(gn,{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`),`:`]}),` `,zR(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,IR(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,IR(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(`cronSessionLabel`),`:`]}),` `,BR(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 UR({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=_R(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=hj({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)($t,{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)(_L,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function WR({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 GR({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)(WR,{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 KR({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)(uL,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(er,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(GR,{tab:e})]})}function qR(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:ZN({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:vR(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 JR({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:c=[],sessionProjectRoot:l,displayMode:u=`docked`}){let d=sc(),f=RL(t),p=tP(e=>e.optimisticReadAtBySessionKey),m=yR({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)(()=>qR({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)(Zt,{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)(_n,{className:`h-4 w-4`})})]}),(0,I.jsx)(SR,{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)(KR,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(UR,{sessionKey:m.tab.sessionKey,onToolAction:d.chatThreadManager.openSessionFromToolAction,onFileOpen:d.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,I.jsx)(NR,{file:m.file,sessionProjectRoot:l,onFileOpen:d.chatThreadManager.openFilePreview}):(0,I.jsx)(HR,{jobs:c})})]}):null}function YR({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var XR=[{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 ZR(){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)(YR,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:XR.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(YR,{"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)(YR,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(YR,{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)(YR,{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)(YR,{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)(YR,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(YR,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(YR,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(YR,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function QR(){let e=sc(),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 $R(){let e=sc(),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=NL(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(NL(c(n),t))},{onScroll:d}=hj({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)(ic,{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)(_L,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function ez(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function tz(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=Ei({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>VR(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:ez(e,t,n,i.length)}}function nz(){let e=sc(),t=Q(e=>e.snapshot);return(0,I.jsx)(kL,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function rz({layoutMode:e,onBackToList:t}){let n=sc(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=tz(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)(AL,{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 iz({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=tz(t);return a?(0,I.jsx)(JR,{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 az({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)(nz,{}),(0,I.jsx)(rz,{layoutMode:e,onBackToList:t}),(0,I.jsx)(QR,{}),(0,I.jsx)($R,{}),(0,I.jsx)(_P,{})]}),(0,I.jsx)(iz,{layoutMode:e})]}):(0,I.jsx)(ZR,{})}var oz={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 sz({status:e,className:t}){let n=oz[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{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)($t,{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)(an,{side:`bottom`,className:`text-xs`,children:i})]})})}function cz(){let e=vL();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function lz(){let e=cz(),[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 uz(e,t){return e.filter(e=>$s(e,t))}function dz(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function fz(e={}){let t=tP(e=>e.snapshot.query),n=wi({limit:e.limit??200}),r=(0,F.useMemo)(()=>uz($I(n.data?.sessions??[]).filter(dz),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function pz(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)(nc,{session:g,active:y,showUnreadDot:ZN({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Ms(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 mz(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function hz(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)(ye,{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)(pn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(Tn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(Rn,{className:`h-4 w-4`})})}),(0,I.jsxs)(xn,{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)(zs,{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)(hn,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function gz(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=mz({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)(hn,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{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)(Tn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{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)(pn,{className:`h-4 w-4`})})}),(0,I.jsxs)(xn,{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)(zs,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(ye,{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)(pn,{className:`h-4 w-4`})})]})})}function _z({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)(Tn,{open:e,onOpenChange:t,children:[(0,I.jsx)(Cn,{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)(vr,{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)(xn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(w,{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)(vr,{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)(un,{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)(vz,{icon:mr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(vz,{icon:lr,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function vz({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(yo,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(xo,{"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)(zn,{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)(wo,{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)(Eo,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function yz(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function bz(e){return[...e].sort((e,t)=>yz(t)-yz(e))}function xz(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=yz(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 Sz(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=yz(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()||CI(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:bz(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function Cz(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)=>yz(t)-yz(e));return t}function wz(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Tz=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:Mn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:E},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:Fn}];function Ez(e,t,n){let r=tP(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 Dz({variant:e=`desktop`}){let n=e===`mobile`,i=sc(),a=On(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=tP(e=>e.snapshot),p=bt(),m=aL(),{isLoading:h,items:g}=fz(),{language:_,setLanguage:v}=Ar(),{theme:y,setTheme:b}=rs(),x=s(Jr.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Jr.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)(()=>bz(g),[g]),D=(0,F.useMemo)(()=>Cz(g),[g]),O=(0,F.useMemo)(()=>xz(E),[E]),k=(0,F.useMemo)(()=>Sz(E),[E]),A=d.defaultSessionType||`native`,ee=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==A),[A,d.sessionTypeOptions]),j=f.listMode===`project-first`,te=Ez(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:ne,savingSessionKey:re,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:se,saveSessionLabel:ce}=lz(),le=e=>{_!==e&&(v(e),window.location.reload())},ue=e=>(0,I.jsx)(pz,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:te,agentsById:T,childSessionsByParentKey:D,editingSessionKey:M,draftLabel:ne,savingSessionKey:re,sessionTitle:wz,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:ce,onCancelEditingSessionLabel:se},e.session.key),de=(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&&!fs()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Mi,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(sz,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(gz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(hz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,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:Tz.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Ao,{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)(bs,{isProjectFirstView:j,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`)}):j?k.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(dr,{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)(Vs,{groups:k,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:ue,onCreateSession:de}):O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(dr,{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:O.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(ue)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(_z,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:le,onOpenDocs:()=>a.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),onOpenApps:()=>oe(a)})})]})}function Oz(){return Ve({queryKey:[`ncp-session-types`],queryFn:Be,staleTime:1e4,retry:!1})}function kz(e){let t=e.trim();return t.length>0?t:null}function Az(e){return e??null}var jz=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=tP.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:kz(e.selectedModel),preferredThinking:Az(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)}}}},Mz=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new jz(gt),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=()=>oP(vt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=FN(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:AN(e),selectedSkills:jN(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:AN(e),selectedSkills:jN(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(kN(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=PN(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=PN(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=tP.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=IN(e.composerNodes,i);if(GN({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(ON()),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=ML(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(NN(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),zN.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{BN.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})}}},Nz=`sid_`,Pz=`/chat/draft`,Fz=Pz.slice(6);function Iz(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Nz}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Lz(e){if(!e.startsWith(Nz))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 Rz(e){if(!e||e===Fz)return null;let t=Lz(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function zz(e){return`/chat/${Iz(e)}`}var Bz=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=tP.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=tP.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=tP.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=tP.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(tP.getState().markSessionRead(r,i),gt(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=SI(t);this.streamActionsManager.resetStreamState(),tP.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(Pz)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=tP.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=tP.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({query:n})}}},Vz=async()=>{},Hz=()=>{},Uz=class{constructor(){this.actions={sendMessage:Vz,stopCurrentRun:Vz,resumeRun:Vz,resetStreamState:Hz,applyHistoryMessages:Hz},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)}},Wz=async e=>!1,Gz=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:Wz},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(zz(e),t)}}},Kz=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=>{tP.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()||(tP.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}}=tP.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()||tP.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=()=>Pr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=tP.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await ct(e),et(De,e),De.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},qz=class{constructor(){this.chatUiManager=new Gz,this.chatStreamActionsManager=new Uz,this.chatSessionListManager=new Bz(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Mz(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new Kz(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function Jz(e){return e?.trim().toLowerCase()||`native`}function Yz(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function Xz(e,t){return typeof t==`string`&&e.includes(t)}function Zz(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function Qz(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 $z(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:Qz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Yz(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function eB(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:Qz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Xz(t,e),firstAvailableValue:Zz(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function tB(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=Jz(r),o,s=-1/0;for(let e of t){if(e.key===n||Jz(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 nB(e){return e.map(e=>e==null?``:String(e)).join(``)}function rB(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);(0,F.useEffect)(()=>{l.current=s},[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 iB(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;rB({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:nB([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>$z({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function aB(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;rB({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:nB([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>eB({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function oB(){let{pathname:e}=S(),t=C();return Vr(e)?(0,I.jsx)(az,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(Dz,{variant:`mobile`})}var sB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DlT90zQD.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function cB({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserDockControls:a,docBrowserRenderers:o={},sideDock:s,children:c}){let l=Br(e),u=t&&!Vr(e),d=fs();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,d?`rounded-[10px]`:null),style:d?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":l?`280px`:`240px`}:void 0,children:[d?(0,I.jsx)(cs,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!l&&(0,I.jsx)(os,{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:l?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:c}):(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:c})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(sB,{customTabRenderers:o,dockControls:a})}):null,s]})]}),u?(0,I.jsx)(hs,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(sB,{customTabRenderers:o,dockControls:a})}):null]})}var lB=`NextClaw`,uB=[{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 dB(e,t){return e===t||e.startsWith(`${t}/`)}function fB(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of uB)if(dB(t,e))return s(n);return s(`settings`)}function pB(e){return`${lB} - ${fB(e)}`}function mB({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=On();Dr();let{pathname:i}=S(),{language:a}=Ar(),{isMobile:o}=Fr(),s=ds();A(e=>e.pinnedItems);let c={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,F.useEffect)(()=>{document.title=pB(i)},[i,a]),o&&s!==`win32`?(0,I.jsx)(vs,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:c,docBrowserRenderers:ie,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(cB,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:c,docBrowserRenderers:ie,sideDock:(0,I.jsx)(j,{manager:t}),children:e})}function hB({children:e}){let t=ae();return(0,I.jsx)(An,{manager:t.docBrowserManager,children:(0,I.jsx)(mB,{sideDockManager:t.sideDockManager,children:e})})}function gB(){let{isMobile:e}=Fr();return e?(0,I.jsx)(ys,{}):(0,I.jsx)(T,{to:`/model`,replace:!0})}function _B(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function vB(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function yB(e,t){e&&_B(t)&&e.invalidateQueries({queryKey:[`config`]}),vB(e,t)}function bB(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Xe.eventBus.on(Re.connectionOpen,()=>{vt.handleConnectionRestored(),at.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Xe.eventBus.on(Re.connectionClose,()=>{vt.handleConnectionInterrupted(null),t.current=!0}),i=Xe.eventBus.on(Re.connectionError,e=>{vt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Xe.eventBus.on(Re.configUpdated,({path:t})=>{yB(e,t)}),o=Xe.eventBus.on(Re.runtimeUpdateSnapshot,e=>{at.reportSnapshot(e)}),s=Xe.eventBus.on(Re.sessionRunStatus,t=>{Ze(e,{type:`session.run-status`,payload:t})}),c=Xe.eventBus.on(Re.sessionSummaryUpsert,t=>{Ze(e,{type:`session.summary.upsert`,payload:t})}),l=Xe.eventBus.on(Re.sessionSummaryDelete,t=>{Ze(e,{type:`session.summary.delete`,payload:t})}),u=Xe.eventBus.on(Re.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var xB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ModelConfig:e}=await import(`./model-config-CgS6dp65.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,14,3,15,16,11,17]))).ModelConfig})),SB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChatPage:e}=await import(`./chat-page-CXRtoQR2.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28,29,30,15,16,31,32,33]))).ChatPage})),CB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SearchConfig:e}=await import(`./search-config-C04PrmHj.js`);return{SearchConfig:e}},__vite__mapDeps([34,2,13,7,3,23,9,35,6]))).SearchConfig})),wB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ProvidersList:e}=await import(`./providers-list-CZNQXY4n.js`);return{ProvidersList:e}},__vite__mapDeps([36,2,3,20,21,5,13,10,22,31,23,8,9,25,35,6,27,17,16]))).ProvidersList})),TB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-C_Xe0CNX.js`);return{ChannelsList:e}},__vite__mapDeps([37,2,3,13,14,7,23,9,10,35,6,27,33,28,30,17]))).ChannelsList})),EB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-gUjM6Z_A.js`);return{RuntimeConfig:e}},__vite__mapDeps([38,2,13,14,3,32,8,39,40,25,26]))).RuntimeConfig})),DB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-BqABa_1C.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([41,2,13,7,3,24,39]))).DesktopUpdateConfig})),OB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecurityConfig:e}=await import(`./api-CIJxdHmy.js`).then(e=>e.ut);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),kB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-DvxHdz9h.js`);return{SecretsConfig:e}},__vite__mapDeps([42,2,13,8,3,40,25]))).SecretsConfig})),AB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RemoteAccessPage:e}=await import(`./remote-CYmsM9DD.js`);return{RemoteAccessPage:e}},__vite__mapDeps([43,19,2,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28]))).RemoteAccessPage})),jB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-CmZwt64F.js`);return{McpMarketplacePage:e}},__vite__mapDeps([44,29,2,3,20,21,5,13,10,11,26,30]))).McpMarketplacePage}));function MB(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function NB({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(MB,{}),children:e})}function PB(e){return(0,I.jsx)(NB,{children:e})}var FB=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:PB((0,I.jsx)(SB,{view:`chat`}))},{path:`/agents`,element:PB((0,I.jsx)(SB,{view:`agents`}))},{path:`/skills`,element:PB((0,I.jsx)(SB,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:PB((0,I.jsx)(SB,{view:`skills`}))},{path:`/cron`,element:PB((0,I.jsx)(SB,{view:`cron`}))},{path:`/model`,element:PB((0,I.jsx)(xB,{}))},{path:`/search`,element:PB((0,I.jsx)(CB,{}))},{path:`/providers`,element:PB((0,I.jsx)(wB,{}))},{path:`/channels`,element:PB((0,I.jsx)(TB,{}))},{path:`/runtime`,element:PB((0,I.jsx)(EB,{}))},{path:`/updates`,element:PB((0,I.jsx)(DB,{}))},{path:`/remote`,element:PB((0,I.jsx)(AB,{}))},{path:`/security`,element:PB((0,I.jsx)(OB,{}))},{path:`/secrets`,element:PB((0,I.jsx)(kB,{}))},{path:`/language`,element:(0,I.jsx)(as,{})},{path:`/settings`,element:(0,I.jsx)(gB,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:PB((0,I.jsx)(jB,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function IB(e){return`redirectTo`in e?(0,I.jsx)(D,{path:e.path,element:(0,I.jsx)(T,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(D,{path:e.path,element:e.element},e.path)}function LB(){return(0,I.jsx)(x,{children:FB.map(IB)})}function RB(){return bB(De),Ye(),(0,F.useEffect)(()=>(at.start(),()=>{at.stop()}),[]),(0,I.jsxs)(se,{children:[(0,I.jsx)(hB,{children:(0,I.jsx)(LB,{})}),(0,I.jsx)(ce,{}),(0,I.jsx)(ee,{})]})}function zB(){let e=tt(),t=e.isError&&Qe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(RB,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(ne,{username:e.data.username}):(0,I.jsx)(RB,{})}function BB(){return(0,F.useEffect)(()=>{Qo()},[]),(0,I.jsxs)(Ke,{client:De,children:[(0,I.jsx)(zB,{}),(0,I.jsx)(Yo,{}),(0,I.jsx)(Xo,{}),(0,I.jsx)(Le,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var VB=window.nextclawDesktop?.platform===`win32`?te:M;(0,Er.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(ns,{children:(0,I.jsx)(kr,{children:(0,I.jsx)(VB,{children:(0,I.jsx)(BB,{})})})})}));export{mi as $,TP as A,cr as At,$s as B,sL as C,Ar as Ct,QI as D,gr as Dt,$I as E,vr as Et,Z as F,Rn as Ft,yo as G,Is as H,lN as I,Ln as It,xo as J,wo as K,oc as L,Fn as Lt,oP as M,ar as Mt,cP as N,Wn as Nt,CI as O,fr as Ot,tP as P,Un as Pt,ui as Q,sc as R,Mn as Rt,aL as S,Fr as St,rL as T,xr as Tt,Cs as U,Ws as V,Jo as W,ai as X,bo as Y,si as Z,FL as _,xi as _t,qz as a,Ti as at,PL as b,Lr as bt,Dz as c,li as ct,zR as d,_i as dt,Ei as et,BR as f,gi as ft,_R as g,pi as gt,pR as h,di as ht,aB as i,yi as it,AP as j,sr as jt,SI as k,ur as kt,az as l,ci as lt,FR as m,bi as mt,tB as n,hi as nt,Rz as o,wi as ot,IR as p,Oi as pt,Eo as q,iB as r,Ci as rt,Oz as s,vi as st,oB as t,Di as tt,YR as u,ki as ut,ML as v,fi as vt,oL as w,Sr as wt,IL as x,Ir as xt,NL as y,Si as yt,Ks as z};
101
+ `)}}async function*BL(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}=VL(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=VL(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function VL(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=zL(e);t&&i.push(t)}if(t&&r.trim()){let e=zL(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var HL=`/ncp/agent`,UL=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function WL(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function GL(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 KL(e){let t=(e??`/ncp/agent`).trim();if(!t)return HL;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function qL(e){try{return(await e.text()).trim()}catch{return``}}function JL(e){if(QL(e))return e.ncpError;if(XL(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:eR(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function YL(e,t={}){return new UL(e,t.alreadyPublished??!1)}function XL(e){return ZL(e)&&typeof e.code==`string`&&typeof e.message==`string`}function ZL(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function QL(e){return e instanceof UL}var $L={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function eR(e){if(!e)return`runtime-error`;let t=$L[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 tR(e){let t=rR(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function nR(e){let t=rR(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=eR(n),i=ZL(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 rR(e){try{let t=JSON.parse(e);return ZL(t)?t:null}catch{return null}}var iR=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],aR=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=WL(e.baseUrl),this.basePath=KL(e.basePath),this.fetchImpl=GL(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:iR,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:EM.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 qL(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(QL(e))throw e;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(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 qL(n)}`)}catch(e){if(t.signal.aborted)return;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(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 qL(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of BL(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(QL(e))throw e;let n=JL(e);throw this.publish({type:EM.EndpointError,payload:n}),YL(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=tR(e.data);if(!t){this.publish({type:EM.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=nR(e.data);throw this.publish({type:EM.EndpointError,payload:t}),YL(t,{alreadyPublished:!0})}}};function oR(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function sR(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 cR(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function lR(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw vt.reportTransportFailure(sR(n)),cR(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${oR(e)}: ${sR(n)}`,n)}}}var uR=300,dR=`ncp agent unavailable during startup`;function fR(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function pR(e){return e?.trim().toLowerCase().includes(dR)??!1}function mR(){return new aR({baseUrl:he,basePath:`/api/ncp/agent`,fetchImpl:lR()})}async function hR(e,t,n=uR){t.throwIfAborted();try{let r=await it(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!fR(e))throw e;return{messages:[],status:`idle`}}}function gR(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 _R(e,t={}){let[n]=(0,F.useState)(()=>mR()),r=bt(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??uR;(0,F.useEffect)(()=>{s(null)},[e]);let l=iN({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await hR(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 gR(e&&r.phase===`ready`&&pR(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 vR(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function yR(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 bR({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)(qn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(uL,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(dr,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function xR({tab:e}){return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{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)(bR,{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)(_n,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(an,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function SR({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)(xR,{tab:e},e.key))})})}function CR({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 wR({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)(nr,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(qn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(zn,{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)(CR,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(CR,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function TR(e){let t=e.path?.trim()??``;return Ve({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>lt({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function ER(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function DR(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:aF({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function OR(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=lF({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 kR({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 AR({diffBlock:e}){return e?(0,I.jsx)(jR,{block:e}):(0,I.jsx)(kR,{text:s(`chatWorkspaceDiffEmpty`)})}function jR({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(Bj,{block:e,layout:`workspace`})})}function MR({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(kR,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(kR,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(kR,{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)(AA,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(jR,{block:t}):(0,I.jsx)(kR,{text:s(`chatWorkspacePreviewEmpty`)})}function NR({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=TR({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?OR(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=ER({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:DR({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)(wR,{breadcrumb:(0,F.useMemo)(()=>AI({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)(AR,{diffBlock:a}):(0,I.jsx)(MR,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var PR={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function FR(){let[e,t]=(0,F.useState)(PR),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 IR(e){return u(e??void 0)}function LR(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function RR(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 zR(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${RR(t.everyMs)}`:t.kind===`at`?`at ${LR(t.atMs)}`:`-`}function BR(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function VR(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function HR({jobs:e}){let t=Di(),{confirm:n,ConfirmDialog:r}=FR(),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)(ye,{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)(gn,{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`),`:`]}),` `,zR(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,IR(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,IR(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(`cronSessionLabel`),`:`]}),` `,BR(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 UR({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=_R(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=hj({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)($t,{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)(_L,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function WR({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 GR({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)(WR,{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 KR({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)(uL,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(er,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(GR,{tab:e})]})}function qR(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:ZN({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:vR(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 JR({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:c=[],sessionProjectRoot:l,displayMode:u=`docked`}){let d=sc(),f=RL(t),p=tP(e=>e.optimisticReadAtBySessionKey),m=yR({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)(()=>qR({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)(Zt,{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)(_n,{className:`h-4 w-4`})})]}),(0,I.jsx)(SR,{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)(KR,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(UR,{sessionKey:m.tab.sessionKey,onToolAction:d.chatThreadManager.openSessionFromToolAction,onFileOpen:d.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,I.jsx)(NR,{file:m.file,sessionProjectRoot:l,onFileOpen:d.chatThreadManager.openFilePreview}):(0,I.jsx)(HR,{jobs:c})})]}):null}function YR({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var XR=[{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 ZR(){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)(YR,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:XR.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(YR,{"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)(YR,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(YR,{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)(YR,{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)(YR,{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)(YR,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(YR,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(YR,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(YR,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function QR(){let e=sc(),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 $R(){let e=sc(),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=NL(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(NL(c(n),t))},{onScroll:d}=hj({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)(ic,{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)(_L,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function ez(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function tz(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=Ei({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>VR(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:ez(e,t,n,i.length)}}function nz(){let e=sc(),t=Q(e=>e.snapshot);return(0,I.jsx)(kL,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function rz({layoutMode:e,onBackToList:t}){let n=sc(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=tz(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)(AL,{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 iz({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=tz(t);return a?(0,I.jsx)(JR,{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 az({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)(nz,{}),(0,I.jsx)(rz,{layoutMode:e,onBackToList:t}),(0,I.jsx)(QR,{}),(0,I.jsx)($R,{}),(0,I.jsx)(_P,{})]}),(0,I.jsx)(iz,{layoutMode:e})]}):(0,I.jsx)(ZR,{})}var oz={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 sz({status:e,className:t}){let n=oz[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{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)($t,{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)(an,{side:`bottom`,className:`text-xs`,children:i})]})})}function cz(){let e=vL();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function lz(){let e=cz(),[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 uz(e,t){return e.filter(e=>$s(e,t))}function dz(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function fz(e={}){let t=tP(e=>e.snapshot.query),n=wi({limit:e.limit??200}),r=(0,F.useMemo)(()=>uz($I(n.data?.sessions??[]).filter(dz),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function pz(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)(nc,{session:g,active:y,showUnreadDot:ZN({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Ms(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 mz(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function hz(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)(ye,{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)(pn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(Tn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(Rn,{className:`h-4 w-4`})})}),(0,I.jsxs)(xn,{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)(zs,{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)(hn,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function gz(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=mz({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)(hn,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{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)(Tn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Cn,{asChild:!0,children:(0,I.jsx)(ye,{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)(pn,{className:`h-4 w-4`})})}),(0,I.jsxs)(xn,{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)(zs,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(ye,{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)(pn,{className:`h-4 w-4`})})]})})}function _z({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)(Tn,{open:e,onOpenChange:t,children:[(0,I.jsx)(Cn,{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)(vr,{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)(xn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(w,{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)(vr,{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)(un,{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)(vz,{icon:mr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(vz,{icon:lr,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function vz({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(yo,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(xo,{"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)(zn,{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)(wo,{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)(Eo,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function yz(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function bz(e){return[...e].sort((e,t)=>yz(t)-yz(e))}function xz(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=yz(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 Sz(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=yz(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()||CI(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:bz(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function Cz(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)=>yz(t)-yz(e));return t}function wz(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Tz=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:Mn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:E},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:Fn}];function Ez(e,t,n){let r=tP(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 Dz({variant:e=`desktop`}){let n=e===`mobile`,i=sc(),a=On(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=tP(e=>e.snapshot),p=bt(),m=aL(),{isLoading:h,items:g}=fz(),{language:_,setLanguage:v}=Ar(),{theme:y,setTheme:b}=rs(),x=s(Jr.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Jr.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)(()=>bz(g),[g]),D=(0,F.useMemo)(()=>Cz(g),[g]),O=(0,F.useMemo)(()=>xz(E),[E]),k=(0,F.useMemo)(()=>Sz(E),[E]),A=d.defaultSessionType||`native`,ee=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==A),[A,d.sessionTypeOptions]),j=f.listMode===`project-first`,te=Ez(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:ne,savingSessionKey:re,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:se,saveSessionLabel:ce}=lz(),le=e=>{_!==e&&(v(e),window.location.reload())},ue=e=>(0,I.jsx)(pz,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:te,agentsById:T,childSessionsByParentKey:D,editingSessionKey:M,draftLabel:ne,savingSessionKey:re,sessionTitle:wz,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:ce,onCancelEditingSessionLabel:se},e.session.key),de=(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&&!fs()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Mi,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(sz,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(gz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(hz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,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:Tz.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Ao,{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)(bs,{isProjectFirstView:j,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`)}):j?k.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(dr,{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)(Vs,{groups:k,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:ue,onCreateSession:de}):O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(dr,{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:O.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(ue)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(_z,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:le,onOpenDocs:()=>a.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),onOpenApps:()=>oe(a)})})]})}function Oz(){return Ve({queryKey:[`ncp-session-types`],queryFn:Be,staleTime:1e4,retry:!1})}function kz(e){let t=e.trim();return t.length>0?t:null}function Az(e){return e??null}var jz=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=tP.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:kz(e.selectedModel),preferredThinking:Az(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)}}}},Mz=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new jz(gt),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=()=>oP(vt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=FN(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:AN(e),selectedSkills:jN(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:AN(e),selectedSkills:jN(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(kN(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=PN(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=PN(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=tP.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=IN(e.composerNodes,i);if(GN({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(ON()),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=ML(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(NN(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),zN.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{BN.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})}}},Nz=`sid_`,Pz=`/chat/draft`,Fz=Pz.slice(6);function Iz(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Nz}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Lz(e){if(!e.startsWith(Nz))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 Rz(e){if(!e||e===Fz)return null;let t=Lz(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function zz(e){return`/chat/${Iz(e)}`}var Bz=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=tP.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=tP.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=tP.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=tP.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(tP.getState().markSessionRead(r,i),gt(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=SI(t);this.streamActionsManager.resetStreamState(),tP.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(Pz)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=tP.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=tP.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&tP.getState().setSnapshot({query:n})}}},Vz=async()=>{},Hz=()=>{},Uz=class{constructor(){this.actions={sendMessage:Vz,stopCurrentRun:Vz,resumeRun:Vz,resetStreamState:Hz,applyHistoryMessages:Hz},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)}},Wz=async e=>!1,Gz=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:Wz},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(zz(e),t)}}},Kz=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=>{tP.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()||(tP.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}}=tP.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()||tP.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=()=>Pr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=tP.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await ct(e),et(De,e),De.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},qz=class{constructor(){this.chatUiManager=new Gz,this.chatStreamActionsManager=new Uz,this.chatSessionListManager=new Bz(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Mz(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new Kz(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function Jz(e){return e?.trim().toLowerCase()||`native`}function Yz(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function Xz(e,t){return typeof t==`string`&&e.includes(t)}function Zz(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function Qz(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 $z(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:Qz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Yz(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function eB(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:Qz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Xz(t,e),firstAvailableValue:Zz(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function tB(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=Jz(r),o,s=-1/0;for(let e of t){if(e.key===n||Jz(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 nB(e){return e.map(e=>e==null?``:String(e)).join(``)}function rB(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);(0,F.useEffect)(()=>{l.current=s},[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 iB(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;rB({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:nB([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>$z({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function aB(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;rB({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:nB([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>eB({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function oB(){let{pathname:e}=S(),t=C();return Vr(e)?(0,I.jsx)(az,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(Dz,{variant:`mobile`})}var sB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yi02ASOL.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function cB({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserDockControls:a,docBrowserRenderers:o={},sideDock:s,children:c}){let l=Br(e),u=t&&!Vr(e),d=fs();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,d?`rounded-[10px]`:null),style:d?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":l?`280px`:`240px`}:void 0,children:[d?(0,I.jsx)(cs,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!l&&(0,I.jsx)(os,{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:l?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:c}):(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:c})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(sB,{customTabRenderers:o,dockControls:a})}):null,s]})]}),u?(0,I.jsx)(hs,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(sB,{customTabRenderers:o,dockControls:a})}):null]})}var lB=`NextClaw`,uB=[{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 dB(e,t){return e===t||e.startsWith(`${t}/`)}function fB(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of uB)if(dB(t,e))return s(n);return s(`settings`)}function pB(e){return`${lB} - ${fB(e)}`}function mB({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=On();Dr();let{pathname:i}=S(),{language:a}=Ar(),{isMobile:o}=Fr(),s=ds();A(e=>e.pinnedItems);let c={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,F.useEffect)(()=>{document.title=pB(i)},[i,a]),o&&s!==`win32`?(0,I.jsx)(vs,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:c,docBrowserRenderers:ie,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(cB,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:c,docBrowserRenderers:ie,sideDock:(0,I.jsx)(j,{manager:t}),children:e})}function hB({children:e}){let t=ae();return(0,I.jsx)(An,{manager:t.docBrowserManager,children:(0,I.jsx)(mB,{sideDockManager:t.sideDockManager,children:e})})}function gB(){let{isMobile:e}=Fr();return e?(0,I.jsx)(ys,{}):(0,I.jsx)(T,{to:`/model`,replace:!0})}function _B(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function vB(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function yB(e,t){e&&_B(t)&&e.invalidateQueries({queryKey:[`config`]}),vB(e,t)}function bB(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Xe.eventBus.on(Re.connectionOpen,()=>{vt.handleConnectionRestored(),at.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Xe.eventBus.on(Re.connectionClose,()=>{vt.handleConnectionInterrupted(null),t.current=!0}),i=Xe.eventBus.on(Re.connectionError,e=>{vt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Xe.eventBus.on(Re.configUpdated,({path:t})=>{yB(e,t)}),o=Xe.eventBus.on(Re.runtimeUpdateSnapshot,e=>{at.reportSnapshot(e)}),s=Xe.eventBus.on(Re.sessionRunStatus,t=>{Ze(e,{type:`session.run-status`,payload:t})}),c=Xe.eventBus.on(Re.sessionSummaryUpsert,t=>{Ze(e,{type:`session.summary.upsert`,payload:t})}),l=Xe.eventBus.on(Re.sessionSummaryDelete,t=>{Ze(e,{type:`session.summary.delete`,payload:t})}),u=Xe.eventBus.on(Re.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var xB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ModelConfig:e}=await import(`./model-config-C9ydDDFh.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,14,3,15,16,11,17]))).ModelConfig})),SB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChatPage:e}=await import(`./chat-page-CImtIhmN.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28,29,30,15,16,31,32,33]))).ChatPage})),CB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SearchConfig:e}=await import(`./search-config-RN01uPJQ.js`);return{SearchConfig:e}},__vite__mapDeps([34,2,13,7,3,23,9,35,6]))).SearchConfig})),wB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ProvidersList:e}=await import(`./providers-list-9eOBQFUn.js`);return{ProvidersList:e}},__vite__mapDeps([36,2,3,20,21,5,13,10,22,31,23,8,9,25,35,6,27,17,16]))).ProvidersList})),TB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-PrT4a9g4.js`);return{ChannelsList:e}},__vite__mapDeps([37,2,3,13,14,7,23,9,10,35,6,27,33,28,30,17]))).ChannelsList})),EB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-B30PC6bx.js`);return{RuntimeConfig:e}},__vite__mapDeps([38,2,13,14,3,32,8,39,40,25,26]))).RuntimeConfig})),DB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-p3rJIgRg.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([41,2,13,7,3,24,39]))).DesktopUpdateConfig})),OB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecurityConfig:e}=await import(`./api-CA2udGyv.js`).then(e=>e.ut);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),kB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-CTZ_TGoA.js`);return{SecretsConfig:e}},__vite__mapDeps([42,2,13,8,3,40,25]))).SecretsConfig})),AB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RemoteAccessPage:e}=await import(`./remote-fGlxrJI_.js`);return{RemoteAccessPage:e}},__vite__mapDeps([43,19,2,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28]))).RemoteAccessPage})),jB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-DNHSmfDf.js`);return{McpMarketplacePage:e}},__vite__mapDeps([44,29,2,3,20,21,5,13,10,11,26,30]))).McpMarketplacePage}));function MB(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function NB({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(MB,{}),children:e})}function PB(e){return(0,I.jsx)(NB,{children:e})}var FB=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:PB((0,I.jsx)(SB,{view:`chat`}))},{path:`/agents`,element:PB((0,I.jsx)(SB,{view:`agents`}))},{path:`/skills`,element:PB((0,I.jsx)(SB,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:PB((0,I.jsx)(SB,{view:`skills`}))},{path:`/cron`,element:PB((0,I.jsx)(SB,{view:`cron`}))},{path:`/model`,element:PB((0,I.jsx)(xB,{}))},{path:`/search`,element:PB((0,I.jsx)(CB,{}))},{path:`/providers`,element:PB((0,I.jsx)(wB,{}))},{path:`/channels`,element:PB((0,I.jsx)(TB,{}))},{path:`/runtime`,element:PB((0,I.jsx)(EB,{}))},{path:`/updates`,element:PB((0,I.jsx)(DB,{}))},{path:`/remote`,element:PB((0,I.jsx)(AB,{}))},{path:`/security`,element:PB((0,I.jsx)(OB,{}))},{path:`/secrets`,element:PB((0,I.jsx)(kB,{}))},{path:`/language`,element:(0,I.jsx)(as,{})},{path:`/settings`,element:(0,I.jsx)(gB,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:PB((0,I.jsx)(jB,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function IB(e){return`redirectTo`in e?(0,I.jsx)(D,{path:e.path,element:(0,I.jsx)(T,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(D,{path:e.path,element:e.element},e.path)}function LB(){return(0,I.jsx)(x,{children:FB.map(IB)})}function RB(){return bB(De),Ye(),(0,F.useEffect)(()=>(at.start(),()=>{at.stop()}),[]),(0,I.jsxs)(se,{children:[(0,I.jsx)(hB,{children:(0,I.jsx)(LB,{})}),(0,I.jsx)(ce,{}),(0,I.jsx)(ee,{})]})}function zB(){let e=tt(),t=e.isError&&Qe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(RB,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(ne,{username:e.data.username}):(0,I.jsx)(RB,{})}function BB(){return(0,F.useEffect)(()=>{Qo()},[]),(0,I.jsxs)(Ke,{client:De,children:[(0,I.jsx)(zB,{}),(0,I.jsx)(Yo,{}),(0,I.jsx)(Xo,{}),(0,I.jsx)(Le,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var VB=window.nextclawDesktop?.platform===`win32`?te:M;(0,Er.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(ns,{children:(0,I.jsx)(kr,{children:(0,I.jsx)(VB,{children:(0,I.jsx)(BB,{})})})})}));export{mi as $,TP as A,cr as At,$s as B,sL as C,Ar as Ct,QI as D,gr as Dt,$I as E,vr as Et,Z as F,Rn as Ft,yo as G,Is as H,lN as I,Ln as It,xo as J,wo as K,oc as L,Fn as Lt,oP as M,ar as Mt,cP as N,Wn as Nt,CI as O,fr as Ot,tP as P,Un as Pt,ui as Q,sc as R,Mn as Rt,aL as S,Fr as St,rL as T,xr as Tt,Cs as U,Ws as V,Jo as W,ai as X,bo as Y,si as Z,FL as _,xi as _t,qz as a,Ti as at,PL as b,Lr as bt,Dz as c,li as ct,zR as d,_i as dt,Ei as et,BR as f,gi as ft,_R as g,pi as gt,pR as h,di as ht,aB as i,yi as it,AP as j,sr as jt,SI as k,ur as kt,az as l,ci as lt,FR as m,bi as mt,tB as n,hi as nt,Rz as o,wi as ot,IR as p,Oi as pt,Eo as q,iB as r,Ci as rt,Oz as s,vi as st,oB as t,Di as tt,YR as u,ki as ut,ML as v,fi as vt,oL as w,Sr as wt,IL as x,Ir as xt,NL as y,Si as yt,Ks as z};