nextclaw 0.21.2 → 0.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/app/index.js +1 -1
- package/dist/cli/app/index.js.map +1 -1
- package/package.json +16 -16
- package/resources/USAGE.md +2 -2
- package/ui-dist/assets/{api-BCDb13Uv.js → api-CIJxdHmy.js} +5 -5
- package/ui-dist/assets/app-presenter-provider-CKZqZfv5.js +3 -0
- package/ui-dist/assets/arrow-left-DHcD-tbC.js +1 -0
- package/ui-dist/assets/channels-list-page-C_Xe0CNX.js +8 -0
- package/ui-dist/assets/chat-page-CXRtoQR2.js +105 -0
- package/ui-dist/assets/{config-split-page-BwhGqmUS.js → config-split-page-DBAcw9mJ.js} +1 -1
- package/ui-dist/assets/{confirm-dialog-DBkKcQ1q.js → confirm-dialog-DwPTxq8C.js} +1 -1
- package/ui-dist/assets/{desktop-update-config-BE9KjiXi.js → desktop-update-config-BqABa_1C.js} +1 -1
- package/ui-dist/assets/{dist-BI0bX8jv.js → dist-BfcibKyv.js} +1 -1
- package/ui-dist/assets/{dist-C8JRt-tf.js → dist-WjhKB-pc.js} +1 -1
- package/ui-dist/assets/{doc-browser-eqdNEerh.js → doc-browser-8EEDwGCJ.js} +1 -1
- package/ui-dist/assets/doc-browser-DlT90zQD.js +1 -0
- package/ui-dist/assets/{doc-browser-context-VHUOIUXL.js → doc-browser-context-DLJOy6Am.js} +1 -1
- package/ui-dist/assets/{ellipsis-C9VB2CxT.js → ellipsis-H-4aNwgt.js} +1 -1
- package/ui-dist/assets/{es2015-BCw3Q7nY.js → es2015-B5k1IpKX.js} +1 -1
- package/ui-dist/assets/{external-link-Bp7_4s9t.js → external-link-BN1wd-eI.js} +1 -1
- package/ui-dist/assets/{index-DTdPDqto.js → index-WJt0X9wC.js} +5 -5
- package/ui-dist/assets/{key-round-Ccy6oND3.js → key-round-D-7IaAQS.js} +1 -1
- package/ui-dist/assets/{loader-circle-OpH4EErP.js → loader-circle-CB38Q7Ws.js} +1 -1
- package/ui-dist/assets/mcp-marketplace-page-CmZwt64F.js +1 -0
- package/ui-dist/assets/{mcp-marketplace-page-B-GxKOqS.js → mcp-marketplace-page-ju1KH3TG.js} +2 -2
- package/ui-dist/assets/{model-config-BXPnV_7n.js → model-config-CgS6dp65.js} +1 -1
- package/ui-dist/assets/{notice-card-Dsbkl7u7.js → notice-card-DW9BLKpG.js} +1 -1
- package/ui-dist/assets/play-DGpH8jeI.js +1 -0
- package/ui-dist/assets/plus-CkcQjwuH.js +1 -0
- package/ui-dist/assets/{popover-BTLZE5Iz.js → popover-ofN845gZ.js} +1 -1
- package/ui-dist/assets/{provider-scoped-model-input-DKI9KN7N.js → provider-scoped-model-input-DaDqi8Zy.js} +1 -1
- package/ui-dist/assets/providers-list-CZNQXY4n.js +1 -0
- package/ui-dist/assets/{react-BqS8oMyM.js → react-Bq34NL59.js} +1 -1
- package/ui-dist/assets/{refresh-cw-BIaj7txb.js → refresh-cw-DJttSXS8.js} +1 -1
- package/ui-dist/assets/remote-CYmsM9DD.js +1 -0
- package/ui-dist/assets/rotate-cw-D_xslHna.js +1 -0
- package/ui-dist/assets/{runtime-config-page-DX_wSK1J.js → runtime-config-page-gUjM6Z_A.js} +1 -1
- package/ui-dist/assets/{save-BEoORten.js → save-DtAFbS7x.js} +1 -1
- package/ui-dist/assets/search-CNMRwAFx.js +1 -0
- package/ui-dist/assets/{search-config-DA5By-tE.js → search-config-C04PrmHj.js} +1 -1
- package/ui-dist/assets/{secrets-config-eDxG7iN4.js → secrets-config-DvxHdz9h.js} +2 -2
- package/ui-dist/assets/{status-dot-oWBjTovo.js → status-dot-D4jbKDLB.js} +1 -1
- package/ui-dist/assets/{tabs-CGaY0BVO.js → tabs-Ca2vw7YQ.js} +1 -1
- package/ui-dist/assets/{tabs-custom-D2fPYb4G.js → tabs-custom-DzGDjYxf.js} +1 -1
- package/ui-dist/assets/{tag-chip-TVkgofS1.js → tag-chip-CW-_pHjH.js} +1 -1
- package/ui-dist/assets/{tooltip-BwHPKBv9.js → tooltip-Cq2mERPk.js} +1 -1
- package/ui-dist/assets/{trash-2-D3psAGrz.js → trash-2-rumaEu9l.js} +1 -1
- package/ui-dist/assets/x-DGqjdMUt.js +1 -0
- package/ui-dist/index.html +24 -24
- package/ui-dist/assets/app-presenter-provider-C-QMjK7m.js +0 -3
- package/ui-dist/assets/arrow-left-rIXFA2Zy.js +0 -1
- package/ui-dist/assets/channels-list-page-DnqwsKGe.js +0 -8
- package/ui-dist/assets/chat-page-CsQx20xL.js +0 -105
- package/ui-dist/assets/doc-browser-lpF_pyx4.js +0 -1
- package/ui-dist/assets/mcp-marketplace-page-Dm-0-w51.js +0 -1
- package/ui-dist/assets/play-CvgYhNbo.js +0 -1
- package/ui-dist/assets/plus-DHcP-K1U.js +0 -1
- package/ui-dist/assets/providers-list-Bko6B7dE.js +0 -1
- package/ui-dist/assets/remote-DHn_b8QU.js +0 -1
- package/ui-dist/assets/rotate-cw-DMqSkRJQ.js +0 -1
- package/ui-dist/assets/search-COFh_SFI.js +0 -1
- package/ui-dist/assets/x-CHAxzyp2.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-
|
|
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-BqS8oMyM.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-C-QMjK7m.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-BCDb13Uv.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-C8JRt-tf.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./es2015-BCw3Q7nY.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-DBkKcQ1q.js";import{t as Xt}from"./arrow-left-rIXFA2Zy.js";import{n as Zt}from"./doc-browser-eqdNEerh.js";import{n as Qt,t as $t}from"./loader-circle-OpH4EErP.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-BwHPKBv9.js";import{t as dn}from"./external-link-Bp7_4s9t.js";import{t as fn}from"./key-round-Ccy6oND3.js";import{t as pn}from"./plus-DHcP-K1U.js";import{t as mn}from"./refresh-cw-BIaj7txb.js";import{t as hn}from"./search-COFh_SFI.js";import{t as gn}from"./trash-2-D3psAGrz.js";import{t as _n}from"./x-CHAxzyp2.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-BTLZE5Iz.js";import{c as En,m as Dn,n as On,s as kn,t as An}from"./doc-browser-context-VHUOIUXL.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=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`,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 n(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?s(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function 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-lpF_pyx4.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-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=`
|
|
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]===`
|
|
@@ -14,7 +14,7 @@ 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 a
|
|
|
14
14
|
`}isInline(){return!1}updateDOM(){return!1}};function mv(){return{node:hv()}}function hv(){return Bh(pv)}var gv=Pg({name:`@lexical/react/ReactProvider`});function _v(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=H();if(V(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(B(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),B(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function vv(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=Lm().getChildren();for(let i=0;i<r.length;i++)yv(e,r[i],n,t);return n.innerHTML}function yv(e,t,n,r=null){let i=r===null||t.isSelected(r),a=U(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&B(t)&&(o=Kg(r,t,`clone`));let s=U(o)?o.getChildren():[],c=fm(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=yv(e,a,f,r);!i&&U(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((wh(u)||Eh(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(Eh(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function bv(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 xv(e,t=H()){return t??bv(166),V(t)&&t.isCollapsed()||t.getNodes().length===0?``:vv(e,t)}function Sv(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var Cv=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,wv=Cv&&`documentMode`in document?document.documentMode:null,Tv=Cv&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ev=!(!Cv||!(`InputEvent`in window)||wv)&&`getTargetRanges`in new window.InputEvent(`input`),Dv=Cv&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ov=Cv&&/Android/.test(navigator.userAgent),kv=Cv&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Ov,Av=Cv&&/^(?=.*Chrome).*/i.test(navigator.userAgent),jv=Cv&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Tv&&!Av;function Mv(e,t){t.update(()=>{if(e!==null){let n=t_(e,KeyboardEvent)?null:e.clipboardData,r=H();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=xv(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Nv(e){return zg(e.registerCommand(Wu,e=>{let t=H();return!!V(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Xu,e=>{let t=H();return!!V(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(Zu,e=>{let t=H();return!!V(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(qu,e=>{let t=H();if(!V(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)Sv(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(Yu,()=>{let e=H();return!!V(e)&&(e.removeText(),!0)},0),e.registerCommand(Gu,e=>{let t=H();return!!V(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(Ku,()=>{let e=H();return!!V(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(id,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Yg(t,!0)&&(n.preventDefault(),Qg(t,r,!0),!0)},0),e.registerCommand(nd,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Yg(t,!1)&&(n.preventDefault(),Qg(t,r,!1),!0)},0),e.registerCommand(ud,t=>!!V(H())&&(!Dv||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(Wu,!0)),0),e.registerCommand(fd,t=>!!V(H())&&(t.preventDefault(),e.dispatchCommand(Wu,!1)),0),e.registerCommand(cd,t=>{if(!V(H()))return!1;if(t!==null){if((Dv||kv||jv)&&Ev)return!1;t.preventDefault()}return e.dispatchCommand(Gu,!1)},0),e.registerCommand(bd,()=>(th(),!0),0),e.registerCommand(vd,t=>!!V(H())&&(Mv(t,e),!0),0),e.registerCommand(yd,t=>!!V(H())&&(function(e,t){Mv(e,t),t.update(()=>{let e=H();V(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(Ju,t=>!!V(H())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=H(),n=t_(e,ClipboardEvent)?e.clipboardData:null;n!=null&&V(t)&&Sv(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(md,e=>!!V(H())&&(e.preventDefault(),!0),0),e.registerCommand(hd,e=>!!V(H())&&(e.preventDefault(),!0),0))}function Pv(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.`)}var Fv=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?F.useLayoutEffect:F.useEffect;function Iv({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,F.useState)(()=>e.getDecorators());return Fv(()=>e.registerDecoratorListener(e=>{(0,Ri.flushSync)(()=>{r(e)})}),[e]),(0,F.useEffect)(()=>{r(e.getDecorators())},[e]),(0,F.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,I.jsx)(t,{onError:t=>e._onError(t),children:(0,I.jsx)(F.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,Ri.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function Lv({editor:e,ErrorBoundary:t}){return function(e){let t=fv.maybeFromEditor(e);if(t&&t.hasExtensionByName(gv.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&Pv(320,e);return!0}return!1}(e)?null:(0,I.jsx)(Iv,{editor:e,ErrorBoundary:t})}function Rv(e){return e.getEditorState().read(Ug(e.isComposing()))}function zv({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=$c();return function(e){Fv(()=>zg(Nv(e),_v(e)),[e])}(r),(0,I.jsxs)(I.Fragment,{children:[e,(0,I.jsx)(Bv,{content:t}),(0,I.jsx)(Lv,{editor:r,ErrorBoundary:n})]})}function Bv({content:e}){let[t]=$c(),n=function(e){let[t,n]=(0,F.useState)(()=>Rv(e));return Fv(()=>{function t(){n(Rv(e))}return t(),zg(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=x_();return n?typeof e==`function`?e(r):e:null}function Vv(){return`composer-${Math.random().toString(36).slice(2,10)}`}function Hv(e=``){return{id:Vv(),type:`text`,text:e}}function Uv(e){return{id:Vv(),type:`token`,tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function Wv(e){return e.type===`text`?e.text.length:1}function Gv(){return[Hv(``)]}function Kv(e){return[Hv(e)]}function qv(e){let t=[];for(let n of e){if(n.type===`text`){if(n.text.length===0)continue;let e=t[t.length-1];if(e?.type===`text`){t[t.length-1]={...e,text:e.text+n.text};continue}}t.push(n)}return t.length===0?Gv():t}function Jv(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}function Yv(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Xv(e,t){let n=[],r=new Set;for(let i of e)i.type!==`token`||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function Zv(e,t,n,r){let i=Math.max(0,n-t),a=Math.max(0,t+e.text.length-r),o=[];return i>0&&o.push({...e,text:e.text.slice(0,i)}),a>0&&o.push({...e,text:e.text.slice(e.text.length-a)}),o}function Qv(e,t,n,r){return t<=n||e>=r}function $v(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function ey(e,t,n,r,i,a,o){let s=Zv(t,n,r,i);s[0]&&e.push(s[0]);let c=o;return c||=(e.push(...a),!0),s[1]&&e.push(s[1]),c}function ty(e,t,n,r,i,a){return!r&&i<=a?(e.push(...n),!0):(e.push(t),r)}function ny(e,t,n,r){let i=Math.max(0,t),a=Math.max(i,n),o=[],s=0,c=!1;for(let t of e){let e=Wv(t),n=s,l=s+e;if(Qv(n,l,i,a)){c=$v(o,r,c,n,a),o.push(t),s=l;continue}c=t.type===`text`?ey(o,t,n,i,a,r,c):ty(o,t,r,c,i,n),s=l}return c||o.push(...r),qv(o)}function ry(e,t){return qv(e.filter(e=>e.type!==`token`||!t(e)))}function iy(e,t){if(!t||t.start!==t.end)return null;let n=Jv(e),r=t.end,i=n.slice(0,r),a=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!a)return null;let o=r-a[0].length+(a[0].startsWith(`/`)?0:1);return{query:(a[1]??``).trim().toLowerCase(),start:o,end:r}}function ay(e){return e===`file`?[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-[min(100%,17rem)]`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`border-slate-200/80`,`bg-slate-50`,`px-2`,`align-baseline`,`text-slate-700`,`transition-[border-color,background-color,box-shadow,color]`,`duration-150`].join(` `):[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-full`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`border-primary/12`,`bg-primary/8`,`px-2`,`align-baseline`,`text-[11px]`,`font-medium`,`text-primary`,`transition`].join(` `)}function oy(e){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:e.tokenKind===`file`?`inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-white text-slate-500 ring-1 ring-black/5`:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70`,children:e.tokenKind===`file`?(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,I.jsx)(`path`,{d:`M3.25 4.25A1.5 1.5 0 0 1 4.75 2.75h6.5a1.5 1.5 0 0 1 1.5 1.5v7.5a1.5 1.5 0 0 1-1.5 1.5h-6.5a1.5 1.5 0 0 1-1.5-1.5v-7.5Z`}),(0,I.jsx)(`path`,{d:`m4.75 10 2.25-2.5 1.75 1.75 1.25-1.25 2 2`}),(0,I.jsx)(`path`,{d:`M9.75 6.25h.01`})]}):(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,I.jsx)(`path`,{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}),(0,I.jsx)(`path`,{d:`M2.75 10 8.5 13.25 14.25 10`}),(0,I.jsx)(`path`,{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}),(0,I.jsx)(`path`,{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`})]})}),(0,I.jsx)(`span`,{className:e.tokenKind===`file`?`min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700`:`truncate`,children:e.label})]})}var sy=class e extends Hp{static getType(){return`chat-composer-token`}static clone(t){return new e(t.__composerId,t.__tokenKind,t.__tokenKey,t.__label,t.__key)}static importJSON(e){return cy({composerId:e.composerId,label:e.label,tokenKey:e.tokenKey,tokenKind:e.tokenKind})}constructor(e,t,n,r,i){super(i),this.applyTokenDom=e=>{e.contentEditable=`false`,e.dataset.composerNodeId=this.__composerId,e.dataset.composerNodeType=`token`,e.dataset.composerTokenKind=this.__tokenKind,e.dataset.composerTokenKey=this.__tokenKey,e.dataset.composerLabel=this.__label,e.title=this.__label,e.className=ay(this.__tokenKind)},this.createDOM=(e,t)=>{let n=document.createElement(`span`);return this.applyTokenDom(n),n},this.updateDOM=(e,t)=>(this.applyTokenDom(t),!1),this.decorate=()=>(0,I.jsx)(oy,{label:this.__label,tokenKind:this.__tokenKind}),this.exportJSON=()=>({composerId:this.__composerId,label:this.__label,tokenKey:this.__tokenKey,tokenKind:this.__tokenKind,type:`chat-composer-token`,version:1}),this.getComposerId=()=>this.getLatest().__composerId,this.getTokenKind=()=>this.getLatest().__tokenKind,this.getTokenKey=()=>this.getLatest().__tokenKey,this.getLabel=()=>this.getLatest().__label,this.getTextContent=()=>``,this.isInline=()=>!0,this.isIsolated=()=>!0,this.isKeyboardSelectable=()=>!1,this.__composerId=e,this.__tokenKind=t,this.__tokenKey=n,this.__label=r}};function cy(e){let{composerId:t,label:n,tokenKey:r,tokenKind:i}=e;return _h(new sy(t,i,r,n))}function ly(e){return e instanceof sy}function uy(){let e=Lm(),t=e.getFirstChild();if(!U(t))return{descriptors:[],paragraphKey:e.getKey(),paragraphSize:0,totalLength:0};let n=t.getChildren(),r=[],i=0;for(let[e,t]of n.entries()){if(B(t)){let n=t.getTextContent();r.push({index:e,key:t.getKey(),length:n.length,node:t,start:i,text:n,type:`text`}),i+=n.length;continue}if(ly(t)){r.push({index:e,key:t.getKey(),length:1,node:t,start:i,type:`token`}),i+=1;continue}r.push({index:e,key:t.getKey(),length:t.getTextContent().length,node:t,start:i,type:`linebreak`}),i+=t.getTextContent().length}return{descriptors:r,paragraphKey:t.getKey(),paragraphSize:n.length,totalLength:i}}function dy(e){let{descriptors:t,paragraphKey:n,paragraphSize:r,totalLength:i}=uy(),a=Math.max(0,Math.min(e,i));if(t.length===0)return{key:n,offset:0,type:`element`};for(let e of t){let r=e.start+e.length;if(e.type===`text`&&a>=e.start&&a<=r)return{key:e.key,offset:a-e.start,type:`text`};if(e.type!==`text`){if(a===e.start)return{key:n,offset:e.index,type:`element`};if(a===r){let r=t[e.index+1];return r?.type===`text`&&r.length===0?{key:r.key,offset:0,type:`text`}:{key:n,offset:e.index+1,type:`element`}}}}return{key:n,offset:r,type:`element`}}function fy(e){let{descriptors:t,paragraphKey:n,totalLength:r}=uy();if(e.key===n){let n=t[e.offset-1];return n?n.start+n.length:0}let i=t.find(t=>t.key===e.key);return i?i.start+Math.min(e.offset,i.length):r}function py(e){if(e.type===`element`)return fy(e);let{descriptors:t,totalLength:n}=uy(),r=t.find(t=>t.key===e.key);return r?r.start+Math.min(e.offset,r.length):n}function my(){let{descriptors:e}=uy(),t=[],n=``,r=``,i=()=>{n.length!==0&&(t.push({id:r,type:`text`,text:n}),n=``,r=``)};for(let a of e){if(a.type===`text`){n.length===0&&(r=a.key),n+=a.text;continue}if(a.type===`linebreak`){n.length===0&&(r=a.key),n+=`
|
|
15
15
|
`;continue}i();let e=a.node;t.push({id:e.getComposerId(),label:e.getLabel(),tokenKey:e.getTokenKey(),tokenKind:e.getTokenKind(),type:`token`})}return i(),qv(t)}function hy(e){return e.read(()=>{let e=H(),t=my();return V(e)?{nodes:t,selection:{start:Math.min(py(e.anchor),py(e.focus)),end:Math.max(py(e.anchor),py(e.focus))}}:{nodes:t,selection:null}})}function gy(e,t){let n=Lm();n.clear();let r=em();n.append(r);for(let t of qv(e)){if(t.type===`token`){r.append(cy({composerId:t.id,label:t.label,tokenKey:t.tokenKey,tokenKind:t.tokenKind}));continue}let e=t.text.split(`
|
|
16
16
|
`);for(let[t,n]of e.entries())n.length>0&&r.append(Mf(n)),t<e.length-1&&r.append(mf())}if(ly(r.getLastChild())&&r.append(Mf(``)),!t)return;let i=ep(),a=dy(t.start),o=dy(t.end);i.anchor.set(a.key,a.offset,a.type),i.focus.set(o.key,o.offset,o.type),zm(i)}function _y(e,t,n){e.update(()=>{gy(t,n)})}function vy(e,t){e.update(()=>{let e=ep(),n=dy(t.start),r=dy(t.end);e.anchor.set(n.key,n.offset,n.type),e.focus.set(r.key,r.offset,r.type),zm(e)})}function yy(e){return e.reduce((e,t)=>e+Wv(t),0)}function by(e){let{label:t,nodes:n,selection:r,tokenKey:i,tokenKind:a,trigger:o}=e,s=yy(n),[c,l]=r?[Math.min(r.start,r.end),Math.max(r.start,r.end)]:[s,s],u=o?.start??c;return{nodes:ny(n,u,o?.end??l,[Uv({label:t,tokenKey:i,tokenKind:a})]),selection:{start:u+1,end:u+1}}}function xy(e){return e.map(e=>e.type===`text`?`text:${e.id}:${e.text}`:`token:${e.id}:${e.tokenKind}:${e.tokenKey}:${e.label}`).join(``)}function Sy(e){let{nodes:t,selection:n,text:r}=e,i=yy(t),[a,o]=n?[Math.min(n.start,n.end),Math.max(n.start,n.end)]:[i,i],s=a+r.length;return{nodes:ny(t,a,o,[Hv(r)]),selection:{start:s,end:s}}}function Cy(e){let{label:t,nodes:n,selection:r,tokenKey:i}=e;return by({label:t,nodes:n,selection:r,tokenKey:i,tokenKind:`file`})}function wy(e){let{label:t,nodes:n,selection:r,tokenKey:i}=e;return Xv(n,`skill`).includes(i)?{nodes:qv(n),selection:r}:by({label:t,nodes:n,selection:r,tokenKey:i,tokenKind:`skill`,trigger:iy(n,r)})}function Ty(e){let{nextKeys:t,nodes:n,options:r,selection:i}=e,a=Xv(n,`skill`),o=new Map(r.map(e=>[e.key,e])),s=t.find(e=>!a.includes(e));if(s)return wy({label:o.get(s)?.label??s,nodes:n,selection:i,tokenKey:s});let c=a.find(e=>!t.includes(e));return c?{nodes:ry(n,e=>e.tokenKind===`skill`&&e.tokenKey===c),selection:i}:{nodes:qv(n),selection:i}}function Ey(e){let{direction:t,nodes:n,selection:r}=e,i=yy(n),[a,o]=r?[Math.min(r.start,r.end),Math.max(r.start,r.end)]:[i,i],s=a,c=o;if(s===c)if(t===`backward`&&s>0)--s;else if(t===`forward`&&c<i)c+=1;else return{nodes:qv(n),selection:{start:s,end:c}};return{nodes:ny(n,s,c,[]),selection:{start:s,end:s}}}function Dy(e){let{activeSlashIndex:t,canStopGeneration:n,isComposing:r,isSending:i,isSlashMenuOpen:a,key:o,shiftKey:s,slashItemCount:c}=e;if(o===`Enter`&&!s&&i)return{type:`consume`};if(a&&c>0){if(o===`ArrowDown`)return{type:`move-slash-index`,index:(t+1)%c};if(o===`ArrowUp`)return{type:`move-slash-index`,index:(t-1+c)%c};if(o===`Enter`&&!s||o===`Tab`)return{type:`insert-active-slash-item`}}return o===`Escape`?a?{type:`close-slash`}:i&&n?{type:`stop-generation`}:{type:`noop`}:o===`Enter`&&s?{type:`insert-line-break`}:o===`Enter`?{type:`send-message`}:!r&&(o===`Backspace`||o===`Delete`)?{type:`delete-content`,direction:o===`Backspace`?`backward`:`forward`}:{type:`noop`}}var Oy=class{constructor(e){this.params=e,this.insertSlashItem=e=>{e.value&&(this.params.onSlashItemSelect?.(e),this.params.publishSnapshot(wy({label:e.title,nodes:this.params.optionsReader().nodes,selection:this.params.optionsReader().selection,tokenKey:e.value}),{focusAfterSync:!0}))},this.insertFileToken=(e,t)=>{this.params.publishSnapshot(Cy({label:t,nodes:this.params.optionsReader().nodes,selection:this.params.optionsReader().selection,tokenKey:e}),{focusAfterSync:!0})},this.insertFileTokens=e=>{let t=this.params.optionsReader().nodes,n=this.params.optionsReader().selection;for(let r of e){let e=Cy({label:r.label,nodes:t,selection:n,tokenKey:r.tokenKey});t=e.nodes,n=e.selection}this.params.publishSnapshot({nodes:t,selection:n},{focusAfterSync:!0})},this.focusComposer=()=>{this.params.focusComposer()},this.focusComposerAtEnd=()=>{this.params.focusComposerAtEnd()},this.syncSelectedSkills=(e,t)=>{this.params.publishSnapshot(Ty({nextKeys:e,nodes:this.params.optionsReader().nodes,options:t,selection:this.params.optionsReader().selection}),{focusAfterSync:!0})}}};function ky(e){return new Oy(e)}function Ay(e){return JSON.stringify(e.map(e=>e.type===`text`?{text:e.text,type:e.type}:{label:e.label,tokenKey:e.tokenKey,tokenKind:e.tokenKind,type:e.type}))}function jy(e){let{disabled:t,event:n,isComposing:r,publishSnapshot:i,snapshotReader:a}=e,o=n.nativeEvent,s=o.inputType===`insertText`||o.inputType===`insertReplacementText`;t||r||o.isComposing||!s||!o.data||(n.preventDefault(),i(Sy({nodes:a().nodes,selection:a().selection,text:o.data})))}function My(e){let{data:t,fallbackSnapshot:n,publishSnapshot:r,snapshotReader:i}=e,a=i(),o=n();r(Ay(o.nodes)===Ay(a.nodes)&&t.length>0?Sy({nodes:a.nodes,selection:a.selection,text:t}):o,{forcePublish:!0})}function Ny(e){let{actions:t,activeSlashIndex:n,nativeEvent:r,onSlashActiveIndexChange:i,onSlashItemSelect:a,onSlashOpenChange:o,onSlashQueryChange:s,publishSnapshot:c,slashItems:l,snapshot:u}=e,d=Dy({activeSlashIndex:n,canStopGeneration:t.canStopGeneration,isComposing:r.isComposing,isSending:t.isSending,isSlashMenuOpen:iy(u.nodes,u.selection)!==null,key:r.key,shiftKey:r.shiftKey,slashItemCount:l.length}),f=l[n]??null;switch(d.type!==`noop`&&r.preventDefault(),d.type){case`move-slash-index`:return i(d.index),!0;case`insert-active-slash-item`:return f?(a?.(f),c(wy({label:f.title,nodes:u.nodes,selection:u.selection,tokenKey:f.value??f.key}),{focusAfterSync:!0}),!0):!0;case`close-slash`:return s?.(null),o(!1),!0;case`consume`:return!0;case`stop-generation`:return t.onStop(),!0;case`insert-line-break`:return c(Sy({nodes:u.nodes,selection:u.selection,text:`
|
|
17
|
-
`})),!0;case`send-message`:return t.onSend(),!0;case`delete-content`:return c(Ey({direction:d.direction,nodes:u.nodes,selection:u.selection})),!0;case`noop`:return!1}}function Py(e){let[t]=$c();return(0,F.useLayoutEffect)(()=>(e.editorRef.current=t,()=>{e.editorRef.current===t&&(e.editorRef.current=null)}),[t,e.editorRef]),(0,F.useLayoutEffect)(()=>{t.setEditable(!e.disabled)},[t,e.disabled]),(0,F.useLayoutEffect)(()=>{let n=xy(e.nodes),r=e.pendingSelectionRef.current,i=n!==e.editorSignatureRef.current;if(!(!i&&!r)){if(e.isApplyingExternalUpdateRef.current=!0,i?(_y(t,e.nodes,r),e.editorSignatureRef.current=n,e.lastPublishedSignatureRef.current=n):r&&vy(t,r),r&&(e.selectionRef.current=r,e.pendingSelectionRef.current=null),e.shouldFocusAfterSyncRef.current){e.shouldFocusAfterSyncRef.current=!1;let n=e.selectionRef.current;t.focus(()=>{n&&vy(t,n)})}requestAnimationFrame(()=>{e.isApplyingExternalUpdateRef.current=!1})}},[t,e.editorSignatureRef,e.isApplyingExternalUpdateRef,e.lastPublishedSignatureRef,e.nodes,e.pendingSelectionRef,e.selectionRef,e.shouldFocusAfterSyncRef]),(0,F.useEffect)(()=>zg(t.registerUpdateListener(({editorState:t})=>{let n=hy(t),r=xy(n.nodes);e.selectionRef.current=n.selection,e.editorSignatureRef.current=r,e.syncSlashState(n.nodes,n.selection),!(e.isApplyingExternalUpdateRef.current||e.isComposingRef.current)&&r!==e.lastPublishedSignatureRef.current&&(e.lastPublishedSignatureRef.current=r,e.onNodesChange(n.nodes))}),t.registerCommand(Ru,()=>{let n=hy(t.getEditorState());return e.selectionRef.current=n.selection,e.isComposingRef.current||e.syncSlashState(n.nodes,n.selection),!1},0),t.registerCommand(Sd,()=>(e.onBlur(),!1),0),t.registerCommand(td,t=>e.onKeyDown(t),3)),[t,e.editorSignatureRef,e.isApplyingExternalUpdateRef,e.isComposingRef,e.lastPublishedSignatureRef,e.onBlur,e.onKeyDown,e.onNodesChange,e.selectionRef,e.syncSlashState]),null}var Fy=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),r=(0,F.useRef)(null),i=(0,F.useRef)(null),a=(0,F.useRef)(!1),o=(0,F.useRef)(!1),s=(0,F.useRef)(!1),c=(0,F.useRef)(``),l=(0,F.useRef)(``),u=(t,n)=>{let r=iy(t,n);e.onSlashTriggerChange?.(r),e.onSlashQueryChange?.(r?.query??null),e.onSlashOpenChange(r!==null)},d=()=>e.nodes,f=()=>{if(r.current)return r.current;if(!n.current)return null;let e=hy(n.current.getEditorState());return r.current=e.selection,e.selection},p=(t,n)=>{r.current=t.selection,i.current=t.selection,n?.focusAfterSync&&(a.current=!0);let o=xy(t.nodes);u(t.nodes,t.selection),(n?.forcePublish||o!==l.current)&&(l.current=o,e.onNodesChange(t.nodes))},m=()=>{let e=n.current;if(!e)return;e.getRootElement()?.focus({preventScroll:!0});let t=r.current;t&&vy(e,t),e.focus()},h=()=>{let e=n.current;if(!e)return;let t=hy(e.getEditorState()).nodes.reduce((e,t)=>e+(t.type===`text`?t.text.length:1),0),i={start:t,end:t};r.current=i,e.getRootElement()?.focus({preventScroll:!0}),vy(e,i),e.focus()},g=()=>({nodes:d(),selection:f()});return(0,F.useImperativeHandle)(t,()=>ky({focusComposer:m,focusComposerAtEnd:h,onSlashItemSelect:e.onSlashItemSelect,optionsReader:g,publishSnapshot:p}),[e.onSlashItemSelect]),(0,I.jsxs)(f_,{initialConfig:(0,F.useMemo)(()=>({editable:!e.disabled,editorState:()=>{gy(e.nodes,null)},namespace:`NextClawChatComposerLexical`,nodes:[sy],onError:e=>{throw e},theme:{}}),[e.disabled,e.nodes]),children:[(0,I.jsx)(`div`,{className:`px-3 py-2 sm:px-4 sm:py-2.5`,children:(0,I.jsx)(`div`,{className:`min-h-11 sm:min-h-[60px]`,children:(0,I.jsx)(zv,{contentEditable:(0,I.jsx)(o_,{className:`min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-gray-800 outline-none`,onBeforeInput:t=>{jy({disabled:e.disabled,event:t,isComposing:o.current,publishSnapshot:p,snapshotReader:g})},onCompositionEnd:e=>{o.current=!1;let t=e.nativeEvent;My({data:typeof t.data==`string`?t.data:``,fallbackSnapshot:()=>{let e=n.current;return e?hy(e.getEditorState()):g()},publishSnapshot:p,snapshotReader:g})},onCompositionStart:()=>{o.current=!0},onPaste:t=>{let n=Array.from(t.clipboardData.files??[]);n.length>0&&e.onFilesAdd&&(t.preventDefault(),e.onFilesAdd(n))}}),placeholder:(0,I.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-2 select-none text-sm leading-6 text-gray-400 sm:left-4 sm:top-2.5`,children:e.placeholder}),ErrorBoundary:v_})})}),(0,I.jsx)(p_,{editorRef:n}),(0,I.jsx)(Py,{disabled:e.disabled,editorRef:n,editorSignatureRef:c,isApplyingExternalUpdateRef:s,isComposingRef:o,lastPublishedSignatureRef:l,nodes:e.nodes,onBlur:()=>{e.onSlashQueryChange?.(null),e.onSlashOpenChange(!1)},onKeyDown:t=>{let i=n.current;if(!i)return!1;let a=hy(i.getEditorState());return r.current=a.selection,Ny({actions:e.actions,activeSlashIndex:e.activeSlashIndex,nativeEvent:t,onSlashActiveIndexChange:e.onSlashActiveIndexChange,onSlashItemSelect:e.onSlashItemSelect,onSlashOpenChange:e.onSlashOpenChange,onSlashQueryChange:e.onSlashQueryChange,publishSnapshot:p,slashItems:e.slashItems,snapshot:a})},onNodesChange:e.onNodesChange,pendingSelectionRef:i,selectionRef:r,shouldFocusAfterSyncRef:a,syncSlashState:u})]})});Fy.displayName=`LexicalChatInputBarTokenizedComposer`;function Iy({hint:e}){return e?e.loading?(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-gray-200`})]})}):(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${e.tone===`warning`?`border-amber-200 bg-amber-50 text-amber-800`:`border-gray-200 bg-gray-50 text-gray-700`}`,children:[e.text?(0,I.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,I.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var Ly=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),r=(0,F.useRef)(!1),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),u=o!==null&&c!==o,d=e.slashMenu.items[i]??null,f=()=>o!==null&&!r.current?l(o):void 0;(0,F.useEffect)(()=>{a(t=>e.slashMenu.items.length===0?0:Math.min(t,e.slashMenu.items.length-1))},[e.slashMenu.items.length]),(0,F.useEffect)(()=>{o===null&&c!==null&&l(null)},[o,c]);let p=(0,F.useMemo)(()=>e.toolbar.skillPicker?{...e.toolbar,skillPicker:{...e.toolbar.skillPicker,onSelectedKeysChange:t=>{n.current?.syncSelectedSkills(t,e.toolbar.skillPicker?.options??[]),e.toolbar.skillPicker?.onSelectedKeysChange(t)}}}:e.toolbar,[e.toolbar]);return(0,F.useImperativeHandle)(t,()=>({insertFileToken:(e,t)=>n.current?.insertFileToken(e,t),insertFileTokens:e=>n.current?.insertFileTokens(e),focusComposer:()=>n.current?.focusComposer(),focusComposerAtEnd:()=>n.current?.focusComposerAtEnd()}),[]),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white px-3 py-3 sm:px-4 sm:py-4`,children:(0,I.jsx)(`div`,{className:`nextclaw-chat-input-bar-shell mx-auto w-full max-w-[min(1120px,100%)] [container:nextclaw-chat-input-bar/inline-size]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Fy,{ref:n,nodes:e.composer.nodes,placeholder:e.composer.placeholder,disabled:e.composer.disabled,slashItems:e.slashMenu.items,onSlashItemSelect:e.slashMenu.onSelectItem,actions:e.toolbar.actions,activeSlashIndex:i,onNodesChange:e.composer.onNodesChange,onFilesAdd:e.composer.onFilesAdd,onSlashQueryChange:t=>{t===null&&r.current||(t!==null&&a(0),e.composer.onSlashQueryChange?.(t))},onSlashTriggerChange:e=>{s(e?.start??null)},onSlashOpenChange:e=>{e||f()},onSlashActiveIndexChange:a}),(0,I.jsx)(Pc,{isOpen:u,isLoading:e.slashMenu.isLoading,items:e.slashMenu.items,activeIndex:i,activeItem:d,texts:e.slashMenu.texts,onSelectItem:e=>{l(null),n.current?.insertSlashItem(e)},onOpenChange:e=>{e||f()},onDetailsPointerDown:()=>{r.current=!0,requestAnimationFrame(()=>{r.current=!1})},onSetActiveIndex:a})]}),(0,I.jsx)(Iy,{hint:e.hint}),(0,I.jsx)(Xc,{...p})]})})})});Ly.displayName=`ChatInputBar`;function Ry({role:e}){return e===`user`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-user`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-white shadow-sm`,children:(0,I.jsx)(wr,{className:`h-4 w-4`})}):e===`tool`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-tool`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 shadow-sm`,children:(0,I.jsx)(O,{className:`h-4 w-4`})}):(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-assistant`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-b from-gray-700 to-gray-950 text-white shadow-md ring-1 ring-inset ring-white/20`,children:(0,I.jsx)(Fn,{className:`h-[18px] w-[18px] text-white/95`,strokeWidth:2.5})})}function zy(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var By=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Vy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Hy={};function Uy(e,t){return((t||Hy).jsx?Vy:By).test(e)}var Wy=/[ \t\n\f\r]/g;function Gy(e){return typeof e==`object`?e.type===`text`?Ky(e.value):!1:Ky(e)}function Ky(e){return e.replace(Wy,``)===``}var qy=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};qy.prototype.normal={},qy.prototype.property={},qy.prototype.space=void 0;function Jy(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new qy(n,r,t)}function Yy(e){return e.toLowerCase()}var Xy=class{constructor(e,t){this.attribute=t,this.property=e}};Xy.prototype.attribute=``,Xy.prototype.booleanish=!1,Xy.prototype.boolean=!1,Xy.prototype.commaOrSpaceSeparated=!1,Xy.prototype.commaSeparated=!1,Xy.prototype.defined=!1,Xy.prototype.mustUseProperty=!1,Xy.prototype.number=!1,Xy.prototype.overloadedBoolean=!1,Xy.prototype.property=``,Xy.prototype.spaceSeparated=!1,Xy.prototype.space=void 0;var Zy=g({boolean:()=>K,booleanish:()=>$y,commaOrSpaceSeparated:()=>rb,commaSeparated:()=>nb,number:()=>q,overloadedBoolean:()=>eb,spaceSeparated:()=>tb}),Qy=0,K=ib(),$y=ib(),eb=ib(),q=ib(),tb=ib(),nb=ib(),rb=ib();function ib(){return 2**++Qy}var ab=Object.keys(Zy),ob=class extends Xy{constructor(e,t,n,r){let i=-1;if(super(e,t),sb(this,`space`,r),typeof n==`number`)for(;++i<ab.length;){let e=ab[i];sb(this,ab[i],(n&Zy[e])===Zy[e])}}};ob.prototype.defined=!0;function sb(e,t,n){n&&(e[t]=n)}function cb(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ob(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Yy(r)]=r,n[Yy(a.attribute)]=r}return new qy(t,n,e.space)}var lb=cb({properties:{ariaActiveDescendant:null,ariaAtomic:$y,ariaAutoComplete:null,ariaBusy:$y,ariaChecked:$y,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:tb,ariaCurrent:null,ariaDescribedBy:tb,ariaDetails:null,ariaDisabled:$y,ariaDropEffect:tb,ariaErrorMessage:null,ariaExpanded:$y,ariaFlowTo:tb,ariaGrabbed:$y,ariaHasPopup:null,ariaHidden:$y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:tb,ariaLevel:q,ariaLive:null,ariaModal:$y,ariaMultiLine:$y,ariaMultiSelectable:$y,ariaOrientation:null,ariaOwns:tb,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:$y,ariaReadOnly:$y,ariaRelevant:null,ariaRequired:$y,ariaRoleDescription:tb,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:$y,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function ub(e,t){return t in e?e[t]:t}function db(e,t){return ub(e,t.toLowerCase())}var fb=cb({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:nb,acceptCharset:tb,accessKey:tb,action:null,allow:null,allowFullScreen:K,allowPaymentRequest:K,allowUserMedia:K,alt:null,as:null,async:K,autoCapitalize:null,autoComplete:tb,autoFocus:K,autoPlay:K,blocking:tb,capture:null,charSet:null,checked:K,cite:null,className:tb,cols:q,colSpan:null,content:null,contentEditable:$y,controls:K,controlsList:tb,coords:q|nb,crossOrigin:null,data:null,dateTime:null,decoding:null,default:K,defer:K,dir:null,dirName:null,disabled:K,download:eb,draggable:$y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:K,formTarget:null,headers:tb,height:q,hidden:eb,high:q,href:null,hrefLang:null,htmlFor:tb,httpEquiv:tb,id:null,imageSizes:null,imageSrcSet:null,inert:K,inputMode:null,integrity:null,is:null,isMap:K,itemId:null,itemProp:tb,itemRef:tb,itemScope:K,itemType:tb,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:K,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:K,muted:K,name:null,nonce:null,noModule:K,noValidate:K,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:K,optimum:q,pattern:null,ping:tb,placeholder:null,playsInline:K,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:K,referrerPolicy:null,rel:tb,required:K,reversed:K,rows:q,rowSpan:q,sandbox:tb,scope:null,scoped:K,seamless:K,selected:K,shadowRootClonable:K,shadowRootDelegatesFocus:K,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:$y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:K,useMap:null,value:$y,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:tb,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:K,declare:K,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:K,noHref:K,noShade:K,noWrap:K,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:$y,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:K,disableRemotePlayback:K,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:db}),pb=cb({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:rb,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:tb,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:K,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:nb,g2:nb,glyphName:nb,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:rb,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:tb,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:rb,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:rb,rev:rb,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:rb,requiredFeatures:rb,requiredFonts:rb,requiredFormats:rb,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:rb,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:rb,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:rb,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:ub}),mb=cb({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),hb=cb({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:db}),gb=cb({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),_b={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},vb=/[A-Z]/g,yb=/-[a-z]/g,bb=/^data[-\w.:]+$/i;function xb(e,t){let n=Yy(t),r=t,i=Xy;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&bb.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(yb,Cb);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!yb.test(e)){let n=e.replace(vb,Sb);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ob}return new i(r,t)}function Sb(e){return`-`+e.toLowerCase()}function Cb(e){return e.charAt(1).toUpperCase()}var wb=Jy([lb,fb,mb,hb,gb],`html`),Tb=Jy([lb,pb,mb,hb,gb],`svg`);function Eb(e){return e.join(` `).trim()}var Db=e(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
17
|
+
`})),!0;case`send-message`:return t.onSend(),!0;case`delete-content`:return c(Ey({direction:d.direction,nodes:u.nodes,selection:u.selection})),!0;case`noop`:return!1}}function Py({disabled:e,editorRef:t,editorSignatureRef:n,isApplyingExternalUpdateRef:r,isComposingRef:i,lastPublishedSignatureRef:a,nodes:o,onBlur:s,onKeyDown:c,onNodesChange:l,pendingSelectionRef:u,selectionRef:d,shouldFocusAfterSyncRef:f,syncSlashState:p}){let[m]=$c();return(0,F.useLayoutEffect)(()=>(t.current=m,()=>{t.current===m&&(t.current=null)}),[m,t]),(0,F.useLayoutEffect)(()=>{m.setEditable(!e)},[e,m]),(0,F.useLayoutEffect)(()=>{let e=xy(o),t=u.current,i=e!==n.current;if(!(!i&&!t)){if(r.current=!0,i?(_y(m,o,t),n.current=e,a.current=e):t&&vy(m,t),t&&(d.current=t,u.current=null),f.current){f.current=!1;let e=d.current;m.focus(()=>{e&&vy(m,e)})}requestAnimationFrame(()=>{r.current=!1})}},[m,n,r,a,o,u,d,f]),(0,F.useEffect)(()=>zg(m.registerUpdateListener(({editorState:e})=>{let t=hy(e),o=xy(t.nodes);d.current=t.selection,n.current=o,p(t.nodes,t.selection),!(r.current||i.current)&&o!==a.current&&(a.current=o,l(t.nodes))}),m.registerCommand(Ru,()=>{let e=hy(m.getEditorState());return d.current=e.selection,i.current||p(e.nodes,e.selection),!1},0),m.registerCommand(Sd,()=>(s(),!1),0),m.registerCommand(td,e=>c(e),3)),[m,n,r,i,a,s,c,l,d,p]),null}var Fy=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),r=(0,F.useRef)(null),i=(0,F.useRef)(null),a=(0,F.useRef)(!1),o=(0,F.useRef)(!1),s=(0,F.useRef)(!1),c=(0,F.useRef)(``),l=(0,F.useRef)(``),u=(t,n)=>{let r=iy(t,n);e.onSlashTriggerChange?.(r),e.onSlashQueryChange?.(r?.query??null),e.onSlashOpenChange(r!==null)},d=()=>e.nodes,f=()=>{if(r.current)return r.current;if(!n.current)return null;let e=hy(n.current.getEditorState());return r.current=e.selection,e.selection},p=(t,n)=>{r.current=t.selection,i.current=t.selection,n?.focusAfterSync&&(a.current=!0);let o=xy(t.nodes);u(t.nodes,t.selection),(n?.forcePublish||o!==l.current)&&(l.current=o,e.onNodesChange(t.nodes))},m=()=>{let e=n.current;if(!e)return;e.getRootElement()?.focus({preventScroll:!0});let t=r.current;t&&vy(e,t),e.focus()},h=()=>{let e=n.current;if(!e)return;let t=hy(e.getEditorState()).nodes.reduce((e,t)=>e+(t.type===`text`?t.text.length:1),0),i={start:t,end:t};r.current=i,e.getRootElement()?.focus({preventScroll:!0}),vy(e,i),e.focus()},g=()=>({nodes:d(),selection:f()});return(0,F.useImperativeHandle)(t,()=>ky({focusComposer:m,focusComposerAtEnd:h,onSlashItemSelect:e.onSlashItemSelect,optionsReader:g,publishSnapshot:p}),[e.onSlashItemSelect]),(0,I.jsxs)(f_,{initialConfig:(0,F.useMemo)(()=>({editable:!e.disabled,editorState:()=>{gy(e.nodes,null)},namespace:`NextClawChatComposerLexical`,nodes:[sy],onError:e=>{throw e},theme:{}}),[e.disabled,e.nodes]),children:[(0,I.jsx)(`div`,{className:`px-3 py-2 sm:px-4 sm:py-2.5`,children:(0,I.jsx)(`div`,{className:`min-h-11 sm:min-h-[60px]`,children:(0,I.jsx)(zv,{contentEditable:(0,I.jsx)(o_,{className:`min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-gray-800 outline-none`,onBeforeInput:t=>{jy({disabled:e.disabled,event:t,isComposing:o.current,publishSnapshot:p,snapshotReader:g})},onCompositionEnd:e=>{o.current=!1;let t=e.nativeEvent;My({data:typeof t.data==`string`?t.data:``,fallbackSnapshot:()=>{let e=n.current;return e?hy(e.getEditorState()):g()},publishSnapshot:p,snapshotReader:g})},onCompositionStart:()=>{o.current=!0},onPaste:t=>{let n=Array.from(t.clipboardData.files??[]);n.length>0&&e.onFilesAdd&&(t.preventDefault(),e.onFilesAdd(n))}}),placeholder:(0,I.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-2 select-none text-sm leading-6 text-gray-400 sm:left-4 sm:top-2.5`,children:e.placeholder}),ErrorBoundary:v_})})}),(0,I.jsx)(p_,{editorRef:n}),(0,I.jsx)(Py,{disabled:e.disabled,editorRef:n,editorSignatureRef:c,isApplyingExternalUpdateRef:s,isComposingRef:o,lastPublishedSignatureRef:l,nodes:e.nodes,onBlur:()=>{e.onSlashQueryChange?.(null),e.onSlashOpenChange(!1)},onKeyDown:t=>{let i=n.current;if(!i)return!1;let a=hy(i.getEditorState());return r.current=a.selection,Ny({actions:e.actions,activeSlashIndex:e.activeSlashIndex,nativeEvent:t,onSlashActiveIndexChange:e.onSlashActiveIndexChange,onSlashItemSelect:e.onSlashItemSelect,onSlashOpenChange:e.onSlashOpenChange,onSlashQueryChange:e.onSlashQueryChange,publishSnapshot:p,slashItems:e.slashItems,snapshot:a})},onNodesChange:e.onNodesChange,pendingSelectionRef:i,selectionRef:r,shouldFocusAfterSyncRef:a,syncSlashState:u})]})});Fy.displayName=`LexicalChatInputBarTokenizedComposer`;function Iy({hint:e}){return e?e.loading?(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-gray-200`})]})}):(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${e.tone===`warning`?`border-amber-200 bg-amber-50 text-amber-800`:`border-gray-200 bg-gray-50 text-gray-700`}`,children:[e.text?(0,I.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,I.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var Ly=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),r=(0,F.useRef)(!1),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),u=o!==null&&c!==o,d=e.slashMenu.items[i]??null,f=()=>o!==null&&!r.current?l(o):void 0;(0,F.useEffect)(()=>{a(t=>e.slashMenu.items.length===0?0:Math.min(t,e.slashMenu.items.length-1))},[e.slashMenu.items.length]),(0,F.useEffect)(()=>{o===null&&c!==null&&l(null)},[o,c]);let p=(0,F.useMemo)(()=>e.toolbar.skillPicker?{...e.toolbar,skillPicker:{...e.toolbar.skillPicker,onSelectedKeysChange:t=>{n.current?.syncSelectedSkills(t,e.toolbar.skillPicker?.options??[]),e.toolbar.skillPicker?.onSelectedKeysChange(t)}}}:e.toolbar,[e.toolbar]);return(0,F.useImperativeHandle)(t,()=>({insertFileToken:(e,t)=>n.current?.insertFileToken(e,t),insertFileTokens:e=>n.current?.insertFileTokens(e),focusComposer:()=>n.current?.focusComposer(),focusComposerAtEnd:()=>n.current?.focusComposerAtEnd()}),[]),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white px-3 py-3 sm:px-4 sm:py-4`,children:(0,I.jsx)(`div`,{className:`nextclaw-chat-input-bar-shell mx-auto w-full max-w-[min(1120px,100%)] [container:nextclaw-chat-input-bar/inline-size]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Fy,{ref:n,nodes:e.composer.nodes,placeholder:e.composer.placeholder,disabled:e.composer.disabled,slashItems:e.slashMenu.items,onSlashItemSelect:e.slashMenu.onSelectItem,actions:e.toolbar.actions,activeSlashIndex:i,onNodesChange:e.composer.onNodesChange,onFilesAdd:e.composer.onFilesAdd,onSlashQueryChange:t=>{t===null&&r.current||(t!==null&&a(0),e.composer.onSlashQueryChange?.(t))},onSlashTriggerChange:e=>{s(e?.start??null)},onSlashOpenChange:e=>{e||f()},onSlashActiveIndexChange:a}),(0,I.jsx)(Pc,{isOpen:u,isLoading:e.slashMenu.isLoading,items:e.slashMenu.items,activeIndex:i,activeItem:d,texts:e.slashMenu.texts,onSelectItem:e=>{l(null),n.current?.insertSlashItem(e)},onOpenChange:e=>{e||f()},onDetailsPointerDown:()=>{r.current=!0,requestAnimationFrame(()=>{r.current=!1})},onSetActiveIndex:a})]}),(0,I.jsx)(Iy,{hint:e.hint}),(0,I.jsx)(Xc,{...p})]})})})});Ly.displayName=`ChatInputBar`;function Ry({role:e}){return e===`user`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-user`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-white shadow-sm`,children:(0,I.jsx)(wr,{className:`h-4 w-4`})}):e===`tool`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-tool`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 shadow-sm`,children:(0,I.jsx)(O,{className:`h-4 w-4`})}):(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-assistant`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-b from-gray-700 to-gray-950 text-white shadow-md ring-1 ring-inset ring-white/20`,children:(0,I.jsx)(Fn,{className:`h-[18px] w-[18px] text-white/95`,strokeWidth:2.5})})}function zy(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var By=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Vy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Hy={};function Uy(e,t){return((t||Hy).jsx?Vy:By).test(e)}var Wy=/[ \t\n\f\r]/g;function Gy(e){return typeof e==`object`?e.type===`text`?Ky(e.value):!1:Ky(e)}function Ky(e){return e.replace(Wy,``)===``}var qy=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};qy.prototype.normal={},qy.prototype.property={},qy.prototype.space=void 0;function Jy(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new qy(n,r,t)}function Yy(e){return e.toLowerCase()}var Xy=class{constructor(e,t){this.attribute=t,this.property=e}};Xy.prototype.attribute=``,Xy.prototype.booleanish=!1,Xy.prototype.boolean=!1,Xy.prototype.commaOrSpaceSeparated=!1,Xy.prototype.commaSeparated=!1,Xy.prototype.defined=!1,Xy.prototype.mustUseProperty=!1,Xy.prototype.number=!1,Xy.prototype.overloadedBoolean=!1,Xy.prototype.property=``,Xy.prototype.spaceSeparated=!1,Xy.prototype.space=void 0;var Zy=g({boolean:()=>K,booleanish:()=>$y,commaOrSpaceSeparated:()=>rb,commaSeparated:()=>nb,number:()=>q,overloadedBoolean:()=>eb,spaceSeparated:()=>tb}),Qy=0,K=ib(),$y=ib(),eb=ib(),q=ib(),tb=ib(),nb=ib(),rb=ib();function ib(){return 2**++Qy}var ab=Object.keys(Zy),ob=class extends Xy{constructor(e,t,n,r){let i=-1;if(super(e,t),sb(this,`space`,r),typeof n==`number`)for(;++i<ab.length;){let e=ab[i];sb(this,ab[i],(n&Zy[e])===Zy[e])}}};ob.prototype.defined=!0;function sb(e,t,n){n&&(e[t]=n)}function cb(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ob(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Yy(r)]=r,n[Yy(a.attribute)]=r}return new qy(t,n,e.space)}var lb=cb({properties:{ariaActiveDescendant:null,ariaAtomic:$y,ariaAutoComplete:null,ariaBusy:$y,ariaChecked:$y,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:tb,ariaCurrent:null,ariaDescribedBy:tb,ariaDetails:null,ariaDisabled:$y,ariaDropEffect:tb,ariaErrorMessage:null,ariaExpanded:$y,ariaFlowTo:tb,ariaGrabbed:$y,ariaHasPopup:null,ariaHidden:$y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:tb,ariaLevel:q,ariaLive:null,ariaModal:$y,ariaMultiLine:$y,ariaMultiSelectable:$y,ariaOrientation:null,ariaOwns:tb,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:$y,ariaReadOnly:$y,ariaRelevant:null,ariaRequired:$y,ariaRoleDescription:tb,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:$y,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function ub(e,t){return t in e?e[t]:t}function db(e,t){return ub(e,t.toLowerCase())}var fb=cb({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:nb,acceptCharset:tb,accessKey:tb,action:null,allow:null,allowFullScreen:K,allowPaymentRequest:K,allowUserMedia:K,alt:null,as:null,async:K,autoCapitalize:null,autoComplete:tb,autoFocus:K,autoPlay:K,blocking:tb,capture:null,charSet:null,checked:K,cite:null,className:tb,cols:q,colSpan:null,content:null,contentEditable:$y,controls:K,controlsList:tb,coords:q|nb,crossOrigin:null,data:null,dateTime:null,decoding:null,default:K,defer:K,dir:null,dirName:null,disabled:K,download:eb,draggable:$y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:K,formTarget:null,headers:tb,height:q,hidden:eb,high:q,href:null,hrefLang:null,htmlFor:tb,httpEquiv:tb,id:null,imageSizes:null,imageSrcSet:null,inert:K,inputMode:null,integrity:null,is:null,isMap:K,itemId:null,itemProp:tb,itemRef:tb,itemScope:K,itemType:tb,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:K,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:K,muted:K,name:null,nonce:null,noModule:K,noValidate:K,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:K,optimum:q,pattern:null,ping:tb,placeholder:null,playsInline:K,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:K,referrerPolicy:null,rel:tb,required:K,reversed:K,rows:q,rowSpan:q,sandbox:tb,scope:null,scoped:K,seamless:K,selected:K,shadowRootClonable:K,shadowRootDelegatesFocus:K,shadowRootMode:null,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:$y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:K,useMap:null,value:$y,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:tb,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:K,declare:K,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:K,noHref:K,noShade:K,noWrap:K,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:$y,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:K,disableRemotePlayback:K,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:db}),pb=cb({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:rb,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:tb,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:K,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:nb,g2:nb,glyphName:nb,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:rb,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:tb,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:rb,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:rb,rev:rb,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:rb,requiredFeatures:rb,requiredFonts:rb,requiredFormats:rb,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:rb,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:rb,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:rb,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:ub}),mb=cb({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),hb=cb({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:db}),gb=cb({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),_b={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},vb=/[A-Z]/g,yb=/-[a-z]/g,bb=/^data[-\w.:]+$/i;function xb(e,t){let n=Yy(t),r=t,i=Xy;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&bb.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(yb,Cb);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!yb.test(e)){let n=e.replace(vb,Sb);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ob}return new i(r,t)}function Sb(e){return`-`+e.toLowerCase()}function Cb(e){return e.charAt(1).toUpperCase()}var wb=Jy([lb,fb,mb,hb,gb],`html`),Tb=Jy([lb,pb,mb,hb,gb],`svg`);function Eb(e){return e.join(` `).trim()}var Db=e(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
18
18
|
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),Ob=e((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(Db());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),kb=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ab=e(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ob()),r=kb();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),jb=Nb(`end`),Mb=Nb(`start`);function Nb(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Pb(e){let t=Mb(e),n=jb(e);if(t&&n)return{start:t,end:n}}function Fb(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Lb(e.position):`start`in e||`end`in e?Lb(e):`line`in e||`column`in e?Ib(e):``}function Ib(e){return Rb(e&&e.line)+`:`+Rb(e&&e.column)}function Lb(e){return Ib(e&&e.start)+`-`+Ib(e&&e.end)}function Rb(e){return e&&typeof e==`number`?e:1}var zb=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Fb(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};zb.prototype.file=``,zb.prototype.name=``,zb.prototype.reason=``,zb.prototype.message=``,zb.prototype.stack=``,zb.prototype.column=void 0,zb.prototype.line=void 0,zb.prototype.ancestors=void 0,zb.prototype.cause=void 0,zb.prototype.fatal=void 0,zb.prototype.place=void 0,zb.prototype.ruleId=void 0,zb.prototype.source=void 0;var Bb=_(Ab(),1),Vb={}.hasOwnProperty,Hb=new Map,Ub=/[A-Z]/g,Wb=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Gb=new Set([`td`,`th`]),Kb=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function qb(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=ix(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=rx(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Tb:wb,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Jb(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Jb(e,t,n){if(t.type===`element`)return Yb(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Xb(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Qb(e,t,n);if(t.type===`mdxjsEsm`)return Zb(e,t);if(t.type===`root`)return $b(e,t,n);if(t.type===`text`)return ex(e,t)}function Yb(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Tb,e.schema=i),e.ancestors.push(t);let a=ux(e,t.tagName,!1),o=ax(e,t),s=sx(e,t);return Wb.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Gy(e):!0})),tx(e,o,a,t),nx(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Xb(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}dx(e,t.position)}function Zb(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);dx(e,t.position)}function Qb(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Tb,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:ux(e,t.name,!0),o=ox(e,t),s=sx(e,t);return tx(e,o,a,t),nx(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function $b(e,t,n){let r={};return nx(r,sx(e,t)),e.create(t,e.Fragment,r,n)}function ex(e,t){return t.value}function tx(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function nx(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function rx(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function ix(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Mb(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function ax(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Vb.call(t.properties,i)){let a=cx(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Gb.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function ox(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else dx(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else dx(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function sx(e,t){let n=[],r=-1,i=e.passKeys?new Map:Hb;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Jb(e,a,o);s!==void 0&&n.push(s)}return n}function cx(e,t,n){let r=xb(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?zy(n):Eb(n)),r.property===`style`){let t=typeof n==`object`?n:lx(e,String(n));return e.stylePropertyNameCase===`css`&&(t=fx(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?_b[r.property]||r.property:r.attribute,n]}}function lx(e,t){try{return(0,Bb.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new zb("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Kb+`#cannot-parse-style-attribute`,r}}function ux(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Uy(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Uy(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Vb.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);dx(e)}function dx(e,t){let n=new zb("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Kb+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function fx(e){let t={},n;for(n in e)Vb.call(e,n)&&(t[px(n)]=e[n]);return t}function px(e){let t=e.replace(Ub,mx);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function mx(e){return`-`+e.toLowerCase()}var hx={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},gx={};function _x(e,t){let n=t||gx;return vx(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function vx(e,t,n){if(bx(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return yx(e.children,t,n)}return Array.isArray(e)?yx(e,t,n):``}function yx(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=vx(e[i],t,n);return r.join(``)}function bx(e){return!!(e&&typeof e==`object`)}var xx=document.createElement(`i`);function Sx(e){let t=`&`+e+`;`;xx.innerHTML=t;let n=xx.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Cx(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function wx(e,t){return e.length>0?(Cx(e,e.length,0,t),e):t}var Tx={}.hasOwnProperty;function Ex(e){let t={},n=-1;for(;++n<e.length;)Dx(t,e[n]);return t}function Dx(e,t){let n;for(n in t){let r=(Tx.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Tx.call(r,a)||(r[a]=[]);let e=i[a];Ox(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Ox(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Cx(e,0,0,r)}function kx(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Ax(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var jx=Vx(/[A-Za-z]/),Mx=Vx(/[\dA-Za-z]/),Nx=Vx(/[#-'*+\--9=?A-Z^-~]/);function Px(e){return e!==null&&(e<32||e===127)}var Fx=Vx(/\d/),Ix=Vx(/[\dA-Fa-f]/),Lx=Vx(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Rx(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var zx=Vx(/\p{P}|\p{S}/u),Bx=Vx(/\s/);function Vx(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Hx(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Mx(e.charCodeAt(n+1))&&Mx(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Ux={tokenize:Wx};function Wx(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Gx={tokenize:qx},Kx={tokenize:Jx};function qx(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Cx(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kx,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Kx,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Cx(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Jx(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Yx(e){if(e===null||Rx(e)||Bx(e))return 1;if(zx(e))return 2}function Xx(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Zx={name:`attention`,resolveAll:Qx,tokenize:$x};function Qx(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};eS(d,-c),eS(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=wx(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=wx(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=wx(l,Xx(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=wx(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=wx(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Cx(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function $x(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Yx(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Yx(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function eS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var tS={name:`autolink`,tokenize:nS};function nS(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return jx(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Mx(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Mx(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Px(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Nx(t)?(e.consume(t),l):n(t)}function u(e){return Mx(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Mx(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var rS={partial:!0,tokenize:iS};function iS(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var aS={continuation:{tokenize:sS},exit:cS,name:`blockQuote`,tokenize:oS};function oS(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function sS(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(aS,t,n)(r)}}function cS(e){e.exit(`blockQuote`)}var lS={name:`characterEscape`,tokenize:uS};function uS(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Lx(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var dS={name:`characterReference`,tokenize:fS};function fS(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Mx,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Ix,u):(e.enter(`characterReferenceValue`),a=7,o=Fx,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Mx&&!Sx(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var pS={partial:!0,tokenize:gS},mS={concrete:!0,name:`codeFenced`,tokenize:hS};function hS(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(pS,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(pS,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function gS(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var _S={name:`codeIndented`,tokenize:yS},vS={partial:!0,tokenize:bS};function yS(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(vS,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function bS(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var xS={name:`codeText`,previous:CS,resolve:SS,tokenize:wS};function SS(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function CS(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function wS(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var TS=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&ES(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ES(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ES(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);ES(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);ES(this.left,t.reverse())}}};function ES(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function DS(e){let t={},n=-1,r,i,a,o,s,c,l,u=new TS(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,OS(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Cx(e,0,1/0,u.slice(0)),!l}function OS(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var kS={resolve:jS,tokenize:MS},AS={partial:!0,tokenize:NS};function jS(e){return DS(e),e}function MS(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(AS,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function NS(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function PS(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Px(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Rx(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Px(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function FS(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Y(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function IS(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function LS(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var RS={name:`definition`,tokenize:BS},zS={partial:!0,tokenize:VS};function BS(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return FS.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Ax(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Rx(t)?LS(e,l)(t):l(t)}function l(t){return PS(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(zS,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function VS(e,t,n){return r;function r(t){return Rx(t)?LS(e,i)(t):n(t)}function i(t){return IS(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var HS={name:`hardBreakEscape`,tokenize:US};function US(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var WS={name:`headingAtx`,resolve:GS,tokenize:KS};function GS(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},Cx(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function KS(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Rx(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Rx(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var qS=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),JS=[`pre`,`script`,`style`,`textarea`],YS={concrete:!0,name:`htmlFlow`,resolveTo:QS,tokenize:$S},XS={partial:!0,tokenize:tC},ZS={partial:!0,tokenize:eC};function QS(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function $S(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):jx(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):jx(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return jx(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Rx(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&JS.includes(l)?(i=1,r.interrupt?t(s):O(s)):qS.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Mx(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Y(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||jx(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Mx(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Rx(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||J(t)?O(t):Y(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),te):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),ne):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(XS,ae,k)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(ZS,A,ae)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return t===null||J(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),re):O(t)}function te(t){return t===47?(e.consume(t),o=``,M):O(t)}function M(t){if(t===62){let n=o.toLowerCase();return JS.includes(n)?(e.consume(t),ie):O(t)}return jx(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),M):O(t)}function ne(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||J(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function eC(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function tC(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(rS,t,n)}}var nC={name:`htmlText`,tokenize:rC};function rC(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):jx(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):jx(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,te(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,te(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):J(t)?(o=v,te(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,te(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return jx(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Mx(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,te(t)):Y(t)?(e.consume(t),C):j(t)}function w(t){return t===45||Mx(t)?(e.consume(t),w):t===47||t===62||Rx(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||jx(t)?(e.consume(t),E):J(t)?(o=T,te(t)):Y(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||Mx(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):J(t)?(o=D,te(t)):Y(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):J(t)?(o=O,te(t)):Y(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,ee):t===null?n(t):J(t)?(o=k,te(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Rx(t)?T(t):(e.consume(t),A)}function ee(e){return e===47||e===62||Rx(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function te(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),M}function M(t){return Y(t)?X(e,ne,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ne(t)}function ne(t){return e.enter(`htmlTextData`),o(t)}}var iC={name:`labelEnd`,resolveAll:cC,resolveTo:lC,tokenize:uC},aC={tokenize:dC},oC={tokenize:fC},sC={tokenize:pC};function cC(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Cx(e,0,e.length,n),e}function lC(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=wx(s,e.slice(a+1,a+r+3)),s=wx(s,[[`enter`,u,t]]),s=wx(s,Xx(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=wx(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=wx(s,e.slice(o+1)),s=wx(s,[[`exit`,c,t]]),Cx(e,a,e.length,s),e}function uC(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Ax(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(aC,u,o?u:d)(t):t===91?e.attempt(oC,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(sC,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function dC(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Rx(t)?LS(e,a)(t):a(t)}function a(t){return t===41?u(t):PS(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Rx(t)?LS(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?IS(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Rx(t)?LS(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function fC(e,t,n){let r=this;return i;function i(t){return FS.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Ax(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function pC(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var mC={name:`labelStartImage`,resolveAll:iC.resolveAll,tokenize:hC};function hC(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var gC={name:`labelStartLink`,resolveAll:iC.resolveAll,tokenize:_C};function _C(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var vC={name:`lineEnding`,tokenize:yC};function yC(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var bC={name:`thematicBreak`,tokenize:xC};function xC(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var SC={continuation:{tokenize:EC},exit:OC,name:`list`,tokenize:TC},CC={partial:!0,tokenize:kC},wC={partial:!0,tokenize:DC};function TC(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Fx(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(bC,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Fx(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(rS,r.interrupt?n:u,e.attempt(CC,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function EC(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(rS,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(wC,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(SC,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function DC(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function OC(e){e.exit(this.containerState.type)}function kC(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var AC={name:`setextUnderline`,resolveTo:jC,tokenize:MC};function jC(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function MC(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var NC={tokenize:PC};function PC(e){let t=this,n=e.attempt(rS,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(kS,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var FC={resolveAll:zC()},IC=RC(`string`),LC=RC(`text`);function RC(e){return{resolveAll:zC(e===`text`?BC:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function zC(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function BC(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var VC=g({attentionMarkers:()=>YC,contentInitial:()=>UC,disable:()=>XC,document:()=>HC,flow:()=>GC,flowInitial:()=>WC,insideSpan:()=>JC,string:()=>KC,text:()=>qC}),HC={42:SC,43:SC,45:SC,48:SC,49:SC,50:SC,51:SC,52:SC,53:SC,54:SC,55:SC,56:SC,57:SC,62:aS},UC={91:RS},WC={[-2]:_S,[-1]:_S,32:_S},GC={35:WS,42:bC,45:[AC,bC],60:YS,61:AC,95:bC,96:mS,126:mS},KC={38:dS,92:lS},qC={[-5]:vC,[-4]:vC,[-3]:vC,33:mC,38:dS,42:Zx,60:[tS,nC],91:gC,92:[HS,lS],93:iC,95:Zx,96:xS},JC={null:[Zx,FC]},YC={null:[42,95]},XC={null:[]};function ZC(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=wx(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Xx(a,l.events,l),l.events):[]}function f(e,t){return $C(p(e),t)}function p(e){return QC(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Cx(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function QC(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function $C(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
19
19
|
`;break;case-3:o=`\r
|
|
20
20
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function ew(e){let t={constructs:Ex([VC,...(e||{}).extensions||[]]),content:n(Ux),defined:[],document:n(Gx),flow:n(NC),lazy:{},string:n(IC),text:n(LC)};return t;function n(e){return n;function n(n){return ZC(t,e,n)}}}function tw(e){for(;!DS(e););return e}var nw=/[\0\t\n\r]/g;function rw(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(nw.lastIndex=u,c=nw.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var iw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function aw(e){return e.replace(iw,ow)}function ow(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return kx(n.slice(t?2:1),t?16:10)}return Sx(n)||e}var sw={}.hasOwnProperty;function cw(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),lw(n)(tw(ew(n).document().write(rw()(e,t,!0))))}function lw(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Se),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(be,o),htmlFlowData:T,htmlText:a(be,o),htmlTextData:T,image:a(xe),label:o,link:a(Se),listItem:a(we),listItemValue:f,listOrdered:a(Ce,d),listUnordered:a(Ce),paragraph:a(Te),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Ee),thematicBreak:a(Oe)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(ee),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(te),label:ne,labelText:M,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};dw(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];sw.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||pw).call(a,void 0,e[0])}for(r.position={start:uw(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:uw(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:uw(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||pw).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Fb({start:e.start,end:e.end})+`): it’s not open`);n.position.end=uw(e.end)}function u(){return _x(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Ax(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=De(),n.position={start:uw(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=uw(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=uw(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=aw(t),n.identifier=Ax(t).toLowerCase()}function ne(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Ax(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=kx(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Sx(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=uw(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function ye(){return{type:`break`}}function be(){return{type:`html`,value:``}}function xe(){return{type:`image`,title:null,url:``,alt:null}}function Se(){return{type:`link`,title:null,url:``,children:[]}}function Ce(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function we(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Te(){return{type:`paragraph`,children:[]}}function Ee(){return{type:`strong`,children:[]}}function De(){return{type:`text`,value:``}}function Oe(){return{type:`thematicBreak`}}}function uw(e){return{line:e.line,column:e.column,offset:e.offset}}function dw(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?dw(e,r):fw(e,r)}}function fw(e,t){let n;for(n in t)if(sw.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function pw(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Fb({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Fb({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Fb({start:t.start,end:t.end})+`) is still open`)}function mw(e){let t=this;t.parser=n;function n(n){return cw(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function hw(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function gw(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -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.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function VR(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function HR(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function UR({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(`cronDeliverTo`),`:`]}),` `,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 WR({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 GR({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 KR({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)(GR,{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 qR({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)(KR,{tab:e})]})}function JR(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 YR({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)(()=>JR({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)(qR,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(WR,{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)(UR,{jobs:c})})]}):null}function XR({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var ZR=[{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 QR(){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)(XR,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:ZR.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(XR,{"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)(XR,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(XR,{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)(XR,{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)(XR,{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)(XR,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(XR,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(XR,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(XR,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function $R(){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 ez(){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 tz(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function nz(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=>HR(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:tz(e,t,n,i.length)}}function rz(){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 iz({layoutMode:e,onBackToList:t}){let n=sc(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=nz(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 az({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=nz(t);return a?(0,I.jsx)(YR,{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 oz({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)(rz,{}),(0,I.jsx)(iz,{layoutMode:e,onBackToList:t}),(0,I.jsx)($R,{}),(0,I.jsx)(ez,{}),(0,I.jsx)(_P,{})]}),(0,I.jsx)(az,{layoutMode:e})]}):(0,I.jsx)(QR,{})}var sz={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 cz({status:e,className:t}){let n=sz[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 lz(){let e=vL();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function uz(){let e=lz(),[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 dz(e,t){return e.filter(e=>$s(e,t))}function fz(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function pz(e={}){let t=tP(e=>e.snapshot.query),n=wi({limit:e.limit??200}),r=(0,F.useMemo)(()=>dz($I(n.data?.sessions??[]).filter(fz),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function mz(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 hz(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function gz(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 _z(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=hz({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 vz({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)(yz,{icon:mr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(yz,{icon:lr,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function yz({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 bz(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function xz(e){return[...e].sort((e,t)=>bz(t)-bz(e))}function Sz(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=bz(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 Cz(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=bz(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:xz(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function wz(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)=>bz(t)-bz(e));return t}function Tz(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Ez=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:Mn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:E},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:Fn}];function Dz(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 Oz({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}=pz(),{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)(()=>xz(g),[g]),D=(0,F.useMemo)(()=>wz(g),[g]),O=(0,F.useMemo)(()=>Sz(E),[E]),k=(0,F.useMemo)(()=>Cz(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=Dz(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:ne,savingSessionKey:re,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:se,saveSessionLabel:ce}=uz(),le=e=>{_!==e&&(v(e),window.location.reload())},ue=e=>(0,I.jsx)(mz,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:te,agentsById:T,childSessionsByParentKey:D,editingSessionKey:M,draftLabel:ne,savingSessionKey:re,sessionTitle:Tz,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)(cz,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(_z,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(gz,{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:Ez.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)(vz,{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 kz(){return Ve({queryKey:[`ncp-session-types`],queryFn:Be,staleTime:1e4,retry:!1})}function Az(e){let t=e.trim();return t.length>0?t:null}function jz(e){return e??null}var Mz=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:Az(e.selectedModel),preferredThinking:jz(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)}}}},Nz=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new Mz(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})}}},Pz=`sid_`,Fz=`/chat/draft`,Iz=Fz.slice(6);function Lz(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Pz}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Rz(e){if(!e.startsWith(Pz))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 zz(e){if(!e||e===Iz)return null;let t=Rz(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Bz(e){return`/chat/${Lz(e)}`}var Vz=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(Fz)},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})}}},Hz=async()=>{},Uz=()=>{},Wz=class{constructor(){this.actions={sendMessage:Hz,stopCurrentRun:Hz,resumeRun:Hz,resetStreamState:Uz,applyHistoryMessages:Uz},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)}},Gz=async e=>!1,Kz=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:Gz},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(Bz(e),t)}}},qz=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})}}}}},Jz=class{constructor(){this.chatUiManager=new Kz,this.chatStreamActionsManager=new Wz,this.chatSessionListManager=new Vz(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Nz(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new qz(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function Yz(e){return e?.trim().toLowerCase()||`native`}function Xz(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function Zz(e,t){return typeof t==`string`&&e.includes(t)}function Qz(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function $z(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 eB(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:$z({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Xz(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function tB(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:$z({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Zz(t,e),firstAvailableValue:Qz(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function nB(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=Yz(r),o,s=-1/0;for(let e of t){if(e.key===n||Yz(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 rB(e){return e.map(e=>e==null?``:String(e)).join(``)}function iB(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,F.useRef)(void 0),l=(0,F.useRef)(s),u=(0,F.useRef)(n);l.current=s,(0,F.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function aB(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;iB({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:rB([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>eB({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function oB(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;iB({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:rB([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>tB({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function sB(){let{pathname:e}=S(),t=C();return Vr(e)?(0,I.jsx)(oz,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(Oz,{variant:`mobile`})}var cB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-lpF_pyx4.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function lB({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)(cB,{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)(cB,{customTabRenderers:o,dockControls:a})}):null]})}var uB=`NextClaw`,dB=[{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 fB(e,t){return e===t||e.startsWith(`${t}/`)}function pB(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of dB)if(fB(t,e))return s(n);return s(`settings`)}function mB(e){return`${uB} - ${pB(e)}`}function hB({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=mB(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)(lB,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:c,docBrowserRenderers:ie,sideDock:(0,I.jsx)(j,{manager:t}),children:e})}function gB({children:e}){let t=ae();return(0,I.jsx)(An,{manager:t.docBrowserManager,children:(0,I.jsx)(hB,{sideDockManager:t.sideDockManager,children:e})})}function _B(){let{isMobile:e}=Fr();return e?(0,I.jsx)(ys,{}):(0,I.jsx)(T,{to:`/model`,replace:!0})}function vB(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function yB(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function bB(e,t){e&&vB(t)&&e.invalidateQueries({queryKey:[`config`]}),yB(e,t)}function xB(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})=>{bB(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 SB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ModelConfig:e}=await import(`./model-config-BXPnV_7n.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,14,3,15,16,11,17]))).ModelConfig})),CB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChatPage:e}=await import(`./chat-page-CsQx20xL.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})),wB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SearchConfig:e}=await import(`./search-config-DA5By-tE.js`);return{SearchConfig:e}},__vite__mapDeps([34,2,13,7,3,23,9,35,6]))).SearchConfig})),TB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ProvidersList:e}=await import(`./providers-list-Bko6B7dE.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})),EB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-DnqwsKGe.js`);return{ChannelsList:e}},__vite__mapDeps([37,2,3,13,14,7,23,9,10,35,6,27,33,28,30,17]))).ChannelsList})),DB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-DX_wSK1J.js`);return{RuntimeConfig:e}},__vite__mapDeps([38,2,13,14,3,32,8,39,40,25,26]))).RuntimeConfig})),OB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-BE9KjiXi.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([41,2,13,7,3,24,39]))).DesktopUpdateConfig})),kB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecurityConfig:e}=await import(`./api-BCDb13Uv.js`).then(e=>e.ut);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),AB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-eDxG7iN4.js`);return{SecretsConfig:e}},__vite__mapDeps([42,2,13,8,3,40,25]))).SecretsConfig})),jB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RemoteAccessPage:e}=await import(`./remote-DHn_b8QU.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})),MB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-Dm-0-w51.js`);return{McpMarketplacePage:e}},__vite__mapDeps([44,29,2,3,20,21,5,13,10,11,26,30]))).McpMarketplacePage}));function NB(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function PB({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(NB,{}),children:e})}function FB(e){return(0,I.jsx)(PB,{children:e})}var IB=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:FB((0,I.jsx)(CB,{view:`chat`}))},{path:`/agents`,element:FB((0,I.jsx)(CB,{view:`agents`}))},{path:`/skills`,element:FB((0,I.jsx)(CB,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:FB((0,I.jsx)(CB,{view:`skills`}))},{path:`/cron`,element:FB((0,I.jsx)(CB,{view:`cron`}))},{path:`/model`,element:FB((0,I.jsx)(SB,{}))},{path:`/search`,element:FB((0,I.jsx)(wB,{}))},{path:`/providers`,element:FB((0,I.jsx)(TB,{}))},{path:`/channels`,element:FB((0,I.jsx)(EB,{}))},{path:`/runtime`,element:FB((0,I.jsx)(DB,{}))},{path:`/updates`,element:FB((0,I.jsx)(OB,{}))},{path:`/remote`,element:FB((0,I.jsx)(jB,{}))},{path:`/security`,element:FB((0,I.jsx)(kB,{}))},{path:`/secrets`,element:FB((0,I.jsx)(AB,{}))},{path:`/language`,element:(0,I.jsx)(as,{})},{path:`/settings`,element:(0,I.jsx)(_B,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:FB((0,I.jsx)(MB,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function LB(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 RB(){return(0,I.jsx)(x,{children:IB.map(LB)})}function zB(){return xB(De),Ye(),(0,F.useEffect)(()=>(at.start(),()=>{at.stop()}),[]),(0,I.jsxs)(se,{children:[(0,I.jsx)(gB,{children:(0,I.jsx)(RB,{})}),(0,I.jsx)(ce,{}),(0,I.jsx)(ee,{})]})}function BB(){let e=tt(),t=e.isError&&Qe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(zB,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(ne,{username:e.data.username}):(0,I.jsx)(zB,{})}function VB(){return(0,F.useEffect)(()=>{Qo()},[]),(0,I.jsxs)(Ke,{client:De,children:[(0,I.jsx)(BB,{}),(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 HB=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)(HB,{children:(0,I.jsx)(VB,{})})})})}));export{ui as $,SI as A,ur as At,Ks as B,aL as C,Fr as Ct,$I as D,vr as Dt,rL as E,xr as Et,tP as F,Un as Ft,Jo as G,Ws as H,Z as I,Rn as It,Eo as J,yo as K,lN as L,Ln as Lt,AP as M,sr as Mt,oP as N,ar as Nt,QI as O,gr as Ot,cP as P,Wn as Pt,si as Q,oc as R,Fn as Rt,IL as S,Ir as St,oL as T,Sr as Tt,Is as U,$s as V,Cs as W,bo as X,xo as Y,ai as Z,_R as _,pi as _t,Jz as a,yi as at,NL as b,Si as bt,Oz as c,vi as ct,BR as d,ki as dt,mi as et,zR as f,_i as ft,pR as g,di as gt,FR as h,bi as ht,oB as i,Ci as it,TP as j,cr as jt,CI as k,fr as kt,oz as l,li as lt,IR as m,Oi as mt,nB as n,Di as nt,zz as o,Ti as ot,VR as p,gi as pt,wo as q,aB as r,hi as rt,kz as s,wi as st,sB as t,Ei as tt,XR as u,ci as ut,FL as v,xi as vt,sL as w,Ar as wt,PL as x,Lr as xt,ML as y,fi as yt,sc as z,Mn as zt};
|
|
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};
|