@nextclaw/ui 0.12.35-beta.2 → 0.12.35-beta.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/CHANGELOG.md +64 -0
- package/dist/assets/{channels-list-page-CzDMCXR_.js → channels-list-page-DHmz9iHg.js} +1 -1
- package/dist/assets/{chat-page-Doi-sasO.js → chat-page-DOKLoiqI.js} +1 -1
- package/dist/assets/{desktop-update-config-Dd4DdPH3.js → desktop-update-config-ClbDsIOs.js} +1 -1
- package/dist/assets/doc-browser-ChY6hMn8.js +1 -0
- package/dist/assets/doc-browser-cR1vWRs1.js +1 -0
- package/dist/assets/{index-dHwM4pEn.js → index-DPz9DRZN.js} +4 -4
- package/dist/assets/{mcp-marketplace-page-n9Z25Cyk.js → mcp-marketplace-page-BYPxLdUR.js} +1 -1
- package/dist/assets/mcp-marketplace-page-DXCvk7wJ.js +1 -0
- package/dist/assets/{model-config-8BVoSVXQ.js → model-config-DcnC_fSr.js} +1 -1
- package/dist/assets/{providers-list-CjJmW-od.js → providers-list-BgvjRVmp.js} +1 -1
- package/dist/assets/remote-BCuZ1JJe.js +1 -0
- package/dist/assets/{runtime-config-page-Ba6atCMq.js → runtime-config-page-B2XPXHrk.js} +1 -1
- package/dist/assets/{search-config-BtCNY431.js → search-config-BFmG4_F7.js} +1 -1
- package/dist/assets/{secrets-config-Ddh05-J5.js → secrets-config-4uY5sk-V.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +9 -9
- package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +2 -2
- package/src/shared/components/doc-browser/doc-browser.test.tsx +82 -2
- package/src/shared/components/doc-browser/doc-browser.tsx +131 -134
- package/dist/assets/doc-browser-DInzGY0W.js +0 -1
- package/dist/assets/doc-browser-DxVvmYQk.js +0 -1
- package/dist/assets/mcp-marketplace-page-D-dydvbL.js +0 -1
- package/dist/assets/remote-DxTFnQm8.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
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,o as u,p as d,r as f,s as p,t as m,u as h}from"./i18n-tWKGEGxB.js";import{$ as g,At as _,B as v,Ct as y,Dt as b,Et as x,F as S,Ft as C,G as w,H as T,I as E,It as ee,J as D,K as te,L as O,Lt as k,M as A,Mt as j,N as M,Nt as N,Ot as ne,P as re,Pt as ie,Q as ae,R as oe,Rt as se,St as ce,Tt as le,U as ue,V as de,W as fe,X as pe,Xt as me,Y as he,Yt as ge,Z as _e,_ as ve,_t as ye,a as be,at as xe,bt as Se,c as Ce,d as we,dt as Te,f as Ee,g as De,gt as Oe,h as ke,i as Ae,it as je,jt as Me,kt as Ne,l as Pe,lt as Fe,m as Ie,mt as Le,n as Re,o as ze,on as Be,ot as Ve,p as He,pt as Ue,q as We,r as Ge,rt as Ke,s as qe,st as Je,t as Ye,u as Xe,ut as Ze,v as Qe,vt as $e,wt as et,y as tt,yt as nt,z as rt,zt as it}from"./api-D3uoaOR8.js";import{_ as at,a as ot,c as st,d as ct,f as lt,g as ut,h as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t,u as vt}from"./es2015-BJw-hrex.js";import{t as yt}from"./dist-e5WATjIW.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,s as Tt,t as Et}from"./notice-card-DUDbOvqx.js";import{t as P}from"./createLucideIcon-Cwr2o6Zq.js";import{n as Dt,t as Ot}from"./search-Czito3Dk.js";import{n as kt}from"./doc-browser-DxVvmYQk.js";import{t as At}from"./book-open--T9dJHnp.js";import{C as jt,D as Mt,E as Nt,O as Pt,S as Ft,T as It,_ as Lt,b as Rt,c as zt,d as Bt,f as Vt,g as Ht,h as Ut,i as Wt,k as Gt,l as Kt,m as qt,n as Jt,o as Yt,p as Xt,r as Zt,s as Qt,t as $t,u as en,v as tn,w as nn,x as rn,y as an}from"./select-CmmDgG8o.js";import{t as on}from"./external-link-CZ9bQY0L.js";import{t as sn}from"./key-round-B8tTb3ZJ.js";import{t as cn}from"./plus-BqfNq7Tu.js";import{t as ln}from"./x-DBP3WiC9.js";import{i as un,n as dn,r as fn}from"./doc-browser-context-CLczyX2Z.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pn=o((e=>{var t=Be();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),F=e(l(),1),mn=pn(),hn=`modulepreload`,gn=function(e){return`/`+e},_n={},vn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=gn(t,n),t in _n)return;_n[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hn,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yn=`popstate`;function bn(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=En(i?l().pathname:`/`,e,t,n);return Cn(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:Dn(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?On(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function xn(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return En(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:Dn(t)}return kn(t,n,null,e)}function Sn(e,t){if(e===!1||e==null)throw Error(t)}function Cn(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function wn(){return Math.random().toString(36).substring(2,10)}function Tn(e,t){return{usr:e.state,key:e.key,idx:t}}function En(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?On(t):t,state:n,key:t&&t.key||r||wn()}}function Dn({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function On(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function kn(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=En(h.location,e,t);n&&n(r,e),l=u()+1;let d=Tn(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=En(h.location,e,t);n&&n(r,e),l=u();let i=Tn(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return An(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(yn,d),c=e,()=>{i.removeEventListener(yn,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function An(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),Sn(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:Dn(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function jn(e,t,n=`/`){return Mn(e,t,n,!1)}function Mn(e,t,n,r){let i=Xn((typeof t==`string`?On(t):t).pathname||`/`,n);if(i==null)return null;let a=Pn(e);In(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Yn(i);o=Kn(a[e],t,r)}return o}function Nn(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Pn(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;Sn(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=ir([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(Sn(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Pn(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Wn(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Fn(e.path))a(e,t,!0,n)}),t}function Fn(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Fn(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function In(e){e.sort((e,t)=>e.score===t.score?Gn(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Ln=/^:[\w-]+$/,Rn=3,zn=2,Bn=1,Vn=10,Hn=-2,Un=e=>e===`*`;function Wn(e,t){let n=e.split(`/`),r=n.length;return n.some(Un)&&(r+=Hn),t&&(r+=zn),n.filter(e=>!Un(e)).reduce((e,t)=>e+(Ln.test(t)?Rn:t===``?Bn:Vn),r)}function Gn(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Kn(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=qn({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=qn({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:ir([a,u.pathname]),pathnameBase:ar(ir([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=ir([a,u.pathnameBase]))}return o}function qn(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Jn(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Jn(e,t=!1,n=!0){Cn(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Yn(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Cn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Xn(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Zn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qn(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?On(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?$n(n.substring(1),`/`):$n(n,t)):a=t,{pathname:a,search:or(r),hash:sr(i)}}function $n(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function er(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tr(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function nr(e){let t=tr(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function rr(e,t,n,r=!1){let i;typeof e==`string`?i=On(e):(i={...e},Sn(!i.pathname||!i.pathname.includes(`?`),er(`?`,`pathname`,`search`,i)),Sn(!i.pathname||!i.pathname.includes(`#`),er(`#`,`pathname`,`hash`,i)),Sn(!i.search||!i.search.includes(`#`),er(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Qn(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ir=e=>e.join(`/`).replace(/\/\/+/g,`/`),ar=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),or=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,sr=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,cr=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function lr(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ur(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var dr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function fr(e,t){let n=e;if(typeof n!=`string`||!Zn.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(dr)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Xn(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Cn(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var pr=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(pr);var mr=[`GET`,...pr];new Set(mr);var hr=F.createContext(null);hr.displayName=`DataRouter`;var gr=F.createContext(null);gr.displayName=`DataRouterState`;var _r=F.createContext(!1),vr=F.createContext({isTransitioning:!1});vr.displayName=`ViewTransition`;var yr=F.createContext(new Map);yr.displayName=`Fetchers`;var br=F.createContext(null);br.displayName=`Await`;var xr=F.createContext(null);xr.displayName=`Navigation`;var Sr=F.createContext(null);Sr.displayName=`Location`;var Cr=F.createContext({outlet:null,matches:[],isDataRoute:!1});Cr.displayName=`Route`;var wr=F.createContext(null);wr.displayName=`RouteError`;var Tr=`REACT_ROUTER_ERROR`,Er=`REDIRECT`,Dr=`ROUTE_ERROR_RESPONSE`;function Or(e){if(e.startsWith(`${Tr}:${Er}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function kr(e){if(e.startsWith(`${Tr}:${Dr}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new cr(t.status,t.statusText,t.data)}catch{}}function Ar(e,{relative:t}={}){Sn(jr(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=F.useContext(xr),{hash:i,pathname:a,search:o}=Rr(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:ir([n,a])),r.createHref({pathname:s,search:o,hash:i})}function jr(){return F.useContext(Sr)!=null}function Mr(){return Sn(jr(),`useLocation() may be used only in the context of a <Router> component.`),F.useContext(Sr).location}var Nr=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Pr(e){F.useContext(xr).static||F.useLayoutEffect(e)}function Fr(){let{isDataRoute:e}=F.useContext(Cr);return e?ri():Ir()}function Ir(){Sn(jr(),`useNavigate() may be used only in the context of a <Router> component.`);let e=F.useContext(hr),{basename:t,navigator:n}=F.useContext(xr),{matches:r}=F.useContext(Cr),{pathname:i}=Mr(),a=JSON.stringify(nr(r)),o=F.useRef(!1);return Pr(()=>{o.current=!0}),F.useCallback((r,s={})=>{if(Cn(o.current,Nr),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=rr(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:ir([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}F.createContext(null);function Lr(){let{matches:e}=F.useContext(Cr),t=e[e.length-1];return t?t.params:{}}function Rr(e,{relative:t}={}){let{matches:n}=F.useContext(Cr),{pathname:r}=Mr(),i=JSON.stringify(nr(n));return F.useMemo(()=>rr(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function zr(e,t){return Br(e,t)}function Br(e,t,n,r,i){Sn(jr(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=F.useContext(xr),{matches:o}=F.useContext(Cr),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;ai(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-cR1vWRs1.js","assets/doc-browser-ChY6hMn8.js","assets/i18n-tWKGEGxB.js","assets/createLucideIcon-Cwr2o6Zq.js","assets/search-Czito3Dk.js","assets/book-open--T9dJHnp.js","assets/external-link-CZ9bQY0L.js","assets/plus-BqfNq7Tu.js","assets/x-DBP3WiC9.js","assets/doc-browser-context-CLczyX2Z.js","assets/model-config-DcnC_fSr.js","assets/api-D3uoaOR8.js","assets/provider-scoped-model-input-eO4XY0iY.js","assets/select-CmmDgG8o.js","assets/es2015-BJw-hrex.js","assets/config-hints-DGfwbumO.js","assets/chat-page-DOKLoiqI.js","assets/notice-card-DUDbOvqx.js","assets/dist-e5WATjIW.js","assets/mcp-marketplace-page-BYPxLdUR.js","assets/tag-chip-Dm_pOtE3.js","assets/play-CV_kwi9X.js","assets/tabs-custom-D3IZL9WX.js","assets/search-config-BFmG4_F7.js","assets/key-round-B8tTb3ZJ.js","assets/config-split-page-Dutq3R5o.js","assets/providers-list-BgvjRVmp.js","assets/setting-row-BUO6FeN1.js","assets/channels-list-page-DHmz9iHg.js","assets/runtime-config-page-B2XPXHrk.js","assets/rotate-cw-BKEhWuWp.js","assets/save-B6wbBLkU.js","assets/desktop-update-config-ClbDsIOs.js","assets/secrets-config-4uY5sk-V.js","assets/mcp-marketplace-page-DXCvk7wJ.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,o as u,p as d,r as f,s as p,t as m,u as h}from"./i18n-tWKGEGxB.js";import{$ as g,At as _,B as v,Ct as y,Dt as b,Et as x,F as S,Ft as C,G as w,H as T,I as E,It as ee,J as D,K as te,L as O,Lt as k,M as A,Mt as j,N as M,Nt as N,Ot as ne,P as re,Pt as ie,Q as ae,R as oe,Rt as se,St as ce,Tt as le,U as ue,V as de,W as fe,X as pe,Xt as me,Y as he,Yt as ge,Z as _e,_ as ve,_t as ye,a as be,at as xe,bt as Se,c as Ce,d as we,dt as Te,f as Ee,g as De,gt as Oe,h as ke,i as Ae,it as je,jt as Me,kt as Ne,l as Pe,lt as Fe,m as Ie,mt as Le,n as Re,o as ze,on as Be,ot as Ve,p as He,pt as Ue,q as We,r as Ge,rt as Ke,s as qe,st as Je,t as Ye,u as Xe,ut as Ze,v as Qe,vt as $e,wt as et,y as tt,yt as nt,z as rt,zt as it}from"./api-D3uoaOR8.js";import{_ as at,a as ot,c as st,d as ct,f as lt,g as ut,h as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t,u as vt}from"./es2015-BJw-hrex.js";import{t as yt}from"./dist-e5WATjIW.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,s as Tt,t as Et}from"./notice-card-DUDbOvqx.js";import{t as P}from"./createLucideIcon-Cwr2o6Zq.js";import{n as Dt,t as Ot}from"./search-Czito3Dk.js";import{n as kt}from"./doc-browser-ChY6hMn8.js";import{t as At}from"./book-open--T9dJHnp.js";import{C as jt,D as Mt,E as Nt,O as Pt,S as Ft,T as It,_ as Lt,b as Rt,c as zt,d as Bt,f as Vt,g as Ht,h as Ut,i as Wt,k as Gt,l as Kt,m as qt,n as Jt,o as Yt,p as Xt,r as Zt,s as Qt,t as $t,u as en,v as tn,w as nn,x as rn,y as an}from"./select-CmmDgG8o.js";import{t as on}from"./external-link-CZ9bQY0L.js";import{t as sn}from"./key-round-B8tTb3ZJ.js";import{t as cn}from"./plus-BqfNq7Tu.js";import{t as ln}from"./x-DBP3WiC9.js";import{i as un,n as dn,r as fn}from"./doc-browser-context-CLczyX2Z.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pn=o((e=>{var t=Be();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),F=e(l(),1),mn=pn(),hn=`modulepreload`,gn=function(e){return`/`+e},_n={},vn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=gn(t,n),t in _n)return;_n[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hn,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yn=`popstate`;function bn(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=En(i?l().pathname:`/`,e,t,n);return Cn(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:Dn(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?On(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function xn(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return En(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:Dn(t)}return kn(t,n,null,e)}function Sn(e,t){if(e===!1||e==null)throw Error(t)}function Cn(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function wn(){return Math.random().toString(36).substring(2,10)}function Tn(e,t){return{usr:e.state,key:e.key,idx:t}}function En(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?On(t):t,state:n,key:t&&t.key||r||wn()}}function Dn({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function On(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function kn(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=En(h.location,e,t);n&&n(r,e),l=u()+1;let d=Tn(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=En(h.location,e,t);n&&n(r,e),l=u();let i=Tn(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return An(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(yn,d),c=e,()=>{i.removeEventListener(yn,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function An(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),Sn(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:Dn(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function jn(e,t,n=`/`){return Mn(e,t,n,!1)}function Mn(e,t,n,r){let i=Xn((typeof t==`string`?On(t):t).pathname||`/`,n);if(i==null)return null;let a=Pn(e);In(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Yn(i);o=Kn(a[e],t,r)}return o}function Nn(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Pn(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;Sn(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=ir([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(Sn(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Pn(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Wn(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Fn(e.path))a(e,t,!0,n)}),t}function Fn(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Fn(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function In(e){e.sort((e,t)=>e.score===t.score?Gn(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Ln=/^:[\w-]+$/,Rn=3,zn=2,Bn=1,Vn=10,Hn=-2,Un=e=>e===`*`;function Wn(e,t){let n=e.split(`/`),r=n.length;return n.some(Un)&&(r+=Hn),t&&(r+=zn),n.filter(e=>!Un(e)).reduce((e,t)=>e+(Ln.test(t)?Rn:t===``?Bn:Vn),r)}function Gn(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Kn(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=qn({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=qn({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:ir([a,u.pathname]),pathnameBase:ar(ir([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=ir([a,u.pathnameBase]))}return o}function qn(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Jn(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Jn(e,t=!1,n=!0){Cn(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Yn(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Cn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Xn(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Zn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qn(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?On(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?$n(n.substring(1),`/`):$n(n,t)):a=t,{pathname:a,search:or(r),hash:sr(i)}}function $n(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function er(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tr(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function nr(e){let t=tr(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function rr(e,t,n,r=!1){let i;typeof e==`string`?i=On(e):(i={...e},Sn(!i.pathname||!i.pathname.includes(`?`),er(`?`,`pathname`,`search`,i)),Sn(!i.pathname||!i.pathname.includes(`#`),er(`#`,`pathname`,`hash`,i)),Sn(!i.search||!i.search.includes(`#`),er(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Qn(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ir=e=>e.join(`/`).replace(/\/\/+/g,`/`),ar=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),or=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,sr=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,cr=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function lr(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ur(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var dr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function fr(e,t){let n=e;if(typeof n!=`string`||!Zn.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(dr)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Xn(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Cn(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var pr=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(pr);var mr=[`GET`,...pr];new Set(mr);var hr=F.createContext(null);hr.displayName=`DataRouter`;var gr=F.createContext(null);gr.displayName=`DataRouterState`;var _r=F.createContext(!1),vr=F.createContext({isTransitioning:!1});vr.displayName=`ViewTransition`;var yr=F.createContext(new Map);yr.displayName=`Fetchers`;var br=F.createContext(null);br.displayName=`Await`;var xr=F.createContext(null);xr.displayName=`Navigation`;var Sr=F.createContext(null);Sr.displayName=`Location`;var Cr=F.createContext({outlet:null,matches:[],isDataRoute:!1});Cr.displayName=`Route`;var wr=F.createContext(null);wr.displayName=`RouteError`;var Tr=`REACT_ROUTER_ERROR`,Er=`REDIRECT`,Dr=`ROUTE_ERROR_RESPONSE`;function Or(e){if(e.startsWith(`${Tr}:${Er}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function kr(e){if(e.startsWith(`${Tr}:${Dr}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new cr(t.status,t.statusText,t.data)}catch{}}function Ar(e,{relative:t}={}){Sn(jr(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=F.useContext(xr),{hash:i,pathname:a,search:o}=Rr(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:ir([n,a])),r.createHref({pathname:s,search:o,hash:i})}function jr(){return F.useContext(Sr)!=null}function Mr(){return Sn(jr(),`useLocation() may be used only in the context of a <Router> component.`),F.useContext(Sr).location}var Nr=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Pr(e){F.useContext(xr).static||F.useLayoutEffect(e)}function Fr(){let{isDataRoute:e}=F.useContext(Cr);return e?ri():Ir()}function Ir(){Sn(jr(),`useNavigate() may be used only in the context of a <Router> component.`);let e=F.useContext(hr),{basename:t,navigator:n}=F.useContext(xr),{matches:r}=F.useContext(Cr),{pathname:i}=Mr(),a=JSON.stringify(nr(r)),o=F.useRef(!1);return Pr(()=>{o.current=!0}),F.useCallback((r,s={})=>{if(Cn(o.current,Nr),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=rr(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:ir([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}F.createContext(null);function Lr(){let{matches:e}=F.useContext(Cr),t=e[e.length-1];return t?t.params:{}}function Rr(e,{relative:t}={}){let{matches:n}=F.useContext(Cr),{pathname:r}=Mr(),i=JSON.stringify(nr(n));return F.useMemo(()=>rr(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function zr(e,t){return Br(e,t)}function Br(e,t,n,r,i){Sn(jr(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=F.useContext(xr),{matches:o}=F.useContext(Cr),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;ai(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
3
3
|
|
|
4
4
|
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let f=Mr(),p;if(t){let e=typeof t==`string`?On(t):t;Sn(u===`/`||e.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=jn(e,{pathname:h});Cn(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Cn(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=qr(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:ir([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:ir([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?F.createElement(Sr.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function Vr(){let e=ni(),t=lr(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=F.createElement(F.Fragment,null,F.createElement(`p`,null,`💿 Hey developer 👋`),F.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,F.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,F.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),F.createElement(F.Fragment,null,F.createElement(`h2`,null,`Unexpected Application Error!`),F.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?F.createElement(`pre`,{style:i},n):null,o)}var Hr=F.createElement(Vr,null),Ur=class extends F.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=kr(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:F.createElement(Cr.Provider,{value:this.props.routeContext},F.createElement(wr.Provider,{value:e,children:this.props.component}));return this.context?F.createElement(Gr,{error:e},t):t}};Ur.contextType=_r;var Wr=new WeakMap;function Gr({children:e,error:t}){let{basename:n}=F.useContext(xr);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Or(t.digest);if(e){let r=Wr.get(t);if(r)throw r;let i=fr(e.location,n);if(dr&&!Wr.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw Wr.set(t,n),n}return F.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Kr({routeContext:e,match:t,children:n}){let r=F.useContext(hr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),F.createElement(Cr.Provider,{value:e},n)}function qr(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);Sn(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:ur(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||Hr,s&&(c<0&&i===0?(ai(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?F.createElement(r.route.Component,null):r.route.element?r.route.element:e,F.createElement(Kr,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?F.createElement(Ur,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function Jr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yr(e){let t=F.useContext(hr);return Sn(t,Jr(e)),t}function Xr(e){let t=F.useContext(gr);return Sn(t,Jr(e)),t}function Zr(e){let t=F.useContext(Cr);return Sn(t,Jr(e)),t}function Qr(e){let t=Zr(e),n=t.matches[t.matches.length-1];return Sn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function $r(){return Qr(`useRouteId`)}function ei(){return Xr(`useNavigation`).navigation}function ti(){let{matches:e,loaderData:t}=Xr(`useMatches`);return F.useMemo(()=>e.map(e=>Nn(e,t)),[e,t])}function ni(){let e=F.useContext(wr),t=Xr(`useRouteError`),n=Qr(`useRouteError`);return e===void 0?t.errors?.[n]:e}function ri(){let{router:e}=Yr(`useNavigate`),t=Qr(`useNavigate`),n=F.useRef(!1);return Pr(()=>{n.current=!0}),F.useCallback(async(r,i={})=>{Cn(n.current,Nr),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var ii={};function ai(e,t,n){!t&&!ii[e]&&(ii[e]=!0,Cn(!1,n))}F.useOptimistic,F.memo(oi);function oi({routes:e,future:t,state:n,onError:r}){return Br(e,void 0,n,r,t)}function si({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=F.useRef();a.current??=bn({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[s,c]=F.useState({action:o.action,location:o.location}),l=F.useCallback(e=>{i===!1?c(e):F.startTransition(()=>c(e))},[i]);return F.useLayoutEffect(()=>o.listen(l),[o,l]),F.createElement(ui,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function ci({to:e,replace:t,state:n,relative:r}){Sn(jr(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=F.useContext(xr);Cn(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=F.useContext(Cr),{pathname:o}=Mr(),s=Fr(),c=rr(e,nr(a),o,r===`path`),l=JSON.stringify(c);return F.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function li(e){Sn(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function ui({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){Sn(!jr(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=F.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=On(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=F.useMemo(()=>{let e=Xn(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return Cn(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:F.createElement(xr.Provider,{value:c},F.createElement(Sr.Provider,{children:t,value:m}))}function di({children:e,location:t}){return zr(fi(e),t)}F.Component;function fi(e,t=[]){let n=[];return F.Children.forEach(e,(e,r)=>{if(!F.isValidElement(e))return;let i=[...t,r];if(e.type===F.Fragment){n.push.apply(n,fi(e.props.children,i));return}Sn(e.type===li,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Sn(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=fi(e.props.children,i)),n.push(a)}),n}var pi=`get`,mi=`application/x-www-form-urlencoded`;function hi(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function gi(e){return hi(e)&&e.tagName.toLowerCase()===`button`}function _i(e){return hi(e)&&e.tagName.toLowerCase()===`form`}function vi(e){return hi(e)&&e.tagName.toLowerCase()===`input`}function yi(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function bi(e,t){return e.button===0&&(!t||t===`_self`)&&!yi(e)}var xi=null;function Si(){if(xi===null)try{new FormData(document.createElement(`form`),0),xi=!1}catch{xi=!0}return xi}var Ci=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function wi(e){return e!=null&&!Ci.has(e)?(Cn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${mi}"`),null):e}function Ti(e,t){let n,r,i,a,o;if(_i(e)){let o=e.getAttribute(`action`);r=o?Xn(o,t):null,n=e.getAttribute(`method`)||pi,i=wi(e.getAttribute(`enctype`))||mi,a=new FormData(e)}else if(gi(e)||vi(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Xn(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||pi,i=wi(e.getAttribute(`formenctype`))||wi(o.getAttribute(`enctype`))||mi,a=new FormData(o,e),!Si()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(hi(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=pi,r=null,i=mi,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ei={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Di=/[&><\u2028\u2029]/g;function Oi(e){return e.replace(Di,e=>Ei[e])}function ki(e,t){if(e===!1||e==null)throw Error(t)}function Ai(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&Xn(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function ji(e,t){if(e.id in t)return t[e.id];try{let n=await vn(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Mi(e){return e!=null&&typeof e.page==`string`}function Ni(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Pi(e,t,n){return zi((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await ji(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Ni).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Fi(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Ii(e,t,{includeHydrateFallback:n}={}){return Li(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Li(e){return[...new Set(e)]}function Ri(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function zi(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Mi(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Ri(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Bi(){let e=F.useContext(hr);return ki(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Vi(){let e=F.useContext(gr);return ki(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Hi=F.createContext(void 0);Hi.displayName=`FrameworkContext`;function Ui(){let e=F.useContext(Hi);return ki(e,`You must render this element inside a <HydratedRouter> element`),e}function Wi(e,t){let n=F.useContext(Hi),[r,i]=F.useState(!1),[a,o]=F.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=F.useRef(null);F.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),F.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Gi(s,p),onBlur:Gi(c,m),onMouseEnter:Gi(l,p),onMouseLeave:Gi(u,m),onTouchStart:Gi(d,p)}]:[a,f,{}]:[!1,f,{}]}function Gi(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ki({page:e,...t}){let{router:n}=Bi(),r=F.useMemo(()=>jn(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?F.createElement(Ji,{page:e,matches:r,...t}):null}function qi(e){let{manifest:t,routeModules:n}=Ui(),[r,i]=F.useState([]);return F.useEffect(()=>{let r=!1;return Pi(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Ji({page:e,matches:t,...n}){let r=Mr(),{future:i,manifest:a,routeModules:o}=Ui(),{basename:s}=Bi(),{loaderData:c,matches:l}=Vi(),u=F.useMemo(()=>Fi(e,t,l,a,r,`data`),[e,t,l,a,r]),d=F.useMemo(()=>Fi(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=F.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=Ai(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=F.useMemo(()=>Ii(d,a),[d,a]),m=qi(d);return F.createElement(F.Fragment,null,f.map(e=>F.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>F.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>F.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Yi(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}F.Component;var Xi=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Xi&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Zi({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=F.useRef();i.current??=xn({window:r,v5Compat:!0});let a=i.current,[o,s]=F.useState({action:a.action,location:a.location}),c=F.useCallback(e=>{n===!1?s(e):F.startTransition(()=>s(e))},[n]);return F.useLayoutEffect(()=>a.listen(c),[a,c]),F.createElement(ui,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Qi({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=F.useState({action:n.action,location:n.location}),o=F.useCallback(e=>{r===!1?a(e):F.startTransition(()=>a(e))},[r]);return F.useLayoutEffect(()=>n.listen(o),[n,o]),F.createElement(ui,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Qi.displayName=`unstable_HistoryRouter`;var $i=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ea=F.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=F.useContext(xr),g=typeof c==`string`&&$i.test(c),_=fr(c,m);c=_.to;let v=Ar(c,{relative:r}),[y,b,x]=Wi(n,f),S=sa(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function C(t){e&&e(t),t.defaultPrevented||S(t)}let w=F.createElement(`a`,{...f,...x,href:_.absoluteURL||v,onClick:_.isExternal||i?e:C,ref:Yi(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?F.createElement(F.Fragment,null,w,F.createElement(Ki,{page:v})):w});ea.displayName=`Link`;var ta=F.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=Rr(a,{relative:c.relative}),d=Mr(),f=F.useContext(gr),{navigator:p,basename:m}=F.useContext(xr),h=f!=null&&_a(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=Xn(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return F.createElement(ea,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});ta.displayName=`NavLink`;var na=F.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=pi,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=F.useContext(xr),g=ua(),_=da(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&$i.test(s);return F.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?F.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});na.displayName=`Form`;function ra({getKey:e,storageKey:t,...n}){let r=F.useContext(Hi),{basename:i}=F.useContext(xr),a=Mr(),o=ti();ha({getKey:e,storageKey:t});let s=F.useMemo(()=>{if(!r||!e)return null;let t=ma(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return F.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Oi(JSON.stringify(t||fa))}, ${Oi(JSON.stringify(s))})`}})}ra.displayName=`ScrollRestoration`;function ia(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function aa(e){let t=F.useContext(hr);return Sn(t,ia(e)),t}function oa(e){let t=F.useContext(gr);return Sn(t,ia(e)),t}function sa(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=Fr(),u=Mr(),d=Rr(e,{relative:a});return F.useCallback(f=>{if(bi(f,t)){f.preventDefault();let t=n===void 0?Dn(u)===Dn(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?F.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var ca=0,la=()=>`__${String(++ca)}__`;function ua(){let{router:e}=aa(`useSubmit`),{basename:t}=F.useContext(xr),n=$r(),r=e.fetch,i=e.navigate;return F.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Ti(e,t);a.navigate===!1?await r(a.fetcherKey||la(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function da(e,{relative:t}={}){let{basename:n}=F.useContext(xr),r=F.useContext(Cr);Sn(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...Rr(e||`.`,{relative:t})},o=Mr();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:ir([n,a.pathname])),Dn(a)}var fa=`react-router-scroll-positions`,pa={};function ma(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Xn(e.pathname,n)||e.pathname},t)),i??=e.key,i}function ha({getKey:e,storageKey:t}={}){let{router:n}=aa(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=oa(`useScrollRestoration`),{basename:a}=F.useContext(xr),o=Mr(),s=ti(),c=ei();F.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),ga(F.useCallback(()=>{if(c.state===`idle`){let t=ma(o,s,a,e);pa[t]=window.scrollY}try{sessionStorage.setItem(t||fa,JSON.stringify(pa))}catch(e){Cn(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(F.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||fa);e&&(pa=JSON.parse(e))}catch{}},[t]),F.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(pa,()=>window.scrollY,e?(t,n)=>ma(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),F.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{Cn(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function ga(e,t){let{capture:n}=t||{};F.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function _a(e,{relative:t}={}){let n=F.useContext(vr);Sn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=aa(`useViewTransitionState`),i=Rr(e,{relative:t});if(!n.isTransitioning)return!1;let a=Xn(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Xn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return qn(i.pathname,o)!=null||qn(i.pathname,a)!=null}var va=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`}]]),ya=P(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),ba=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),xa=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Sa=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`}]]),Ca=P(`BrainCircuit`,[[`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:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`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:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),wa=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`}]]),Ta=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Ea=P(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Da=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`}]]),Oa=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`}]]),ka=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`}]]),Aa=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`}]]),ja=P(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ma=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`}]]),Na=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`}]]),Pa=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`}]]),Fa=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`}]]),Ia=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`}]]),La=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`}]]),Ra=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`}]]),za=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`}]]),Ba=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`}]]),Va=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`}]]),Ha=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`}]]),Ua=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`}]]),Wa=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`}]]),Ga=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`}]]),Ka=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`}]]),qa=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`}]]),Ja=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`}]]),Ya=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`}]]),Xa=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`}]]),Za=P(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Qa=P(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),$a=P(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),eo=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),to=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`}]]),no=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`}]]),ro=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),io=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`}]]),ao=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`}]]),oo=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`}]]),so=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`}]]),co=P(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),lo=P(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),uo=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`}]]),fo=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`}]]),po=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),mo=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`}]]),ho=P(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),go=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),_o=P(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),vo=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),yo=P(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),bo=P(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),xo=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`}]]),So=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`}]]),Co=P(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),I=d(),wo={active:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},ready:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},inactive:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},setup:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},warning:{dot:`bg-amber-400`,text:`text-amber-600`,bg:`bg-amber-50`}};function To({status:e,label:t,className:n}){let r=wo[e];return(0,I.jsxs)(`div`,{className:h(`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5`,r.bg,n),children:[(0,I.jsx)(`span`,{className:h(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,I.jsx)(`span`,{className:h(`text-[11px] font-medium`,r.text),children:t})]})}function Eo(){return it({queryKey:ko,queryFn:be,staleTime:5e3,refetchOnWindowFocus:!0})}function Do(e){let{label:t,muted:n,value:r}=e;return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,I.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function Oo(){let e=es(),t=Eo(),n=t.data,r=Lo(e=>e.actionLabel),i=(0,F.useMemo)(()=>Uo(n),[n]),a=!!r,o=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||f(`remoteDeviceNameAuto`),s=!!(n?.account.loggedIn&&Io(n)),{hero:c,issueHint:l}=i;return(0,F.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,I.jsx)(`div`,{className:`p-8 text-gray-400`,children:f(`remoteLoading`)}):(0,I.jsxs)(_,{className:`space-y-6`,children:[(0,I.jsx)(Ne,{title:f(`remotePageTitle`),description:f(`remotePageDescription`)}),(0,I.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,I.jsxs)(et,{children:[(0,I.jsxs)(b,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(ne,{children:c.title}),(0,I.jsx)(To,{status:c.badgeStatus,label:c.badgeLabel})]}),(0,I.jsx)(x,{children:c.description})]}),(0,I.jsxs)(le,{className:`space-y-5`,children:[(0,I.jsxs)(Et,{tone:`neutral`,children:[(0,I.jsx)(Do,{label:f(`remoteSignedInAccount`),value:n?.account.email}),(0,I.jsx)(Do,{label:f(`remoteDeviceName`),value:o}),(0,I.jsx)(Do,{label:f(`remoteConnectionStatus`),value:c.badgeLabel}),(0,I.jsx)(Do,{label:f(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?m(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.primaryAction?(0,I.jsxs)(N,{onClick:()=>{if(i.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(i.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:a,children:[i.primaryAction.showRefreshIcon?(0,I.jsx)(co,{className:`mr-2 h-4 w-4`}):null,r||i.primaryAction.label]}):null,(0,I.jsxs)(N,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:a||!s,children:[(0,I.jsx)(ho,{className:`mr-2 h-4 w-4`}),f(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,I.jsx)(N,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:a,children:f(`remoteDisable`)}):null]}),i.shouldShowIssueHint&&l?(0,I.jsx)(Et,{tone:`warning`,title:l.title,description:l.body}):null,(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:f(`remoteOpenWebHint`)})]})]}),(0,I.jsxs)(et,{children:[(0,I.jsxs)(b,{children:[(0,I.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Za,{className:`h-4 w-4 text-primary`}),f(`remoteDeviceSectionTitle`)]}),(0,I.jsx)(x,{children:f(`remoteDeviceSectionDescription`)})]}),(0,I.jsxs)(le,{className:`space-y-5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(To,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?f(`remoteAccountConnected`):f(`remoteAccountNotConnected`)}),(0,I.jsx)(To,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?f(`remoteEnabled`):f(`remoteStateDisabled`)}),(0,I.jsx)(To,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?f(`remoteServiceRunning`):f(`remoteServiceStopped`)})]}),(0,I.jsxs)(Et,{tone:`neutral`,children:[(0,I.jsx)(Do,{label:f(`remoteDeviceName`),value:o}),(0,I.jsx)(Do,{label:f(`remoteConnectionStatus`),value:c.badgeLabel}),(0,I.jsx)(Do,{label:f(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?m(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,I.jsx)(Et,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?f(`remoteOpenWebHint`):f(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var ko=[`remote-status`],Ao=`https://platform.nextclaw.io`,jo=`https://nextclaw-platform-console.pages.dev`,Mo=async()=>await C.fetchQuery({queryKey:ko,queryFn:be,staleTime:5e3}),No=async()=>(await C.invalidateQueries({queryKey:ko}),await Mo()),Po=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function Fo(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return Ao;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return jo}var Io=e=>Fo(e?.account.apiBase)||Fo(e?.settings.platformApiBase)||Fo(e?.platformBase)||Fo(e?.account.platformBase)||void 0,Lo=Se(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),Ro=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=Lo.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{Lo.getState().setEnabled(e)},this.setDeviceName=e=>{Lo.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{Lo.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{Lo.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await No(),n=Lo.getState();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`},apiBase:n.platformApiBase});return}await this.applyEnabledState(!0,t)},this.disableRemoteAccess=async e=>{let t=e??await No();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await No();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`}});return}let n=t.service.running?`restart`:`start`;await this.runManagedAction({actionLabel:f(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await Ge(n);let e=await No();this.hydrateDraftFromStatus(e)},successMessage:f(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await No();await this.accountManager?.startBrowserSignIn({status:t,apiBase:Lo.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let t=e??await No(),n=Lo.getState();await this.runManagedAction({actionLabel:f(`remoteActionSavingAdvanced`),job:async()=>{await Xe({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await No();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?f(`remoteSettingsSaved`):f(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:f(`remoteDoctorRunning`),job:async()=>{let e=await Ae();Lo.getState().setDoctor(e)},successMessage:f(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,f(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,f(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,f(`remoteActionStopping`))},this.resumePendingActionAfterSignIn=async(e,t)=>{if(e){if(e.type===`enable-remote`){await this.applyEnabledState(!0,t);return}e.type===`repair-remote`&&await this.repairRemoteAccess(t)}},this.applyEnabledState=async(e,t)=>{let n=Lo.getState();await this.runManagedAction({actionLabel:f(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await Xe({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await No();this.hydrateDraftFromStatus(r),e?await Ge(r.service.running?`restart`:`start`):t.service.running&&await Ge(`restart`);let i=await No();this.hydrateDraftFromStatus(i)},successMessage:f(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await Ge(e),n=await No();this.hydrateDraftFromStatus(n),k.success(t.message)}})},this.hydrateDraftFromStatus=e=>{Lo.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{Lo.getState().beginAction(e.actionLabel);try{await e.job(),e.successMessage&&k.success(e.successMessage)}catch(e){let t=e instanceof Error?e.message:f(`error`);throw k.error(t),e}finally{Lo.getState().finishAction()}}}},zo=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function Bo(e){return e?.runtime?.lastError?.trim()||``}function Vo(e){let t=f(`remoteStatusIssueDetailGeneric`),n=Bo(e);return n?`${t} (${n})`:t}function Ho(e){if(!e?.settings.enabled)return!1;let t=Bo(e);return zo.some(e=>e.test(t))}function Uo(e){return Ho(e)?{hero:{badgeStatus:`warning`,badgeLabel:f(`remoteStateReauthorizationRequired`),title:f(`remoteStatusReauthorizationTitle`),description:f(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:f(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:f(`remoteStatusRecoveryTitle`),body:f(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:f(`statusReady`),title:f(`remoteStatusReadyTitle`),description:f(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:f(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:f(`connecting`),title:f(`remoteStatusConnectingTitle`),description:f(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:f(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:f(`remoteStateDisconnected`),title:f(`remoteStatusIssueTitle`),description:f(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:f(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:f(`remoteStatusRecoveryTitle`),body:Vo(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:f(`remoteServiceStopped`),title:f(`remoteStatusNeedsServiceTitle`),description:f(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:f(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:f(`remoteStatusRecoveryTitle`),body:f(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:f(`statusInactive`),title:f(`remoteStatusNeedsEnable`),description:f(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:f(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:f(`statusSetup`),title:f(`remoteStatusNeedsSignIn`),description:f(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:f(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Wo=Se(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,pendingAction:null,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),setPendingAction:t=>e({pendingAction:t}),clearPendingAction:()=>e({pendingAction:null}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function Go({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,I.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Ko(e){let{email:t,username:n,role:r,canSubmitUsername:i,savingUsername:a,usernameDraft:o,onUsernameDraftChange:s,onSubmitUsername:c,onOpenDeviceList:l,onLogout:u}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Et,{tone:`success`,title:f(`accountPanelSignedInTitle`),description:f(`accountPanelSignedInDescription`)}),(0,I.jsxs)(Et,{tone:`neutral`,children:[(0,I.jsx)(Go,{label:f(`remoteAccountEmail`),value:t}),(0,I.jsx)(Go,{label:f(`remoteAccountUsername`),value:n}),(0,I.jsx)(Go,{label:f(`remoteAccountRole`),value:r})]}),n?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:f(`remoteAccountUsernameLockedHelp`)}):(0,I.jsxs)(Et,{tone:`warning`,title:f(`remoteAccountUsernameRequiredTitle`),description:f(`remoteAccountUsernameRequiredDescription`),children:[(0,I.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,I.jsx)(Me,{htmlFor:`account-panel-username`,children:f(`remoteAccountUsername`)}),(0,I.jsx)(j,{id:`account-panel-username`,value:o,onChange:e=>s(e.target.value),placeholder:f(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,I.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,I.jsx)(N,{disabled:!i,onClick:()=>void c(),children:f(a?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsxs)(N,{onClick:()=>void l(),children:[(0,I.jsx)(ho,{className:`mr-2 h-4 w-4`}),f(`remoteOpenDeviceList`)]}),(0,I.jsxs)(N,{variant:`outline`,onClick:()=>void u(),children:[(0,I.jsx)($a,{className:`mr-2 h-4 w-4`}),f(`remoteLogout`)]})]})]})}function qo(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:r,authVerificationUri:i,onStartBrowserSignIn:a,onResumeBrowserSignIn:o}=e;return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(Et,{tone:`neutral`,title:f(`accountPanelSignedOutTitle`),description:f(`accountPanelSignedOutDescription`),children:t?(0,I.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,I.jsx)(Go,{label:f(`remoteBrowserAuthSession`),value:t}),(0,I.jsx)(Go,{label:f(`remoteBrowserAuthExpiresAt`),value:n?m(n):`-`})]}):null}),r?(0,I.jsx)(`p`,{className:`text-sm text-gray-600`,children:r}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,I.jsx)(N,{onClick:()=>void a(),children:f(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),i?(0,I.jsx)(N,{variant:`outline`,onClick:o,children:f(`remoteBrowserAuthResume`)}):null]})]})}function Jo(){let e=es(),t=Eo(),n=Wo(e=>e.panelOpen),r=Wo(e=>e.authSessionId),i=Wo(e=>e.authVerificationUri),a=Wo(e=>e.authExpiresAt),o=Wo(e=>e.authStatusMessage),s=t.data,[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1);(0,F.useEffect)(()=>{e.accountManager.syncRemoteStatus(s)},[e,s]);let p=!u&&c.trim().length>0&&!s?.account.username;return(0,I.jsx)(St,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,I.jsxs)(wt,{className:`max-w-xl`,children:[(0,I.jsxs)(Ct,{children:[(0,I.jsxs)(Tt,{className:`flex items-center gap-2`,children:[(0,I.jsx)(sn,{className:`h-5 w-5 text-primary`}),f(`accountPanelTitle`)]}),(0,I.jsx)(xt,{children:f(`accountPanelDescription`)})]}),s?.account.loggedIn?(0,I.jsx)(Ko,{email:s.account.email,username:s.account.username,role:s.account.role,canSubmitUsername:p,savingUsername:u,usernameDraft:c,onUsernameDraftChange:l,onSubmitUsername:async()=>{d(!0);try{await e.accountManager.updateUsername(c)}finally{d(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,I.jsx)(qo,{authSessionId:r,authExpiresAt:a,authStatusMessage:o,authVerificationUri:i,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Yo({username:e}){let t=Te(),[n,r]=(0,F.useState)(e??``),[i,a]=(0,F.useState)(``),o=n.trim().length>0&&i.length>0&&!t.isPending;return(0,I.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,I.jsxs)(et,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,I.jsxs)(b,{children:[(0,I.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:f(`authBrand`)}),(0,I.jsx)(ne,{className:`text-2xl`,children:f(`authLoginTitle`)}),(0,I.jsx)(x,{children:f(`authLoginDescription`)})]}),(0,I.jsx)(le,{children:(0,I.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),o&&t.mutate({username:n.trim(),password:i})},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:f(`authUsername`)}),(0,I.jsx)(j,{value:n,onChange:e=>r(e.target.value),placeholder:f(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:f(`authPassword`)}),(0,I.jsx)(j,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:f(`authPasswordPlaceholder`)})]}),(0,I.jsx)(N,{type:`submit`,className:`w-full`,disabled:!o,children:t.isPending?f(`authLoggingIn`):f(`authLoginAction`)})]})})]})})}var Xo=class{constructor(){this.authPollTimerId=null,this.afterSignedIn=null,this.bindSignedInContinuation=e=>{this.afterSignedIn=e},this.openAccountPanel=()=>{Wo.getState().openPanel()},this.closeAccountPanel=()=>{Wo.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),Wo.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await Mo();return t.account.loggedIn?!0:(e?.pendingAction&&Wo.getState().setPendingAction(e.pendingAction),this.openAccountPanel(),await this.startBrowserSignIn({apiBase:e?.apiBase,status:t}),!1)},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,n=e?.pendingAction,r=e?.status??await Mo();n&&Wo.getState().setPendingAction(n);let i=await Ce({apiBase:Po(r,t)});Wo.getState().beginBrowserAuth({sessionId:i.sessionId,verificationUri:i.verificationUri,expiresAt:i.expiresAt,intervalMs:i.intervalMs,statusMessage:f(`remoteBrowserAuthWaiting`)}),window.open(i.verificationUri,`_blank`,`noopener,noreferrer`)||Wo.getState().setAuthStatusMessage(f(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:f(`remoteBrowserAuthStartFailed`);k.error(`${f(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Wo.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ze(),Wo.getState().clearPendingAction(),Wo.getState().clearBrowserAuth(),await No(),k.success(f(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:f(`remoteLogoutFailed`);k.error(`${f(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await Pe({username:e.trim()}),await No(),k.success(f(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:f(`remoteAccountUsernameSetFailed`);k.error(`${f(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=Io(await Mo());if(!t){k.error(f(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(n,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Wo.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Wo.getState();if(e.authSessionId)try{let t=await Mo(),n=await qe({sessionId:e.authSessionId,apiBase:Po(t)});if(n.status===`pending`){Wo.getState().updateBrowserAuth({statusMessage:f(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),Wo.getState().clearBrowserAuth(),k.error(n.message||f(`remoteBrowserAuthExpired`));return}Wo.getState().setAuthStatusMessage(f(`remoteBrowserAuthCompleted`));let r=await No(),{pendingAction:i}=Wo.getState();this.clearPollTimer(),Wo.getState().clearBrowserAuth(),k.success(f(`remoteLoginSuccess`)),i&&this.afterSignedIn&&await this.afterSignedIn(i,r),Wo.getState().clearPendingAction()}catch(e){this.clearPollTimer(),Wo.getState().clearBrowserAuth();let t=e instanceof Error?e.message:f(`remoteBrowserAuthPollFailed`);k.error(`${f(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.getBrowserAuthSummary=()=>{let e=Wo.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?m(e.authExpiresAt):`-`}}}},Zo=new class{constructor(){this.accountManager=new Xo,this.remoteAccessManager=new Ro}};Zo.accountManager.bindSignedInContinuation(Zo.remoteAccessManager.resumePendingActionAfterSignIn),Zo.remoteAccessManager.bindAccountManager(Zo.accountManager);var Qo=(0,F.createContext)(null);function $o({children:e}){return(0,I.jsx)(Qo.Provider,{value:Zo,children:e})}function es(){let e=(0,F.useContext)(Qo);if(!e)throw Error(`useAppManager must be used inside AppManagerProvider`);return e}function ts(){let e=un();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;fn(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 ns=(0,F.createContext)(null);function rs({children:e}){let[r,i]=(0,F.useState)(()=>p());(0,F.useEffect)(()=>c(e=>{i(e)}),[]);let a=(0,F.useCallback)(e=>{n(e),i(t())},[]),o=(0,F.useCallback)(()=>{a(r===`en`?`zh`:`en`)},[r,a]),s=(0,F.useMemo)(()=>({language:r,setLanguage:a,toggleLanguage:o}),[r,a,o]);return(0,I.jsx)(ns.Provider,{value:s,children:e})}function is(){let e=(0,F.useContext)(ns);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:f}}function as(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function os(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:as(e),width:e}}var ss=Se(()=>os()),cs=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=()=>ss.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),ss.setState(os())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;ss.setState({width:e,mode:as(e)})}}};function ls(){return(0,F.useEffect)(()=>cs.attach(),[]),{isMobile:ss(e=>e.mode)===`mobile`}}var us=Se(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),ds=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}us.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();us.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){us.setState({supported:!0,initialized:!0,busyAction:null}),k.error(`${f(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{us.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(f(`runtimePresenceLaunchAtLoginUnavailable`));us.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return us.setState({supported:!0,initialized:!0,snapshot:n}),k.success(f(`runtimePresenceSaved`)),n}catch(e){throw k.error(`${f(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{us.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:f(`error`)}},fs=Se(()=>({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){fs.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{fs.setState({supported:!0,initialized:!0,snapshot:e})}),fs.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();fs.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){fs.setState({supported:!0,initialized:!0}),k.error(`${f(`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`,f(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){k.success(f(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){k.success(f(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??f(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){k.success(f(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&k.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,f(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&k.success(f(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,f(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,f(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(fs.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,f(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){k.success(f(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}k.success(f(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(f(`desktopUpdatesDesktopOnlyDescription`));fs.setState({busyAction:e});try{let e=await n(r);return fs.setState({snapshot:e}),e}catch(e){throw k.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{fs.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:f(`error`),this.getChannelLabel=e=>f(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function ps(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function ms(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 hs(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function gs(e){return[{target:`/chat`,label:e(`chat`),icon:eo},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:Ca},{target:`/agents`,label:e(`agentsPageTitle`),icon:Sa},{target:`/settings`,label:e(`settings`),icon:uo}]}function _s(e){return[{target:`/model`,label:e(`model`),icon:ka},{target:`/providers`,label:e(`providers`),icon:mo},{target:`/channels`,label:e(`channels`),icon:no},{target:`/search`,label:e(`searchChannels`),icon:Ot},{target:`/runtime`,label:e(`runtime`),icon:ka},{target:`/updates`,label:e(`updates`),icon:Aa},{target:`/remote`,label:e(`remote`),icon:So},{target:`/security`,label:e(`security`),icon:fo},{target:`/secrets`,label:e(`secrets`),icon:sn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:Co}]}function vs(e){return[{target:`/language`,label:e(`language`),icon:Xa},..._s(e)]}function ys(e){let t=e.toLowerCase();return t===`/settings`?!0:vs(e=>e).some(e=>ps(t,e.target))}function bs(e,t){let n=e.toLowerCase(),r=vs(t);if(hs(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(ps(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var xs=`nextclaw.ui.theme`,Ss=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Cs=`warm`,ws=!1,Ts=new Set;function Es(e){return e===`warm`||e===`cool`}function Ds(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function Os(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(xs);if(Es(e))return e}catch{}return`warm`}function ks(){return ws||=(Cs=Os(),Ds(Cs),!0),Cs}function As(){return ws?Cs:ks()}function js(e){if(ks(),e!==Cs){if(Cs=e,Ds(Cs),typeof window<`u`)try{window.localStorage.setItem(xs,Cs)}catch{}Ts.forEach(e=>e(Cs))}}function Ms(e){return Ts.add(e),()=>{Ts.delete(e)}}function Ns(){return it({queryKey:[`config`],queryFn:O,staleTime:3e4,refetchOnWindowFocus:!0})}function Ps(){return it({queryKey:[`app-meta`],queryFn:E,staleTime:1/0})}function Fs(){return it({queryKey:[`config-meta`],queryFn:oe,staleTime:1/0})}function Is(){return it({queryKey:[`config-schema`],queryFn:rt,staleTime:1/0})}function Ls(){let e=me();return se({mutationFn:he,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),k.success(f(`configSaved`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Rs(){let e=me();return se({mutationFn:({data:e})=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function zs(){let e=me();return se({mutationFn:({provider:e,data:t})=>pe(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),k.success(f(`configSaved`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Bs(){let e=me();return se({mutationFn:({data:e})=>A(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),k.success(f(`configSaved`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Vs(){let e=me();return se({mutationFn:({provider:e})=>re(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),k.success(f(`configSaved`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Hs(){return se({mutationFn:({provider:e,data:t})=>We(e,t)})}function Us(){return se({mutationFn:({provider:e,data:t})=>te(e,t)})}function Ws(){return se({mutationFn:({provider:e,data:t})=>ue(e,t)})}function Gs(){return se({mutationFn:({provider:e})=>T(e)})}function Ks(){let e=me();return se({mutationFn:({channel:e,data:t})=>D(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),k.success(f(`configSavedApplying`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function qs(){let e=me();return se({mutationFn:({data:e})=>_e(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Js(){let e=me();return se({mutationFn:({data:e})=>g(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function Ys(){return se({mutationFn:({actionId:e,data:t})=>S(e,t),onError:e=>{k.error(f(`error`)+`: `+e.message)}})}function Xs(e){return it({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>ve(e),staleTime:5e3,retry:!1})}function Zs(e){return it({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>De(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Qs(e={all:!0}){return it({queryKey:[`cron`,e],queryFn:()=>v(e),staleTime:1e4})}function $s(){let e=me();return se({mutationFn:({id:e})=>M(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function ec(){let e=me();return se({mutationFn:({id:e,enabled:t})=>w(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function tc(){let e=me();return se({mutationFn:({id:e,force:t})=>fe(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}var nc=`Popover`,[rc,ic]=dt(nc,[Nt]),ac=Nt(),[oc,sc]=rc(nc),cc=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ac(t),c=F.useRef(null),[l,u]=F.useState(!1),[d,f]=ct({prop:r,defaultProp:i??!1,onChange:a,caller:nc});return(0,I.jsx)(It,{...s,children:(0,I.jsx)(oc,{scope:t,contentId:lt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:F.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:F.useCallback(()=>u(!0),[]),onCustomAnchorRemove:F.useCallback(()=>u(!1),[]),modal:o,children:n})})};cc.displayName=nc;var lc=`PopoverAnchor`,uc=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sc(lc,n),a=ac(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return F.useEffect(()=>(o(),()=>s()),[o,s]),(0,I.jsx)(Ft,{...a,...r,ref:t})});uc.displayName=lc;var dc=`PopoverTrigger`,fc=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sc(dc,n),a=ac(n),o=ut(t,i.triggerRef),s=(0,I.jsx)(st.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dc(i.open),...r,ref:o,onClick:at(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,I.jsx)(Ft,{asChild:!0,...a,children:s})});fc.displayName=dc;var pc=`PopoverPortal`,[mc,hc]=rc(pc,{forceMount:void 0}),gc=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=sc(pc,t);return(0,I.jsx)(mc,{scope:t,forceMount:n,children:(0,I.jsx)(yt,{present:n||a.open,children:(0,I.jsx)(ft,{asChild:!0,container:i,children:r})})})};gc.displayName=pc;var _c=`PopoverContent`,vc=F.forwardRef((e,t)=>{let n=hc(_c,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=sc(_c,e.__scopePopover);return(0,I.jsx)(yt,{present:r||a.open,children:a.modal?(0,I.jsx)(bc,{...i,ref:t}):(0,I.jsx)(xc,{...i,ref:t})})});vc.displayName=_c;var yc=pt(`PopoverContent.RemoveScroll`),bc=F.forwardRef((e,t)=>{let n=sc(_c,e.__scopePopover),r=F.useRef(null),i=ut(t,r),a=F.useRef(!1);return F.useEffect(()=>{let e=r.current;if(e)return _t(e)},[]),(0,I.jsx)(mt,{as:yc,allowPinchZoom:!0,children:(0,I.jsx)(Sc,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:at(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:at(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),xc=F.forwardRef((e,t)=>{let n=sc(_c,e.__scopePopover),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(Sc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Sc=F.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=sc(_c,n),p=ac(n);return gt(),(0,I.jsx)(ot,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(ht,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,I.jsx)(nn,{"data-state":Dc(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Cc=`PopoverClose`,wc=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sc(Cc,n);return(0,I.jsx)(st.button,{type:`button`,...r,ref:t,onClick:at(e.onClick,()=>i.onOpenChange(!1))})});wc.displayName=Cc;var Tc=`PopoverArrow`,Ec=F.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ac(n);return(0,I.jsx)(jt,{...i,...r,ref:t})});Ec.displayName=Tc;function Dc(e){return e?`open`:`closed`}var Oc=cc,kc=uc,Ac=fc,jc=gc,Mc=vc,Nc=Oc,Pc=Ac,Fc=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(jc,{children:(0,I.jsx)(Mc,{ref:i,sideOffset:t,align:n,className:h(`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})}));Fc.displayName=Mc.displayName;var Ic={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 Lc(){let e=Oe(),t=e.actionLabel===f(`runtimeStatusRestartAction`),n=async()=>{if(t)try{let e=await nt.runRuntimeControlAction(`restart-service`);k.success(e.message)}catch(e){let t=e instanceof Error?e.message:f(`runtimeControlActionFailed`);k.error(`${f(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(Nc,{children:[(0,I.jsx)(Pc,{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:h(`h-2.5 w-2.5 rounded-full`,Ic[e.tone])})})}),(0,I.jsxs)(Fc,{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:f(`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?f(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function Rc({className:e,density:t=`sidebar`,suffix:n}){let{data:r}=Ps(),i=r?.name??`NextClaw`,a=r?.productVersion?.trim(),o=a?`v${a}`:null,s=n??(0,I.jsx)(Lc,{}),c=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,l=t===`chrome`;return(0,I.jsxs)(`div`,{className:h(e??`flex min-w-0 items-center gap-2`,c&&`pl-[58px]`),children:[(0,I.jsx)(`div`,{className:h(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,I.jsx)(`img`,{src:`/logo.svg`,alt:i,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:h(`shrink-0 font-semibold text-gray-800`,l?`text-[15px]`:`text-[14px]`),children:i}),o?(0,I.jsx)(zc,{versionLabel:o,density:t}):null]}),(0,I.jsx)(Bc,{}),s?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:s}):null]})]})}function zc({versionLabel:e,density:t}){let[n,r]=(0,F.useState)(!1);return(0,I.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[(0,I.jsx)(`span`,{tabIndex:0,"aria-label":e,className:h(`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 Bc(){let{supported:e,busyAction:t,snapshot:n}=Le();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Vc,{snapshot:n}):n.status===`downloaded`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void Ue.applyDownloadedUpdate(),children:f(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void Ue.downloadUpdate(),children:f(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Vc({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Hc,{snapshot:e});let t=e.status===`downloading`?Uc(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:f(`updates`),children:t}):null}function Hc({snapshot:e}){let t=e.status===`failed`?f(`desktopUpdatesStatusFailed`):f(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?f(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
|
|
5
|
-
`);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 Uc(e){let t=e.progress?.percent;return t==null?f(`desktopUpdatesInlineDownloading`):f(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Wc={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 Gc(e){return Wc[e]}function Kc({to:e,label:t,icon:n,density:r=`default`,className:i}){let a=Gc(r);return(0,I.jsx)(ta,{to:e,className:({isActive:e})=>h(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,a.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,i),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:h(a.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 qc({label:e,icon:t,onClick:n,density:r=`default`,className:i,labelClassName:a,trailing:o,trailingClassName:s,testId:c,trailingTestId:l}){let u=Gc(r);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:h(`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`,u.row,i),"data-testid":c,children:[(0,I.jsx)(t,{className:h(u.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:h(`min-w-0 flex-1 text-left`,a),children:e}),o?(0,I.jsx)(`span`,{className:h(`shrink-0 text-gray-500`,u.value,s),"data-testid":l,children:o}):null]})}function Jc({label:e,icon:t,value:n,valueLabel:r,onValueChange:i,density:a=`default`,children:o}){let s=Gc(a);return(0,I.jsxs)($t,{value:n,onValueChange:i,children:[(0,I.jsxs)(Wt,{className:h(`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`,s.row),children:[(0,I.jsxs)(`div`,{className:h(`flex min-w-0 items-center`,s.gap),children:[(0,I.jsx)(t,{className:h(s.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:h(`ml-auto text-gray-500`,s.value),children:r})]}),(0,I.jsx)(Jt,{children:o})]})}var Yc=`nextclaw-pwa-install-banner-dismissed`,Xc=`nextclaw-pwa-install-banner-dismissed-until`;function Zc(){let e=el();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:tl(e):!1}function Qc(){let e=el();e?.setItem(Yc,`1`),e?.removeItem(Xc)}function $c(){let e=el();e?.removeItem(Yc),e?.removeItem(Xc)}function el(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function tl(e){let t=e.getItem(Xc);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Xc),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Yc,`1`),!0)}function nl(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Zc(),updateAvailable:!1,registrationFailed:!1}}var rl=Se(()=>nl()),il=`nextclaw-pwa-dev-sw-reset`,al=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{rl.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){rl.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;rl.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:rl.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(il)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(il,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(il)}catch{}}}},ol=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(),rl.setState(nl())},this.refreshState=()=>{let e=this.resolveInstallability();rl.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Zc()})),al.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Qc(),rl.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`?($c(),this.refreshState(),k.success(f(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,$c(),rl.setState({dismissedInstallPrompt:!0}),k.success(f(`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 sl(){let e=rl(e=>e.installability);return(0,I.jsx)(`span`,{className:h(`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:cl(e)})}function cl(e){return f(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function ll(e,t,n){return f(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function ul(){let e=rl(e=>e.installability),t=rl(e=>e.installMethod),n=rl(e=>e.blockedReason);return(0,I.jsxs)(et,{children:[(0,I.jsxs)(b,{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)(ne,{children:f(`pwaInstallTitle`)}),(0,I.jsx)(x,{children:f(`pwaInstallDescription`)})]}),(0,I.jsx)(sl,{})]}),(0,I.jsxs)(le,{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:ll(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(N,{type:`button`,className:`gap-2`,onClick:()=>{ol.promptInstall()},children:[(0,I.jsx)(Aa,{className:`h-4 w-4`}),f(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:f(`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)(po,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaInstallManualHint`)})]}):null]})]})}function dl(){let e=rl(e=>e.installability),t=rl(e=>e.installMethod),n=rl(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:f(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":f(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{ol.dismissInstallPrompt()},children:(0,I.jsx)(ln,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(N,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{ol.promptInstall()},children:[(0,I.jsx)(Aa,{className:`h-4 w-4`}),f(`pwaInstallAction`)]}),(0,I.jsx)(N,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{ol.dismissInstallPrompt()},children:f(`pwaInstallDismiss`)})]})]})}function fl(){let e=rl(e=>e.updateAvailable),t=rl(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:f(`pwaUpdateBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaUpdateBannerDescription`)})]})}),(0,I.jsx)(`div`,{className:`mt-4`,children:(0,I.jsxs)(N,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{al.applyUpdate()},children:[(0,I.jsx)(lo,{className:`h-4 w-4`}),f(`pwaUpdateAction`)]})})]})}var pl=!1;function ml(){pl||typeof window>`u`||(pl=!0,ol.start(),al.start())}var hl={warm:`#F9F8F5`,cool:`#F8FAFB`},gl=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=hl[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)}}},_l=(0,F.createContext)(null);function vl({children:e}){let[t,n]=(0,F.useState)(()=>ks());(0,F.useEffect)(()=>{gl.syncTheme(t)},[t]),(0,F.useEffect)(()=>Ms(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{js(e),n(As())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(_l.Provider,{value:i,children:e})}function yl(){let e=(0,F.useContext)(_l);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function bl(){let{language:e,setLanguage:t}=is();return{currentLanguage:e,currentLanguageLabel:s.find(t=>t.value===e)?.label??e,languageOptions:s,selectLanguage:(0,F.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}function xl(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:r}=bl();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)(Xa,{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:f(`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:()=>r(t.value),className:h(`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)(Gt,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function Sl({mode:e}){let t=es(),n=un(),r=Eo(),{currentLanguage:i,currentLanguageLabel:a,languageOptions:o,selectLanguage:s}=bl(),{theme:c,setTheme:l}=yl(),u=e===`settings`,d=f(Ss.find(e=>e.value===c)?.labelKey??`themeWarm`),p=r.data?.account.email?.trim(),m=!!r.data?.account.loggedIn,g=e=>{c!==e&&l(e)},_=[{target:`/chat`,label:f(`chat`),icon:eo},{target:`/chat/cron`,label:f(`cron`),icon:va},{target:`/chat/skills`,label:f(`marketplaceFilterSkills`),icon:Ca},{target:`/agents`,label:f(`agentsPageTitle`),icon:Sa}],v=_s(f),y=u?v:_,b=u?`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:[u?(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)(ta,{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)(Dt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:f(`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:f(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(Rc,{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:h(u?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Kc,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:h(`shrink-0 border-t border-[#dde0ea] bg-secondary`,u?`mt-2 pt-3`:`mt-3 pt-3`),children:[u?(0,I.jsx)(qc,{onClick:()=>t.accountManager.openAccountPanel(),icon:sn,label:f(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:m?p||f(`remoteAccountEntryConnected`):f(`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)(Kc,{to:`/settings`,label:f(`settings`),icon:uo})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Jc,{value:c,onValueChange:e=>g(e),icon:io,label:f(`theme`),valueLabel:d,density:b,children:Ss.map(e=>(0,I.jsx)(Zt,{value:e.value,className:`text-xs`,children:f(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Jc,{value:i,onValueChange:e=>s(e),icon:Xa,label:f(`language`),valueLabel:a,density:b,children:o.map(e=>(0,I.jsx)(Zt,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(qc,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:At,label:f(`docBrowserHelp`),density:b})]})]})]})}var Cl=[{action:`minimize`,label:`Minimize`,icon:ro},{action:`close`,label:`Close`,icon:ln,variant:`danger`}];function wl(){let e=El()?{action:`toggle-maximize`,label:`Restore`,icon:Oa}:{action:`toggle-maximize`,label:`Maximize`,icon:go};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)(Rc,{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:[Cl[0],e,Cl[1]].map(e=>(0,I.jsx)(Tl,{control:e},e.action))})]})}function Tl({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 El(){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 Dl(){return typeof window>`u`?null:kl()??window.nextclawDesktop?.platform??null}function Ol(){return Dl()===`win32`}function kl(){return null}function Al(e,t){if(t===`/settings`)return ys(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function jl(){let{pathname:e}=Mr(),t=gs(f);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":f(`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=Al(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(ea,{to:t.target,"aria-current":n?`page`:void 0,className:h(`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:h(`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:h(`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 Ml({leadingInset:e}){let t=Fr(),{pathname:n}=Mr(),r=bs(n,f);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??f(`backToMain`),children:(0,I.jsx)(Dt,{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 Nl=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DInzGY0W.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function Pl({pathname:e,isDocBrowserOpen:t,docBrowserRenderers:n={},topbarLeadingInset:r,children:i}){let a=ms(e),o=!hs(e),s=!hs(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[o?(0,I.jsx)(Ml,{leadingInset:r}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:a?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:i}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:i})})}),s?(0,I.jsx)(jl,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(Nl,{customTabRenderers:n,displayMode:`fullscreen`})}):null]})}function Fl(){let e=vs(f);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(ta,{to:e.target,className:({isActive:e})=>h(`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 Il({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:h(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:f(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:h(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:f(`chatSidebarViewProject`)})]})}var Ll={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 Rl(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function zl(e){return Rl(Ll,e)}var Bl={wx:`weixin`,lark:`feishu`},Vl={cron:{icon:`cron`}},Hl={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Ul(e){return e?.trim().toLowerCase()??``}function Wl(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Gl(e,t){let n=Ul(e);if(!n||n===`native`)return null;let r=t.find(e=>Ul(e.value)===n);return r?.label.trim()?r.label.trim():Wl(n)}function Kl(e,t){let n=Ul(e);return!n||n===`native`?null:t.find(e=>Ul(e.value)===n)??null}function ql(e){let t=Ul(e);if(!t)return null;let n=Bl[t]??t;return zl(n)?n:null}function Jl(e,t){let n=ql(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Vl[Ul(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Ul(e.sessionType),a=Kl(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=Hl[i];return o?{icon:null,label:f(o)}:{icon:null,label:a?.label?.trim()||Gl(e.sessionType,t)}}var Yl=`app://`;function Xl(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 Zl(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Yl))return t;let n=Xl(t.slice(6));return n?`/${n}`:null}function Ql({name:e,src:t,className:n,imgClassName:r,fallback:i}){let[a,o]=(0,F.useState)(!1),s=!!t&&!a;return(0,I.jsx)(`div`,{className:h(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:s?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:h(`block h-6 w-6 object-contain`,r),onError:()=>o(!0),draggable:!1}):i??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function $l({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(eu,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Zl(e.src);return(0,I.jsx)(Ql,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:h(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Sa,{className:h(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(va,{className:h(`h-3.5 w-3.5`,t)})}function eu({channel:e,className:t}){return(0,I.jsx)(Ql,{name:e,src:zl(e),className:h(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Sa,{className:`h-3 w-3 text-gray-500`})})}function tu(e){let{option:t,onSelect:n}=e,r=t.ready===!1?t.reasonMessage?.trim()||f(`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)($l,{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)(Sa,{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:h(`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:h(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?f(`statusSetup`):f(`statusReady`)]})]}),r?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:r}):null]})]})})})}function nu(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function ru(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,s]=(0,F.useState)(null),c=(0,F.useMemo)(()=>nu(n,r),[n,r]),l=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${f(`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})]}),l?(0,I.jsxs)(Nc,{open:o===e.projectRoot,onOpenChange:t=>{s(t?e.projectRoot:null)},children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{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)(cn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(Fc,{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:f(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(tu,{option:t,onSelect:()=>{a(t.value,e.projectRoot),s(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(N,{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(c,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(cn,{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 iu=[[`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 au(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 ou({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=iu[au(e)%iu.length]??iu[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:h(`rounded-full object-cover`,r)}):(0,I.jsx)(`div`,{className:h(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(Sa,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(i.trim()||`A`).slice(0,1).toUpperCase()})}function su({status:e,className:t}){let n=f(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:h(`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)(Qa,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function cu(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function lu(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 uu(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function du(e,t){return e.getFullYear()===t.getFullYear()}function fu(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return du(e,t)?n:`${e.getFullYear()}年${n}`}function pu(e,n=t(),r=new Date){if(!e)return`-`;let i=e instanceof Date?e:new Date(e);if(Number.isNaN(i.getTime()))return typeof e==`string`?e:`-`;let a=u(n),o=uu(i),s=uu(r),c=Math.floor((s-o)/864e5);if(c===0)return new Intl.DateTimeFormat(a,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);if(c===1)return f(`chatSidebarYesterday`,n);if(c>1&&c<7)return new Intl.DateTimeFormat(a,{weekday:`long`}).format(i);if(n===`zh`)return fu(i,r);let l=du(i,r)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(a,l).format(i)}function mu(e){return e.trim().toLowerCase()}function hu(e,t){let n=mu(t);return n?[e.key,cu(e),e.projectRoot??``,e.projectName??``].map(mu).some(e=>e.includes(n)):!0}function gu({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(j,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:f(`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)(N,{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":f(`save`),children:(0,I.jsx)(Gt,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(N,{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":f(`cancel`),children:(0,I.jsx)(ln,{className:`h-3.5 w-3.5`})})]})]})]})}function _u({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l=0,onSelect:u,onOpenChildSessions:d,onStartEditing:p}){let m=l>0&&d?`pr-14`:`pr-6`,g=lu(e),_=`${s?.trim()?`${s} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:u,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:h(`flex min-w-0 items-start`,m),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[o?.trim()&&o.trim().toLowerCase()!==`main`?(0,I.jsx)(ou,{agentId:o,displayName:s,avatarUrl:c,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,I.jsx)(`span`,{className:h(`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:i.label}):null,i.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)($l,{icon:i.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":f(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:pu(e.lastMessageAt??e.createdAt)})]})]}),l>0&&d?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d()},className:h(`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":f(`chatSessionOpenChildSessions`),title:f(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(qa,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:l})]}):null,r?(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)(su,{status:r})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:h(`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":f(`edit`),children:(0,I.jsx)(oo,{className:`h-3 w-3`})})]})}function vu({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l,isEditing:u,draftLabel:d,isSaving:f,onSelect:p,onOpenChildSessions:m,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:h(`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:u?(0,I.jsx)(gu,{session:e,draftLabel:d,isSaving:f,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(_u,{session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,onSelect:p,childSessionCount:l,onOpenChildSessions:m,onStartEditing:g})})}var yu=[{icon:eo,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:Ca,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:va,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function bu({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(Sa,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:f(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:f(`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:f(`chatDraftAgentTitle`)}),(0,I.jsxs)($t,{value:n,onValueChange:r,children:[(0,I.jsxs)(Wt,{"aria-label":f(`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:f(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(ou,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(Jt,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(Zt,{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)(ou,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:yu.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:f(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:f(t.descKey)})]},t.titleKey)})})]})})}var xu=(0,F.createContext)(null);function Su({presenter:e,children:t}){return(0,I.jsx)(xu.Provider,{value:e,children:t})}function Cu(){let e=(0,F.useContext)(xu);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var wu=e=>`[data-item-index="${e}"]`;function Tu(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??wu;(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 Eu(){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 r(i(e))}var Du=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}));Du.displayName=`ChatInput`;var Ou=Oc,ku=Ac,Au=kc,ju=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(jc,{children:(0,I.jsx)(Mc,{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})}));ju.displayName=Mc.displayName;var Mu=qt,Nu=Qt,Pu=an,Fu=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(tn,{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)(zt,{asChild:!0,children:(0,I.jsx)(Pt,{className:`h-4 w-4 opacity-50`})})]}));Fu.displayName=tn.displayName;var Iu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ht,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Mt,{className:`h-4 w-4`})}));Iu.displayName=Ht.displayName;var Lu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ut,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Pt,{className:`h-4 w-4`})}));Lu.displayName=Ut.displayName;var Ru=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(Xt,{children:(0,I.jsxs)(Yt,{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)(Iu,{}),(0,I.jsx)(Rt,{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)(Lu,{})]})}));Ru.displayName=Yt.displayName;var zu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Vt,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));zu.displayName=Vt.displayName;var Bu=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(Kt,{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)(en,{children:(0,I.jsx)(Gt,{className:`h-4 w-4`})})}),(0,I.jsx)(Bt,{children:t})]}));Bu.displayName=Kt.displayName;var Vu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Lt,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Vu.displayName=Lt.displayName;var[Hu,Uu]=dt(`Tooltip`,[Nt]),Wu=Nt(),Gu=`TooltipProvider`,Ku=700,qu=`tooltip.open`,[Ju,Yu]=Hu(Gu),Xu=e=>{let{__scopeTooltip:t,delayDuration:n=Ku,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(Ju,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:F.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Xu.displayName=Gu;var Zu=`Tooltip`,[Qu,$u]=Hu(Zu),ed=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Yu(Zu,e.__scopeTooltip),l=Wu(t),[u,d]=F.useState(null),f=lt(),p=F.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=F.useRef(!1),[_,v]=ct({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(qu))):c.onClose(),a?.(e)},caller:Zu}),y=F.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=F.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return F.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,I.jsx)(It,{...l,children:(0,I.jsx)(Qu,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:F.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:F.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};ed.displayName=Zu;var td=`TooltipTrigger`,nd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=$u(td,n),a=Yu(td,n),o=Wu(n),s=ut(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Ft,{asChild:!0,...o,children:(0,I.jsx)(st.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:at(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:at(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:at(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:at(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:at(e.onBlur,i.onClose),onClick:at(e.onClick,i.onClose)})})});nd.displayName=td;var rd=`TooltipPortal`,[id,ad]=Hu(rd,{forceMount:void 0}),od=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=$u(rd,t);return(0,I.jsx)(id,{scope:t,forceMount:n,children:(0,I.jsx)(yt,{present:n||a.open,children:(0,I.jsx)(ft,{asChild:!0,container:i,children:r})})})};od.displayName=rd;var sd=`TooltipContent`,cd=F.forwardRef((e,t)=>{let n=ad(sd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=$u(sd,e.__scopeTooltip);return(0,I.jsx)(yt,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(pd,{side:i,...a,ref:t}):(0,I.jsx)(ld,{side:i,...a,ref:t})})}),ld=F.forwardRef((e,t)=>{let n=$u(sd,e.__scopeTooltip),r=Yu(sd,e.__scopeTooltip),i=F.useRef(null),a=ut(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_d(r,gd(r,n.getBoundingClientRect())),a=vd(t.getBoundingClientRect());s(bd([...i,...a])),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yd(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(pd,{...e,ref:a})}),[ud,dd]=Hu(Zu,{isInside:!1}),fd=vt(`TooltipContent`),pd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=$u(sd,n),l=Wu(n),{onClose:u}=c;return F.useEffect(()=>(document.addEventListener(qu,u),()=>document.removeEventListener(qu,u)),[u]),F.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,I.jsx)(ht,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,I.jsxs)(nn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(fd,{children:r}),(0,I.jsx)(ud,{scope:n,isInside:!0,children:(0,I.jsx)(rn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});cd.displayName=sd;var md=`TooltipArrow`,hd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Wu(n);return dd(md,n).isInside?null:(0,I.jsx)(jt,{...i,...r,ref:t})});hd.displayName=md;function gd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function _d(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function vd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function yd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function bd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),xd(t)}function xd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Sd=Xu,Cd=ed,wd=nd,Td=od,Ed=cd,Dd=Sd,Od=Cd,kd=wd,Ad=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Td,{children:(0,I.jsx)(Ed,{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})}));Ad.displayName=Ed.displayName;var jd={Popover:Ou,PopoverAnchor:Au,PopoverContent:ju,PopoverTrigger:ku,Input:Du,Select:Mu,SelectContent:Ru,SelectGroup:Nu,SelectItem:Bu,SelectLabel:zu,SelectSeparator:Vu,SelectTrigger:Fu,SelectValue:Pu,Tooltip:Od,TooltipContent:Ad,TooltipProvider:Dd,TooltipTrigger:kd},Md=680,Nd=.82,Pd=560;function Fd(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=jd,{elementRef:i,width:a}=Eu(),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>Pd?a*Nd:a,Md)},[a]);return Tu({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 Id=ie(`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`}}),Ld=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Id({variant:t,size:n,className:e})),ref:i,...r}));Ld.displayName=`ChatButton`;var Rd=120;function zd(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Rd?t:`${t.slice(0,Rd-1)}…`}function Bd(){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 Vd({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=jd,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 Hd({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}=jd,y=e?.trim()??``,b=y?zd(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)(Vd,{contextWindow:l}):null,n?r?(0,I.jsx)(Ld,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(Bd,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Ld,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(Bd,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Ld,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(xa,{className:`h-5 w-5`})})]})]})}function Ud(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 Wd(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=jd,{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):Ud(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]),Tu({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)(Ca,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Ot,{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)(so,{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)(Gt,{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)(on,{className:`h-3 w-3`})]})}):null]})]})}function Gd({icon:e}){return e===`sparkles`?(0,I.jsx)(mo,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(wa,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Kd({icon:e}){return e===`paperclip`?(0,I.jsx)(ao,{className:`h-4 w-4`}):(0,I.jsx)(Gd,{icon:e})}var qd={model:`min-w-0 flex-1 sm:min-w-[220px] sm:flex-none`,"session-type":`shrink-0`,thinking:`shrink-0`},Jd={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Yd(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Xd({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=jd,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=Yd(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${qd[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Gd,{icon:e.icon}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700 sm:hidden`,children:d}),(0,I.jsx)(`span`,{className:`hidden truncate text-xs font-semibold text-gray-700 sm:inline`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:Jd[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 Zd({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=jd;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Wd,{picker:r}):null,n.map(e=>(0,I.jsx)(Xd,{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)(Kd,{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)(Hd,{...e})]})}var Qd=(0,F.createContext)(null);function $d(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function ef(){let e=(0,F.useContext)(Qd);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 tf(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 nf=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,rf=nf&&`documentMode`in document?document.documentMode:null,af=nf&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),of=nf&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),sf=!(!nf||!(`InputEvent`in window)||rf)&&`getTargetRanges`in new window.InputEvent(`input`),cf=nf&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,lf=nf&&/Android/.test(navigator.userAgent),uf=nf&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!lf,df=nf&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ff=nf&&lf&&df,pf=nf&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&af&&!df,mf=0,hf=1,gf=2,_f=1,vf=2,yf=3,bf=4,xf=5,Sf=6,Cf=uf||cf||pf?`\xA0`:``,wf=`
|
|
5
|
+
`);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 Uc(e){let t=e.progress?.percent;return t==null?f(`desktopUpdatesInlineDownloading`):f(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Wc={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 Gc(e){return Wc[e]}function Kc({to:e,label:t,icon:n,density:r=`default`,className:i}){let a=Gc(r);return(0,I.jsx)(ta,{to:e,className:({isActive:e})=>h(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,a.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,i),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:h(a.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 qc({label:e,icon:t,onClick:n,density:r=`default`,className:i,labelClassName:a,trailing:o,trailingClassName:s,testId:c,trailingTestId:l}){let u=Gc(r);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:h(`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`,u.row,i),"data-testid":c,children:[(0,I.jsx)(t,{className:h(u.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:h(`min-w-0 flex-1 text-left`,a),children:e}),o?(0,I.jsx)(`span`,{className:h(`shrink-0 text-gray-500`,u.value,s),"data-testid":l,children:o}):null]})}function Jc({label:e,icon:t,value:n,valueLabel:r,onValueChange:i,density:a=`default`,children:o}){let s=Gc(a);return(0,I.jsxs)($t,{value:n,onValueChange:i,children:[(0,I.jsxs)(Wt,{className:h(`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`,s.row),children:[(0,I.jsxs)(`div`,{className:h(`flex min-w-0 items-center`,s.gap),children:[(0,I.jsx)(t,{className:h(s.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:h(`ml-auto text-gray-500`,s.value),children:r})]}),(0,I.jsx)(Jt,{children:o})]})}var Yc=`nextclaw-pwa-install-banner-dismissed`,Xc=`nextclaw-pwa-install-banner-dismissed-until`;function Zc(){let e=el();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:tl(e):!1}function Qc(){let e=el();e?.setItem(Yc,`1`),e?.removeItem(Xc)}function $c(){let e=el();e?.removeItem(Yc),e?.removeItem(Xc)}function el(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function tl(e){let t=e.getItem(Xc);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(Xc),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Yc,`1`),!0)}function nl(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Zc(),updateAvailable:!1,registrationFailed:!1}}var rl=Se(()=>nl()),il=`nextclaw-pwa-dev-sw-reset`,al=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{rl.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){rl.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;rl.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:rl.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(il)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(il,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(il)}catch{}}}},ol=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(),rl.setState(nl())},this.refreshState=()=>{let e=this.resolveInstallability();rl.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Zc()})),al.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Qc(),rl.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`?($c(),this.refreshState(),k.success(f(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,$c(),rl.setState({dismissedInstallPrompt:!0}),k.success(f(`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 sl(){let e=rl(e=>e.installability);return(0,I.jsx)(`span`,{className:h(`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:cl(e)})}function cl(e){return f(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function ll(e,t,n){return f(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function ul(){let e=rl(e=>e.installability),t=rl(e=>e.installMethod),n=rl(e=>e.blockedReason);return(0,I.jsxs)(et,{children:[(0,I.jsxs)(b,{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)(ne,{children:f(`pwaInstallTitle`)}),(0,I.jsx)(x,{children:f(`pwaInstallDescription`)})]}),(0,I.jsx)(sl,{})]}),(0,I.jsxs)(le,{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:ll(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(N,{type:`button`,className:`gap-2`,onClick:()=>{ol.promptInstall()},children:[(0,I.jsx)(Aa,{className:`h-4 w-4`}),f(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:f(`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)(po,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaInstallManualHint`)})]}):null]})]})}function dl(){let e=rl(e=>e.installability),t=rl(e=>e.installMethod),n=rl(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:f(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":f(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{ol.dismissInstallPrompt()},children:(0,I.jsx)(ln,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(N,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{ol.promptInstall()},children:[(0,I.jsx)(Aa,{className:`h-4 w-4`}),f(`pwaInstallAction`)]}),(0,I.jsx)(N,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{ol.dismissInstallPrompt()},children:f(`pwaInstallDismiss`)})]})]})}function fl(){let e=rl(e=>e.updateAvailable),t=rl(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:f(`pwaUpdateBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:f(`pwaUpdateBannerDescription`)})]})}),(0,I.jsx)(`div`,{className:`mt-4`,children:(0,I.jsxs)(N,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{al.applyUpdate()},children:[(0,I.jsx)(lo,{className:`h-4 w-4`}),f(`pwaUpdateAction`)]})})]})}var pl=!1;function ml(){pl||typeof window>`u`||(pl=!0,ol.start(),al.start())}var hl={warm:`#F9F8F5`,cool:`#F8FAFB`},gl=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=hl[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)}}},_l=(0,F.createContext)(null);function vl({children:e}){let[t,n]=(0,F.useState)(()=>ks());(0,F.useEffect)(()=>{gl.syncTheme(t)},[t]),(0,F.useEffect)(()=>Ms(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{js(e),n(As())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(_l.Provider,{value:i,children:e})}function yl(){let e=(0,F.useContext)(_l);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function bl(){let{language:e,setLanguage:t}=is();return{currentLanguage:e,currentLanguageLabel:s.find(t=>t.value===e)?.label??e,languageOptions:s,selectLanguage:(0,F.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}function xl(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:r}=bl();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)(Xa,{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:f(`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:()=>r(t.value),className:h(`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)(Gt,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function Sl({mode:e}){let t=es(),n=un(),r=Eo(),{currentLanguage:i,currentLanguageLabel:a,languageOptions:o,selectLanguage:s}=bl(),{theme:c,setTheme:l}=yl(),u=e===`settings`,d=f(Ss.find(e=>e.value===c)?.labelKey??`themeWarm`),p=r.data?.account.email?.trim(),m=!!r.data?.account.loggedIn,g=e=>{c!==e&&l(e)},_=[{target:`/chat`,label:f(`chat`),icon:eo},{target:`/chat/cron`,label:f(`cron`),icon:va},{target:`/chat/skills`,label:f(`marketplaceFilterSkills`),icon:Ca},{target:`/agents`,label:f(`agentsPageTitle`),icon:Sa}],v=_s(f),y=u?v:_,b=u?`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:[u?(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)(ta,{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)(Dt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:f(`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:f(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(Rc,{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:h(u?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Kc,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:h(`shrink-0 border-t border-[#dde0ea] bg-secondary`,u?`mt-2 pt-3`:`mt-3 pt-3`),children:[u?(0,I.jsx)(qc,{onClick:()=>t.accountManager.openAccountPanel(),icon:sn,label:f(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:m?p||f(`remoteAccountEntryConnected`):f(`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)(Kc,{to:`/settings`,label:f(`settings`),icon:uo})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Jc,{value:c,onValueChange:e=>g(e),icon:io,label:f(`theme`),valueLabel:d,density:b,children:Ss.map(e=>(0,I.jsx)(Zt,{value:e.value,className:`text-xs`,children:f(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(Jc,{value:i,onValueChange:e=>s(e),icon:Xa,label:f(`language`),valueLabel:a,density:b,children:o.map(e=>(0,I.jsx)(Zt,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(qc,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:At,label:f(`docBrowserHelp`),density:b})]})]})]})}var Cl=[{action:`minimize`,label:`Minimize`,icon:ro},{action:`close`,label:`Close`,icon:ln,variant:`danger`}];function wl(){let e=El()?{action:`toggle-maximize`,label:`Restore`,icon:Oa}:{action:`toggle-maximize`,label:`Maximize`,icon:go};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)(Rc,{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:[Cl[0],e,Cl[1]].map(e=>(0,I.jsx)(Tl,{control:e},e.action))})]})}function Tl({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 El(){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 Dl(){return typeof window>`u`?null:kl()??window.nextclawDesktop?.platform??null}function Ol(){return Dl()===`win32`}function kl(){return null}function Al(e,t){if(t===`/settings`)return ys(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function jl(){let{pathname:e}=Mr(),t=gs(f);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":f(`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=Al(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(ea,{to:t.target,"aria-current":n?`page`:void 0,className:h(`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:h(`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:h(`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 Ml({leadingInset:e}){let t=Fr(),{pathname:n}=Mr(),r=bs(n,f);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??f(`backToMain`),children:(0,I.jsx)(Dt,{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 Nl=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DocBrowser:e}=await import(`./doc-browser-cR1vWRs1.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function Pl({pathname:e,isDocBrowserOpen:t,docBrowserRenderers:n={},topbarLeadingInset:r,children:i}){let a=ms(e),o=!hs(e),s=!hs(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[o?(0,I.jsx)(Ml,{leadingInset:r}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:a?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:i}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:i})})}),s?(0,I.jsx)(jl,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(Nl,{customTabRenderers:n,displayMode:`fullscreen`})}):null]})}function Fl(){let e=vs(f);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(ta,{to:e.target,className:({isActive:e})=>h(`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 Il({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:h(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:f(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:h(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:f(`chatSidebarViewProject`)})]})}var Ll={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 Rl(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function zl(e){return Rl(Ll,e)}var Bl={wx:`weixin`,lark:`feishu`},Vl={cron:{icon:`cron`}},Hl={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function Ul(e){return e?.trim().toLowerCase()??``}function Wl(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Gl(e,t){let n=Ul(e);if(!n||n===`native`)return null;let r=t.find(e=>Ul(e.value)===n);return r?.label.trim()?r.label.trim():Wl(n)}function Kl(e,t){let n=Ul(e);return!n||n===`native`?null:t.find(e=>Ul(e.value)===n)??null}function ql(e){let t=Ul(e);if(!t)return null;let n=Bl[t]??t;return zl(n)?n:null}function Jl(e,t){let n=ql(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Vl[Ul(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=Ul(e.sessionType),a=Kl(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=Hl[i];return o?{icon:null,label:f(o)}:{icon:null,label:a?.label?.trim()||Gl(e.sessionType,t)}}var Yl=`app://`;function Xl(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 Zl(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Yl))return t;let n=Xl(t.slice(6));return n?`/${n}`:null}function Ql({name:e,src:t,className:n,imgClassName:r,fallback:i}){let[a,o]=(0,F.useState)(!1),s=!!t&&!a;return(0,I.jsx)(`div`,{className:h(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:s?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:h(`block h-6 w-6 object-contain`,r),onError:()=>o(!0),draggable:!1}):i??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function $l({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(eu,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Zl(e.src);return(0,I.jsx)(Ql,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:h(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Sa,{className:h(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(va,{className:h(`h-3.5 w-3.5`,t)})}function eu({channel:e,className:t}){return(0,I.jsx)(Ql,{name:e,src:zl(e),className:h(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Sa,{className:`h-3 w-3 text-gray-500`})})}function tu(e){let{option:t,onSelect:n}=e,r=t.ready===!1?t.reasonMessage?.trim()||f(`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)($l,{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)(Sa,{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:h(`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:h(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?f(`statusSetup`):f(`statusReady`)]})]}),r?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:r}):null]})]})})})}function nu(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function ru(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,s]=(0,F.useState)(null),c=(0,F.useMemo)(()=>nu(n,r),[n,r]),l=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${f(`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})]}),l?(0,I.jsxs)(Nc,{open:o===e.projectRoot,onOpenChange:t=>{s(t?e.projectRoot:null)},children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{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)(cn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(Fc,{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:f(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(tu,{option:t,onSelect:()=>{a(t.value,e.projectRoot),s(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(N,{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(c,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(cn,{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 iu=[[`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 au(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 ou({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=iu[au(e)%iu.length]??iu[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:h(`rounded-full object-cover`,r)}):(0,I.jsx)(`div`,{className:h(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(Sa,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(i.trim()||`A`).slice(0,1).toUpperCase()})}function su({status:e,className:t}){let n=f(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:h(`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)(Qa,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function cu(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function lu(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 uu(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function du(e,t){return e.getFullYear()===t.getFullYear()}function fu(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return du(e,t)?n:`${e.getFullYear()}年${n}`}function pu(e,n=t(),r=new Date){if(!e)return`-`;let i=e instanceof Date?e:new Date(e);if(Number.isNaN(i.getTime()))return typeof e==`string`?e:`-`;let a=u(n),o=uu(i),s=uu(r),c=Math.floor((s-o)/864e5);if(c===0)return new Intl.DateTimeFormat(a,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);if(c===1)return f(`chatSidebarYesterday`,n);if(c>1&&c<7)return new Intl.DateTimeFormat(a,{weekday:`long`}).format(i);if(n===`zh`)return fu(i,r);let l=du(i,r)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(a,l).format(i)}function mu(e){return e.trim().toLowerCase()}function hu(e,t){let n=mu(t);return n?[e.key,cu(e),e.projectRoot??``,e.projectName??``].map(mu).some(e=>e.includes(n)):!0}function gu({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(j,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:f(`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)(N,{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":f(`save`),children:(0,I.jsx)(Gt,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(N,{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":f(`cancel`),children:(0,I.jsx)(ln,{className:`h-3.5 w-3.5`})})]})]})]})}function _u({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l=0,onSelect:u,onOpenChildSessions:d,onStartEditing:p}){let m=l>0&&d?`pr-14`:`pr-6`,g=lu(e),_=`${s?.trim()?`${s} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:u,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:h(`flex min-w-0 items-start`,m),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[o?.trim()&&o.trim().toLowerCase()!==`main`?(0,I.jsx)(ou,{agentId:o,displayName:s,avatarUrl:c,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,I.jsx)(`span`,{className:h(`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:i.label}):null,i.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)($l,{icon:i.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":f(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:pu(e.lastMessageAt??e.createdAt)})]})]}),l>0&&d?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d()},className:h(`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":f(`chatSessionOpenChildSessions`),title:f(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(qa,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:l})]}):null,r?(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)(su,{status:r})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:h(`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":f(`edit`),children:(0,I.jsx)(oo,{className:`h-3 w-3`})})]})}function vu({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l,isEditing:u,draftLabel:d,isSaving:f,onSelect:p,onOpenChildSessions:m,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:h(`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:u?(0,I.jsx)(gu,{session:e,draftLabel:d,isSaving:f,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(_u,{session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,onSelect:p,childSessionCount:l,onOpenChildSessions:m,onStartEditing:g})})}var yu=[{icon:eo,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:Ca,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:va,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function bu({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(Sa,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:f(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:f(`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:f(`chatDraftAgentTitle`)}),(0,I.jsxs)($t,{value:n,onValueChange:r,children:[(0,I.jsxs)(Wt,{"aria-label":f(`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:f(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(ou,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(Jt,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(Zt,{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)(ou,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:yu.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:f(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:f(t.descKey)})]},t.titleKey)})})]})})}var xu=(0,F.createContext)(null);function Su({presenter:e,children:t}){return(0,I.jsx)(xu.Provider,{value:e,children:t})}function Cu(){let e=(0,F.useContext)(xu);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var wu=e=>`[data-item-index="${e}"]`;function Tu(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??wu;(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 Eu(){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 r(i(e))}var Du=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}));Du.displayName=`ChatInput`;var Ou=Oc,ku=Ac,Au=kc,ju=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(jc,{children:(0,I.jsx)(Mc,{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})}));ju.displayName=Mc.displayName;var Mu=qt,Nu=Qt,Pu=an,Fu=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(tn,{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)(zt,{asChild:!0,children:(0,I.jsx)(Pt,{className:`h-4 w-4 opacity-50`})})]}));Fu.displayName=tn.displayName;var Iu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ht,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Mt,{className:`h-4 w-4`})}));Iu.displayName=Ht.displayName;var Lu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ut,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Pt,{className:`h-4 w-4`})}));Lu.displayName=Ut.displayName;var Ru=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(Xt,{children:(0,I.jsxs)(Yt,{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)(Iu,{}),(0,I.jsx)(Rt,{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)(Lu,{})]})}));Ru.displayName=Yt.displayName;var zu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Vt,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));zu.displayName=Vt.displayName;var Bu=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(Kt,{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)(en,{children:(0,I.jsx)(Gt,{className:`h-4 w-4`})})}),(0,I.jsx)(Bt,{children:t})]}));Bu.displayName=Kt.displayName;var Vu=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Lt,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Vu.displayName=Lt.displayName;var[Hu,Uu]=dt(`Tooltip`,[Nt]),Wu=Nt(),Gu=`TooltipProvider`,Ku=700,qu=`tooltip.open`,[Ju,Yu]=Hu(Gu),Xu=e=>{let{__scopeTooltip:t,delayDuration:n=Ku,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(Ju,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:F.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Xu.displayName=Gu;var Zu=`Tooltip`,[Qu,$u]=Hu(Zu),ed=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Yu(Zu,e.__scopeTooltip),l=Wu(t),[u,d]=F.useState(null),f=lt(),p=F.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=F.useRef(!1),[_,v]=ct({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(qu))):c.onClose(),a?.(e)},caller:Zu}),y=F.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=F.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=F.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return F.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,I.jsx)(It,{...l,children:(0,I.jsx)(Qu,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:F.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:F.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};ed.displayName=Zu;var td=`TooltipTrigger`,nd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=$u(td,n),a=Yu(td,n),o=Wu(n),s=ut(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Ft,{asChild:!0,...o,children:(0,I.jsx)(st.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:at(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:at(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:at(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:at(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:at(e.onBlur,i.onClose),onClick:at(e.onClick,i.onClose)})})});nd.displayName=td;var rd=`TooltipPortal`,[id,ad]=Hu(rd,{forceMount:void 0}),od=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=$u(rd,t);return(0,I.jsx)(id,{scope:t,forceMount:n,children:(0,I.jsx)(yt,{present:n||a.open,children:(0,I.jsx)(ft,{asChild:!0,container:i,children:r})})})};od.displayName=rd;var sd=`TooltipContent`,cd=F.forwardRef((e,t)=>{let n=ad(sd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=$u(sd,e.__scopeTooltip);return(0,I.jsx)(yt,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(pd,{side:i,...a,ref:t}):(0,I.jsx)(ld,{side:i,...a,ref:t})})}),ld=F.forwardRef((e,t)=>{let n=$u(sd,e.__scopeTooltip),r=Yu(sd,e.__scopeTooltip),i=F.useRef(null),a=ut(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_d(r,gd(r,n.getBoundingClientRect())),a=vd(t.getBoundingClientRect());s(bd([...i,...a])),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yd(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(pd,{...e,ref:a})}),[ud,dd]=Hu(Zu,{isInside:!1}),fd=vt(`TooltipContent`),pd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=$u(sd,n),l=Wu(n),{onClose:u}=c;return F.useEffect(()=>(document.addEventListener(qu,u),()=>document.removeEventListener(qu,u)),[u]),F.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,I.jsx)(ht,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,I.jsxs)(nn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(fd,{children:r}),(0,I.jsx)(ud,{scope:n,isInside:!0,children:(0,I.jsx)(rn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});cd.displayName=sd;var md=`TooltipArrow`,hd=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Wu(n);return dd(md,n).isInside?null:(0,I.jsx)(jt,{...i,...r,ref:t})});hd.displayName=md;function gd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function _d(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function vd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function yd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function bd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),xd(t)}function xd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Sd=Xu,Cd=ed,wd=nd,Td=od,Ed=cd,Dd=Sd,Od=Cd,kd=wd,Ad=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Td,{children:(0,I.jsx)(Ed,{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})}));Ad.displayName=Ed.displayName;var jd={Popover:Ou,PopoverAnchor:Au,PopoverContent:ju,PopoverTrigger:ku,Input:Du,Select:Mu,SelectContent:Ru,SelectGroup:Nu,SelectItem:Bu,SelectLabel:zu,SelectSeparator:Vu,SelectTrigger:Fu,SelectValue:Pu,Tooltip:Od,TooltipContent:Ad,TooltipProvider:Dd,TooltipTrigger:kd},Md=680,Nd=.82,Pd=560;function Fd(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=jd,{elementRef:i,width:a}=Eu(),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>Pd?a*Nd:a,Md)},[a]);return Tu({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 Id=ie(`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`}}),Ld=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Id({variant:t,size:n,className:e})),ref:i,...r}));Ld.displayName=`ChatButton`;var Rd=120;function zd(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Rd?t:`${t.slice(0,Rd-1)}…`}function Bd(){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 Vd({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=jd,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 Hd({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}=jd,y=e?.trim()??``,b=y?zd(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)(Vd,{contextWindow:l}):null,n?r?(0,I.jsx)(Ld,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(Bd,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Ld,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(Bd,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Ld,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(xa,{className:`h-5 w-5`})})]})]})}function Ud(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 Wd(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=jd,{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):Ud(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]),Tu({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)(Ca,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Ot,{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)(so,{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)(Gt,{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)(on,{className:`h-3 w-3`})]})}):null]})]})}function Gd({icon:e}){return e===`sparkles`?(0,I.jsx)(mo,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(wa,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Kd({icon:e}){return e===`paperclip`?(0,I.jsx)(ao,{className:`h-4 w-4`}):(0,I.jsx)(Gd,{icon:e})}var qd={model:`min-w-0 flex-1 sm:min-w-[220px] sm:flex-none`,"session-type":`shrink-0`,thinking:`shrink-0`},Jd={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Yd(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Xd({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=jd,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=Yd(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${qd[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Gd,{icon:e.icon}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700 sm:hidden`,children:d}),(0,I.jsx)(`span`,{className:`hidden truncate text-xs font-semibold text-gray-700 sm:inline`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:Jd[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 Zd({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=jd;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Wd,{picker:r}):null,n.map(e=>(0,I.jsx)(Xd,{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)(Kd,{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)(Hd,{...e})]})}var Qd=(0,F.createContext)(null);function $d(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function ef(){let e=(0,F.useContext)(Qd);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 tf(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 nf=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,rf=nf&&`documentMode`in document?document.documentMode:null,af=nf&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),of=nf&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),sf=!(!nf||!(`InputEvent`in window)||rf)&&`getTargetRanges`in new window.InputEvent(`input`),cf=nf&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,lf=nf&&/Android/.test(navigator.userAgent),uf=nf&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!lf,df=nf&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ff=nf&&lf&&df,pf=nf&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&af&&!df,mf=0,hf=1,gf=2,_f=1,vf=2,yf=3,bf=4,xf=5,Sf=6,Cf=uf||cf||pf?`\xA0`:``,wf=`
|
|
6
6
|
|
|
7
7
|
`,Tf=of?`\xA0`:Cf,Ef={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Df={directionless:1,unmergeable:2},Of={center:2,end:6,justify:4,left:1,right:3,start:5},kf={[vf]:`center`,[Sf]:`end`,[bf]:`justify`,[_f]:`left`,[yf]:`right`,[xf]:`start`},Af={normal:0,segmented:2,token:1},jf={[mf]:`normal`,[gf]:`segmented`,[hf]:`token`},Mf=`$config`;function Nf(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(U(o)&&Nf(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var Pf=!1,Ff=0;function If(e){Ff=e.timeStamp}function Lf(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&P_(e,n)!==void 0}function Rf(e,t,n){let r=Cv(hv(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&q_(t,o,i,a,!1)}function zf(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return C_(t)&&n.isAttached()}function Bf(e,t,n,r){for(let i=e;i&&!Rv(i);i=lv(i)){let e=P_(i,t);if(e!==void 0){let t=M_(e,n);if(t)return Wg(t)||!Tv(i)?void 0:[i,t]}else if(i===r)return[r,z_(n)]}}function Vf(e,t,n){Pf=!0;let r=performance.now()-Ff>100;try{Rg(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=Bf(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&B(g)&&C_(p)&&zf(i,p,g)&&Rf(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=N_(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!Lf(r,a,e)){if(of){let e=(Tv(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];(Lf(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`||Lf(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&B_(i),of&&sv(e)&&i.insertRawText(u))})}finally{Pf=!1}}function Hf(e){let t=e._observer;t!==null&&Vf(e,t.takeRecords(),t)}function Uf(e){(function(e){Ff===0&&hv(e).addEventListener(`textInput`,If,!0)})(e),e._observer=new MutationObserver((t,n)=>{Vf(e,t,n)})}var Wf=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Zf).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Gf(e,t){return new Wf(e,t)}function Kf(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}=Bv(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 qf=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 Xf(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=Xf(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 Jf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new qf(t,Yf(t));return t.__state=n,n}function Yf(e){return e.__state?e.__state.sharedNodeState:f_(jv(),e.getType()).sharedNodeState}function Xf(e){if(e)for(let t in e)return e}function Zf(e){return e}function Qf(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 $f(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 ep(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function tp(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&&Qf(n,e,t)||t&&Qf(n,t,e)||e&&$f(n,e,t)||t&&$f(n,t,e))}(c,l))}function np(e,t){let n=e.mergeWithSibling(t),r=Tg()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function rp(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(tp(t,r)){r=np(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(tp(r,n)){r=np(r,n);break}break}n.remove()}}else r.remove()}function ip(e){return ap(e.anchor),ap(e.focus),e}function ap(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 op,sp,cp,lp,up,dp,fp,pp,mp,hp,gp=``,_p=null,vp=null,yp=!1,bp=!1;function xp(e,t){let n=fp.get(e);if(t!==null){let n=zp(e);n.parentNode===t&&t.removeChild(n)}if(pp.has(e)||sp._keyToDOMMap.delete(e),U(n)){let e=Np(n,fp);Sp(e,0,e.length-1,null)}n!==void 0&&iv(hp,cp,lp,n,`destroyed`)}function Sp(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&xp(t,r)}}function Cp(e,t){e.setProperty(`text-align`,t)}var wp=`40px`;function Tp(e,t){let n=op.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(sp._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||wp;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function Ep(e,t){let n=e.style;t===0?Cp(n,``):t===1?Cp(n,`left`):t===2?Cp(n,`center`):t===3?Cp(n,`right`):t===4?Cp(n,`justify`):t===5?Cp(n,`start`):t===6&&Cp(n,`end`)}function Dp(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Kg(e))return null;let n=e.getParentOrThrow();return Kg(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Op(e,t){let n=pp.get(e);n===void 0&&R(60);let r=n.createDOM(op,sp);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,sp),B(n)?r.setAttribute(`data-lexical-text`,`true`):Wg(n)&&r.setAttribute(`data-lexical-decorator`,`true`),U(n)){let e=n.__indent,t=n.__size;if(Dp(r,n),e!==0&&Tp(r,e),t!==0){let e=t-1;kp(Np(n,pp),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&Ep(r,i),n.isInline()||jp(null,n,r)}else{let t=n.getTextContent();if(Wg(n)){let t=n.decorate(sp,op);t!==null&&Fp(e,t),r.contentEditable=`false`}gp+=t}return t!==null&&t.insertChild(r),iv(hp,cp,lp,n,`created`),r}function kp(e,t,n,r,i){let a=gp;gp=``;let o=n;for(;o<=r;++o){Op(e[o],i);let t=pp.get(e[o]);t!==null&&B(t)?_p===null&&(_p=t.getFormat(),vp=t.getStyle()):U(t)&&o<r&&!t.isInline()&&(gp+=wf)}i.element.__lexicalTextContent=gp,gp=a+gp}function Ap(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return gh(e)?`line-break`:Wg(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function jp(e,t,n){let r=Ap(e,fp),i=Ap(t,pp);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Mp(e,t,n){var r;_p=null,vp=null,function(e,t,n){let r=gp,i=e.__size,a=t.__size;gp=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)Pp(n,o);else{let e=zp(n),t=Op(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}xp(n,null)}let i=pp.get(r);B(i)&&_p===null&&(_p=i.getFormat(),vp=i.getStyle())}else{let r=Np(e,fp),s=Np(t,pp);if(r.length!==i&&R(227),s.length!==a&&R(228),i===0)a!==0&&kp(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;Sp(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=Ip(Pp(r,a.element)),d++,f++;else{if(l===void 0&&(l=Lp(n,f)),c===void 0)c=Lp(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=Ip(zp(e)),xp(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=cv(sp,r);e!==u&&a.withBefore(u).insertChild(e),u=Ip(Pp(r,a.element)),d++,f++}else Op(r,a.withBefore(u)),f++}let i=pp.get(r);i!==null&&B(i)?_p===null&&(_p=i.getFormat(),vp=i.getStyle()):U(i)&&f<=s&&!i.isInline()&&(gp+=wf)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:sp.getElementByKey(e);kp(n,0,f,s,a.withBefore(t))}else m&&!p&&Sp(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=gp,gp=r+gp}(e,t,t.getDOMSlot(n)),r=t,_p==null||_p===r.__textFormat||bp||r.setTextFormat(_p),function(e){vp==null||vp===e.__textStyle||bp||e.setTextStyle(vp)}(t)}function Np(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 Pp(e,t){let n=fp.get(e),r=pp.get(e);n!==void 0&&r!==void 0||R(61);let i=yp||dp.has(e)||up.has(e),a=cv(sp,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 gp+=e,a}if(n!==r&&i&&iv(hp,cp,lp,r,`updated`),r.updateDOM(n,a,op)){let n=Op(e,null);return t===null&&R(62),t.replaceChild(n,a),xp(e,null),n}if(U(n)){U(r)||R(334,e);let t=r.__indent;(yp||t!==n.__indent)&&Tp(a,t);let o=r.__format;if((yp||o!==n.__format)&&Ep(a,o),i)Mp(n,r,a),Kg(r)||r.isInline()||jp(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),gp+=t}if((yp||r.__dir!==n.__dir)&&(Dp(a,r),Kg(r)&&!yp))for(let e of r.getChildren())U(e)&&Dp(cv(sp,e.getKey()),e)}else{let t=r.getTextContent();if(Wg(r)){let t=r.decorate(sp,op);t!==null&&Fp(e,t)}gp+=t}if(!bp&&Kg(r)&&r.__cachedText!==gp){let e=r.getWritable();e.__cachedText=gp,r=e}return a}function Fp(e,t){let n=sp._pendingDecorators,r=sp._decorators;if(n===null){if(r[e]===t)return;n=I_(sp)}n[e]=t}function Ip(e){let t=e.nextSibling;return t!==null&&t===sp._blockCursorElement&&(t=t.nextSibling),t}function Lp(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Rp(e,t,n,r,i,a){gp=``,yp=r===2,sp=n,op=n._config,cp=n._nodes,lp=sp._listeners.mutation,up=i,dp=a,fp=e._nodeMap,pp=t._nodeMap,bp=t._readOnly,mp=new Map(n._keyToDOMMap);let o=new Map;return hp=o,Pp(`root`,null),sp=void 0,cp=void 0,up=void 0,dp=void 0,fp=void 0,pp=void 0,op=void 0,mp=void 0,hp=void 0,o}function zp(e){let t=mp.get(e);return t===void 0&&R(75,e),t}function z(e){return{type:e}}var Bp=z(`SELECTION_CHANGE_COMMAND`),Vp=z(`CLICK_COMMAND`),Hp=z(`BEFORE_INPUT_COMMAND`),Up=z(`INPUT_COMMAND`),Wp=z(`COMPOSITION_START_COMMAND`),Gp=z(`COMPOSITION_END_COMMAND`),Kp=z(`DELETE_CHARACTER_COMMAND`),qp=z(`INSERT_LINE_BREAK_COMMAND`),Jp=z(`INSERT_PARAGRAPH_COMMAND`),Yp=z(`CONTROLLED_TEXT_INSERTION_COMMAND`),Xp=z(`PASTE_COMMAND`),Zp=z(`REMOVE_TEXT_COMMAND`),Qp=z(`DELETE_WORD_COMMAND`),$p=z(`DELETE_LINE_COMMAND`),em=z(`FORMAT_TEXT_COMMAND`),tm=z(`UNDO_COMMAND`),nm=z(`REDO_COMMAND`),rm=z(`KEYDOWN_COMMAND`),im=z(`KEY_ARROW_RIGHT_COMMAND`),am=z(`MOVE_TO_END`),om=z(`KEY_ARROW_LEFT_COMMAND`),sm=z(`MOVE_TO_START`),cm=z(`KEY_ARROW_UP_COMMAND`),lm=z(`KEY_ARROW_DOWN_COMMAND`),um=z(`KEY_ENTER_COMMAND`),dm=z(`KEY_SPACE_COMMAND`),fm=z(`KEY_BACKSPACE_COMMAND`),pm=z(`KEY_ESCAPE_COMMAND`),mm=z(`KEY_DELETE_COMMAND`),hm=z(`KEY_TAB_COMMAND`),gm=z(`DROP_COMMAND`),_m=z(`DRAGSTART_COMMAND`),vm=z(`DRAGOVER_COMMAND`),ym=z(`DRAGEND_COMMAND`),bm=z(`COPY_COMMAND`),xm=z(`CUT_COMMAND`),Sm=z(`SELECT_ALL_COMMAND`),Cm=z(`FOCUS_COMMAND`),wm=z(`BLUR_COMMAND`),Tm=z(`KEY_MODIFIER_COMMAND`),Em=Object.freeze({}),Dm=[[`keydown`,function(e,t){Om=e.timeStamp,km=e.key,!t.isComposing()&&W(t,rm,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;Ev(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Rg(t,()=>{h_(n)||(Fm=!0)})}],[`compositionstart`,function(e,t){W(t,Wp,e)}],[`compositionend`,function(e,t){of?Lm=!0:cf||!uf&&!pf?W(t,Gp,e):(Rm=!0,zm=e.data)}],[`input`,function(e,t){e.stopPropagation(),Rg(t,()=>{t.dispatchCommand(Up,e)},{event:e}),jm=null}],[`click`,function(e,t){Rg(t,()=>{let n=H(),r=Cv(hv(t)),i=ig();if(r){if(V(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Kg(a)&&R_().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=Hv(a,e=>U(e)&&!e.isInline());U(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(Tv(n)||C_(n))&&B_(rg(i,r,t,e))}}W(t,Vp,e)})}],[`cut`,Em],[`copy`,Em],[`dragstart`,Em],[`dragover`,Em],[`dragend`,Em],[`paste`,Em],[`focus`,Em],[`blur`,Em],[`drop`,Em]];sf&&Dm.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||of&&sv(t)||n!==`insertCompositionText`&&W(t,Hp,e)}(e,t)]);var Om=0,km=null,Am=0,jm=null,Mm=new WeakMap,Nm=new WeakMap,Pm=!1,Fm=!1,Im=!1,Lm=!1,Rm=!1,zm=``,Bm=null,Vm=[0,``,0,`root`,0];function Hm(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=Tg(),l=Cv(hv(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!B(s)||(!i&&(!sf||Am<r+50)||s.isDirty()&&p<2||H_(n))&&a.offset!==o.offset&&!s.isComposing()||S_(s)||s.isDirty()&&p>1||(i||!sf)&&f!==null&&!s.isComposing()&&u!==T_(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=x_(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 Um(e,t){return C_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Wm(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;Pm&&(Pm=!1,Um(r,i)&&Um(a,o)&&!Bm)||Rg(t,()=>{if(!n)return void B_(null);if(!__(t,r,a))return;let s=H();if(Bm&&V(s)&&s.isCollapsed()){let e=s.anchor,t=Bm.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=Bm.clone(),B_(s))}if(Bm=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=hv(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=Vm,f=R_(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Gm(s,o,c);else if(n.type===`text`)B(r)||R(141),Km(s,r);else if(n.type===`element`&&!p){U(r)||R(259);let e=n.getNode();e.isEmpty()?function(e,t){Gm(e,t.getTextFormat(),t.getTextStyle())}(s,e):Gm(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,Bp,void 0)})}function Gm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Km(e,t){Gm(e,t.getFormat(),t.getStyle())}function qm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Jm(e){let t=e.inputType,n=qm(e),r=Tg(),i=H();if(t===`deleteContentBackward`){if(i===null){let e=ig();if(!V(e))return!0;B_(e.clone())}if(V(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,km===`MediaLast`&&a<Om+30&&r.isComposing()&&t){if(A_(null),Om=0,setTimeout(()=>{Rg(r,()=>{A_(null)})},30),V(i)){let e=i.anchor.getNode();e.markDirty(),B(e)||R(142),Km(i,e)}}else{A_(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=ff&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!Wg(ov(i.anchor,!0))),!c){W(r,Kp,!0);let e=H();ff&&V(e)&&e.isCollapsed()&&(Bm=e,setTimeout(()=>Bm=null))}}return!0}}var a;if(!V(i))return!0;let o=e.data;jm!==null&&K_(!1,r,jm),i.dirty&&jm===null||!i.isCollapsed()||Kg(i.anchor.getNode())||n===null||i.applyDOMRange(n),jm=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
|
|
8
8
|
`)e.preventDefault(),W(r,qp,!1);else if(o===wf)e.preventDefault(),W(r,Jp,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&Hm(i,n,o,e.timeStamp,!0)?(e.preventDefault(),W(r,Yp,o)):jm=o;return Am=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:W(r,Yp,e);break;case`insertFromComposition`:A_(null),W(r,Yp,e);break;case`insertLineBreak`:A_(null),W(r,qp,!1);break;case`insertParagraph`:A_(null),Im&&!cf?(Im=!1,W(r,qp,!1)):W(r,Jp,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:W(r,Xp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!x_(e)||!x_(t)})(l,u)&&W(r,Zp,e);break;case`deleteByDrag`:case`deleteByCut`:W(r,Zp,e);break;case`deleteContent`:W(r,Kp,!1);break;case`deleteWordBackward`:W(r,Qp,!0);break;case`deleteWordForward`:W(r,Qp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:W(r,$p,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:W(r,$p,!1);break;case`formatStrikeThrough`:W(r,em,`strikethrough`);break;case`formatBold`:W(r,em,`bold`);break;case`formatItalic`:W(r,em,`italic`);break;case`formatUnderline`:W(r,em,`underline`);break;case`historyUndo`:W(r,tm,void 0);break;case`historyRedo`:W(r,nm,void 0)}return!0}function Ym(e){if(Tv(e.target)&&h_(e.target))return!0;let t=Tg(),n=H(),r=e.data,i=qm(e);if(r!=null&&V(n)&&Hm(n,i,r,e.timeStamp,!1)){Lm&&=(Qm(t,r),!1);let i=n.anchor.getNode(),a=Cv(hv(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;sf&&!n.isCollapsed()&&B(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===G_(a.anchorNode)||W(t,Yp,r);let l=r.length;of&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),ff&&t.isComposing()&&(Om=0,A_(null))}else K_(!1,t,r===null?void 0:r),Lm&&=(Qm(t,r||void 0),!1);return function(){Sg(),Hf(Tg())}(),!0}function Xm(e){let t=Tg(),n=H();if(V(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();A_(r.key),dv(dh),(e.timeStamp<Om+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||B(i)&&i.getStyle()!==n.style)&&W(t,Yp,Tf)}return!0}function Zm(e){return Qm(Tg(),e.data),dv(fh),!0}function Qm(e,t){let n=e._compositionKey;if(A_(null),n!==null&&t!=null){if(t===``){let t=M_(n),r=T_(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&B(t)){let n=Cv(hv(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),q_(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
|
|
@@ -100,4 +100,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
100
100
|
|
|
101
101
|
`):void 0}function rz(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=YR(o);if(s){let e=JR(s.status)?.toLowerCase(),t=$R(s,a),o=tz(s),c=JR(s.sessionId),l=XL({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...JR(s.title)?{label:s.title.trim()}:{},...JR(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:QR(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:QR(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:QR(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=XR(o);if(!c)return null;let l=ez(c,a),u=nz(c),d=JR(c.sessionId),f=XL({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...JR(c.title)?{label:c.title.trim()}:{},...JR(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:QR(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function iz(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 az(e,t){let n=IL(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function oz(e,t){let n=e.mimeType.startsWith(`image/`),r=zL(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 sz(e,t){let n=e.toolInvocation,r=VL(n.result,t);if(r)return r;let i=rz({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:HL(i,t)};let a=UL({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=iz(n.result),s=Array.isArray(o?.issues)?o.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,c=KR({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??SL(n.parsedArgs??n.args),u=c?void 0:GL(n.args,n.parsedArgs),d=s||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:bL(n.result).trim()),f=!n.error&&BL(n.result),p=(!c?.fileOperation||!!n.error)&&!f,m=XL(n);return{type:`tool-card`,card:HL({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 cz(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:bL(e)}}function lz(e){return e.type===`text`&&typeof e.text==`string`}function uz(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function dz(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function fz(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 pz(e){let{inlineTokens:t,part:n,texts:r}=e;return lz(n)?FL(n,t):uz(n)?az(n,r):dz(n)?oz(n,r):fz(n)?sz(n,r):cz(n,r)}function mz(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function hz(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function gz(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function _z(e,t){return{id:e.id,role:gz(e.role),roleLabel:hz(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(mz(e)),status:e.meta?.status,parts:e.parts.map(n=>pz({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var vz=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function yz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function bz(e){return yz(e)}function xz(e){let t=yz(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 Sz(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function Cz(e){let t=Sz(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function wz(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 Tz(e){let t=Cz(e.path),n=Cz(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 Ez(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 Dz(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function Oz(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?Tz({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=xz(i)??i.trim();c=Ez({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=wz(o);c=Ez({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:Dz({line:n,column:t}),truncated:a,segments:c}}var kz=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),Az=new Set([`running`,`completed`,`failed`,`idle`]);function jz(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function Mz(e){return`${ce}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function Nz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Pz(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function Fz(e){let t=Pz(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=Nz(n.timestamp);if(!Az.has(r)||!i)return null;let a=Nz(n.statusText),o=Nz(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function Iz(e){let t=Pz(e);return t?Nz(t.preferred_model)??Nz(t.preferredModel)??Nz(t.model):null}function Lz(e){let t=Pz(e);if(!t)return null;let n=Nz(t.preferred_thinking)??Nz(t.thinking)??Nz(t.thinking_level)??Nz(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return kz.has(r)?r:null}function Rz(e){let t=Pz(e);return t?Nz(t.label):null}function zz(e){let t=Pz(e);return t?bz(t.project_root??t.projectRoot):null}function Bz(e){let t=Pz(e);return t?Nz(t.ui_last_read_at):null}function Vz(e){let t=Pz(e);return t?Nz(t.runtime)??Nz(t.session_type)??Nz(t.sessionType)??`native`:`native`}function Hz(e){let t=Pz(e);return t?Nz(t.parent_session_id)??Nz(t.parentSessionId):null}function Uz(e){let t=Pz(e);return t?Nz(t.spawned_by_request_id)??Nz(t.spawnedByRequestId):null}function Wz(e){let t=Pz(e);return t?t.child_session_promoted===!0:!1}function Gz(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 Kz(e){return e.state===`cancelled`?vz.CANCELLED:e.state===`result`?vz.RESULT:e.state===`partial-call`?vz.PARTIAL_CALL:vz.CALL}function qz(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:Mz(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:Kz(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:jz(n.args),result:n.result}})}return t}function Jz(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function Yz(e){return{id:e.id,role:Jz(e.role),parts:qz(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function Xz(e){let t=Rz(e),n=Iz(e),r=Lz(e),i=zz(e),a=Bz(e),o=Nz(e.lastMessageAt),s=xz(i),c=Gz(e.sessionId),l=Hz(e),u=Uz(e),d=Wz(e),f=Fz(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:Vz(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 Zz(e){return e.map(Xz)}function Qz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function $z(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function eB(e){return e===!0}function tB(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=$z(n.usedContextTokens),i=$z(n.totalContextTokens),a=$z(n.prunedUsedContextTokens),o=Qz(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=$z(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:$z(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:$z(n.droppedHistoryCount)??0,truncatedToolResultCount:$z(n.truncatedToolResultCount)??0,truncatedSystemPrompt:eB(n.truncatedSystemPrompt),truncatedUserMessage:eB(n.truncatedUserMessage),compacted:eB(n.compacted),...Qz(n.checkpointId)?{checkpointId:Qz(n.checkpointId)??void 0}:{},compactedMessageCount:$z(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function nB(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=Qz(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=Qz(n.summary),o=$z(n.coveredMessageCount),s=$z(n.coveredSessionMessageCount),c=$z(n.originalEstimatedTokens),l=$z(n.projectedEstimatedTokens),u=Qz(n.createdAt),d=Qz(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 rB(){return it({queryKey:[`agents`],queryFn:je,staleTime:3e4})}function iB(){let e=me();return se({mutationFn:({agentId:e,data:t})=>xe(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function aB(){let e=me();return se({mutationFn:({agentId:e})=>Ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),k.success(f(`configSavedApplied`))},onError:e=>{k.error(f(`configSaveFailed`)+`: `+e.message)}})}function oB(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function sB(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=rB(),i=(0,F.useMemo)(()=>oB(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 cB({agentId:e,className:t}){let n=sB(e);return n?(0,I.jsx)(ou,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var lB=new WeakMap;function uB(e){return{roleLabels:{user:f(`chatRoleUser`),assistant:f(`chatRoleAssistant`),tool:f(`chatRoleTool`),system:f(`chatRoleSystem`),fallback:f(`chatRoleMessage`)},reasoningLabel:f(`chatReasoning`),toolCallLabel:f(`chatToolCall`),toolResultLabel:f(`chatToolResult`),toolInputLabel:f(`chatToolInput`),toolNoOutputLabel:f(`chatToolNoOutput`),toolOutputLabel:f(`chatToolOutput`),toolStatusPreparingLabel:f(`chatToolStatusPreparing`),toolStatusRunningLabel:f(`chatToolStatusRunning`),toolStatusCompletedLabel:f(`chatToolStatusCompleted`),toolStatusFailedLabel:f(`chatToolStatusFailed`),toolStatusCancelledLabel:f(`chatToolStatusCancelled`),imageAttachmentLabel:f(`chatImageAttachment`),fileAttachmentLabel:f(`chatFileAttachment`),unknownPartLabel:f(`chatUnknownPart`)}}function dB(e){return{copyCodeLabel:f(`chatCodeCopy`),copiedCodeLabel:f(`chatCodeCopied`),copyMessageLabel:f(`chatMessageCopy`),copiedMessageLabel:f(`chatMessageCopied`),typingLabel:f(`chatTyping`),attachmentOpenLabel:f(`chatAttachmentOpen`),attachmentAttachedLabel:f(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:f(`chatAttachmentCategoryArchive`),audio:f(`chatAttachmentCategoryAudio`),code:f(`chatAttachmentCategoryCode`),data:f(`chatAttachmentCategoryData`),document:f(`chatAttachmentCategoryDocument`),generic:f(`chatAttachmentCategoryGeneric`),image:f(`chatAttachmentCategoryImage`),pdf:f(`chatAttachmentCategoryPdf`),sheet:f(`chatAttachmentCategorySheet`),video:f(`chatAttachmentCategoryVideo`)}}}function fB({checkpoint:e}){return(0,I.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-gray-500`,title:[`${f(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${f(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${f(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
|
|
102
102
|
`),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`?f(`chatContextCompactionCompressing`):f(`chatContextCompactionCompressed`)})]}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`})]})}function pB(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=>!nB(e)).length-1}function mB(e){let t=e.rawMessages.filter(e=>!nB(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:nB(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:pB({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 hB({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=is(),o=(0,F.useMemo)(()=>uB(a),[a]),s=(0,F.useMemo)(()=>e.flatMap(e=>{if(nB(e))return[];let t=lB.get(e);if(t&&t.language===a)return[t.viewModel];let n=Yz(e),r=_z({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:kL(e.metadata)},parts:n.parts},{formatTimestamp:e=>m(e,a),texts:o});return lB.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)(()=>dB(a),[a]),u=(0,F.useMemo)(()=>mB({rawMessages:e,messages:s}),[s,e]);return(0,I.jsx)(`div`,{className:n,children:u.map((e,n)=>e.kind===`compaction`?(0,I.jsx)(fB,{checkpoint:e.checkpoint},e.key):(0,I.jsx)(DF,{messages:e.messages,isSending:n===u.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,I.jsx)(cB,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function gB(){let e=me();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{He(e,await Qe(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),k.success(i??f(`configSavedApplied`))}catch(e){throw k.error(f(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function _B(){let e=gB();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=f(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),k.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function vB({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,I.jsxs)(`button`,{type:`button`,className:h(`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`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:t})]})}function yB(e){return it({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>Ye({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var bB=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsx)(`div`,{ref:r,className:h(`overflow-auto`,e),...n,children:t}));bB.displayName=`ScrollArea`;function xB({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:s,pathPlaceholder:c,confirmLabel:l,hint:u}){let[d,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=yB({path:m,enabled:e});(0,F.useEffect)(()=>{!e||!v.data||d.trim().length===0&&p(v.data.currentPath)},[v.data,d,e]);let y=d.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)(St,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(wt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(Ct,{children:[(0,I.jsx)(Tt,{children:a}),o?(0,I.jsx)(xt,{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)(Me,{htmlFor:`server-path-picker-input`,children:s}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(j,{id:`server-path-picker-input`,value:d,onChange:e=>p(e.target.value),placeholder:c,autoFocus:!0,disabled:n}),(0,I.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>w(y||null),disabled:n,children:f(`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)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,I.jsx)(Ya,{className:`mr-1 h-4 w-4`}),f(`homeDirectory`)]}),(0,I.jsxs)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,I.jsx)(Wa,{className:`mr-1 h-4 w-4`}),f(`parentDirectory`)]}),(0,I.jsxs)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,I.jsx)(co,{className:`mr-1 h-4 w-4`}),f(`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:f(`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)(Ta,{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)(Ot,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:g,onChange:e=>_(e.target.value),placeholder:f(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,I.jsx)(bB,{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:f(`loading`)}):x?(0,I.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[f(`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)(Ka,{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:f(`pathPickerSearchEmpty`)}):(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:f(`emptyDirectory`)})})]}),u?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:u}):null,(0,I.jsxs)(bt,{children:[(0,I.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:f(`cancel`)}),(0,I.jsx)(N,{type:`submit`,disabled:b,children:n?f(`saving`):l})]})]})]})})}function SB({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(xB,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:f(`chatSessionProjectDialogTitle`),description:f(`chatSessionProjectDialogDescription`),pathLabel:f(`chatSessionProjectPathLabel`),pathPlaceholder:f(`chatSessionProjectPathPlaceholder`),confirmLabel:f(`chatSessionSetProject`),hint:f(`chatSessionProjectUpdateHint`)})}var CB=`flex shrink-0 items-center gap-1.5`,wB=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function TB({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:s,onDeleteSession:c}){let l=_B(),[u,d]=(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 l({sessionKey:e,projectRoot:n,persistToServer:r}),m(!1),d(!1)}finally{g(!1)}};return(0,I.jsxs)(`div`,{className:CB,children:[i>0&&o?(0,I.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,className:wB,"aria-label":f(`chatSessionOpenChildSessions`),title:f(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,I.jsx)(qa,{className:`h-4 w-4`})}):null,a>0&&s?(0,I.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,className:wB,"aria-label":f(`chatSessionOpenCronJobs`),title:f(`chatSessionOpenCronJobs`),onClick:s,disabled:_,children:(0,I.jsx)(va,{className:`h-4 w-4`})}):null,(0,I.jsxs)(Nc,{open:u,onOpenChange:d,children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{variant:`ghost`,size:`icon`,className:wB,"aria-label":f(`chatSessionMoreActions`),disabled:_,children:(0,I.jsx)(ja,{className:`h-4 w-4`})})}),(0,I.jsx)(Fc,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(vB,{icon:Ha,label:f(`chatSessionSetProject`),onClick:()=>{d(!1),m(!0)},disabled:_}),(0,I.jsx)(vB,{icon:yo,label:f(`chatDeleteSession`),onClick:()=>{d(!1),c()},disabled:!t||_,destructive:!0})]})})]}),(0,I.jsx)(SB,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function EB({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=_B(),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=async t=>{u(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),c(!1),o(!1)}finally{u(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Nc,{open:a,onOpenChange:o,children:[(0,I.jsx)(Pc,{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":f(`chatSessionSetProject`),disabled:l,children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(Ha,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(Pt,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(Fc,{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)(vB,{icon:oo,label:f(`chatSessionSetProject`),onClick:()=>{o(!1),c(!0)},disabled:l}),(0,I.jsx)(vB,{icon:Ga,label:f(`chatSessionClearProject`),onClick:()=>{d(null)},disabled:l})]})]})]}),(0,I.jsx)(SB,{open:s,currentProjectRoot:n,isSaving:l,onOpenChange:c,onSave:d})]})}function DB({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)(Dt,{className:`h-3.5 w-3.5`}),(0,I.jsxs)(`span`,{children:[f(`chatBackToParent`),n?` · ${n}`:``]})]})})}function OB({snapshot:e,childSessionCount:t,sessionCronJobCount:n,layoutMode:r,normalizedAgentId:i,sessionHeaderTitle:a,shouldShowHeaderAgentAvatar:o,shouldShowSessionHeader:s,onBackToList:c,onOpenChildSessions:l,onOpenSessionCronJobs:u,onDeleteSession:d}){let p=r===`mobile`;return(0,I.jsxs)(`div`,{className:h(`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`,p?`px-3 sm:px-3`:`px-4 sm:px-5`,s?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,s&&(p?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:p&&s?{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:[p&&c?(0,I.jsx)(`button`,{type:`button`,onClick:c,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":f(`chat`),children:(0,I.jsx)(Dt,{className:`h-4 w-4`})}):null,o?(0,I.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(ou,{agentId:i,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:a}),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)($l,{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)(EB,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,I.jsx)(TB,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:l,onOpenSessionCronJobs:u,onDeleteSession:d}):null]})}var kB=`native`;function AB(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:kB}function jB(e,t=kB){return AB(e?.runtime?.trim()||e?.engine?.trim()||t)}function MB(e,t){return e===`native`?f(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function NB(e){let t=new Map;for(let n of e){let e=AB(n.value);t.set(e,{value:e,label:n.label?.trim()||MB(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(kB,{value:kB,label:MB(kB),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 PB(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,F.useMemo)(()=>NB(i?.options??[]),[i?.options]),o=(0,F.useMemo)(()=>{let e=[...a],n=AB(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:MB(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]),s=(0,F.useMemo)(()=>AB(i?.defaultType??`native`),[i?.defaultType]),c=(0,F.useRef)(null),l=(0,F.useMemo)(()=>AB(t?.sessionType??n??s),[s,n,t?.sessionType]),u=(0,F.useMemo)(()=>o.find(e=>e.value===l)??null,[l,o]);(0,F.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=AB(n);(e.length===0||c.current===i||c.current===null&&i===`native`)&&(c.current=s,i!==s&&r(s))},[s,n,t,r]);let d=!t||!!t.sessionTypeMutable,p=(0,F.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:o,selectedSessionTypeOption:u,defaultSessionType:s,selectedSessionType:l,canEditSessionType:d,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!p.has(AB(t.sessionType))?!0:u?.ready===!1,[p,t,u?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!p.has(AB(t.sessionType))?`${MB(l)} ${f(`chatSessionTypeUnavailableSuffix`)}`:u?.ready===!1?u.reasonMessage?.trim()||`${u.label} setup required`:null,[p,t,l,u])}}function FB(e,t){return e.label?.trim()?e.label.trim():t?cu(t):e.sessionKey}function IB(e){let t=Xs({limit:200}),n=(0,F.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,F.useMemo)(()=>{let e=Zz(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:FB(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?MB(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function LB(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(`
|
|
103
|
-
`)}}async function*RB(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}=zB(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=zB(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function zB(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=LB(e);t&&i.push(t)}if(t&&r.trim()){let e=LB(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var BB=`/ncp/agent`,VB=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function HB(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function UB(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 WB(e){let t=(e??`/ncp/agent`).trim();if(!t)return BB;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function GB(e){try{return(await e.text()).trim()}catch{return``}}function KB(e){if(XB(e))return e.ncpError;if(JB(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:QB(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function qB(e,t={}){return new VB(e,t.alreadyPublished??!1)}function JB(e){return YB(e)&&typeof e.code==`string`&&typeof e.message==`string`}function YB(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function XB(e){return e instanceof VB}var ZB={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function QB(e){if(!e)return`runtime-error`;let t=ZB[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 $B(e){let t=tV(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function eV(e){let t=tV(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=QB(n),i=YB(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 tV(e){try{let t=JSON.parse(e);return YB(t)?t:null}catch{return null}}var nV=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],rV=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=HB(e.baseUrl),this.basePath=WB(e.basePath),this.fetchImpl=UB(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:nV,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:OF.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 GB(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(XB(e))throw e;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(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 GB(n)}`)}catch(e){if(t.signal.aborted)return;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(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 GB(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of RB(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(XB(e))throw e;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=$B(e.data);if(!t){this.publish({type:OF.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=eV(e.data);throw this.publish({type:OF.EndpointError,payload:t}),qB(t,{alreadyPublished:!0})}}};function iV(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function aV(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 oV(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function sV(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw nt.reportTransportFailure(aV(n)),oV(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${iV(e)}: ${aV(n)}`,n)}}}var cV=300,lV=`ncp agent unavailable during startup`;function uV(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function dV(e){return e?.trim().toLowerCase().includes(lV)??!1}function fV(){return new rV({baseUrl:ce,basePath:`/api/ncp/agent`,fetchImpl:sV()})}async function pV(e,t,n=cV){t.throwIfAborted();try{let r=await ke(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!uV(e))throw e;return{messages:[],status:`idle`}}}function mV(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 hV(e,t={}){let[n]=(0,F.useState)(()=>fV()),r=ye(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??cV;(0,F.useEffect)(()=>{s(null)},[e]);let l=oI({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await pV(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 mV(e&&r.phase===`ready`&&dV(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}var gV=Sd,_V=Cd,vV=wd,yV=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Td,{children:(0,I.jsx)(Ed,{ref:r,sideOffset:t,className:h(`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})}));yV.displayName=Ed.displayName;function bV(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function xV(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 SV({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(va,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Pa,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(cB,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function CV({tab:e}){return(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsxs)(`div`,{className:h(`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)(SV,{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:f(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":f(`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:h(`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":f(`chatWorkspaceCloseFile`),children:(0,I.jsx)(ln,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(yV,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function wV({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)(CV,{tab:e},e.key))})})}function TV({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:h(`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 EV({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:h(`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)(Ua,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Pa,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Ta,{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)(TV,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(TV,{tone:`warning`,value:f(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function DV(e){let t=e.path?.trim()??``;return it({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>Re({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function OV(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function kV(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:rR({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function AV(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=sR({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 jV({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:h(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function MV({diffBlock:e}){return e?(0,I.jsx)(NV,{block:e}):(0,I.jsx)(jV,{text:f(`chatWorkspaceDiffEmpty`)})}function NV({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(HP,{block:e,layout:`workspace`})})}function PV({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(jV,{text:f(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(jV,{text:f(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(jV,{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)(MN,{text:i,role:`assistant`,texts:{copyCodeLabel:f(`chatCodeCopy`),copiedCodeLabel:f(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(NV,{block:t}):(0,I.jsx)(jV,{text:f(`chatWorkspacePreviewEmpty`)})}function FV({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=DV({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?AV(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=OV({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:kV({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)(EV,{breadcrumb:(0,F.useMemo)(()=>Oz({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)(MV,{diffBlock:a}):(0,I.jsx)(PV,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var IV=({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=f(`confirm`),cancelLabel:a=f(`cancel`),variant:o=`default`,onConfirm:s,onCancel:c})=>(0,I.jsx)(St,{open:e,onOpenChange:t,children:(0,I.jsxs)(wt,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(Ct,{children:[(0,I.jsx)(Tt,{children:n}),r?(0,I.jsx)(xt,{children:r}):null]}),(0,I.jsxs)(bt,{className:`gap-2 sm:gap-0`,children:[(0,I.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>{c(),t(!1)},children:a}),(0,I.jsx)(N,{type:`button`,variant:o===`destructive`?`destructive`:`default`,onClick:()=>{s(),t(!1)},children:i})]})]})}),LV={open:!1,title:``,description:``,confirmLabel:f(`confirm`),cancelLabel:f(`cancel`),variant:`default`,resolve:null};function RV(){let[e,t]=(0,F.useState)(LV),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??f(`confirm`),cancelLabel:e.cancelLabel??f(`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)(IV,{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 zV(e){return m(e??void 0)}function BV(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:m(new Date(e))}function VV(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 HV(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${VV(t.everyMs)}`:t.kind===`at`?`at ${BV(t.atMs)}`:`-`}function UV(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function WV(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function GV(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function KV({jobs:e}){let t=$s(),{confirm:n,ConfirmDialog:r}=RV(),i=async e=>{await n({title:`${f(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:f(`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:f(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[f(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:f(`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)(N,{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)(yo,{className:`h-3.5 w-3.5`}),f(`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:[f(`cronScheduleLabel`),`:`]}),` `,HV(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronNextRun`),`:`]}),` `,zV(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronLastRun`),`:`]}),` `,zV(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronDeliverTo`),`:`]}),` `,UV(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 qV({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=hV(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=_P({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)(Qa,{className:`mr-2 h-4 w-4 animate-spin`}),f(`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:f(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(hB,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function JV({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 YV({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)(JV,{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 XV({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)(cB,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(Va,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(YV,{tab:e})]})}function ZV(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:s,onCloseFile:c,onSelectCronJobs:l}=e,u=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:YI({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),d=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:bV(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>s(e.key),onClose:()=>c(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:f(`chatWorkspaceSessionCronJobs`),tooltip:f(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:l}]:[];return[...u,...d,...p]}function QV({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:r,activeWorkspaceFileKey:i,activePanelKind:a,sessionCronJobs:o=[],sessionProjectRoot:s,displayMode:c=`docked`}){let l=Cu(),u=IB(t),d=$I(e=>e.optimisticReadAtBySessionKey),p=xV({activeChildSessionKey:n,activeWorkspaceFileKey:i,activePanelKind:a,childSessionTabs:u,workspaceFileTabs:r,sessionCronJobCount:o.length}),m=u.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(p?.kind!==`child-session`||p.tab.runStatus===`running`)return;let e=p.tab.lastMessageAt?.trim()??null;e&&l.chatSessionListManager.markSessionRead(p.tab.sessionKey,e,p.tab.readAt??null)},[p,l]);let g=(0,F.useMemo)(()=>ZV({resolvedChildTabs:u,workspaceFileTabs:r,sessionCronJobCount:o.length,activeSelection:p,optimisticReadAtBySessionKey:d,onSelectSession:l.chatThreadManager.selectChildSessionDetail,onSelectFile:l.chatThreadManager.selectWorkspaceFile,onCloseFile:l.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&l.chatThreadManager.openSessionCronPanel(e)}}),[p,d,l.chatThreadManager,u,e,r,o.length]);return p?(0,I.jsxs)(kt,{className:h(c===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:c===`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:l.chatThreadManager.goToParentSession,className:h(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!m&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(Dt,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:f(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:l.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":f(`chatWorkspaceClosePanel`),children:(0,I.jsx)(ln,{className:`h-4 w-4`})})]}),(0,I.jsx)(wV,{tabs:g}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:p.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XV,{tab:p.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(qV,{sessionKey:p.tab.sessionKey,onToolAction:l.chatThreadManager.openSessionFromToolAction,onFileOpen:l.chatThreadManager.openFilePreview})})]}):p.kind===`file`?(0,I.jsx)(FV,{file:p.file,sessionProjectRoot:s,onFileOpen:l.chatThreadManager.openFilePreview}):(0,I.jsx)(KV,{jobs:o})})]}):null}function $V({className:e,...t}){return(0,I.jsx)(`div`,{className:h(`animate-pulse rounded-md bg-slate-200`,e),...t})}var eH=[{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 tH(){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)($V,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:eH.map(e=>(0,I.jsx)(`div`,{className:h(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)($V,{"data-testid":`chat-conversation-skeleton-bubble`,className:h(`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)($V,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)($V,{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)($V,{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)($V,{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)($V,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)($V,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)($V,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)($V,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function nH(){let e=Cu(),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:f(`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:f(`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 rH(){let e=Cu(),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=jB(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(jB(c(n),t))},{onScroll:d}=_P({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)(bu,{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)(hB,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function iH(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function aH(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=Qs({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>GV(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:iH(e,t,n,i.length)}}function oH(){let e=Cu(),t=Q(e=>e.snapshot);return(0,I.jsx)(DB,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function sH({layoutMode:e,onBackToList:t}){let n=Cu(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=aH(r),o=!!(r.sessionKey||r.sessionTypeLabel),s=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||f(`chatSidebarNewTask`),c=r.agentId?.trim()??``,l=c.length>0&&c.toLowerCase()!==`main`;return(0,I.jsx)(OB,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:c,sessionHeaderTitle:s,shouldShowHeaderAgentAvatar:l,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 cH({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=aH(t);return a?(0,I.jsx)(QV,{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 lH({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)(oH,{}),(0,I.jsx)(sH,{layoutMode:e,onBackToList:t}),(0,I.jsx)(nH,{}),(0,I.jsx)(rH,{}),(0,I.jsx)(hL,{})]}),(0,I.jsx)(cH,{layoutMode:e})]}):(0,I.jsx)(tH,{})}var uH={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 dH({status:e,className:t}){let n=uH[e],r=f(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":r,className:h(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)(Qa,{className:h(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:h(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(yV,{side:`bottom`,className:`text-xs`,children:r})]})})}function fH(){let e=gB();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:f(`configSavedApplied`)})}}function pH(){let e=fH(),[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 mH(e,t){return e.filter(e=>hu(e,t))}function hH(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function gH(e={}){let t=$I(e=>e.snapshot.query),n=Xs({limit:e.limit??200}),r=(0,F.useMemo)(()=>mH(Zz(n.data?.sessions??[]).filter(hH),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function _H(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)(vu,{session:g,active:y,showUnreadDot:YI({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Jl(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 vH(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function yH(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:o,onQueryChange:s}=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)(N,{variant:`primary`,className:h(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),o(n)},children:[(0,I.jsx)(cn,{className:`mr-2 h-4 w-4`}),f(`chatSidebarNewTask`)]}),r.length>0?(0,I.jsxs)(Nc,{open:i,onOpenChange:a,children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":f(`chatSessionTypeLabel`),children:(0,I.jsx)(Pt,{className:`h-4 w-4`})})}),(0,I.jsxs)(Fc,{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:f(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,I.jsx)(tu,{option:e,onSelect:()=>{o(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Ot,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>s(e.target.value),placeholder:f(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function bH(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onQueryChange:c}=e,l=vH({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),u=l.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)(Ot,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>c(e.target.value),placeholder:f(`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`})]}),u?(0,I.jsxs)(Nc,{open:a,onOpenChange:o,children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{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":f(`chatSidebarNewTask`),children:(0,I.jsx)(cn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Fc,{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:f(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,I.jsx)(tu,{option:e,onSelect:()=>{s(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(N,{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":f(`chatSidebarNewTask`),onClick:()=>s(n),children:(0,I.jsx)(cn,{className:`h-4 w-4`})})]})})}function xH({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:s,languageOptions:c,onSelectLanguage:l,onOpenDocs:u,onOpenPanelApps:d}){let p=()=>{u(),t(!1)},m=()=>{d(),t(!1)};return(0,I.jsxs)(Nc,{open:e,onOpenChange:t,children:[(0,I.jsx)(Pc,{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)(uo,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:f(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,s]})]})}),(0,I.jsxs)(Fc,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(ta,{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)(uo,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`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)(At,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`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)(ya,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`panelAppsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(SH,{icon:io,label:f(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(SH,{icon:Xa,label:f(`language`),options:c,value:o,valueLabel:s,onSelect:l,onCloseMenu:()=>t(!1)})]})]})}function SH({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)($t,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(Wt,{"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)(Ta,{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)(Jt,{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)(Zt,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function CH({onOpenPanelApps:e,onRefresh:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,I.jsx)(Dt,{className:`h-3.5 w-3.5`}),f(`panelAppsTitle`)]}),(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:f(`panelAppsRefreshCurrent`),"aria-label":f(`panelAppsRefreshCurrent`),children:(0,I.jsx)(lo,{className:`h-3.5 w-3.5`})})]})}function wH({entry:e,favoritePending:t,onOpen:n,onToggleFavorite:r}){let i=e.favorite?f(`panelAppsUnfavorite`):f(`panelAppsFavorite`),a=e.lastOpenedAt?`${f(`panelAppsLastOpened`)} ${m(e.lastOpenedAt)}`:`${f(`panelAppsUpdated`)} ${m(e.updatedAt)}`;return(0,I.jsxs)(`div`,{className:`group flex w-full min-w-0 items-start gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:`flex min-w-0 flex-1 items-start gap-3 text-left`,children:[(0,I.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,I.jsx)(TH,{icon:e.icon,title:e.title})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900`,children:e.title}),e.description?(0,I.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-gray-600`,children:e.description}):null,(0,I.jsx)(`span`,{className:`mt-1 block truncate text-xs text-gray-400`,children:a})]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},disabled:t,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:i,"aria-label":i,children:(0,I.jsx)(_o,{className:e.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})})]})}function TH({icon:e,title:t}){return e?EH(e)?(0,I.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,I.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,I.jsx)(ya,{className:`h-4 w-4`})}function EH(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var DH=[`panel-apps`];function OH(){return it({queryKey:DH,queryFn:()=>Ve.panelApps.listPanelApps(),staleTime:0})}function kH(){let e=me();return se({mutationFn:({id:e,preferences:t})=>Ve.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:DH})}})}function AH(){let e=me();return se({mutationFn:e=>Ve.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:DH})}})}function jH(e,t){return t===`favorites`?MH(e.filter(e=>e.favorite),`smart`):MH(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function MH(e,t){return[...e].sort((e,n)=>NH(e,n,t))}function NH(e,t,n){return n===`recent-open`?FH(e.lastOpenedAt,t.lastOpenedAt)||PH(e,t):n===`updated`?FH(e.updatedAt,t.updatedAt)||PH(e,t):n===`name`?PH(e,t):Number(t.favorite)-Number(e.favorite)||FH(e.lastOpenedAt,t.lastOpenedAt)||FH(e.updatedAt,t.updatedAt)||PH(e,t)}function PH(e,t){return e.title.localeCompare(t.title)}function FH(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var IH=F.createContext(null);function LH({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,I.jsx)(IH.Provider,{value:{value:t,onValueChange:n},children:r})}function RH({children:e,className:t}){return(0,I.jsx)(`div`,{className:h(`inline-flex h-9 items-center justify-center rounded-xl bg-gray-100/80 p-1 text-gray-500`,t),children:e})}function zH({value:e,children:t,className:n}){let r=F.useContext(IH);if(!r)throw Error(`TabsTrigger must be used within Tabs`);let i=r.value===e;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>r.onValueChange(e),"aria-pressed":i,"data-state":i?`active`:`inactive`,className:h(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium ring-offset-white transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,i?`bg-white text-gray-900 shadow-sm`:`hover:bg-white/50 hover:text-gray-800 text-gray-600`,n),children:t})}function BH({value:e,children:t,className:n}){let r=F.useContext(IH);if(!r)throw Error(`TabsContent must be used within Tabs`);return r.value===e?(0,I.jsx)(`div`,{className:h(`mt-2 animate-fade-in`,n),children:t}):null}function VH({onOpenPanelApp:e}){let t=OH(),n=kH(),r=AH(),[i,a]=(0,F.useState)(`smart`),o=(0,F.useMemo)(()=>jH(t.data?.entries??[],i),[t.data?.entries,i]),s=async t=>{try{e(await r.mutateAsync(t.id))}catch{e(t)}},c=e=>{n.mutate({id:e.id,preferences:{favorite:!e.favorite}})};return t.isLoading?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:f(`panelAppsLoading`)}):t.isError?(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:t.error instanceof Error?t.error.message:f(`panelAppsLoadFailed`)}):(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:f(`panelAppsTitle`)}),t.data?.panelsPath?(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":f(`panelAppsTitle`),children:(0,I.jsx)(Ea,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(yV,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:t.data.panelsPath})]})}):null]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void t.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:f(`panelAppsRefresh`),"aria-label":f(`panelAppsRefresh`),children:(0,I.jsx)(lo,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,I.jsx)(LH,{value:i,onValueChange:e=>a(e),children:(0,I.jsxs)(RH,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsx)(zH,{value:`smart`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortSmart`)}),(0,I.jsx)(zH,{value:`favorites`,className:`px-2 py-1 text-xs`,children:f(`panelAppsFavorites`)}),(0,I.jsx)(zH,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortRecentOpen`)}),(0,I.jsx)(zH,{value:`updated`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortUpdated`)}),(0,I.jsx)(zH,{value:`name`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortName`)})]})})}),o.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:f(`panelAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,I.jsx)(wH,{entry:e,favoritePending:n.isPending,onOpen:()=>void s(e),onToggleFavorite:()=>c(e)},e.id))})})]})}var HH=`panel-apps`,UH=`panel-app`,WH=`nextclaw://panel-apps`,GH=[`allow-same-origin`,`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function KH(e){e.open(WH,{kind:HH,title:f(`panelAppsTitle`),dedupeKey:`panel-apps:list`})}var qH={[HH]:{getTitle:()=>f(`panelAppsTitle`),renderIcon:()=>(0,I.jsx)(ya,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({open:e})=>(0,I.jsx)(VH,{onOpenPanelApp:t=>e(t.contentPath,{kind:UH,title:t.title,dedupeKey:`panel-app:${t.id}`})})},[UH]:{getIframeSandbox:()=>GH,getTitle:e=>e.title||f(`panelAppsTitle`),renderIcon:()=>(0,I.jsx)(ya,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,I.jsx)(CH,{onOpenPanelApps:()=>KH({open:e}),onRefresh:t})}};function JH(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function YH(e){return[...e].sort((e,t)=>JH(t)-JH(e))}function XH(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],s=[],c=[];for(let t of e){let e=JH(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?s.push(t):c.push(t)}let l=[];return a.length>0&&l.push({label:f(`chatSidebarToday`),items:a}),o.length>0&&l.push({label:f(`chatSidebarYesterday`),items:o}),s.length>0&&l.push({label:f(`chatSidebarPrevious7Days`),items:s}),c.length>0&&l.push({label:f(`chatSidebarOlder`),items:c}),l}function ZH(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=JH(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()||xz(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:YH(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function QH(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)=>JH(t)-JH(e));return t}function $H(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var eU=[{target:`/cron`,label:()=>f(`chatSidebarScheduledTasks`),icon:va},{target:`/skills`,label:()=>f(`chatSidebarSkills`),icon:Ca},{target:`/agents`,label:()=>f(`agentsPageTitle`),icon:Sa}];function tU(e,t,n){let r=$I(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 nU({variant:e=`desktop`}){let t=e===`mobile`,n=Cu(),r=un(),[i,a]=(0,F.useState)(!1),[o,c]=(0,F.useState)(!1),l=Z(e=>e.snapshot),u=$I(e=>e.snapshot),d=ye(),p=rB(),{isLoading:m,items:g}=gH(),{language:_,setLanguage:v}=is(),{theme:y,setTheme:b}=yl(),x=f(Ss.find(e=>e.value===y)?.labelKey??`themeWarm`),S=s.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Ss.map(e=>({value:e.value,label:f(e.labelKey)})),[]),w=(0,F.useMemo)(()=>s.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((p.data?.agents??[]).map(e=>[e.id,e])),[p.data?.agents]),E=(0,F.useMemo)(()=>YH(g),[g]),ee=(0,F.useMemo)(()=>QH(g),[g]),D=(0,F.useMemo)(()=>XH(E),[E]),te=(0,F.useMemo)(()=>ZH(E),[E]),O=l.defaultSessionType||`native`,k=(0,F.useMemo)(()=>l.sessionTypeOptions.filter(e=>e.value!==O),[O,l.sessionTypeOptions]),A=u.listMode===`project-first`,j=tU(g,u.selectedSessionKey,n.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:N,savingSessionKey:ne,setDraftLabel:re,startEditingSessionLabel:ie,cancelEditingSessionLabel:ae,saveSessionLabel:oe}=pH(),se=e=>{_!==e&&(v(e),window.location.reload())},ce=e=>(0,I.jsx)(_H,{item:e,selectedSessionKey:u.selectedSessionKey,optimisticReadAtBySessionKey:j,agentsById:T,childSessionsByParentKey:ee,editingSessionKey:M,draftLabel:N,savingSessionKey:ne,sessionTitle:$H,onSelectSession:n.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>n.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ie,onDraftLabelChange:re,onSaveSessionLabel:oe,onCancelEditingSessionLabel:ae},e.session.key),le=(e,t)=>{n.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:h(`flex h-full min-h-0 flex-col bg-secondary`,t?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!t&&!Ol()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Rc,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(dH,{status:d.connectionStatus})})}):null,t?(0,I.jsx)(bH,{query:u.query,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:k,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:le,onQueryChange:n.chatSessionListManager.setQuery}):(0,I.jsx)(yH,{query:u.query,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:k,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:le,onQueryChange:n.chatSessionListManager.setQuery}),t?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:eU.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Kc,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),t?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:f(`chatSidebarTaskRecords`)}),(0,I.jsx)(Il,{isProjectFirstView:A,onSelectMode:n.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:m?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:f(`sessionsLoading`)}):A?te.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(to,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(ru,{groups:te,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,renderSessionItem:ce,onCreateSession:le}):D.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(to,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(ce)})]},e.label))})}),t?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(xH,{isOpen:o,onOpenChange:c,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:se,onOpenDocs:()=>r.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),onOpenPanelApps:()=>KH(r)})})]})}function rU(){return it({queryKey:[`ncp-session-types`],queryFn:de,staleTime:1e4,retry:!1})}function iU(e){let t=e.trim();return t.length>0?t:null}function aU(e){return e??null}var oU=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=$I.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:iU(e.selectedModel),preferredThinking:aU(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)}}}},sU=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new oU(Qe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>iL(nt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=LI(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:MI(e),selectedSkills:NI(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:MI(e),selectedSkills:NI(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(jI(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=II(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=II(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=$I.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=RI(e.composerNodes,i);if(qI({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(AI()),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=AB(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(FI(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),VI.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{HI.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})}}},cU=`sid_`,lU=`/chat/draft`,uU=lU.slice(6);function dU(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${cU}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function fU(e){if(!e.startsWith(cU))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 pU(e){if(!e||e===uU)return null;let t=fU(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function mU(e){return`/chat/${dU(e)}`}var hU=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=$I.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=$I.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=$I.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=$I.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&($I.getState().markSessionRead(r,i),Qe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=bz(t);this.streamActionsManager.resetStreamState(),$I.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(lU)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=$I.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=$I.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({query:n})}}},gU=async()=>{},_U=()=>{},vU=class{constructor(){this.actions={sendMessage:gU,stopCurrentRun:gU,resumeRun:gU,resetStreamState:_U,applyHistoryMessages:_U},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)}},yU=async e=>!1,bU=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:yU},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(mU(e),t)}}},xU=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=>{$I.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()||($I.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}}=$I.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()||$I.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=()=>cs.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=$I.getState();if(e&&await this.uiManager.confirm({title:f(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:f(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await Ie(e),Ee(C,e),C.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},SU=class{constructor(){this.chatUiManager=new bU,this.chatStreamActionsManager=new vU,this.chatSessionListManager=new hU(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new sU(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new xU(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function CU(e){return e?.trim().toLowerCase()||`native`}function wU(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function TU(e,t){return typeof t==`string`&&e.includes(t)}function EU(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function DU(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 OU(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:DU({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>wU(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function kU(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:DU({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>TU(t,e),firstAvailableValue:EU(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function AU(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=CU(r),o,s=-1/0;for(let e of t){if(e.key===n||CU(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 jU(e){return e.map(e=>e==null?``:String(e)).join(``)}function MU(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 NU(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;MU({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:jU([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>OU({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function PU(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;MU({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:jU([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>kU({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function FU(){let{pathname:e}=Mr(),t=Fr();return hs(e)?(0,I.jsx)(lH,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(nU,{variant:`mobile`})}var IU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DInzGY0W.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function LU({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:r,docBrowserRenderers:i={},children:a}){let o=ms(e),s=t&&!hs(e),c=Ol();return(0,I.jsxs)(`div`,{className:h(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,c?`rounded-[10px]`:null),style:c?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":o?`280px`:`240px`}:void 0,children:[c?(0,I.jsx)(wl,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!o&&(0,I.jsx)(Sl,{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:o?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:a}):(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:a})})}),n&&r===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(IU,{customTabRenderers:i})}):null]})]}),s?(0,I.jsx)(jl,{}):null,n&&r===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(IU,{customTabRenderers:i})}):null]})}var RU=`NextClaw`,zU=[{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 BU(e,t){return e===t||e.startsWith(`${t}/`)}function VU(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of zU)if(BU(t,e))return f(n);return f(`settings`)}function HU(e){return`${RU} - ${VU(e)}`}function UU({children:e}){let{isOpen:t,mode:n}=un();ts();let{pathname:r}=Mr(),{language:i}=is(),{isMobile:a}=ls(),o=Dl();return(0,F.useEffect)(()=>{document.title=HU(r)},[r,i]),a&&o!==`win32`?(0,I.jsx)(Pl,{pathname:r,isDocBrowserOpen:t,docBrowserRenderers:qH,topbarLeadingInset:o===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(LU,{pathname:r,isMobileLayout:a,isDocBrowserOpen:t,docBrowserMode:n,docBrowserRenderers:qH,children:e})}function WU({children:e}){return(0,I.jsx)(dn,{children:(0,I.jsx)(UU,{children:e})})}function GU(){let{isMobile:e}=ls();return e?(0,I.jsx)(Fl,{}):(0,I.jsx)(ci,{to:`/model`,replace:!0})}function KU(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function qU(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function JU(e,t){e&&KU(t)&&e.invalidateQueries({queryKey:[`config`]}),qU(e,t)}function YU(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Ve.eventBus.on(y.connectionOpen,()=>{nt.handleConnectionRestored(),Ue.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Ve.eventBus.on(y.connectionClose,()=>{nt.handleConnectionInterrupted(null),t.current=!0}),i=Ve.eventBus.on(y.connectionError,e=>{nt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Ve.eventBus.on(y.configUpdated,({path:t})=>{JU(e,t)}),o=Ve.eventBus.on(y.runtimeUpdateSnapshot,e=>{Ue.reportSnapshot(e)}),s=Ve.eventBus.on(y.sessionRunStatus,t=>{we(e,{type:`session.run-status`,payload:t})}),c=Ve.eventBus.on(y.sessionSummaryUpsert,t=>{we(e,{type:`session.summary.upsert`,payload:t})}),l=Ve.eventBus.on(y.sessionSummaryDelete,t=>{we(e,{type:`session.summary.delete`,payload:t})}),u=Ve.eventBus.on(y.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var XU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ModelConfig:e}=await import(`./model-config-8BVoSVXQ.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,5,3,12,13,14,9,15]))).ModelConfig})),ZU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ChatPage:e}=await import(`./chat-page-Doi-sasO.js`);return{ChatPage:e}},__vite__mapDeps([16,2,13,14,11,3,17,18,8,19,9,20,4,12,21,7,22]))).ChatPage})),QU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SearchConfig:e}=await import(`./search-config-BtCNY431.js`);return{SearchConfig:e}},__vite__mapDeps([23,2,13,14,11,3,4,6,24,25]))).SearchConfig})),$U=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ProvidersList:e}=await import(`./providers-list-CjJmW-od.js`);return{ProvidersList:e}},__vite__mapDeps([26,2,13,14,11,3,4,24,7,8,25,27,22,15]))).ProvidersList})),eW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-CzDMCXR_.js`);return{ChannelsList:e}},__vite__mapDeps([28,2,13,14,11,3,4,5,6,24,8,25,22,20,15]))).ChannelsList})),tW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-Ba6atCMq.js`);return{RuntimeConfig:e}},__vite__mapDeps([29,2,13,14,11,3,17,18,8,21,7,30,31,27]))).RuntimeConfig})),nW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-Dd4DdPH3.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([32,2,13,14,11,3,6,30]))).DesktopUpdateConfig})),rW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SecurityConfig:e}=await import(`./api-D3uoaOR8.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),iW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-Ddh05-J5.js`);return{SecretsConfig:e}},__vite__mapDeps([33,2,13,14,11,3,7,31]))).SecretsConfig})),aW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{RemoteAccessPage:e}=await import(`./remote-DxTFnQm8.js`);return{RemoteAccessPage:e}},[])).RemoteAccessPage})),oW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-D-dydvbL.js`);return{McpMarketplacePage:e}},__vite__mapDeps([34,19,2,13,14,11,3,17,18,8,9,20]))).McpMarketplacePage}));function sW(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function cW({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(sW,{}),children:e})}function lW(e){return(0,I.jsx)(cW,{children:e})}var uW=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:lW((0,I.jsx)(ZU,{view:`chat`}))},{path:`/agents`,element:lW((0,I.jsx)(ZU,{view:`agents`}))},{path:`/skills`,element:lW((0,I.jsx)(ZU,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:lW((0,I.jsx)(ZU,{view:`skills`}))},{path:`/cron`,element:lW((0,I.jsx)(ZU,{view:`cron`}))},{path:`/model`,element:lW((0,I.jsx)(XU,{}))},{path:`/search`,element:lW((0,I.jsx)(QU,{}))},{path:`/providers`,element:lW((0,I.jsx)($U,{}))},{path:`/channels`,element:lW((0,I.jsx)(eW,{}))},{path:`/runtime`,element:lW((0,I.jsx)(tW,{}))},{path:`/updates`,element:lW((0,I.jsx)(nW,{}))},{path:`/remote`,element:lW((0,I.jsx)(aW,{}))},{path:`/security`,element:lW((0,I.jsx)(rW,{}))},{path:`/secrets`,element:lW((0,I.jsx)(iW,{}))},{path:`/language`,element:(0,I.jsx)(xl,{})},{path:`/settings`,element:(0,I.jsx)(GU,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:lW((0,I.jsx)(oW,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function dW(e){return`redirectTo`in e?(0,I.jsx)(li,{path:e.path,element:(0,I.jsx)(ci,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(li,{path:e.path,element:e.element},e.path)}function fW(){return(0,I.jsx)(di,{children:uW.map(dW)})}function pW(){return YU(C),$e(),(0,F.useEffect)(()=>(Ue.start(),()=>{Ue.stop()}),[]),(0,I.jsxs)($o,{children:[(0,I.jsx)(WU,{children:(0,I.jsx)(fW,{})}),(0,I.jsx)(Jo,{})]})}function mW(){let e=Ze(),t=e.isError&&Fe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(pW,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(Yo,{username:e.data.username}):(0,I.jsx)(pW,{})}function hW(){return(0,F.useEffect)(()=>{ml()},[]),(0,I.jsxs)(ge,{client:C,children:[(0,I.jsx)(mW,{}),(0,I.jsx)(dl,{}),(0,I.jsx)(fl,{}),(0,I.jsx)(ee,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var gW=window.nextclawDesktop?.platform===`win32`?si:Zi;(0,mn.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(vl,{children:(0,I.jsx)(rs,{children:(0,I.jsx)(gW,{children:(0,I.jsx)(hW,{})})})})}));export{ul as $,Aa as $t,PB as A,Ho as At,OL as B,To as Bt,vV as C,Rs as Ct,AB as D,ls as Dt,NB as E,us as Et,Zz as F,No as Ft,dI as G,lo as Gt,oL as H,go as Ht,Xz as I,Po as It,cu as J,eo as Jt,Su as K,oo as Kt,xz as L,Io as Lt,aB as M,Lo as Mt,iB as N,ko as Nt,jB as O,is as Ot,tB as P,Mo as Pt,zl as Q,Ka as Qt,bz as R,Oo as Rt,gV as S,qs as St,hV as T,ds as Tt,$I as U,mo as Ut,iL as V,yo as Vt,Z as W,uo as Wt,ou as X,Ya as Xt,hu as Y,Qa as Yt,Ql as Z,Ja as Zt,WV as _,Hs as _t,SU as a,Lr as an,Is as at,_V as b,Ls as bt,nU as c,$s as ct,RH as d,Gs as dt,ka as en,Nc as et,zH as f,Zs as ft,HV as g,Us as gt,UV as h,tc as ht,PU as i,Fr as in,Fs as it,rB as j,Ro as jt,MB as k,Uo as kt,LH as l,Vs as lt,$V as m,Ws as mt,AU as n,va as nn,Pc as nt,pU as o,Bs as ot,lH as p,Xs as pt,Cu as q,no as qt,NU as r,Mr as rn,Ns as rt,rU as s,Qs as st,FU as t,Sa as tn,Fc as tt,BH as u,Ys as ut,zV as v,ec as vt,dV as w,Js as wt,yV as x,zs as xt,RV as y,Ks as yt,CL as z,Eo as zt};
|
|
103
|
+
`)}}async function*RB(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}=zB(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=zB(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function zB(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=LB(e);t&&i.push(t)}if(t&&r.trim()){let e=LB(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var BB=`/ncp/agent`,VB=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function HB(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function UB(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 WB(e){let t=(e??`/ncp/agent`).trim();if(!t)return BB;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function GB(e){try{return(await e.text()).trim()}catch{return``}}function KB(e){if(XB(e))return e.ncpError;if(JB(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:QB(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function qB(e,t={}){return new VB(e,t.alreadyPublished??!1)}function JB(e){return YB(e)&&typeof e.code==`string`&&typeof e.message==`string`}function YB(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function XB(e){return e instanceof VB}var ZB={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function QB(e){if(!e)return`runtime-error`;let t=ZB[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 $B(e){let t=tV(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function eV(e){let t=tV(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=QB(n),i=YB(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 tV(e){try{let t=JSON.parse(e);return YB(t)?t:null}catch{return null}}var nV=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],rV=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=HB(e.baseUrl),this.basePath=WB(e.basePath),this.fetchImpl=UB(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:nV,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:OF.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 GB(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(XB(e))throw e;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(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 GB(n)}`)}catch(e){if(t.signal.aborted)return;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(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 GB(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of RB(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(XB(e))throw e;let n=KB(e);throw this.publish({type:OF.EndpointError,payload:n}),qB(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=$B(e.data);if(!t){this.publish({type:OF.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=eV(e.data);throw this.publish({type:OF.EndpointError,payload:t}),qB(t,{alreadyPublished:!0})}}};function iV(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function aV(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 oV(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function sV(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw nt.reportTransportFailure(aV(n)),oV(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${iV(e)}: ${aV(n)}`,n)}}}var cV=300,lV=`ncp agent unavailable during startup`;function uV(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function dV(e){return e?.trim().toLowerCase().includes(lV)??!1}function fV(){return new rV({baseUrl:ce,basePath:`/api/ncp/agent`,fetchImpl:sV()})}async function pV(e,t,n=cV){t.throwIfAborted();try{let r=await ke(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!uV(e))throw e;return{messages:[],status:`idle`}}}function mV(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 hV(e,t={}){let[n]=(0,F.useState)(()=>fV()),r=ye(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??cV;(0,F.useEffect)(()=>{s(null)},[e]);let l=oI({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await pV(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 mV(e&&r.phase===`ready`&&dV(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}var gV=Sd,_V=Cd,vV=wd,yV=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Td,{children:(0,I.jsx)(Ed,{ref:r,sideOffset:t,className:h(`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})}));yV.displayName=Ed.displayName;function bV(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function xV(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 SV({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(va,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Pa,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(cB,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(to,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function CV({tab:e}){return(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsxs)(`div`,{className:h(`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)(SV,{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:f(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":f(`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:h(`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":f(`chatWorkspaceCloseFile`),children:(0,I.jsx)(ln,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(yV,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function wV({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)(CV,{tab:e},e.key))})})}function TV({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:h(`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 EV({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:h(`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)(Ua,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Pa,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Ta,{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)(TV,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(TV,{tone:`warning`,value:f(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function DV(e){let t=e.path?.trim()??``;return it({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>Re({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function OV(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function kV(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:rR({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function AV(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=sR({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 jV({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:h(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function MV({diffBlock:e}){return e?(0,I.jsx)(NV,{block:e}):(0,I.jsx)(jV,{text:f(`chatWorkspaceDiffEmpty`)})}function NV({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(HP,{block:e,layout:`workspace`})})}function PV({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(jV,{text:f(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(jV,{text:f(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(jV,{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)(MN,{text:i,role:`assistant`,texts:{copyCodeLabel:f(`chatCodeCopy`),copiedCodeLabel:f(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(NV,{block:t}):(0,I.jsx)(jV,{text:f(`chatWorkspacePreviewEmpty`)})}function FV({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=DV({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?AV(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=OV({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:kV({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)(EV,{breadcrumb:(0,F.useMemo)(()=>Oz({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)(MV,{diffBlock:a}):(0,I.jsx)(PV,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var IV=({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=f(`confirm`),cancelLabel:a=f(`cancel`),variant:o=`default`,onConfirm:s,onCancel:c})=>(0,I.jsx)(St,{open:e,onOpenChange:t,children:(0,I.jsxs)(wt,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(Ct,{children:[(0,I.jsx)(Tt,{children:n}),r?(0,I.jsx)(xt,{children:r}):null]}),(0,I.jsxs)(bt,{className:`gap-2 sm:gap-0`,children:[(0,I.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>{c(),t(!1)},children:a}),(0,I.jsx)(N,{type:`button`,variant:o===`destructive`?`destructive`:`default`,onClick:()=>{s(),t(!1)},children:i})]})]})}),LV={open:!1,title:``,description:``,confirmLabel:f(`confirm`),cancelLabel:f(`cancel`),variant:`default`,resolve:null};function RV(){let[e,t]=(0,F.useState)(LV),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??f(`confirm`),cancelLabel:e.cancelLabel??f(`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)(IV,{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 zV(e){return m(e??void 0)}function BV(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:m(new Date(e))}function VV(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 HV(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${VV(t.everyMs)}`:t.kind===`at`?`at ${BV(t.atMs)}`:`-`}function UV(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function WV(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function GV(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function KV({jobs:e}){let t=$s(),{confirm:n,ConfirmDialog:r}=RV(),i=async e=>{await n({title:`${f(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:f(`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:f(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[f(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:f(`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)(N,{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)(yo,{className:`h-3.5 w-3.5`}),f(`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:[f(`cronScheduleLabel`),`:`]}),` `,HV(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronNextRun`),`:`]}),` `,zV(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronLastRun`),`:`]}),` `,zV(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[f(`cronDeliverTo`),`:`]}),` `,UV(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 qV({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=hV(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=_P({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)(Qa,{className:`mr-2 h-4 w-4 animate-spin`}),f(`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:f(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(hB,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function JV({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 YV({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)(JV,{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 XV({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)(cB,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)(Va,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(YV,{tab:e})]})}function ZV(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:s,onCloseFile:c,onSelectCronJobs:l}=e,u=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:YI({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),d=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:bV(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>s(e.key),onClose:()=>c(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:f(`chatWorkspaceSessionCronJobs`),tooltip:f(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:l}]:[];return[...u,...d,...p]}function QV({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:r,activeWorkspaceFileKey:i,activePanelKind:a,sessionCronJobs:o=[],sessionProjectRoot:s,displayMode:c=`docked`}){let l=Cu(),u=IB(t),d=$I(e=>e.optimisticReadAtBySessionKey),p=xV({activeChildSessionKey:n,activeWorkspaceFileKey:i,activePanelKind:a,childSessionTabs:u,workspaceFileTabs:r,sessionCronJobCount:o.length}),m=u.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(p?.kind!==`child-session`||p.tab.runStatus===`running`)return;let e=p.tab.lastMessageAt?.trim()??null;e&&l.chatSessionListManager.markSessionRead(p.tab.sessionKey,e,p.tab.readAt??null)},[p,l]);let g=(0,F.useMemo)(()=>ZV({resolvedChildTabs:u,workspaceFileTabs:r,sessionCronJobCount:o.length,activeSelection:p,optimisticReadAtBySessionKey:d,onSelectSession:l.chatThreadManager.selectChildSessionDetail,onSelectFile:l.chatThreadManager.selectWorkspaceFile,onCloseFile:l.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&l.chatThreadManager.openSessionCronPanel(e)}}),[p,d,l.chatThreadManager,u,e,r,o.length]);return p?(0,I.jsxs)(kt,{className:h(c===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:c===`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:l.chatThreadManager.goToParentSession,className:h(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!m&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(Dt,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:f(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:l.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":f(`chatWorkspaceClosePanel`),children:(0,I.jsx)(ln,{className:`h-4 w-4`})})]}),(0,I.jsx)(wV,{tabs:g}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:p.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XV,{tab:p.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(qV,{sessionKey:p.tab.sessionKey,onToolAction:l.chatThreadManager.openSessionFromToolAction,onFileOpen:l.chatThreadManager.openFilePreview})})]}):p.kind===`file`?(0,I.jsx)(FV,{file:p.file,sessionProjectRoot:s,onFileOpen:l.chatThreadManager.openFilePreview}):(0,I.jsx)(KV,{jobs:o})})]}):null}function $V({className:e,...t}){return(0,I.jsx)(`div`,{className:h(`animate-pulse rounded-md bg-slate-200`,e),...t})}var eH=[{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 tH(){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)($V,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:eH.map(e=>(0,I.jsx)(`div`,{className:h(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)($V,{"data-testid":`chat-conversation-skeleton-bubble`,className:h(`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)($V,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)($V,{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)($V,{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)($V,{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)($V,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)($V,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)($V,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)($V,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function nH(){let e=Cu(),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:f(`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:f(`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 rH(){let e=Cu(),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=jB(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(jB(c(n),t))},{onScroll:d}=_P({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)(bu,{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)(hB,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function iH(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function aH(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=Qs({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>GV(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:iH(e,t,n,i.length)}}function oH(){let e=Cu(),t=Q(e=>e.snapshot);return(0,I.jsx)(DB,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function sH({layoutMode:e,onBackToList:t}){let n=Cu(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=aH(r),o=!!(r.sessionKey||r.sessionTypeLabel),s=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||f(`chatSidebarNewTask`),c=r.agentId?.trim()??``,l=c.length>0&&c.toLowerCase()!==`main`;return(0,I.jsx)(OB,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:c,sessionHeaderTitle:s,shouldShowHeaderAgentAvatar:l,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 cH({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=aH(t);return a?(0,I.jsx)(QV,{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 lH({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)(oH,{}),(0,I.jsx)(sH,{layoutMode:e,onBackToList:t}),(0,I.jsx)(nH,{}),(0,I.jsx)(rH,{}),(0,I.jsx)(hL,{})]}),(0,I.jsx)(cH,{layoutMode:e})]}):(0,I.jsx)(tH,{})}var uH={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 dH({status:e,className:t}){let n=uH[e],r=f(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":r,className:h(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)(Qa,{className:h(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:h(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(yV,{side:`bottom`,className:`text-xs`,children:r})]})})}function fH(){let e=gB();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:f(`configSavedApplied`)})}}function pH(){let e=fH(),[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 mH(e,t){return e.filter(e=>hu(e,t))}function hH(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function gH(e={}){let t=$I(e=>e.snapshot.query),n=Xs({limit:e.limit??200}),r=(0,F.useMemo)(()=>mH(Zz(n.data?.sessions??[]).filter(hH),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function _H(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)(vu,{session:g,active:y,showUnreadDot:YI({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Jl(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 vH(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function yH(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:o,onQueryChange:s}=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)(N,{variant:`primary`,className:h(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),o(n)},children:[(0,I.jsx)(cn,{className:`mr-2 h-4 w-4`}),f(`chatSidebarNewTask`)]}),r.length>0?(0,I.jsxs)(Nc,{open:i,onOpenChange:a,children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":f(`chatSessionTypeLabel`),children:(0,I.jsx)(Pt,{className:`h-4 w-4`})})}),(0,I.jsxs)(Fc,{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:f(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,I.jsx)(tu,{option:e,onSelect:()=>{o(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Ot,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>s(e.target.value),placeholder:f(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function bH(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onQueryChange:c}=e,l=vH({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),u=l.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)(Ot,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(j,{value:t,onChange:e=>c(e.target.value),placeholder:f(`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`})]}),u?(0,I.jsxs)(Nc,{open:a,onOpenChange:o,children:[(0,I.jsx)(Pc,{asChild:!0,children:(0,I.jsx)(N,{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":f(`chatSidebarNewTask`),children:(0,I.jsx)(cn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Fc,{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:f(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,I.jsx)(tu,{option:e,onSelect:()=>{s(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(N,{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":f(`chatSidebarNewTask`),onClick:()=>s(n),children:(0,I.jsx)(cn,{className:`h-4 w-4`})})]})})}function xH({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:s,languageOptions:c,onSelectLanguage:l,onOpenDocs:u,onOpenPanelApps:d}){let p=()=>{u(),t(!1)},m=()=>{d(),t(!1)};return(0,I.jsxs)(Nc,{open:e,onOpenChange:t,children:[(0,I.jsx)(Pc,{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)(uo,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:f(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,s]})]})}),(0,I.jsxs)(Fc,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(ta,{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)(uo,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`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)(At,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`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)(ya,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:f(`panelAppsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(SH,{icon:io,label:f(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(SH,{icon:Xa,label:f(`language`),options:c,value:o,valueLabel:s,onSelect:l,onCloseMenu:()=>t(!1)})]})]})}function SH({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)($t,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(Wt,{"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)(Ta,{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)(Jt,{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)(Zt,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function CH({onOpenPanelApps:e,onRefresh:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,I.jsx)(Dt,{className:`h-3.5 w-3.5`}),f(`panelAppsTitle`)]}),(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:f(`panelAppsRefreshCurrent`),"aria-label":f(`panelAppsRefreshCurrent`),children:(0,I.jsx)(lo,{className:`h-3.5 w-3.5`})})]})}function wH({entry:e,favoritePending:t,onOpen:n,onToggleFavorite:r}){let i=e.favorite?f(`panelAppsUnfavorite`):f(`panelAppsFavorite`),a=e.lastOpenedAt?`${f(`panelAppsLastOpened`)} ${m(e.lastOpenedAt)}`:`${f(`panelAppsUpdated`)} ${m(e.updatedAt)}`;return(0,I.jsxs)(`div`,{className:`group flex w-full min-w-0 items-start gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:`flex min-w-0 flex-1 items-start gap-3 text-left`,children:[(0,I.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,I.jsx)(TH,{icon:e.icon,title:e.title})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900`,children:e.title}),e.description?(0,I.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-gray-600`,children:e.description}):null,(0,I.jsx)(`span`,{className:`mt-1 block truncate text-xs text-gray-400`,children:a})]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},disabled:t,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:i,"aria-label":i,children:(0,I.jsx)(_o,{className:e.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})})]})}function TH({icon:e,title:t}){return e?EH(e)?(0,I.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,I.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,I.jsx)(ya,{className:`h-4 w-4`})}function EH(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var DH=[`panel-apps`];function OH(){return it({queryKey:DH,queryFn:()=>Ve.panelApps.listPanelApps(),staleTime:0})}function kH(){let e=me();return se({mutationFn:({id:e,preferences:t})=>Ve.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:DH})}})}function AH(){let e=me();return se({mutationFn:e=>Ve.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:DH})}})}function jH(e,t){return t===`favorites`?MH(e.filter(e=>e.favorite),`smart`):MH(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function MH(e,t){return[...e].sort((e,n)=>NH(e,n,t))}function NH(e,t,n){return n===`recent-open`?FH(e.lastOpenedAt,t.lastOpenedAt)||PH(e,t):n===`updated`?FH(e.updatedAt,t.updatedAt)||PH(e,t):n===`name`?PH(e,t):Number(t.favorite)-Number(e.favorite)||FH(e.lastOpenedAt,t.lastOpenedAt)||FH(e.updatedAt,t.updatedAt)||PH(e,t)}function PH(e,t){return e.title.localeCompare(t.title)}function FH(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var IH=F.createContext(null);function LH({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,I.jsx)(IH.Provider,{value:{value:t,onValueChange:n},children:r})}function RH({children:e,className:t}){return(0,I.jsx)(`div`,{className:h(`inline-flex h-9 items-center justify-center rounded-xl bg-gray-100/80 p-1 text-gray-500`,t),children:e})}function zH({value:e,children:t,className:n}){let r=F.useContext(IH);if(!r)throw Error(`TabsTrigger must be used within Tabs`);let i=r.value===e;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>r.onValueChange(e),"aria-pressed":i,"data-state":i?`active`:`inactive`,className:h(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium ring-offset-white transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,i?`bg-white text-gray-900 shadow-sm`:`hover:bg-white/50 hover:text-gray-800 text-gray-600`,n),children:t})}function BH({value:e,children:t,className:n}){let r=F.useContext(IH);if(!r)throw Error(`TabsContent must be used within Tabs`);return r.value===e?(0,I.jsx)(`div`,{className:h(`mt-2 animate-fade-in`,n),children:t}):null}function VH({onOpenPanelApp:e}){let t=OH(),n=kH(),r=AH(),[i,a]=(0,F.useState)(`smart`),o=(0,F.useMemo)(()=>jH(t.data?.entries??[],i),[t.data?.entries,i]),s=async t=>{try{e(await r.mutateAsync(t.id))}catch{e(t)}},c=e=>{n.mutate({id:e.id,preferences:{favorite:!e.favorite}})};return t.isLoading?(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:f(`panelAppsLoading`)}):t.isError?(0,I.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:t.error instanceof Error?t.error.message:f(`panelAppsLoadFailed`)}):(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:f(`panelAppsTitle`)}),t.data?.panelsPath?(0,I.jsx)(gV,{delayDuration:250,children:(0,I.jsxs)(_V,{children:[(0,I.jsx)(vV,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":f(`panelAppsTitle`),children:(0,I.jsx)(Ea,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(yV,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:t.data.panelsPath})]})}):null]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void t.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:f(`panelAppsRefresh`),"aria-label":f(`panelAppsRefresh`),children:(0,I.jsx)(lo,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,I.jsx)(LH,{value:i,onValueChange:e=>a(e),children:(0,I.jsxs)(RH,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,I.jsx)(zH,{value:`smart`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortSmart`)}),(0,I.jsx)(zH,{value:`favorites`,className:`px-2 py-1 text-xs`,children:f(`panelAppsFavorites`)}),(0,I.jsx)(zH,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortRecentOpen`)}),(0,I.jsx)(zH,{value:`updated`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortUpdated`)}),(0,I.jsx)(zH,{value:`name`,className:`px-2 py-1 text-xs`,children:f(`panelAppsSortName`)})]})})}),o.length===0?(0,I.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:f(`panelAppsEmpty`)}):(0,I.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,I.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,I.jsx)(wH,{entry:e,favoritePending:n.isPending,onOpen:()=>void s(e),onToggleFavorite:()=>c(e)},e.id))})})]})}var HH=`panel-apps`,UH=`panel-app`,WH=`nextclaw://panel-apps`,GH=[`allow-same-origin`,`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function KH(e){e.open(WH,{kind:HH,title:f(`panelAppsTitle`),dedupeKey:`panel-apps:list`})}var qH={[HH]:{getTitle:()=>f(`panelAppsTitle`),renderIcon:()=>(0,I.jsx)(ya,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({open:e})=>(0,I.jsx)(VH,{onOpenPanelApp:t=>e(t.contentPath,{kind:UH,title:t.title,dedupeKey:`panel-app:${t.id}`})})},[UH]:{getIframeSandbox:()=>GH,getTitle:e=>e.title||f(`panelAppsTitle`),renderIcon:()=>(0,I.jsx)(ya,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,I.jsx)(CH,{onOpenPanelApps:()=>KH({open:e}),onRefresh:t})}};function JH(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function YH(e){return[...e].sort((e,t)=>JH(t)-JH(e))}function XH(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],s=[],c=[];for(let t of e){let e=JH(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?s.push(t):c.push(t)}let l=[];return a.length>0&&l.push({label:f(`chatSidebarToday`),items:a}),o.length>0&&l.push({label:f(`chatSidebarYesterday`),items:o}),s.length>0&&l.push({label:f(`chatSidebarPrevious7Days`),items:s}),c.length>0&&l.push({label:f(`chatSidebarOlder`),items:c}),l}function ZH(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=JH(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()||xz(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:YH(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function QH(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)=>JH(t)-JH(e));return t}function $H(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var eU=[{target:`/cron`,label:()=>f(`chatSidebarScheduledTasks`),icon:va},{target:`/skills`,label:()=>f(`chatSidebarSkills`),icon:Ca},{target:`/agents`,label:()=>f(`agentsPageTitle`),icon:Sa}];function tU(e,t,n){let r=$I(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 nU({variant:e=`desktop`}){let t=e===`mobile`,n=Cu(),r=un(),[i,a]=(0,F.useState)(!1),[o,c]=(0,F.useState)(!1),l=Z(e=>e.snapshot),u=$I(e=>e.snapshot),d=ye(),p=rB(),{isLoading:m,items:g}=gH(),{language:_,setLanguage:v}=is(),{theme:y,setTheme:b}=yl(),x=f(Ss.find(e=>e.value===y)?.labelKey??`themeWarm`),S=s.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>Ss.map(e=>({value:e.value,label:f(e.labelKey)})),[]),w=(0,F.useMemo)(()=>s.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((p.data?.agents??[]).map(e=>[e.id,e])),[p.data?.agents]),E=(0,F.useMemo)(()=>YH(g),[g]),ee=(0,F.useMemo)(()=>QH(g),[g]),D=(0,F.useMemo)(()=>XH(E),[E]),te=(0,F.useMemo)(()=>ZH(E),[E]),O=l.defaultSessionType||`native`,k=(0,F.useMemo)(()=>l.sessionTypeOptions.filter(e=>e.value!==O),[O,l.sessionTypeOptions]),A=u.listMode===`project-first`,j=tU(g,u.selectedSessionKey,n.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:N,savingSessionKey:ne,setDraftLabel:re,startEditingSessionLabel:ie,cancelEditingSessionLabel:ae,saveSessionLabel:oe}=pH(),se=e=>{_!==e&&(v(e),window.location.reload())},ce=e=>(0,I.jsx)(_H,{item:e,selectedSessionKey:u.selectedSessionKey,optimisticReadAtBySessionKey:j,agentsById:T,childSessionsByParentKey:ee,editingSessionKey:M,draftLabel:N,savingSessionKey:ne,sessionTitle:$H,onSelectSession:n.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>n.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ie,onDraftLabelChange:re,onSaveSessionLabel:oe,onCancelEditingSessionLabel:ae},e.session.key),le=(e,t)=>{n.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:h(`flex h-full min-h-0 flex-col bg-secondary`,t?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!t&&!Ol()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(Rc,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(dH,{status:d.connectionStatus})})}):null,t?(0,I.jsx)(bH,{query:u.query,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:k,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:le,onQueryChange:n.chatSessionListManager.setQuery}):(0,I.jsx)(yH,{query:u.query,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:k,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:le,onQueryChange:n.chatSessionListManager.setQuery}),t?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:eU.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Kc,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),t?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:f(`chatSidebarTaskRecords`)}),(0,I.jsx)(Il,{isProjectFirstView:A,onSelectMode:n.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:m?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:f(`sessionsLoading`)}):A?te.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(to,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(ru,{groups:te,defaultSessionType:O,sessionTypeOptions:l.sessionTypeOptions,renderSessionItem:ce,onCreateSession:le}):D.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(to,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(ce)})]},e.label))})}),t?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(xH,{isOpen:o,onOpenChange:c,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:se,onOpenDocs:()=>r.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),onOpenPanelApps:()=>KH(r)})})]})}function rU(){return it({queryKey:[`ncp-session-types`],queryFn:de,staleTime:1e4,retry:!1})}function iU(e){let t=e.trim();return t.length>0?t:null}function aU(e){return e??null}var oU=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=$I.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:iU(e.selectedModel),preferredThinking:aU(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)}}}},sU=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new oU(Qe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>iL(nt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=LI(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:MI(e),selectedSkills:NI(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:MI(e),selectedSkills:NI(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(jI(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=II(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=II(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=$I.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=RI(e.composerNodes,i);if(qI({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(AI()),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=AB(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(FI(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),VI.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{HI.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})}}},cU=`sid_`,lU=`/chat/draft`,uU=lU.slice(6);function dU(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${cU}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function fU(e){if(!e.startsWith(cU))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 pU(e){if(!e||e===uU)return null;let t=fU(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function mU(e){return`/chat/${dU(e)}`}var hU=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=$I.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=$I.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=$I.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=$I.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&($I.getState().markSessionRead(r,i),Qe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=bz(t);this.streamActionsManager.resetStreamState(),$I.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(lU)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=$I.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=$I.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&$I.getState().setSnapshot({query:n})}}},gU=async()=>{},_U=()=>{},vU=class{constructor(){this.actions={sendMessage:gU,stopCurrentRun:gU,resumeRun:gU,resetStreamState:_U,applyHistoryMessages:_U},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)}},yU=async e=>!1,bU=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:yU},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(mU(e),t)}}},xU=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=>{$I.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()||($I.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}}=$I.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()||$I.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=()=>cs.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=$I.getState();if(e&&await this.uiManager.confirm({title:f(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:f(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await Ie(e),Ee(C,e),C.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},SU=class{constructor(){this.chatUiManager=new bU,this.chatStreamActionsManager=new vU,this.chatSessionListManager=new hU(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new sU(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new xU(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function CU(e){return e?.trim().toLowerCase()||`native`}function wU(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function TU(e,t){return typeof t==`string`&&e.includes(t)}function EU(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function DU(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 OU(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:DU({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>wU(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function kU(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:DU({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>TU(t,e),firstAvailableValue:EU(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function AU(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=CU(r),o,s=-1/0;for(let e of t){if(e.key===n||CU(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 jU(e){return e.map(e=>e==null?``:String(e)).join(``)}function MU(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 NU(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;MU({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:jU([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>OU({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function PU(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;MU({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:jU([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>kU({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function FU(){let{pathname:e}=Mr(),t=Fr();return hs(e)?(0,I.jsx)(lH,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(nU,{variant:`mobile`})}var IU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DocBrowser:e}=await import(`./doc-browser-cR1vWRs1.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function LU({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:r,docBrowserRenderers:i={},children:a}){let o=ms(e),s=t&&!hs(e),c=Ol();return(0,I.jsxs)(`div`,{className:h(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,c?`rounded-[10px]`:null),style:c?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":o?`280px`:`240px`}:void 0,children:[c?(0,I.jsx)(wl,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!o&&(0,I.jsx)(Sl,{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:o?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:a}):(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:a})})}),n&&r===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(IU,{customTabRenderers:i})}):null]})]}),s?(0,I.jsx)(jl,{}):null,n&&r===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(IU,{customTabRenderers:i})}):null]})}var RU=`NextClaw`,zU=[{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 BU(e,t){return e===t||e.startsWith(`${t}/`)}function VU(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of zU)if(BU(t,e))return f(n);return f(`settings`)}function HU(e){return`${RU} - ${VU(e)}`}function UU({children:e}){let{isOpen:t,mode:n}=un();ts();let{pathname:r}=Mr(),{language:i}=is(),{isMobile:a}=ls(),o=Dl();return(0,F.useEffect)(()=>{document.title=HU(r)},[r,i]),a&&o!==`win32`?(0,I.jsx)(Pl,{pathname:r,isDocBrowserOpen:t,docBrowserRenderers:qH,topbarLeadingInset:o===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(LU,{pathname:r,isMobileLayout:a,isDocBrowserOpen:t,docBrowserMode:n,docBrowserRenderers:qH,children:e})}function WU({children:e}){return(0,I.jsx)(dn,{children:(0,I.jsx)(UU,{children:e})})}function GU(){let{isMobile:e}=ls();return e?(0,I.jsx)(Fl,{}):(0,I.jsx)(ci,{to:`/model`,replace:!0})}function KU(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function qU(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function JU(e,t){e&&KU(t)&&e.invalidateQueries({queryKey:[`config`]}),qU(e,t)}function YU(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Ve.eventBus.on(y.connectionOpen,()=>{nt.handleConnectionRestored(),Ue.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Ve.eventBus.on(y.connectionClose,()=>{nt.handleConnectionInterrupted(null),t.current=!0}),i=Ve.eventBus.on(y.connectionError,e=>{nt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Ve.eventBus.on(y.configUpdated,({path:t})=>{JU(e,t)}),o=Ve.eventBus.on(y.runtimeUpdateSnapshot,e=>{Ue.reportSnapshot(e)}),s=Ve.eventBus.on(y.sessionRunStatus,t=>{we(e,{type:`session.run-status`,payload:t})}),c=Ve.eventBus.on(y.sessionSummaryUpsert,t=>{we(e,{type:`session.summary.upsert`,payload:t})}),l=Ve.eventBus.on(y.sessionSummaryDelete,t=>{we(e,{type:`session.summary.delete`,payload:t})}),u=Ve.eventBus.on(y.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var XU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ModelConfig:e}=await import(`./model-config-DcnC_fSr.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,5,3,12,13,14,9,15]))).ModelConfig})),ZU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ChatPage:e}=await import(`./chat-page-DOKLoiqI.js`);return{ChatPage:e}},__vite__mapDeps([16,2,13,14,11,3,17,18,8,19,9,20,4,12,21,7,22]))).ChatPage})),QU=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SearchConfig:e}=await import(`./search-config-BFmG4_F7.js`);return{SearchConfig:e}},__vite__mapDeps([23,2,13,14,11,3,4,6,24,25]))).SearchConfig})),$U=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ProvidersList:e}=await import(`./providers-list-BgvjRVmp.js`);return{ProvidersList:e}},__vite__mapDeps([26,2,13,14,11,3,4,24,7,8,25,27,22,15]))).ProvidersList})),eW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-DHmz9iHg.js`);return{ChannelsList:e}},__vite__mapDeps([28,2,13,14,11,3,4,5,6,24,8,25,22,20,15]))).ChannelsList})),tW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-B2XPXHrk.js`);return{RuntimeConfig:e}},__vite__mapDeps([29,2,13,14,11,3,17,18,8,21,7,30,31,27]))).RuntimeConfig})),nW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-ClbDsIOs.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([32,2,13,14,11,3,6,30]))).DesktopUpdateConfig})),rW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SecurityConfig:e}=await import(`./api-D3uoaOR8.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),iW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-4uY5sk-V.js`);return{SecretsConfig:e}},__vite__mapDeps([33,2,13,14,11,3,7,31]))).SecretsConfig})),aW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{RemoteAccessPage:e}=await import(`./remote-BCuZ1JJe.js`);return{RemoteAccessPage:e}},[])).RemoteAccessPage})),oW=(0,F.lazy)(async()=>({default:(await vn(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-DXCvk7wJ.js`);return{McpMarketplacePage:e}},__vite__mapDeps([34,19,2,13,14,11,3,17,18,8,9,20]))).McpMarketplacePage}));function sW(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function cW({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(sW,{}),children:e})}function lW(e){return(0,I.jsx)(cW,{children:e})}var uW=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:lW((0,I.jsx)(ZU,{view:`chat`}))},{path:`/agents`,element:lW((0,I.jsx)(ZU,{view:`agents`}))},{path:`/skills`,element:lW((0,I.jsx)(ZU,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:lW((0,I.jsx)(ZU,{view:`skills`}))},{path:`/cron`,element:lW((0,I.jsx)(ZU,{view:`cron`}))},{path:`/model`,element:lW((0,I.jsx)(XU,{}))},{path:`/search`,element:lW((0,I.jsx)(QU,{}))},{path:`/providers`,element:lW((0,I.jsx)($U,{}))},{path:`/channels`,element:lW((0,I.jsx)(eW,{}))},{path:`/runtime`,element:lW((0,I.jsx)(tW,{}))},{path:`/updates`,element:lW((0,I.jsx)(nW,{}))},{path:`/remote`,element:lW((0,I.jsx)(aW,{}))},{path:`/security`,element:lW((0,I.jsx)(rW,{}))},{path:`/secrets`,element:lW((0,I.jsx)(iW,{}))},{path:`/language`,element:(0,I.jsx)(xl,{})},{path:`/settings`,element:(0,I.jsx)(GU,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:lW((0,I.jsx)(oW,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function dW(e){return`redirectTo`in e?(0,I.jsx)(li,{path:e.path,element:(0,I.jsx)(ci,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(li,{path:e.path,element:e.element},e.path)}function fW(){return(0,I.jsx)(di,{children:uW.map(dW)})}function pW(){return YU(C),$e(),(0,F.useEffect)(()=>(Ue.start(),()=>{Ue.stop()}),[]),(0,I.jsxs)($o,{children:[(0,I.jsx)(WU,{children:(0,I.jsx)(fW,{})}),(0,I.jsx)(Jo,{})]})}function mW(){let e=Ze(),t=e.isError&&Fe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(pW,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(Yo,{username:e.data.username}):(0,I.jsx)(pW,{})}function hW(){return(0,F.useEffect)(()=>{ml()},[]),(0,I.jsxs)(ge,{client:C,children:[(0,I.jsx)(mW,{}),(0,I.jsx)(dl,{}),(0,I.jsx)(fl,{}),(0,I.jsx)(ee,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var gW=window.nextclawDesktop?.platform===`win32`?si:Zi;(0,mn.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(vl,{children:(0,I.jsx)(rs,{children:(0,I.jsx)(gW,{children:(0,I.jsx)(hW,{})})})})}));export{ul as $,Aa as $t,PB as A,Ho as At,OL as B,To as Bt,vV as C,Rs as Ct,AB as D,ls as Dt,NB as E,us as Et,Zz as F,No as Ft,dI as G,lo as Gt,oL as H,go as Ht,Xz as I,Po as It,cu as J,eo as Jt,Su as K,oo as Kt,xz as L,Io as Lt,aB as M,Lo as Mt,iB as N,ko as Nt,jB as O,is as Ot,tB as P,Mo as Pt,zl as Q,Ka as Qt,bz as R,Oo as Rt,gV as S,qs as St,hV as T,ds as Tt,$I as U,mo as Ut,iL as V,yo as Vt,Z as W,uo as Wt,ou as X,Ya as Xt,hu as Y,Qa as Yt,Ql as Z,Ja as Zt,WV as _,Hs as _t,SU as a,Lr as an,Is as at,_V as b,Ls as bt,nU as c,$s as ct,RH as d,Gs as dt,ka as en,Nc as et,zH as f,Zs as ft,HV as g,Us as gt,UV as h,tc as ht,PU as i,Fr as in,Fs as it,rB as j,Ro as jt,MB as k,Uo as kt,LH as l,Vs as lt,$V as m,Ws as mt,AU as n,va as nn,Pc as nt,pU as o,Bs as ot,lH as p,Xs as pt,Cu as q,no as qt,NU as r,Mr as rn,Ns as rt,rU as s,Qs as st,FU as t,Sa as tn,Fc as tt,BH as u,Ys as ut,zV as v,ec as vt,dV as w,Js as wt,yV as x,zs as xt,RV as y,Ks as yt,CL as z,Eo as zt};
|