@spencer-kit/coder-studio-win32-x64 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,7 @@
1
+ import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{a as t,c as n,i as r,l as i,n as a,o,r as s,s as c,t as l}from"./react-BF8D1Hk7.js";import{n as u,t as d}from"./terminal-vdgmTa16.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 f=e(c(),1),p=e(i(),1),m=`modulepreload`,h=function(e){return`/`+e},g={},_=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=h(t,n),t in g)return;g[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`:m,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)})},v=`popstate`;function y(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function b(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=E(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),ee(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:T(t))}function r(e,t){S(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return te(t,n,r,e)}function x(e,t){if(e===!1||e==null)throw Error(t)}function S(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function C(){return Math.random().toString(36).substring(2,10)}function w(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ee(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?E(t):t,state:n,key:t&&t.key||r||C(),unstable_mask:i}}function T({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 E(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 te(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=y(e)?e:ee(h.location,e,t);n&&n(r,e),l=u()+1;let d=w(r,l),f=h.createHref(r.unstable_mask||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=y(e)?e:ee(h.location,e,t);n&&n(r,e),l=u();let i=w(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return D(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(v,d),c=e,()=>{i.removeEventListener(v,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 D(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),x(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:T(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function O(e,t,n=`/`){return ne(e,t,n,!1)}function ne(e,t,n,r){let i=M((typeof t==`string`?E(t):t).pathname||`/`,n);if(i==null)return null;let a=ie(e);oe(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=ge(i);o=pe(a[e],t,r)}return o}function re(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 ie(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;x(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=we([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(x(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ie(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:de(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ae(e.path))a(e,t,!0,n)}),t}function ae(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=ae(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 oe(e){e.sort((e,t)=>e.score===t.score?fe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var se=/^:[\w-]+$/,k=3,A=2,j=1,ce=10,le=-2,ue=e=>e===`*`;function de(e,t){let n=e.split(`/`),r=n.length;return n.some(ue)&&(r+=le),t&&(r+=A),n.filter(e=>!ue(e)).reduce((e,t)=>e+(se.test(t)?k:t===``?j:ce),r)}function fe(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 pe(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=me({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=me({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:we([a,u.pathname]),pathnameBase:Te(we([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=we([a,u.pathnameBase]))}return o}function me(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=he(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 he(e,t=!1,n=!0){S(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,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).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 ge(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return S(!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 M(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 _e=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ve(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?E(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?ye(n.substring(1),`/`):ye(n,t)):a=t,{pathname:a,search:Ee(r),hash:N(i)}}function ye(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 be(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 xe(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Se(e){let t=xe(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Ce(e,t,n,r=!1){let i;typeof e==`string`?i=E(e):(i={...e},x(!i.pathname||!i.pathname.includes(`?`),be(`?`,`pathname`,`search`,i)),x(!i.pathname||!i.pathname.includes(`#`),be(`#`,`pathname`,`hash`,i)),x(!i.search||!i.search.includes(`#`),be(`#`,`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=ve(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var we=e=>e.join(`/`).replace(/\/\/+/g,`/`),Te=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Ee=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,N=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,De=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 Oe(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ke(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Ae=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function je(e,t){let n=e;if(typeof n!=`string`||!_e.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Ae)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=M(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{S(!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 Me=p.createContext(null);Me.displayName=`DataRouter`;var Ne=p.createContext(null);Ne.displayName=`DataRouterState`;var Pe=p.createContext(!1),Fe=p.createContext({isTransitioning:!1});Fe.displayName=`ViewTransition`;var Ie=p.createContext(new Map);Ie.displayName=`Fetchers`;var Le=p.createContext(null);Le.displayName=`Await`;var P=p.createContext(null);P.displayName=`Navigation`;var Re=p.createContext(null);Re.displayName=`Location`;var F=p.createContext({outlet:null,matches:[],isDataRoute:!1});F.displayName=`Route`;var ze=p.createContext(null);ze.displayName=`RouteError`;var Be=`REACT_ROUTER_ERROR`,Ve=`REDIRECT`,He=`ROUTE_ERROR_RESPONSE`;function Ue(e){if(e.startsWith(`${Be}:${Ve}:{`))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 We(e){if(e.startsWith(`${Be}:${He}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new De(t.status,t.statusText,t.data)}catch{}}function Ge(e,{relative:t}={}){x(I(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=p.useContext(P),{hash:i,pathname:a,search:o}=Ye(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:we([n,a])),r.createHref({pathname:s,search:o,hash:i})}function I(){return p.useContext(Re)!=null}function L(){return x(I(),`useLocation() may be used only in the context of a <Router> component.`),p.useContext(Re).location}var R=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function z(e){p.useContext(P).static||p.useLayoutEffect(e)}function Ke(){let{isDataRoute:e}=p.useContext(F);return e?U():qe()}function qe(){x(I(),`useNavigate() may be used only in the context of a <Router> component.`);let e=p.useContext(Me),{basename:t,navigator:n}=p.useContext(P),{matches:r}=p.useContext(F),{pathname:i}=L(),a=JSON.stringify(Se(r)),o=p.useRef(!1);return z(()=>{o.current=!0}),p.useCallback((r,s={})=>{if(S(o.current,R),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Ce(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:we([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}p.createContext(null);function Je(){let{matches:e}=p.useContext(F),t=e[e.length-1];return t?t.params:{}}function Ye(e,{relative:t}={}){let{matches:n}=p.useContext(F),{pathname:r}=L(),i=JSON.stringify(Se(n));return p.useMemo(()=>Ce(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Xe(e,t){return Ze(e,t)}function Ze(e,t,n){x(I(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=p.useContext(P),{matches:i}=p.useContext(F),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;ft(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (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.
2
+
3
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=L(),d;if(t){let e=typeof t==`string`?E(t):t;x(c===`/`||e.pathname?.startsWith(c),`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 "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,m=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);m=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=O(e,{pathname:m});S(l||h!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),S(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.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 g=rt(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:we([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:we([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?p.createElement(Re.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},g):g}function Qe(){let e=ut(),t=Oe(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=p.createElement(p.Fragment,null,p.createElement(`p`,null,`💿 Hey developer 👋`),p.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,p.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,p.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),p.createElement(p.Fragment,null,p.createElement(`h2`,null,`Unexpected Application Error!`),p.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?p.createElement(`pre`,{style:i},n):null,o)}var $e=p.createElement(Qe,null),et=class extends p.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=We(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:p.createElement(F.Provider,{value:this.props.routeContext},p.createElement(ze.Provider,{value:e,children:this.props.component}));return this.context?p.createElement(B,{error:e},t):t}};et.contextType=Pe;var tt=new WeakMap;function B({children:e,error:t}){let{basename:n}=p.useContext(P);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ue(t.digest);if(e){let r=tt.get(t);if(r)throw r;let i=je(e.location,n);if(Ae&&!tt.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 tt.set(t,n),n}return p.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function nt({routeContext:e,match:t,children:n}){let r=p.useContext(Me);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),p.createElement(F.Provider,{value:e},n)}function rt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);x(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:ke(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,m=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||$e,o&&(s<0&&c===0?(ft(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,m=null):s===c&&(d=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(i.slice(0,c+1)),g=()=>{let t;return t=u?f:d?m:n.route.Component?p.createElement(n.route.Component,null):n.route.element?n.route.element:e,p.createElement(nt,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?p.createElement(et,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:l}):g()},null)}function V(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function H(e){let t=p.useContext(Me);return x(t,V(e)),t}function it(e){let t=p.useContext(Ne);return x(t,V(e)),t}function at(e){let t=p.useContext(F);return x(t,V(e)),t}function ot(e){let t=at(e),n=t.matches[t.matches.length-1];return x(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function st(){return ot(`useRouteId`)}function ct(){return it(`useNavigation`).navigation}function lt(){let{matches:e,loaderData:t}=it(`useMatches`);return p.useMemo(()=>e.map(e=>re(e,t)),[e,t])}function ut(){let e=p.useContext(ze),t=it(`useRouteError`),n=ot(`useRouteError`);return e===void 0?t.errors?.[n]:e}function U(){let{router:e}=H(`useNavigate`),t=ot(`useNavigate`),n=p.useRef(!1);return z(()=>{n.current=!0}),p.useCallback(async(r,i={})=>{S(n.current,R),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var dt={};function ft(e,t,n){!t&&!dt[e]&&(dt[e]=!0,S(!1,n))}p.useOptimistic,p.memo(pt);function pt({routes:e,future:t,state:n,isStatic:r,onError:i}){return Ze(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function mt({to:e,replace:t,state:n,relative:r}){x(I(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=p.useContext(P);S(!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}=p.useContext(F),{pathname:o}=L(),s=Ke(),c=Ce(e,Se(a),o,r===`path`),l=JSON.stringify(c);return p.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function ht(e){x(!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 gt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){x(!I(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=p.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=E(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:m=`default`,unstable_mask:h}=n,g=p.useMemo(()=>{let e=M(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:m,unstable_mask:h},navigationType:r}},[s,l,u,d,f,m,r,h]);return S(g!=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.`),g==null?null:p.createElement(P.Provider,{value:c},p.createElement(Re.Provider,{children:t,value:g}))}function _t({children:e,location:t}){return Xe(W(e),t)}function W(e,t=[]){let n=[];return p.Children.forEach(e,(e,r)=>{if(!p.isValidElement(e))return;let i=[...t,r];if(e.type===p.Fragment){n.push.apply(n,W(e.props.children,i));return}x(e.type===ht,`[${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>`),x(!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=W(e.props.children,i)),n.push(a)}),n}var vt=`get`,G=`application/x-www-form-urlencoded`;function yt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function K(e){return yt(e)&&e.tagName.toLowerCase()===`button`}function bt(e){return yt(e)&&e.tagName.toLowerCase()===`form`}function xt(e){return yt(e)&&e.tagName.toLowerCase()===`input`}function St(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ct(e,t){return e.button===0&&(!t||t===`_self`)&&!St(e)}var wt=null;function Tt(){if(wt===null)try{new FormData(document.createElement(`form`),0),wt=!1}catch{wt=!0}return wt}var Et=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Dt(e){return e!=null&&!Et.has(e)?(S(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${G}"`),null):e}function Ot(e,t){let n,r,i,a,o;if(bt(e)){let o=e.getAttribute(`action`);r=o?M(o,t):null,n=e.getAttribute(`method`)||vt,i=Dt(e.getAttribute(`enctype`))||G,a=new FormData(e)}else if(K(e)||xt(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?M(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||vt,i=Dt(e.getAttribute(`formenctype`))||Dt(o.getAttribute(`enctype`))||G,a=new FormData(o,e),!Tt()){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(yt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=vt,r=null,i=G,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 kt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},At=/[&><\u2028\u2029]/g;function jt(e){return e.replace(At,e=>kt[e])}function Mt(e,t){if(e===!1||e==null)throw Error(t)}function Nt(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&&M(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function Pt(e,t){if(e.id in t)return t[e.id];try{let n=await _(()=>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 Ft(e){return e!=null&&typeof e.page==`string`}function It(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 Lt(e,t,n){return Ht((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Pt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(It).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Rt(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 zt(e,t,{includeHydrateFallback:n}={}){return Bt(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 Bt(e){return[...new Set(e)]}function Vt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ht(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Ft(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Vt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Ut(){let e=p.useContext(Me);return Mt(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Wt(){let e=p.useContext(Ne);return Mt(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Gt=p.createContext(void 0);Gt.displayName=`FrameworkContext`;function Kt(){let e=p.useContext(Gt);return Mt(e,`You must render this element inside a <HydratedRouter> element`),e}function qt(e,t){let n=p.useContext(Gt),[r,i]=p.useState(!1),[a,o]=p.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=p.useRef(null);p.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]),p.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Jt(s,m),onBlur:Jt(c,h),onMouseEnter:Jt(l,m),onMouseLeave:Jt(u,h),onTouchStart:Jt(d,m)}]:[a,f,{}]:[!1,f,{}]}function Jt(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Yt({page:e,...t}){let{router:n}=Ut(),r=p.useMemo(()=>O(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?p.createElement(Zt,{page:e,matches:r,...t}):null}function Xt(e){let{manifest:t,routeModules:n}=Kt(),[r,i]=p.useState([]);return p.useEffect(()=>{let r=!1;return Lt(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Zt({page:e,matches:t,...n}){let r=L(),{future:i,manifest:a,routeModules:o}=Kt(),{basename:s}=Ut(),{loaderData:c,matches:l}=Wt(),u=p.useMemo(()=>Rt(e,t,l,a,r,`data`),[e,t,l,a,r]),d=p.useMemo(()=>Rt(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=p.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=Nt(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]),m=p.useMemo(()=>zt(d,a),[d,a]),h=Xt(d);return p.createElement(p.Fragment,null,f.map(e=>p.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>p.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>p.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Qt(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var $t=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{$t&&(window.__reactRouterVersion=`7.13.1`)}catch{}function en({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=p.useRef();i.current??=b({window:r,v5Compat:!0});let a=i.current,[o,s]=p.useState({action:a.action,location:a.location}),c=p.useCallback(e=>{n===!1?s(e):p.startTransition(()=>s(e))},[n]);return p.useLayoutEffect(()=>a.listen(c),[a,c]),p.createElement(gt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function tn({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=p.useState({action:n.action,location:n.location}),o=p.useCallback(e=>{r===!1?a(e):p.startTransition(()=>a(e))},[r]);return p.useLayoutEffect(()=>n.listen(o),[n,o]),p.createElement(gt,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}tn.displayName=`unstable_HistoryRouter`;var nn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,rn=p.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...m},h){let{basename:g,navigator:_,unstable_useTransitions:v}=p.useContext(P),y=typeof l==`string`&&nn.test(l),b=je(l,g);l=b.to;let x=Ge(l,{relative:r}),S=L(),C=null;if(o){let e=Ce(o,[],S.unstable_mask?S.unstable_mask.pathname:`/`,!0);g!==`/`&&(e.pathname=e.pathname===`/`?g:we([g,e.pathname])),C=_.createHref(e)}let[w,ee,T]=qt(n,m),E=dn(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:v});function te(t){e&&e(t),t.defaultPrevented||E(t)}let D=!(b.isExternal||i),O=p.createElement(`a`,{...m,...T,href:(D?C:void 0)||b.absoluteURL||x,onClick:D?te:e,ref:Qt(h,ee),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return w&&!y?p.createElement(p.Fragment,null,O,p.createElement(Yt,{page:x})):O});rn.displayName=`Link`;var an=p.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=Ye(a,{relative:c.relative}),d=L(),f=p.useContext(Ne),{navigator:m,basename:h}=p.useContext(P),g=f!=null&&bn(u)&&o===!0,_=m.encodeLocation?m.encodeLocation(u).pathname:u.pathname,v=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=M(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,ee;ee=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(C):i;return p.createElement(rn,{...c,"aria-current":w,className:ee,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(C):s)});an.displayName=`NavLink`;var on=p.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=vt,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...m},h)=>{let{unstable_useTransitions:g}=p.useContext(P),_=mn(),v=q(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&nn.test(s);return p.createElement(`form`,{ref:h,method:y,action:v,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,m=()=>_(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});g&&n!==!1?p.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});on.displayName=`Form`;function sn({getKey:e,storageKey:t,...n}){let r=p.useContext(Gt),{basename:i}=p.useContext(P),a=L(),o=lt();vn({getKey:e,storageKey:t});let s=p.useMemo(()=>{if(!r||!e)return null;let t=_n(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 p.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${jt(JSON.stringify(t||hn))}, ${jt(JSON.stringify(s))})`}})}sn.displayName=`ScrollRestoration`;function cn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ln(e){let t=p.useContext(Me);return x(t,cn(e)),t}function un(e){let t=p.useContext(Ne);return x(t,cn(e)),t}function dn(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=Ke(),d=L(),f=Ye(e,{relative:o});return p.useCallback(m=>{if(Ct(m,t)){m.preventDefault();let t=n===void 0?T(d)===T(f):n,h=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?p.startTransition(()=>h()):h()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}var fn=0,pn=()=>`__${String(++fn)}__`;function mn(){let{router:e}=ln(`useSubmit`),{basename:t}=p.useContext(P),n=st(),r=e.fetch,i=e.navigate;return p.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Ot(e,t);a.navigate===!1?await r(a.fetcherKey||pn(),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 q(e,{relative:t}={}){let{basename:n}=p.useContext(P),r=p.useContext(F);x(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...Ye(e||`.`,{relative:t})},o=L();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:we([n,a.pathname])),T(a)}var hn=`react-router-scroll-positions`,gn={};function _n(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:M(e.pathname,n)||e.pathname},t)),i??=e.key,i}function vn({getKey:e,storageKey:t}={}){let{router:n}=ln(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=un(`useScrollRestoration`),{basename:a}=p.useContext(P),o=L(),s=lt(),c=ct();p.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),yn(p.useCallback(()=>{if(c.state===`idle`){let t=_n(o,s,a,e);gn[t]=window.scrollY}try{sessionStorage.setItem(t||hn,JSON.stringify(gn))}catch(e){S(!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`&&(p.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||hn);e&&(gn=JSON.parse(e))}catch{}},[t]),p.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(gn,()=>window.scrollY,e?(t,n)=>_n(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),p.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{S(!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 yn(e,t){let{capture:n}=t||{};p.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function bn(e,{relative:t}={}){let n=p.useContext(Fe);x(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ln(`useViewTransitionState`),i=Ye(e,{relative:t});if(!n.isTransitioning)return!1;let a=M(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=M(n.nextLocation.pathname,r)||n.nextLocation.pathname;return me(i.pathname,o)!=null||me(i.pathname,a)!=null}var xn=`coder-studio.locale`,Sn={en:{appTagline:`Commercial-grade agent operations desk`,languageLabel:`Language`,theme:`Theme`,themeDark:`Dark`,themeLight:`Light`,workspaceLabel:`Workspace`,noWorkspace:`No workspace`,activeCount:({count:e})=>`Active ${e}`,waitingCount:({count:e})=>`Waiting ${e}`,queuedCount:({count:e})=>`Queued ${e}`,newTab:`+ New Tab`,deleteWorkspace:`Delete workspace`,threads:`Threads`,sortByTime:`Sort by time`,sortByName:`Sort by name`,settings:`Settings`,workspaceBrief:`Workspace Brief`,workspaceDescription:`Coordinate AI coding sessions, monitor repo health, and keep terminal control in one operational surface.`,status:`Status`,ready:`Ready`,idle:`Idle`,branch:`Branch`,changes:`Changes`,agent:`Agent`,remoteGit:`Remote Git`,localFolder:`Local Folder`,noCommits:`No commits`,newSession:`New Session`,complete:`Complete`,stop:`Stop`,pool:`Pool`,mode:`Mode`,branchMode:`Branch`,gitTreeMode:`Git Tree`,autoSuspend:`Auto suspend`,idleAfter:`Idle after`,minutesShort:`min`,maxActive:`Max active`,sessionsWord:`sessions`,memoryPressure:`Memory pressure`,sessionDeck:`Session Deck`,sessionsNav:`Sessions`,parallelWorkstreams:`Parallel Workstreams`,tasksCount:({count:e})=>`${e} tasks`,completePercent:({percent:e})=>`${e}% complete`,archive:`Archive`,taskQueue:`Task Queue`,dispatchBoard:`Dispatch Board`,autoFeed:`Auto-feed`,queuePlaceholder:`Add a task to the queue...`,add:`Add`,runNext:`Run Next`,liveTask:`Live task`,noTaskInProgress:`No task in progress`,queueEmpty:`Queue is empty.`,running:`Running`,background:`Background`,waiting:`Waiting`,suspended:`Suspended`,queued:`Queued`,done:`Done`,agentConfiguration:`Agent Configuration`,executionProfile:`Execution Profile`,provider:`Provider`,launchCommand:`Launch command`,launchCommandPlaceholder:`e.g. claude`,launchCommandHint:`Command used when a workspace boots an agent process.`,launchCommandChecking:`Checking command availability...`,launchCommandAvailable:({runtime:e})=>`Available in ${e}`,launchCommandResolvedPath:({path:e})=>`Resolved to ${e}`,launchCommandMissing:({runtime:e})=>`Not found in ${e}`,launchCommandEmpty:`Enter a command to validate the runtime.`,autoSuspendHint:`Automatically suspend idle sessions when capacity needs to be reclaimed.`,idleAfterHint:`How long a session can stay idle before it is suspended.`,maxActiveHint:`Maximum number of concurrently active sessions across workspaces.`,memoryPressureHint:`Allow the app to suspend sessions earlier when the system is under pressure.`,themeHint:`Choose how the application surface is rendered.`,languageHint:`Choose the interface language used across the application.`,worktrees:`Worktrees`,noWorktrees:`No worktrees`,archiveLog:`Archive Log`,noArchiveYet:`No archive yet.`,activityFeed:`Activity Feed`,recentEvents:`Recent Events`,repositoryNavigator:`Repository Navigator`,projectStructure:`Project Structure`,files:`Files`,gitNav:`Git`,refresh:`Refresh`,sourceControl:`Source Control`,stagedChanges:`Staged Changes`,untrackedFiles:`Untracked`,stageFile:`Stage file`,unstageFile:`Unstage file`,discardFile:`Discard changes`,changesCount:({count:e})=>`Changes ${e}`,stagedCount:({count:e})=>`Staged ${e}`,untrackedCount:({count:e})=>`Untracked ${e}`,commitMessage:`Commit Message`,commitPlaceholder:`Describe this change set`,stageAll:`Stage All`,unstageAll:`Unstage All`,discardAll:`Discard All`,commit:`Commit`,gitCommitSucceeded:`Commit created`,gitActionFailed:`Git action failed`,selectProjectToLoadFiles:`Select a project to load files.`,noChangesDetected:`No changes detected.`,modified:`Modified`,liveSession:`Live Session`,liveSessionDescription:`Queue a task or send the next instruction to the agent.`,inputConsole:`Input Console`,inputConsoleHint:`Agent output is read-only here. Send instructions and special keys from the input bar below.`,terminalMode:`Terminal`,inputMode:`Input`,viewingArchivedSession:`Viewing archived session (read-only)`,exitArchiveHint:`Exit archive view to resume live operations.`,exit:`Exit`,agentOutput:`Agent Output`,interactiveCommandStream:`Interactive command stream`,executing:`Executing`,listening:`Listening`,archiveViewReadonly:`Archive view (read-only)`,agentInputPlaceholder:`Type your next instruction...`,draftTaskPlaceholder:`Type to start a new task`,send:`Send`,globalSettings:`Global Settings`,backToApp:`Back to app`,settingsGeneral:`General`,settingsConfiguration:`Configuration`,settingsAppearance:`Appearance`,settingsMcpServers:`MCP Servers`,settingsEnvironment:`Environment`,settingsWorktrees:`Worktrees`,settingsArchives:`Archived Threads`,settingsDescription:`Configure agent defaults and suspend policy for every workspace from one place.`,settingsAutoSave:`Changes save automatically.`,appliesToAllWorkspaces:`Applies to all workspaces`,changesAffectNextLaunch:`Agent changes affect the next launch. Suspend policy updates immediately.`,agentDefaults:`Agent Defaults`,agentDefaultsHint:`Choose the provider and launch command used when a workspace starts or an agent restarts.`,suspendStrategy:`Suspend Strategy`,suspendStrategyHint:`Keep active capacity predictable by automatically yielding idle sessions when the pool is busy.`,applySettings:`Apply Settings`,save:`Save`,unsavedChanges:`Unsaved changes`,saved:`Saved`,editorReady:`Editable editor`,editorHint:`VS Code-style editing surface with direct file save.`,repositoryInspector:`Repository Inspector`,collapseCodePanel:`Collapse code panel`,expandCodePanel:`Expand code panel`,codePanel:`Code`,terminalPanel:`Terminal`,selectFileFromNavigator:`Select a file from the navigator`,preview:`Preview`,diff:`Diff`,filesStat:({count:e,additions:t,deletions:n})=>`Files ${e} · +${t} / -${n}`,noPreviewAvailable:`No preview available.`,noDiffAvailable:`No diff available.`,shellDock:`Shell Dock`,projectTerminal:`Project Terminal`,new:`New`,noTerminalYet:`No terminal yet.`,loading:`Loading`,slashMenu:`Insert Claude Command`,slashBuiltins:`Built-in Commands`,slashBundledSkills:`Bundled Skills`,slashProjectSkills:`Workspace Skills`,slashPersonalSkills:`Personal Skills`,slashMenuEmpty:`No Claude commands or skills found.`,slashSkillBadge:`skill`,slashCommandBadge:`cmd`,close:`Close`,splitVertical:`Split Vertically`,splitHorizontal:`Split Horizontally`,splitVerticalDescription:`Split current agent pane into left and right`,splitHorizontalDescription:`Split current agent pane into top and bottom`,statusTab:`Status`,treeTab:`Tree`,loadingWorktreeDetails:`Loading worktree details...`,path:`Path`,clean:`Clean`,launchWorkspace:`Launch Workspace`,launchWorkspaceTitle:`Attach a local workspace for agent-driven coding`,launchWorkspaceDescription:`Pick an existing local repository, connect your preferred CLI agent, and start parallel coding sessions with live Git visibility.`,sessionsCard:`Sessions`,parallelAgentTracks:`Parallel agent tracks`,gitCard:`Git`,liveDiffAndWorktree:`Live diff + worktree context`,terminalCard:`Terminal`,embeddedShellControl:`Embedded shell control`,remoteGitHint:`Clone to a managed workspace and begin immediately.`,localFolderHint:`Attach an existing project folder as your live workspace.`,nativeTarget:`Native`,nativeTargetHint:`Use the host shell runtime.`,wslHint:`Route Git and agent commands through WSL.`,optionalDistroPlaceholder:`Optional distro name (e.g. Ubuntu-22.04)`,folderBrowserRecovered:`The previous location is unavailable. Showing a valid server directory instead.`,homeDirectory:`Home`,goUp:`Up`,useCurrentFolder:`Use Current Folder`,loadingDirectories:`Loading server directories...`,emptyDirectories:`No subdirectories in this location`,folderBrowserInteractionHint:`Click a folder to enter and select it.`,folderBrowserRowHint:`Click to enter`,enterFolder:`Enter`,pasteGitUrl:`Paste a Git URL`,selectFolder:`Select Folder`,selected:`Selected`,notSelected:`Not selected`,cancel:`Cancel`,startWorkspace:`Start Workspace`,initializeWorkspace:`Initialize Workspace`,selectFolderDialog:`Select Folder`,noFolderSelected:`No folder selected`,dialogFailed:`Dialog failed`,selectProjectFirst:`Select a project first`,agentStartFailed:`Agent start failed`,agentSendFailed:`Agent send failed`,agentKeySendFailed:`Agent key send failed`,taskCompleteMessage:({text:e})=>`Task complete: ${e}`,taskCompletedToast:({title:e})=>`${e} completed`,taskStopped:`Task stopped`,workingOn:({text:e})=>`Working on: ${e}`,draftSessionTitle:`New Session`,draftSessionPrompt:`Start here`,draftSessionWorkspace:({path:e})=>`Workspace: ${e}`,previewUnavailable:`Preview unavailable.`,agentExited:`Agent exited`,escKey:`Esc`,tabKey:`Tab`,enterKey:`Enter`,arrowUp:`Up`,arrowDown:`Down`,arrowLeft:`Left`,arrowRight:`Right`,poolSummary:({active:e,max:t,queued:n})=>`Active ${e} / ${t} • Queued ${n}`,authPublicModeBadge:`Public Mode`,authLoadingTitle:`Checking access`,authLoadingDescription:`Verifying deployment mode and session state before the workspace loads.`,authTitle:`Unlock Coder Studio`,authDescription:`This deployment is protected by a single access passphrase. Enter it to continue.`,authAllowedRoots:`Allowed roots`,authAllowedRootsHint:`After sign-in, only the folders in this list can be opened from the browser.`,authAllowedRootsEmpty:`No allowed roots are configured yet.`,authIdleWindow:`Idle timeout`,authSessionWindow:`Session max`,authPasswordLabel:`Access passphrase`,authPasswordPlaceholder:`Enter passphrase`,authShowPassword:`Show`,authHidePassword:`Hide`,authLogin:`Enter workspace`,authLoggingIn:`Checking…`,authInvalidCredentials:`That passphrase is incorrect.`,authBlockedUntil:({time:e})=>`Too many failed attempts. Try again after ${e}.`,authSessionExpired:`Your session expired. Sign in again to continue.`,authNotConfigured:`Set the passphrase in auth.json before public mode can be used.`,authNotConfiguredTitle:`Passphrase is not configured yet`,authNotConfiguredDescription:`Set the password field in auth.json, then retry the status check from this screen.`,authSetupHint:`If login is unavailable, check auth.json and make sure the password field is configured.`,authSecureTransportRequired:`HTTPS is required before the passphrase can be submitted from this host.`,authTransportRequiredTitle:`HTTPS is required on this host`,authTransportRequiredDescription:`This deployment only accepts the passphrase over an encrypted connection when accessed remotely.`,authBlockedTitle:`This IP is temporarily blocked`,authBlockedDescription:({time:e})=>`Too many failed attempts were recorded from this IP. Access resumes after ${e}.`,authUnavailable:`Authentication is temporarily unavailable. Check the transport service and try again.`,authUnavailableTitle:`Authentication service is unavailable`,authUnavailableDescription:`The service could not confirm the current session. Retry after the transport service is healthy.`,authRetry:`Retry check`,authRefreshing:`Refreshing…`,authUnlockingBadge:`Ready`,authUnlockingTitle:`Access granted`,authUnlockingDescription:`Loading the workbench and restoring your session.`},zh:{appTagline:`商业级智能体协同工作台`,languageLabel:`语言`,theme:`主题`,themeDark:`深色`,themeLight:`浅色`,workspaceLabel:`工作区`,noWorkspace:`未选择工作区`,activeCount:({count:e})=>`活跃 ${e}`,waitingCount:({count:e})=>`等待 ${e}`,queuedCount:({count:e})=>`排队 ${e}`,newTab:`+ 新建标签`,deleteWorkspace:`删除工作区`,threads:`线程`,sortByTime:`按时间排序`,sortByName:`按名称排序`,settings:`设置`,workspaceBrief:`工作区概览`,workspaceDescription:`把 AI 编码会话、仓库健康度和终端控制收拢到同一个作业界面里。`,status:`状态`,ready:`就绪`,idle:`空闲`,branch:`分支`,changes:`变更`,agent:`智能体`,remoteGit:`远程仓库`,localFolder:`本地目录`,noCommits:`暂无提交`,newSession:`新建会话`,complete:`完成`,stop:`停止`,pool:`资源池`,mode:`模式`,branchMode:`分支`,gitTreeMode:`工作树`,autoSuspend:`自动挂起`,idleAfter:`空闲后`,minutesShort:`分钟`,maxActive:`最大活跃数`,sessionsWord:`个会话`,memoryPressure:`内存压力`,sessionDeck:`会话面板`,sessionsNav:`会话`,parallelWorkstreams:`并行工作流`,tasksCount:({count:e})=>`${e} 个任务`,completePercent:({percent:e})=>`完成 ${e}%`,archive:`归档`,taskQueue:`任务队列`,dispatchBoard:`派发面板`,autoFeed:`自动投喂`,queuePlaceholder:`向队列添加任务...`,add:`添加`,runNext:`运行下一项`,liveTask:`实时任务`,noTaskInProgress:`当前没有进行中的任务`,queueEmpty:`队列为空。`,running:`执行中`,background:`后台`,waiting:`等待`,suspended:`挂起`,queued:`排队中`,done:`已完成`,agentConfiguration:`智能体配置`,executionProfile:`执行配置`,provider:`提供方`,launchCommand:`启动命令`,launchCommandPlaceholder:`例如 claude`,launchCommandHint:`工作区启动智能体进程时使用的命令。`,launchCommandChecking:`正在检查命令是否可用…`,launchCommandAvailable:({runtime:e})=>`${e} 中可用`,launchCommandResolvedPath:({path:e})=>`解析路径:${e}`,launchCommandMissing:({runtime:e})=>`${e} 中未找到该命令`,launchCommandEmpty:`输入命令后会自动检测当前运行时。`,autoSuspendHint:`当容量需要回收时,自动挂起空闲会话。`,idleAfterHint:`会话在被挂起前允许保持空闲的时长。`,maxActiveHint:`所有工作区内允许同时活跃的会话上限。`,memoryPressureHint:`当系统资源紧张时,允许更早挂起空闲会话。`,themeHint:`选择应用整体的外观主题。`,languageHint:`选择整个应用界面使用的语言。`,worktrees:`工作树`,noWorktrees:`暂无工作树`,archiveLog:`归档记录`,noArchiveYet:`暂无归档。`,activityFeed:`活动流`,recentEvents:`最近事件`,repositoryNavigator:`仓库导航`,projectStructure:`项目结构`,files:`文件`,gitNav:`Git`,refresh:`刷新`,sourceControl:`源码管理`,stagedChanges:`已暂存更改`,untrackedFiles:`未跟踪`,stageFile:`暂存文件`,unstageFile:`取消暂存`,discardFile:`放弃更改`,changesCount:({count:e})=>`更改 ${e}`,stagedCount:({count:e})=>`已暂存 ${e}`,untrackedCount:({count:e})=>`未跟踪 ${e}`,commitMessage:`提交说明`,commitPlaceholder:`输入本次变更说明`,stageAll:`全部暂存`,unstageAll:`取消暂存`,discardAll:`全部回退`,commit:`提交`,gitCommitSucceeded:`已创建提交`,gitActionFailed:`Git 操作失败`,selectProjectToLoadFiles:`先选择项目再加载文件。`,noChangesDetected:`未检测到变更。`,modified:`已修改`,liveSession:`实时会话`,liveSessionDescription:`可以先排任务,或直接给智能体发送下一条指令。`,inputConsole:`输入控制台`,inputConsoleHint:`这里的智能体输出为只读,所有指令和特殊按键都从下方输入栏发送。`,terminalMode:`终端`,inputMode:`输入框`,viewingArchivedSession:`正在查看归档会话(只读)`,exitArchiveHint:`退出归档视图后即可恢复实时操作。`,exit:`退出`,agentOutput:`智能体输出`,interactiveCommandStream:`交互命令流`,executing:`执行中`,listening:`监听中`,archiveViewReadonly:`归档视图(只读)`,agentInputPlaceholder:`输入下一条指令...`,draftTaskPlaceholder:`请输入内容开启新任务`,send:`发送`,globalSettings:`全局设置`,backToApp:`返回应用`,settingsGeneral:`常规`,settingsConfiguration:`配置`,settingsAppearance:`个性化`,settingsMcpServers:`MCP 服务器`,settingsEnvironment:`环境`,settingsWorktrees:`工作树`,settingsArchives:`已归档线程`,settingsDescription:`在一个面板里统一配置所有工作区的智能体默认值和挂起策略。`,settingsAutoSave:`修改后会自动保存。`,appliesToAllWorkspaces:`作用于全部工作区`,changesAffectNextLaunch:`智能体配置在下次启动时生效,挂起策略会立即同步。`,agentDefaults:`智能体默认值`,agentDefaultsHint:`设置工作区启动或智能体重启时使用的提供方和启动命令。`,suspendStrategy:`挂起策略`,suspendStrategyHint:`在会话池繁忙时自动让空闲会话让出容量,保证活跃并发可控。`,applySettings:`应用设置`,save:`保存`,unsavedChanges:`未保存修改`,saved:`已保存`,editorReady:`可编辑编辑器`,editorHint:`基于 VS Code 风格的编辑界面,可直接保存文件。`,repositoryInspector:`仓库检查器`,collapseCodePanel:`收起代码区域`,expandCodePanel:`展开代码区域`,codePanel:`代码`,terminalPanel:`终端`,selectFileFromNavigator:`从导航中选择一个文件`,preview:`预览`,diff:`差异`,filesStat:({count:e,additions:t,deletions:n})=>`文件 ${e} · +${t} / -${n}`,noPreviewAvailable:`暂无可预览内容。`,noDiffAvailable:`暂无差异。`,shellDock:`终端停靠区`,projectTerminal:`项目终端`,new:`新建`,noTerminalYet:`还没有终端。`,loading:`加载中`,slashMenu:`插入 Claude 命令`,slashBuiltins:`内置命令`,slashBundledSkills:`内置技能`,slashProjectSkills:`工作区技能`,slashPersonalSkills:`个人技能`,slashMenuEmpty:`未发现 Claude 命令或技能。`,slashSkillBadge:`技能`,slashCommandBadge:`命令`,close:`关闭`,splitVertical:`垂直拆分`,splitHorizontal:`水平拆分`,splitVerticalDescription:`将当前智能体面板拆分为左右两栏`,splitHorizontalDescription:`将当前智能体面板拆分为上下两栏`,statusTab:`状态`,treeTab:`目录`,loadingWorktreeDetails:`正在加载工作树详情...`,path:`路径`,clean:`干净`,launchWorkspace:`启动工作区`,launchWorkspaceTitle:`接入本地工作区并启动智能体协作编码`,launchWorkspaceDescription:`选择一个现有本地仓库,接入你偏好的 CLI 智能体,并在可见 Git 状态下开启并行编码会话。`,sessionsCard:`会话`,parallelAgentTracks:`并行智能体轨道`,gitCard:`Git`,liveDiffAndWorktree:`实时差异与工作树上下文`,terminalCard:`终端`,embeddedShellControl:`内嵌 Shell 控制`,remoteGitHint:`克隆到托管工作区并立即开始。`,localFolderHint:`把现有项目目录接入为实时工作区。`,nativeTarget:`系统`,nativeTargetHint:`使用宿主机 Shell 运行时。`,wslHint:`通过 WSL 执行 Git 和智能体命令。`,optionalDistroPlaceholder:`可选发行版名称(如 Ubuntu-22.04)`,folderBrowserRecovered:`上次的位置已不可用,当前已切换到可读取的服务端目录。`,homeDirectory:`主目录`,goUp:`上一级`,useCurrentFolder:`使用当前目录`,loadingDirectories:`正在读取服务端目录…`,emptyDirectories:`当前目录下没有可进入的子目录`,folderBrowserInteractionHint:`点击目录即可进入并选中。`,folderBrowserRowHint:`点击进入`,enterFolder:`进入`,pasteGitUrl:`粘贴 Git 地址`,selectFolder:`选择文件夹`,selected:`已选择`,notSelected:`未选择`,cancel:`取消`,startWorkspace:`开始工作区`,initializeWorkspace:`初始化工作区`,selectFolderDialog:`选择文件夹`,noFolderSelected:`未选择文件夹`,dialogFailed:`对话框打开失败`,selectProjectFirst:`请先选择项目`,agentStartFailed:`智能体启动失败`,agentSendFailed:`发送给智能体失败`,agentKeySendFailed:`按键发送失败`,taskCompleteMessage:({text:e})=>`任务完成:${e}`,taskCompletedToast:({title:e})=>`${e} 已完成`,taskStopped:`任务已停止`,workingOn:({text:e})=>`正在处理:${e}`,draftSessionTitle:`新会话`,draftSessionPrompt:`请开始`,draftSessionWorkspace:({path:e})=>`当前工作区:${e}`,previewUnavailable:`无法预览。`,agentExited:`智能体已退出`,escKey:`退出`,tabKey:`制表`,enterKey:`回车`,arrowUp:`上`,arrowDown:`下`,arrowLeft:`左`,arrowRight:`右`,poolSummary:({active:e,max:t,queued:n})=>`活跃 ${e} / ${t} • 排队 ${n}`,authPublicModeBadge:`公开访问模式`,authLoadingTitle:`正在校验访问状态`,authLoadingDescription:`在工作区加载前,先确认当前部署模式和会话状态。`,authTitle:`解锁 Coder Studio`,authDescription:`当前部署已启用单口令保护,请输入访问口令后继续。`,authAllowedRoots:`允许目录`,authAllowedRootsHint:`登录后,浏览器只能打开这份白名单中的目录。`,authAllowedRootsEmpty:`当前还没有配置任何可访问目录。`,authIdleWindow:`空闲超时`,authSessionWindow:`会话上限`,authPasswordLabel:`访问口令`,authPasswordPlaceholder:`请输入访问口令`,authShowPassword:`显示`,authHidePassword:`隐藏`,authLogin:`进入工作区`,authLoggingIn:`校验中…`,authInvalidCredentials:`访问口令不正确。`,authBlockedUntil:({time:e})=>`失败次数过多,请在 ${e} 后重试。`,authSessionExpired:`当前会话已过期,请重新输入口令。`,authNotConfigured:`请先在 auth.json 中设置访问口令,再使用公开访问模式。`,authNotConfiguredTitle:`当前还没有配置访问口令`,authNotConfiguredDescription:`请先在 auth.json 中设置 password 字段,然后回到这里重新检查状态。`,authSetupHint:`如果当前无法登录,请先检查 auth.json,确认 password 字段已经设置。`,authSecureTransportRequired:`当前主机必须启用 HTTPS,才能安全提交访问口令。`,authTransportRequiredTitle:`当前主机必须使用 HTTPS`,authTransportRequiredDescription:`远程访问这个部署时,只允许通过加密连接提交访问口令。`,authBlockedTitle:`当前 IP 已被临时封禁`,authBlockedDescription:({time:e})=>`这个 IP 的失败次数过多,请在 ${e} 后再试。`,authUnavailable:`鉴权服务暂时不可用,请检查传输服务后重试。`,authUnavailableTitle:`鉴权服务当前不可用`,authUnavailableDescription:`系统暂时无法确认当前会话,请在传输服务恢复后重新检查。`,authRetry:`重新检查`,authRefreshing:`检查中…`,authUnlockingBadge:`就绪`,authUnlockingTitle:`访问已通过`,authUnlockingDescription:`正在载入工作台并恢复当前会话。`}},Cn=()=>{if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(xn);return e===`en`||e===`zh`?e:null}catch{return null}},wn=()=>Cn()||(typeof navigator<`u`&&navigator.language.toLowerCase().startsWith(`zh`)?`zh`:`en`),Tn=e=>{typeof document<`u`&&(document.documentElement.lang=e===`zh`?`zh-CN`:`en`)},En=e=>{if(typeof window<`u`)try{window.localStorage.setItem(xn,e)}catch{}Tn(e)},Dn=e=>(t,n={})=>{let r=Sn[e][t]??Sn.en[t];return typeof r==`function`?r(n):r},On=e=>typeof e==`string`?e:String(e).padStart(2,`0`),kn=(e,t)=>t===`zh`?`会话 ${On(e)}`:`Session ${On(e)}`,An=(e,t)=>t===`zh`?`工作区 ${On(e)}`:`Workspace ${On(e)}`,jn=(e,t)=>t===`zh`?`终端 ${e}`:`Terminal ${e}`,Mn=(e,t)=>t===`zh`?`${kn(e,t)} 已就绪。`:`${kn(e,t)} is ready.`,Nn=(e,t)=>{for(let n of t){let t=e.match(n);if(t?.[1])return t[1]}return null},Pn=(e,t)=>{let n=Nn(e,[/^Session (\d+)$/,/^会话 (\d+)$/]);return n?kn(n,t):e},Fn=(e,t)=>{let n=Nn(e,[/^Workspace (\d+)$/,/^工作区 (\d+)$/]);return n?An(n,t):e},In=(e,t)=>{let n=Nn(e,[/^Terminal (\d+)$/,/^终端 (\d+)$/]);return n?jn(n,t):e},Ln=`http://127.0.0.1:41033`,Rn=`5174`,zn=e=>{let t=e.trim();if(!t)return``;try{return(typeof window<`u`?new URL(t,window.location.origin):new URL(t)).origin.replace(/\/+$/,``)}catch{return t.replace(/\/+$/,``)}},Bn=()=>typeof window>`u`?``:zn(window.__CODER_STUDIO_BACKEND__??``),Vn=()=>{if(typeof window>`u`)return!1;let e=window.location.hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`},Hn=()=>{if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).get(`auth`)===`force`}catch{return!1}},Un=e=>(Hn()&&e.searchParams.set(`auth`,`force`),e),Wn=()=>typeof window<`u`&&!!window.__TAURI_INTERNALS__,Gn=()=>typeof window>`u`?!1:Wn()&&Vn()&&window.location.port===Rn,Kn=()=>typeof window>`u`?``:Bn()||(Gn()?Ln:zn(window.location.origin)),qn=()=>{let e=Kn(),t=new URL(e||(typeof window<`u`?window.location.origin:`http://127.0.0.1`));return t.pathname=`/health`,t.search=``,t.hash=``,Un(t).toString()},Jn=()=>{let e=Kn(),t=new URL(e||(typeof window<`u`?window.location.origin:`http://127.0.0.1`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.pathname=`/ws`,t.search=``,t.hash=``,Un(t).toString()},Yn={public_mode:!1,authenticated:!0,password_configured:!0,local_host:!1,secure_transport_required:!1,secure_transport_ok:!0,session_idle_minutes:15,session_max_hours:12,allowed_roots:[]},Xn=new Set,Zn=new Set,Qn=Yn,$n=!1,er=null,tr=class extends Error{code;status;blockedUntil;constructor(e,t,n){super(e),this.name=`AuthRequestError`,this.code=e,this.status=t,this.blockedUntil=n}},nr=()=>typeof window>`u`?!1:window.location.protocol===`http:`||window.location.protocol===`https:`,rr=()=>nr()&&Vn(),ir=()=>nr()&&!rr()||Hn(),ar=e=>Un(new URL(e,`${Kn()}/`)).toString(),or=()=>{Xn.forEach(e=>e(Qn))},sr=e=>{Qn=e,$n=!0,or()},cr=()=>({...Yn,public_mode:!1,authenticated:!0,local_host:!1}),lr=()=>Wn()&&!ir(),ur=async(e,t)=>{let n=await fetch(ar(e),{cache:`no-store`,credentials:`include`,...t,headers:{"content-type":`application/json`,...t?.headers??{}}}),r={};try{r=await n.json()}catch{}if(!n.ok||r.ok===!1)throw new tr(r.error||`HTTP ${n.status}`,n.status,r.blocked_until);return r.data},dr=()=>Qn,fr=()=>$n?Qn.public_mode:ir(),pr=()=>fr()?$n?Qn.authenticated:!1:!0,mr=()=>er,hr=()=>{er=null},gr=e=>(Xn.add(e),()=>{Xn.delete(e)}),_r=e=>(Zn.add(e),()=>{Zn.delete(e)}),vr=e=>{fr()&&(er=e,sr({...Qn,public_mode:!0,authenticated:!1}),Zn.forEach(t=>t(e)))},yr=async()=>{try{let e=await ur(`/api/auth/status`,{method:`GET`});return sr(e),e}catch(e){if(lr()){let e=cr();return sr(e),e}throw sr({...Qn,public_mode:!0,authenticated:!1}),e}},br=async e=>{let t=await ur(`/api/auth/login`,{method:`POST`,body:JSON.stringify({password:e})});return er=null,sr(t),t},xr=(e,t)=>!e||t.startsWith(e)||t.startsWith(`/`)||t.includes(`:`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}/${t.startsWith(`/`)?t.slice(1):t}`,Sr=e=>e.replace(/\\/g,`/`),Cr=e=>Sr(e).replace(/^[:/\\]+/,``),wr=(e,t)=>{let n=Sr(e),r=Sr(t);return n===r||n.endsWith(`/${r}`)},Tr=e=>/^[a-zA-Z]:[\\/]/.test(e),Er=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`).split(`/`);return t.pop(),t.join(`/`)},Dr=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return e;let n=t.split(`/`).filter(Boolean);return n[n.length-1]??t},J=t(),Or=180,kr=(e,t)=>{if(!e)return``;try{return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e}};function Ar({locale:e,onSelectLocale:t,children:n}){let r=(0,p.useMemo)(()=>Dn(e),[e]),[i,a]=(0,p.useState)(()=>dr()),[o,s]=(0,p.useState)(!0),[c,l]=(0,p.useState)(!1),[u,d]=(0,p.useState)(``),[f,m]=(0,p.useState)(!1),[h,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(!1),[y,b]=(0,p.useState)(()=>mr()),[x,S]=(0,p.useState)(),C=e=>{if(a(e=>({...e,public_mode:!0,authenticated:!1})),e instanceof tr){b(e.code),S(e.blockedUntil);return}b(`auth_unavailable`)},w=async()=>{l(!0);try{let e=await yr();return a(e),b(null),S(void 0),e}catch(e){return C(e),null}finally{l(!1)}};(0,p.useEffect)(()=>gr(e=>a(e)),[]),(0,p.useEffect)(()=>_r(e=>{b(e),g(!1),v(!1)}),[]),(0,p.useEffect)(()=>{let e=!0;return s(!0),yr().then(t=>{e&&(a(t),b(null),S(void 0))}).catch(t=>{e&&C(t)}).finally(()=>{e&&s(!1)}),()=>{e=!1}},[]),(0,p.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{v(!1)},Or);return()=>{window.clearTimeout(e)}},[_]),(0,p.useEffect)(()=>{i.authenticated||v(!1)},[i.authenticated]);let ee=async e=>{if(e.preventDefault(),!(h||!u.trim())){if(hr(),g(!0),b(null),S(void 0),!i.password_configured){b(`auth_not_configured`),g(!1);return}try{let e=await br(u.trim());a(e),d(``),m(!1),e.authenticated&&v(!0)}catch(e){e instanceof tr?(b(e.code),S(e.blockedUntil)):b(`auth_unavailable`)}finally{g(!1)}}},T=(0,J.jsxs)(`div`,{className:`settings-pill-select auth-locale-switch`,"aria-label":r(`languageLabel`),children:[(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`zh`?`active`:``}`,onClick:()=>t(`zh`),children:`中文`}),(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`en`?`active`:``}`,onClick:()=>t(`en`),children:`English`})]}),E=(0,J.jsxs)(`div`,{className:`auth-preview-shell`,"aria-hidden":`true`,children:[(0,J.jsxs)(`header`,{className:`topbar auth-preview-topbar`,children:[(0,J.jsx)(`div`,{className:`topbar-left`,children:(0,J.jsxs)(`div`,{className:`app-title auth-preview-brand`,children:[(0,J.jsx)(`span`,{className:`auth-preview-dot`}),(0,J.jsx)(`span`,{children:`CODER STUDIO`})]})}),(0,J.jsx)(`div`,{className:`topbar-center`,children:(0,J.jsxs)(`div`,{className:`topbar-session-strip topbar-workspace-strip auth-preview-tabs`,children:[(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab active`,children:[(0,J.jsx)(`span`,{className:`session-top-dot active`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`checkout-api`})]}),(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab`,children:[(0,J.jsx)(`span`,{className:`session-top-dot idle`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`release-note`})]}),(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab running-glow`,children:[(0,J.jsx)(`span`,{className:`session-top-dot active pulse`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`deploy-guard`})]})]})}),(0,J.jsxs)(`div`,{className:`topbar-actions`,children:[(0,J.jsx)(`span`,{className:`topbar-tool topbar-tool-wide auth-preview-tool`,children:(0,J.jsx)(`span`,{children:e===`zh`?`操作`:`Actions`})}),(0,J.jsx)(`span`,{className:`topbar-tool auth-preview-tool-square`})]})]}),(0,J.jsxs)(`div`,{className:`workspace-layout auth-preview-layout`,children:[(0,J.jsxs)(`aside`,{className:`panel left-panel auth-preview-panel`,children:[(0,J.jsx)(`div`,{className:`sidebar-header`,children:(0,J.jsx)(`span`,{className:`sidebar-title`,children:e===`zh`?`会话`:`Sessions`})}),(0,J.jsxs)(`div`,{className:`sidebar-content auth-preview-panel-body`,children:[(0,J.jsx)(`span`,{className:`auth-preview-label`}),(0,J.jsx)(`span`,{className:`auth-preview-line wide`}),(0,J.jsx)(`span`,{className:`auth-preview-line`}),(0,J.jsxs)(`div`,{className:`auth-preview-stack`,children:[(0,J.jsx)(`span`,{className:`auth-preview-block`}),(0,J.jsx)(`span`,{className:`auth-preview-block`}),(0,J.jsx)(`span`,{className:`auth-preview-block`})]})]})]}),(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`left`}),(0,J.jsxs)(`main`,{className:`workspace-main auth-preview-main`,children:[(0,J.jsxs)(`div`,{className:`auth-preview-main-bar`,children:[(0,J.jsx)(`span`,{className:`auth-preview-chip wide`}),(0,J.jsx)(`span`,{className:`auth-preview-chip`}),(0,J.jsx)(`span`,{className:`auth-preview-chip short`})]}),(0,J.jsxs)(`div`,{className:`auth-preview-main-grid`,children:[(0,J.jsx)(`span`,{className:`auth-preview-surface large`}),(0,J.jsx)(`span`,{className:`auth-preview-surface`}),(0,J.jsx)(`span`,{className:`auth-preview-surface`})]})]}),(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`right`}),(0,J.jsxs)(`aside`,{className:`panel right-panel auth-preview-panel auth-preview-panel-right`,children:[(0,J.jsx)(`div`,{className:`panel-header`,children:(0,J.jsx)(`span`,{className:`panel-title`,children:e===`zh`?`终端`:`Terminal`})}),(0,J.jsxs)(`div`,{className:`panel-body auth-preview-panel-body`,children:[(0,J.jsx)(`span`,{className:`auth-preview-line`}),(0,J.jsx)(`span`,{className:`auth-preview-line short`}),(0,J.jsxs)(`div`,{className:`auth-preview-stack compact`,children:[(0,J.jsx)(`span`,{className:`auth-preview-card`}),(0,J.jsx)(`span`,{className:`auth-preview-card`}),(0,J.jsx)(`span`,{className:`auth-preview-card`})]})]})]})]})]});if(o)return(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-loading`,role:`status`,"aria-live":`polite`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsx)(`div`,{className:`auth-badge-stack`,children:(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)})}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{children:r(`authLoadingTitle`)}),(0,J.jsx)(`p`,{children:r(`authLoadingDescription`)})]}),(0,J.jsxs)(`div`,{className:`auth-loading-stack`,children:[(0,J.jsx)(`span`,{className:`auth-loading-line wide`}),(0,J.jsx)(`span`,{className:`auth-loading-line`}),(0,J.jsx)(`span`,{className:`auth-loading-line short`})]})]})})})]});if(!i.public_mode||i.authenticated&&!_)return(0,J.jsx)(J.Fragment,{children:n});let te=kr(x,e),D=!i.password_configured||y===`auth_not_configured`?`not-configured`:y===`ip_blocked`?`blocked`:y===`auth_unavailable`?`unavailable`:`sign-in`,O=y===`invalid_credentials`?r(`authInvalidCredentials`):y===`session_expired`||y===`session_missing`?r(`authSessionExpired`):``,ne=D===`sign-in`?r(`authAllowedRootsHint`):D===`blocked`?r(`authBlockedUntil`,{time:te||`—`}):r(D===`unavailable`?`authUnavailable`:`authSetupHint`),re=h||c||D!==`sign-in`,ie=D!==`sign-in`,ae=i.allowed_roots.map(e=>({path:e,label:Dr(e)||e})),oe=``,se=``,k=`neutral`,A=!1;return D===`not-configured`?(oe=r(`authNotConfiguredTitle`),se=r(`authNotConfiguredDescription`),k=`warning`,A=!0):D===`blocked`?(oe=r(`authBlockedTitle`),se=r(`authBlockedDescription`,{time:te||`—`}),k=`danger`):D===`unavailable`&&(oe=r(`authUnavailableTitle`),se=r(`authUnavailableDescription`),k=`danger`,A=!0),i.authenticated&&_?(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-transition`,role:`status`,"aria-live":`polite`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsxs)(`div`,{className:`auth-badge-stack`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),(0,J.jsx)(`span`,{className:`auth-state-pill success`,children:r(`authUnlockingBadge`)})]}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{children:r(`authUnlockingTitle`)}),(0,J.jsx)(`p`,{children:r(`authUnlockingDescription`)})]}),(0,J.jsx)(`div`,{className:`surface-progress loading auth-transition-progress`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`82%`}})})]})})})]}):(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-form`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`auth-title`,"aria-describedby":`auth-description`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsxs)(`div`,{className:`auth-badge-stack`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),D===`not-configured`?(0,J.jsx)(`span`,{className:`auth-state-pill warning`,children:`auth.json`}):null,D===`blocked`?(0,J.jsx)(`span`,{className:`auth-state-pill danger`,children:`IP`}):null]}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{id:`auth-title`,children:r(`authTitle`)}),(0,J.jsx)(`p`,{id:`auth-description`,children:r(`authDescription`)})]}),(0,J.jsxs)(`div`,{className:`auth-summary`,"aria-label":r(`authPublicModeBadge`),children:[(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authAllowedRoots`)}),(0,J.jsx)(`strong`,{children:i.allowed_roots.length})]}),(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authIdleWindow`)}),(0,J.jsxs)(`strong`,{children:[i.session_idle_minutes,`m`]})]}),(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authSessionWindow`)}),(0,J.jsxs)(`strong`,{children:[i.session_max_hours,`h`]})]})]}),ie?(0,J.jsxs)(`div`,{className:`auth-state-panel ${k}`,role:`status`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`auth-state-copy`,children:[(0,J.jsx)(`div`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),(0,J.jsx)(`h2`,{children:oe}),(0,J.jsx)(`p`,{children:se})]}),A?(0,J.jsx)(`button`,{type:`button`,className:`btn auth-secondary-action`,onClick:()=>{w()},disabled:c,children:r(c?`authRefreshing`:`authRetry`)}):null]}):null,(0,J.jsxs)(`div`,{className:`auth-block`,children:[(0,J.jsx)(`div`,{className:`auth-block-header`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`section-kicker`,children:r(`authAllowedRoots`)}),(0,J.jsx)(`p`,{children:r(`authAllowedRootsHint`)})]})}),(0,J.jsx)(`div`,{className:`auth-roots-list`,role:`list`,"aria-label":r(`authAllowedRoots`),children:ae.length>0?ae.map(e=>(0,J.jsxs)(`div`,{className:`auth-root-item`,role:`listitem`,title:e.path,children:[(0,J.jsx)(`strong`,{children:e.label}),(0,J.jsx)(`span`,{children:e.path})]},e.path)):(0,J.jsx)(`p`,{className:`auth-root-empty`,children:r(`authAllowedRootsEmpty`)})})]}),D===`sign-in`?(0,J.jsxs)(`form`,{className:`auth-form`,onSubmit:ee,children:[(0,J.jsxs)(`label`,{className:`auth-field`,children:[(0,J.jsxs)(`div`,{className:`auth-field-row`,children:[(0,J.jsx)(`span`,{children:r(`authPasswordLabel`)}),(0,J.jsx)(`button`,{type:`button`,className:`auth-visibility-toggle`,onClick:()=>m(e=>!e),disabled:re,"aria-label":r(f?`authHidePassword`:`authShowPassword`),"aria-pressed":f,children:r(f?`authHidePassword`:`authShowPassword`)})]}),(0,J.jsx)(`div`,{className:`auth-input-shell`,children:(0,J.jsx)(`input`,{autoFocus:!0,autoComplete:`current-password`,className:`auth-input`,type:f?`text`:`password`,value:u,onChange:e=>d(e.target.value),placeholder:r(`authPasswordPlaceholder`),disabled:re,"aria-invalid":y===`invalid_credentials`})})]}),(0,J.jsx)(`div`,{className:`auth-message-slot ${O?`has-message`:``}`,"aria-live":`polite`,children:O?(0,J.jsx)(`div`,{className:`auth-message error`,role:`alert`,children:O}):null}),(0,J.jsxs)(`div`,{className:`auth-form-footer`,children:[(0,J.jsx)(`p`,{className:`auth-support-copy`,children:ne}),(0,J.jsx)(`button`,{className:`btn primary btn-lg auth-submit`,type:`submit`,disabled:h||!u.trim(),children:r(h?`authLoggingIn`:`authLogin`)})]})]}):(0,J.jsx)(`div`,{className:`auth-form-footer auth-form-footer-static`,children:(0,J.jsx)(`p`,{className:`auth-support-copy`,children:ne})})]})})})]})}var jr=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Mr=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Nr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Pr=e=>{let t=Nr(e);return t.charAt(0).toUpperCase()+t.slice(1)},Fr={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ir=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Lr=(0,p.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,p.createElement)(`svg`,{ref:c,...Fr,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:jr(`lucide`,i),...!a&&!Ir(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,p.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Y=(e,t)=>{let n=(0,p.forwardRef)(({className:n,...r},i)=>(0,p.createElement)(Lr,{ref:i,iconNode:t,className:jr(`lucide-${Mr(Pr(e))}`,`lucide-${e}`,n),...r}));return n.displayName=Pr(e),n},Rr=Y(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),zr=Y(`arrow-down-up`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]),Br=Y(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Vr=Y(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),Hr=Y(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ur=Y(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Wr=Y(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Gr=Y(`code-xml`,[[`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`}]]),Kr=Y(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),qr=Y(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Jr=Y(`folder-open`,[[`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`}]]),Yr=Y(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Xr=Y(`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`}]]),Zr=Y(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Qr=Y(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),$r=Y(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),ei=Y(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),ti=Y(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ni=Y(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ri=Y(`moon-star`,[[`path`,{d:`M18 5h4`,key:`1lhgn2`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ii=Y(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`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:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),ai=Y(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),oi=Y(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),si=Y(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ci=Y(`refresh-cw`,[[`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`}]]),li=Y(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),ui=Y(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),di=Y(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),fi=Y(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),pi=Y(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mi=Y(`square-split-horizontal`,[[`path`,{d:`M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3`,key:`lubmu8`}],[`path`,{d:`M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3`,key:`1ag34g`}],[`line`,{x1:`12`,x2:`12`,y1:`4`,y2:`20`,key:`1tx1rr`}]]),hi=Y(`square-split-vertical`,[[`path`,{d:`M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3`,key:`1pi83i`}],[`path`,{d:`M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3`,key:`ido5k7`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),gi=Y(`sun-medium`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 3v1`,key:`1asbbs`}],[`path`,{d:`M12 20v1`,key:`1wcdkc`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M20 12h1`,key:`1vloll`}],[`path`,{d:`m18.364 5.636-.707.707`,key:`1hakh0`}],[`path`,{d:`m6.343 17.657-.707.707`,key:`18m9nf`}],[`path`,{d:`m5.636 5.636.707.707`,key:`1xv1c5`}],[`path`,{d:`m17.657 17.657.707.707`,key:`vl76zb`}]]),_i=Y(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),vi=Y(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),yi=Y(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),X=(e,t)=>{let n=n=>(0,J.jsx)(e,{"aria-hidden":`true`,size:16,strokeWidth:1.5,...t,...n});return n.displayName=`Icon(${e.displayName??e.name??`Lucide`})`,n};X(li),X(Jr),X(Zr);var bi=X(Xr),xi=X(Zr);X(Zr);var Si=X(Kr),Ci=X(Gr),wi=X(_i),Ti=X(Br);X(si),X(ri),X(gi),X(pi),X(zr),X(Yr);var Ei=X(si),Di=X(yi),Oi=X(di),ki=X(Ur),Ai=X(fi);X(Qr);var ji=X(ii);X(Vr),X(Zr),X(ni),X(Xr),X(Rr);var Mi=X(si),Ni=X(ti),Pi=X(vi),Fi=X(ci);X(Yr);var Ii=X(ui,{size:14}),Li=X(Wr,{size:12}),Ri=X(Hr,{size:12}),zi=X($r,{size:14}),Bi=X(ei,{size:14});X(ai,{size:14}),X(oi,{size:14});var Vi=X(hi,{size:13}),Hi=X(mi,{size:13}),Ui=X(Xr,{size:14}),Wi=X(Jr,{size:14});X(qr,{size:14});var Gi={ts:`#3178c6`,tsx:`#3178c6`,js:`#f7df1e`,jsx:`#f7df1e`,json:`#cbcb41`,md:`#519aba`,html:`#e34c26`,css:`#563d7c`,scss:`#563d7c`,py:`#3572A5`,go:`#00ADD8`,rs:`#dea584`,java:`#b07219`,sql:`#e38c00`,sh:`#89e051`,yml:`#cb171e`,yaml:`#cb171e`,toml:`#9c4121`,svg:`#a0c4e3`,png:`#a0c4e3`,jpg:`#a0c4e3`,pdf:`#b30b00`},Ki=(e,t,n)=>t?n?(0,J.jsx)(Wi,{}):(0,J.jsx)(Ui,{}):(0,J.jsx)(qr,{style:{color:Gi[e.split(`.`).pop()?.toLowerCase()||``]||`#808080`,width:14,height:14,flexShrink:0}}),qi=e=>[{id:`general`,label:e(`settingsGeneral`),icon:(0,J.jsx)(Ai,{})},{id:`appearance`,label:e(`settingsAppearance`),icon:(0,J.jsx)(ji,{})}],Ji=({locale:e,activeSettingsPanel:t,settingsDraft:n,launchCommandStatus:r,onSettingsPanelChange:i,onSettingsChange:a,onSettingsIdlePolicyChange:o,onSelectLocale:s,t:c})=>(0,J.jsx)(`main`,{className:`settings-route`,"data-testid":`settings-page`,children:(0,J.jsxs)(`section`,{className:`settings-layout`,children:[(0,J.jsx)(`aside`,{className:`settings-sidebar-v2`,children:(0,J.jsx)(`nav`,{className:`settings-nav-list`,"aria-label":c(`settings`),children:qi(c).map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`settings-nav-item ${e.id===t?`active`:``}`,onClick:()=>i(e.id),children:[(0,J.jsx)(`span`,{className:`settings-nav-icon`,children:e.icon}),(0,J.jsx)(`span`,{children:e.label})]},e.id))})}),(0,J.jsxs)(`section`,{className:`settings-content-v2`,children:[(0,J.jsx)(`div`,{className:`settings-scroll-panel`,children:t===`general`?(0,J.jsxs)(`div`,{className:`settings-group-card`,children:[(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`launchCommand`)}),(0,J.jsx)(`span`,{children:c(`launchCommandHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`div`,{className:`settings-command-field`,children:[(0,J.jsx)(`input`,{className:`settings-inline-input`,value:n.agentCommand,onChange:e=>a({agentCommand:e.target.value}),placeholder:c(`launchCommandPlaceholder`),"data-testid":`settings-agent-command`}),(0,J.jsxs)(`div`,{className:`settings-inline-status ${r.stateClass}`,"data-testid":`settings-agent-command-status`,children:[(0,J.jsx)(`span`,{className:`settings-inline-status-dot`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`settings-inline-status-copy`,children:[(0,J.jsx)(`span`,{children:r.text}),r.detailText&&(0,J.jsx)(`small`,{children:r.detailText})]})]})]})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`autoSuspend`)}),(0,J.jsx)(`span`,{children:c(`autoSuspendHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`label`,{className:`toggle`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:n.idlePolicy.enabled,onChange:()=>o({enabled:!n.idlePolicy.enabled})}),(0,J.jsx)(`span`,{className:`toggle-track`,children:(0,J.jsx)(`span`,{className:`toggle-thumb`})})]})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`idleAfter`)}),(0,J.jsx)(`span`,{children:c(`idleAfterHint`)})]}),(0,J.jsxs)(`div`,{className:`settings-row-control settings-number-control`,children:[(0,J.jsx)(`input`,{className:`settings-inline-number`,type:`number`,min:1,value:n.idlePolicy.idleMinutes,onChange:e=>o({idleMinutes:Number(e.target.value)}),"data-testid":`settings-idle-minutes`}),(0,J.jsx)(`span`,{children:c(`minutesShort`)})]})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`maxActive`)}),(0,J.jsx)(`span`,{children:c(`maxActiveHint`)})]}),(0,J.jsxs)(`div`,{className:`settings-row-control settings-number-control`,children:[(0,J.jsx)(`input`,{className:`settings-inline-number`,type:`number`,min:1,value:n.idlePolicy.maxActive,onChange:e=>o({maxActive:Number(e.target.value)}),"data-testid":`settings-max-active`}),(0,J.jsx)(`span`,{children:c(`sessionsWord`)})]})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`memoryPressure`)}),(0,J.jsx)(`span`,{children:c(`memoryPressureHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`label`,{className:`toggle`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:n.idlePolicy.pressure,onChange:()=>o({pressure:!n.idlePolicy.pressure})}),(0,J.jsx)(`span`,{className:`toggle-track`,children:(0,J.jsx)(`span`,{className:`toggle-thumb`})})]})})]})]}):(0,J.jsxs)(`div`,{className:`settings-group-card`,children:[(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`theme`)}),(0,J.jsx)(`span`,{children:e===`zh`?`当前版本仅保留深色主题。`:`This version uses a dark-only theme.`})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsx)(`div`,{className:`settings-pill-select single`,children:(0,J.jsx)(`span`,{className:`settings-pill-option active`,children:c(`themeDark`)})})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`languageLabel`)}),(0,J.jsx)(`span`,{children:c(`languageHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`div`,{className:`settings-pill-select`,children:[(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`zh`?`active`:``}`,onClick:()=>s(`zh`),children:`中文`}),(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`en`?`active`:``}`,onClick:()=>s(`en`),children:`English`})]})})]})]})}),(0,J.jsx)(`div`,{className:`settings-footer-bar`,children:(0,J.jsx)(`div`,{className:`settings-page-status`,children:c(`settingsAutoSave`)})})]})]})}),Yi=({isSettingsRoute:e,locale:t,workspaceTabs:n,onSwitchWorkspace:r,onAddTab:i,onRemoveTab:a,onOpenSettings:o,onCloseSettings:s,onOpenCommandPalette:c,t:l})=>(0,J.jsxs)(`header`,{className:`topbar ${e?`topbar-settings`:``}`,children:[(0,J.jsx)(`div`,{className:`topbar-tabs-wrap`,children:e?(0,J.jsxs)(`div`,{className:`route-topbar`,"data-testid":`settings-topbar`,children:[(0,J.jsxs)(`button`,{className:`route-topbar-back`,type:`button`,onClick:s,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(`span`,{children:l(`backToApp`)})]}),(0,J.jsx)(`div`,{className:`route-topbar-title`,children:l(`settings`)})]}):(0,J.jsxs)(`div`,{className:`topbar-session-strip topbar-workspace-strip`,"data-testid":`workspace-topbar`,children:[n.map(e=>(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,className:`session-top-tab workspace-top-tab ${e.active?`active`:``} ${e.hasRunning?`running-glow`:``}`,onClick:()=>r(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.id))},title:e.label,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${e.hasRunning?`active pulse`:`idle`}`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:e.label}),!e.active&&e.unread>0&&(0,J.jsx)(`span`,{className:`session-top-unread`,title:`${e.unread}`,"aria-label":`${e.unread}`,children:e.unread>9?`9+`:e.unread}),(0,J.jsx)(`button`,{type:`button`,className:`session-top-close`,title:l(`close`),"aria-label":l(`close`),onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,J.jsx)(Di,{})})]},e.id)),(0,J.jsx)(`button`,{type:`button`,className:`session-top-add`,onClick:i,title:t===`zh`?`新建工作区`:`Add workspace`,"aria-label":t===`zh`?`新建工作区`:`Add workspace`,children:(0,J.jsx)(Ei,{})})]})}),(0,J.jsx)(`div`,{className:`topbar-actions`,children:!e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`topbar-tool topbar-tool-wide`,onClick:c,title:t===`zh`?`快速操作(⌘/Ctrl+K)`:`Quick actions (⌘/Ctrl+K)`,"aria-label":t===`zh`?`快速操作`:`Quick actions`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`span`,{children:t===`zh`?`操作`:`Actions`})]}),(0,J.jsx)(`button`,{className:`topbar-tool`,type:`button`,onClick:o,"data-testid":`settings-open`,title:l(`settings`),"aria-label":l(`settings`),children:(0,J.jsx)(Oi,{})})]})})]}),Z=async(e,t={})=>{let n=[],r=[Kn()];for(let i of r)try{let n=Un(new URL(`/api/rpc/${e}`,`${i}/`)).toString(),r=await fetch(n,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),a={};try{a=await r.json()}catch{}if(!r.ok||a.ok===!1){let e=a.error||`HTTP ${r.status}`;throw(r.status===401||e===`session_missing`||e===`session_expired`)&&vr(e),Error(e)}return a.data}catch(e){let t=e instanceof Error?e.message:String(e);n.push(`${i||`unknown_base`}: ${t}`)}throw Error(n.join(` | `))},Xi=async(e,t)=>{try{return await e()}catch{return t}},Zi=(e,t)=>Z(`filesystem_list`,{target:e,path:t}),Qi=(e,t,n)=>Z(`command_exists`,{command:e,target:t,cwd:n}),$i=`coder-studio.app-settings`,ea=()=>({agentProvider:`claude`,agentCommand:`claude`,idlePolicy:{enabled:!0,idleMinutes:10,maxActive:3,pressure:!0}}),ta=e=>({agentProvider:e.agentProvider,agentCommand:e.agentCommand,idlePolicy:{...e.idlePolicy}}),na=()=>{let e=ea();if(typeof window>`u`)return e;try{let t=window.localStorage.getItem($i);if(!t)return e;let n=JSON.parse(t);return{agentProvider:`claude`,agentCommand:typeof n.agentCommand==`string`&&n.agentCommand.trim()?n.agentCommand:e.agentCommand,idlePolicy:{enabled:n.idlePolicy?.enabled??e.idlePolicy.enabled,idleMinutes:Number.isFinite(n.idlePolicy?.idleMinutes)?Math.max(1,Number(n.idlePolicy?.idleMinutes)):e.idlePolicy.idleMinutes,maxActive:Number.isFinite(n.idlePolicy?.maxActive)?Math.max(1,Number(n.idlePolicy?.maxActive)):e.idlePolicy.maxActive,pressure:n.idlePolicy?.pressure??e.idlePolicy.pressure}}}catch{return e}},ra=e=>{typeof window>`u`||window.localStorage.setItem($i,JSON.stringify(e))},ia=e=>Number.isFinite(e)?Math.max(0,Number(e)):320,aa=e=>Number.isFinite(e)?Math.max(0,Number(e)):320,oa=e=>Number.isFinite(e)?Math.min(100,Math.max(0,Number(e))):64,sa=()=>{let e=new Date;return`${`${e.getHours()}`.padStart(2,`0`)}:${`${e.getMinutes()}`.padStart(2,`0`)}`},Q=(e=`id`)=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,ca=()=>({path:``,content:``,mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1}),la=e=>({type:`leaf`,id:Q(`pane`),sessionId:e}),ua=e=>la(e),da=(e,t=`branch`,n=wn())=>({id:Q(`session`),title:kn(e,n),status:`idle`,mode:t,autoFeed:!0,isDraft:!1,queue:[],messages:[{id:Q(`msg`),role:`system`,content:Mn(e,n),time:sa()}],stream:``,unread:0,lastActiveAt:Date.now()}),fa=(e,t=wn())=>{let n=da(1,`branch`,t),r=ua(n.id);return{id:Q(`tab`),title:An(e,t),status:`init`,agent:{provider:`claude`,command:`claude`,useWsl:!1},git:{branch:`—`,changes:0,lastCommit:`—`},gitChanges:[],worktrees:[],sessions:[n],activeSessionId:n.id,archive:[],terminals:[],activeTerminalId:``,fileTree:[],changesTree:[],filePreview:ca(),paneLayout:r,activePaneId:r.id,idlePolicy:{enabled:!0,idleMinutes:10,maxActive:3,pressure:!0}}},pa=()=>({tabs:[],activeTabId:``,layout:{leftWidth:320,rightWidth:320,rightSplit:64,showCodePanel:!1,showTerminalPanel:!1},overlay:{visible:!0,mode:`local`,input:``,target:{type:`native`}}}),ma=e=>e?e.type===`leaf`?[e.id]:[...ma(e.first),...ma(e.second)]:[],ha=e=>e?e.type===`leaf`?[e.sessionId]:[...ha(e.first),...ha(e.second)]:[],ga=(e,t)=>{if(e)return e.type===`leaf`?e.sessionId===t?e.id:void 0:ga(e.first,t)??ga(e.second,t)},_a=(e,t)=>e?e.type===`leaf`?{type:`leaf`,id:e.id||Q(`pane`),sessionId:e.sessionId||t}:{type:`split`,id:e.id||Q(`pane`),axis:e.axis===`vertical`?`vertical`:`horizontal`,ratio:Number.isFinite(e.ratio)?Math.min(1,Math.max(0,e.ratio)):.5,first:_a(e.first,t),second:_a(e.second,t)}:ua(t),va=(e,t,n)=>{if(!e)return null;if(e.type===`leaf`)return!t.has(e.sessionId)||n.has(e.sessionId)?null:(n.add(e.sessionId),{type:`leaf`,id:e.id||Q(`pane`),sessionId:e.sessionId});let r=va(e.first,t,n),i=va(e.second,t,n);return!r&&!i?null:r?i?{type:`split`,id:e.id||Q(`split`),axis:e.axis===`vertical`?`vertical`:`horizontal`,ratio:Number.isFinite(e.ratio)?Math.min(1,Math.max(0,e.ratio)):.5,first:r,second:i}:r:i},ya=(e,t)=>{let n=(e.sessions??[]).filter(Boolean),r=n.filter(e=>!e.isDraft),i=r.length?r:n,a=i.length?i:[da(1,`branch`,t)],o=a.some(t=>t.id===e.activeSessionId)?e.activeSessionId:a[0].id,s=new Set(a.map(e=>e.id)),c=va(_a(e.paneLayout,o),s,new Set)??ua(o),l=new Set(ha(c)),u=a.map(e=>e.id).filter(e=>!l.has(e)).reduce((e,t)=>({type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:e,second:la(t)}),c),d=ma(u),f=ga(u,o)??(d.includes(e.activePaneId)?e.activePaneId:d[0]);return{...e,gitChanges:e.gitChanges??[],sessions:a,activeSessionId:o,paneLayout:u,activePaneId:f}},ba=e=>{let t=pa();if(!e?.tabs?.length)return t;let n=wn(),r=e.tabs.filter(Boolean).map(e=>ya(e,n));if(!r.length)return t;let i=r.some(t=>t.id===e.activeTabId)?e.activeTabId??r[0].id:r[0].id,a=r.some(e=>e.status===`ready`||(e.sessions?.length??0)>1||!!e.sessions?.[0]?.stream||(e.archive?.length??0)>0),o=e.layout;return{tabs:r,activeTabId:i,layout:{leftWidth:ia(o?.leftWidth??t.layout.leftWidth),rightWidth:aa(o?.rightWidth??t.layout.rightWidth),rightSplit:oa(o?.rightSplit??o?.rightTopHeight??t.layout.rightSplit),showCodePanel:o?.showCodePanel??(typeof o?.rightCollapsed==`boolean`?!o.rightCollapsed:t.layout.showCodePanel),showTerminalPanel:o?.showTerminalPanel??t.layout.showTerminalPanel},overlay:{visible:a?!1:e.overlay?.visible??t.overlay.visible,mode:e.overlay?.mode??t.overlay.mode,input:e.overlay?.input??t.overlay.input,target:e.overlay?.target??t.overlay.target}}},xa=o({...pa()}),Sa=(e,t)=>{let n=e.trim().toLowerCase(),r=t.toLowerCase();if(!n)return 0;if(r===n)return 1e3;if(r.includes(n))return 700-Math.max(0,r.indexOf(n));let i=0,a=0;for(let e of n){let t=r.indexOf(e,a);if(t===-1)return-1;i+=t===a?10:Math.max(2,8-(t-a)),a=t+1}return i},Ca=e=>{switch(e.split(`.`).pop()?.toLowerCase()??``){case`ts`:case`tsx`:return`typescript`;case`js`:case`jsx`:case`mjs`:case`cjs`:return`javascript`;case`json`:return`json`;case`md`:return`markdown`;case`css`:case`scss`:return`css`;case`html`:case`htm`:return`html`;default:return`plaintext`}},wa=(e=[])=>{let t=[];return e.forEach(e=>{e.kind===`file`&&t.push(e),e.children?.length&&t.push(...wa(e.children))}),t},Ta=(e,t)=>{let n=new Intl.Collator(t===`zh`?`zh-CN`:`en`,{numeric:!0,sensitivity:`base`});return[...e].sort((e,t)=>e.kind===t.kind?n.compare(e.name,t.name):e.kind===`dir`?-1:1).map(e=>({...e,children:e.children?.length?Ta(e.children,t):e.children}))},Ea=()=>({query:``,open:!1,activeIndex:0,dropdownStyle:null}),Da=e=>e.trim().toLowerCase(),Oa=(e,t,n)=>{let r=Da(n);return r?wa(e).filter(e=>e.kind===`file`).map(e=>({node:{...e,absolutePath:xr(t,e.path)},score:Sa(r,`${e.name} ${e.path}`)})).filter(e=>e.score>=0).sort((e,t)=>t.score-e.score||e.node.path.localeCompare(t.node.path)).slice(0,24):[]},ka=e=>e.open&&Da(e.query).length>0,Aa=(e,t)=>{if(!Da(e.query))return!e.open&&e.activeIndex===0&&e.dropdownStyle===null?e:{...e,open:!1,activeIndex:0,dropdownStyle:null};let n=Math.min(e.activeIndex,Math.max(t-1,0));return n===e.activeIndex?e:{...e,activeIndex:n}},ja=(e,t)=>({...e,query:t,open:!!Da(t),activeIndex:0}),Ma=(e,t=e.query)=>({...e,open:!!Da(t)}),Na=e=>e.open?{...e,open:!1}:e,Pa=e=>!e.query&&!e.open&&e.activeIndex===0?e:{...e,query:``,open:!1,activeIndex:0},Fa=(e,t,n)=>({...e,open:!0,activeIndex:n===0?0:t>0?Math.min(e.activeIndex+1,n-1):Math.max(e.activeIndex-1,0)}),Ia=(e,t)=>e.activeIndex===t?e:{...e,activeIndex:t},La=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ra=(e,t)=>La(e.dropdownStyle,t)?e:{...e,dropdownStyle:t},za=(e,t,n)=>{let r=Math.min(Math.max(e.width,320),Math.max(320,t-24)),i=Math.min(Math.max(12,e.left),Math.max(12,t-r-12)),a=Math.max(0,n-e.bottom-12),o=Math.max(0,e.top-12),s=a<180&&o>a+40,c=s?`above`:`below`;return{left:i,width:r,maxHeight:Math.max(120,Math.min(420,s?o:a)),placement:c,top:s?void 0:e.bottom+8,bottom:s?Math.max(12,n-e.top+8):void 0}},Ba=(e,t)=>({...e,overlay:{...e.overlay,input:t}}),Va=(e,t)=>({...e,overlay:{...e.overlay,target:t}}),Ha=async({target:e,path:t,selectCurrent:n=!1,locale:r,t:i,setFolderBrowser:a,setOverlayCanUseWsl:o,updateOverlayInput:s})=>{a(e=>({...e,loading:!0,error:void 0,notice:void 0}));try{let r=await Zi(e,t),c=!!(t&&r.fallback_reason);e.type===`native`&&o(r.roots.some(e=>Tr(e.path))),a({loading:!1,currentPath:r.current_path,homePath:r.home_path,parentPath:r.parent_path??void 0,roots:r.roots,entries:r.entries,notice:c?i(`folderBrowserRecovered`):void 0}),(n||c)&&s(r.current_path)}catch(e){let t=e instanceof Error?e.message:String(e);a(e=>({...e,loading:!1,currentPath:``,parentPath:void 0,entries:[],error:r===`zh`?`无法读取服务器目录${t?`:${t}`:``}`:`Unable to read server directories${t?`: ${t}`:``}`}))}},Ua=e=>Z(`file_preview`,{path:e}),Wa=(e,t)=>Z(`file_save`,{path:e,content:t}),Ga=(e,t)=>Z(`git_changes`,{path:e,target:t}),Ka=(e,t)=>Z(`git_diff`,{path:e,target:t}),qa=(e,t,n,r)=>Z(`git_diff_file`,{path:e,target:t,filePath:n,staged:r}),Ja=(e,t,n,r)=>Z(`git_file_diff_payload`,{path:e,target:t,filePath:n,section:r}),Ya=(e,t,n)=>Z(`git_stage_file`,{path:e,target:t,filePath:n}),Xa=(e,t,n)=>Z(`git_unstage_file`,{path:e,target:t,filePath:n}),Za=(e,t,n,r)=>Z(`git_discard_file`,{path:e,target:t,filePath:n,section:r}),Qa=(e,t)=>Z(`git_stage_all`,{path:e,target:t}),$a=(e,t)=>Z(`git_unstage_all`,{path:e,target:t}),eo=(e,t)=>Z(`git_discard_all`,{path:e,target:t}),to=(e,t,n)=>Z(`git_commit`,{path:e,target:t,message:n}),no=e=>{let t=0,n=0,r=0,i=[];return e.split(`
4
+ `).forEach(e=>{if(e.startsWith(`diff --git`)){t+=1;let n=e.split(` `)[2]?.replace(`a/`,``)??`file`;i.push(n);return}e.startsWith(`+++ `)||e.startsWith(`--- `)||(e.startsWith(`+`)&&(n+=1),e.startsWith(`-`)&&(r+=1))}),{files:t,additions:n,deletions:r,diffFiles:i}},ro=async({tab:e,node:t,updateTab:n,withServiceFallback:r,t:i})=>{let a=xr(e.project?.path,t.path),o=await r(()=>Ua(a),{path:t.path,content:i(`previewUnavailable`),mode:`preview`});n(e.id,e=>({...e,filePreview:{...e.filePreview,path:o.path||t.path,content:o.content||i(`previewUnavailable`),mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1,source:`tree`,statusLabel:t.status,parentPath:Er(o.path||t.path),section:void 0,diff:void 0}}))},io=async({tab:e,path:t,updateTab:n,withServiceFallback:r,t:i,options:a})=>{let o=await r(()=>Ua(t),{path:t,content:i(`previewUnavailable`),mode:`preview`});n(e.id,e=>({...e,filePreview:{...e.filePreview,path:o.path||t,content:o.content||i(`previewUnavailable`),mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1,source:`tree`,statusLabel:a?.statusLabel??e.filePreview.statusLabel,parentPath:a?.parentPath??Er(o.path||t),section:void 0,diff:void 0}}))},ao=async({tab:e,updateTab:t,withServiceFallback:n})=>{let r=e.project?.target??{type:`native`},i=e.project?.path??``,a=await n(()=>Ka(i,r),``),o=no(a);t(e.id,e=>({...e,filePreview:{...e.filePreview,mode:`diff`,diff:a,originalContent:``,modifiedContent:``,diffStats:{files:o.files,additions:o.additions,deletions:o.deletions},diffFiles:o.diffFiles,dirty:e.filePreview.dirty}}))},oo=async({tab:e,activeSessionId:t,updateTab:n,withServiceFallback:r,refreshWorkspaceArtifacts:i,addToast:a,t:o,createToastId:s})=>{let c=e.filePreview;if(!c.path||!c.dirty)return!1;let l=await r(()=>Wa(c.path,c.content),null);return l?(n(e.id,e=>({...e,filePreview:{...e.filePreview,path:l.path,content:l.content,dirty:!1}})),await i(e.id),a({id:s(),text:`${o(`saved`)}: ${l.path}`,sessionId:t}),!0):!1},so=e=>Z(`launch_workspace`,{source:e}),co=()=>Z(`workbench_bootstrap`,{}),lo=e=>Z(`workspace_snapshot`,{workspaceId:e}),uo=e=>Z(`activate_workspace`,{workspaceId:e}),fo=e=>Z(`close_workspace`,{workspaceId:e}),po=e=>Z(`update_workbench_layout`,{layout:e}),mo=(e,t)=>Z(`workspace_view_update`,{workspaceId:e,patch:t}),ho=(e,t,n=4)=>Z(`workspace_tree`,{path:e,target:t,depth:n}),go=(e,t)=>Z(`worktree_list`,{path:e,target:t}),_o=(e,t)=>Z(`git_status`,{path:e,target:t}),vo=async({tab:e,change:t,updateTab:n,withServiceFallback:r})=>{let i=Cr(t.path),a=xr(e.project?.path,i),o=await r(()=>Ja(e.project?.path??``,e.project?.target??{type:`native`},i,t.section),{original_content:``,modified_content:``,diff:``});if(!o.original_content&&!o.modified_content&&!o.diff){let n=await r(()=>qa(e.project?.path??``,e.project?.target??{type:`native`},i,t.section===`staged`),``);o={original_content:``,modified_content:(await r(()=>Ua(a),null))?.content??``,diff:n}}let s=no(o.diff);return n(e.id,e=>({...e,filePreview:{...e.filePreview,path:a,content:o.modified_content,mode:`diff`,diff:o.diff,originalContent:o.original_content,modifiedContent:o.modified_content,diffStats:{files:s.files,additions:s.additions,deletions:s.deletions},diffFiles:[t.path],dirty:!1,source:`git`,statusLabel:t.status,parentPath:t.parent,section:t.section}})),`${t.section}:${t.path}:${t.code}`},yo=async({tab:e,activeSessionId:t,selectedGitChangeKey:n,previewMode:r,updateTab:i,refreshWorkspaceArtifacts:a,onSelectGitChange:o,onReloadRepositoryDiff:s,onClearPreviewSelection:c,addToast:l,t:u,createToastId:d,getCurrentTab:f,operation:p})=>{if(!e.project?.path)return l({id:d(),text:u(`selectProjectFirst`),sessionId:t}),!1;try{await p(),await a(e.id);let t=f(e.id),l=t?.gitChanges.find(e=>`${e.section}:${e.path}:${e.code}`===n)??t?.gitChanges.find(n=>wr(t?.filePreview.path||e.filePreview.path,n.path));return l?await o(l):r===`diff`?await s():n&&(c(),i(e.id,e=>({...e,filePreview:ca()}))),!0}catch(e){return l({id:d(),text:`${u(`gitActionFailed`)}: ${String(e)}`,sessionId:t}),!1}},bo=(e,t)=>[{key:`changes`,label:t(`changes`),items:e.filter(e=>e.section===`changes`)},{key:`staged`,label:t(`stagedChanges`),items:e.filter(e=>e.section===`staged`)},{key:`untracked`,label:t(`untrackedFiles`),items:e.filter(e=>e.section===`untracked`)}].filter(e=>e.items.length>0),xo=(e,t)=>t.find(t=>wr(e,t.path)),So=(e,t,n)=>{if(!e)return``;if(!t)return e;let r=Sr(t);return Sr(e).startsWith(r)&&(e.slice(t.length).replace(/^[/\\]+/,``)||n)||e},Co=e=>e.type===`leaf`?[{id:e.id,sessionId:e.sessionId}]:[...Co(e.first),...Co(e.second)],wo=(e,t)=>e.type===`leaf`?e.id===t?e.sessionId:null:wo(e.first,t)??wo(e.second,t),To=(e,t)=>e.type===`leaf`?e.sessionId===t?e.id:null:To(e.first,t)??To(e.second,t),Eo=(e,t,n)=>e.type===`leaf`?e.id===t?n(e):e:{...e,first:Eo(e.first,t,n),second:Eo(e.second,t,n)},Do=(e,t)=>{if(e.type===`leaf`)return e.id===t?null:e;let n=Do(e.first,t),r=Do(e.second,t);return!n&&!r?null:n?r?{...e,first:n,second:r}:n:r},Oo=(e,t,n)=>e.type===`leaf`?e.sessionId===t?{...e,sessionId:n}:e:{...e,first:Oo(e.first,t,n),second:Oo(e.second,t,n)},ko=(e,t,n)=>e.type===`leaf`?e:e.id===t?{...e,ratio:n}:{...e,first:ko(e.first,t,n),second:ko(e.second,t,n)},Ao=()=>new Date().toLocaleTimeString().slice(0,5),jo=e=>{let t=Number(e);return Number.isFinite(t)?t:null},Mo=(e,t,n)=>({id:String(e.id),title:e.title||n?.title||kn(e.id,t),status:e.status,mode:e.mode,autoFeed:e.auto_feed,isDraft:!1,queue:e.queue.map(e=>({id:String(e.id),text:e.text,status:e.status})),messages:e.messages?.length?e.messages:n?.messages??[{id:Q(`msg`),role:`system`,content:Mn(e.id,t),time:Ao()}],stream:e.stream??n?.stream??``,unread:e.unread??n?.unread??0,lastActiveAt:e.last_active_at,claudeSessionId:e.claude_session_id??n?.claudeSessionId}),No=({locale:e,workspacePath:t,branch:n,mode:r=`branch`,existing:i})=>{let a=Dn(e),o=`${t}${n&&n!==`—`?` · ${n}`:``}`;return{id:i?.id??Q(`session`),title:i?.title??a(`draftSessionTitle`),status:i?.status??`idle`,mode:i?.mode??r,autoFeed:i?.autoFeed??!0,isDraft:!0,queue:i?.queue??[],messages:i?.messages?.length?i.messages:[{id:Q(`msg`),role:`system`,content:a(`draftSessionPrompt`),time:Ao()},{id:Q(`msg`),role:`system`,content:a(`draftSessionWorkspace`,{path:o}),time:Ao()}],stream:i?.stream??``,unread:i?.unread??0,lastActiveAt:i?.lastActiveAt??Date.now(),claudeSessionId:i?.claudeSessionId}},Po=e=>!!e?.isDraft,Fo=e=>!!(e&&!e.stream.trim()&&e.queue.length===0&&e.messages.every(e=>e.role===`system`)),Io=e=>{let t=e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e.trim();return t?t.length<=48?t:`${t.slice(0,45)}...`:``},Lo=e=>e===`running`||e===`waiting`,Ro=e=>Lo(e)?`background`:e,zo=e=>e.status===`background`?`waiting`:e.status,Bo=(e,t,n)=>n===`running`||n===`waiting`?e.activeSessionId===t.id?n:`background`:n,Vo=e=>e===`running`||e===`waiting`||e===`background`?`active`:e===`idle`?`idle`:e===`queued`?`queued`:`suspended`,Ho=e=>{if(!e.queue.length)return 0;let t=e.queue.filter(e=>e.status===`done`).length;return Math.round(t/e.queue.length*100)},Uo=(e,t)=>({...e,layout:{...e.layout,showCodePanel:t===`code`?!e.layout.showCodePanel:e.layout.showCodePanel,showTerminalPanel:t===`terminal`?!e.layout.showTerminalPanel:e.layout.showTerminalPanel}}),Wo=(e,t,n,r)=>{let i=Date.now();e(t,e=>({...e,activePaneId:n,activeSessionId:r,sessions:e.sessions.map(t=>t.id===r?{...t,unread:0,status:zo(t),lastActiveAt:i}:t.id===e.activeSessionId?{...t,status:Ro(t.status)}:t)}))},Go=({tab:e,paneId:t,axis:n,updateTab:r,createDraftSessionForTab:i,onFocusPane:a})=>{let o=null;r(e.id,e=>{let r=wo(e.paneLayout,t)?t:To(e.paneLayout,e.activeSessionId)??Co(e.paneLayout)[0]?.id;if(!r)return e;let a=i(e,`branch`),s=la(a.id);return o=s.id,{...e,sessions:[a,...e.sessions.filter(e=>e.id!==a.id)],activePaneId:s.id,activeSessionId:a.id,paneLayout:Eo(e.paneLayout,r,e=>({type:`split`,id:Q(`split`),axis:n,ratio:.5,first:e,second:s}))}}),o&&a(o)},Ko=({event:e,type:t,stateRef:n,updateState:r,shellTerminalRef:i,fitAgentTerminals:a})=>{e.preventDefault(),document.body.classList.add(`is-resizing-panels`),document.body.classList.add(t===`right-split`?`is-resizing-rows`:`is-resizing-columns`);let o=e.clientX,s=e.clientY,{rightWidth:c,rightSplit:l}=n.current.layout,u=t===`right-split`&&e.currentTarget instanceof HTMLElement?e.currentTarget.parentElement?.getBoundingClientRect().height??1:1,d=0,f=c,p=l,m=()=>{d=0,r(e=>({...e,layout:{...e.layout,rightWidth:t===`left`?f:e.layout.rightWidth,rightSplit:t===`right-split`?p:e.layout.rightSplit}}))},h=e=>{if(t===`left`&&(f=Math.max(0,Math.round(c-(e.clientX-o)))),t===`right-split`){let t=e.clientY-s;p=Math.max(0,Math.min(100,l+t/u*100))}d||=window.requestAnimationFrame(m)},g=()=>{document.body.classList.remove(`is-resizing-panels`),document.body.classList.remove(`is-resizing-columns`,`is-resizing-rows`),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),d&&(window.cancelAnimationFrame(d),m()),requestAnimationFrame(()=>{i.current?.fit(),a()})};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g)},qo=({event:e,tabId:t,paneLayout:n,splitId:r,axis:i,updateTab:a,fitAgentTerminals:o})=>{e.preventDefault(),document.body.classList.add(`is-resizing-panels`),document.body.classList.add(i===`horizontal`?`is-resizing-rows`:`is-resizing-columns`);let s=e.currentTarget.parentElement;if(!s)return;let c=s.getBoundingClientRect(),l=e.clientX,u=e.clientY,d=e=>e.type===`leaf`?null:e.id===r?e.ratio:d(e.first)??d(e.second),f=d(n)??.5,p=0,m=f,h=()=>{p=0,a(t,e=>({...e,paneLayout:ko(e.paneLayout,r,m)}))},g=e=>{let t=i===`vertical`?(e.clientX-l)/Math.max(c.width,1):(e.clientY-u)/Math.max(c.height,1);m=Math.max(0,Math.min(1,f+t)),p||=window.requestAnimationFrame(h)},_=()=>{document.body.classList.remove(`is-resizing-panels`),document.body.classList.remove(`is-resizing-columns`,`is-resizing-rows`),window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),p&&(window.cancelAnimationFrame(p),h()),o()};window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_)},Jo=e=>Array.from(new Set(e.filter(Boolean))),Yo=(e,t)=>{let n=e&&typeof e==`object`?e:{};return{...ca(),...t,...n,path:typeof n.path==`string`?n.path:t?.path??``,content:typeof n.content==`string`?n.content:t?.content??``,mode:n.mode===`diff`?`diff`:`preview`,diff:typeof n.diff==`string`?n.diff:t?.diff??``,originalContent:typeof n.originalContent==`string`?n.originalContent:t?.originalContent??``,modifiedContent:typeof n.modifiedContent==`string`?n.modifiedContent:t?.modifiedContent??``,dirty:n.dirty??t?.dirty??!1,source:n.source??t?.source,statusLabel:typeof n.statusLabel==`string`?n.statusLabel:t?.statusLabel,parentPath:typeof n.parentPath==`string`?n.parentPath:t?.parentPath,section:n.section??t?.section}},Xo=(e,t)=>({id:String(e.id),sessionId:String(e.session_id),time:e.time,mode:e.mode,snapshot:Mo(e.snapshot,t)}),Zo=(e,t,n)=>{if(!e.length){let e=n?.terminals??[];return{terminals:e,activeTerminalId:e.some(e=>e.id===n?.activeTerminalId)?n?.activeTerminalId??``:e[0]?.id??``}}let r=e.map((e,r)=>{let i=`term-${e.id}`,a=n?.terminals.find(e=>e.id===i);return{id:i,title:a?.title??jn(r+1,t),output:e.output??a?.output??``}});return{terminals:r,activeTerminalId:r.some(e=>e.id===n?.activeTerminalId)?n?.activeTerminalId??``:r[0]?.id??``}},Qo=e=>({leftWidth:e.left_width,rightWidth:e.right_width,rightSplit:e.right_split,showCodePanel:e.show_code_panel,showTerminalPanel:e.show_terminal_panel}),$o=e=>({left_width:e.leftWidth,right_width:e.rightWidth,right_split:e.rightSplit,show_code_panel:e.showCodePanel,show_terminal_panel:e.showTerminalPanel}),es=(e,t,n,r)=>{let i=e.sessions.map(e=>{let n=r?.sessions.find(t=>t.id===String(e.id));return Mo(e,t,n)}),a=r?.sessions.filter(e=>Po(e))??[],o=i.length>0?[...a,...i]:a.length>0?a:[No({locale:t,workspacePath:e.workspace.project_path,branch:r?.git.branch})],s=o[0]?.id??r?.activeSessionId??`1`,c=o.some(t=>t.id===e.view_state.active_session_id)?e.view_state.active_session_id:o.some(e=>e.id===r?.activeSessionId)?r?.activeSessionId??s:s,l=Zo(e.terminals,t,r),u={id:e.workspace.workspace_id,title:e.workspace.title,status:`ready`,project:{kind:e.workspace.source_kind,path:e.workspace.project_path,gitUrl:e.workspace.git_url??void 0,target:e.workspace.target},agent:{provider:n.agentProvider,command:n.agentCommand,useWsl:e.workspace.target.type===`wsl`,distro:e.workspace.target.type===`wsl`?e.workspace.target.distro:void 0},git:r?.git??{branch:`—`,changes:0,lastCommit:`—`},gitChanges:r?.gitChanges??[],worktrees:r?.worktrees??[],sessions:o,activeSessionId:c,archive:e.archive.map(e=>Xo(e,t)),terminals:l.terminals,activeTerminalId:l.activeTerminalId,fileTree:r?.fileTree??[],changesTree:r?.changesTree??[],filePreview:Yo(e.view_state.file_preview,r?.filePreview),paneLayout:e.view_state.pane_layout??la(c),activePaneId:e.view_state.active_pane_id||r?.activePaneId||``,idlePolicy:{enabled:e.workspace.idle_policy.enabled,idleMinutes:e.workspace.idle_policy.idle_minutes,maxActive:e.workspace.idle_policy.max_active,pressure:e.workspace.idle_policy.pressure},viewingArchiveId:void 0};return ba({tabs:[u],activeTabId:u.id,layout:pa().layout,overlay:{visible:!1,mode:`remote`,input:``,target:{type:`native`}}}).tabs[0]},ts=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return Jo(t).map(e=>n.get(e)).filter(e=>!!e)},ns=(e,t)=>t&&e.some(e=>e.id===t)?t:e[0]?.id??``,rs=(e,t,n,r)=>{let i=new Map(e.tabs.map(e=>[e.id,e])),a=new Map(t.workspaces.map(e=>[e.workspace.workspace_id,e])),o=Jo(t.ui_state.open_workspace_ids).map(e=>{let t=a.get(e);return t?es(t,n,r,i.get(e)):null}).filter(e=>!!e);return{tabs:o,activeTabId:ns(o,t.ui_state.active_workspace_id),layout:Qo(t.ui_state.layout),overlay:{...e.overlay,visible:o.length===0,input:o.length===0?e.overlay.input:``}}},is=(e,t,n,r,i)=>{let a=es(t,n,r,e.tabs.find(e=>e.id===t.workspace.workspace_id)),o=new Map(e.tabs.map(e=>[e.id,e]));o.set(a.id,a);let s=Jo(i?.open_workspace_ids??[...e.tabs.map(e=>e.id),a.id]);s.includes(a.id)||s.push(a.id);let c=ts(Array.from(o.values()),s);return{...e,tabs:c,activeTabId:ns(c,i?.active_workspace_id??a.id),layout:i?Qo(i.layout):e.layout,overlay:{...e.overlay,visible:!1,input:``}}},as=(e,t)=>{let n=ts(e.tabs,t.open_workspace_ids);return{...e,tabs:n,activeTabId:ns(n,t.active_workspace_id),layout:Qo(t.layout),overlay:{...e.overlay,visible:n.length===0}}},os=async({overlay:e,locale:t,appSettings:n,updateState:r,withServiceFallback:i,refreshWorkspaceArtifacts:a})=>{let o=e.input.trim();if(!o)return null;let s=await i(()=>so({kind:e.mode,pathOrUrl:o,target:e.target}),null);if(!s)return null;r(e=>is(e,s.snapshot,t,n,s.ui_state));let c=s.snapshot.workspace.workspace_id,l=await a(c),u=s.created&&!s.snapshot.view_state.file_preview.path?wa(l?.root.children??[]).find(e=>e.kind===`file`):void 0;return{workspaceId:c,created:s.created,alreadyOpen:s.already_open,firstFile:u}},ss=(e,t)=>Z(`create_session`,{workspaceId:e,mode:t}),cs=(e,t,n)=>Z(`session_update`,{workspaceId:e,sessionId:t,patch:n}),ls=(e,t)=>Z(`switch_session`,{workspaceId:e,sessionId:t}),us=(e,t)=>Z(`archive_session`,{workspaceId:e,sessionId:t}),ds=(e,t)=>Z(`update_idle_policy`,{workspaceId:e,policy:t}),fs=({appSettings:e,locale:t,t:n,stateRef:r,updateTab:i,withServiceFallback:a,addToast:o})=>{let s=e=>No({locale:t,workspacePath:e.project?.path??n(`noWorkspace`),branch:e.git.branch}).messages,c=(e,r=`branch`)=>No({locale:t,workspacePath:e.project?.path??n(`noWorkspace`),branch:e.git.branch,mode:r}),l=async(e,t,n)=>{let r=jo(t);r!==null&&await a(()=>cs(e,r,n),null)},u=(e,t)=>{let n=Date.now();i(e,e=>({...e,sessions:e.sessions.map(e=>e.id===t?{...e,lastActiveAt:n}:e)})),l(e,t,{last_active_at:n})},d=async(e,n,o)=>{let s=r.current.tabs.find(t=>t.id===e),c=s?.sessions.find(e=>e.id===n);if(!s||!c)return null;if(!Po(c))return{tab:s,session:c};let l=null,u=await a(()=>ss(e,c.mode),null);u&&(l=Mo(u,t));let d=null,f=null;return i(e,e=>{let r=e.sessions.find(e=>e.id===n);if(!r)return e;let i=l??da(e.sessions.length+1,r.mode,t),a=Io(o)||r.title||kn(i.id,t),s={...i,title:a,status:i.status===`queued`?`queued`:`idle`,mode:r.mode,autoFeed:r.autoFeed,isDraft:!1,queue:r.queue,messages:r.messages,stream:r.stream,unread:0,lastActiveAt:Date.now(),claudeSessionId:i.claudeSessionId},c=e.sessions.filter(e=>e.id!==n);return d={...e,sessions:[s,...c],activeSessionId:s.id,paneLayout:Eo(e.paneLayout,e.activePaneId,e=>({...e,sessionId:s.id})),viewingArchiveId:void 0},f=s,d}),!d||!f?null:{tab:d,session:f}},f=async n=>{let r=await a(()=>lo(n),null);r&&i(n,n=>es(r,t,e,n))},p=async()=>{let e=r.current.tabs.find(e=>e.id===r.current.activeTabId);if(!e)return;i(e.id,e=>{let t=c(e,`branch`),n=la(t.id),r=e.sessions.map(t=>t.id===e.activeSessionId?{...t,status:Ro(t.status)}:t);return{...e,sessions:[t,...r],activeSessionId:t.id,activePaneId:n.id,paneLayout:Eo(e.paneLayout,e.activePaneId,e=>({type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:e,second:n})),viewingArchiveId:void 0}});let t=e.sessions.find(t=>t.id===e.activeSessionId);t&&Lo(t.status)&&l(e.id,t.id,{status:`background`})},m=(e,t)=>{let n=Date.now(),r=e.activeSessionId,a=e.sessions.find(e=>e.id===r),o=e.sessions.find(e=>e.id===t),s=To(e.paneLayout,t);if(!s||!o)return;i(e.id,e=>({...e,activeSessionId:t,activePaneId:s,sessions:e.sessions.filter(e=>!(r!==t&&e.id===r&&Po(e))).map(r=>r.id===t?{...r,unread:0,status:zo(r),lastActiveAt:n}:r.id===e.activeSessionId?{...r,status:Ro(r.status)}:r),viewingArchiveId:void 0}));let c=jo(t);c!==null&&ls(e.id,c).catch(()=>{}),r!==t&&a&&Lo(a.status)&&l(e.id,r,{status:`background`});let u=zo(o);l(e.id,t,{status:u,last_active_at:n})},h=(e,t,n)=>{let r=e.sessions.find(e=>e.id===n);if(!r)return;let a=Date.now(),o=null;if(i(e.id,e=>{if(!e.sessions.some(e=>e.id===n))return e;let r=Co(e.paneLayout).length>1,i=e.sessions.filter(e=>e.id!==n),s=i.length>0,l=s?null:c(e,`branch`),u=s?i:[l],d=u[0]?.id??n,f=r?Do(e.paneLayout,t)??e.paneLayout:e.paneLayout;f=Oo(f,n,d);let p=Co(f),m=e.activePaneId===t?p[0]?.id??e.activePaneId:e.activePaneId,h=wo(f,m)??d;return o=h,{...e,sessions:u.map(e=>e.id===h?{...e,unread:0,status:zo(e),lastActiveAt:a}:e),paneLayout:f,activePaneId:m,activeSessionId:h,viewingArchiveId:void 0}}),o){let t=jo(o);t!==null&&ls(e.id,t).catch(()=>{})}if(!Po(r)){let t=jo(r.id);t!==null&&us(e.id,t).catch(()=>{})}},g=async(e,t)=>{let n=r.current.tabs.find(t=>t.id===e),o=n?.sessions.find(e=>e.id===t);if(!n||!o)return;let s=n.activeSessionId===t;if(Po(o)){let r=n.sessions.find(e=>e.id!==t),a=Date.now();if(i(e,e=>{let n=e.sessions.filter(e=>e.id!==t);n.length===0&&(n=[c(e,`branch`)]);let r=n[0]?.id??t;return{...e,sessions:n.map(e=>e.id===r&&e.status===`background`?{...e,status:zo(e),unread:0,lastActiveAt:Date.now()}:e),paneLayout:Oo(e.paneLayout,t,r),activeSessionId:r,viewingArchiveId:void 0}}),r){let t=zo(r);l(e,r.id,{status:t,last_active_at:a})}return}let u=jo(t),d=u===null?null:await a(()=>us(e,u),null),f=Date.now(),p=null,m=null;if(i(e,e=>{if(e.sessions.findIndex(e=>e.id===t)===-1)return e;let n={id:d?String(d.id):Q(`archive`),sessionId:o.id,time:d?.time??Ao(),mode:d?.mode??o.mode,snapshot:o},r=e.sessions.filter(e=>e.id!==t).map(e=>({...e,status:Ro(e.status)})),i=r;s?i=[c(e,`branch`),...r]:i.length===0&&(i=[c(e,`branch`)]);let a=i[0]?.id??t;return p=a,m=i[0]?zo(i[0]):null,{...e,sessions:i.map(e=>e.id===a&&e.status===`background`?{...e,status:zo(e),unread:0,lastActiveAt:f}:e.id===a&&s?{...e,unread:0,lastActiveAt:f}:e),archive:[n,...e.archive],paneLayout:Oo(e.paneLayout,t,a),activeSessionId:a,viewingArchiveId:void 0}}),s&&p){let t=jo(p);t!==null&&ls(e,t).catch(()=>{}),m&&l(e,p,{status:m,last_active_at:f})}},_=async(e,t,a)=>{let s=r.current.tabs.find(t=>t.id===e),c=s?.sessions.find(e=>e.id===t);if(!s||!c)return;i(e,e=>({...e,sessions:e.sessions.map(n=>{if(n.id!==t)return n;let r=n.id===e.activeSessionId?0:n.unread+1;return{...n,status:`idle`,unread:r,lastActiveAt:Date.now(),messages:a?[...n.messages,{id:Q(`msg`),role:`system`,content:a,time:Ao()}]:n.messages}})})),l(e,t,{status:`idle`,last_active_at:Date.now()});let u=r.current.tabs.find(t=>t.id===e),d=u?.sessions.find(e=>e.id===t);!u||!d||u.activeSessionId!==t&&c.status!==`idle`&&o({id:Q(`toast`),text:a??n(`taskCompletedToast`,{title:d.title}),sessionId:t})};return{buildDraftSessionMessages:s,createDraftSessionForTab:c,syncSessionPatch:l,touchSession:u,materializeSession:d,refreshTabFromBackend:f,onNewSession:p,onSwitchSession:m,onCloseAgentPane:h,archiveSessionForTab:g,markSessionIdle:_,settleSessionAfterExit:async(e,t)=>{let i=r.current.tabs.find(t=>t.id===e),a=i?.sessions.find(e=>e.id===t);!i||!a||a.status!==`idle`&&await _(e,t,n(`agentExited`))}}},ps=(e,t,n)=>Z(`terminal_create`,{workspaceId:e,cwd:t,target:n}),ms=(e,t,n)=>Z(`terminal_write`,{workspaceId:e,terminalId:t,input:n}),hs=(e,t,n,r)=>Z(`terminal_resize`,{workspaceId:e,terminalId:t,cols:n,rows:r}),gs=(e,t)=>Z(`terminal_close`,{workspaceId:e,terminalId:t}),_s=(e,t,n,r,i)=>{if(!t||!n)return;let a=Number(n.replace(`term-`,``));if(!Number.isFinite(a))return;let o=e.current;o.id===n&&o.cols===r&&o.rows===i||(e.current={id:n,cols:r,rows:i},hs(t,a,r,i).catch(()=>{}))},vs=(e,t,n)=>{if(!t)return;let r=Number(t.replace(`term-`,``));Number.isFinite(r)&&ms(e,r,n).catch(()=>{})},ys=async({tab:e,locale:t,updateTab:n,withServiceFallback:r,addToast:i,activeSessionId:a,createToastId:o,t:s})=>{let c=e.project;if(!c?.path)return i({id:o(),text:s(`selectProjectFirst`),sessionId:a}),!1;let l=await r(()=>ps(e.id,c.path,c.target),{id:Date.now(),output:``});return n(e.id,e=>{let n={id:`term-${l.id}`,title:jn(e.terminals.length+1,t),output:l.output??``};return{...e,terminals:[...e.terminals,n],activeTerminalId:n.id}}),!0},bs=(e,t,n)=>{e(t,e=>({...e,activeTerminalId:n}))},xs=async(e,t,n,r)=>{let i=Number(t.replace(`term-`,``));Number.isFinite(i)&&await r(()=>gs(e.id,i),null),n(e.id,e=>{let n=e.terminals.filter(e=>e.id!==t),r=e.activeTerminalId===t?n[0]?.id??``:e.activeTerminalId;return{...e,terminals:n,activeTerminalId:r}})},Ss=(e,t,n,r=`default`)=>(r===`name`?[...e].sort((e,t)=>(Dr(e.project?.path)||Fn(e.title,n)).localeCompare(Dr(t.project?.path)||Fn(t.title,n),n===`zh`?`zh-CN`:`en`)):e).map(e=>({id:e.id,label:Dr(e.project?.path)||Fn(e.title,n),active:e.id===t,hasRunning:e.sessions.some(e=>[`running`,`waiting`,`background`].includes(e.status)),unread:e.sessions.reduce((e,t)=>e+t.unread,0)})),Cs=({locale:e,appSettings:t,onSelectLocale:n,onCommitSettings:r,onCloseSettings:i})=>{let[a]=s(xa),[o,c]=(0,p.useState)(()=>ta(t)),[l,u]=(0,p.useState)(`general`),[d,f]=(0,p.useState)({loading:!1,available:null,runtimeLabel:``}),m=(0,p.useMemo)(()=>Dn(e),[e]),h=a.tabs.find(e=>e.id===a.activeTabId)??a.tabs[0],g=Ss(a.tabs,a.activeTabId,e);(0,p.useEffect)(()=>{c(ta(t))},[t]),(0,p.useEffect)(()=>{let e=o.agentCommand.trim();if(!e){f({loading:!1,available:null,runtimeLabel:``});return}let t=!1,n=window.setTimeout(async()=>{f(e=>({...e,loading:!0,error:void 0}));try{let n=await Qi(e,h?.project?.target??{type:`native`},h?.project?.path);if(t)return;f({loading:!1,available:n.available,runtimeLabel:h?.project?.target?.type===`wsl`?h.project?.target.distro?.trim()?`WSL (${h.project.target.distro.trim()})`:`WSL`:m(`nativeTarget`),resolvedPath:n.resolved_path??void 0,error:n.error??void 0})}catch(e){if(t)return;f({loading:!1,available:!1,runtimeLabel:h?.project?.target?.type===`wsl`?h.project?.target.distro?.trim()?`WSL (${h.project.target.distro.trim()})`:`WSL`:m(`nativeTarget`),error:e instanceof Error?e.message:String(e)})}},220);return()=>{t=!0,window.clearTimeout(n)}},[o.agentCommand,h?.project?.path,h?.project?.target?.type,h?.project?.target?.type===`wsl`?h?.project?.target.distro:``,m]);let _=e=>{c(ta(e)),r(e)},v=e=>{_({...o,...e,idlePolicy:e.idlePolicy?{...e.idlePolicy}:o.idlePolicy})},y=e=>{_({...o,idlePolicy:{enabled:e.enabled??o.idlePolicy.enabled,idleMinutes:Math.max(1,Number(e.idleMinutes??o.idlePolicy.idleMinutes)||1),maxActive:Math.max(1,Number(e.maxActive??o.idlePolicy.maxActive)||1),pressure:e.pressure??o.idlePolicy.pressure}})},b=o.agentCommand.trim(),x=d.loading?`checking`:b?d.available?`available`:`missing`:`idle`,S=d.loading?m(`launchCommandChecking`):b?d.available?m(`launchCommandAvailable`,{runtime:d.runtimeLabel||m(`nativeTarget`)}):m(`launchCommandMissing`,{runtime:d.runtimeLabel||m(`nativeTarget`)}):m(`launchCommandEmpty`),C=b?d.available?d.resolvedPath?m(`launchCommandResolvedPath`,{path:d.resolvedPath}):``:d.error??``:``;return(0,J.jsxs)(`div`,{className:`app`,"data-theme":`dark`,children:[(0,J.jsx)(Yi,{isSettingsRoute:!0,locale:e,workspaceTabs:g,onSwitchWorkspace:()=>{},onAddTab:()=>{},onRemoveTab:()=>{},onOpenSettings:()=>{},onCloseSettings:i,onOpenCommandPalette:()=>{},t:m}),(0,J.jsx)(Ji,{locale:e,activeSettingsPanel:l,settingsDraft:o,launchCommandStatus:{stateClass:x,text:S,detailText:C},onSettingsPanelChange:u,onSettingsChange:v,onSettingsIdlePolicyChange:y,onSelectLocale:n,t:m})]})},ws=({locale:e,inputRef:t,query:n,activeIndex:r,actions:i,activeAction:a,onClose:o,onQueryChange:s,onActivateIndex:c,onRunAction:l})=>(0,J.jsx)(`div`,{className:`command-palette-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&o()},children:(0,J.jsxs)(`div`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":e===`zh`?`快速操作面板`:`Quick actions palette`,onMouseDown:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`command-palette-search-row`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`input`,{ref:t,className:`command-palette-search-input`,value:n,onChange:e=>s(e.target.value),placeholder:e===`zh`?`搜索操作、面板或工作区…`:`Search actions, panels, or workspaces...`,onKeyDown:e=>{if(e.key===`ArrowDown`){e.preventDefault(),c(e=>i.length?Math.min(e+1,i.length-1):0);return}if(e.key===`ArrowUp`){e.preventDefault(),c(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault(),l(a);return}e.key===`Escape`&&(e.preventDefault(),o())}})]}),(0,J.jsx)(`div`,{className:`command-palette-results`,children:i.length===0?(0,J.jsx)(`div`,{className:`command-palette-empty`,children:e===`zh`?`未找到匹配操作`:`No matching actions`}):i.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`command-palette-item ${t===r?`active`:``}`,onMouseEnter:()=>c(t),onClick:()=>l(e),children:[(0,J.jsxs)(`span`,{className:`command-palette-item-copy`,children:[(0,J.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,J.jsx)(`span`,{className:`command-palette-item-description`,children:e.description})]}),e.shortcut&&(0,J.jsx)(`span`,{className:`command-palette-shortcut`,children:e.shortcut})]},e.id))})]})}),Ts=({nodes:e,depth:t=0,onSelect:n,collapsedPaths:r,onToggleCollapse:i,locale:a=`en`,selectedPath:o,rootPath:s})=>e?.length?(0,J.jsx)(`div`,{className:`tree tree-list`,children:Ta(e,a).map(e=>{let c=e.kind===`dir`,l=c?r?.has(e.path)??!1:!1,u=o?Sr(o):``,d=!c&&!!o&&Sr(s?xr(s,e.path):e.path)===u;return(0,J.jsxs)(`div`,{className:`tree-node`,children:[(0,J.jsxs)(`div`,{className:`tree-line ${e.kind===`file`?`file`:`dir`} ${e.status?`changed`:``} ${d?`selected`:``}`,style:{paddingLeft:`${t*16+8}px`},onClick:()=>{if(c){i?.(e.path);return}n?.(e)},children:[(0,J.jsx)(`span`,{className:`tree-disclosure`,children:c?l?(0,J.jsx)(Ri,{}):(0,J.jsx)(Li,{}):null}),(0,J.jsx)(`span`,{className:`tree-icon`,children:Ki(e.name,c,l)}),(0,J.jsx)(`span`,{className:`tree-label`,children:e.name}),e.status&&(0,J.jsx)(`span`,{className:`status`,children:e.status})]}),e.children?.length&&l?(0,J.jsx)(`div`,{className:`tree-children`,children:(0,J.jsx)(Ts,{nodes:e.children,depth:t+1,onSelect:n,collapsedPaths:r,onToggleCollapse:i,locale:a,selectedPath:o,rootPath:s})}):null]},e.path)})}):null,Es=({locale:e,worktree:t,view:n,collapsedPaths:r,onClose:i,onViewChange:a,onFileSelect:o,onToggleCollapse:s,t:c})=>(0,J.jsx)(`div`,{className:`modal-overlay`,children:(0,J.jsxs)(`div`,{className:`modal-card`,children:[(0,J.jsxs)(`div`,{className:`modal-header`,children:[(0,J.jsx)(`h3`,{children:t.name}),(0,J.jsx)(`button`,{className:`btn tiny`,onClick:i,children:c(`close`)})]}),(0,J.jsx)(`div`,{className:`file-tabs`,children:[`status`,`diff`,`tree`].map(e=>(0,J.jsx)(`div`,{className:`t-tab ${n===e?`active`:``}`,onClick:()=>a(e),children:c(e===`status`?`statusTab`:e===`diff`?`diff`:`treeTab`)},e))}),(0,J.jsxs)(`div`,{className:`modal-body`,children:[t.loading&&(0,J.jsx)(`div`,{className:`empty`,children:c(`loadingWorktreeDetails`)}),n===`status`&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`muted`,children:[c(`path`),`: `,t.path]}),(0,J.jsxs)(`div`,{className:`muted`,children:[c(`branch`),`: `,t.branch]}),(0,J.jsx)(`div`,{className:`status`,children:t.status||c(`clean`)})]}),n===`diff`&&(0,J.jsx)(`pre`,{className:`diff`,children:t.diff||c(`noDiffAvailable`)}),n===`tree`&&(0,J.jsx)(Ts,{nodes:t.tree??[],onSelect:o,collapsedPaths:r,locale:e,onToggleCollapse:s})]})]})}),Ds=({visible:e,target:t,input:n,canUseWsl:r,folderBrowser:i,onUpdateTarget:a,onBrowseDirectory:o,onStartWorkspace:s,t:c})=>{if(!e)return null;let l=n.trim(),u=i.roots.filter(e=>e.id!==`root`&&e.path!==i.homePath);return(0,J.jsx)(`div`,{className:`overlay`,"data-testid":`overlay`,children:(0,J.jsx)(`div`,{className:`modal onboarding-modal`,children:(0,J.jsxs)(`div`,{className:`onboarding-form`,children:[(0,J.jsx)(`div`,{className:`onboarding-header`,children:(0,J.jsx)(`h2`,{children:c(`localFolder`)})}),(0,J.jsx)(`div`,{className:`choice-grid`,children:(0,J.jsxs)(`div`,{className:`choice active`,"data-testid":`choice-local-only`,children:[(0,J.jsx)(`strong`,{children:c(`localFolder`)}),(0,J.jsx)(`div`,{className:`hint`,children:c(`localFolderHint`)})]})}),r&&(0,J.jsxs)(`div`,{className:`choice-grid small`,children:[(0,J.jsxs)(`div`,{className:`choice ${t.type===`native`?`active`:``}`,onClick:()=>a({type:`native`}),children:[(0,J.jsx)(`strong`,{children:c(`nativeTarget`)}),(0,J.jsx)(`div`,{className:`hint`,children:c(`nativeTargetHint`)})]}),(0,J.jsxs)(`div`,{className:`choice ${t.type===`wsl`?`active`:``}`,onClick:()=>a({type:`wsl`}),children:[(0,J.jsx)(`strong`,{children:`WSL`}),(0,J.jsx)(`div`,{className:`hint`,children:c(`wslHint`)})]})]}),r&&t.type===`wsl`&&(0,J.jsx)(`input`,{value:t.distro??``,onChange:e=>a({type:`wsl`,distro:e.target.value}),placeholder:c(`optionalDistroPlaceholder`)}),(0,J.jsxs)(`div`,{className:`local-picker web-folder-picker`,"data-testid":`folder-select`,children:[(0,J.jsxs)(`div`,{className:`web-folder-picker-toolbar`,children:[(0,J.jsxs)(`div`,{className:`web-folder-picker-paths`,children:[(0,J.jsx)(`div`,{className:`hint`,"data-testid":`folder-selected`,children:c(`selected`)}),(0,J.jsx)(`strong`,{children:l||i.currentPath||c(`loading`)}),(0,J.jsx)(`div`,{className:`web-folder-picker-tip`,children:c(`folderBrowserInteractionHint`)})]}),(0,J.jsxs)(`div`,{className:`web-folder-picker-actions`,children:[(0,J.jsx)(`button`,{className:`btn tiny ghost`,type:`button`,onClick:()=>o(i.homePath||void 0,!0),disabled:i.loading,children:c(`homeDirectory`)}),(0,J.jsx)(`button`,{className:`btn tiny ghost`,type:`button`,onClick:()=>o(i.parentPath,!0),disabled:i.loading||!i.parentPath,children:c(`goUp`)})]})]}),i.notice&&(0,J.jsx)(`div`,{className:`folder-browser-notice`,children:i.notice}),u.length>0&&(0,J.jsx)(`div`,{className:`web-folder-picker-roots`,children:u.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`folder-root-chip ${l===e.path||i.currentPath===e.path?`active`:``}`,onClick:()=>o(e.path,!0),title:c(`folderBrowserInteractionHint`),children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`small`,{children:e.description})]},e.id))}),(0,J.jsxs)(`div`,{className:`web-folder-picker-list`,children:[i.loading&&(0,J.jsx)(`div`,{className:`tree-empty`,children:c(`loadingDirectories`)}),!i.loading&&i.error&&(0,J.jsx)(`div`,{className:`tree-empty`,children:i.error}),!i.loading&&!i.error&&i.entries.length===0&&(0,J.jsx)(`div`,{className:`tree-empty`,children:c(`emptyDirectories`)}),!i.loading&&!i.error&&i.entries.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`folder-browser-row ${l===e.path?`selected`:``}`,onClick:()=>o(e.path,!0),title:c(`folderBrowserInteractionHint`),children:[(0,J.jsxs)(`span`,{className:`folder-browser-row-meta`,children:[(0,J.jsxs)(`span`,{className:`folder-browser-row-name`,children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:e.name})]}),(0,J.jsx)(`span`,{className:`folder-browser-row-hint`,children:c(`folderBrowserRowHint`)})]}),(0,J.jsxs)(`span`,{className:`folder-browser-row-action`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:c(`enterFolder`)}),(0,J.jsx)(Li,{})]})]},e.path))]})]}),(0,J.jsx)(`div`,{className:`modal-actions`,children:(0,J.jsx)(`button`,{className:`btn primary`,onClick:s,"data-testid":`start-workspace`,disabled:!l,children:c(`startWorkspace`)})})]})})})},Os=({locale:e,isExpanded:t,width:n,codeSidebarView:r,previewPathLabel:i,previewFileName:a,fileSearchQuery:o,fileSearchActiveIndex:s,showFileSearchDropdown:c,searchShellRef:l,fileSearchInputRef:u,editorContent:d,sidebarContent:f,onSetSidebarView:p,onFileSearchChange:m,onFileSearchFocus:h,onFileSearchBlur:g,onFileSearchKeyDown:_,onToggleExpanded:v,t:y})=>(0,J.jsx)(`section`,{className:`panel workspace-code-shell`,style:t?{flex:`1 1 100%`}:{flex:`0 0 ${n}px`},children:(0,J.jsxs)(`div`,{className:`panel-inner workspace-code-panel`,children:[(0,J.jsxs)(`div`,{className:`workspace-code-header`,children:[(0,J.jsx)(`div`,{className:`workspace-code-modes`,children:t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${r===`files`?`active`:``}`,onClick:()=>p(`files`),children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:y(`files`)})]}),(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${r===`git`?`active`:``}`,onClick:()=>p(`git`),children:[(0,J.jsx)(Si,{}),(0,J.jsx)(`span`,{children:`Git Diff`})]}),i&&(0,J.jsx)(`span`,{className:`workspace-code-current-path`,title:i,children:i})]}):(0,J.jsxs)(`div`,{className:`workspace-code-title-block`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`codePanel`)}),(0,J.jsx)(`strong`,{children:a||y(`selectFileFromNavigator`)})]})}),(0,J.jsxs)(`div`,{className:`workspace-code-actions`,children:[(0,J.jsx)(`div`,{className:`workspace-search-shell`,ref:l,children:(0,J.jsxs)(`div`,{className:`workspace-search-field`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`input`,{ref:u,value:o,onChange:e=>m(e.target.value),onFocus:e=>h(e.currentTarget.value),onBlur:g,onKeyDown:_,placeholder:e===`zh`?`搜索文件并跳转…`:`Search files and jump...`,autoComplete:`off`,spellCheck:!1,"aria-expanded":c,"aria-controls":`workspace-file-search-results`,"aria-activedescendant":c?`workspace-file-search-option-${s}`:void 0})]})}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:v,"aria-label":t?e===`zh`?`退出展开`:`Exit expand`:e===`zh`?`展开代码区`:`Expand code area`,title:t?e===`zh`?`退出展开`:`Exit expand`:e===`zh`?`展开代码区`:`Expand code area`,children:t?(0,J.jsx)(Bi,{}):(0,J.jsx)(zi,{})})]})]}),(0,J.jsxs)(`div`,{className:`workspace-code-body ${t?`expanded`:`collapsed`}`,children:[(0,J.jsx)(`div`,{className:`workspace-code-editor`,children:d}),t&&(0,J.jsx)(`aside`,{className:`workspace-code-sidebar`,children:f})]})]})}),ks=e(n(),1),As=({container:e,locale:t,dropdownStyle:n,results:r,activeIndex:i,onHover:a,onSelect:o,fileParentLabel:s})=>(0,ks.createPortal)((0,J.jsx)(`div`,{className:`workspace-search-dropdown floating ${n.placement}`,id:`workspace-file-search-results`,role:`listbox`,style:{left:n.left,width:n.width,maxHeight:n.maxHeight,top:n.top,bottom:n.bottom},children:r.length===0?(0,J.jsx)(`div`,{className:`workspace-search-empty`,children:t===`zh`?`未找到匹配文件`:`No matching files`}):r.map((e,t)=>(0,J.jsxs)(`button`,{id:`workspace-file-search-option-${t}`,type:`button`,role:`option`,"aria-selected":t===i,tabIndex:-1,className:`code-search-result ${t===i?`active`:``}`,onMouseEnter:()=>a(t),onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,J.jsx)(`span`,{className:`code-search-result-name`,children:e.name}),(0,J.jsx)(`span`,{className:`code-search-result-path`,children:s(e.path)||`.`})]},e.absolutePath))}),e),js=({locale:e,isFocusMode:t,isCodeExpanded:n,showAgentPanel:r,showCodePanel:i,showTerminalPanel:a,rightSplit:o,workspaceFolderName:s,branchName:c,changeCount:l,agentPanel:u,codePanel:d,terminalPanel:f,onToggleRightPane:p,t:m})=>(0,J.jsxs)(`main`,{className:`workspace-shell`,children:[(0,J.jsxs)(`div`,{className:`workspace-main-header workspace-shell-header`,children:[(0,J.jsx)(`div`,{className:`workspace-main-header-copy`,children:(0,J.jsxs)(`div`,{className:`workspace-main-meta`,children:[(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:s})]}),(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(xi,{}),(0,J.jsx)(`span`,{children:c||`—`})]}),(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(Si,{}),(0,J.jsx)(`span`,{children:m(`changesCount`,{count:l})})]})]})}),(0,J.jsxs)(`div`,{className:`workspace-main-actions`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${i?`active`:``}`,onClick:()=>p(`code`),title:m(`codePanel`),"aria-pressed":i,children:[(0,J.jsx)(Ci,{}),(0,J.jsx)(`span`,{children:m(`codePanel`)})]}),(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${a?`active`:``}`,onClick:()=>p(`terminal`),title:m(`terminalPanel`),"aria-pressed":a,children:[(0,J.jsx)(wi,{}),(0,J.jsx)(`span`,{children:m(`terminalPanel`)})]}),(0,J.jsx)(`span`,{className:`workspace-shortcut-hint`,children:e===`zh`?`⌘/Ctrl+K 快速操作`:`⌘/Ctrl+K actions`})]})]}),(0,J.jsxs)(`div`,{className:`workspace-stack ${t?`focus-mode`:``} ${n?`code-expanded`:``}`,children:[(0,J.jsxs)(`div`,{className:`workspace-top-shell`,style:!n&&a?{flex:`0 0 ${o}%`}:void 0,children:[r&&u,i&&d]}),!n&&a&&f]})]}),Ms=({locale:e,view:t,fileTree:n,rootPath:r,selectedPath:i,repoCollapsedPaths:a,gitChangeGroups:o,activeGitChangeKey:s,commitMessage:c,onCommitMessageChange:l,onFileSelect:u,onToggleRepoCollapse:d,onRefresh:f,onStageAll:p,onUnstageAll:m,onDiscardAll:h,onCommit:g,onGitChangeSelect:_,onGitChangeAction:v,t:y})=>t===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`workspace-code-sidebar-head`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`repositoryNavigator`)}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:f,title:y(`refresh`),"aria-label":y(`refresh`),children:(0,J.jsx)(Fi,{})})]}),n.length===0?(0,J.jsx)(`div`,{className:`tree-empty`,children:y(`selectProjectToLoadFiles`)}):(0,J.jsx)(Ts,{nodes:n,onSelect:u,collapsedPaths:a,locale:e,selectedPath:i,rootPath:r,onToggleCollapse:d})]}):(0,J.jsxs)(`div`,{className:`workspace-git-sidebar`,children:[(0,J.jsxs)(`div`,{className:`workspace-code-sidebar-head git-sidebar-head`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`sourceControl`)}),(0,J.jsxs)(`div`,{className:`git-toolbar-actions`,children:[(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:f,title:y(`refresh`),"aria-label":y(`refresh`),children:(0,J.jsx)(Fi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:p,title:y(`stageAll`),"aria-label":y(`stageAll`),children:(0,J.jsx)(Mi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:m,title:y(`unstageAll`),"aria-label":y(`unstageAll`),children:(0,J.jsx)(Ni,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:h,title:y(`discardAll`),"aria-label":y(`discardAll`),children:(0,J.jsx)(Pi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:g,disabled:!c.trim(),title:y(`commit`),"aria-label":y(`commit`),children:(0,J.jsx)(Ti,{})})]})]}),(0,J.jsx)(`div`,{className:`workspace-git-compose`,children:(0,J.jsx)(`div`,{className:`form-row`,children:(0,J.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:y(`commitPlaceholder`),"data-testid":`git-commit-message`,className:`workspace-git-commit-input`})})}),(0,J.jsxs)(`div`,{className:`source-control-list`,children:[o.length===0&&(0,J.jsx)(`div`,{className:`tree-empty`,children:y(`noChangesDetected`)}),o.map(e=>(0,J.jsxs)(`div`,{className:`source-group`,children:[(0,J.jsxs)(`div`,{className:`source-group-head`,children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{children:e.items.length})]}),(0,J.jsx)(`div`,{className:`source-group-items`,children:e.items.map(e=>{let t=`${e.section}:${e.path}:${e.code}`,n=e.section===`staged`?[{id:`unstage`,title:y(`unstageFile`),icon:(0,J.jsx)(Ni,{})}]:[{id:`stage`,title:y(`stageFile`),icon:(0,J.jsx)(Mi,{})},{id:`discard`,title:y(`discardFile`),icon:(0,J.jsx)(Pi,{})}];return(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,className:`source-change-row ${s===t?`active`:``}`,"data-section":e.section,onClick:()=>_(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_(e))},children:[(0,J.jsx)(`span`,{className:`source-change-file-icon`,"aria-hidden":`true`,children:Ki(e.name,!1,!1)}),(0,J.jsxs)(`span`,{className:`source-change-copy`,children:[(0,J.jsx)(`span`,{className:`source-change-name`,children:e.name}),(0,J.jsx)(`span`,{className:`source-change-parent`,children:e.parent||`.`})]}),(0,J.jsxs)(`span`,{className:`source-change-tail`,children:[(0,J.jsx)(`span`,{className:`source-status-badge ${e.section}`,title:e.status,children:e.code}),(0,J.jsx)(`span`,{className:`source-change-actions`,children:n.map(t=>(0,J.jsx)(`button`,{type:`button`,className:`source-action-btn`,title:t.title,"aria-label":t.title,onClick:n=>{n.stopPropagation(),v(e,t.id)},children:t.icon},t.id))})]})]},t)})})]},e.key))]})]}),Ns=({progressPercent:e,progressTone:t,activeTerminalId:n,terminals:r,terminalContent:i,onResizeStart:a,onSelect:o,onClose:s,onAdd:c,hasActiveTerminal:l,t:u})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-resizer workspace-bottom-splitter`,"data-resize":`right-split`,onPointerDown:a}),(0,J.jsx)(`section`,{className:`panel workspace-terminal-shell`,children:(0,J.jsxs)(`div`,{className:`panel-inner terminal-card workspace-terminal-panel`,children:[(0,J.jsx)(`div`,{className:`surface-progress ${t}`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`${e}%`}})}),(0,J.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,J.jsx)(`div`,{className:`terminal-toolbar-title`,children:u(`terminalPanel`)}),(0,J.jsxs)(`div`,{className:`terminal-toolbar-actions`,children:[(0,J.jsx)(`select`,{className:`terminal-select`,value:n??``,onChange:e=>o(e.target.value),children:r.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.title},e.id))}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:s,disabled:!l,title:u(`close`),"aria-label":u(`close`),children:(0,J.jsx)(Di,{})}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:c,title:u(`new`),"aria-label":u(`new`),children:(0,J.jsx)(Ei,{})})]})]}),(0,J.jsx)(`div`,{className:`terminal-output`,children:i})]})})]}),Ps=15e3,Fs=1e4,Is=class{pingTimer=null;pongTimer=null;constructor(e){this.options=e}start(){this.stop(),this.scheduleNextPing()}stop(){this.pingTimer!==null&&(window.clearTimeout(this.pingTimer),this.pingTimer=null),this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}markAlive(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}scheduleNextPing(){this.pingTimer=window.setTimeout(()=>{this.options.send({type:`ping`,ts:Date.now()}),this.pongTimer=window.setTimeout(()=>{this.options.onTimeout()},Fs),this.scheduleNextPing()},Ps)}},Ls=e=>{try{let t=JSON.parse(e);return t?.type===`event`&&typeof t.event==`string`?{type:`event`,event:t.event,payload:t.payload}:(t?.type===`ping`||t?.type===`pong`)&&typeof t.ts==`number`?t:null}catch{return null}},Rs=new class{listeners=new Map;socket=null;reconnectTimer=null;activeSocketUrl=``;healthProbe=null;heartbeat=new Is({send:e=>{this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))},onTimeout:()=>{this.socket?.close()}});subscribe(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),this.connect(),()=>{let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e),this.prune())}}notify(e){let t=this.listeners.get(e.event);t&&t.forEach(t=>t(e.payload))}scheduleReconnect(){this.reconnectTimer!==null||this.listeners.size===0||(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},800))}connect(){if(typeof window>`u`||fr()&&!pr())return;let e=``;try{e=Jn()}catch{this.scheduleReconnect();return}this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)&&this.activeSocketUrl===e||(this.socket&&=(this.socket.close(),null),this.activeSocketUrl=e,this.openSocket(e))}async ensureBackendReady(){return this.healthProbe||=fetch(qn(),{method:`GET`,cache:`no-store`,credentials:`include`}).then(e=>e.ok).catch(()=>!1).finally(()=>{this.healthProbe=null}),this.healthProbe}async openSocket(e){if(!await this.ensureBackendReady()){this.scheduleReconnect();return}this.listeners.size===0||this.activeSocketUrl!==e||this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)||(this.socket=new WebSocket(e),this.socket.addEventListener(`open`,()=>{this.heartbeat.start()}),this.socket.addEventListener(`message`,e=>{let t=Ls(String(e.data));if(t){if(t.type===`event`){this.notify(t);return}if(t.type===`pong`){this.heartbeat.markAlive();return}t.type===`ping`&&this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:`pong`,ts:t.ts}))}}),this.socket.addEventListener(`close`,()=>{this.heartbeat.stop(),this.socket=null,this.scheduleReconnect()}),this.socket.addEventListener(`error`,()=>{this.socket?.close()}))}prune(){this.listeners.size>0||(this.heartbeat.stop(),this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.socket&&=(this.socket.close(),null))}},zs=(e,t)=>Rs.subscribe(e,t),Bs=e=>zs(`agent://event`,e),Vs=e=>zs(`agent://lifecycle`,e),Hs=e=>zs(`terminal://event`,e),Us=e=>{if(typeof window>`u`)return{background:`#0b151a`,foreground:`#d8edf4`,cursor:`#8fffae`,cursorAccent:`#0d1418`};let t=window.getComputedStyle(e??document.documentElement),n=window.getComputedStyle(document.documentElement),r=(e,r)=>t.getPropertyValue(e).trim()||n.getPropertyValue(e).trim()||r;return{background:r(`--terminal-bg`,`#0b151a`),foreground:r(`--terminal-fg`,`#d8edf4`),cursor:r(`--terminal-cursor`,`#8fffae`),cursorAccent:r(`--terminal-cursor-accent`,`#0d1418`),selectionBackground:r(`--terminal-selection`,`rgba(90, 200, 250, 0.3)`),selectionInactiveBackground:r(`--terminal-selection-inactive`,`rgba(90, 200, 250, 0.2)`),black:r(`--ansi-black`,`#5f7680`),red:r(`--ansi-red`,`#ff9eb0`),green:r(`--ansi-green`,`#8fffae`),yellow:r(`--ansi-yellow`,`#ffd37a`),blue:r(`--ansi-blue`,`#5ac8fa`),magenta:r(`--ansi-magenta`,`#b9a4ff`),cyan:r(`--ansi-cyan`,`#79f6de`),white:r(`--ansi-white`,`#e7f3f7`),brightBlack:r(`--ansi-bright-black`,`#8da6b0`),brightRed:r(`--ansi-bright-red`,`#ffbac6`),brightGreen:r(`--ansi-bright-green`,`#b8ffca`),brightYellow:r(`--ansi-bright-yellow`,`#ffe7a6`),brightBlue:r(`--ansi-bright-blue`,`#9edfff`),brightMagenta:r(`--ansi-bright-magenta`,`#d8caff`),brightCyan:r(`--ansi-bright-cyan`,`#a7fff0`),brightWhite:r(`--ansi-bright-white`,`#f4fbfd`)}},Ws=(e,t)=>{if(t===e)return``;if(t.startsWith(e))return t.slice(e.length);let n=Math.min(256,t.length);if(n===0)return null;let r=t.slice(0,n),i=e.lastIndexOf(r);if(i===-1)return null;let a=e.slice(i);return t.startsWith(a)?t.slice(a.length):null},Gs=(e,t,n)=>{if(n===t)return;let r=Ws(t,n);if(r!==null){r&&e.write(r);return}e.reset(),n&&e.write(n)},Ks=3,qs=e=>e?e.closest(`.agent-pane-card`)??e.closest(`.terminal-card`)??e.closest(`.app`):null,Js=(0,p.forwardRef)(({output:e,outputIdentity:t,themeIdentity:n,theme:r,fontSize:i,mode:a=`interactive`,className:o=`agent-pane-xterm`,sanitizeOutput:s,onData:c,onSize:l,autoFocus:f=!1},m)=>{let h=(0,p.useRef)(null),g=(0,p.useRef)(null),_=(0,p.useRef)(null),v=(0,p.useRef)(``),y=(0,p.useRef)(void 0),b=(0,p.useRef)(null),x=(0,p.useCallback)(()=>{let e=g.current;if(!e||!l)return;let t={cols:e.cols,rows:e.rows};b.current?.cols===t.cols&&b.current?.rows===t.rows||(b.current=t,l(t))},[l]),S=(0,p.useCallback)(()=>{_.current?.fit(),x()},[x]);return(0,p.useEffect)(()=>{let e=h.current;if(e){if(!g.current){let t=new u({convertEol:!0,disableStdin:a===`readonly`,cursorBlink:a===`interactive`,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, SFMono-Regular, monospace`,fontSize:i,overviewRuler:{width:Ks},theme:Us(qs(e))}),n=new d;t.loadAddon(n),t.open(e),g.current=t,_.current=n,v.current=``,y.current=void 0,b.current=null,S();return}S()}},[S,i,a]),(0,p.useEffect)(()=>{let e=h.current,t=g.current;!e||!t||(t.options={disableStdin:a===`readonly`,cursorBlink:a===`interactive`,fontSize:i,overviewRuler:{width:Ks},theme:Us(qs(e))},requestAnimationFrame(()=>S()))},[S,i,a,r,n]),(0,p.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>{S()});return t.observe(e),()=>t.disconnect()},[S]),(0,p.useEffect)(()=>{let n=g.current;if(!n)return;y.current!==t&&(n.reset(),v.current=``,y.current=t);let r=s?s(e):e;Gs(n,v.current,r),v.current=r},[e,t,s]),(0,p.useEffect)(()=>{t!==void 0&&(b.current=null,x())},[x,t]),(0,p.useEffect)(()=>{let e=g.current;if(!e||a!==`interactive`||!c)return;let t=e.onData(c);return()=>t.dispose()},[a,c]),(0,p.useEffect)(()=>{f&&g.current?.focus()},[f,t]),(0,p.useImperativeHandle)(m,()=>({fit:S,focus:()=>{g.current?.focus()},size:()=>{let e=g.current;return e?{cols:e.cols,rows:e.rows}:null}}),[S]),(0,p.useEffect)(()=>()=>{g.current?.dispose(),g.current=null,_.current=null,v.current=``,y.current=void 0,b.current=null},[]),(0,J.jsx)(`div`,{ref:h,className:o,onClick:()=>{a===`interactive`&&g.current?.focus()}})});Js.displayName=`XtermBase`;var Ys=(0,p.forwardRef)(({streamId:e,stream:t,toneKey:n,theme:r,fontSize:i,mode:a=`readonly`,autoFocus:o=!1,onData:s,onSize:c},l)=>(0,J.jsx)(Js,{ref:l,outputIdentity:e,themeIdentity:n,output:t,theme:r,fontSize:i,mode:a,onData:s,onSize:c,autoFocus:o,className:`agent-pane-xterm`}));Ys.displayName=`AgentStreamTerminal`;var Xs=(0,p.forwardRef)(({terminalId:e,output:t,theme:n,fontSize:r,autoFocus:i=!1,onData:a,onSize:o},s)=>(0,J.jsx)(Js,{ref:s,outputIdentity:e,output:t,theme:n,fontSize:r,mode:`interactive`,onData:a,onSize:o,autoFocus:i,className:`agent-pane-xterm`}));Xs.displayName=`ShellTerminal`;var Zs=e=>e&&e.replace(/\x1b\][^\u0007]*(\u0007|\x1b\\)/g,``).replace(/\x1b\[(?![0-9;:]*m)[0-?]*[ -/]*[@-~]/g,``).replace(/\x1b(?!\[)/g,``).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,``).replace(/\r/g,``),Qs=e=>e&&Zs(e).replace(/\x1b\[[0-9;:]*m/g,``),$s=e=>e.replace(/\x1b\][^\u0007]*(\u0007|\x1b\\)/g,``).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,``).replace(/\x1b./g,``),ec=({visible:e,activeTab:t,activePaneSession:n,viewedSession:r,isArchiveView:i,showCodePanel:a,theme:o,terminalFontSize:s,draftPromptInputs:c,displaySessionTitle:l,onExitArchive:u,onSetActivePane:d,onSplitPane:f,onCloseAgentPane:p,onSubmitDraftPrompt:m,onDraftPromptChange:h,setDraftPromptInputRef:g,setAgentTerminalRef:_,onAgentTerminalData:v,onAgentTerminalSize:y,onPaneSplitResizeStart:b,onCodeResizeStart:x,t:S})=>{if(!e)return null;let C=Qs(r.stream),w=e=>{if(e.type===`split`)return(0,J.jsxs)(`div`,{className:`agent-split-pane ${e.axis}`,children:[(0,J.jsx)(`div`,{className:`agent-split-child`,style:{flex:`${e.ratio} 1 0%`},children:w(e.first)}),(0,J.jsx)(`div`,{className:`agent-split-divider ${e.axis}`,onPointerDown:b(e.id,e.axis)}),(0,J.jsx)(`div`,{className:`agent-split-child`,style:{flex:`${1-e.ratio} 1 0%`},children:w(e.second)})]},e.id);let r=t.sessions.find(t=>t.id===e.sessionId)??n,i=t.activePaneId===e.id,a=(()=>{let e=Ho(r);return e>0?Math.max(14,e):r.status===`running`||r.status===`background`?34:r.status===`waiting`?22:6})(),u=r.status===`running`||r.status===`background`?`live`:r.status===`waiting`?`queued`:`idle`,x=Vo(r.status),C=Fo(r);return(0,J.jsxs)(`section`,{className:`agent-pane-card ${i?`active`:``}`,onMouseDown:()=>d(e.id,r.id),children:[(0,J.jsx)(`div`,{className:`surface-progress ${u}`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`${a}%`}})}),(0,J.jsxs)(`div`,{className:`agent-pane-header`,children:[(0,J.jsxs)(`div`,{className:`agent-pane-header-copy`,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${x} ${x===`active`?`pulse`:``}`}),(0,J.jsx)(`span`,{className:`agent-pane-title`,children:l(r.title)})]}),(0,J.jsxs)(`div`,{className:`agent-pane-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`pane-action split`,onClick:()=>f(e.id,`vertical`),title:S(`splitVertical`),"aria-label":S(`splitVertical`),children:(0,J.jsx)(Hi,{})}),(0,J.jsx)(`button`,{type:`button`,className:`pane-action split`,onClick:()=>f(e.id,`horizontal`),title:S(`splitHorizontal`),"aria-label":S(`splitHorizontal`),children:(0,J.jsx)(Vi,{})}),(0,J.jsx)(`button`,{type:`button`,className:`pane-action close`,onClick:()=>p(e.id,r.id),title:S(`close`),children:(0,J.jsx)(Di,{})})]})]}),(0,J.jsx)(`div`,{className:`agent-pane-body`,"data-testid":`agent-pane-${e.id}`,children:C?(0,J.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,J.jsxs)(`div`,{className:`agent-draft-launcher-card`,children:[(0,J.jsxs)(`div`,{className:`agent-draft-launcher-copy`,children:[(0,J.jsx)(`div`,{className:`agent-draft-launcher-title`,children:S(`draftSessionPrompt`)}),(0,J.jsx)(`div`,{className:`agent-draft-launcher-hint`,children:S(`draftTaskPlaceholder`)})]}),(0,J.jsx)(`form`,{className:`agent-pane-input agent-draft-launcher-form`,onSubmit:t=>{t.preventDefault(),m(e.id)},children:(0,J.jsxs)(`div`,{className:`agent-compose`,children:[(0,J.jsx)(`input`,{ref:t=>g(e.id,t),className:`agent-compose-field agent-draft-launcher-field`,value:c[e.id]??``,onChange:t=>h(e.id,t.target.value),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},placeholder:S(`draftTaskPlaceholder`),"aria-label":S(`draftTaskPlaceholder`),"data-testid":`agent-draft-input-${e.id}`,autoFocus:i}),(0,J.jsx)(`button`,{type:`submit`,className:`agent-send-button`,disabled:!c[e.id]?.trim(),title:S(`send`),"aria-label":S(`send`),children:(0,J.jsx)(Ti,{})})]})})]})}):(0,J.jsx)(Ys,{ref:t=>_(e.id,t),streamId:r.id,stream:r.stream,toneKey:i?`active`:`inactive`,theme:o,fontSize:s,mode:`interactive`,autoFocus:i,onData:t=>{v(e.id,t)},onSize:n=>y(e.id,t.id,r.id,n)})})]},e.id)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`section`,{className:`panel center-panel workspace-agent-shell`,style:{flex:`1 1 0%`},children:(0,J.jsxs)(`div`,{className:`panel-inner studio-panel compact`,children:[i&&(0,J.jsxs)(`div`,{className:`archive-banner`,children:[(0,J.jsxs)(`div`,{children:[S(`viewingArchivedSession`),(0,J.jsx)(`div`,{className:`hint`,children:S(`exitArchiveHint`)})]}),(0,J.jsx)(`button`,{className:`btn tiny`,onClick:u,children:S(`exit`)})]}),(0,J.jsx)(`div`,{className:`agent-pane-workspace`,children:i?(0,J.jsxs)(`section`,{className:`agent-pane-card archive-only`,children:[(0,J.jsx)(`div`,{className:`agent-pane-header`,children:(0,J.jsxs)(`div`,{className:`agent-pane-header-copy`,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${Vo(r.status)} ${Vo(r.status)===`active`?`pulse`:``}`}),(0,J.jsx)(`span`,{className:`agent-pane-title`,children:l(r.title)})]})}),(0,J.jsx)(`div`,{className:`agent-pane-body`,children:C.trim()?(0,J.jsx)(Ys,{streamId:r.id,stream:r.stream,toneKey:`active`,theme:o,fontSize:s}):(0,J.jsx)(`div`,{className:`terminal-empty`,children:S(`archiveViewReadonly`)})})]}):w(t.paneLayout)})]})}),a&&(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`left`,onPointerDown:x})]})},tc=e=>Z(`agent_start`,e),nc=(e,t,n,r)=>Z(`agent_send`,{workspaceId:e,sessionId:t,input:n,appendNewline:r}),rc=(e,t,n,r)=>Z(`agent_resize`,{workspaceId:e,sessionId:t,cols:n,rows:r});Object.fromEntries([{labelKey:`escKey`,sequence:`\x1B`,key:`Escape`},{labelKey:`tabKey`,sequence:` `,key:`Tab`},{labelKey:`enterKey`,sequence:`\r`,key:`Enter`},{labelKey:`arrowUp`,sequence:`\x1B[A`,key:`ArrowUp`},{labelKey:`arrowDown`,sequence:`\x1B[B`,key:`ArrowDown`},{labelKey:`arrowLeft`,sequence:`\x1B[D`,key:`ArrowLeft`},{labelKey:`arrowRight`,sequence:`\x1B[C`,key:`ArrowRight`}].map(e=>[e.key,e.sequence]));var ic=1e6,ac=1e6,oc=(e,t)=>`${e}:${t}`,sc=(e,t,n)=>e.runningAgentKeysRef.current.has(oc(t,n)),cc=e=>{requestAnimationFrame(()=>{e.agentTerminalRefs.current.forEach(e=>e?.fit())})},lc=(e,t,n)=>{let r=oc(t,n),i=e.agentResizeStateRef.current.get(r);if(!i||i.inflight||!i.pending)return;let a=i.pending;i.pending=void 0;let o=e.agentRuntimeSizeRef.current.get(r);o?.cols===a.cols&&o?.rows===a.rows&&!i.pending||(i.inflight=!0,rc(t,n,a.cols,a.rows).then(()=>{e.agentRuntimeSizeRef.current.set(r,a)}).catch(()=>{e.agentRuntimeSizeRef.current.delete(r)}).finally(()=>{let i=e.agentResizeStateRef.current.get(r);if(i){if(i.inflight=!1,i.pending){lc(e,t,n);return}e.runningAgentKeysRef.current.has(r)||e.agentResizeStateRef.current.delete(r)}}))},uc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentRuntimeSizeRef.current.get(i),o=e.agentResizeStateRef.current.get(i)??{inflight:!1};a?.cols===r.cols&&a?.rows===r.rows&&!o.pending||o.pending?.cols===r.cols&&o.pending?.rows===r.rows||(o.pending=r,e.agentResizeStateRef.current.set(i,o),lc(e,t,n))},dc=(e,t,n,r)=>{let i=e.agentPaneSizeRef.current.get(t)??e.agentTerminalRefs.current.get(t)?.size();i&&uc(e,n,r,i)},fc=(e,t,n)=>{let r=++e.agentStartupTokenRef.current,i=Date.now();return e.agentStartupStateRef.current.set(oc(t,n),{token:r,startedAt:i,lastEventAt:i,sawOutput:!1,sawReady:!1,exited:!1}),r},pc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentStartupStateRef.current.get(i);a&&(r!==void 0&&a.token!==r||e.agentStartupStateRef.current.delete(i))},mc=(e,t,n)=>{let r=oc(t,n);e.runningAgentKeysRef.current.delete(r),e.agentRuntimeSizeRef.current.delete(r),e.agentResizeStateRef.current.delete(r),pc(e,t,n)},hc=(e,t,n)=>{let r=oc(t,n);e.agentRuntimeSizeRef.current.delete(r),e.agentResizeStateRef.current.delete(r),e.runningAgentKeysRef.current.add(r)},gc=(e,t,n)=>{if(n){e.agentTerminalRefs.current.set(t,n);return}e.agentTerminalRefs.current.delete(t),e.agentTerminalQueueRef.current.delete(t),e.agentPaneSizeRef.current.delete(t),e.agentTitleTrackerRef.current.delete(t)},_c=(e,t,n)=>{if(n){e.draftPromptInputRefs.current.set(t,n);return}e.draftPromptInputRefs.current.delete(t)},vc=(e,t)=>{t&&requestAnimationFrame(()=>{let n=e.draftPromptInputRefs.current.get(t);if(n){n.focus();let e=n.value.length;n.setSelectionRange(e,e);return}e.agentTerminalRefs.current.get(t)?.focus()})},yc=(e,t,n,r)=>{let i=e.agentTitleTrackerRef.current.get(t),a=i??{draftSessionId:n.isDraft?n.id:void 0,buffer:``,locked:!1};if(n.isDraft&&i?.draftSessionId!==n.id&&(a.draftSessionId=n.id,a.buffer=``,a.locked=!1),a.locked)return e.agentTitleTrackerRef.current.set(t,a),null;let o=$s(r),s=a.buffer,c=null;for(let e of o){if(e===`\r`||e===`
5
+ `){!c&&s.trim()&&(c=s),s=``;continue}if(e===``||e===`\b`){s=s.slice(0,-1);continue}if(e===` `){s+=` `;continue}e<` `||(s+=e,s.length>240&&(s=s.slice(-240)))}return a.buffer=s,e.agentTitleTrackerRef.current.set(t,a),c},bc=({refs:e,paneId:t,tabId:n,sessionId:r,rawInput:i,locale:a,t:o,updateTab:s})=>{let c=Io(i);if(!c)return;let l=!1;if(s(n,e=>({...e,sessions:e.sessions.map(e=>{if(e.id!==r)return e;let t=jo(e.id),n=t===null?null:kn(t,a);return e.isDraft||e.title===o(`draftSessionTitle`)||n!==null&&e.title===n?(l=!0,{...e,title:c}):e})})),!l)return;let u=e.agentTitleTrackerRef.current.get(t);u&&(u.locked=!0,u.buffer=``,e.agentTitleTrackerRef.current.set(t,u))},xc=(e,t,n,r,i)=>{let a=oc(t,n),o=e.agentStartupStateRef.current.get(a);if(!o)return;if(r===`exit`){o.exited=!0,o.lastEventAt=Date.now();return}let s=Qs(i).trim();(r===`stdout`||r===`stderr`||r===`system`&&s!==``&&s!==`Agent started / 智能体已启动`)&&(o.sawOutput=!0,o.lastEventAt=Date.now())},Sc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentStartupStateRef.current.get(i);if(a){if(r===`session_started`){a.sawReady=!0,a.lastEventAt=Date.now();return}r===`session_ended`&&(a.exited=!0,a.lastEventAt=Date.now())}},Cc=async(e,t,n,r)=>{let i=oc(t,n);for(;;){let a=e.agentStartupStateRef.current.get(i);if(!a||a.token!==r)return;let o=Date.now();if(a.exited){pc(e,t,n,r);return}if(a.sawReady&&o-a.lastEventAt>=120){pc(e,t,n,r);return}if(a.sawOutput&&o-a.lastEventAt>=240){pc(e,t,n,r);return}if(!a.sawOutput&&o-a.startedAt>=1200){pc(e,t,n,r);return}if(o-a.startedAt>=5e3){pc(e,t,n,r);return}await new Promise(e=>window.setTimeout(e,80))}},wc=({locale:e,t,route:n,isFocusMode:r,showCodePanel:i,showTerminalPanel:a,workspaceTabs:o,onAddTab:s,onToggleFocusMode:c,onToggleCodePanel:l,onToggleTerminalPanel:u,onFocusAgent:d,onSplitVertical:f,onSplitHorizontal:p,onCycleWorkspace:m,onOpenSettings:h,onCloseSettings:g,onSwitchWorkspace:_})=>[{id:`new-workspace`,label:e===`zh`?`新建工作区`:`New Workspace`,description:e===`zh`?`创建并切换到新的工作区`:`Create and switch to a new workspace`,shortcut:`⌘/Ctrl N`,keywords:`new workspace tab add create`,run:s},{id:`toggle-focus`,label:e===`zh`?r?`退出专注模式`:`进入专注模式`:r?`Exit Focus Mode`:`Enter Focus Mode`,description:e===`zh`?`隐藏左右面板,聚焦命令流`:`Hide side panels and focus the command stream`,shortcut:`F`,keywords:`focus mode zen panel hide`,run:c},{id:`toggle-code`,label:i?e===`zh`?`隐藏代码面板`:`Hide Code Panel`:e===`zh`?`显示代码面板`:`Show Code Panel`,description:e===`zh`?`切换右侧代码预览区域`:`Toggle the right-side code preview area`,keywords:`code panel preview right inspector`,run:l},{id:`toggle-terminal`,label:a?e===`zh`?`隐藏终端面板`:`Hide Terminal Panel`:e===`zh`?`显示终端面板`:`Show Terminal Panel`,description:e===`zh`?`切换右侧终端区域`:`Toggle the right-side terminal area`,keywords:`terminal panel shell dock right`,run:u},{id:`focus-input`,label:e===`zh`?`聚焦当前 Agent`:`Focus Current Agent`,description:e===`zh`?`将光标移动到当前 agent 终端`:`Move cursor to the active agent terminal`,keywords:`agent terminal focus`,run:d},{id:`split-pane-vertical`,label:t(`splitVertical`),description:t(`splitVerticalDescription`),shortcut:`Alt/⌘ D`,keywords:`split pane vertical agent`,run:f},{id:`split-pane-horizontal`,label:t(`splitHorizontal`),description:t(`splitHorizontalDescription`),shortcut:`Shift + Alt/⌘ D`,keywords:`split pane horizontal agent`,run:p},{id:`switch-prev-workspace`,label:e===`zh`?`切换到上一个工作区`:`Switch To Previous Workspace`,description:e===`zh`?`按当前标签顺序回到上一个工作区`:`Jump to the previous workspace tab`,shortcut:`⌘/Ctrl ⇧ [`,keywords:`workspace previous back`,run:()=>m(-1)},{id:`switch-next-workspace`,label:e===`zh`?`切换到下一个工作区`:`Switch To Next Workspace`,description:e===`zh`?`按当前标签顺序前往下一个工作区`:`Jump to the next workspace tab`,shortcut:`⌘/Ctrl ⇧ ]`,keywords:`workspace next forward`,run:()=>m(1)},{id:`open-settings`,label:n===`settings`?e===`zh`?`返回工作区`:`Back To Workspace`:e===`zh`?`打开设置`:`Open Settings`,description:n===`settings`?e===`zh`?`关闭设置并返回工作台`:`Close settings and return to the workbench`:e===`zh`?`打开全局设置面板`:`Open global settings panel`,keywords:`settings preferences`,run:()=>{if(n===`settings`){g();return}h()}},...o.map(t=>({id:`workspace:${t.id}`,label:`${e===`zh`?`切换到`:`Switch To`} ${t.label}`,description:e===`zh`?`直接跳转到该工作区`:`Jump directly to this workspace`,keywords:`workspace ${t.label.toLowerCase()}`,run:()=>_(t.id)}))],Tc=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>`${e.label} ${e.description} ${e.keywords}`.toLowerCase().includes(n)):e},Ec=({container:e,locale:t,isExpanded:n,width:r,codeSidebarView:i,previewPathLabel:a,previewFileName:o,editorContent:s,fileParentLabel:c,sidebar:l,fileSearch:u,onSetSidebarView:d,onToggleExpanded:f,t:p})=>{let m=(0,J.jsx)(Ms,{locale:t,view:l.view,fileTree:l.fileTree,rootPath:l.rootPath,selectedPath:l.selectedPath,repoCollapsedPaths:l.repoCollapsedPaths,gitChangeGroups:l.gitChangeGroups,activeGitChangeKey:l.activeGitChangeKey,commitMessage:l.commitMessage,onCommitMessageChange:l.onCommitMessageChange,onFileSelect:l.onFileSelect,onToggleRepoCollapse:l.onToggleRepoCollapse,onRefresh:l.onRefresh,onStageAll:l.onStageAll,onUnstageAll:l.onUnstageAll,onDiscardAll:l.onDiscardAll,onCommit:l.onCommit,onGitChangeSelect:l.onGitChangeSelect,onGitChangeAction:l.onGitChangeAction,t:p});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Os,{locale:t,isExpanded:n,width:r,codeSidebarView:i,previewPathLabel:a,previewFileName:o,fileSearchQuery:u.query,fileSearchActiveIndex:u.activeIndex,showFileSearchDropdown:u.showDropdown,searchShellRef:u.searchShellRef,fileSearchInputRef:u.inputRef,editorContent:s,sidebarContent:m,onSetSidebarView:d,onFileSearchChange:u.onChange,onFileSearchFocus:u.onFocus,onFileSearchBlur:u.onBlur,onFileSearchKeyDown:u.onKeyDown,onToggleExpanded:f,t:p}),u.showDropdown&&u.dropdownStyle&&e&&(0,J.jsx)(As,{container:e,locale:t,dropdownStyle:u.dropdownStyle,results:u.results,activeIndex:u.activeIndex,onHover:u.onHover,onSelect:u.onSelect,fileParentLabel:c})]})},Dc=({visible:e,progressPercent:t,progressTone:n,activeTerminal:r,terminals:i,shellTerminalRef:a,theme:o,fontSize:s,autoFocus:c,onTerminalData:l,onTerminalSize:u,onResizeStart:d,onSelect:f,onCloseActive:p,onAdd:m,t:h})=>e?(0,J.jsx)(Ns,{progressPercent:t,progressTone:n,activeTerminalId:r?.id,terminals:i,terminalContent:r?(0,J.jsx)(Xs,{ref:a,terminalId:r.id,output:r.output??``,theme:o,fontSize:s,onData:l,onSize:u,autoFocus:c}):(0,J.jsx)(`div`,{className:`terminal-empty`,children:h(`noTerminalYet`)}),onResizeStart:d,onSelect:f,onClose:p,onAdd:m,hasActiveTerminal:!!r,t:h}):null,$=async(e,t)=>Xi(e,t),Oc=(e,t)=>e.type===`wsl`?e.distro?.trim()?`WSL (${e.distro.trim()})`:`WSL`:t(`nativeTarget`),kc=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return e.isContentEditable||t===`INPUT`||t===`TEXTAREA`||t===`SELECT`};function Ac({locale:e,appSettings:t,onOpenSettings:n}){let[r,i]=s(xa),o=Ke(),{workspaceId:c}=Je(),u=`dark`,[d,f]=(0,p.useState)(``),[m,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(null),[v,y]=(0,p.useState)(`status`),[b,x]=(0,p.useState)(`preview`),[S,C]=(0,p.useState)(`files`),[w,ee]=(0,p.useState)(!1),[T,E]=(0,p.useState)(!1),[te,D]=(0,p.useState)({loading:!1,currentPath:``,homePath:``,roots:[],entries:[]}),[O,ne]=(0,p.useState)(!1),[re,ie]=(0,p.useState)(!1),[ae,oe]=(0,p.useState)(``),[se,k]=(0,p.useState)(0),[A,j]=(0,p.useState)(Ea),[ce,le]=(0,p.useState)({}),[ue,de]=(0,p.useState)(`time`),[fe,pe]=(0,p.useState)(()=>new Set),[me,he]=(0,p.useState)(()=>new Set),[ge,M]=(0,p.useState)(``),[_e,ve]=(0,p.useState)(!1),[ye,be]=(0,p.useState)(null),[xe,Se]=(0,p.useState)(!1),[Ce,we]=(0,p.useState)([]),[Te,Ee]=(0,p.useState)(!1),N=(0,p.useRef)(r),De=(0,p.useRef)(null),Oe=(0,p.useRef)(null),ke=(0,p.useRef)(null),Ae=(0,p.useRef)(null),je=(0,p.useRef)(null),Me=(0,p.useRef)(new Map),Ne=(0,p.useRef)(null),Pe=(0,p.useRef)(null),Fe=(0,p.useRef)(new Map),Ie=(0,p.useRef)(new Map),Le=(0,p.useRef)(new Map),P=(0,p.useRef)(new Map),Re=(0,p.useRef)(new Map),F=(0,p.useRef)(new Map),ze=(0,p.useRef)({cols:0,rows:0}),Be=(0,p.useRef)(new Set),Ve=(0,p.useRef)(new Set),He=(0,p.useRef)(``),Ue=(0,p.useRef)(new Map),We=(0,p.useRef)(new Map),Ge=(0,p.useRef)(0),I=(0,p.useMemo)(()=>Dn(e),[e]),L=(0,p.useMemo)(()=>{if(typeof window>`u`)return{fontSize:13,paddingY:12,terminalFontSize:12};let e=De.current??document.documentElement,t=window.getComputedStyle(e);return{fontSize:Number.parseInt(t.getPropertyValue(`--editor-font-size`),10)||13,paddingY:Number.parseInt(t.getPropertyValue(`--editor-padding-y`),10)||12,terminalFontSize:Number.parseInt(t.getPropertyValue(`--terminal-font-size`),10)||12}},[u]),R=e=>{let t=e(N.current);N.current=t,i(t)},z=(0,p.useMemo)(()=>({draftPromptInputRefs:Me,agentTerminalRefs:Fe,agentTerminalQueueRef:Ie,agentPaneSizeRef:Le,agentRuntimeSizeRef:P,agentResizeStateRef:Re,agentTitleTrackerRef:F,runningAgentKeysRef:Be,agentStartupStateRef:We,agentStartupTokenRef:Ge}),[]),qe=()=>{cc(z)},Ye=(e,t)=>{gc(z,e,t)},Xe=(e,t)=>{_c(z,e,t)},Ze=(e=N.current.tabs.find(e=>e.id===N.current.activeTabId)?.activePaneId)=>{vc(z,e)},Qe=(t,n,r,i)=>{bc({refs:z,paneId:t,tabId:n,sessionId:r,rawInput:i,locale:e,t:I,updateTab:K})},$e=()=>{ie(!0),oe(``),k(0)},et=()=>{ie(!1),oe(``),k(0)},tt=e=>{let t=ta(e);R(e=>({...e,tabs:e.tabs.map(e=>({...e,agent:{...e.agent,provider:t.agentProvider,command:t.agentCommand},idlePolicy:{...t.idlePolicy}}))})),N.current.tabs.forEach(e=>{ds(e.id,t.idlePolicy).catch(()=>{})})};(0,p.useEffect)(()=>{N.current=r},[r]),(0,p.useEffect)(()=>{let n=!1;return(async()=>{let r=await $(()=>co(),null);if(n||!r){n||Ee(!0);return}R(n=>rs(n,r,e,t)),n||Ee(!0)})(),()=>{n=!0}},[t,e]),(0,p.useEffect)(()=>{if(Te){if(c){if(N.current.tabs.find(e=>e.id===c)){N.current.activeTabId!==c&&(Nt(c),$(()=>uo(c),null).then(e=>{e&&R(t=>as(t,e))})),Mt(c);return}let n=!1;return(async()=>{let r=await $(()=>uo(c),null);if(!r||n){n||o(`/workspace`,{replace:!0});return}let i=await $(()=>lo(c),null);if(!i||n){n||o(`/workspace`,{replace:!0});return}R(n=>is(n,i,e,t,r)),Mt(c)})(),()=>{n=!0}}N.current.activeTabId&&o(`/workspace/${N.current.activeTabId}`,{replace:!0})}},[t,Te,e,o,c]),(0,p.useEffect)(()=>{if(!Te)return;let e=JSON.stringify($o(r.layout));He.current!==e&&(He.current=e,$(()=>po($o(r.layout)),null))},[Te,r.layout.leftWidth,r.layout.rightWidth,r.layout.rightSplit,r.layout.showCodePanel,r.layout.showTerminalPanel]),(0,p.useEffect)(()=>{if(!Te)return;let e=new Set(r.tabs.map(e=>e.id));r.tabs.forEach(e=>{if(e.status!==`ready`||!e.project?.path)return;let t={active_session_id:e.activeSessionId,active_pane_id:e.activePaneId,pane_layout:e.paneLayout,file_preview:e.filePreview},n=JSON.stringify(t);Ue.current.get(e.id)!==n&&(Ue.current.set(e.id,n),$(()=>mo(e.id,t),null))}),Array.from(Ue.current.keys()).forEach(t=>{e.has(t)||Ue.current.delete(t)})},[Te,r.tabs]),(0,p.useEffect)(()=>{if(!_e)return;let e=e=>{Ae.current?.contains(e.target)||(ve(!1),be(null))},t=e=>{e.key===`Escape`&&(ve(!1),be(null))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[_e]),(0,p.useEffect)(()=>{re&&requestAnimationFrame(()=>{je.current?.focus(),je.current?.select()})},[re]),(0,p.useEffect)(()=>{r.overlay.visible&&et()},[r.overlay.visible]),(0,p.useEffect)(()=>{typeof document<`u`&&(document.documentElement.dataset.theme=`dark`)},[]),(0,p.useEffect)(()=>{tt(t)},[t]),(0,p.useEffect)(()=>{!T&&N.current.overlay.target.type===`wsl`&&R(e=>({...e,overlay:{...e.overlay,target:{type:`native`}}}))},[T]),(0,p.useEffect)(()=>{!r.overlay.visible||r.overlay.mode===`local`||R(e=>({...e,overlay:{...e.overlay,mode:`local`,input:``}}))},[r.overlay.mode,r.overlay.visible]),(0,p.useEffect)(()=>Bs(({workspace_id:e,session_id:t,kind:n,data:r})=>{xc(z,e,t,n,r);let i=Qs(r),a=n===`stdout`||n===`stderr`,o=n===`system`,s=n===`exit`;R(n=>({...n,tabs:n.tabs.map(n=>n.id===e?{...n,sessions:n.sessions.map(e=>{if(e.id!==t)return e;let c=a?e.status:s?`idle`:e.status,l=s?`
6
+ [agent exited]
7
+ `:o?i&&i!==`Agent started / 智能体已启动`?`\n[${i}]\n`:``:r,u=`${e.stream}${l}`.slice(-ic),d=s?{id:Q(`msg`),role:`system`,content:I(`agentExited`),time:Ao()}:o?{id:Q(`msg`),role:`system`,content:i,time:Ao()}:null,f=n.activeSessionId===e.id?0:e.unread+(o||s||a?1:0);return{...e,status:c,unread:f,stream:u,messages:d?[...e.messages,d]:e.messages}})}:n)})),n===`exit`&&(mc(z,e,t),Ot(e,t))}),[I]),(0,p.useEffect)(()=>Vs(({workspace_id:e,session_id:t,kind:n,data:r})=>{Sc(z,e,t,n);let i=null;n===`turn_waiting`||n===`approval_required`?i=`waiting`:n===`tool_started`||n===`tool_finished`?i=`running`:(n===`turn_completed`||n===`session_ended`)&&(i=`idle`),n===`session_ended`&&mc(z,e,t),i&&R(n=>({...n,tabs:n.tabs.map(n=>n.id===e?{...n,sessions:n.sessions.map(e=>e.id===t?{...e,status:Bo(n,e,i)}:e)}:n)}));let a=(()=>{try{let e=JSON.parse(r);return typeof e.session_id==`string`&&e.session_id.trim()?e.session_id.trim():null}catch{return null}})();if(a){let n=!1;R(r=>({...r,tabs:r.tabs.map(r=>r.id===e?{...r,sessions:r.sessions.map(e=>e.id!==t||e.claudeSessionId===a?e:(n=!0,{...e,claudeSessionId:a}))}:r)})),n&&kt(e,t,{claude_session_id:a})}n===`turn_completed`&&St(e,t)}),[I]),(0,p.useEffect)(()=>Hs(({workspace_id:e,terminal_id:t,data:n})=>{if(!n)return;let r=`term-${t}`;R(t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,terminals:t.terminals.map(e=>{if(e.id!==r)return e;let t=`${e.output}${n}`.slice(-ac);return{...e,output:t}})}:t)}))}),[]);let B=(0,p.useMemo)(()=>{let n=r.tabs.find(e=>e.id===r.activeTabId)??r.tabs[0];if(n)return n;if(!Pe.current){let n=fa(1,e);Pe.current={...n,agent:{...n.agent,provider:t.agentProvider,command:t.agentCommand},idlePolicy:{...t.idlePolicy}}}return Pe.current},[t.agentCommand,t.agentProvider,t.idlePolicy,e,r.activeTabId,r.tabs]),nt=r.tabs.length>0,rt=r.layout.showCodePanel,V=r.layout.showTerminalPanel,H=(0,p.useMemo)(()=>B.sessions.find(e=>e.id===B.activeSessionId)??B.sessions[0],[B]),it=(0,p.useMemo)(()=>wo(B.paneLayout,B.activePaneId)??B.activeSessionId,[B]),at=(0,p.useMemo)(()=>B.sessions.find(e=>e.id===it)??H,[it,H,B.sessions]),ot=(0,p.useMemo)(()=>B.sessions.map(e=>e.id).join(`|`),[B.sessions]),st=A.query,ct=A.activeIndex,lt=A.dropdownStyle,ut=Da(A.query),U=(0,p.useMemo)(()=>Oa(B.fileTree,B.project?.path,A.query),[B.fileTree,B.project?.path,A.query]),dt=ka(A);(0,p.useEffect)(()=>{j(e=>Aa(e,U.length))},[U.length,ut]),(0,p.useEffect)(()=>{if(!dt){j(e=>Ra(e,null));return}let e=()=>{let e=Oe.current;e&&j(t=>Ra(t,za(e.getBoundingClientRect(),window.innerWidth,window.innerHeight)))};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[dt,r.layout.rightWidth,rt,w]),(0,p.useEffect)(()=>{if(!dt)return;let e=e=>{let t=e.target;t instanceof Node&&(Oe.current?.contains(t)||t.closest?.(`.workspace-search-dropdown`)||j(e=>Na(e)))};return document.addEventListener(`pointerdown`,e),()=>{document.removeEventListener(`pointerdown`,e)}},[dt]);let ft=t=>Fn(t,e),pt=t=>Pn(t,e),mt=t=>In(t,e),ht=!!B.filePreview.path,gt=B.viewingArchiveId?B.archive.find(e=>e.id===B.viewingArchiveId):void 0,_t=gt?gt.snapshot:H,W=!!gt,vt=W?_t:H;Qs(vt.stream),(0,p.useEffect)(()=>{K(B.id,e=>{let t=Co(e.paneLayout),n=new Set(t.map(e=>e.sessionId)),r=e.sessions.filter(e=>!n.has(e.id));if(r.length===0)return e;let i=e.paneLayout;r.forEach(e=>{let t=la(e.id);i={type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:i,second:t}});let a=To(i,e.activeSessionId)??Co(i)[0]?.id??e.activePaneId;return{...e,paneLayout:i,activePaneId:a}})},[B.id,ot]);let G=e=>{h(t=>[...t,e]),setTimeout(()=>{h(t=>t.filter(t=>t.id!==e.id))},4e3)},yt=async(e,t,n)=>{try{return await e()}catch(e){return G({id:Q(`toast`),text:`${n}: ${String(e)}`,sessionId:t}),null}},K=(e,t)=>{R(n=>({...n,tabs:n.tabs.map(n=>n.id===e?t(n):n)}))},{archiveSessionForTab:bt,createDraftSessionForTab:xt,markSessionIdle:St,materializeSession:Ct,onCloseAgentPane:wt,onNewSession:Tt,onSwitchSession:Et,refreshTabFromBackend:Dt,settleSessionAfterExit:Ot,syncSessionPatch:kt,touchSession:At}=fs({appSettings:t,locale:e,t:I,stateRef:N,updateTab:K,withServiceFallback:$,addToast:G}),jt=async e=>{let t=N.current.tabs.find(t=>t.id===e),n=t?.project?.path,r=t?.project?.target;if(!t||!n||!r)return null;let[i,a,o,s]=await Promise.all([$(()=>_o(n,r),{branch:t.git.branch||`main`,changes:t.git.changes??0,last_commit:t.git.lastCommit||`—`}),$(()=>Ga(n,r),t.gitChanges??[]),$(()=>go(n,r),t.worktrees),$(()=>ho(n,r,4),{root:{name:`.`,path:n,kind:`dir`,children:[]},changes:[]})]);return K(e,e=>({...e,git:{branch:i.branch||e.git.branch||`main`,changes:i.changes??e.git.changes??0,lastCommit:i.last_commit||e.git.lastCommit||`—`},gitChanges:a,worktrees:o,fileTree:s.root.children??[],changesTree:s.changes??[]})),s},Mt=(0,p.useCallback)(async t=>{let n=N.current.tabs.find(e=>e.id===t);!n?.project?.path||n.terminals.length>0||Ve.current.has(t)||(Ve.current.add(t),await ys({tab:n,locale:e,updateTab:K,withServiceFallback:$,addToast:G,activeSessionId:n.activeSessionId,createToastId:()=>Q(`toast`),t:I})||Ve.current.delete(t))},[e,I]),Nt=e=>{R(t=>{if(!t.tabs.find(t=>t.id===e))return t;let n=t.activeTabId;return{...t,activeTabId:e,overlay:{...t.overlay,visible:!1},tabs:t.tabs.map(t=>t.id===e?{...t,sessions:t.sessions.map(e=>e.id===t.activeSessionId?{...e,unread:0,status:zo(e),lastActiveAt:Date.now()}:e)}:t.id===n?{...t,sessions:t.sessions.map(e=>e.id===t.activeSessionId?{...e,status:Ro(e.status)}:e)}:t)}})},Pt=()=>{R(e=>({...e,overlay:{...e.overlay,visible:!0,mode:`local`,input:``,target:e.overlay.target}})),nt||o(`/workspace`,{replace:!0})},Ft=async e=>{let t=N.current.tabs,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t.filter(t=>t.id!==e).map(e=>e.id),i=await $(()=>fo(e),{open_workspace_ids:r,active_workspace_id:N.current.activeTabId===e?r[Math.max(0,n-1)]??r[0]??null:N.current.activeTabId,layout:$o(N.current.layout)});if(Ve.current.delete(e),R(e=>{let t=as(e,i);return{...t,overlay:{...t.overlay,visible:t.tabs.length===0}}}),i.active_workspace_id){o(`/workspace/${i.active_workspace_id}`),Mt(i.active_workspace_id);return}o(`/workspace`)},It=e=>{N.current.tabs.find(t=>t.id===e)&&(Nt(e),o(`/workspace/${e}`),$(()=>uo(e),null).then(e=>{e&&R(t=>as(t,e))}),Mt(e))},Lt=e=>{let t=N.current.tabs;if(t.length<2)return;let n=t.findIndex(e=>e.id===N.current.activeTabId);n<0||It(t[(n+(e>=0?1:-1)+t.length)%t.length].id)},Rt=e=>{R(t=>Va(t,e))},zt=(0,p.useCallback)(async(t,n,r=!1)=>{await Ha({target:t,path:n,selectCurrent:r,locale:e,t:I,setFolderBrowser:D,setOverlayCanUseWsl:E,updateOverlayInput:e=>{R(t=>Ba(t,e))}})},[e,I]),Bt=(e,t=!1)=>{zt(N.current.overlay.target,e,t)};(0,p.useEffect)(()=>{!r.overlay.visible||r.overlay.mode!==`local`||zt(r.overlay.target,r.overlay.input||void 0,!r.overlay.input)},[r.overlay.visible,r.overlay.mode,r.overlay.target.type,r.overlay.target.type===`wsl`?r.overlay.target.distro:``,zt]);let Vt=async()=>{let n=await os({overlay:N.current.overlay,locale:e,appSettings:t,updateState:R,withServiceFallback:$,refreshWorkspaceArtifacts:jt});n&&(o(`/workspace/${n.workspaceId}`),Mt(n.workspaceId),n.firstFile&&await Jt(n.firstFile,n.workspaceId))},Ht=e=>{let t=e.project?.path??``;return e.agent.command.replace(`{path}`,t)},Ut=async(e,t)=>{let n=e.project;if(!n?.path)return!1;let r=Ht(e),i=n.target,a=await $(()=>Qi(r,i,n.path),null);if(a&&!a.available)return G({id:Q(`toast`),text:`${I(`agentStartFailed`)}: ${a.error??I(`launchCommandMissing`,{runtime:Oc(i,I)})}`,sessionId:t.id}),!1;let o=fc(z,e.id,t.id),s=await yt(()=>tc({workspaceId:e.id,sessionId:t.id,provider:e.agent.provider,command:r}),t.id,I(`agentStartFailed`));return s?(hc(z,e.id,t.id),s.started||pc(z,e.id,t.id,o),{ok:!0,started:s.started,startupToken:s.started?o:null}):(pc(z,e.id,t.id,o),!1)},Wt=async(e,t,n)=>{let r=Date.now();return K(e.id,e=>({...e,sessions:e.sessions.map(e=>e.id===t.id?{...e,lastActiveAt:r}:e)})),kt(e.id,t.id,{last_active_at:r}),await yt(()=>nc(e.id,t.id,n,!1),t.id,I(`agentKeySendFailed`))!==null},Gt=e=>{Et(B,e)},Kt=(e,t)=>{wt(B,e,t)},qt=()=>{K(B.id,e=>({...e,viewingArchiveId:void 0}))},Jt=async(e,t)=>{if(e.kind!==`file`)return;let n=N.current.tabs.find(e=>e.id===(t??B.id))??B,r=e.path.split(/[\/]+/).filter(Boolean);r.length>1&&pe(e=>{let t=new Set(e),n=``;for(let e of r.slice(0,-1))n=n?`${n}/${e}`:e,t.add(n);return t}),await ro({tab:n,node:e,updateTab:K,withServiceFallback:$,t:I}),M(``),x(`preview`)},Yt=async(e,t)=>{await io({tab:N.current.tabs.find(e=>e.id===B.id)??B,path:e,updateTab:K,withServiceFallback:$,t:I,options:t}),(t?.clearGitSelection??!1)&&M(``),x(`preview`)},Xt=async e=>{j(e=>Pa(e)),C(`files`),await Jt(e),requestAnimationFrame(()=>{ke.current?.blur()})},Zt=()=>{requestAnimationFrame(()=>{let e=document.activeElement;e instanceof Node&&Oe.current?.contains(e)||j(e=>Na(e))})},Qt=e=>{if(ut){if(e.key===`ArrowDown`){e.preventDefault(),j(e=>Fa(e,1,U.length));return}if(e.key===`ArrowUp`){e.preventDefault(),j(e=>Fa(e,-1,U.length));return}if(e.key===`Enter`){if(!U.length)return;e.preventDefault(),Xt((U[ct]??U[0]).node);return}e.key===`Escape`&&(e.preventDefault(),j(e=>Na(e)))}},$t=async e=>{let t=await vo({tab:N.current.tabs.find(e=>e.id===B.id)??B,change:e,updateTab:K,withServiceFallback:$});x(`diff`),M(t)},en=async(e,t)=>{let n=N.current.tabs.find(e=>e.id===B.id)??B,r=Cr(e.path),i={path:n.project?.path??``,target:n.project?.target??{type:`native`},filePath:r};if(t===`stage`){await an(()=>Ya(i.path,i.target,i.filePath));return}if(t===`unstage`){await an(()=>Xa(i.path,i.target,i.filePath));return}await an(()=>Za(i.path,i.target,i.filePath,e.section))},tn=e=>{K(B.id,t=>({...t,filePreview:{...t.filePreview,content:e,dirty:!0}}))},nn=async e=>{if(x(e),e===`preview`)return;let t=N.current.tabs.find(e=>e.id===B.id)??B;await jt(t.id),await ao({tab:t,updateTab:K,withServiceFallback:$})},rn=async()=>{await oo({tab:N.current.tabs.find(e=>e.id===B.id)??B,activeSessionId:H.id,updateTab:K,withServiceFallback:$,refreshWorkspaceArtifacts:jt,addToast:G,t:I,createToastId:()=>Q(`toast`)})},an=async e=>yo({tab:N.current.tabs.find(e=>e.id===B.id)??B,activeSessionId:H.id,selectedGitChangeKey:ge,previewMode:b,updateTab:K,refreshWorkspaceArtifacts:jt,onSelectGitChange:async e=>{await $t(e)},onReloadRepositoryDiff:async()=>{await nn(`diff`)},onClearPreviewSelection:()=>{M(``),x(`preview`)},addToast:G,t:I,createToastId:()=>Q(`toast`),getCurrentTab:e=>N.current.tabs.find(t=>t.id===e),operation:e}),on=async()=>{let e=N.current.tabs.find(e=>e.id===B.id)??B;await an(()=>Qa(e.project?.path??``,e.project?.target??{type:`native`}))},sn=async()=>{let e=N.current.tabs.find(e=>e.id===B.id)??B;await an(()=>$a(e.project?.path??``,e.project?.target??{type:`native`}))},cn=async()=>{let e=N.current.tabs.find(e=>e.id===B.id)??B;await an(()=>eo(e.project?.path??``,e.project?.target??{type:`native`}))&&(K(e.id,e=>({...e,filePreview:ca()})),x(`preview`))},ln=async()=>{if(!d.trim())return;let e=N.current.tabs.find(e=>e.id===B.id)??B;await an(()=>to(e.project?.path??``,e.project?.target??{type:`native`},d.trim()))&&(f(``),G({id:Q(`toast`),text:I(`gitCommitSucceeded`),sessionId:H.id}))},un=async()=>{await ys({tab:N.current.tabs.find(e=>e.id===B.id)??B,locale:e,updateTab:K,withServiceFallback:$,addToast:G,activeSessionId:H.id,createToastId:()=>Q(`toast`),t:I})},dn=e=>{bs(K,B.id,e)},fn=async e=>{await xs(N.current.tabs.find(e=>e.id===B.id)??B,e,K,$)},pn=e=>t=>{Ko({event:t,type:e,stateRef:N,updateState:R,shellTerminalRef:Ne,fitAgentTerminals:qe})},mn=e=>{R(t=>Uo(t,e)),e===`code`&&ee(!1),requestAnimationFrame(()=>{Ne.current?.fit()})},q=B.terminals.find(e=>e.id===B.activeTerminalId)??B.terminals[0],hn=!w,gn=async()=>{w&&(S===`git`&&B.filePreview.mode===`diff`&&B.filePreview.path&&await Yt(B.filePreview.path,{clearGitSelection:!1,statusLabel:B.filePreview.statusLabel,parentPath:B.filePreview.parentPath}),C(`files`)),ee(e=>!e)},_n=(e,t)=>{Wo(K,B.id,e,t)},vn=(e,t)=>{Go({tab:B,paneId:e,axis:t,updateTab:K,createDraftSessionForTab:xt,onFocusPane:Ze})},yn=(e,t)=>n=>{qo({event:n,tabId:B.id,paneLayout:B.paneLayout,splitId:e,axis:t,updateTab:K,fitAgentTerminals:qe})},bn=e=>{e&&(et(),e.run())},xn=async e=>{if(W)return null;let t=N.current.tabs.find(e=>e.id===N.current.activeTabId);if(!t)return null;let n=wo(t.paneLayout,e)??t.activeSessionId,r=t.sessions.find(e=>e.id===n);if(!r)return null;let i=Po(r)?await Ct(t.id,r.id,``):{tab:t,session:r},a=i?.tab??t,o=i?.session??r;if(!a||!o)return null;if(!sc(z,a.id,o.id)){let t=await Ut(a,o);if(!t)return null;t.started&&dc(z,e,a.id,o.id),t.started&&t.startupToken!==null&&await Cc(z,a.id,o.id,t.startupToken)}return dc(z,e,a.id,o.id),At(a.id,o.id),{tab:a,session:o}},Sn=async(e,t)=>{if(W||!t)return;let n=N.current.tabs.find(e=>e.id===N.current.activeTabId),r=n?wo(n.paneLayout,e)??n.activeSessionId:null,i=r&&n?n.sessions.find(e=>e.id===r)??null:null,a=i?yc(z,e,i,t):null,o=(Ie.current.get(e)??Promise.resolve()).catch(()=>void 0).then(async()=>{let n=await xn(e);n&&(a&&Qe(e,n.tab.id,n.session.id,a),await Wt(n.tab,n.session,t))});Ie.current.set(e,o),await o},Cn=async e=>{let t=(ce[e]??``).trim();t&&(le(t=>({...t,[e]:``})),await Sn(e,t),await Sn(e,`\r`))};(0,p.useEffect)(()=>{let e=e=>{let t=e.key.toLowerCase(),n=e.metaKey||e.ctrlKey,r=kc(e.target);if(n&&t===`k`){e.preventDefault(),re?et():($e(),ve(!1),be(null));return}if(re){e.key===`Escape`&&(e.preventDefault(),et());return}if(n&&t===`s`){if(!B.filePreview.path)return;e.preventDefault(),rn();return}if(n&&t===`n`){e.preventDefault(),Pt();return}if(n&&e.shiftKey&&(e.key===`[`||e.key===`{`)){e.preventDefault(),Lt(-1);return}if(n&&e.shiftKey&&(e.key===`]`||e.key===`}`)){e.preventDefault(),Lt(1);return}if(!n&&!e.altKey&&!e.shiftKey&&t===`f`&&!r&&!W){e.preventDefault(),ne(e=>!e);return}if(!n&&!e.altKey&&!e.shiftKey&&e.key===`Escape`&&O){e.preventDefault(),ne(!1);return}if(W||!(typeof navigator<`u`&&(navigator.platform||``).toLowerCase().includes(`mac`)?e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`d`:e.altKey&&!e.ctrlKey&&!e.metaKey&&t===`d`)||e.repeat)return;e.preventDefault();let i=e.shiftKey?`horizontal`:`vertical`;vn(B.activePaneId,i),ve(!1),be(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[B.activePaneId,B.filePreview.path,B.filePreview.dirty,B.filePreview.content,H.id,re,W,O]),(0,p.useEffect)(()=>{W||Ze()},[B.activePaneId,at.id,W]),(0,p.useEffect)(()=>{f(``),M(``),ve(!1),be(null)},[B.id]),(0,p.useEffect)(()=>{B.project?.path&&jt(B.id)},[S,B.id,B.project?.path]),(0,p.useEffect)(()=>{B.project?.path&&Mt(B.id)},[B.id,B.project?.path,Mt]),(0,p.useEffect)(()=>{if(!B.project?.path)return;let e=window.setInterval(()=>{jt(B.id)},4e3);return()=>window.clearInterval(e)},[B.id,B.project?.path]);let wn=(0,p.useCallback)(e=>{_s(ze,B.id,q?.id,e.cols,e.rows)},[q?.id,B.id]),Tn=(0,p.useCallback)(e=>{vs(B.id,q?.id,e)},[q?.id,B.id]),En=(0,p.useCallback)((e,t,n,r)=>{Le.current.set(e,r),sc(z,t,n)&&uc(z,t,n,r)},[]);(0,p.useEffect)(()=>{!V||w||requestAnimationFrame(()=>{Ne.current?.fit()})},[V,w,r.layout.rightSplit]),(0,p.useEffect)(()=>{q&&V&&!w&&Ne.current?.focus()},[q?.id,V,w]),(0,p.useEffect)(()=>{q||(ze.current={id:void 0,cols:0,rows:0})},[q?.id]);let On={"--left-w":`${r.layout.leftWidth}px`,"--right-w":`${r.layout.rightWidth}px`,"--right-split":`${r.layout.rightSplit}%`},kn=r.tabs.map(t=>{let n=[...t.sessions].sort((t,n)=>ue===`name`?pt(t.title).localeCompare(pt(n.title),e===`zh`?`zh-CN`:`en`):n.lastActiveAt-t.lastActiveAt),i=n.some(e=>[`running`,`waiting`,`background`].includes(e.status)),a=n.reduce((e,t)=>e+t.unread,0);return{id:t.id,label:Dr(t.project?.path)||ft(t.title),active:t.id===r.activeTabId,hasRunning:i,unread:a,sessions:n}}),An=Tc(wc({locale:e,t:I,route:`workspace`,isFocusMode:O,showCodePanel:rt,showTerminalPanel:V,workspaceTabs:kn,onAddTab:Pt,onToggleFocusMode:()=>ne(e=>!e),onToggleCodePanel:()=>mn(`code`),onToggleTerminalPanel:()=>mn(`terminal`),onFocusAgent:()=>Ze(),onSplitVertical:()=>vn(B.activePaneId,`vertical`),onSplitHorizontal:()=>vn(B.activePaneId,`horizontal`),onCycleWorkspace:Lt,onOpenSettings:n,onCloseSettings:()=>{},onSwitchWorkspace:It}),ae),jn=An[se]??An[0];(0,p.useEffect)(()=>{if(!An.length){k(0);return}k(e=>Math.min(e,An.length-1))},[An.length]);let Mn=bo(B.gitChanges,I),Nn=xo(B.filePreview.path,B.gitChanges),Ln=Nn?`${Nn.section}:${Nn.path}:${Nn.code}`:ge;Mn.find(e=>e.key===`changes`)?.items.length,Mn.find(e=>e.key===`staged`)?.items.length,Mn.find(e=>e.key===`untracked`)?.items.length;let Rn=Dr(B.filePreview.path),zn=Dr(B.project?.path)||I(`noWorkspace`),Bn=So(B.filePreview.path,B.project?.path,Rn),Vn=B.git.changes,Hn=!!(B.filePreview.originalContent&&B.filePreview.originalContent.length>0||B.filePreview.modifiedContent&&B.filePreview.modifiedContent.length>0),Un=!!q?.output?.trim(),Wn=q?Un?88:52:8,Gn=q?Un?`live`:`steady`:`idle`,Kn=(0,J.jsx)(ec,{visible:hn,activeTab:B,activePaneSession:at,viewedSession:vt,isArchiveView:W,showCodePanel:rt,theme:u,terminalFontSize:L.terminalFontSize,draftPromptInputs:ce,displaySessionTitle:pt,onExitArchive:qt,onSetActivePane:_n,onSplitPane:vn,onCloseAgentPane:Kt,onSubmitDraftPrompt:e=>{Cn(e)},onDraftPromptChange:(e,t)=>{le(n=>({...n,[e]:t}))},setDraftPromptInputRef:Xe,setAgentTerminalRef:Ye,onAgentTerminalData:(e,t)=>{Sn(e,t)},onAgentTerminalSize:En,onPaneSplitResizeStart:yn,onCodeResizeStart:pn(`left`),t:I}),qn=ht?B.filePreview.mode===`diff`?B.filePreview.source===`git`&&B.filePreview.section&&Hn?(0,J.jsx)(`div`,{className:`editor-surface diff-editor-surface`,"data-testid":`preview-diff-editor`,children:(0,J.jsx)(a,{height:`100%`,original:B.filePreview.originalContent??``,modified:B.filePreview.modifiedContent??``,originalModelPath:`${B.filePreview.path}.original`,modifiedModelPath:B.filePreview.path,language:Ca(B.filePreview.path),theme:`vs-dark`,options:{automaticLayout:!0,readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6,useShadows:!1,alwaysConsumeMouseWheel:!1},wordWrap:`on`,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, monospace`,fontSize:L.fontSize,lineNumbersMinChars:3,renderWhitespace:`selection`}},`${B.filePreview.path}:${B.filePreview.section??`diff`}`)}):(0,J.jsx)(`pre`,{className:`diff code-surface`,children:B.filePreview.diff||I(`noDiffAvailable`)}):(0,J.jsx)(`div`,{className:`editor-surface`,"data-testid":`preview-editor`,children:(0,J.jsx)(l,{height:`100%`,path:B.filePreview.path,language:Ca(B.filePreview.path),value:B.filePreview.content,onChange:e=>tn(e??``),theme:`vs-dark`,options:{automaticLayout:!0,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, monospace`,fontSize:L.fontSize,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6,useShadows:!1,alwaysConsumeMouseWheel:!1},wordWrap:`on`,padding:{top:L.paddingY,bottom:L.paddingY},lineNumbersMinChars:3,renderWhitespace:`selection`}},B.filePreview.path)}):(0,J.jsx)(`div`,{className:`preview-empty`,children:I(`selectFileFromNavigator`)}),Jn=rt?(0,J.jsx)(Ec,{container:De.current,locale:e,isExpanded:w,width:r.layout.rightWidth,codeSidebarView:S,previewPathLabel:Bn,previewFileName:Rn,editorContent:qn,fileParentLabel:Er,sidebar:{view:S,fileTree:B.fileTree,rootPath:B.project?.path,selectedPath:B.filePreview.path,repoCollapsedPaths:fe,gitChangeGroups:Mn,activeGitChangeKey:Ln,commitMessage:d,onCommitMessageChange:f,onFileSelect:Jt,onToggleRepoCollapse:e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onRefresh:()=>{jt(B.id)},onStageAll:()=>{on()},onUnstageAll:()=>{sn()},onDiscardAll:()=>{cn()},onCommit:()=>{ln()},onGitChangeSelect:e=>{$t(e)},onGitChangeAction:(e,t)=>{en(e,t)}},fileSearch:{query:st,activeIndex:ct,showDropdown:dt,dropdownStyle:lt,results:U.map(({node:e})=>e),searchShellRef:Oe,inputRef:ke,onChange:e=>{j(t=>ja(t,e))},onFocus:e=>{j(t=>Ma(t,e))},onBlur:Zt,onKeyDown:Qt,onHover:e=>{j(t=>Ia(t,e))},onSelect:e=>{let t=U.find(t=>t.node.absolutePath===e.absolutePath)?.node??U.find(t=>t.node.path===e.path)?.node;t&&Xt(t)}},onSetSidebarView:C,onToggleExpanded:()=>{gn()},t:I}):null,Yn=(0,J.jsx)(Dc,{visible:!w&&V,progressPercent:Wn,progressTone:Gn,activeTerminal:q?{id:q.id,output:q.output??``}:void 0,terminals:B.terminals.map(e=>({id:e.id,title:mt(e.title)})),shellTerminalRef:Ne,theme:u,fontSize:L.terminalFontSize,autoFocus:V&&!w,onTerminalData:Tn,onTerminalSize:wn,onResizeStart:pn(`right-split`),onSelect:dn,onCloseActive:()=>{q&&fn(q.id)},onAdd:()=>{un()},t:I});return(0,J.jsxs)(`div`,{ref:De,className:`app`,style:On,"data-theme":u,children:[(0,J.jsx)(Yi,{isSettingsRoute:!1,locale:e,workspaceTabs:kn,onSwitchWorkspace:It,onAddTab:Pt,onRemoveTab:Ft,onOpenSettings:n,onCloseSettings:()=>{},onOpenCommandPalette:$e,t:I}),(0,J.jsx)(js,{locale:e,isFocusMode:O,isCodeExpanded:w,showAgentPanel:hn,showCodePanel:rt,showTerminalPanel:V,rightSplit:r.layout.rightSplit,workspaceFolderName:zn,branchName:B.git.branch,changeCount:Vn,agentPanel:Kn,codePanel:Jn,terminalPanel:Yn,onToggleRightPane:mn,t:I}),re&&(0,J.jsx)(ws,{locale:e,inputRef:je,query:ae,activeIndex:se,actions:An,activeAction:jn,onClose:et,onQueryChange:oe,onActivateIndex:k,onRunAction:bn}),(0,J.jsx)(`div`,{className:`toast-container`,children:m.map(e=>(0,J.jsx)(`button`,{className:`toast`,onClick:()=>Gt(e.sessionId),children:e.text},e.id))}),g&&(0,J.jsx)(Es,{locale:e,worktree:g,view:v,collapsedPaths:me,onClose:()=>_(null),onViewChange:y,onFileSelect:Jt,onToggleCollapse:e=>{he(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t:I}),(0,J.jsx)(Ds,{visible:r.overlay.visible,target:r.overlay.target,input:r.overlay.input,canUseWsl:T,folderBrowser:te,onUpdateTarget:Rt,onBrowseDirectory:Bt,onStartWorkspace:Vt,t:I})]})}function jc(){let[e,t]=(0,p.useState)(()=>wn()),[n,r]=(0,p.useState)(()=>na()),[i,a]=(0,p.useState)(`/workspace`),o=Ke(),s=L(),c=s.pathname===`/settings`?`settings`:`workspace`;(0,p.useEffect)(()=>{Tn(e)},[e]),(0,p.useEffect)(()=>{try{ra(n)}catch{}},[n]),(0,p.useEffect)(()=>{s.pathname.startsWith(`/workspace`)&&a(s.pathname||`/workspace`)},[s.pathname]);let l=e=>{o(e===`settings`?`/settings`:i)},u=e=>{t(e),En(e)};return(0,J.jsx)(Ar,{locale:e,onSelectLocale:u,children:(0,J.jsxs)(_t,{children:[(0,J.jsx)(ht,{path:`/`,element:(0,J.jsx)(mt,{to:`/workspace`,replace:!0})}),(0,J.jsx)(ht,{path:`/workspace`,element:(0,J.jsx)(Ac,{locale:e,appSettings:n,onOpenSettings:()=>l(`settings`)})}),(0,J.jsx)(ht,{path:`/workspace/:workspaceId`,element:(0,J.jsx)(Ac,{locale:e,appSettings:n,onOpenSettings:()=>l(`settings`)})}),(0,J.jsx)(ht,{path:`/settings`,element:(0,J.jsx)(Cs,{locale:e,appSettings:n,onSelectLocale:u,onCommitSettings:e=>{r(ta(e))},onCloseSettings:()=>o(i)})}),(0,J.jsx)(ht,{path:`*`,element:(0,J.jsx)(mt,{to:c===`settings`?`/settings`:i,replace:!0})})]})})}function Mc(){return(0,J.jsx)(en,{children:(0,J.jsx)(jc,{})})}f.createRoot(document.getElementById(`root`)).render((0,J.jsx)(p.StrictMode,{children:(0,J.jsx)(r,{children:(0,J.jsx)(Mc,{})})}));
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Coder Studio</title>
7
- <script type="module" crossorigin src="/assets/index-CpxaaHT7.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BJ8mpERu.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-DF2fYuay.js">
9
9
  <link rel="modulepreload" crossorigin href="/assets/react-BF8D1Hk7.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/terminal-vdgmTa16.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spencer-kit/coder-studio-win32-x64",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Windows x64 runtime bundle for Coder Studio.",
5
5
  "os": [
6
6
  "win32"
@@ -1,7 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{a as t,c as n,i as r,l as i,n as a,o,r as s,s as c,t as l}from"./react-BF8D1Hk7.js";import{n as u,t as d}from"./terminal-vdgmTa16.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 f=e(c(),1),p=e(i(),1),m=`modulepreload`,h=function(e){return`/`+e},g={},_=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=h(t,n),t in g)return;g[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`:m,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)})},v=`popstate`;function y(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function b(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=E(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),ee(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:T(t))}function r(e,t){S(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return te(t,n,r,e)}function x(e,t){if(e===!1||e==null)throw Error(t)}function S(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function C(){return Math.random().toString(36).substring(2,10)}function w(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ee(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?E(t):t,state:n,key:t&&t.key||r||C(),unstable_mask:i}}function T({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 E(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 te(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=y(e)?e:ee(h.location,e,t);n&&n(r,e),l=u()+1;let d=w(r,l),f=h.createHref(r.unstable_mask||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=y(e)?e:ee(h.location,e,t);n&&n(r,e),l=u();let i=w(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return ne(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(v,d),c=e,()=>{i.removeEventListener(v,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 ne(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),x(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:T(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function D(e,t,n=`/`){return re(e,t,n,!1)}function re(e,t,n,r){let i=j((typeof t==`string`?E(t):t).pathname||`/`,n);if(i==null)return null;let a=ae(e);se(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=_e(i);o=me(a[e],t,r)}return o}function ie(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 ae(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;x(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=M([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(x(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ae(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:fe(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of oe(e.path))a(e,t,!0,n)}),t}function oe(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=oe(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 se(e){e.sort((e,t)=>e.score===t.score?pe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ce=/^:[\w-]+$/,O=3,k=2,A=1,le=10,ue=-2,de=e=>e===`*`;function fe(e,t){let n=e.split(`/`),r=n.length;return n.some(de)&&(r+=ue),t&&(r+=k),n.filter(e=>!de(e)).reduce((e,t)=>e+(ce.test(t)?O:t===``?A:le),r)}function pe(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 me(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=he({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=he({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:M([a,u.pathname]),pathnameBase:Te(M([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=M([a,u.pathnameBase]))}return o}function he(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ge(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 ge(e,t=!1,n=!0){S(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,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).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 _e(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return S(!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 j(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 ve=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ye(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?E(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?be(n.substring(1),`/`):be(n,t)):a=t,{pathname:a,search:Ee(r),hash:N(i)}}function be(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 xe(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 Se(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ce(e){let t=Se(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function we(e,t,n,r=!1){let i;typeof e==`string`?i=E(e):(i={...e},x(!i.pathname||!i.pathname.includes(`?`),xe(`?`,`pathname`,`search`,i)),x(!i.pathname||!i.pathname.includes(`#`),xe(`#`,`pathname`,`hash`,i)),x(!i.search||!i.search.includes(`#`),xe(`#`,`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=ye(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var M=e=>e.join(`/`).replace(/\/\/+/g,`/`),Te=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Ee=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,N=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,De=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 Oe(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ke(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Ae=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function je(e,t){let n=e;if(typeof n!=`string`||!ve.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Ae)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=j(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{S(!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 Me=p.createContext(null);Me.displayName=`DataRouter`;var P=p.createContext(null);P.displayName=`DataRouterState`;var Ne=p.createContext(!1),Pe=p.createContext({isTransitioning:!1});Pe.displayName=`ViewTransition`;var Fe=p.createContext(new Map);Fe.displayName=`Fetchers`;var Ie=p.createContext(null);Ie.displayName=`Await`;var F=p.createContext(null);F.displayName=`Navigation`;var Le=p.createContext(null);Le.displayName=`Location`;var I=p.createContext({outlet:null,matches:[],isDataRoute:!1});I.displayName=`Route`;var Re=p.createContext(null);Re.displayName=`RouteError`;var ze=`REACT_ROUTER_ERROR`,Be=`REDIRECT`,Ve=`ROUTE_ERROR_RESPONSE`;function He(e){if(e.startsWith(`${ze}:${Be}:{`))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 Ue(e){if(e.startsWith(`${ze}:${Ve}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new De(t.status,t.statusText,t.data)}catch{}}function We(e,{relative:t}={}){x(L(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=p.useContext(F),{hash:i,pathname:a,search:o}=Je(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:M([n,a])),r.createHref({pathname:s,search:o,hash:i})}function L(){return p.useContext(Le)!=null}function R(){return x(L(),`useLocation() may be used only in the context of a <Router> component.`),p.useContext(Le).location}var z=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function B(e){p.useContext(F).static||p.useLayoutEffect(e)}function Ge(){let{isDataRoute:e}=p.useContext(I);return e?U():Ke()}function Ke(){x(L(),`useNavigate() may be used only in the context of a <Router> component.`);let e=p.useContext(Me),{basename:t,navigator:n}=p.useContext(F),{matches:r}=p.useContext(I),{pathname:i}=R(),a=JSON.stringify(Ce(r)),o=p.useRef(!1);return B(()=>{o.current=!0}),p.useCallback((r,s={})=>{if(S(o.current,z),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=we(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:M([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}p.createContext(null);function qe(){let{matches:e}=p.useContext(I),t=e[e.length-1];return t?t.params:{}}function Je(e,{relative:t}={}){let{matches:n}=p.useContext(I),{pathname:r}=R(),i=JSON.stringify(Ce(n));return p.useMemo(()=>we(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ye(e,t){return Xe(e,t)}function Xe(e,t,n){x(L(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=p.useContext(F),{matches:i}=p.useContext(I),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;ft(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (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.
2
-
3
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=R(),d;if(t){let e=typeof t==`string`?E(t):t;x(c===`/`||e.pathname?.startsWith(c),`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 "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,m=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);m=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=D(e,{pathname:m});S(l||h!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),S(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.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 g=nt(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:M([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:M([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?p.createElement(Le.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},g):g}function Ze(){let e=ut(),t=Oe(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=p.createElement(p.Fragment,null,p.createElement(`p`,null,`💿 Hey developer 👋`),p.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,p.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,p.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),p.createElement(p.Fragment,null,p.createElement(`h2`,null,`Unexpected Application Error!`),p.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?p.createElement(`pre`,{style:i},n):null,o)}var Qe=p.createElement(Ze,null),$e=class extends p.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=Ue(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:p.createElement(I.Provider,{value:this.props.routeContext},p.createElement(Re.Provider,{value:e,children:this.props.component}));return this.context?p.createElement(V,{error:e},t):t}};$e.contextType=Ne;var et=new WeakMap;function V({children:e,error:t}){let{basename:n}=p.useContext(F);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=He(t.digest);if(e){let r=et.get(t);if(r)throw r;let i=je(e.location,n);if(Ae&&!et.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 et.set(t,n),n}return p.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function tt({routeContext:e,match:t,children:n}){let r=p.useContext(Me);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),p.createElement(I.Provider,{value:e},n)}function nt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);x(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:ke(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,m=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||Qe,o&&(s<0&&c===0?(ft(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,m=null):s===c&&(d=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(i.slice(0,c+1)),g=()=>{let t;return t=u?f:d?m:n.route.Component?p.createElement(n.route.Component,null):n.route.element?n.route.element:e,p.createElement(tt,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?p.createElement($e,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:l}):g()},null)}function H(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rt(e){let t=p.useContext(Me);return x(t,H(e)),t}function it(e){let t=p.useContext(P);return x(t,H(e)),t}function at(e){let t=p.useContext(I);return x(t,H(e)),t}function ot(e){let t=at(e),n=t.matches[t.matches.length-1];return x(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function st(){return ot(`useRouteId`)}function ct(){return it(`useNavigation`).navigation}function lt(){let{matches:e,loaderData:t}=it(`useMatches`);return p.useMemo(()=>e.map(e=>ie(e,t)),[e,t])}function ut(){let e=p.useContext(Re),t=it(`useRouteError`),n=ot(`useRouteError`);return e===void 0?t.errors?.[n]:e}function U(){let{router:e}=rt(`useNavigate`),t=ot(`useNavigate`),n=p.useRef(!1);return B(()=>{n.current=!0}),p.useCallback(async(r,i={})=>{S(n.current,z),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var dt={};function ft(e,t,n){!t&&!dt[e]&&(dt[e]=!0,S(!1,n))}p.useOptimistic,p.memo(pt);function pt({routes:e,future:t,state:n,isStatic:r,onError:i}){return Xe(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function mt({to:e,replace:t,state:n,relative:r}){x(L(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=p.useContext(F);S(!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}=p.useContext(I),{pathname:o}=R(),s=Ge(),c=we(e,Ce(a),o,r===`path`),l=JSON.stringify(c);return p.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function ht(e){x(!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 gt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){x(!L(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=p.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=E(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:m=`default`,unstable_mask:h}=n,g=p.useMemo(()=>{let e=j(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:m,unstable_mask:h},navigationType:r}},[s,l,u,d,f,m,r,h]);return S(g!=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.`),g==null?null:p.createElement(F.Provider,{value:c},p.createElement(Le.Provider,{children:t,value:g}))}function _t({children:e,location:t}){return Ye(W(e),t)}function W(e,t=[]){let n=[];return p.Children.forEach(e,(e,r)=>{if(!p.isValidElement(e))return;let i=[...t,r];if(e.type===p.Fragment){n.push.apply(n,W(e.props.children,i));return}x(e.type===ht,`[${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>`),x(!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=W(e.props.children,i)),n.push(a)}),n}var vt=`get`,G=`application/x-www-form-urlencoded`;function yt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function K(e){return yt(e)&&e.tagName.toLowerCase()===`button`}function bt(e){return yt(e)&&e.tagName.toLowerCase()===`form`}function xt(e){return yt(e)&&e.tagName.toLowerCase()===`input`}function St(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ct(e,t){return e.button===0&&(!t||t===`_self`)&&!St(e)}var wt=null;function Tt(){if(wt===null)try{new FormData(document.createElement(`form`),0),wt=!1}catch{wt=!0}return wt}var Et=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Dt(e){return e!=null&&!Et.has(e)?(S(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${G}"`),null):e}function Ot(e,t){let n,r,i,a,o;if(bt(e)){let o=e.getAttribute(`action`);r=o?j(o,t):null,n=e.getAttribute(`method`)||vt,i=Dt(e.getAttribute(`enctype`))||G,a=new FormData(e)}else if(K(e)||xt(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?j(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||vt,i=Dt(e.getAttribute(`formenctype`))||Dt(o.getAttribute(`enctype`))||G,a=new FormData(o,e),!Tt()){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(yt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=vt,r=null,i=G,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 kt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},At=/[&><\u2028\u2029]/g;function jt(e){return e.replace(At,e=>kt[e])}function Mt(e,t){if(e===!1||e==null)throw Error(t)}function Nt(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&&j(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function Pt(e,t){if(e.id in t)return t[e.id];try{let n=await _(()=>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 Ft(e){return e!=null&&typeof e.page==`string`}function It(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 Lt(e,t,n){return Ht((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Pt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(It).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Rt(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 zt(e,t,{includeHydrateFallback:n}={}){return Bt(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 Bt(e){return[...new Set(e)]}function Vt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ht(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Ft(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Vt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Ut(){let e=p.useContext(Me);return Mt(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Wt(){let e=p.useContext(P);return Mt(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Gt=p.createContext(void 0);Gt.displayName=`FrameworkContext`;function Kt(){let e=p.useContext(Gt);return Mt(e,`You must render this element inside a <HydratedRouter> element`),e}function qt(e,t){let n=p.useContext(Gt),[r,i]=p.useState(!1),[a,o]=p.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=p.useRef(null);p.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]),p.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Jt(s,m),onBlur:Jt(c,h),onMouseEnter:Jt(l,m),onMouseLeave:Jt(u,h),onTouchStart:Jt(d,m)}]:[a,f,{}]:[!1,f,{}]}function Jt(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Yt({page:e,...t}){let{router:n}=Ut(),r=p.useMemo(()=>D(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?p.createElement(Zt,{page:e,matches:r,...t}):null}function Xt(e){let{manifest:t,routeModules:n}=Kt(),[r,i]=p.useState([]);return p.useEffect(()=>{let r=!1;return Lt(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Zt({page:e,matches:t,...n}){let r=R(),{future:i,manifest:a,routeModules:o}=Kt(),{basename:s}=Ut(),{loaderData:c,matches:l}=Wt(),u=p.useMemo(()=>Rt(e,t,l,a,r,`data`),[e,t,l,a,r]),d=p.useMemo(()=>Rt(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=p.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=Nt(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]),m=p.useMemo(()=>zt(d,a),[d,a]),h=Xt(d);return p.createElement(p.Fragment,null,f.map(e=>p.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>p.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>p.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Qt(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var $t=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{$t&&(window.__reactRouterVersion=`7.13.1`)}catch{}function en({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=p.useRef();i.current??=b({window:r,v5Compat:!0});let a=i.current,[o,s]=p.useState({action:a.action,location:a.location}),c=p.useCallback(e=>{n===!1?s(e):p.startTransition(()=>s(e))},[n]);return p.useLayoutEffect(()=>a.listen(c),[a,c]),p.createElement(gt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function tn({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=p.useState({action:n.action,location:n.location}),o=p.useCallback(e=>{r===!1?a(e):p.startTransition(()=>a(e))},[r]);return p.useLayoutEffect(()=>n.listen(o),[n,o]),p.createElement(gt,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}tn.displayName=`unstable_HistoryRouter`;var nn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,rn=p.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...m},h){let{basename:g,navigator:_,unstable_useTransitions:v}=p.useContext(F),y=typeof l==`string`&&nn.test(l),b=je(l,g);l=b.to;let x=We(l,{relative:r}),S=R(),C=null;if(o){let e=we(o,[],S.unstable_mask?S.unstable_mask.pathname:`/`,!0);g!==`/`&&(e.pathname=e.pathname===`/`?g:M([g,e.pathname])),C=_.createHref(e)}let[w,ee,T]=qt(n,m),E=dn(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:v});function te(t){e&&e(t),t.defaultPrevented||E(t)}let ne=!(b.isExternal||i),D=p.createElement(`a`,{...m,...T,href:(ne?C:void 0)||b.absoluteURL||x,onClick:ne?te:e,ref:Qt(h,ee),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return w&&!y?p.createElement(p.Fragment,null,D,p.createElement(Yt,{page:x})):D});rn.displayName=`Link`;var an=p.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=Je(a,{relative:c.relative}),d=R(),f=p.useContext(P),{navigator:m,basename:h}=p.useContext(F),g=f!=null&&bn(u)&&o===!0,_=m.encodeLocation?m.encodeLocation(u).pathname:u.pathname,v=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=j(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,ee;ee=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(C):i;return p.createElement(rn,{...c,"aria-current":w,className:ee,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(C):s)});an.displayName=`NavLink`;var on=p.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=vt,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...m},h)=>{let{unstable_useTransitions:g}=p.useContext(F),_=mn(),v=q(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&nn.test(s);return p.createElement(`form`,{ref:h,method:y,action:v,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,m=()=>_(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});g&&n!==!1?p.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});on.displayName=`Form`;function sn({getKey:e,storageKey:t,...n}){let r=p.useContext(Gt),{basename:i}=p.useContext(F),a=R(),o=lt();vn({getKey:e,storageKey:t});let s=p.useMemo(()=>{if(!r||!e)return null;let t=_n(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 p.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${jt(JSON.stringify(t||hn))}, ${jt(JSON.stringify(s))})`}})}sn.displayName=`ScrollRestoration`;function cn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ln(e){let t=p.useContext(Me);return x(t,cn(e)),t}function un(e){let t=p.useContext(P);return x(t,cn(e)),t}function dn(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=Ge(),d=R(),f=Je(e,{relative:o});return p.useCallback(m=>{if(Ct(m,t)){m.preventDefault();let t=n===void 0?T(d)===T(f):n,h=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?p.startTransition(()=>h()):h()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}var fn=0,pn=()=>`__${String(++fn)}__`;function mn(){let{router:e}=ln(`useSubmit`),{basename:t}=p.useContext(F),n=st(),r=e.fetch,i=e.navigate;return p.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Ot(e,t);a.navigate===!1?await r(a.fetcherKey||pn(),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 q(e,{relative:t}={}){let{basename:n}=p.useContext(F),r=p.useContext(I);x(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...Je(e||`.`,{relative:t})},o=R();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:M([n,a.pathname])),T(a)}var hn=`react-router-scroll-positions`,gn={};function _n(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:j(e.pathname,n)||e.pathname},t)),i??=e.key,i}function vn({getKey:e,storageKey:t}={}){let{router:n}=ln(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=un(`useScrollRestoration`),{basename:a}=p.useContext(F),o=R(),s=lt(),c=ct();p.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),yn(p.useCallback(()=>{if(c.state===`idle`){let t=_n(o,s,a,e);gn[t]=window.scrollY}try{sessionStorage.setItem(t||hn,JSON.stringify(gn))}catch(e){S(!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`&&(p.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||hn);e&&(gn=JSON.parse(e))}catch{}},[t]),p.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(gn,()=>window.scrollY,e?(t,n)=>_n(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),p.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{S(!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 yn(e,t){let{capture:n}=t||{};p.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function bn(e,{relative:t}={}){let n=p.useContext(Pe);x(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ln(`useViewTransitionState`),i=Je(e,{relative:t});if(!n.isTransitioning)return!1;let a=j(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=j(n.nextLocation.pathname,r)||n.nextLocation.pathname;return he(i.pathname,o)!=null||he(i.pathname,a)!=null}var xn=`coder-studio.locale`,Sn={en:{appTagline:`Commercial-grade agent operations desk`,languageLabel:`Language`,theme:`Theme`,themeDark:`Dark`,themeLight:`Light`,workspaceLabel:`Workspace`,noWorkspace:`No workspace`,activeCount:({count:e})=>`Active ${e}`,waitingCount:({count:e})=>`Waiting ${e}`,queuedCount:({count:e})=>`Queued ${e}`,newTab:`+ New Tab`,deleteWorkspace:`Delete workspace`,threads:`Threads`,sortByTime:`Sort by time`,sortByName:`Sort by name`,settings:`Settings`,workspaceBrief:`Workspace Brief`,workspaceDescription:`Coordinate AI coding sessions, monitor repo health, and keep terminal control in one operational surface.`,status:`Status`,ready:`Ready`,idle:`Idle`,branch:`Branch`,changes:`Changes`,agent:`Agent`,remoteGit:`Remote Git`,localFolder:`Local Folder`,noCommits:`No commits`,newSession:`New Session`,complete:`Complete`,stop:`Stop`,pool:`Pool`,mode:`Mode`,branchMode:`Branch`,gitTreeMode:`Git Tree`,autoSuspend:`Auto suspend`,idleAfter:`Idle after`,minutesShort:`min`,maxActive:`Max active`,sessionsWord:`sessions`,memoryPressure:`Memory pressure`,sessionDeck:`Session Deck`,sessionsNav:`Sessions`,parallelWorkstreams:`Parallel Workstreams`,tasksCount:({count:e})=>`${e} tasks`,completePercent:({percent:e})=>`${e}% complete`,archive:`Archive`,taskQueue:`Task Queue`,dispatchBoard:`Dispatch Board`,autoFeed:`Auto-feed`,queuePlaceholder:`Add a task to the queue...`,add:`Add`,runNext:`Run Next`,liveTask:`Live task`,noTaskInProgress:`No task in progress`,queueEmpty:`Queue is empty.`,running:`Running`,background:`Background`,waiting:`Waiting`,suspended:`Suspended`,queued:`Queued`,done:`Done`,agentConfiguration:`Agent Configuration`,executionProfile:`Execution Profile`,provider:`Provider`,launchCommand:`Launch command`,launchCommandPlaceholder:`e.g. claude`,launchCommandHint:`Command used when a workspace boots an agent process.`,launchCommandChecking:`Checking command availability...`,launchCommandAvailable:({runtime:e})=>`Available in ${e}`,launchCommandResolvedPath:({path:e})=>`Resolved to ${e}`,launchCommandMissing:({runtime:e})=>`Not found in ${e}`,launchCommandEmpty:`Enter a command to validate the runtime.`,autoSuspendHint:`Automatically suspend idle sessions when capacity needs to be reclaimed.`,idleAfterHint:`How long a session can stay idle before it is suspended.`,maxActiveHint:`Maximum number of concurrently active sessions across workspaces.`,memoryPressureHint:`Allow the app to suspend sessions earlier when the system is under pressure.`,themeHint:`Choose how the application surface is rendered.`,languageHint:`Choose the interface language used across the application.`,worktrees:`Worktrees`,noWorktrees:`No worktrees`,archiveLog:`Archive Log`,noArchiveYet:`No archive yet.`,activityFeed:`Activity Feed`,recentEvents:`Recent Events`,repositoryNavigator:`Repository Navigator`,projectStructure:`Project Structure`,files:`Files`,gitNav:`Git`,refresh:`Refresh`,sourceControl:`Source Control`,stagedChanges:`Staged Changes`,untrackedFiles:`Untracked`,stageFile:`Stage file`,unstageFile:`Unstage file`,discardFile:`Discard changes`,changesCount:({count:e})=>`Changes ${e}`,stagedCount:({count:e})=>`Staged ${e}`,untrackedCount:({count:e})=>`Untracked ${e}`,commitMessage:`Commit Message`,commitPlaceholder:`Describe this change set`,stageAll:`Stage All`,unstageAll:`Unstage All`,discardAll:`Discard All`,commit:`Commit`,gitCommitSucceeded:`Commit created`,gitActionFailed:`Git action failed`,selectProjectToLoadFiles:`Select a project to load files.`,noChangesDetected:`No changes detected.`,modified:`Modified`,liveSession:`Live Session`,liveSessionDescription:`Queue a task or send the next instruction to the agent.`,inputConsole:`Input Console`,inputConsoleHint:`Agent output is read-only here. Send instructions and special keys from the input bar below.`,terminalMode:`Terminal`,inputMode:`Input`,viewingArchivedSession:`Viewing archived session (read-only)`,exitArchiveHint:`Exit archive view to resume live operations.`,exit:`Exit`,agentOutput:`Agent Output`,interactiveCommandStream:`Interactive command stream`,executing:`Executing`,listening:`Listening`,archiveViewReadonly:`Archive view (read-only)`,agentInputPlaceholder:`Type your next instruction...`,draftTaskPlaceholder:`Type to start a new task`,send:`Send`,globalSettings:`Global Settings`,backToApp:`Back to app`,settingsGeneral:`General`,settingsConfiguration:`Configuration`,settingsAppearance:`Appearance`,settingsMcpServers:`MCP Servers`,settingsEnvironment:`Environment`,settingsWorktrees:`Worktrees`,settingsArchives:`Archived Threads`,settingsDescription:`Configure agent defaults and suspend policy for every workspace from one place.`,settingsAutoSave:`Changes save automatically.`,appliesToAllWorkspaces:`Applies to all workspaces`,changesAffectNextLaunch:`Agent changes affect the next launch. Suspend policy updates immediately.`,agentDefaults:`Agent Defaults`,agentDefaultsHint:`Choose the provider and launch command used when a workspace starts or an agent restarts.`,suspendStrategy:`Suspend Strategy`,suspendStrategyHint:`Keep active capacity predictable by automatically yielding idle sessions when the pool is busy.`,applySettings:`Apply Settings`,save:`Save`,unsavedChanges:`Unsaved changes`,saved:`Saved`,editorReady:`Editable editor`,editorHint:`VS Code-style editing surface with direct file save.`,repositoryInspector:`Repository Inspector`,collapseCodePanel:`Collapse code panel`,expandCodePanel:`Expand code panel`,codePanel:`Code`,terminalPanel:`Terminal`,selectFileFromNavigator:`Select a file from the navigator`,preview:`Preview`,diff:`Diff`,filesStat:({count:e,additions:t,deletions:n})=>`Files ${e} · +${t} / -${n}`,noPreviewAvailable:`No preview available.`,noDiffAvailable:`No diff available.`,shellDock:`Shell Dock`,projectTerminal:`Project Terminal`,new:`New`,noTerminalYet:`No terminal yet.`,loading:`Loading`,slashMenu:`Insert Claude Command`,slashBuiltins:`Built-in Commands`,slashBundledSkills:`Bundled Skills`,slashProjectSkills:`Workspace Skills`,slashPersonalSkills:`Personal Skills`,slashMenuEmpty:`No Claude commands or skills found.`,slashSkillBadge:`skill`,slashCommandBadge:`cmd`,close:`Close`,splitVertical:`Split Vertically`,splitHorizontal:`Split Horizontally`,splitVerticalDescription:`Split current agent pane into left and right`,splitHorizontalDescription:`Split current agent pane into top and bottom`,statusTab:`Status`,treeTab:`Tree`,loadingWorktreeDetails:`Loading worktree details...`,path:`Path`,clean:`Clean`,launchWorkspace:`Launch Workspace`,launchWorkspaceTitle:`Attach a local workspace for agent-driven coding`,launchWorkspaceDescription:`Pick an existing local repository, connect your preferred CLI agent, and start parallel coding sessions with live Git visibility.`,sessionsCard:`Sessions`,parallelAgentTracks:`Parallel agent tracks`,gitCard:`Git`,liveDiffAndWorktree:`Live diff + worktree context`,terminalCard:`Terminal`,embeddedShellControl:`Embedded shell control`,remoteGitHint:`Clone to a managed workspace and begin immediately.`,localFolderHint:`Attach an existing project folder as your live workspace.`,nativeTarget:`Native`,nativeTargetHint:`Use the host shell runtime.`,wslHint:`Route Git and agent commands through WSL.`,optionalDistroPlaceholder:`Optional distro name (e.g. Ubuntu-22.04)`,folderBrowserRecovered:`The previous location is unavailable. Showing a valid server directory instead.`,homeDirectory:`Home`,goUp:`Up`,useCurrentFolder:`Use Current Folder`,loadingDirectories:`Loading server directories...`,emptyDirectories:`No subdirectories in this location`,folderBrowserInteractionHint:`Click a folder to enter and select it.`,folderBrowserRowHint:`Click to enter`,enterFolder:`Enter`,pasteGitUrl:`Paste a Git URL`,selectFolder:`Select Folder`,selected:`Selected`,notSelected:`Not selected`,cancel:`Cancel`,startWorkspace:`Start Workspace`,initializeWorkspace:`Initialize Workspace`,selectFolderDialog:`Select Folder`,noFolderSelected:`No folder selected`,dialogFailed:`Dialog failed`,selectProjectFirst:`Select a project first`,agentStartFailed:`Agent start failed`,agentSendFailed:`Agent send failed`,agentKeySendFailed:`Agent key send failed`,taskCompleteMessage:({text:e})=>`Task complete: ${e}`,taskCompletedToast:({title:e})=>`${e} completed`,taskStopped:`Task stopped`,workingOn:({text:e})=>`Working on: ${e}`,draftSessionTitle:`New Session`,draftSessionPrompt:`Start here`,draftSessionWorkspace:({path:e})=>`Workspace: ${e}`,previewUnavailable:`Preview unavailable.`,agentExited:`Agent exited`,escKey:`Esc`,tabKey:`Tab`,enterKey:`Enter`,arrowUp:`Up`,arrowDown:`Down`,arrowLeft:`Left`,arrowRight:`Right`,poolSummary:({active:e,max:t,queued:n})=>`Active ${e} / ${t} • Queued ${n}`,authPublicModeBadge:`Public Mode`,authLoadingTitle:`Checking access`,authLoadingDescription:`Verifying deployment mode and session state before the workspace loads.`,authTitle:`Unlock Coder Studio`,authDescription:`This deployment is protected by a single access passphrase. Enter it to continue.`,authAllowedRoots:`Allowed roots`,authAllowedRootsHint:`After sign-in, only the folders in this list can be opened from the browser.`,authAllowedRootsEmpty:`No allowed roots are configured yet.`,authIdleWindow:`Idle timeout`,authSessionWindow:`Session max`,authPasswordLabel:`Access passphrase`,authPasswordPlaceholder:`Enter passphrase`,authShowPassword:`Show`,authHidePassword:`Hide`,authLogin:`Enter workspace`,authLoggingIn:`Checking…`,authInvalidCredentials:`That passphrase is incorrect.`,authBlockedUntil:({time:e})=>`Too many failed attempts. Try again after ${e}.`,authSessionExpired:`Your session expired. Sign in again to continue.`,authNotConfigured:`Set the passphrase in auth.json before public mode can be used.`,authNotConfiguredTitle:`Passphrase is not configured yet`,authNotConfiguredDescription:`Set the password field in auth.json, then retry the status check from this screen.`,authSetupHint:`If login is unavailable, check auth.json and make sure the password field is configured.`,authSecureTransportRequired:`HTTPS is required before the passphrase can be submitted from this host.`,authTransportRequiredTitle:`HTTPS is required on this host`,authTransportRequiredDescription:`This deployment only accepts the passphrase over an encrypted connection when accessed remotely.`,authBlockedTitle:`This IP is temporarily blocked`,authBlockedDescription:({time:e})=>`Too many failed attempts were recorded from this IP. Access resumes after ${e}.`,authUnavailable:`Authentication is temporarily unavailable. Check the transport service and try again.`,authUnavailableTitle:`Authentication service is unavailable`,authUnavailableDescription:`The service could not confirm the current session. Retry after the transport service is healthy.`,authRetry:`Retry check`,authRefreshing:`Refreshing…`,authUnlockingBadge:`Ready`,authUnlockingTitle:`Access granted`,authUnlockingDescription:`Loading the workbench and restoring your session.`},zh:{appTagline:`商业级智能体协同工作台`,languageLabel:`语言`,theme:`主题`,themeDark:`深色`,themeLight:`浅色`,workspaceLabel:`工作区`,noWorkspace:`未选择工作区`,activeCount:({count:e})=>`活跃 ${e}`,waitingCount:({count:e})=>`等待 ${e}`,queuedCount:({count:e})=>`排队 ${e}`,newTab:`+ 新建标签`,deleteWorkspace:`删除工作区`,threads:`线程`,sortByTime:`按时间排序`,sortByName:`按名称排序`,settings:`设置`,workspaceBrief:`工作区概览`,workspaceDescription:`把 AI 编码会话、仓库健康度和终端控制收拢到同一个作业界面里。`,status:`状态`,ready:`就绪`,idle:`空闲`,branch:`分支`,changes:`变更`,agent:`智能体`,remoteGit:`远程仓库`,localFolder:`本地目录`,noCommits:`暂无提交`,newSession:`新建会话`,complete:`完成`,stop:`停止`,pool:`资源池`,mode:`模式`,branchMode:`分支`,gitTreeMode:`工作树`,autoSuspend:`自动挂起`,idleAfter:`空闲后`,minutesShort:`分钟`,maxActive:`最大活跃数`,sessionsWord:`个会话`,memoryPressure:`内存压力`,sessionDeck:`会话面板`,sessionsNav:`会话`,parallelWorkstreams:`并行工作流`,tasksCount:({count:e})=>`${e} 个任务`,completePercent:({percent:e})=>`完成 ${e}%`,archive:`归档`,taskQueue:`任务队列`,dispatchBoard:`派发面板`,autoFeed:`自动投喂`,queuePlaceholder:`向队列添加任务...`,add:`添加`,runNext:`运行下一项`,liveTask:`实时任务`,noTaskInProgress:`当前没有进行中的任务`,queueEmpty:`队列为空。`,running:`执行中`,background:`后台`,waiting:`等待`,suspended:`挂起`,queued:`排队中`,done:`已完成`,agentConfiguration:`智能体配置`,executionProfile:`执行配置`,provider:`提供方`,launchCommand:`启动命令`,launchCommandPlaceholder:`例如 claude`,launchCommandHint:`工作区启动智能体进程时使用的命令。`,launchCommandChecking:`正在检查命令是否可用…`,launchCommandAvailable:({runtime:e})=>`${e} 中可用`,launchCommandResolvedPath:({path:e})=>`解析路径:${e}`,launchCommandMissing:({runtime:e})=>`${e} 中未找到该命令`,launchCommandEmpty:`输入命令后会自动检测当前运行时。`,autoSuspendHint:`当容量需要回收时,自动挂起空闲会话。`,idleAfterHint:`会话在被挂起前允许保持空闲的时长。`,maxActiveHint:`所有工作区内允许同时活跃的会话上限。`,memoryPressureHint:`当系统资源紧张时,允许更早挂起空闲会话。`,themeHint:`选择应用整体的外观主题。`,languageHint:`选择整个应用界面使用的语言。`,worktrees:`工作树`,noWorktrees:`暂无工作树`,archiveLog:`归档记录`,noArchiveYet:`暂无归档。`,activityFeed:`活动流`,recentEvents:`最近事件`,repositoryNavigator:`仓库导航`,projectStructure:`项目结构`,files:`文件`,gitNav:`Git`,refresh:`刷新`,sourceControl:`源码管理`,stagedChanges:`已暂存更改`,untrackedFiles:`未跟踪`,stageFile:`暂存文件`,unstageFile:`取消暂存`,discardFile:`放弃更改`,changesCount:({count:e})=>`更改 ${e}`,stagedCount:({count:e})=>`已暂存 ${e}`,untrackedCount:({count:e})=>`未跟踪 ${e}`,commitMessage:`提交说明`,commitPlaceholder:`输入本次变更说明`,stageAll:`全部暂存`,unstageAll:`取消暂存`,discardAll:`全部回退`,commit:`提交`,gitCommitSucceeded:`已创建提交`,gitActionFailed:`Git 操作失败`,selectProjectToLoadFiles:`先选择项目再加载文件。`,noChangesDetected:`未检测到变更。`,modified:`已修改`,liveSession:`实时会话`,liveSessionDescription:`可以先排任务,或直接给智能体发送下一条指令。`,inputConsole:`输入控制台`,inputConsoleHint:`这里的智能体输出为只读,所有指令和特殊按键都从下方输入栏发送。`,terminalMode:`终端`,inputMode:`输入框`,viewingArchivedSession:`正在查看归档会话(只读)`,exitArchiveHint:`退出归档视图后即可恢复实时操作。`,exit:`退出`,agentOutput:`智能体输出`,interactiveCommandStream:`交互命令流`,executing:`执行中`,listening:`监听中`,archiveViewReadonly:`归档视图(只读)`,agentInputPlaceholder:`输入下一条指令...`,draftTaskPlaceholder:`请输入内容开启新任务`,send:`发送`,globalSettings:`全局设置`,backToApp:`返回应用`,settingsGeneral:`常规`,settingsConfiguration:`配置`,settingsAppearance:`个性化`,settingsMcpServers:`MCP 服务器`,settingsEnvironment:`环境`,settingsWorktrees:`工作树`,settingsArchives:`已归档线程`,settingsDescription:`在一个面板里统一配置所有工作区的智能体默认值和挂起策略。`,settingsAutoSave:`修改后会自动保存。`,appliesToAllWorkspaces:`作用于全部工作区`,changesAffectNextLaunch:`智能体配置在下次启动时生效,挂起策略会立即同步。`,agentDefaults:`智能体默认值`,agentDefaultsHint:`设置工作区启动或智能体重启时使用的提供方和启动命令。`,suspendStrategy:`挂起策略`,suspendStrategyHint:`在会话池繁忙时自动让空闲会话让出容量,保证活跃并发可控。`,applySettings:`应用设置`,save:`保存`,unsavedChanges:`未保存修改`,saved:`已保存`,editorReady:`可编辑编辑器`,editorHint:`基于 VS Code 风格的编辑界面,可直接保存文件。`,repositoryInspector:`仓库检查器`,collapseCodePanel:`收起代码区域`,expandCodePanel:`展开代码区域`,codePanel:`代码`,terminalPanel:`终端`,selectFileFromNavigator:`从导航中选择一个文件`,preview:`预览`,diff:`差异`,filesStat:({count:e,additions:t,deletions:n})=>`文件 ${e} · +${t} / -${n}`,noPreviewAvailable:`暂无可预览内容。`,noDiffAvailable:`暂无差异。`,shellDock:`终端停靠区`,projectTerminal:`项目终端`,new:`新建`,noTerminalYet:`还没有终端。`,loading:`加载中`,slashMenu:`插入 Claude 命令`,slashBuiltins:`内置命令`,slashBundledSkills:`内置技能`,slashProjectSkills:`工作区技能`,slashPersonalSkills:`个人技能`,slashMenuEmpty:`未发现 Claude 命令或技能。`,slashSkillBadge:`技能`,slashCommandBadge:`命令`,close:`关闭`,splitVertical:`垂直拆分`,splitHorizontal:`水平拆分`,splitVerticalDescription:`将当前智能体面板拆分为左右两栏`,splitHorizontalDescription:`将当前智能体面板拆分为上下两栏`,statusTab:`状态`,treeTab:`目录`,loadingWorktreeDetails:`正在加载工作树详情...`,path:`路径`,clean:`干净`,launchWorkspace:`启动工作区`,launchWorkspaceTitle:`接入本地工作区并启动智能体协作编码`,launchWorkspaceDescription:`选择一个现有本地仓库,接入你偏好的 CLI 智能体,并在可见 Git 状态下开启并行编码会话。`,sessionsCard:`会话`,parallelAgentTracks:`并行智能体轨道`,gitCard:`Git`,liveDiffAndWorktree:`实时差异与工作树上下文`,terminalCard:`终端`,embeddedShellControl:`内嵌 Shell 控制`,remoteGitHint:`克隆到托管工作区并立即开始。`,localFolderHint:`把现有项目目录接入为实时工作区。`,nativeTarget:`系统`,nativeTargetHint:`使用宿主机 Shell 运行时。`,wslHint:`通过 WSL 执行 Git 和智能体命令。`,optionalDistroPlaceholder:`可选发行版名称(如 Ubuntu-22.04)`,folderBrowserRecovered:`上次的位置已不可用,当前已切换到可读取的服务端目录。`,homeDirectory:`主目录`,goUp:`上一级`,useCurrentFolder:`使用当前目录`,loadingDirectories:`正在读取服务端目录…`,emptyDirectories:`当前目录下没有可进入的子目录`,folderBrowserInteractionHint:`点击目录即可进入并选中。`,folderBrowserRowHint:`点击进入`,enterFolder:`进入`,pasteGitUrl:`粘贴 Git 地址`,selectFolder:`选择文件夹`,selected:`已选择`,notSelected:`未选择`,cancel:`取消`,startWorkspace:`开始工作区`,initializeWorkspace:`初始化工作区`,selectFolderDialog:`选择文件夹`,noFolderSelected:`未选择文件夹`,dialogFailed:`对话框打开失败`,selectProjectFirst:`请先选择项目`,agentStartFailed:`智能体启动失败`,agentSendFailed:`发送给智能体失败`,agentKeySendFailed:`按键发送失败`,taskCompleteMessage:({text:e})=>`任务完成:${e}`,taskCompletedToast:({title:e})=>`${e} 已完成`,taskStopped:`任务已停止`,workingOn:({text:e})=>`正在处理:${e}`,draftSessionTitle:`新会话`,draftSessionPrompt:`请开始`,draftSessionWorkspace:({path:e})=>`当前工作区:${e}`,previewUnavailable:`无法预览。`,agentExited:`智能体已退出`,escKey:`退出`,tabKey:`制表`,enterKey:`回车`,arrowUp:`上`,arrowDown:`下`,arrowLeft:`左`,arrowRight:`右`,poolSummary:({active:e,max:t,queued:n})=>`活跃 ${e} / ${t} • 排队 ${n}`,authPublicModeBadge:`公开访问模式`,authLoadingTitle:`正在校验访问状态`,authLoadingDescription:`在工作区加载前,先确认当前部署模式和会话状态。`,authTitle:`解锁 Coder Studio`,authDescription:`当前部署已启用单口令保护,请输入访问口令后继续。`,authAllowedRoots:`允许目录`,authAllowedRootsHint:`登录后,浏览器只能打开这份白名单中的目录。`,authAllowedRootsEmpty:`当前还没有配置任何可访问目录。`,authIdleWindow:`空闲超时`,authSessionWindow:`会话上限`,authPasswordLabel:`访问口令`,authPasswordPlaceholder:`请输入访问口令`,authShowPassword:`显示`,authHidePassword:`隐藏`,authLogin:`进入工作区`,authLoggingIn:`校验中…`,authInvalidCredentials:`访问口令不正确。`,authBlockedUntil:({time:e})=>`失败次数过多,请在 ${e} 后重试。`,authSessionExpired:`当前会话已过期,请重新输入口令。`,authNotConfigured:`请先在 auth.json 中设置访问口令,再使用公开访问模式。`,authNotConfiguredTitle:`当前还没有配置访问口令`,authNotConfiguredDescription:`请先在 auth.json 中设置 password 字段,然后回到这里重新检查状态。`,authSetupHint:`如果当前无法登录,请先检查 auth.json,确认 password 字段已经设置。`,authSecureTransportRequired:`当前主机必须启用 HTTPS,才能安全提交访问口令。`,authTransportRequiredTitle:`当前主机必须使用 HTTPS`,authTransportRequiredDescription:`远程访问这个部署时,只允许通过加密连接提交访问口令。`,authBlockedTitle:`当前 IP 已被临时封禁`,authBlockedDescription:({time:e})=>`这个 IP 的失败次数过多,请在 ${e} 后再试。`,authUnavailable:`鉴权服务暂时不可用,请检查传输服务后重试。`,authUnavailableTitle:`鉴权服务当前不可用`,authUnavailableDescription:`系统暂时无法确认当前会话,请在传输服务恢复后重新检查。`,authRetry:`重新检查`,authRefreshing:`检查中…`,authUnlockingBadge:`就绪`,authUnlockingTitle:`访问已通过`,authUnlockingDescription:`正在载入工作台并恢复当前会话。`}},Cn=()=>{if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(xn);return e===`en`||e===`zh`?e:null}catch{return null}},wn=()=>Cn()||(typeof navigator<`u`&&navigator.language.toLowerCase().startsWith(`zh`)?`zh`:`en`),Tn=e=>{typeof document<`u`&&(document.documentElement.lang=e===`zh`?`zh-CN`:`en`)},En=e=>{if(typeof window<`u`)try{window.localStorage.setItem(xn,e)}catch{}Tn(e)},Dn=e=>(t,n={})=>{let r=Sn[e][t]??Sn.en[t];return typeof r==`function`?r(n):r},On=e=>typeof e==`string`?e:String(e).padStart(2,`0`),kn=(e,t)=>t===`zh`?`会话 ${On(e)}`:`Session ${On(e)}`,An=(e,t)=>t===`zh`?`工作区 ${On(e)}`:`Workspace ${On(e)}`,jn=(e,t)=>t===`zh`?`终端 ${e}`:`Terminal ${e}`,Mn=(e,t)=>t===`zh`?`${kn(e,t)} 已就绪。`:`${kn(e,t)} is ready.`,Nn=(e,t)=>{for(let n of t){let t=e.match(n);if(t?.[1])return t[1]}return null},Pn=(e,t)=>{let n=Nn(e,[/^Session (\d+)$/,/^会话 (\d+)$/]);return n?kn(n,t):e},Fn=(e,t)=>{let n=Nn(e,[/^Workspace (\d+)$/,/^工作区 (\d+)$/]);return n?An(n,t):e},In=(e,t)=>{let n=Nn(e,[/^Terminal (\d+)$/,/^终端 (\d+)$/]);return n?jn(n,t):e},Ln=`http://127.0.0.1:41033`,Rn=`5174`,zn=e=>{let t=e.trim();if(!t)return``;try{return(typeof window<`u`?new URL(t,window.location.origin):new URL(t)).origin.replace(/\/+$/,``)}catch{return t.replace(/\/+$/,``)}},Bn=()=>typeof window>`u`?``:zn(window.__CODER_STUDIO_BACKEND__??``),Vn=()=>{if(typeof window>`u`)return!1;let e=window.location.hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`},Hn=()=>{if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).get(`auth`)===`force`}catch{return!1}},Un=e=>(Hn()&&e.searchParams.set(`auth`,`force`),e),Wn=()=>typeof window<`u`&&!!window.__TAURI_INTERNALS__,Gn=()=>typeof window>`u`?!1:Wn()&&Vn()&&window.location.port===Rn,Kn=()=>typeof window>`u`?``:Bn()||(Gn()?Ln:zn(window.location.origin)),qn=()=>{let e=Kn(),t=new URL(e||(typeof window<`u`?window.location.origin:`http://127.0.0.1`));return t.pathname=`/health`,t.search=``,t.hash=``,Un(t).toString()},Jn=()=>{let e=Kn(),t=new URL(e||(typeof window<`u`?window.location.origin:`http://127.0.0.1`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.pathname=`/ws`,t.search=``,t.hash=``,Un(t).toString()},Yn={public_mode:!1,authenticated:!0,password_configured:!0,local_host:!1,secure_transport_required:!1,secure_transport_ok:!0,session_idle_minutes:15,session_max_hours:12,allowed_roots:[]},Xn=new Set,Zn=new Set,Qn=Yn,$n=!1,er=null,tr=class extends Error{code;status;blockedUntil;constructor(e,t,n){super(e),this.name=`AuthRequestError`,this.code=e,this.status=t,this.blockedUntil=n}},nr=()=>typeof window>`u`?!1:window.location.protocol===`http:`||window.location.protocol===`https:`,rr=()=>nr()&&Vn(),ir=()=>nr()&&!rr()||Hn(),ar=e=>Un(new URL(e,`${Kn()}/`)).toString(),or=()=>{Xn.forEach(e=>e(Qn))},sr=e=>{Qn=e,$n=!0,or()},cr=()=>({...Yn,public_mode:!1,authenticated:!0,local_host:!1}),lr=()=>Wn()&&!ir(),ur=async(e,t)=>{let n=await fetch(ar(e),{cache:`no-store`,credentials:`include`,...t,headers:{"content-type":`application/json`,...t?.headers??{}}}),r={};try{r=await n.json()}catch{}if(!n.ok||r.ok===!1)throw new tr(r.error||`HTTP ${n.status}`,n.status,r.blocked_until);return r.data},dr=()=>Qn,fr=()=>$n?Qn.public_mode:ir(),pr=()=>fr()?$n?Qn.authenticated:!1:!0,mr=()=>er,hr=()=>{er=null},gr=e=>(Xn.add(e),()=>{Xn.delete(e)}),_r=e=>(Zn.add(e),()=>{Zn.delete(e)}),vr=e=>{fr()&&(er=e,sr({...Qn,public_mode:!0,authenticated:!1}),Zn.forEach(t=>t(e)))},yr=async()=>{try{let e=await ur(`/api/auth/status`,{method:`GET`});return sr(e),e}catch(e){if(lr()){let e=cr();return sr(e),e}throw sr({...Qn,public_mode:!0,authenticated:!1}),e}},br=async e=>{let t=await ur(`/api/auth/login`,{method:`POST`,body:JSON.stringify({password:e})});return er=null,sr(t),t},xr=(e,t)=>!e||t.startsWith(e)||t.startsWith(`/`)||t.includes(`:`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}/${t.startsWith(`/`)?t.slice(1):t}`,Sr=e=>e.replace(/\\/g,`/`),Cr=e=>Sr(e).replace(/^[:/\\]+/,``),wr=(e,t)=>{let n=Sr(e),r=Sr(t);return n===r||n.endsWith(`/${r}`)},Tr=e=>/^[a-zA-Z]:[\\/]/.test(e),Er=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`).split(`/`);return t.pop(),t.join(`/`)},Dr=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return e;let n=t.split(`/`).filter(Boolean);return n[n.length-1]??t},J=t(),Or=180,kr=(e,t)=>{if(!e)return``;try{return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e}};function Ar({locale:e,onSelectLocale:t,children:n}){let r=(0,p.useMemo)(()=>Dn(e),[e]),[i,a]=(0,p.useState)(()=>dr()),[o,s]=(0,p.useState)(!0),[c,l]=(0,p.useState)(!1),[u,d]=(0,p.useState)(``),[f,m]=(0,p.useState)(!1),[h,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(!1),[y,b]=(0,p.useState)(()=>mr()),[x,S]=(0,p.useState)(),C=e=>{if(a(e=>({...e,public_mode:!0,authenticated:!1})),e instanceof tr){b(e.code),S(e.blockedUntil);return}b(`auth_unavailable`)},w=async()=>{l(!0);try{let e=await yr();return a(e),b(null),S(void 0),e}catch(e){return C(e),null}finally{l(!1)}};(0,p.useEffect)(()=>gr(e=>a(e)),[]),(0,p.useEffect)(()=>_r(e=>{b(e),g(!1),v(!1)}),[]),(0,p.useEffect)(()=>{let e=!0;return s(!0),yr().then(t=>{e&&(a(t),b(null),S(void 0))}).catch(t=>{e&&C(t)}).finally(()=>{e&&s(!1)}),()=>{e=!1}},[]),(0,p.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{v(!1)},Or);return()=>{window.clearTimeout(e)}},[_]),(0,p.useEffect)(()=>{i.authenticated||v(!1)},[i.authenticated]);let ee=async e=>{if(e.preventDefault(),!(h||!u.trim())){if(hr(),g(!0),b(null),S(void 0),!i.password_configured){b(`auth_not_configured`),g(!1);return}try{let e=await br(u.trim());a(e),d(``),m(!1),e.authenticated&&v(!0)}catch(e){e instanceof tr?(b(e.code),S(e.blockedUntil)):b(`auth_unavailable`)}finally{g(!1)}}},T=(0,J.jsxs)(`div`,{className:`settings-pill-select auth-locale-switch`,"aria-label":r(`languageLabel`),children:[(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`zh`?`active`:``}`,onClick:()=>t(`zh`),children:`中文`}),(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`en`?`active`:``}`,onClick:()=>t(`en`),children:`English`})]}),E=(0,J.jsxs)(`div`,{className:`auth-preview-shell`,"aria-hidden":`true`,children:[(0,J.jsxs)(`header`,{className:`topbar auth-preview-topbar`,children:[(0,J.jsx)(`div`,{className:`topbar-left`,children:(0,J.jsxs)(`div`,{className:`app-title auth-preview-brand`,children:[(0,J.jsx)(`span`,{className:`auth-preview-dot`}),(0,J.jsx)(`span`,{children:`CODER STUDIO`})]})}),(0,J.jsx)(`div`,{className:`topbar-center`,children:(0,J.jsxs)(`div`,{className:`topbar-session-strip topbar-workspace-strip auth-preview-tabs`,children:[(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab active`,children:[(0,J.jsx)(`span`,{className:`session-top-dot active`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`checkout-api`})]}),(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab`,children:[(0,J.jsx)(`span`,{className:`session-top-dot idle`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`release-note`})]}),(0,J.jsxs)(`span`,{className:`session-top-tab workspace-top-tab running-glow`,children:[(0,J.jsx)(`span`,{className:`session-top-dot active pulse`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:`deploy-guard`})]})]})}),(0,J.jsxs)(`div`,{className:`topbar-actions`,children:[(0,J.jsx)(`span`,{className:`topbar-tool topbar-tool-wide auth-preview-tool`,children:(0,J.jsx)(`span`,{children:e===`zh`?`操作`:`Actions`})}),(0,J.jsx)(`span`,{className:`topbar-tool auth-preview-tool-square`})]})]}),(0,J.jsxs)(`div`,{className:`workspace-layout auth-preview-layout`,children:[(0,J.jsxs)(`aside`,{className:`panel left-panel auth-preview-panel`,children:[(0,J.jsx)(`div`,{className:`sidebar-header`,children:(0,J.jsx)(`span`,{className:`sidebar-title`,children:e===`zh`?`会话`:`Sessions`})}),(0,J.jsxs)(`div`,{className:`sidebar-content auth-preview-panel-body`,children:[(0,J.jsx)(`span`,{className:`auth-preview-label`}),(0,J.jsx)(`span`,{className:`auth-preview-line wide`}),(0,J.jsx)(`span`,{className:`auth-preview-line`}),(0,J.jsxs)(`div`,{className:`auth-preview-stack`,children:[(0,J.jsx)(`span`,{className:`auth-preview-block`}),(0,J.jsx)(`span`,{className:`auth-preview-block`}),(0,J.jsx)(`span`,{className:`auth-preview-block`})]})]})]}),(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`left`}),(0,J.jsxs)(`main`,{className:`workspace-main auth-preview-main`,children:[(0,J.jsxs)(`div`,{className:`auth-preview-main-bar`,children:[(0,J.jsx)(`span`,{className:`auth-preview-chip wide`}),(0,J.jsx)(`span`,{className:`auth-preview-chip`}),(0,J.jsx)(`span`,{className:`auth-preview-chip short`})]}),(0,J.jsxs)(`div`,{className:`auth-preview-main-grid`,children:[(0,J.jsx)(`span`,{className:`auth-preview-surface large`}),(0,J.jsx)(`span`,{className:`auth-preview-surface`}),(0,J.jsx)(`span`,{className:`auth-preview-surface`})]})]}),(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`right`}),(0,J.jsxs)(`aside`,{className:`panel right-panel auth-preview-panel auth-preview-panel-right`,children:[(0,J.jsx)(`div`,{className:`panel-header`,children:(0,J.jsx)(`span`,{className:`panel-title`,children:e===`zh`?`终端`:`Terminal`})}),(0,J.jsxs)(`div`,{className:`panel-body auth-preview-panel-body`,children:[(0,J.jsx)(`span`,{className:`auth-preview-line`}),(0,J.jsx)(`span`,{className:`auth-preview-line short`}),(0,J.jsxs)(`div`,{className:`auth-preview-stack compact`,children:[(0,J.jsx)(`span`,{className:`auth-preview-card`}),(0,J.jsx)(`span`,{className:`auth-preview-card`}),(0,J.jsx)(`span`,{className:`auth-preview-card`})]})]})]})]})]});if(o)return(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-loading`,role:`status`,"aria-live":`polite`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsx)(`div`,{className:`auth-badge-stack`,children:(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)})}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{children:r(`authLoadingTitle`)}),(0,J.jsx)(`p`,{children:r(`authLoadingDescription`)})]}),(0,J.jsxs)(`div`,{className:`auth-loading-stack`,children:[(0,J.jsx)(`span`,{className:`auth-loading-line wide`}),(0,J.jsx)(`span`,{className:`auth-loading-line`}),(0,J.jsx)(`span`,{className:`auth-loading-line short`})]})]})})})]});if(!i.public_mode||i.authenticated&&!_)return(0,J.jsx)(J.Fragment,{children:n});let te=kr(x,e),ne=i.secure_transport_required&&!i.secure_transport_ok,D=!i.password_configured||y===`auth_not_configured`?`not-configured`:ne?`transport-required`:y===`ip_blocked`?`blocked`:y===`auth_unavailable`?`unavailable`:`sign-in`,re=y===`invalid_credentials`?r(`authInvalidCredentials`):y===`session_expired`||y===`session_missing`?r(`authSessionExpired`):``,ie=D===`sign-in`?r(`authAllowedRootsHint`):D===`transport-required`?r(`authSecureTransportRequired`):D===`blocked`?r(`authBlockedUntil`,{time:te||`—`}):r(D===`unavailable`?`authUnavailable`:`authSetupHint`),ae=h||c||D!==`sign-in`,oe=D!==`sign-in`,se=i.allowed_roots.map(e=>({path:e,label:Dr(e)||e})),ce=``,O=``,k=`neutral`,A=!1;return D===`not-configured`?(ce=r(`authNotConfiguredTitle`),O=r(`authNotConfiguredDescription`),k=`warning`,A=!0):D===`transport-required`?(ce=r(`authTransportRequiredTitle`),O=r(`authTransportRequiredDescription`),k=`warning`,A=!0):D===`blocked`?(ce=r(`authBlockedTitle`),O=r(`authBlockedDescription`,{time:te||`—`}),k=`danger`):D===`unavailable`&&(ce=r(`authUnavailableTitle`),O=r(`authUnavailableDescription`),k=`danger`,A=!0),i.authenticated&&_?(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-transition`,role:`status`,"aria-live":`polite`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsxs)(`div`,{className:`auth-badge-stack`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),(0,J.jsx)(`span`,{className:`auth-state-pill success`,children:r(`authUnlockingBadge`)})]}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{children:r(`authUnlockingTitle`)}),(0,J.jsx)(`p`,{children:r(`authUnlockingDescription`)})]}),(0,J.jsx)(`div`,{className:`surface-progress loading auth-transition-progress`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`82%`}})})]})})})]}):(0,J.jsxs)(`div`,{className:`app auth-gate-screen`,"data-theme":`dark`,children:[E,(0,J.jsx)(`div`,{className:`auth-veil`}),(0,J.jsx)(`div`,{className:`auth-stage`,children:(0,J.jsx)(`section`,{className:`panel auth-card auth-card-form`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`auth-title`,"aria-describedby":`auth-description`,children:(0,J.jsxs)(`div`,{className:`auth-card-inner`,children:[(0,J.jsxs)(`div`,{className:`auth-card-bar`,children:[(0,J.jsxs)(`div`,{className:`auth-badge-stack`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),D===`transport-required`?(0,J.jsx)(`span`,{className:`auth-state-pill warning`,children:`HTTPS`}):null,D===`not-configured`?(0,J.jsx)(`span`,{className:`auth-state-pill warning`,children:`auth.json`}):null,D===`blocked`?(0,J.jsx)(`span`,{className:`auth-state-pill danger`,children:`IP`}):null]}),T]}),(0,J.jsxs)(`div`,{className:`auth-header`,children:[(0,J.jsx)(`h1`,{id:`auth-title`,children:r(`authTitle`)}),(0,J.jsx)(`p`,{id:`auth-description`,children:r(`authDescription`)})]}),(0,J.jsxs)(`div`,{className:`auth-summary`,"aria-label":r(`authPublicModeBadge`),children:[(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authAllowedRoots`)}),(0,J.jsx)(`strong`,{children:i.allowed_roots.length})]}),(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authIdleWindow`)}),(0,J.jsxs)(`strong`,{children:[i.session_idle_minutes,`m`]})]}),(0,J.jsxs)(`div`,{className:`auth-summary-item`,children:[(0,J.jsx)(`span`,{children:r(`authSessionWindow`)}),(0,J.jsxs)(`strong`,{children:[i.session_max_hours,`h`]})]})]}),oe?(0,J.jsxs)(`div`,{className:`auth-state-panel ${k}`,role:`status`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`auth-state-copy`,children:[(0,J.jsx)(`div`,{className:`section-kicker`,children:r(`authPublicModeBadge`)}),(0,J.jsx)(`h2`,{children:ce}),(0,J.jsx)(`p`,{children:O})]}),A?(0,J.jsx)(`button`,{type:`button`,className:`btn auth-secondary-action`,onClick:()=>{w()},disabled:c,children:r(c?`authRefreshing`:`authRetry`)}):null]}):null,(0,J.jsxs)(`div`,{className:`auth-block`,children:[(0,J.jsx)(`div`,{className:`auth-block-header`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`section-kicker`,children:r(`authAllowedRoots`)}),(0,J.jsx)(`p`,{children:r(`authAllowedRootsHint`)})]})}),(0,J.jsx)(`div`,{className:`auth-roots-list`,role:`list`,"aria-label":r(`authAllowedRoots`),children:se.length>0?se.map(e=>(0,J.jsxs)(`div`,{className:`auth-root-item`,role:`listitem`,title:e.path,children:[(0,J.jsx)(`strong`,{children:e.label}),(0,J.jsx)(`span`,{children:e.path})]},e.path)):(0,J.jsx)(`p`,{className:`auth-root-empty`,children:r(`authAllowedRootsEmpty`)})})]}),D===`sign-in`?(0,J.jsxs)(`form`,{className:`auth-form`,onSubmit:ee,children:[(0,J.jsxs)(`label`,{className:`auth-field`,children:[(0,J.jsxs)(`div`,{className:`auth-field-row`,children:[(0,J.jsx)(`span`,{children:r(`authPasswordLabel`)}),(0,J.jsx)(`button`,{type:`button`,className:`auth-visibility-toggle`,onClick:()=>m(e=>!e),disabled:ae,"aria-label":r(f?`authHidePassword`:`authShowPassword`),"aria-pressed":f,children:r(f?`authHidePassword`:`authShowPassword`)})]}),(0,J.jsx)(`div`,{className:`auth-input-shell`,children:(0,J.jsx)(`input`,{autoFocus:!0,autoComplete:`current-password`,className:`auth-input`,type:f?`text`:`password`,value:u,onChange:e=>d(e.target.value),placeholder:r(`authPasswordPlaceholder`),disabled:ae,"aria-invalid":y===`invalid_credentials`})})]}),(0,J.jsx)(`div`,{className:`auth-message-slot ${re?`has-message`:``}`,"aria-live":`polite`,children:re?(0,J.jsx)(`div`,{className:`auth-message error`,role:`alert`,children:re}):null}),(0,J.jsxs)(`div`,{className:`auth-form-footer`,children:[(0,J.jsx)(`p`,{className:`auth-support-copy`,children:ie}),(0,J.jsx)(`button`,{className:`btn primary btn-lg auth-submit`,type:`submit`,disabled:h||!u.trim(),children:r(h?`authLoggingIn`:`authLogin`)})]})]}):(0,J.jsx)(`div`,{className:`auth-form-footer auth-form-footer-static`,children:(0,J.jsx)(`p`,{className:`auth-support-copy`,children:ie})})]})})})]})}var jr=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Mr=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Nr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Pr=e=>{let t=Nr(e);return t.charAt(0).toUpperCase()+t.slice(1)},Fr={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ir=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Lr=(0,p.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,p.createElement)(`svg`,{ref:c,...Fr,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:jr(`lucide`,i),...!a&&!Ir(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,p.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Y=(e,t)=>{let n=(0,p.forwardRef)(({className:n,...r},i)=>(0,p.createElement)(Lr,{ref:i,iconNode:t,className:jr(`lucide-${Mr(Pr(e))}`,`lucide-${e}`,n),...r}));return n.displayName=Pr(e),n},Rr=Y(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),zr=Y(`arrow-down-up`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]),Br=Y(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Vr=Y(`blocks`,[[`path`,{d:`M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2`,key:`1ah6g2`}],[`rect`,{x:`14`,y:`2`,width:`8`,height:`8`,rx:`1`,key:`88lufb`}]]),Hr=Y(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ur=Y(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Wr=Y(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Gr=Y(`code-xml`,[[`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`}]]),Kr=Y(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),qr=Y(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Jr=Y(`folder-open`,[[`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`}]]),Yr=Y(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Xr=Y(`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`}]]),Zr=Y(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Qr=Y(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),$r=Y(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),ei=Y(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),ti=Y(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ni=Y(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ri=Y(`moon-star`,[[`path`,{d:`M18 5h4`,key:`1lhgn2`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ii=Y(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`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:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),ai=Y(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),oi=Y(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),si=Y(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ci=Y(`refresh-cw`,[[`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`}]]),li=Y(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),ui=Y(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),di=Y(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),fi=Y(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),pi=Y(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mi=Y(`square-split-horizontal`,[[`path`,{d:`M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3`,key:`lubmu8`}],[`path`,{d:`M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3`,key:`1ag34g`}],[`line`,{x1:`12`,x2:`12`,y1:`4`,y2:`20`,key:`1tx1rr`}]]),hi=Y(`square-split-vertical`,[[`path`,{d:`M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3`,key:`1pi83i`}],[`path`,{d:`M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3`,key:`ido5k7`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),gi=Y(`sun-medium`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 3v1`,key:`1asbbs`}],[`path`,{d:`M12 20v1`,key:`1wcdkc`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M20 12h1`,key:`1vloll`}],[`path`,{d:`m18.364 5.636-.707.707`,key:`1hakh0`}],[`path`,{d:`m6.343 17.657-.707.707`,key:`18m9nf`}],[`path`,{d:`m5.636 5.636.707.707`,key:`1xv1c5`}],[`path`,{d:`m17.657 17.657.707.707`,key:`vl76zb`}]]),_i=Y(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),vi=Y(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),yi=Y(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),X=(e,t)=>{let n=n=>(0,J.jsx)(e,{"aria-hidden":`true`,size:16,strokeWidth:1.5,...t,...n});return n.displayName=`Icon(${e.displayName??e.name??`Lucide`})`,n};X(li),X(Jr),X(Zr);var bi=X(Xr),xi=X(Zr);X(Zr);var Si=X(Kr),Ci=X(Gr),wi=X(_i),Ti=X(Br);X(si),X(ri),X(gi),X(pi),X(zr),X(Yr);var Ei=X(si),Di=X(yi),Oi=X(di),ki=X(Ur),Ai=X(fi);X(Qr);var ji=X(ii);X(Vr),X(Zr),X(ni),X(Xr),X(Rr);var Mi=X(si),Ni=X(ti),Pi=X(vi),Fi=X(ci);X(Yr);var Ii=X(ui,{size:14}),Li=X(Wr,{size:12}),Ri=X(Hr,{size:12}),zi=X($r,{size:14}),Bi=X(ei,{size:14});X(ai,{size:14}),X(oi,{size:14});var Vi=X(hi,{size:13}),Hi=X(mi,{size:13}),Ui=X(Xr,{size:14}),Wi=X(Jr,{size:14});X(qr,{size:14});var Gi={ts:`#3178c6`,tsx:`#3178c6`,js:`#f7df1e`,jsx:`#f7df1e`,json:`#cbcb41`,md:`#519aba`,html:`#e34c26`,css:`#563d7c`,scss:`#563d7c`,py:`#3572A5`,go:`#00ADD8`,rs:`#dea584`,java:`#b07219`,sql:`#e38c00`,sh:`#89e051`,yml:`#cb171e`,yaml:`#cb171e`,toml:`#9c4121`,svg:`#a0c4e3`,png:`#a0c4e3`,jpg:`#a0c4e3`,pdf:`#b30b00`},Ki=(e,t,n)=>t?n?(0,J.jsx)(Wi,{}):(0,J.jsx)(Ui,{}):(0,J.jsx)(qr,{style:{color:Gi[e.split(`.`).pop()?.toLowerCase()||``]||`#808080`,width:14,height:14,flexShrink:0}}),qi=e=>[{id:`general`,label:e(`settingsGeneral`),icon:(0,J.jsx)(Ai,{})},{id:`appearance`,label:e(`settingsAppearance`),icon:(0,J.jsx)(ji,{})}],Ji=({locale:e,activeSettingsPanel:t,settingsDraft:n,launchCommandStatus:r,onSettingsPanelChange:i,onSettingsChange:a,onSettingsIdlePolicyChange:o,onSelectLocale:s,t:c})=>(0,J.jsx)(`main`,{className:`settings-route`,"data-testid":`settings-page`,children:(0,J.jsxs)(`section`,{className:`settings-layout`,children:[(0,J.jsx)(`aside`,{className:`settings-sidebar-v2`,children:(0,J.jsx)(`nav`,{className:`settings-nav-list`,"aria-label":c(`settings`),children:qi(c).map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`settings-nav-item ${e.id===t?`active`:``}`,onClick:()=>i(e.id),children:[(0,J.jsx)(`span`,{className:`settings-nav-icon`,children:e.icon}),(0,J.jsx)(`span`,{children:e.label})]},e.id))})}),(0,J.jsxs)(`section`,{className:`settings-content-v2`,children:[(0,J.jsx)(`div`,{className:`settings-scroll-panel`,children:t===`general`?(0,J.jsxs)(`div`,{className:`settings-group-card`,children:[(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`launchCommand`)}),(0,J.jsx)(`span`,{children:c(`launchCommandHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`div`,{className:`settings-command-field`,children:[(0,J.jsx)(`input`,{className:`settings-inline-input`,value:n.agentCommand,onChange:e=>a({agentCommand:e.target.value}),placeholder:c(`launchCommandPlaceholder`),"data-testid":`settings-agent-command`}),(0,J.jsxs)(`div`,{className:`settings-inline-status ${r.stateClass}`,"data-testid":`settings-agent-command-status`,children:[(0,J.jsx)(`span`,{className:`settings-inline-status-dot`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`settings-inline-status-copy`,children:[(0,J.jsx)(`span`,{children:r.text}),r.detailText&&(0,J.jsx)(`small`,{children:r.detailText})]})]})]})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`autoSuspend`)}),(0,J.jsx)(`span`,{children:c(`autoSuspendHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`label`,{className:`toggle`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:n.idlePolicy.enabled,onChange:()=>o({enabled:!n.idlePolicy.enabled})}),(0,J.jsx)(`span`,{className:`toggle-track`,children:(0,J.jsx)(`span`,{className:`toggle-thumb`})})]})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`idleAfter`)}),(0,J.jsx)(`span`,{children:c(`idleAfterHint`)})]}),(0,J.jsxs)(`div`,{className:`settings-row-control settings-number-control`,children:[(0,J.jsx)(`input`,{className:`settings-inline-number`,type:`number`,min:1,value:n.idlePolicy.idleMinutes,onChange:e=>o({idleMinutes:Number(e.target.value)}),"data-testid":`settings-idle-minutes`}),(0,J.jsx)(`span`,{children:c(`minutesShort`)})]})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`maxActive`)}),(0,J.jsx)(`span`,{children:c(`maxActiveHint`)})]}),(0,J.jsxs)(`div`,{className:`settings-row-control settings-number-control`,children:[(0,J.jsx)(`input`,{className:`settings-inline-number`,type:`number`,min:1,value:n.idlePolicy.maxActive,onChange:e=>o({maxActive:Number(e.target.value)}),"data-testid":`settings-max-active`}),(0,J.jsx)(`span`,{children:c(`sessionsWord`)})]})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`memoryPressure`)}),(0,J.jsx)(`span`,{children:c(`memoryPressureHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`label`,{className:`toggle`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:n.idlePolicy.pressure,onChange:()=>o({pressure:!n.idlePolicy.pressure})}),(0,J.jsx)(`span`,{className:`toggle-track`,children:(0,J.jsx)(`span`,{className:`toggle-thumb`})})]})})]})]}):(0,J.jsxs)(`div`,{className:`settings-group-card`,children:[(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`theme`)}),(0,J.jsx)(`span`,{children:e===`zh`?`当前版本仅保留深色主题。`:`This version uses a dark-only theme.`})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsx)(`div`,{className:`settings-pill-select single`,children:(0,J.jsx)(`span`,{className:`settings-pill-option active`,children:c(`themeDark`)})})})]}),(0,J.jsxs)(`div`,{className:`settings-row`,children:[(0,J.jsxs)(`div`,{className:`settings-row-copy`,children:[(0,J.jsx)(`strong`,{children:c(`languageLabel`)}),(0,J.jsx)(`span`,{children:c(`languageHint`)})]}),(0,J.jsx)(`div`,{className:`settings-row-control`,children:(0,J.jsxs)(`div`,{className:`settings-pill-select`,children:[(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`zh`?`active`:``}`,onClick:()=>s(`zh`),children:`中文`}),(0,J.jsx)(`button`,{type:`button`,className:`settings-pill-option ${e===`en`?`active`:``}`,onClick:()=>s(`en`),children:`English`})]})})]})]})}),(0,J.jsx)(`div`,{className:`settings-footer-bar`,children:(0,J.jsx)(`div`,{className:`settings-page-status`,children:c(`settingsAutoSave`)})})]})]})}),Yi=({isSettingsRoute:e,locale:t,workspaceTabs:n,onSwitchWorkspace:r,onAddTab:i,onRemoveTab:a,onOpenSettings:o,onCloseSettings:s,onOpenCommandPalette:c,t:l})=>(0,J.jsxs)(`header`,{className:`topbar ${e?`topbar-settings`:``}`,children:[(0,J.jsx)(`div`,{className:`topbar-tabs-wrap`,children:e?(0,J.jsxs)(`div`,{className:`route-topbar`,"data-testid":`settings-topbar`,children:[(0,J.jsxs)(`button`,{className:`route-topbar-back`,type:`button`,onClick:s,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(`span`,{children:l(`backToApp`)})]}),(0,J.jsx)(`div`,{className:`route-topbar-title`,children:l(`settings`)})]}):(0,J.jsxs)(`div`,{className:`topbar-session-strip topbar-workspace-strip`,"data-testid":`workspace-topbar`,children:[n.map(e=>(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,className:`session-top-tab workspace-top-tab ${e.active?`active`:``} ${e.hasRunning?`running-glow`:``}`,onClick:()=>r(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.id))},title:e.label,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${e.hasRunning?`active pulse`:`idle`}`}),(0,J.jsx)(`span`,{className:`session-top-label`,children:e.label}),!e.active&&e.unread>0&&(0,J.jsx)(`span`,{className:`session-top-unread`,title:`${e.unread}`,"aria-label":`${e.unread}`,children:e.unread>9?`9+`:e.unread}),(0,J.jsx)(`button`,{type:`button`,className:`session-top-close`,title:l(`close`),"aria-label":l(`close`),onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,J.jsx)(Di,{})})]},e.id)),(0,J.jsx)(`button`,{type:`button`,className:`session-top-add`,onClick:i,title:t===`zh`?`新建工作区`:`Add workspace`,"aria-label":t===`zh`?`新建工作区`:`Add workspace`,children:(0,J.jsx)(Ei,{})})]})}),(0,J.jsx)(`div`,{className:`topbar-actions`,children:!e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`topbar-tool topbar-tool-wide`,onClick:c,title:t===`zh`?`快速操作(⌘/Ctrl+K)`:`Quick actions (⌘/Ctrl+K)`,"aria-label":t===`zh`?`快速操作`:`Quick actions`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`span`,{children:t===`zh`?`操作`:`Actions`})]}),(0,J.jsx)(`button`,{className:`topbar-tool`,type:`button`,onClick:o,"data-testid":`settings-open`,title:l(`settings`),"aria-label":l(`settings`),children:(0,J.jsx)(Oi,{})})]})})]}),Z=async(e,t={})=>{let n=[],r=[Kn()];for(let i of r)try{let n=Un(new URL(`/api/rpc/${e}`,`${i}/`)).toString(),r=await fetch(n,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),a={};try{a=await r.json()}catch{}if(!r.ok||a.ok===!1){let e=a.error||`HTTP ${r.status}`;throw(r.status===401||e===`session_missing`||e===`session_expired`)&&vr(e),Error(e)}return a.data}catch(e){let t=e instanceof Error?e.message:String(e);n.push(`${i||`unknown_base`}: ${t}`)}throw Error(n.join(` | `))},Xi=async(e,t)=>{try{return await e()}catch{return t}},Zi=(e,t)=>Z(`filesystem_list`,{target:e,path:t}),Qi=(e,t,n)=>Z(`command_exists`,{command:e,target:t,cwd:n}),$i=`coder-studio.app-settings`,ea=()=>({agentProvider:`claude`,agentCommand:`claude`,idlePolicy:{enabled:!0,idleMinutes:10,maxActive:3,pressure:!0}}),ta=e=>({agentProvider:e.agentProvider,agentCommand:e.agentCommand,idlePolicy:{...e.idlePolicy}}),na=()=>{let e=ea();if(typeof window>`u`)return e;try{let t=window.localStorage.getItem($i);if(!t)return e;let n=JSON.parse(t);return{agentProvider:`claude`,agentCommand:typeof n.agentCommand==`string`&&n.agentCommand.trim()?n.agentCommand:e.agentCommand,idlePolicy:{enabled:n.idlePolicy?.enabled??e.idlePolicy.enabled,idleMinutes:Number.isFinite(n.idlePolicy?.idleMinutes)?Math.max(1,Number(n.idlePolicy?.idleMinutes)):e.idlePolicy.idleMinutes,maxActive:Number.isFinite(n.idlePolicy?.maxActive)?Math.max(1,Number(n.idlePolicy?.maxActive)):e.idlePolicy.maxActive,pressure:n.idlePolicy?.pressure??e.idlePolicy.pressure}}}catch{return e}},ra=e=>{typeof window>`u`||window.localStorage.setItem($i,JSON.stringify(e))},ia=e=>Number.isFinite(e)?Math.max(0,Number(e)):320,aa=e=>Number.isFinite(e)?Math.max(0,Number(e)):320,oa=e=>Number.isFinite(e)?Math.min(100,Math.max(0,Number(e))):64,sa=()=>{let e=new Date;return`${`${e.getHours()}`.padStart(2,`0`)}:${`${e.getMinutes()}`.padStart(2,`0`)}`},Q=(e=`id`)=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,ca=()=>({path:``,content:``,mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1}),la=e=>({type:`leaf`,id:Q(`pane`),sessionId:e}),ua=e=>la(e),da=(e,t=`branch`,n=wn())=>({id:Q(`session`),title:kn(e,n),status:`idle`,mode:t,autoFeed:!0,isDraft:!1,queue:[],messages:[{id:Q(`msg`),role:`system`,content:Mn(e,n),time:sa()}],stream:``,unread:0,lastActiveAt:Date.now()}),fa=(e,t=wn())=>{let n=da(1,`branch`,t),r=ua(n.id);return{id:Q(`tab`),title:An(e,t),status:`init`,agent:{provider:`claude`,command:`claude`,useWsl:!1},git:{branch:`—`,changes:0,lastCommit:`—`},gitChanges:[],worktrees:[],sessions:[n],activeSessionId:n.id,archive:[],terminals:[],activeTerminalId:``,fileTree:[],changesTree:[],filePreview:ca(),paneLayout:r,activePaneId:r.id,idlePolicy:{enabled:!0,idleMinutes:10,maxActive:3,pressure:!0}}},pa=()=>({tabs:[],activeTabId:``,layout:{leftWidth:320,rightWidth:320,rightSplit:64,showCodePanel:!1,showTerminalPanel:!1},overlay:{visible:!0,mode:`local`,input:``,target:{type:`native`}}}),ma=e=>e?e.type===`leaf`?[e.id]:[...ma(e.first),...ma(e.second)]:[],ha=e=>e?e.type===`leaf`?[e.sessionId]:[...ha(e.first),...ha(e.second)]:[],ga=(e,t)=>{if(e)return e.type===`leaf`?e.sessionId===t?e.id:void 0:ga(e.first,t)??ga(e.second,t)},_a=(e,t)=>e?e.type===`leaf`?{type:`leaf`,id:e.id||Q(`pane`),sessionId:e.sessionId||t}:{type:`split`,id:e.id||Q(`pane`),axis:e.axis===`vertical`?`vertical`:`horizontal`,ratio:Number.isFinite(e.ratio)?Math.min(1,Math.max(0,e.ratio)):.5,first:_a(e.first,t),second:_a(e.second,t)}:ua(t),va=(e,t,n)=>{if(!e)return null;if(e.type===`leaf`)return!t.has(e.sessionId)||n.has(e.sessionId)?null:(n.add(e.sessionId),{type:`leaf`,id:e.id||Q(`pane`),sessionId:e.sessionId});let r=va(e.first,t,n),i=va(e.second,t,n);return!r&&!i?null:r?i?{type:`split`,id:e.id||Q(`split`),axis:e.axis===`vertical`?`vertical`:`horizontal`,ratio:Number.isFinite(e.ratio)?Math.min(1,Math.max(0,e.ratio)):.5,first:r,second:i}:r:i},ya=(e,t)=>{let n=(e.sessions??[]).filter(Boolean),r=n.filter(e=>!e.isDraft),i=r.length?r:n,a=i.length?i:[da(1,`branch`,t)],o=a.some(t=>t.id===e.activeSessionId)?e.activeSessionId:a[0].id,s=new Set(a.map(e=>e.id)),c=va(_a(e.paneLayout,o),s,new Set)??ua(o),l=new Set(ha(c)),u=a.map(e=>e.id).filter(e=>!l.has(e)).reduce((e,t)=>({type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:e,second:la(t)}),c),d=ma(u),f=ga(u,o)??(d.includes(e.activePaneId)?e.activePaneId:d[0]);return{...e,gitChanges:e.gitChanges??[],sessions:a,activeSessionId:o,paneLayout:u,activePaneId:f}},ba=e=>{let t=pa();if(!e?.tabs?.length)return t;let n=wn(),r=e.tabs.filter(Boolean).map(e=>ya(e,n));if(!r.length)return t;let i=r.some(t=>t.id===e.activeTabId)?e.activeTabId??r[0].id:r[0].id,a=r.some(e=>e.status===`ready`||(e.sessions?.length??0)>1||!!e.sessions?.[0]?.stream||(e.archive?.length??0)>0),o=e.layout;return{tabs:r,activeTabId:i,layout:{leftWidth:ia(o?.leftWidth??t.layout.leftWidth),rightWidth:aa(o?.rightWidth??t.layout.rightWidth),rightSplit:oa(o?.rightSplit??o?.rightTopHeight??t.layout.rightSplit),showCodePanel:o?.showCodePanel??(typeof o?.rightCollapsed==`boolean`?!o.rightCollapsed:t.layout.showCodePanel),showTerminalPanel:o?.showTerminalPanel??t.layout.showTerminalPanel},overlay:{visible:a?!1:e.overlay?.visible??t.overlay.visible,mode:e.overlay?.mode??t.overlay.mode,input:e.overlay?.input??t.overlay.input,target:e.overlay?.target??t.overlay.target}}},xa=o({...pa()}),Sa=(e,t)=>{let n=e.trim().toLowerCase(),r=t.toLowerCase();if(!n)return 0;if(r===n)return 1e3;if(r.includes(n))return 700-Math.max(0,r.indexOf(n));let i=0,a=0;for(let e of n){let t=r.indexOf(e,a);if(t===-1)return-1;i+=t===a?10:Math.max(2,8-(t-a)),a=t+1}return i},Ca=e=>{switch(e.split(`.`).pop()?.toLowerCase()??``){case`ts`:case`tsx`:return`typescript`;case`js`:case`jsx`:case`mjs`:case`cjs`:return`javascript`;case`json`:return`json`;case`md`:return`markdown`;case`css`:case`scss`:return`css`;case`html`:case`htm`:return`html`;default:return`plaintext`}},wa=(e=[])=>{let t=[];return e.forEach(e=>{e.kind===`file`&&t.push(e),e.children?.length&&t.push(...wa(e.children))}),t},Ta=(e,t)=>{let n=new Intl.Collator(t===`zh`?`zh-CN`:`en`,{numeric:!0,sensitivity:`base`});return[...e].sort((e,t)=>e.kind===t.kind?n.compare(e.name,t.name):e.kind===`dir`?-1:1).map(e=>({...e,children:e.children?.length?Ta(e.children,t):e.children}))},Ea=()=>({query:``,open:!1,activeIndex:0,dropdownStyle:null}),Da=e=>e.trim().toLowerCase(),Oa=(e,t,n)=>{let r=Da(n);return r?wa(e).filter(e=>e.kind===`file`).map(e=>({node:{...e,absolutePath:xr(t,e.path)},score:Sa(r,`${e.name} ${e.path}`)})).filter(e=>e.score>=0).sort((e,t)=>t.score-e.score||e.node.path.localeCompare(t.node.path)).slice(0,24):[]},ka=e=>e.open&&Da(e.query).length>0,Aa=(e,t)=>{if(!Da(e.query))return!e.open&&e.activeIndex===0&&e.dropdownStyle===null?e:{...e,open:!1,activeIndex:0,dropdownStyle:null};let n=Math.min(e.activeIndex,Math.max(t-1,0));return n===e.activeIndex?e:{...e,activeIndex:n}},ja=(e,t)=>({...e,query:t,open:!!Da(t),activeIndex:0}),Ma=(e,t=e.query)=>({...e,open:!!Da(t)}),Na=e=>e.open?{...e,open:!1}:e,Pa=e=>!e.query&&!e.open&&e.activeIndex===0?e:{...e,query:``,open:!1,activeIndex:0},Fa=(e,t,n)=>({...e,open:!0,activeIndex:n===0?0:t>0?Math.min(e.activeIndex+1,n-1):Math.max(e.activeIndex-1,0)}),Ia=(e,t)=>e.activeIndex===t?e:{...e,activeIndex:t},La=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ra=(e,t)=>La(e.dropdownStyle,t)?e:{...e,dropdownStyle:t},za=(e,t,n)=>{let r=Math.min(Math.max(e.width,320),Math.max(320,t-24)),i=Math.min(Math.max(12,e.left),Math.max(12,t-r-12)),a=Math.max(0,n-e.bottom-12),o=Math.max(0,e.top-12),s=a<180&&o>a+40,c=s?`above`:`below`;return{left:i,width:r,maxHeight:Math.max(120,Math.min(420,s?o:a)),placement:c,top:s?void 0:e.bottom+8,bottom:s?Math.max(12,n-e.top+8):void 0}},Ba=(e,t)=>({...e,overlay:{...e.overlay,input:t}}),Va=(e,t)=>({...e,overlay:{...e.overlay,target:t}}),Ha=async({target:e,path:t,selectCurrent:n=!1,locale:r,t:i,setFolderBrowser:a,setOverlayCanUseWsl:o,updateOverlayInput:s})=>{a(e=>({...e,loading:!0,error:void 0,notice:void 0}));try{let r=await Zi(e,t),c=!!(t&&r.fallback_reason);e.type===`native`&&o(r.roots.some(e=>Tr(e.path))),a({loading:!1,currentPath:r.current_path,homePath:r.home_path,parentPath:r.parent_path??void 0,roots:r.roots,entries:r.entries,notice:c?i(`folderBrowserRecovered`):void 0}),(n||c)&&s(r.current_path)}catch(e){let t=e instanceof Error?e.message:String(e);a(e=>({...e,loading:!1,currentPath:``,parentPath:void 0,entries:[],error:r===`zh`?`无法读取服务器目录${t?`:${t}`:``}`:`Unable to read server directories${t?`: ${t}`:``}`}))}},Ua=e=>Z(`file_preview`,{path:e}),Wa=(e,t)=>Z(`file_save`,{path:e,content:t}),Ga=(e,t)=>Z(`git_changes`,{path:e,target:t}),Ka=(e,t)=>Z(`git_diff`,{path:e,target:t}),qa=(e,t,n,r)=>Z(`git_diff_file`,{path:e,target:t,filePath:n,staged:r}),Ja=(e,t,n,r)=>Z(`git_file_diff_payload`,{path:e,target:t,filePath:n,section:r}),Ya=(e,t,n)=>Z(`git_stage_file`,{path:e,target:t,filePath:n}),Xa=(e,t,n)=>Z(`git_unstage_file`,{path:e,target:t,filePath:n}),Za=(e,t,n,r)=>Z(`git_discard_file`,{path:e,target:t,filePath:n,section:r}),Qa=(e,t)=>Z(`git_stage_all`,{path:e,target:t}),$a=(e,t)=>Z(`git_unstage_all`,{path:e,target:t}),eo=(e,t)=>Z(`git_discard_all`,{path:e,target:t}),to=(e,t,n)=>Z(`git_commit`,{path:e,target:t,message:n}),no=e=>{let t=0,n=0,r=0,i=[];return e.split(`
4
- `).forEach(e=>{if(e.startsWith(`diff --git`)){t+=1;let n=e.split(` `)[2]?.replace(`a/`,``)??`file`;i.push(n);return}e.startsWith(`+++ `)||e.startsWith(`--- `)||(e.startsWith(`+`)&&(n+=1),e.startsWith(`-`)&&(r+=1))}),{files:t,additions:n,deletions:r,diffFiles:i}},ro=async({tab:e,node:t,updateTab:n,withServiceFallback:r,t:i})=>{let a=xr(e.project?.path,t.path),o=await r(()=>Ua(a),{path:t.path,content:i(`previewUnavailable`),mode:`preview`});n(e.id,e=>({...e,filePreview:{...e.filePreview,path:o.path||t.path,content:o.content||i(`previewUnavailable`),mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1,source:`tree`,statusLabel:t.status,parentPath:Er(o.path||t.path),section:void 0,diff:void 0}}))},io=async({tab:e,path:t,updateTab:n,withServiceFallback:r,t:i,options:a})=>{let o=await r(()=>Ua(t),{path:t,content:i(`previewUnavailable`),mode:`preview`});n(e.id,e=>({...e,filePreview:{...e.filePreview,path:o.path||t,content:o.content||i(`previewUnavailable`),mode:`preview`,originalContent:``,modifiedContent:``,dirty:!1,source:`tree`,statusLabel:a?.statusLabel??e.filePreview.statusLabel,parentPath:a?.parentPath??Er(o.path||t),section:void 0,diff:void 0}}))},ao=async({tab:e,updateTab:t,withServiceFallback:n})=>{let r=e.project?.target??{type:`native`},i=e.project?.path??``,a=await n(()=>Ka(i,r),``),o=no(a);t(e.id,e=>({...e,filePreview:{...e.filePreview,mode:`diff`,diff:a,originalContent:``,modifiedContent:``,diffStats:{files:o.files,additions:o.additions,deletions:o.deletions},diffFiles:o.diffFiles,dirty:e.filePreview.dirty}}))},oo=async({tab:e,activeSessionId:t,updateTab:n,withServiceFallback:r,refreshWorkspaceArtifacts:i,addToast:a,t:o,createToastId:s})=>{let c=e.filePreview;if(!c.path||!c.dirty)return!1;let l=await r(()=>Wa(c.path,c.content),null);return l?(n(e.id,e=>({...e,filePreview:{...e.filePreview,path:l.path,content:l.content,dirty:!1}})),await i(e.id),a({id:s(),text:`${o(`saved`)}: ${l.path}`,sessionId:t}),!0):!1},so=e=>Z(`launch_workspace`,{source:e}),co=()=>Z(`workbench_bootstrap`,{}),lo=e=>Z(`workspace_snapshot`,{workspaceId:e}),uo=e=>Z(`activate_workspace`,{workspaceId:e}),fo=e=>Z(`close_workspace`,{workspaceId:e}),po=e=>Z(`update_workbench_layout`,{layout:e}),mo=(e,t)=>Z(`workspace_view_update`,{workspaceId:e,patch:t}),ho=(e,t,n=4)=>Z(`workspace_tree`,{path:e,target:t,depth:n}),go=(e,t)=>Z(`worktree_list`,{path:e,target:t}),_o=(e,t)=>Z(`git_status`,{path:e,target:t}),vo=async({tab:e,change:t,updateTab:n,withServiceFallback:r})=>{let i=Cr(t.path),a=xr(e.project?.path,i),o=await r(()=>Ja(e.project?.path??``,e.project?.target??{type:`native`},i,t.section),{original_content:``,modified_content:``,diff:``});if(!o.original_content&&!o.modified_content&&!o.diff){let n=await r(()=>qa(e.project?.path??``,e.project?.target??{type:`native`},i,t.section===`staged`),``);o={original_content:``,modified_content:(await r(()=>Ua(a),null))?.content??``,diff:n}}let s=no(o.diff);return n(e.id,e=>({...e,filePreview:{...e.filePreview,path:a,content:o.modified_content,mode:`diff`,diff:o.diff,originalContent:o.original_content,modifiedContent:o.modified_content,diffStats:{files:s.files,additions:s.additions,deletions:s.deletions},diffFiles:[t.path],dirty:!1,source:`git`,statusLabel:t.status,parentPath:t.parent,section:t.section}})),`${t.section}:${t.path}:${t.code}`},yo=async({tab:e,activeSessionId:t,selectedGitChangeKey:n,previewMode:r,updateTab:i,refreshWorkspaceArtifacts:a,onSelectGitChange:o,onReloadRepositoryDiff:s,onClearPreviewSelection:c,addToast:l,t:u,createToastId:d,getCurrentTab:f,operation:p})=>{if(!e.project?.path)return l({id:d(),text:u(`selectProjectFirst`),sessionId:t}),!1;try{await p(),await a(e.id);let t=f(e.id),l=t?.gitChanges.find(e=>`${e.section}:${e.path}:${e.code}`===n)??t?.gitChanges.find(n=>wr(t?.filePreview.path||e.filePreview.path,n.path));return l?await o(l):r===`diff`?await s():n&&(c(),i(e.id,e=>({...e,filePreview:ca()}))),!0}catch(e){return l({id:d(),text:`${u(`gitActionFailed`)}: ${String(e)}`,sessionId:t}),!1}},bo=(e,t)=>[{key:`changes`,label:t(`changes`),items:e.filter(e=>e.section===`changes`)},{key:`staged`,label:t(`stagedChanges`),items:e.filter(e=>e.section===`staged`)},{key:`untracked`,label:t(`untrackedFiles`),items:e.filter(e=>e.section===`untracked`)}].filter(e=>e.items.length>0),xo=(e,t)=>t.find(t=>wr(e,t.path)),So=(e,t,n)=>{if(!e)return``;if(!t)return e;let r=Sr(t);return Sr(e).startsWith(r)&&(e.slice(t.length).replace(/^[/\\]+/,``)||n)||e},Co=e=>e.type===`leaf`?[{id:e.id,sessionId:e.sessionId}]:[...Co(e.first),...Co(e.second)],wo=(e,t)=>e.type===`leaf`?e.id===t?e.sessionId:null:wo(e.first,t)??wo(e.second,t),To=(e,t)=>e.type===`leaf`?e.sessionId===t?e.id:null:To(e.first,t)??To(e.second,t),Eo=(e,t,n)=>e.type===`leaf`?e.id===t?n(e):e:{...e,first:Eo(e.first,t,n),second:Eo(e.second,t,n)},Do=(e,t)=>{if(e.type===`leaf`)return e.id===t?null:e;let n=Do(e.first,t),r=Do(e.second,t);return!n&&!r?null:n?r?{...e,first:n,second:r}:n:r},Oo=(e,t,n)=>e.type===`leaf`?e.sessionId===t?{...e,sessionId:n}:e:{...e,first:Oo(e.first,t,n),second:Oo(e.second,t,n)},ko=(e,t,n)=>e.type===`leaf`?e:e.id===t?{...e,ratio:n}:{...e,first:ko(e.first,t,n),second:ko(e.second,t,n)},Ao=()=>new Date().toLocaleTimeString().slice(0,5),jo=e=>{let t=Number(e);return Number.isFinite(t)?t:null},Mo=(e,t,n)=>({id:String(e.id),title:e.title||n?.title||kn(e.id,t),status:e.status,mode:e.mode,autoFeed:e.auto_feed,isDraft:!1,queue:e.queue.map(e=>({id:String(e.id),text:e.text,status:e.status})),messages:e.messages?.length?e.messages:n?.messages??[{id:Q(`msg`),role:`system`,content:Mn(e.id,t),time:Ao()}],stream:e.stream??n?.stream??``,unread:e.unread??n?.unread??0,lastActiveAt:e.last_active_at,claudeSessionId:e.claude_session_id??n?.claudeSessionId}),No=({locale:e,workspacePath:t,branch:n,mode:r=`branch`,existing:i})=>{let a=Dn(e),o=`${t}${n&&n!==`—`?` · ${n}`:``}`;return{id:i?.id??Q(`session`),title:i?.title??a(`draftSessionTitle`),status:i?.status??`idle`,mode:i?.mode??r,autoFeed:i?.autoFeed??!0,isDraft:!0,queue:i?.queue??[],messages:i?.messages?.length?i.messages:[{id:Q(`msg`),role:`system`,content:a(`draftSessionPrompt`),time:Ao()},{id:Q(`msg`),role:`system`,content:a(`draftSessionWorkspace`,{path:o}),time:Ao()}],stream:i?.stream??``,unread:i?.unread??0,lastActiveAt:i?.lastActiveAt??Date.now(),claudeSessionId:i?.claudeSessionId}},Po=e=>!!e?.isDraft,Fo=e=>!!(e&&!e.stream.trim()&&e.queue.length===0&&e.messages.every(e=>e.role===`system`)),Io=e=>{let t=e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e.trim();return t?t.length<=48?t:`${t.slice(0,45)}...`:``},Lo=e=>e===`running`||e===`waiting`,Ro=e=>Lo(e)?`background`:e,zo=e=>e.status===`background`?`waiting`:e.status,Bo=(e,t,n)=>n===`running`||n===`waiting`?e.activeSessionId===t.id?n:`background`:n,Vo=e=>e===`running`||e===`waiting`||e===`background`?`active`:e===`idle`?`idle`:e===`queued`?`queued`:`suspended`,Ho=e=>{if(!e.queue.length)return 0;let t=e.queue.filter(e=>e.status===`done`).length;return Math.round(t/e.queue.length*100)},Uo=(e,t)=>({...e,layout:{...e.layout,showCodePanel:t===`code`?!e.layout.showCodePanel:e.layout.showCodePanel,showTerminalPanel:t===`terminal`?!e.layout.showTerminalPanel:e.layout.showTerminalPanel}}),Wo=(e,t,n,r)=>{let i=Date.now();e(t,e=>({...e,activePaneId:n,activeSessionId:r,sessions:e.sessions.map(t=>t.id===r?{...t,unread:0,status:zo(t),lastActiveAt:i}:t.id===e.activeSessionId?{...t,status:Ro(t.status)}:t)}))},Go=({tab:e,paneId:t,axis:n,updateTab:r,createDraftSessionForTab:i,onFocusPane:a})=>{let o=null;r(e.id,e=>{let r=wo(e.paneLayout,t)?t:To(e.paneLayout,e.activeSessionId)??Co(e.paneLayout)[0]?.id;if(!r)return e;let a=i(e,`branch`),s=la(a.id);return o=s.id,{...e,sessions:[a,...e.sessions.filter(e=>e.id!==a.id)],activePaneId:s.id,activeSessionId:a.id,paneLayout:Eo(e.paneLayout,r,e=>({type:`split`,id:Q(`split`),axis:n,ratio:.5,first:e,second:s}))}}),o&&a(o)},Ko=({event:e,type:t,stateRef:n,updateState:r,shellTerminalRef:i,fitAgentTerminals:a})=>{e.preventDefault(),document.body.classList.add(`is-resizing-panels`),document.body.classList.add(t===`right-split`?`is-resizing-rows`:`is-resizing-columns`);let o=e.clientX,s=e.clientY,{rightWidth:c,rightSplit:l}=n.current.layout,u=t===`right-split`&&e.currentTarget instanceof HTMLElement?e.currentTarget.parentElement?.getBoundingClientRect().height??1:1,d=0,f=c,p=l,m=()=>{d=0,r(e=>({...e,layout:{...e.layout,rightWidth:t===`left`?f:e.layout.rightWidth,rightSplit:t===`right-split`?p:e.layout.rightSplit}}))},h=e=>{if(t===`left`&&(f=Math.max(0,Math.round(c-(e.clientX-o)))),t===`right-split`){let t=e.clientY-s;p=Math.max(0,Math.min(100,l+t/u*100))}d||=window.requestAnimationFrame(m)},g=()=>{document.body.classList.remove(`is-resizing-panels`),document.body.classList.remove(`is-resizing-columns`,`is-resizing-rows`),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),d&&(window.cancelAnimationFrame(d),m()),requestAnimationFrame(()=>{i.current?.fit(),a()})};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g)},qo=({event:e,tabId:t,paneLayout:n,splitId:r,axis:i,updateTab:a,fitAgentTerminals:o})=>{e.preventDefault(),document.body.classList.add(`is-resizing-panels`),document.body.classList.add(i===`horizontal`?`is-resizing-rows`:`is-resizing-columns`);let s=e.currentTarget.parentElement;if(!s)return;let c=s.getBoundingClientRect(),l=e.clientX,u=e.clientY,d=e=>e.type===`leaf`?null:e.id===r?e.ratio:d(e.first)??d(e.second),f=d(n)??.5,p=0,m=f,h=()=>{p=0,a(t,e=>({...e,paneLayout:ko(e.paneLayout,r,m)}))},g=e=>{let t=i===`vertical`?(e.clientX-l)/Math.max(c.width,1):(e.clientY-u)/Math.max(c.height,1);m=Math.max(0,Math.min(1,f+t)),p||=window.requestAnimationFrame(h)},_=()=>{document.body.classList.remove(`is-resizing-panels`),document.body.classList.remove(`is-resizing-columns`,`is-resizing-rows`),window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),p&&(window.cancelAnimationFrame(p),h()),o()};window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_)},Jo=e=>Array.from(new Set(e.filter(Boolean))),Yo=(e,t)=>{let n=e&&typeof e==`object`?e:{};return{...ca(),...t,...n,path:typeof n.path==`string`?n.path:t?.path??``,content:typeof n.content==`string`?n.content:t?.content??``,mode:n.mode===`diff`?`diff`:`preview`,diff:typeof n.diff==`string`?n.diff:t?.diff??``,originalContent:typeof n.originalContent==`string`?n.originalContent:t?.originalContent??``,modifiedContent:typeof n.modifiedContent==`string`?n.modifiedContent:t?.modifiedContent??``,dirty:n.dirty??t?.dirty??!1,source:n.source??t?.source,statusLabel:typeof n.statusLabel==`string`?n.statusLabel:t?.statusLabel,parentPath:typeof n.parentPath==`string`?n.parentPath:t?.parentPath,section:n.section??t?.section}},Xo=(e,t)=>({id:String(e.id),sessionId:String(e.session_id),time:e.time,mode:e.mode,snapshot:Mo(e.snapshot,t)}),Zo=(e,t,n)=>{if(!e.length){let e=n?.terminals??[];return{terminals:e,activeTerminalId:e.some(e=>e.id===n?.activeTerminalId)?n?.activeTerminalId??``:e[0]?.id??``}}let r=e.map((e,r)=>{let i=`term-${e.id}`,a=n?.terminals.find(e=>e.id===i);return{id:i,title:a?.title??jn(r+1,t),output:e.output??a?.output??``}});return{terminals:r,activeTerminalId:r.some(e=>e.id===n?.activeTerminalId)?n?.activeTerminalId??``:r[0]?.id??``}},Qo=e=>({leftWidth:e.left_width,rightWidth:e.right_width,rightSplit:e.right_split,showCodePanel:e.show_code_panel,showTerminalPanel:e.show_terminal_panel}),$o=e=>({left_width:e.leftWidth,right_width:e.rightWidth,right_split:e.rightSplit,show_code_panel:e.showCodePanel,show_terminal_panel:e.showTerminalPanel}),es=(e,t,n,r)=>{let i=e.sessions.map(e=>{let n=r?.sessions.find(t=>t.id===String(e.id));return Mo(e,t,n)}),a=r?.sessions.filter(e=>Po(e))??[],o=i.length>0?[...a,...i]:a.length>0?a:[No({locale:t,workspacePath:e.workspace.project_path,branch:r?.git.branch})],s=o[0]?.id??r?.activeSessionId??`1`,c=o.some(t=>t.id===e.view_state.active_session_id)?e.view_state.active_session_id:o.some(e=>e.id===r?.activeSessionId)?r?.activeSessionId??s:s,l=Zo(e.terminals,t,r),u={id:e.workspace.workspace_id,title:e.workspace.title,status:`ready`,project:{kind:e.workspace.source_kind,path:e.workspace.project_path,gitUrl:e.workspace.git_url??void 0,target:e.workspace.target},agent:{provider:n.agentProvider,command:n.agentCommand,useWsl:e.workspace.target.type===`wsl`,distro:e.workspace.target.type===`wsl`?e.workspace.target.distro:void 0},git:r?.git??{branch:`—`,changes:0,lastCommit:`—`},gitChanges:r?.gitChanges??[],worktrees:r?.worktrees??[],sessions:o,activeSessionId:c,archive:e.archive.map(e=>Xo(e,t)),terminals:l.terminals,activeTerminalId:l.activeTerminalId,fileTree:r?.fileTree??[],changesTree:r?.changesTree??[],filePreview:Yo(e.view_state.file_preview,r?.filePreview),paneLayout:e.view_state.pane_layout??la(c),activePaneId:e.view_state.active_pane_id||r?.activePaneId||``,idlePolicy:{enabled:e.workspace.idle_policy.enabled,idleMinutes:e.workspace.idle_policy.idle_minutes,maxActive:e.workspace.idle_policy.max_active,pressure:e.workspace.idle_policy.pressure},viewingArchiveId:void 0};return ba({tabs:[u],activeTabId:u.id,layout:pa().layout,overlay:{visible:!1,mode:`remote`,input:``,target:{type:`native`}}}).tabs[0]},ts=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return Jo(t).map(e=>n.get(e)).filter(e=>!!e)},ns=(e,t)=>t&&e.some(e=>e.id===t)?t:e[0]?.id??``,rs=(e,t,n,r)=>{let i=new Map(e.tabs.map(e=>[e.id,e])),a=new Map(t.workspaces.map(e=>[e.workspace.workspace_id,e])),o=Jo(t.ui_state.open_workspace_ids).map(e=>{let t=a.get(e);return t?es(t,n,r,i.get(e)):null}).filter(e=>!!e);return{tabs:o,activeTabId:ns(o,t.ui_state.active_workspace_id),layout:Qo(t.ui_state.layout),overlay:{...e.overlay,visible:o.length===0,input:o.length===0?e.overlay.input:``}}},is=(e,t,n,r,i)=>{let a=es(t,n,r,e.tabs.find(e=>e.id===t.workspace.workspace_id)),o=new Map(e.tabs.map(e=>[e.id,e]));o.set(a.id,a);let s=Jo(i?.open_workspace_ids??[...e.tabs.map(e=>e.id),a.id]);s.includes(a.id)||s.push(a.id);let c=ts(Array.from(o.values()),s);return{...e,tabs:c,activeTabId:ns(c,i?.active_workspace_id??a.id),layout:i?Qo(i.layout):e.layout,overlay:{...e.overlay,visible:!1,input:``}}},as=(e,t)=>{let n=ts(e.tabs,t.open_workspace_ids);return{...e,tabs:n,activeTabId:ns(n,t.active_workspace_id),layout:Qo(t.layout),overlay:{...e.overlay,visible:n.length===0}}},os=async({overlay:e,locale:t,appSettings:n,updateState:r,withServiceFallback:i,refreshWorkspaceArtifacts:a})=>{let o=e.input.trim();if(!o)return null;let s=await i(()=>so({kind:e.mode,pathOrUrl:o,target:e.target}),null);if(!s)return null;r(e=>is(e,s.snapshot,t,n,s.ui_state));let c=s.snapshot.workspace.workspace_id,l=await a(c),u=s.created&&!s.snapshot.view_state.file_preview.path?wa(l?.root.children??[]).find(e=>e.kind===`file`):void 0;return{workspaceId:c,created:s.created,alreadyOpen:s.already_open,firstFile:u}},ss=(e,t)=>Z(`create_session`,{workspaceId:e,mode:t}),cs=(e,t,n)=>Z(`session_update`,{workspaceId:e,sessionId:t,patch:n}),ls=(e,t)=>Z(`switch_session`,{workspaceId:e,sessionId:t}),us=(e,t)=>Z(`archive_session`,{workspaceId:e,sessionId:t}),ds=(e,t)=>Z(`update_idle_policy`,{workspaceId:e,policy:t}),fs=({appSettings:e,locale:t,t:n,stateRef:r,updateTab:i,withServiceFallback:a,addToast:o})=>{let s=e=>No({locale:t,workspacePath:e.project?.path??n(`noWorkspace`),branch:e.git.branch}).messages,c=(e,r=`branch`)=>No({locale:t,workspacePath:e.project?.path??n(`noWorkspace`),branch:e.git.branch,mode:r}),l=async(e,t,n)=>{let r=jo(t);r!==null&&await a(()=>cs(e,r,n),null)},u=(e,t)=>{let n=Date.now();i(e,e=>({...e,sessions:e.sessions.map(e=>e.id===t?{...e,lastActiveAt:n}:e)})),l(e,t,{last_active_at:n})},d=async(e,n,o)=>{let s=r.current.tabs.find(t=>t.id===e),c=s?.sessions.find(e=>e.id===n);if(!s||!c)return null;if(!Po(c))return{tab:s,session:c};let l=null,u=await a(()=>ss(e,c.mode),null);u&&(l=Mo(u,t));let d=null,f=null;return i(e,e=>{let r=e.sessions.find(e=>e.id===n);if(!r)return e;let i=l??da(e.sessions.length+1,r.mode,t),a=Io(o)||r.title||kn(i.id,t),s={...i,title:a,status:i.status===`queued`?`queued`:`idle`,mode:r.mode,autoFeed:r.autoFeed,isDraft:!1,queue:r.queue,messages:r.messages,stream:r.stream,unread:0,lastActiveAt:Date.now(),claudeSessionId:i.claudeSessionId},c=e.sessions.filter(e=>e.id!==n);return d={...e,sessions:[s,...c],activeSessionId:s.id,paneLayout:Eo(e.paneLayout,e.activePaneId,e=>({...e,sessionId:s.id})),viewingArchiveId:void 0},f=s,d}),!d||!f?null:{tab:d,session:f}},f=async n=>{let r=await a(()=>lo(n),null);r&&i(n,n=>es(r,t,e,n))},p=async()=>{let e=r.current.tabs.find(e=>e.id===r.current.activeTabId);if(!e)return;i(e.id,e=>{let t=c(e,`branch`),n=la(t.id),r=e.sessions.map(t=>t.id===e.activeSessionId?{...t,status:Ro(t.status)}:t);return{...e,sessions:[t,...r],activeSessionId:t.id,activePaneId:n.id,paneLayout:Eo(e.paneLayout,e.activePaneId,e=>({type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:e,second:n})),viewingArchiveId:void 0}});let t=e.sessions.find(t=>t.id===e.activeSessionId);t&&Lo(t.status)&&l(e.id,t.id,{status:`background`})},m=(e,t)=>{let n=Date.now(),r=e.activeSessionId,a=e.sessions.find(e=>e.id===r),o=e.sessions.find(e=>e.id===t),s=To(e.paneLayout,t);if(!s||!o)return;i(e.id,e=>({...e,activeSessionId:t,activePaneId:s,sessions:e.sessions.filter(e=>!(r!==t&&e.id===r&&Po(e))).map(r=>r.id===t?{...r,unread:0,status:zo(r),lastActiveAt:n}:r.id===e.activeSessionId?{...r,status:Ro(r.status)}:r),viewingArchiveId:void 0}));let c=jo(t);c!==null&&ls(e.id,c).catch(()=>{}),r!==t&&a&&Lo(a.status)&&l(e.id,r,{status:`background`});let u=zo(o);l(e.id,t,{status:u,last_active_at:n})},h=(e,t,n)=>{let r=e.sessions.find(e=>e.id===n);if(!r)return;let a=Date.now(),o=null;if(i(e.id,e=>{if(!e.sessions.some(e=>e.id===n))return e;let r=Co(e.paneLayout).length>1,i=e.sessions.filter(e=>e.id!==n),s=i.length>0,l=s?null:c(e,`branch`),u=s?i:[l],d=u[0]?.id??n,f=r?Do(e.paneLayout,t)??e.paneLayout:e.paneLayout;f=Oo(f,n,d);let p=Co(f),m=e.activePaneId===t?p[0]?.id??e.activePaneId:e.activePaneId,h=wo(f,m)??d;return o=h,{...e,sessions:u.map(e=>e.id===h?{...e,unread:0,status:zo(e),lastActiveAt:a}:e),paneLayout:f,activePaneId:m,activeSessionId:h,viewingArchiveId:void 0}}),o){let t=jo(o);t!==null&&ls(e.id,t).catch(()=>{})}if(!Po(r)){let t=jo(r.id);t!==null&&us(e.id,t).catch(()=>{})}},g=async(e,t)=>{let n=r.current.tabs.find(t=>t.id===e),o=n?.sessions.find(e=>e.id===t);if(!n||!o)return;let s=n.activeSessionId===t;if(Po(o)){let r=n.sessions.find(e=>e.id!==t),a=Date.now();if(i(e,e=>{let n=e.sessions.filter(e=>e.id!==t);n.length===0&&(n=[c(e,`branch`)]);let r=n[0]?.id??t;return{...e,sessions:n.map(e=>e.id===r&&e.status===`background`?{...e,status:zo(e),unread:0,lastActiveAt:Date.now()}:e),paneLayout:Oo(e.paneLayout,t,r),activeSessionId:r,viewingArchiveId:void 0}}),r){let t=zo(r);l(e,r.id,{status:t,last_active_at:a})}return}let u=jo(t),d=u===null?null:await a(()=>us(e,u),null),f=Date.now(),p=null,m=null;if(i(e,e=>{if(e.sessions.findIndex(e=>e.id===t)===-1)return e;let n={id:d?String(d.id):Q(`archive`),sessionId:o.id,time:d?.time??Ao(),mode:d?.mode??o.mode,snapshot:o},r=e.sessions.filter(e=>e.id!==t).map(e=>({...e,status:Ro(e.status)})),i=r;s?i=[c(e,`branch`),...r]:i.length===0&&(i=[c(e,`branch`)]);let a=i[0]?.id??t;return p=a,m=i[0]?zo(i[0]):null,{...e,sessions:i.map(e=>e.id===a&&e.status===`background`?{...e,status:zo(e),unread:0,lastActiveAt:f}:e.id===a&&s?{...e,unread:0,lastActiveAt:f}:e),archive:[n,...e.archive],paneLayout:Oo(e.paneLayout,t,a),activeSessionId:a,viewingArchiveId:void 0}}),s&&p){let t=jo(p);t!==null&&ls(e,t).catch(()=>{}),m&&l(e,p,{status:m,last_active_at:f})}},_=async(e,t,a)=>{let s=r.current.tabs.find(t=>t.id===e),c=s?.sessions.find(e=>e.id===t);if(!s||!c)return;i(e,e=>({...e,sessions:e.sessions.map(n=>{if(n.id!==t)return n;let r=n.id===e.activeSessionId?0:n.unread+1;return{...n,status:`idle`,unread:r,lastActiveAt:Date.now(),messages:a?[...n.messages,{id:Q(`msg`),role:`system`,content:a,time:Ao()}]:n.messages}})})),l(e,t,{status:`idle`,last_active_at:Date.now()});let u=r.current.tabs.find(t=>t.id===e),d=u?.sessions.find(e=>e.id===t);!u||!d||u.activeSessionId!==t&&c.status!==`idle`&&o({id:Q(`toast`),text:a??n(`taskCompletedToast`,{title:d.title}),sessionId:t})};return{buildDraftSessionMessages:s,createDraftSessionForTab:c,syncSessionPatch:l,touchSession:u,materializeSession:d,refreshTabFromBackend:f,onNewSession:p,onSwitchSession:m,onCloseAgentPane:h,archiveSessionForTab:g,markSessionIdle:_,settleSessionAfterExit:async(e,t)=>{let i=r.current.tabs.find(t=>t.id===e),a=i?.sessions.find(e=>e.id===t);!i||!a||a.status!==`idle`&&await _(e,t,n(`agentExited`))}}},ps=(e,t,n)=>Z(`terminal_create`,{workspaceId:e,cwd:t,target:n}),ms=(e,t,n)=>Z(`terminal_write`,{workspaceId:e,terminalId:t,input:n}),hs=(e,t,n,r)=>Z(`terminal_resize`,{workspaceId:e,terminalId:t,cols:n,rows:r}),gs=(e,t)=>Z(`terminal_close`,{workspaceId:e,terminalId:t}),_s=(e,t,n,r,i)=>{if(!t||!n)return;let a=Number(n.replace(`term-`,``));if(!Number.isFinite(a))return;let o=e.current;o.id===n&&o.cols===r&&o.rows===i||(e.current={id:n,cols:r,rows:i},hs(t,a,r,i).catch(()=>{}))},vs=(e,t,n)=>{if(!t)return;let r=Number(t.replace(`term-`,``));Number.isFinite(r)&&ms(e,r,n).catch(()=>{})},ys=async({tab:e,locale:t,updateTab:n,withServiceFallback:r,addToast:i,activeSessionId:a,createToastId:o,t:s})=>{let c=e.project;if(!c?.path)return i({id:o(),text:s(`selectProjectFirst`),sessionId:a}),!1;let l=await r(()=>ps(e.id,c.path,c.target),{id:Date.now(),output:``});return n(e.id,e=>{let n={id:`term-${l.id}`,title:jn(e.terminals.length+1,t),output:l.output??``};return{...e,terminals:[...e.terminals,n],activeTerminalId:n.id}}),!0},bs=(e,t,n)=>{e(t,e=>({...e,activeTerminalId:n}))},xs=async(e,t,n,r)=>{let i=Number(t.replace(`term-`,``));Number.isFinite(i)&&await r(()=>gs(e.id,i),null),n(e.id,e=>{let n=e.terminals.filter(e=>e.id!==t),r=e.activeTerminalId===t?n[0]?.id??``:e.activeTerminalId;return{...e,terminals:n,activeTerminalId:r}})},Ss=(e,t,n,r=`default`)=>(r===`name`?[...e].sort((e,t)=>(Dr(e.project?.path)||Fn(e.title,n)).localeCompare(Dr(t.project?.path)||Fn(t.title,n),n===`zh`?`zh-CN`:`en`)):e).map(e=>({id:e.id,label:Dr(e.project?.path)||Fn(e.title,n),active:e.id===t,hasRunning:e.sessions.some(e=>[`running`,`waiting`,`background`].includes(e.status)),unread:e.sessions.reduce((e,t)=>e+t.unread,0)})),Cs=({locale:e,appSettings:t,onSelectLocale:n,onCommitSettings:r,onCloseSettings:i})=>{let[a]=s(xa),[o,c]=(0,p.useState)(()=>ta(t)),[l,u]=(0,p.useState)(`general`),[d,f]=(0,p.useState)({loading:!1,available:null,runtimeLabel:``}),m=(0,p.useMemo)(()=>Dn(e),[e]),h=a.tabs.find(e=>e.id===a.activeTabId)??a.tabs[0],g=Ss(a.tabs,a.activeTabId,e);(0,p.useEffect)(()=>{c(ta(t))},[t]),(0,p.useEffect)(()=>{let e=o.agentCommand.trim();if(!e){f({loading:!1,available:null,runtimeLabel:``});return}let t=!1,n=window.setTimeout(async()=>{f(e=>({...e,loading:!0,error:void 0}));try{let n=await Qi(e,h?.project?.target??{type:`native`},h?.project?.path);if(t)return;f({loading:!1,available:n.available,runtimeLabel:h?.project?.target?.type===`wsl`?h.project?.target.distro?.trim()?`WSL (${h.project.target.distro.trim()})`:`WSL`:m(`nativeTarget`),resolvedPath:n.resolved_path??void 0,error:n.error??void 0})}catch(e){if(t)return;f({loading:!1,available:!1,runtimeLabel:h?.project?.target?.type===`wsl`?h.project?.target.distro?.trim()?`WSL (${h.project.target.distro.trim()})`:`WSL`:m(`nativeTarget`),error:e instanceof Error?e.message:String(e)})}},220);return()=>{t=!0,window.clearTimeout(n)}},[o.agentCommand,h?.project?.path,h?.project?.target?.type,h?.project?.target?.type===`wsl`?h?.project?.target.distro:``,m]);let _=e=>{c(ta(e)),r(e)},v=e=>{_({...o,...e,idlePolicy:e.idlePolicy?{...e.idlePolicy}:o.idlePolicy})},y=e=>{_({...o,idlePolicy:{enabled:e.enabled??o.idlePolicy.enabled,idleMinutes:Math.max(1,Number(e.idleMinutes??o.idlePolicy.idleMinutes)||1),maxActive:Math.max(1,Number(e.maxActive??o.idlePolicy.maxActive)||1),pressure:e.pressure??o.idlePolicy.pressure}})},b=o.agentCommand.trim(),x=d.loading?`checking`:b?d.available?`available`:`missing`:`idle`,S=d.loading?m(`launchCommandChecking`):b?d.available?m(`launchCommandAvailable`,{runtime:d.runtimeLabel||m(`nativeTarget`)}):m(`launchCommandMissing`,{runtime:d.runtimeLabel||m(`nativeTarget`)}):m(`launchCommandEmpty`),C=b?d.available?d.resolvedPath?m(`launchCommandResolvedPath`,{path:d.resolvedPath}):``:d.error??``:``;return(0,J.jsxs)(`div`,{className:`app`,"data-theme":`dark`,children:[(0,J.jsx)(Yi,{isSettingsRoute:!0,locale:e,workspaceTabs:g,onSwitchWorkspace:()=>{},onAddTab:()=>{},onRemoveTab:()=>{},onOpenSettings:()=>{},onCloseSettings:i,onOpenCommandPalette:()=>{},t:m}),(0,J.jsx)(Ji,{locale:e,activeSettingsPanel:l,settingsDraft:o,launchCommandStatus:{stateClass:x,text:S,detailText:C},onSettingsPanelChange:u,onSettingsChange:v,onSettingsIdlePolicyChange:y,onSelectLocale:n,t:m})]})},ws=({locale:e,inputRef:t,query:n,activeIndex:r,actions:i,activeAction:a,onClose:o,onQueryChange:s,onActivateIndex:c,onRunAction:l})=>(0,J.jsx)(`div`,{className:`command-palette-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&o()},children:(0,J.jsxs)(`div`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":e===`zh`?`快速操作面板`:`Quick actions palette`,onMouseDown:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`command-palette-search-row`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`input`,{ref:t,className:`command-palette-search-input`,value:n,onChange:e=>s(e.target.value),placeholder:e===`zh`?`搜索操作、面板或工作区…`:`Search actions, panels, or workspaces...`,onKeyDown:e=>{if(e.key===`ArrowDown`){e.preventDefault(),c(e=>i.length?Math.min(e+1,i.length-1):0);return}if(e.key===`ArrowUp`){e.preventDefault(),c(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault(),l(a);return}e.key===`Escape`&&(e.preventDefault(),o())}})]}),(0,J.jsx)(`div`,{className:`command-palette-results`,children:i.length===0?(0,J.jsx)(`div`,{className:`command-palette-empty`,children:e===`zh`?`未找到匹配操作`:`No matching actions`}):i.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`command-palette-item ${t===r?`active`:``}`,onMouseEnter:()=>c(t),onClick:()=>l(e),children:[(0,J.jsxs)(`span`,{className:`command-palette-item-copy`,children:[(0,J.jsx)(`span`,{className:`command-palette-item-label`,children:e.label}),(0,J.jsx)(`span`,{className:`command-palette-item-description`,children:e.description})]}),e.shortcut&&(0,J.jsx)(`span`,{className:`command-palette-shortcut`,children:e.shortcut})]},e.id))})]})}),Ts=({nodes:e,depth:t=0,onSelect:n,collapsedPaths:r,onToggleCollapse:i,locale:a=`en`,selectedPath:o,rootPath:s})=>e?.length?(0,J.jsx)(`div`,{className:`tree tree-list`,children:Ta(e,a).map(e=>{let c=e.kind===`dir`,l=c?r?.has(e.path)??!1:!1,u=o?Sr(o):``,d=!c&&!!o&&Sr(s?xr(s,e.path):e.path)===u;return(0,J.jsxs)(`div`,{className:`tree-node`,children:[(0,J.jsxs)(`div`,{className:`tree-line ${e.kind===`file`?`file`:`dir`} ${e.status?`changed`:``} ${d?`selected`:``}`,style:{paddingLeft:`${t*16+8}px`},onClick:()=>{if(c){i?.(e.path);return}n?.(e)},children:[(0,J.jsx)(`span`,{className:`tree-disclosure`,children:c?l?(0,J.jsx)(Ri,{}):(0,J.jsx)(Li,{}):null}),(0,J.jsx)(`span`,{className:`tree-icon`,children:Ki(e.name,c,l)}),(0,J.jsx)(`span`,{className:`tree-label`,children:e.name}),e.status&&(0,J.jsx)(`span`,{className:`status`,children:e.status})]}),e.children?.length&&l?(0,J.jsx)(`div`,{className:`tree-children`,children:(0,J.jsx)(Ts,{nodes:e.children,depth:t+1,onSelect:n,collapsedPaths:r,onToggleCollapse:i,locale:a,selectedPath:o,rootPath:s})}):null]},e.path)})}):null,Es=({locale:e,worktree:t,view:n,collapsedPaths:r,onClose:i,onViewChange:a,onFileSelect:o,onToggleCollapse:s,t:c})=>(0,J.jsx)(`div`,{className:`modal-overlay`,children:(0,J.jsxs)(`div`,{className:`modal-card`,children:[(0,J.jsxs)(`div`,{className:`modal-header`,children:[(0,J.jsx)(`h3`,{children:t.name}),(0,J.jsx)(`button`,{className:`btn tiny`,onClick:i,children:c(`close`)})]}),(0,J.jsx)(`div`,{className:`file-tabs`,children:[`status`,`diff`,`tree`].map(e=>(0,J.jsx)(`div`,{className:`t-tab ${n===e?`active`:``}`,onClick:()=>a(e),children:c(e===`status`?`statusTab`:e===`diff`?`diff`:`treeTab`)},e))}),(0,J.jsxs)(`div`,{className:`modal-body`,children:[t.loading&&(0,J.jsx)(`div`,{className:`empty`,children:c(`loadingWorktreeDetails`)}),n===`status`&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`muted`,children:[c(`path`),`: `,t.path]}),(0,J.jsxs)(`div`,{className:`muted`,children:[c(`branch`),`: `,t.branch]}),(0,J.jsx)(`div`,{className:`status`,children:t.status||c(`clean`)})]}),n===`diff`&&(0,J.jsx)(`pre`,{className:`diff`,children:t.diff||c(`noDiffAvailable`)}),n===`tree`&&(0,J.jsx)(Ts,{nodes:t.tree??[],onSelect:o,collapsedPaths:r,locale:e,onToggleCollapse:s})]})]})}),Ds=({visible:e,target:t,input:n,canUseWsl:r,folderBrowser:i,onUpdateTarget:a,onBrowseDirectory:o,onStartWorkspace:s,t:c})=>{if(!e)return null;let l=n.trim(),u=i.roots.filter(e=>e.id!==`root`&&e.path!==i.homePath);return(0,J.jsx)(`div`,{className:`overlay`,"data-testid":`overlay`,children:(0,J.jsx)(`div`,{className:`modal onboarding-modal`,children:(0,J.jsxs)(`div`,{className:`onboarding-form`,children:[(0,J.jsx)(`div`,{className:`onboarding-header`,children:(0,J.jsx)(`h2`,{children:c(`localFolder`)})}),(0,J.jsx)(`div`,{className:`choice-grid`,children:(0,J.jsxs)(`div`,{className:`choice active`,"data-testid":`choice-local-only`,children:[(0,J.jsx)(`strong`,{children:c(`localFolder`)}),(0,J.jsx)(`div`,{className:`hint`,children:c(`localFolderHint`)})]})}),r&&(0,J.jsxs)(`div`,{className:`choice-grid small`,children:[(0,J.jsxs)(`div`,{className:`choice ${t.type===`native`?`active`:``}`,onClick:()=>a({type:`native`}),children:[(0,J.jsx)(`strong`,{children:c(`nativeTarget`)}),(0,J.jsx)(`div`,{className:`hint`,children:c(`nativeTargetHint`)})]}),(0,J.jsxs)(`div`,{className:`choice ${t.type===`wsl`?`active`:``}`,onClick:()=>a({type:`wsl`}),children:[(0,J.jsx)(`strong`,{children:`WSL`}),(0,J.jsx)(`div`,{className:`hint`,children:c(`wslHint`)})]})]}),r&&t.type===`wsl`&&(0,J.jsx)(`input`,{value:t.distro??``,onChange:e=>a({type:`wsl`,distro:e.target.value}),placeholder:c(`optionalDistroPlaceholder`)}),(0,J.jsxs)(`div`,{className:`local-picker web-folder-picker`,"data-testid":`folder-select`,children:[(0,J.jsxs)(`div`,{className:`web-folder-picker-toolbar`,children:[(0,J.jsxs)(`div`,{className:`web-folder-picker-paths`,children:[(0,J.jsx)(`div`,{className:`hint`,"data-testid":`folder-selected`,children:c(`selected`)}),(0,J.jsx)(`strong`,{children:l||i.currentPath||c(`loading`)}),(0,J.jsx)(`div`,{className:`web-folder-picker-tip`,children:c(`folderBrowserInteractionHint`)})]}),(0,J.jsxs)(`div`,{className:`web-folder-picker-actions`,children:[(0,J.jsx)(`button`,{className:`btn tiny ghost`,type:`button`,onClick:()=>o(i.homePath||void 0,!0),disabled:i.loading,children:c(`homeDirectory`)}),(0,J.jsx)(`button`,{className:`btn tiny ghost`,type:`button`,onClick:()=>o(i.parentPath,!0),disabled:i.loading||!i.parentPath,children:c(`goUp`)})]})]}),i.notice&&(0,J.jsx)(`div`,{className:`folder-browser-notice`,children:i.notice}),u.length>0&&(0,J.jsx)(`div`,{className:`web-folder-picker-roots`,children:u.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`folder-root-chip ${l===e.path||i.currentPath===e.path?`active`:``}`,onClick:()=>o(e.path,!0),title:c(`folderBrowserInteractionHint`),children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`small`,{children:e.description})]},e.id))}),(0,J.jsxs)(`div`,{className:`web-folder-picker-list`,children:[i.loading&&(0,J.jsx)(`div`,{className:`tree-empty`,children:c(`loadingDirectories`)}),!i.loading&&i.error&&(0,J.jsx)(`div`,{className:`tree-empty`,children:i.error}),!i.loading&&!i.error&&i.entries.length===0&&(0,J.jsx)(`div`,{className:`tree-empty`,children:c(`emptyDirectories`)}),!i.loading&&!i.error&&i.entries.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`folder-browser-row ${l===e.path?`selected`:``}`,onClick:()=>o(e.path,!0),title:c(`folderBrowserInteractionHint`),children:[(0,J.jsxs)(`span`,{className:`folder-browser-row-meta`,children:[(0,J.jsxs)(`span`,{className:`folder-browser-row-name`,children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:e.name})]}),(0,J.jsx)(`span`,{className:`folder-browser-row-hint`,children:c(`folderBrowserRowHint`)})]}),(0,J.jsxs)(`span`,{className:`folder-browser-row-action`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:c(`enterFolder`)}),(0,J.jsx)(Li,{})]})]},e.path))]})]}),(0,J.jsx)(`div`,{className:`modal-actions`,children:(0,J.jsx)(`button`,{className:`btn primary`,onClick:s,"data-testid":`start-workspace`,disabled:!l,children:c(`startWorkspace`)})})]})})})},Os=({locale:e,isExpanded:t,width:n,codeSidebarView:r,previewPathLabel:i,previewFileName:a,fileSearchQuery:o,fileSearchActiveIndex:s,showFileSearchDropdown:c,searchShellRef:l,fileSearchInputRef:u,editorContent:d,sidebarContent:f,onSetSidebarView:p,onFileSearchChange:m,onFileSearchFocus:h,onFileSearchBlur:g,onFileSearchKeyDown:_,onToggleExpanded:v,t:y})=>(0,J.jsx)(`section`,{className:`panel workspace-code-shell`,style:t?{flex:`1 1 100%`}:{flex:`0 0 ${n}px`},children:(0,J.jsxs)(`div`,{className:`panel-inner workspace-code-panel`,children:[(0,J.jsxs)(`div`,{className:`workspace-code-header`,children:[(0,J.jsx)(`div`,{className:`workspace-code-modes`,children:t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${r===`files`?`active`:``}`,onClick:()=>p(`files`),children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:y(`files`)})]}),(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${r===`git`?`active`:``}`,onClick:()=>p(`git`),children:[(0,J.jsx)(Si,{}),(0,J.jsx)(`span`,{children:`Git Diff`})]}),i&&(0,J.jsx)(`span`,{className:`workspace-code-current-path`,title:i,children:i})]}):(0,J.jsxs)(`div`,{className:`workspace-code-title-block`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`codePanel`)}),(0,J.jsx)(`strong`,{children:a||y(`selectFileFromNavigator`)})]})}),(0,J.jsxs)(`div`,{className:`workspace-code-actions`,children:[(0,J.jsx)(`div`,{className:`workspace-search-shell`,ref:l,children:(0,J.jsxs)(`div`,{className:`workspace-search-field`,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(`input`,{ref:u,value:o,onChange:e=>m(e.target.value),onFocus:e=>h(e.currentTarget.value),onBlur:g,onKeyDown:_,placeholder:e===`zh`?`搜索文件并跳转…`:`Search files and jump...`,autoComplete:`off`,spellCheck:!1,"aria-expanded":c,"aria-controls":`workspace-file-search-results`,"aria-activedescendant":c?`workspace-file-search-option-${s}`:void 0})]})}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:v,"aria-label":t?e===`zh`?`退出展开`:`Exit expand`:e===`zh`?`展开代码区`:`Expand code area`,title:t?e===`zh`?`退出展开`:`Exit expand`:e===`zh`?`展开代码区`:`Expand code area`,children:t?(0,J.jsx)(Bi,{}):(0,J.jsx)(zi,{})})]})]}),(0,J.jsxs)(`div`,{className:`workspace-code-body ${t?`expanded`:`collapsed`}`,children:[(0,J.jsx)(`div`,{className:`workspace-code-editor`,children:d}),t&&(0,J.jsx)(`aside`,{className:`workspace-code-sidebar`,children:f})]})]})}),ks=e(n(),1),As=({container:e,locale:t,dropdownStyle:n,results:r,activeIndex:i,onHover:a,onSelect:o,fileParentLabel:s})=>(0,ks.createPortal)((0,J.jsx)(`div`,{className:`workspace-search-dropdown floating ${n.placement}`,id:`workspace-file-search-results`,role:`listbox`,style:{left:n.left,width:n.width,maxHeight:n.maxHeight,top:n.top,bottom:n.bottom},children:r.length===0?(0,J.jsx)(`div`,{className:`workspace-search-empty`,children:t===`zh`?`未找到匹配文件`:`No matching files`}):r.map((e,t)=>(0,J.jsxs)(`button`,{id:`workspace-file-search-option-${t}`,type:`button`,role:`option`,"aria-selected":t===i,tabIndex:-1,className:`code-search-result ${t===i?`active`:``}`,onMouseEnter:()=>a(t),onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,J.jsx)(`span`,{className:`code-search-result-name`,children:e.name}),(0,J.jsx)(`span`,{className:`code-search-result-path`,children:s(e.path)||`.`})]},e.absolutePath))}),e),js=({locale:e,isFocusMode:t,isCodeExpanded:n,showAgentPanel:r,showCodePanel:i,showTerminalPanel:a,rightSplit:o,workspaceFolderName:s,branchName:c,changeCount:l,agentPanel:u,codePanel:d,terminalPanel:f,onToggleRightPane:p,t:m})=>(0,J.jsxs)(`main`,{className:`workspace-shell`,children:[(0,J.jsxs)(`div`,{className:`workspace-main-header workspace-shell-header`,children:[(0,J.jsx)(`div`,{className:`workspace-main-header-copy`,children:(0,J.jsxs)(`div`,{className:`workspace-main-meta`,children:[(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(bi,{}),(0,J.jsx)(`span`,{children:s})]}),(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(xi,{}),(0,J.jsx)(`span`,{children:c||`—`})]}),(0,J.jsxs)(`span`,{className:`workspace-main-chip`,children:[(0,J.jsx)(Si,{}),(0,J.jsx)(`span`,{children:m(`changesCount`,{count:l})})]})]})}),(0,J.jsxs)(`div`,{className:`workspace-main-actions`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${i?`active`:``}`,onClick:()=>p(`code`),title:m(`codePanel`),"aria-pressed":i,children:[(0,J.jsx)(Ci,{}),(0,J.jsx)(`span`,{children:m(`codePanel`)})]}),(0,J.jsxs)(`button`,{type:`button`,className:`workspace-panel-toggle ${a?`active`:``}`,onClick:()=>p(`terminal`),title:m(`terminalPanel`),"aria-pressed":a,children:[(0,J.jsx)(wi,{}),(0,J.jsx)(`span`,{children:m(`terminalPanel`)})]}),(0,J.jsx)(`span`,{className:`workspace-shortcut-hint`,children:e===`zh`?`⌘/Ctrl+K 快速操作`:`⌘/Ctrl+K actions`})]})]}),(0,J.jsxs)(`div`,{className:`workspace-stack ${t?`focus-mode`:``} ${n?`code-expanded`:``}`,children:[(0,J.jsxs)(`div`,{className:`workspace-top-shell`,style:!n&&a?{flex:`0 0 ${o}%`}:void 0,children:[r&&u,i&&d]}),!n&&a&&f]})]}),Ms=({locale:e,view:t,fileTree:n,rootPath:r,selectedPath:i,repoCollapsedPaths:a,gitChangeGroups:o,activeGitChangeKey:s,commitMessage:c,onCommitMessageChange:l,onFileSelect:u,onToggleRepoCollapse:d,onRefresh:f,onStageAll:p,onUnstageAll:m,onDiscardAll:h,onCommit:g,onGitChangeSelect:_,onGitChangeAction:v,t:y})=>t===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`workspace-code-sidebar-head`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`repositoryNavigator`)}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:f,title:y(`refresh`),"aria-label":y(`refresh`),children:(0,J.jsx)(Fi,{})})]}),n.length===0?(0,J.jsx)(`div`,{className:`tree-empty`,children:y(`selectProjectToLoadFiles`)}):(0,J.jsx)(Ts,{nodes:n,onSelect:u,collapsedPaths:a,locale:e,selectedPath:i,rootPath:r,onToggleCollapse:d})]}):(0,J.jsxs)(`div`,{className:`workspace-git-sidebar`,children:[(0,J.jsxs)(`div`,{className:`workspace-code-sidebar-head git-sidebar-head`,children:[(0,J.jsx)(`span`,{className:`section-kicker`,children:y(`sourceControl`)}),(0,J.jsxs)(`div`,{className:`git-toolbar-actions`,children:[(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:f,title:y(`refresh`),"aria-label":y(`refresh`),children:(0,J.jsx)(Fi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:p,title:y(`stageAll`),"aria-label":y(`stageAll`),children:(0,J.jsx)(Mi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:m,title:y(`unstageAll`),"aria-label":y(`unstageAll`),children:(0,J.jsx)(Ni,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:h,title:y(`discardAll`),"aria-label":y(`discardAll`),children:(0,J.jsx)(Pi,{})}),(0,J.jsx)(`button`,{className:`workspace-icon-button bare`,type:`button`,onClick:g,disabled:!c.trim(),title:y(`commit`),"aria-label":y(`commit`),children:(0,J.jsx)(Ti,{})})]})]}),(0,J.jsx)(`div`,{className:`workspace-git-compose`,children:(0,J.jsx)(`div`,{className:`form-row`,children:(0,J.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:y(`commitPlaceholder`),"data-testid":`git-commit-message`,className:`workspace-git-commit-input`})})}),(0,J.jsxs)(`div`,{className:`source-control-list`,children:[o.length===0&&(0,J.jsx)(`div`,{className:`tree-empty`,children:y(`noChangesDetected`)}),o.map(e=>(0,J.jsxs)(`div`,{className:`source-group`,children:[(0,J.jsxs)(`div`,{className:`source-group-head`,children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{children:e.items.length})]}),(0,J.jsx)(`div`,{className:`source-group-items`,children:e.items.map(e=>{let t=`${e.section}:${e.path}:${e.code}`,n=e.section===`staged`?[{id:`unstage`,title:y(`unstageFile`),icon:(0,J.jsx)(Ni,{})}]:[{id:`stage`,title:y(`stageFile`),icon:(0,J.jsx)(Mi,{})},{id:`discard`,title:y(`discardFile`),icon:(0,J.jsx)(Pi,{})}];return(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,className:`source-change-row ${s===t?`active`:``}`,"data-section":e.section,onClick:()=>_(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_(e))},children:[(0,J.jsx)(`span`,{className:`source-change-file-icon`,"aria-hidden":`true`,children:Ki(e.name,!1,!1)}),(0,J.jsxs)(`span`,{className:`source-change-copy`,children:[(0,J.jsx)(`span`,{className:`source-change-name`,children:e.name}),(0,J.jsx)(`span`,{className:`source-change-parent`,children:e.parent||`.`})]}),(0,J.jsxs)(`span`,{className:`source-change-tail`,children:[(0,J.jsx)(`span`,{className:`source-status-badge ${e.section}`,title:e.status,children:e.code}),(0,J.jsx)(`span`,{className:`source-change-actions`,children:n.map(t=>(0,J.jsx)(`button`,{type:`button`,className:`source-action-btn`,title:t.title,"aria-label":t.title,onClick:n=>{n.stopPropagation(),v(e,t.id)},children:t.icon},t.id))})]})]},t)})})]},e.key))]})]}),Ns=({progressPercent:e,progressTone:t,activeTerminalId:n,terminals:r,terminalContent:i,onResizeStart:a,onSelect:o,onClose:s,onAdd:c,hasActiveTerminal:l,t:u})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-resizer workspace-bottom-splitter`,"data-resize":`right-split`,onPointerDown:a}),(0,J.jsx)(`section`,{className:`panel workspace-terminal-shell`,children:(0,J.jsxs)(`div`,{className:`panel-inner terminal-card workspace-terminal-panel`,children:[(0,J.jsx)(`div`,{className:`surface-progress ${t}`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`${e}%`}})}),(0,J.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,J.jsx)(`div`,{className:`terminal-toolbar-title`,children:u(`terminalPanel`)}),(0,J.jsxs)(`div`,{className:`terminal-toolbar-actions`,children:[(0,J.jsx)(`select`,{className:`terminal-select`,value:n??``,onChange:e=>o(e.target.value),children:r.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.title},e.id))}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:s,disabled:!l,title:u(`close`),"aria-label":u(`close`),children:(0,J.jsx)(Di,{})}),(0,J.jsx)(`button`,{type:`button`,className:`workspace-icon-button`,onClick:c,title:u(`new`),"aria-label":u(`new`),children:(0,J.jsx)(Ei,{})})]})]}),(0,J.jsx)(`div`,{className:`terminal-output`,children:i})]})})]}),Ps=15e3,Fs=1e4,Is=class{pingTimer=null;pongTimer=null;constructor(e){this.options=e}start(){this.stop(),this.scheduleNextPing()}stop(){this.pingTimer!==null&&(window.clearTimeout(this.pingTimer),this.pingTimer=null),this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}markAlive(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}scheduleNextPing(){this.pingTimer=window.setTimeout(()=>{this.options.send({type:`ping`,ts:Date.now()}),this.pongTimer=window.setTimeout(()=>{this.options.onTimeout()},Fs),this.scheduleNextPing()},Ps)}},Ls=e=>{try{let t=JSON.parse(e);return t?.type===`event`&&typeof t.event==`string`?{type:`event`,event:t.event,payload:t.payload}:(t?.type===`ping`||t?.type===`pong`)&&typeof t.ts==`number`?t:null}catch{return null}},Rs=new class{listeners=new Map;socket=null;reconnectTimer=null;activeSocketUrl=``;healthProbe=null;heartbeat=new Is({send:e=>{this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))},onTimeout:()=>{this.socket?.close()}});subscribe(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),this.connect(),()=>{let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e),this.prune())}}notify(e){let t=this.listeners.get(e.event);t&&t.forEach(t=>t(e.payload))}scheduleReconnect(){this.reconnectTimer!==null||this.listeners.size===0||(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},800))}connect(){if(typeof window>`u`||fr()&&!pr())return;let e=``;try{e=Jn()}catch{this.scheduleReconnect();return}this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)&&this.activeSocketUrl===e||(this.socket&&=(this.socket.close(),null),this.activeSocketUrl=e,this.openSocket(e))}async ensureBackendReady(){return this.healthProbe||=fetch(qn(),{method:`GET`,cache:`no-store`,credentials:`include`}).then(e=>e.ok).catch(()=>!1).finally(()=>{this.healthProbe=null}),this.healthProbe}async openSocket(e){if(!await this.ensureBackendReady()){this.scheduleReconnect();return}this.listeners.size===0||this.activeSocketUrl!==e||this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)||(this.socket=new WebSocket(e),this.socket.addEventListener(`open`,()=>{this.heartbeat.start()}),this.socket.addEventListener(`message`,e=>{let t=Ls(String(e.data));if(t){if(t.type===`event`){this.notify(t);return}if(t.type===`pong`){this.heartbeat.markAlive();return}t.type===`ping`&&this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:`pong`,ts:t.ts}))}}),this.socket.addEventListener(`close`,()=>{this.heartbeat.stop(),this.socket=null,this.scheduleReconnect()}),this.socket.addEventListener(`error`,()=>{this.socket?.close()}))}prune(){this.listeners.size>0||(this.heartbeat.stop(),this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.socket&&=(this.socket.close(),null))}},zs=(e,t)=>Rs.subscribe(e,t),Bs=e=>zs(`agent://event`,e),Vs=e=>zs(`agent://lifecycle`,e),Hs=e=>zs(`terminal://event`,e),Us=e=>{if(typeof window>`u`)return{background:`#0b151a`,foreground:`#d8edf4`,cursor:`#8fffae`,cursorAccent:`#0d1418`};let t=window.getComputedStyle(e??document.documentElement),n=window.getComputedStyle(document.documentElement),r=(e,r)=>t.getPropertyValue(e).trim()||n.getPropertyValue(e).trim()||r;return{background:r(`--terminal-bg`,`#0b151a`),foreground:r(`--terminal-fg`,`#d8edf4`),cursor:r(`--terminal-cursor`,`#8fffae`),cursorAccent:r(`--terminal-cursor-accent`,`#0d1418`),selectionBackground:r(`--terminal-selection`,`rgba(90, 200, 250, 0.3)`),selectionInactiveBackground:r(`--terminal-selection-inactive`,`rgba(90, 200, 250, 0.2)`),black:r(`--ansi-black`,`#5f7680`),red:r(`--ansi-red`,`#ff9eb0`),green:r(`--ansi-green`,`#8fffae`),yellow:r(`--ansi-yellow`,`#ffd37a`),blue:r(`--ansi-blue`,`#5ac8fa`),magenta:r(`--ansi-magenta`,`#b9a4ff`),cyan:r(`--ansi-cyan`,`#79f6de`),white:r(`--ansi-white`,`#e7f3f7`),brightBlack:r(`--ansi-bright-black`,`#8da6b0`),brightRed:r(`--ansi-bright-red`,`#ffbac6`),brightGreen:r(`--ansi-bright-green`,`#b8ffca`),brightYellow:r(`--ansi-bright-yellow`,`#ffe7a6`),brightBlue:r(`--ansi-bright-blue`,`#9edfff`),brightMagenta:r(`--ansi-bright-magenta`,`#d8caff`),brightCyan:r(`--ansi-bright-cyan`,`#a7fff0`),brightWhite:r(`--ansi-bright-white`,`#f4fbfd`)}},Ws=(e,t)=>{if(t===e)return``;if(t.startsWith(e))return t.slice(e.length);let n=Math.min(256,t.length);if(n===0)return null;let r=t.slice(0,n),i=e.lastIndexOf(r);if(i===-1)return null;let a=e.slice(i);return t.startsWith(a)?t.slice(a.length):null},Gs=(e,t,n)=>{if(n===t)return;let r=Ws(t,n);if(r!==null){r&&e.write(r);return}e.reset(),n&&e.write(n)},Ks=3,qs=e=>e?e.closest(`.agent-pane-card`)??e.closest(`.terminal-card`)??e.closest(`.app`):null,Js=(0,p.forwardRef)(({output:e,outputIdentity:t,themeIdentity:n,theme:r,fontSize:i,mode:a=`interactive`,className:o=`agent-pane-xterm`,sanitizeOutput:s,onData:c,onSize:l,autoFocus:f=!1},m)=>{let h=(0,p.useRef)(null),g=(0,p.useRef)(null),_=(0,p.useRef)(null),v=(0,p.useRef)(``),y=(0,p.useRef)(void 0),b=(0,p.useRef)(null),x=(0,p.useCallback)(()=>{let e=g.current;if(!e||!l)return;let t={cols:e.cols,rows:e.rows};b.current?.cols===t.cols&&b.current?.rows===t.rows||(b.current=t,l(t))},[l]),S=(0,p.useCallback)(()=>{_.current?.fit(),x()},[x]);return(0,p.useEffect)(()=>{let e=h.current;if(e){if(!g.current){let t=new u({convertEol:!0,disableStdin:a===`readonly`,cursorBlink:a===`interactive`,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, SFMono-Regular, monospace`,fontSize:i,overviewRuler:{width:Ks},theme:Us(qs(e))}),n=new d;t.loadAddon(n),t.open(e),g.current=t,_.current=n,v.current=``,y.current=void 0,b.current=null,S();return}S()}},[S,i,a]),(0,p.useEffect)(()=>{let e=h.current,t=g.current;!e||!t||(t.options={disableStdin:a===`readonly`,cursorBlink:a===`interactive`,fontSize:i,overviewRuler:{width:Ks},theme:Us(qs(e))},requestAnimationFrame(()=>S()))},[S,i,a,r,n]),(0,p.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>{S()});return t.observe(e),()=>t.disconnect()},[S]),(0,p.useEffect)(()=>{let n=g.current;if(!n)return;y.current!==t&&(n.reset(),v.current=``,y.current=t);let r=s?s(e):e;Gs(n,v.current,r),v.current=r},[e,t,s]),(0,p.useEffect)(()=>{t!==void 0&&(b.current=null,x())},[x,t]),(0,p.useEffect)(()=>{let e=g.current;if(!e||a!==`interactive`||!c)return;let t=e.onData(c);return()=>t.dispose()},[a,c]),(0,p.useEffect)(()=>{f&&g.current?.focus()},[f,t]),(0,p.useImperativeHandle)(m,()=>({fit:S,focus:()=>{g.current?.focus()},size:()=>{let e=g.current;return e?{cols:e.cols,rows:e.rows}:null}}),[S]),(0,p.useEffect)(()=>()=>{g.current?.dispose(),g.current=null,_.current=null,v.current=``,y.current=void 0,b.current=null},[]),(0,J.jsx)(`div`,{ref:h,className:o,onClick:()=>{a===`interactive`&&g.current?.focus()}})});Js.displayName=`XtermBase`;var Ys=(0,p.forwardRef)(({streamId:e,stream:t,toneKey:n,theme:r,fontSize:i,mode:a=`readonly`,autoFocus:o=!1,onData:s,onSize:c},l)=>(0,J.jsx)(Js,{ref:l,outputIdentity:e,themeIdentity:n,output:t,theme:r,fontSize:i,mode:a,onData:s,onSize:c,autoFocus:o,className:`agent-pane-xterm`}));Ys.displayName=`AgentStreamTerminal`;var Xs=(0,p.forwardRef)(({terminalId:e,output:t,theme:n,fontSize:r,autoFocus:i=!1,onData:a,onSize:o},s)=>(0,J.jsx)(Js,{ref:s,outputIdentity:e,output:t,theme:n,fontSize:r,mode:`interactive`,onData:a,onSize:o,autoFocus:i,className:`agent-pane-xterm`}));Xs.displayName=`ShellTerminal`;var Zs=e=>e&&e.replace(/\x1b\][^\u0007]*(\u0007|\x1b\\)/g,``).replace(/\x1b\[(?![0-9;:]*m)[0-?]*[ -/]*[@-~]/g,``).replace(/\x1b(?!\[)/g,``).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,``).replace(/\r/g,``),Qs=e=>e&&Zs(e).replace(/\x1b\[[0-9;:]*m/g,``),$s=e=>e.replace(/\x1b\][^\u0007]*(\u0007|\x1b\\)/g,``).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,``).replace(/\x1b./g,``),ec=({visible:e,activeTab:t,activePaneSession:n,viewedSession:r,isArchiveView:i,showCodePanel:a,theme:o,terminalFontSize:s,draftPromptInputs:c,displaySessionTitle:l,onExitArchive:u,onSetActivePane:d,onSplitPane:f,onCloseAgentPane:p,onSubmitDraftPrompt:m,onDraftPromptChange:h,setDraftPromptInputRef:g,setAgentTerminalRef:_,onAgentTerminalData:v,onAgentTerminalSize:y,onPaneSplitResizeStart:b,onCodeResizeStart:x,t:S})=>{if(!e)return null;let C=Qs(r.stream),w=e=>{if(e.type===`split`)return(0,J.jsxs)(`div`,{className:`agent-split-pane ${e.axis}`,children:[(0,J.jsx)(`div`,{className:`agent-split-child`,style:{flex:`${e.ratio} 1 0%`},children:w(e.first)}),(0,J.jsx)(`div`,{className:`agent-split-divider ${e.axis}`,onPointerDown:b(e.id,e.axis)}),(0,J.jsx)(`div`,{className:`agent-split-child`,style:{flex:`${1-e.ratio} 1 0%`},children:w(e.second)})]},e.id);let r=t.sessions.find(t=>t.id===e.sessionId)??n,i=t.activePaneId===e.id,a=(()=>{let e=Ho(r);return e>0?Math.max(14,e):r.status===`running`||r.status===`background`?34:r.status===`waiting`?22:6})(),u=r.status===`running`||r.status===`background`?`live`:r.status===`waiting`?`queued`:`idle`,x=Vo(r.status),C=Fo(r);return(0,J.jsxs)(`section`,{className:`agent-pane-card ${i?`active`:``}`,onMouseDown:()=>d(e.id,r.id),children:[(0,J.jsx)(`div`,{className:`surface-progress ${u}`,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{className:`surface-progress-bar`,style:{width:`${a}%`}})}),(0,J.jsxs)(`div`,{className:`agent-pane-header`,children:[(0,J.jsxs)(`div`,{className:`agent-pane-header-copy`,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${x} ${x===`active`?`pulse`:``}`}),(0,J.jsx)(`span`,{className:`agent-pane-title`,children:l(r.title)})]}),(0,J.jsxs)(`div`,{className:`agent-pane-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`pane-action split`,onClick:()=>f(e.id,`vertical`),title:S(`splitVertical`),"aria-label":S(`splitVertical`),children:(0,J.jsx)(Hi,{})}),(0,J.jsx)(`button`,{type:`button`,className:`pane-action split`,onClick:()=>f(e.id,`horizontal`),title:S(`splitHorizontal`),"aria-label":S(`splitHorizontal`),children:(0,J.jsx)(Vi,{})}),(0,J.jsx)(`button`,{type:`button`,className:`pane-action close`,onClick:()=>p(e.id,r.id),title:S(`close`),children:(0,J.jsx)(Di,{})})]})]}),(0,J.jsx)(`div`,{className:`agent-pane-body`,"data-testid":`agent-pane-${e.id}`,children:C?(0,J.jsx)(`div`,{className:`agent-draft-launcher`,children:(0,J.jsxs)(`div`,{className:`agent-draft-launcher-card`,children:[(0,J.jsxs)(`div`,{className:`agent-draft-launcher-copy`,children:[(0,J.jsx)(`div`,{className:`agent-draft-launcher-title`,children:S(`draftSessionPrompt`)}),(0,J.jsx)(`div`,{className:`agent-draft-launcher-hint`,children:S(`draftTaskPlaceholder`)})]}),(0,J.jsx)(`form`,{className:`agent-pane-input agent-draft-launcher-form`,onSubmit:t=>{t.preventDefault(),m(e.id)},children:(0,J.jsxs)(`div`,{className:`agent-compose`,children:[(0,J.jsx)(`input`,{ref:t=>g(e.id,t),className:`agent-compose-field agent-draft-launcher-field`,value:c[e.id]??``,onChange:t=>h(e.id,t.target.value),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},placeholder:S(`draftTaskPlaceholder`),"aria-label":S(`draftTaskPlaceholder`),"data-testid":`agent-draft-input-${e.id}`,autoFocus:i}),(0,J.jsx)(`button`,{type:`submit`,className:`agent-send-button`,disabled:!c[e.id]?.trim(),title:S(`send`),"aria-label":S(`send`),children:(0,J.jsx)(Ti,{})})]})})]})}):(0,J.jsx)(Ys,{ref:t=>_(e.id,t),streamId:r.id,stream:r.stream,toneKey:i?`active`:`inactive`,theme:o,fontSize:s,mode:`interactive`,autoFocus:i,onData:t=>{v(e.id,t)},onSize:n=>y(e.id,t.id,r.id,n)})})]},e.id)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`section`,{className:`panel center-panel workspace-agent-shell`,style:{flex:`1 1 0%`},children:(0,J.jsxs)(`div`,{className:`panel-inner studio-panel compact`,children:[i&&(0,J.jsxs)(`div`,{className:`archive-banner`,children:[(0,J.jsxs)(`div`,{children:[S(`viewingArchivedSession`),(0,J.jsx)(`div`,{className:`hint`,children:S(`exitArchiveHint`)})]}),(0,J.jsx)(`button`,{className:`btn tiny`,onClick:u,children:S(`exit`)})]}),(0,J.jsx)(`div`,{className:`agent-pane-workspace`,children:i?(0,J.jsxs)(`section`,{className:`agent-pane-card archive-only`,children:[(0,J.jsx)(`div`,{className:`agent-pane-header`,children:(0,J.jsxs)(`div`,{className:`agent-pane-header-copy`,children:[(0,J.jsx)(`span`,{className:`session-top-dot ${Vo(r.status)} ${Vo(r.status)===`active`?`pulse`:``}`}),(0,J.jsx)(`span`,{className:`agent-pane-title`,children:l(r.title)})]})}),(0,J.jsx)(`div`,{className:`agent-pane-body`,children:C.trim()?(0,J.jsx)(Ys,{streamId:r.id,stream:r.stream,toneKey:`active`,theme:o,fontSize:s}):(0,J.jsx)(`div`,{className:`terminal-empty`,children:S(`archiveViewReadonly`)})})]}):w(t.paneLayout)})]})}),a&&(0,J.jsx)(`div`,{className:`v-resizer`,"data-resize":`left`,onPointerDown:x})]})},tc=e=>Z(`agent_start`,e),nc=(e,t,n,r)=>Z(`agent_send`,{workspaceId:e,sessionId:t,input:n,appendNewline:r}),rc=(e,t,n,r)=>Z(`agent_resize`,{workspaceId:e,sessionId:t,cols:n,rows:r});Object.fromEntries([{labelKey:`escKey`,sequence:`\x1B`,key:`Escape`},{labelKey:`tabKey`,sequence:` `,key:`Tab`},{labelKey:`enterKey`,sequence:`\r`,key:`Enter`},{labelKey:`arrowUp`,sequence:`\x1B[A`,key:`ArrowUp`},{labelKey:`arrowDown`,sequence:`\x1B[B`,key:`ArrowDown`},{labelKey:`arrowLeft`,sequence:`\x1B[D`,key:`ArrowLeft`},{labelKey:`arrowRight`,sequence:`\x1B[C`,key:`ArrowRight`}].map(e=>[e.key,e.sequence]));var ic=1e6,ac=1e6,oc=(e,t)=>`${e}:${t}`,sc=(e,t,n)=>e.runningAgentKeysRef.current.has(oc(t,n)),cc=e=>{requestAnimationFrame(()=>{e.agentTerminalRefs.current.forEach(e=>e?.fit())})},lc=(e,t,n)=>{let r=oc(t,n),i=e.agentResizeStateRef.current.get(r);if(!i||i.inflight||!i.pending)return;let a=i.pending;i.pending=void 0;let o=e.agentRuntimeSizeRef.current.get(r);o?.cols===a.cols&&o?.rows===a.rows&&!i.pending||(i.inflight=!0,rc(t,n,a.cols,a.rows).then(()=>{e.agentRuntimeSizeRef.current.set(r,a)}).catch(()=>{e.agentRuntimeSizeRef.current.delete(r)}).finally(()=>{let i=e.agentResizeStateRef.current.get(r);if(i){if(i.inflight=!1,i.pending){lc(e,t,n);return}e.runningAgentKeysRef.current.has(r)||e.agentResizeStateRef.current.delete(r)}}))},uc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentRuntimeSizeRef.current.get(i),o=e.agentResizeStateRef.current.get(i)??{inflight:!1};a?.cols===r.cols&&a?.rows===r.rows&&!o.pending||o.pending?.cols===r.cols&&o.pending?.rows===r.rows||(o.pending=r,e.agentResizeStateRef.current.set(i,o),lc(e,t,n))},dc=(e,t,n,r)=>{let i=e.agentPaneSizeRef.current.get(t)??e.agentTerminalRefs.current.get(t)?.size();i&&uc(e,n,r,i)},fc=(e,t,n)=>{let r=++e.agentStartupTokenRef.current,i=Date.now();return e.agentStartupStateRef.current.set(oc(t,n),{token:r,startedAt:i,lastEventAt:i,sawOutput:!1,sawReady:!1,exited:!1}),r},pc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentStartupStateRef.current.get(i);a&&(r!==void 0&&a.token!==r||e.agentStartupStateRef.current.delete(i))},mc=(e,t,n)=>{let r=oc(t,n);e.runningAgentKeysRef.current.delete(r),e.agentRuntimeSizeRef.current.delete(r),e.agentResizeStateRef.current.delete(r),pc(e,t,n)},hc=(e,t,n)=>{let r=oc(t,n);e.agentRuntimeSizeRef.current.delete(r),e.agentResizeStateRef.current.delete(r),e.runningAgentKeysRef.current.add(r)},gc=(e,t,n)=>{if(n){e.agentTerminalRefs.current.set(t,n);return}e.agentTerminalRefs.current.delete(t),e.agentTerminalQueueRef.current.delete(t),e.agentPaneSizeRef.current.delete(t),e.agentTitleTrackerRef.current.delete(t)},_c=(e,t,n)=>{if(n){e.draftPromptInputRefs.current.set(t,n);return}e.draftPromptInputRefs.current.delete(t)},vc=(e,t)=>{t&&requestAnimationFrame(()=>{let n=e.draftPromptInputRefs.current.get(t);if(n){n.focus();let e=n.value.length;n.setSelectionRange(e,e);return}e.agentTerminalRefs.current.get(t)?.focus()})},yc=(e,t,n,r)=>{let i=e.agentTitleTrackerRef.current.get(t),a=i??{draftSessionId:n.isDraft?n.id:void 0,buffer:``,locked:!1};if(n.isDraft&&i?.draftSessionId!==n.id&&(a.draftSessionId=n.id,a.buffer=``,a.locked=!1),a.locked)return e.agentTitleTrackerRef.current.set(t,a),null;let o=$s(r),s=a.buffer,c=null;for(let e of o){if(e===`\r`||e===`
5
- `){!c&&s.trim()&&(c=s),s=``;continue}if(e===``||e===`\b`){s=s.slice(0,-1);continue}if(e===` `){s+=` `;continue}e<` `||(s+=e,s.length>240&&(s=s.slice(-240)))}return a.buffer=s,e.agentTitleTrackerRef.current.set(t,a),c},bc=({refs:e,paneId:t,tabId:n,sessionId:r,rawInput:i,locale:a,t:o,updateTab:s})=>{let c=Io(i);if(!c)return;let l=!1;if(s(n,e=>({...e,sessions:e.sessions.map(e=>{if(e.id!==r)return e;let t=jo(e.id),n=t===null?null:kn(t,a);return e.isDraft||e.title===o(`draftSessionTitle`)||n!==null&&e.title===n?(l=!0,{...e,title:c}):e})})),!l)return;let u=e.agentTitleTrackerRef.current.get(t);u&&(u.locked=!0,u.buffer=``,e.agentTitleTrackerRef.current.set(t,u))},xc=(e,t,n,r,i)=>{let a=oc(t,n),o=e.agentStartupStateRef.current.get(a);if(!o)return;if(r===`exit`){o.exited=!0,o.lastEventAt=Date.now();return}let s=Qs(i).trim();(r===`stdout`||r===`stderr`||r===`system`&&s!==``&&s!==`Agent started / 智能体已启动`)&&(o.sawOutput=!0,o.lastEventAt=Date.now())},Sc=(e,t,n,r)=>{let i=oc(t,n),a=e.agentStartupStateRef.current.get(i);if(a){if(r===`session_started`){a.sawReady=!0,a.lastEventAt=Date.now();return}r===`session_ended`&&(a.exited=!0,a.lastEventAt=Date.now())}},Cc=async(e,t,n,r)=>{let i=oc(t,n);for(;;){let a=e.agentStartupStateRef.current.get(i);if(!a||a.token!==r)return;let o=Date.now();if(a.exited){pc(e,t,n,r);return}if(a.sawReady&&o-a.lastEventAt>=120){pc(e,t,n,r);return}if(a.sawOutput&&o-a.lastEventAt>=240){pc(e,t,n,r);return}if(!a.sawOutput&&o-a.startedAt>=1200){pc(e,t,n,r);return}if(o-a.startedAt>=5e3){pc(e,t,n,r);return}await new Promise(e=>window.setTimeout(e,80))}},wc=({locale:e,t,route:n,isFocusMode:r,showCodePanel:i,showTerminalPanel:a,workspaceTabs:o,onAddTab:s,onToggleFocusMode:c,onToggleCodePanel:l,onToggleTerminalPanel:u,onFocusAgent:d,onSplitVertical:f,onSplitHorizontal:p,onCycleWorkspace:m,onOpenSettings:h,onCloseSettings:g,onSwitchWorkspace:_})=>[{id:`new-workspace`,label:e===`zh`?`新建工作区`:`New Workspace`,description:e===`zh`?`创建并切换到新的工作区`:`Create and switch to a new workspace`,shortcut:`⌘/Ctrl N`,keywords:`new workspace tab add create`,run:s},{id:`toggle-focus`,label:e===`zh`?r?`退出专注模式`:`进入专注模式`:r?`Exit Focus Mode`:`Enter Focus Mode`,description:e===`zh`?`隐藏左右面板,聚焦命令流`:`Hide side panels and focus the command stream`,shortcut:`F`,keywords:`focus mode zen panel hide`,run:c},{id:`toggle-code`,label:i?e===`zh`?`隐藏代码面板`:`Hide Code Panel`:e===`zh`?`显示代码面板`:`Show Code Panel`,description:e===`zh`?`切换右侧代码预览区域`:`Toggle the right-side code preview area`,keywords:`code panel preview right inspector`,run:l},{id:`toggle-terminal`,label:a?e===`zh`?`隐藏终端面板`:`Hide Terminal Panel`:e===`zh`?`显示终端面板`:`Show Terminal Panel`,description:e===`zh`?`切换右侧终端区域`:`Toggle the right-side terminal area`,keywords:`terminal panel shell dock right`,run:u},{id:`focus-input`,label:e===`zh`?`聚焦当前 Agent`:`Focus Current Agent`,description:e===`zh`?`将光标移动到当前 agent 终端`:`Move cursor to the active agent terminal`,keywords:`agent terminal focus`,run:d},{id:`split-pane-vertical`,label:t(`splitVertical`),description:t(`splitVerticalDescription`),shortcut:`Alt/⌘ D`,keywords:`split pane vertical agent`,run:f},{id:`split-pane-horizontal`,label:t(`splitHorizontal`),description:t(`splitHorizontalDescription`),shortcut:`Shift + Alt/⌘ D`,keywords:`split pane horizontal agent`,run:p},{id:`switch-prev-workspace`,label:e===`zh`?`切换到上一个工作区`:`Switch To Previous Workspace`,description:e===`zh`?`按当前标签顺序回到上一个工作区`:`Jump to the previous workspace tab`,shortcut:`⌘/Ctrl ⇧ [`,keywords:`workspace previous back`,run:()=>m(-1)},{id:`switch-next-workspace`,label:e===`zh`?`切换到下一个工作区`:`Switch To Next Workspace`,description:e===`zh`?`按当前标签顺序前往下一个工作区`:`Jump to the next workspace tab`,shortcut:`⌘/Ctrl ⇧ ]`,keywords:`workspace next forward`,run:()=>m(1)},{id:`open-settings`,label:n===`settings`?e===`zh`?`返回工作区`:`Back To Workspace`:e===`zh`?`打开设置`:`Open Settings`,description:n===`settings`?e===`zh`?`关闭设置并返回工作台`:`Close settings and return to the workbench`:e===`zh`?`打开全局设置面板`:`Open global settings panel`,keywords:`settings preferences`,run:()=>{if(n===`settings`){g();return}h()}},...o.map(t=>({id:`workspace:${t.id}`,label:`${e===`zh`?`切换到`:`Switch To`} ${t.label}`,description:e===`zh`?`直接跳转到该工作区`:`Jump directly to this workspace`,keywords:`workspace ${t.label.toLowerCase()}`,run:()=>_(t.id)}))],Tc=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>`${e.label} ${e.description} ${e.keywords}`.toLowerCase().includes(n)):e},Ec=({container:e,locale:t,isExpanded:n,width:r,codeSidebarView:i,previewPathLabel:a,previewFileName:o,editorContent:s,fileParentLabel:c,sidebar:l,fileSearch:u,onSetSidebarView:d,onToggleExpanded:f,t:p})=>{let m=(0,J.jsx)(Ms,{locale:t,view:l.view,fileTree:l.fileTree,rootPath:l.rootPath,selectedPath:l.selectedPath,repoCollapsedPaths:l.repoCollapsedPaths,gitChangeGroups:l.gitChangeGroups,activeGitChangeKey:l.activeGitChangeKey,commitMessage:l.commitMessage,onCommitMessageChange:l.onCommitMessageChange,onFileSelect:l.onFileSelect,onToggleRepoCollapse:l.onToggleRepoCollapse,onRefresh:l.onRefresh,onStageAll:l.onStageAll,onUnstageAll:l.onUnstageAll,onDiscardAll:l.onDiscardAll,onCommit:l.onCommit,onGitChangeSelect:l.onGitChangeSelect,onGitChangeAction:l.onGitChangeAction,t:p});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Os,{locale:t,isExpanded:n,width:r,codeSidebarView:i,previewPathLabel:a,previewFileName:o,fileSearchQuery:u.query,fileSearchActiveIndex:u.activeIndex,showFileSearchDropdown:u.showDropdown,searchShellRef:u.searchShellRef,fileSearchInputRef:u.inputRef,editorContent:s,sidebarContent:m,onSetSidebarView:d,onFileSearchChange:u.onChange,onFileSearchFocus:u.onFocus,onFileSearchBlur:u.onBlur,onFileSearchKeyDown:u.onKeyDown,onToggleExpanded:f,t:p}),u.showDropdown&&u.dropdownStyle&&e&&(0,J.jsx)(As,{container:e,locale:t,dropdownStyle:u.dropdownStyle,results:u.results,activeIndex:u.activeIndex,onHover:u.onHover,onSelect:u.onSelect,fileParentLabel:c})]})},Dc=({visible:e,progressPercent:t,progressTone:n,activeTerminal:r,terminals:i,shellTerminalRef:a,theme:o,fontSize:s,autoFocus:c,onTerminalData:l,onTerminalSize:u,onResizeStart:d,onSelect:f,onCloseActive:p,onAdd:m,t:h})=>e?(0,J.jsx)(Ns,{progressPercent:t,progressTone:n,activeTerminalId:r?.id,terminals:i,terminalContent:r?(0,J.jsx)(Xs,{ref:a,terminalId:r.id,output:r.output??``,theme:o,fontSize:s,onData:l,onSize:u,autoFocus:c}):(0,J.jsx)(`div`,{className:`terminal-empty`,children:h(`noTerminalYet`)}),onResizeStart:d,onSelect:f,onClose:p,onAdd:m,hasActiveTerminal:!!r,t:h}):null,$=async(e,t)=>Xi(e,t),Oc=(e,t)=>e.type===`wsl`?e.distro?.trim()?`WSL (${e.distro.trim()})`:`WSL`:t(`nativeTarget`),kc=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return e.isContentEditable||t===`INPUT`||t===`TEXTAREA`||t===`SELECT`};function Ac({locale:e,appSettings:t,onOpenSettings:n}){let[r,i]=s(xa),o=Ge(),{workspaceId:c}=qe(),u=`dark`,[d,f]=(0,p.useState)(``),[m,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(null),[v,y]=(0,p.useState)(`status`),[b,x]=(0,p.useState)(`preview`),[S,C]=(0,p.useState)(`files`),[w,ee]=(0,p.useState)(!1),[T,E]=(0,p.useState)(!1),[te,ne]=(0,p.useState)({loading:!1,currentPath:``,homePath:``,roots:[],entries:[]}),[D,re]=(0,p.useState)(!1),[ie,ae]=(0,p.useState)(!1),[oe,se]=(0,p.useState)(``),[ce,O]=(0,p.useState)(0),[k,A]=(0,p.useState)(Ea),[le,ue]=(0,p.useState)({}),[de,fe]=(0,p.useState)(`time`),[pe,me]=(0,p.useState)(()=>new Set),[he,ge]=(0,p.useState)(()=>new Set),[_e,j]=(0,p.useState)(``),[ve,ye]=(0,p.useState)(!1),[be,xe]=(0,p.useState)(null),[Se,Ce]=(0,p.useState)(!1),[we,M]=(0,p.useState)([]),[Te,Ee]=(0,p.useState)(!1),N=(0,p.useRef)(r),De=(0,p.useRef)(null),Oe=(0,p.useRef)(null),ke=(0,p.useRef)(null),Ae=(0,p.useRef)(null),je=(0,p.useRef)(null),Me=(0,p.useRef)(new Map),P=(0,p.useRef)(null),Ne=(0,p.useRef)(null),Pe=(0,p.useRef)(new Map),Fe=(0,p.useRef)(new Map),Ie=(0,p.useRef)(new Map),F=(0,p.useRef)(new Map),Le=(0,p.useRef)(new Map),I=(0,p.useRef)(new Map),Re=(0,p.useRef)({cols:0,rows:0}),ze=(0,p.useRef)(new Set),Be=(0,p.useRef)(new Set),Ve=(0,p.useRef)(``),He=(0,p.useRef)(new Map),Ue=(0,p.useRef)(new Map),We=(0,p.useRef)(0),L=(0,p.useMemo)(()=>Dn(e),[e]),R=(0,p.useMemo)(()=>{if(typeof window>`u`)return{fontSize:13,paddingY:12,terminalFontSize:12};let e=De.current??document.documentElement,t=window.getComputedStyle(e);return{fontSize:Number.parseInt(t.getPropertyValue(`--editor-font-size`),10)||13,paddingY:Number.parseInt(t.getPropertyValue(`--editor-padding-y`),10)||12,terminalFontSize:Number.parseInt(t.getPropertyValue(`--terminal-font-size`),10)||12}},[u]),z=e=>{let t=e(N.current);N.current=t,i(t)},B=(0,p.useMemo)(()=>({draftPromptInputRefs:Me,agentTerminalRefs:Pe,agentTerminalQueueRef:Fe,agentPaneSizeRef:Ie,agentRuntimeSizeRef:F,agentResizeStateRef:Le,agentTitleTrackerRef:I,runningAgentKeysRef:ze,agentStartupStateRef:Ue,agentStartupTokenRef:We}),[]),Ke=()=>{cc(B)},Je=(e,t)=>{gc(B,e,t)},Ye=(e,t)=>{_c(B,e,t)},Xe=(e=N.current.tabs.find(e=>e.id===N.current.activeTabId)?.activePaneId)=>{vc(B,e)},Ze=(t,n,r,i)=>{bc({refs:B,paneId:t,tabId:n,sessionId:r,rawInput:i,locale:e,t:L,updateTab:K})},Qe=()=>{ae(!0),se(``),O(0)},$e=()=>{ae(!1),se(``),O(0)},et=e=>{let t=ta(e);z(e=>({...e,tabs:e.tabs.map(e=>({...e,agent:{...e.agent,provider:t.agentProvider,command:t.agentCommand},idlePolicy:{...t.idlePolicy}}))})),N.current.tabs.forEach(e=>{ds(e.id,t.idlePolicy).catch(()=>{})})};(0,p.useEffect)(()=>{N.current=r},[r]),(0,p.useEffect)(()=>{let n=!1;return(async()=>{let r=await $(()=>co(),null);if(n||!r){n||Ee(!0);return}z(n=>rs(n,r,e,t)),n||Ee(!0)})(),()=>{n=!0}},[t,e]),(0,p.useEffect)(()=>{if(Te){if(c){if(N.current.tabs.find(e=>e.id===c)){N.current.activeTabId!==c&&(Nt(c),$(()=>uo(c),null).then(e=>{e&&z(t=>as(t,e))})),Mt(c);return}let n=!1;return(async()=>{let r=await $(()=>uo(c),null);if(!r||n){n||o(`/workspace`,{replace:!0});return}let i=await $(()=>lo(c),null);if(!i||n){n||o(`/workspace`,{replace:!0});return}z(n=>is(n,i,e,t,r)),Mt(c)})(),()=>{n=!0}}N.current.activeTabId&&o(`/workspace/${N.current.activeTabId}`,{replace:!0})}},[t,Te,e,o,c]),(0,p.useEffect)(()=>{if(!Te)return;let e=JSON.stringify($o(r.layout));Ve.current!==e&&(Ve.current=e,$(()=>po($o(r.layout)),null))},[Te,r.layout.leftWidth,r.layout.rightWidth,r.layout.rightSplit,r.layout.showCodePanel,r.layout.showTerminalPanel]),(0,p.useEffect)(()=>{if(!Te)return;let e=new Set(r.tabs.map(e=>e.id));r.tabs.forEach(e=>{if(e.status!==`ready`||!e.project?.path)return;let t={active_session_id:e.activeSessionId,active_pane_id:e.activePaneId,pane_layout:e.paneLayout,file_preview:e.filePreview},n=JSON.stringify(t);He.current.get(e.id)!==n&&(He.current.set(e.id,n),$(()=>mo(e.id,t),null))}),Array.from(He.current.keys()).forEach(t=>{e.has(t)||He.current.delete(t)})},[Te,r.tabs]),(0,p.useEffect)(()=>{if(!ve)return;let e=e=>{Ae.current?.contains(e.target)||(ye(!1),xe(null))},t=e=>{e.key===`Escape`&&(ye(!1),xe(null))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[ve]),(0,p.useEffect)(()=>{ie&&requestAnimationFrame(()=>{je.current?.focus(),je.current?.select()})},[ie]),(0,p.useEffect)(()=>{r.overlay.visible&&$e()},[r.overlay.visible]),(0,p.useEffect)(()=>{typeof document<`u`&&(document.documentElement.dataset.theme=`dark`)},[]),(0,p.useEffect)(()=>{et(t)},[t]),(0,p.useEffect)(()=>{!T&&N.current.overlay.target.type===`wsl`&&z(e=>({...e,overlay:{...e.overlay,target:{type:`native`}}}))},[T]),(0,p.useEffect)(()=>{!r.overlay.visible||r.overlay.mode===`local`||z(e=>({...e,overlay:{...e.overlay,mode:`local`,input:``}}))},[r.overlay.mode,r.overlay.visible]),(0,p.useEffect)(()=>Bs(({workspace_id:e,session_id:t,kind:n,data:r})=>{xc(B,e,t,n,r);let i=Qs(r),a=n===`stdout`||n===`stderr`,o=n===`system`,s=n===`exit`;z(n=>({...n,tabs:n.tabs.map(n=>n.id===e?{...n,sessions:n.sessions.map(e=>{if(e.id!==t)return e;let c=a?e.status:s?`idle`:e.status,l=s?`
6
- [agent exited]
7
- `:o?i&&i!==`Agent started / 智能体已启动`?`\n[${i}]\n`:``:r,u=`${e.stream}${l}`.slice(-ic),d=s?{id:Q(`msg`),role:`system`,content:L(`agentExited`),time:Ao()}:o?{id:Q(`msg`),role:`system`,content:i,time:Ao()}:null,f=n.activeSessionId===e.id?0:e.unread+(o||s||a?1:0);return{...e,status:c,unread:f,stream:u,messages:d?[...e.messages,d]:e.messages}})}:n)})),n===`exit`&&(mc(B,e,t),Ot(e,t))}),[L]),(0,p.useEffect)(()=>Vs(({workspace_id:e,session_id:t,kind:n,data:r})=>{Sc(B,e,t,n);let i=null;n===`turn_waiting`||n===`approval_required`?i=`waiting`:n===`tool_started`||n===`tool_finished`?i=`running`:(n===`turn_completed`||n===`session_ended`)&&(i=`idle`),n===`session_ended`&&mc(B,e,t),i&&z(n=>({...n,tabs:n.tabs.map(n=>n.id===e?{...n,sessions:n.sessions.map(e=>e.id===t?{...e,status:Bo(n,e,i)}:e)}:n)}));let a=(()=>{try{let e=JSON.parse(r);return typeof e.session_id==`string`&&e.session_id.trim()?e.session_id.trim():null}catch{return null}})();if(a){let n=!1;z(r=>({...r,tabs:r.tabs.map(r=>r.id===e?{...r,sessions:r.sessions.map(e=>e.id!==t||e.claudeSessionId===a?e:(n=!0,{...e,claudeSessionId:a}))}:r)})),n&&kt(e,t,{claude_session_id:a})}n===`turn_completed`&&St(e,t)}),[L]),(0,p.useEffect)(()=>Hs(({workspace_id:e,terminal_id:t,data:n})=>{if(!n)return;let r=`term-${t}`;z(t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,terminals:t.terminals.map(e=>{if(e.id!==r)return e;let t=`${e.output}${n}`.slice(-ac);return{...e,output:t}})}:t)}))}),[]);let V=(0,p.useMemo)(()=>{let n=r.tabs.find(e=>e.id===r.activeTabId)??r.tabs[0];if(n)return n;if(!Ne.current){let n=fa(1,e);Ne.current={...n,agent:{...n.agent,provider:t.agentProvider,command:t.agentCommand},idlePolicy:{...t.idlePolicy}}}return Ne.current},[t.agentCommand,t.agentProvider,t.idlePolicy,e,r.activeTabId,r.tabs]),tt=r.tabs.length>0,nt=r.layout.showCodePanel,H=r.layout.showTerminalPanel,rt=(0,p.useMemo)(()=>V.sessions.find(e=>e.id===V.activeSessionId)??V.sessions[0],[V]),it=(0,p.useMemo)(()=>wo(V.paneLayout,V.activePaneId)??V.activeSessionId,[V]),at=(0,p.useMemo)(()=>V.sessions.find(e=>e.id===it)??rt,[it,rt,V.sessions]),ot=(0,p.useMemo)(()=>V.sessions.map(e=>e.id).join(`|`),[V.sessions]),st=k.query,ct=k.activeIndex,lt=k.dropdownStyle,ut=Da(k.query),U=(0,p.useMemo)(()=>Oa(V.fileTree,V.project?.path,k.query),[V.fileTree,V.project?.path,k.query]),dt=ka(k);(0,p.useEffect)(()=>{A(e=>Aa(e,U.length))},[U.length,ut]),(0,p.useEffect)(()=>{if(!dt){A(e=>Ra(e,null));return}let e=()=>{let e=Oe.current;e&&A(t=>Ra(t,za(e.getBoundingClientRect(),window.innerWidth,window.innerHeight)))};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[dt,r.layout.rightWidth,nt,w]),(0,p.useEffect)(()=>{if(!dt)return;let e=e=>{let t=e.target;t instanceof Node&&(Oe.current?.contains(t)||t.closest?.(`.workspace-search-dropdown`)||A(e=>Na(e)))};return document.addEventListener(`pointerdown`,e),()=>{document.removeEventListener(`pointerdown`,e)}},[dt]);let ft=t=>Fn(t,e),pt=t=>Pn(t,e),mt=t=>In(t,e),ht=!!V.filePreview.path,gt=V.viewingArchiveId?V.archive.find(e=>e.id===V.viewingArchiveId):void 0,_t=gt?gt.snapshot:rt,W=!!gt,vt=W?_t:rt;Qs(vt.stream),(0,p.useEffect)(()=>{K(V.id,e=>{let t=Co(e.paneLayout),n=new Set(t.map(e=>e.sessionId)),r=e.sessions.filter(e=>!n.has(e.id));if(r.length===0)return e;let i=e.paneLayout;r.forEach(e=>{let t=la(e.id);i={type:`split`,id:Q(`split`),axis:`vertical`,ratio:.5,first:i,second:t}});let a=To(i,e.activeSessionId)??Co(i)[0]?.id??e.activePaneId;return{...e,paneLayout:i,activePaneId:a}})},[V.id,ot]);let G=e=>{h(t=>[...t,e]),setTimeout(()=>{h(t=>t.filter(t=>t.id!==e.id))},4e3)},yt=async(e,t,n)=>{try{return await e()}catch(e){return G({id:Q(`toast`),text:`${n}: ${String(e)}`,sessionId:t}),null}},K=(e,t)=>{z(n=>({...n,tabs:n.tabs.map(n=>n.id===e?t(n):n)}))},{archiveSessionForTab:bt,createDraftSessionForTab:xt,markSessionIdle:St,materializeSession:Ct,onCloseAgentPane:wt,onNewSession:Tt,onSwitchSession:Et,refreshTabFromBackend:Dt,settleSessionAfterExit:Ot,syncSessionPatch:kt,touchSession:At}=fs({appSettings:t,locale:e,t:L,stateRef:N,updateTab:K,withServiceFallback:$,addToast:G}),jt=async e=>{let t=N.current.tabs.find(t=>t.id===e),n=t?.project?.path,r=t?.project?.target;if(!t||!n||!r)return null;let[i,a,o,s]=await Promise.all([$(()=>_o(n,r),{branch:t.git.branch||`main`,changes:t.git.changes??0,last_commit:t.git.lastCommit||`—`}),$(()=>Ga(n,r),t.gitChanges??[]),$(()=>go(n,r),t.worktrees),$(()=>ho(n,r,4),{root:{name:`.`,path:n,kind:`dir`,children:[]},changes:[]})]);return K(e,e=>({...e,git:{branch:i.branch||e.git.branch||`main`,changes:i.changes??e.git.changes??0,lastCommit:i.last_commit||e.git.lastCommit||`—`},gitChanges:a,worktrees:o,fileTree:s.root.children??[],changesTree:s.changes??[]})),s},Mt=(0,p.useCallback)(async t=>{let n=N.current.tabs.find(e=>e.id===t);!n?.project?.path||n.terminals.length>0||Be.current.has(t)||(Be.current.add(t),await ys({tab:n,locale:e,updateTab:K,withServiceFallback:$,addToast:G,activeSessionId:n.activeSessionId,createToastId:()=>Q(`toast`),t:L})||Be.current.delete(t))},[e,L]),Nt=e=>{z(t=>{if(!t.tabs.find(t=>t.id===e))return t;let n=t.activeTabId;return{...t,activeTabId:e,overlay:{...t.overlay,visible:!1},tabs:t.tabs.map(t=>t.id===e?{...t,sessions:t.sessions.map(e=>e.id===t.activeSessionId?{...e,unread:0,status:zo(e),lastActiveAt:Date.now()}:e)}:t.id===n?{...t,sessions:t.sessions.map(e=>e.id===t.activeSessionId?{...e,status:Ro(e.status)}:e)}:t)}})},Pt=()=>{z(e=>({...e,overlay:{...e.overlay,visible:!0,mode:`local`,input:``,target:e.overlay.target}})),tt||o(`/workspace`,{replace:!0})},Ft=async e=>{let t=N.current.tabs,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t.filter(t=>t.id!==e).map(e=>e.id),i=await $(()=>fo(e),{open_workspace_ids:r,active_workspace_id:N.current.activeTabId===e?r[Math.max(0,n-1)]??r[0]??null:N.current.activeTabId,layout:$o(N.current.layout)});if(Be.current.delete(e),z(e=>{let t=as(e,i);return{...t,overlay:{...t.overlay,visible:t.tabs.length===0}}}),i.active_workspace_id){o(`/workspace/${i.active_workspace_id}`),Mt(i.active_workspace_id);return}o(`/workspace`)},It=e=>{N.current.tabs.find(t=>t.id===e)&&(Nt(e),o(`/workspace/${e}`),$(()=>uo(e),null).then(e=>{e&&z(t=>as(t,e))}),Mt(e))},Lt=e=>{let t=N.current.tabs;if(t.length<2)return;let n=t.findIndex(e=>e.id===N.current.activeTabId);n<0||It(t[(n+(e>=0?1:-1)+t.length)%t.length].id)},Rt=e=>{z(t=>Va(t,e))},zt=(0,p.useCallback)(async(t,n,r=!1)=>{await Ha({target:t,path:n,selectCurrent:r,locale:e,t:L,setFolderBrowser:ne,setOverlayCanUseWsl:E,updateOverlayInput:e=>{z(t=>Ba(t,e))}})},[e,L]),Bt=(e,t=!1)=>{zt(N.current.overlay.target,e,t)};(0,p.useEffect)(()=>{!r.overlay.visible||r.overlay.mode!==`local`||zt(r.overlay.target,r.overlay.input||void 0,!r.overlay.input)},[r.overlay.visible,r.overlay.mode,r.overlay.target.type,r.overlay.target.type===`wsl`?r.overlay.target.distro:``,zt]);let Vt=async()=>{let n=await os({overlay:N.current.overlay,locale:e,appSettings:t,updateState:z,withServiceFallback:$,refreshWorkspaceArtifacts:jt});n&&(o(`/workspace/${n.workspaceId}`),Mt(n.workspaceId),n.firstFile&&await Jt(n.firstFile,n.workspaceId))},Ht=e=>{let t=e.project?.path??``;return e.agent.command.replace(`{path}`,t)},Ut=async(e,t)=>{let n=e.project;if(!n?.path)return!1;let r=Ht(e),i=n.target,a=await $(()=>Qi(r,i,n.path),null);if(a&&!a.available)return G({id:Q(`toast`),text:`${L(`agentStartFailed`)}: ${a.error??L(`launchCommandMissing`,{runtime:Oc(i,L)})}`,sessionId:t.id}),!1;let o=fc(B,e.id,t.id),s=await yt(()=>tc({workspaceId:e.id,sessionId:t.id,provider:e.agent.provider,command:r}),t.id,L(`agentStartFailed`));return s?(hc(B,e.id,t.id),s.started||pc(B,e.id,t.id,o),{ok:!0,started:s.started,startupToken:s.started?o:null}):(pc(B,e.id,t.id,o),!1)},Wt=async(e,t,n)=>{let r=Date.now();return K(e.id,e=>({...e,sessions:e.sessions.map(e=>e.id===t.id?{...e,lastActiveAt:r}:e)})),kt(e.id,t.id,{last_active_at:r}),await yt(()=>nc(e.id,t.id,n,!1),t.id,L(`agentKeySendFailed`))!==null},Gt=e=>{Et(V,e)},Kt=(e,t)=>{wt(V,e,t)},qt=()=>{K(V.id,e=>({...e,viewingArchiveId:void 0}))},Jt=async(e,t)=>{if(e.kind!==`file`)return;let n=N.current.tabs.find(e=>e.id===(t??V.id))??V,r=e.path.split(/[\/]+/).filter(Boolean);r.length>1&&me(e=>{let t=new Set(e),n=``;for(let e of r.slice(0,-1))n=n?`${n}/${e}`:e,t.add(n);return t}),await ro({tab:n,node:e,updateTab:K,withServiceFallback:$,t:L}),j(``),x(`preview`)},Yt=async(e,t)=>{await io({tab:N.current.tabs.find(e=>e.id===V.id)??V,path:e,updateTab:K,withServiceFallback:$,t:L,options:t}),(t?.clearGitSelection??!1)&&j(``),x(`preview`)},Xt=async e=>{A(e=>Pa(e)),C(`files`),await Jt(e),requestAnimationFrame(()=>{ke.current?.blur()})},Zt=()=>{requestAnimationFrame(()=>{let e=document.activeElement;e instanceof Node&&Oe.current?.contains(e)||A(e=>Na(e))})},Qt=e=>{if(ut){if(e.key===`ArrowDown`){e.preventDefault(),A(e=>Fa(e,1,U.length));return}if(e.key===`ArrowUp`){e.preventDefault(),A(e=>Fa(e,-1,U.length));return}if(e.key===`Enter`){if(!U.length)return;e.preventDefault(),Xt((U[ct]??U[0]).node);return}e.key===`Escape`&&(e.preventDefault(),A(e=>Na(e)))}},$t=async e=>{let t=await vo({tab:N.current.tabs.find(e=>e.id===V.id)??V,change:e,updateTab:K,withServiceFallback:$});x(`diff`),j(t)},en=async(e,t)=>{let n=N.current.tabs.find(e=>e.id===V.id)??V,r=Cr(e.path),i={path:n.project?.path??``,target:n.project?.target??{type:`native`},filePath:r};if(t===`stage`){await an(()=>Ya(i.path,i.target,i.filePath));return}if(t===`unstage`){await an(()=>Xa(i.path,i.target,i.filePath));return}await an(()=>Za(i.path,i.target,i.filePath,e.section))},tn=e=>{K(V.id,t=>({...t,filePreview:{...t.filePreview,content:e,dirty:!0}}))},nn=async e=>{if(x(e),e===`preview`)return;let t=N.current.tabs.find(e=>e.id===V.id)??V;await jt(t.id),await ao({tab:t,updateTab:K,withServiceFallback:$})},rn=async()=>{await oo({tab:N.current.tabs.find(e=>e.id===V.id)??V,activeSessionId:rt.id,updateTab:K,withServiceFallback:$,refreshWorkspaceArtifacts:jt,addToast:G,t:L,createToastId:()=>Q(`toast`)})},an=async e=>yo({tab:N.current.tabs.find(e=>e.id===V.id)??V,activeSessionId:rt.id,selectedGitChangeKey:_e,previewMode:b,updateTab:K,refreshWorkspaceArtifacts:jt,onSelectGitChange:async e=>{await $t(e)},onReloadRepositoryDiff:async()=>{await nn(`diff`)},onClearPreviewSelection:()=>{j(``),x(`preview`)},addToast:G,t:L,createToastId:()=>Q(`toast`),getCurrentTab:e=>N.current.tabs.find(t=>t.id===e),operation:e}),on=async()=>{let e=N.current.tabs.find(e=>e.id===V.id)??V;await an(()=>Qa(e.project?.path??``,e.project?.target??{type:`native`}))},sn=async()=>{let e=N.current.tabs.find(e=>e.id===V.id)??V;await an(()=>$a(e.project?.path??``,e.project?.target??{type:`native`}))},cn=async()=>{let e=N.current.tabs.find(e=>e.id===V.id)??V;await an(()=>eo(e.project?.path??``,e.project?.target??{type:`native`}))&&(K(e.id,e=>({...e,filePreview:ca()})),x(`preview`))},ln=async()=>{if(!d.trim())return;let e=N.current.tabs.find(e=>e.id===V.id)??V;await an(()=>to(e.project?.path??``,e.project?.target??{type:`native`},d.trim()))&&(f(``),G({id:Q(`toast`),text:L(`gitCommitSucceeded`),sessionId:rt.id}))},un=async()=>{await ys({tab:N.current.tabs.find(e=>e.id===V.id)??V,locale:e,updateTab:K,withServiceFallback:$,addToast:G,activeSessionId:rt.id,createToastId:()=>Q(`toast`),t:L})},dn=e=>{bs(K,V.id,e)},fn=async e=>{await xs(N.current.tabs.find(e=>e.id===V.id)??V,e,K,$)},pn=e=>t=>{Ko({event:t,type:e,stateRef:N,updateState:z,shellTerminalRef:P,fitAgentTerminals:Ke})},mn=e=>{z(t=>Uo(t,e)),e===`code`&&ee(!1),requestAnimationFrame(()=>{P.current?.fit()})},q=V.terminals.find(e=>e.id===V.activeTerminalId)??V.terminals[0],hn=!w,gn=async()=>{w&&(S===`git`&&V.filePreview.mode===`diff`&&V.filePreview.path&&await Yt(V.filePreview.path,{clearGitSelection:!1,statusLabel:V.filePreview.statusLabel,parentPath:V.filePreview.parentPath}),C(`files`)),ee(e=>!e)},_n=(e,t)=>{Wo(K,V.id,e,t)},vn=(e,t)=>{Go({tab:V,paneId:e,axis:t,updateTab:K,createDraftSessionForTab:xt,onFocusPane:Xe})},yn=(e,t)=>n=>{qo({event:n,tabId:V.id,paneLayout:V.paneLayout,splitId:e,axis:t,updateTab:K,fitAgentTerminals:Ke})},bn=e=>{e&&($e(),e.run())},xn=async e=>{if(W)return null;let t=N.current.tabs.find(e=>e.id===N.current.activeTabId);if(!t)return null;let n=wo(t.paneLayout,e)??t.activeSessionId,r=t.sessions.find(e=>e.id===n);if(!r)return null;let i=Po(r)?await Ct(t.id,r.id,``):{tab:t,session:r},a=i?.tab??t,o=i?.session??r;if(!a||!o)return null;if(!sc(B,a.id,o.id)){let t=await Ut(a,o);if(!t)return null;t.started&&dc(B,e,a.id,o.id),t.started&&t.startupToken!==null&&await Cc(B,a.id,o.id,t.startupToken)}return dc(B,e,a.id,o.id),At(a.id,o.id),{tab:a,session:o}},Sn=async(e,t)=>{if(W||!t)return;let n=N.current.tabs.find(e=>e.id===N.current.activeTabId),r=n?wo(n.paneLayout,e)??n.activeSessionId:null,i=r&&n?n.sessions.find(e=>e.id===r)??null:null,a=i?yc(B,e,i,t):null,o=(Fe.current.get(e)??Promise.resolve()).catch(()=>void 0).then(async()=>{let n=await xn(e);n&&(a&&Ze(e,n.tab.id,n.session.id,a),await Wt(n.tab,n.session,t))});Fe.current.set(e,o),await o},Cn=async e=>{let t=(le[e]??``).trim();t&&(ue(t=>({...t,[e]:``})),await Sn(e,t),await Sn(e,`\r`))};(0,p.useEffect)(()=>{let e=e=>{let t=e.key.toLowerCase(),n=e.metaKey||e.ctrlKey,r=kc(e.target);if(n&&t===`k`){e.preventDefault(),ie?$e():(Qe(),ye(!1),xe(null));return}if(ie){e.key===`Escape`&&(e.preventDefault(),$e());return}if(n&&t===`s`){if(!V.filePreview.path)return;e.preventDefault(),rn();return}if(n&&t===`n`){e.preventDefault(),Pt();return}if(n&&e.shiftKey&&(e.key===`[`||e.key===`{`)){e.preventDefault(),Lt(-1);return}if(n&&e.shiftKey&&(e.key===`]`||e.key===`}`)){e.preventDefault(),Lt(1);return}if(!n&&!e.altKey&&!e.shiftKey&&t===`f`&&!r&&!W){e.preventDefault(),re(e=>!e);return}if(!n&&!e.altKey&&!e.shiftKey&&e.key===`Escape`&&D){e.preventDefault(),re(!1);return}if(W||!(typeof navigator<`u`&&(navigator.platform||``).toLowerCase().includes(`mac`)?e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`d`:e.altKey&&!e.ctrlKey&&!e.metaKey&&t===`d`)||e.repeat)return;e.preventDefault();let i=e.shiftKey?`horizontal`:`vertical`;vn(V.activePaneId,i),ye(!1),xe(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[V.activePaneId,V.filePreview.path,V.filePreview.dirty,V.filePreview.content,rt.id,ie,W,D]),(0,p.useEffect)(()=>{W||Xe()},[V.activePaneId,at.id,W]),(0,p.useEffect)(()=>{f(``),j(``),ye(!1),xe(null)},[V.id]),(0,p.useEffect)(()=>{V.project?.path&&jt(V.id)},[S,V.id,V.project?.path]),(0,p.useEffect)(()=>{V.project?.path&&Mt(V.id)},[V.id,V.project?.path,Mt]),(0,p.useEffect)(()=>{if(!V.project?.path)return;let e=window.setInterval(()=>{jt(V.id)},4e3);return()=>window.clearInterval(e)},[V.id,V.project?.path]);let wn=(0,p.useCallback)(e=>{_s(Re,V.id,q?.id,e.cols,e.rows)},[q?.id,V.id]),Tn=(0,p.useCallback)(e=>{vs(V.id,q?.id,e)},[q?.id,V.id]),En=(0,p.useCallback)((e,t,n,r)=>{Ie.current.set(e,r),sc(B,t,n)&&uc(B,t,n,r)},[]);(0,p.useEffect)(()=>{!H||w||requestAnimationFrame(()=>{P.current?.fit()})},[H,w,r.layout.rightSplit]),(0,p.useEffect)(()=>{q&&H&&!w&&P.current?.focus()},[q?.id,H,w]),(0,p.useEffect)(()=>{q||(Re.current={id:void 0,cols:0,rows:0})},[q?.id]);let On={"--left-w":`${r.layout.leftWidth}px`,"--right-w":`${r.layout.rightWidth}px`,"--right-split":`${r.layout.rightSplit}%`},kn=r.tabs.map(t=>{let n=[...t.sessions].sort((t,n)=>de===`name`?pt(t.title).localeCompare(pt(n.title),e===`zh`?`zh-CN`:`en`):n.lastActiveAt-t.lastActiveAt),i=n.some(e=>[`running`,`waiting`,`background`].includes(e.status)),a=n.reduce((e,t)=>e+t.unread,0);return{id:t.id,label:Dr(t.project?.path)||ft(t.title),active:t.id===r.activeTabId,hasRunning:i,unread:a,sessions:n}}),An=Tc(wc({locale:e,t:L,route:`workspace`,isFocusMode:D,showCodePanel:nt,showTerminalPanel:H,workspaceTabs:kn,onAddTab:Pt,onToggleFocusMode:()=>re(e=>!e),onToggleCodePanel:()=>mn(`code`),onToggleTerminalPanel:()=>mn(`terminal`),onFocusAgent:()=>Xe(),onSplitVertical:()=>vn(V.activePaneId,`vertical`),onSplitHorizontal:()=>vn(V.activePaneId,`horizontal`),onCycleWorkspace:Lt,onOpenSettings:n,onCloseSettings:()=>{},onSwitchWorkspace:It}),oe),jn=An[ce]??An[0];(0,p.useEffect)(()=>{if(!An.length){O(0);return}O(e=>Math.min(e,An.length-1))},[An.length]);let Mn=bo(V.gitChanges,L),Nn=xo(V.filePreview.path,V.gitChanges),Ln=Nn?`${Nn.section}:${Nn.path}:${Nn.code}`:_e;Mn.find(e=>e.key===`changes`)?.items.length,Mn.find(e=>e.key===`staged`)?.items.length,Mn.find(e=>e.key===`untracked`)?.items.length;let Rn=Dr(V.filePreview.path),zn=Dr(V.project?.path)||L(`noWorkspace`),Bn=So(V.filePreview.path,V.project?.path,Rn),Vn=V.git.changes,Hn=!!(V.filePreview.originalContent&&V.filePreview.originalContent.length>0||V.filePreview.modifiedContent&&V.filePreview.modifiedContent.length>0),Un=!!q?.output?.trim(),Wn=q?Un?88:52:8,Gn=q?Un?`live`:`steady`:`idle`,Kn=(0,J.jsx)(ec,{visible:hn,activeTab:V,activePaneSession:at,viewedSession:vt,isArchiveView:W,showCodePanel:nt,theme:u,terminalFontSize:R.terminalFontSize,draftPromptInputs:le,displaySessionTitle:pt,onExitArchive:qt,onSetActivePane:_n,onSplitPane:vn,onCloseAgentPane:Kt,onSubmitDraftPrompt:e=>{Cn(e)},onDraftPromptChange:(e,t)=>{ue(n=>({...n,[e]:t}))},setDraftPromptInputRef:Ye,setAgentTerminalRef:Je,onAgentTerminalData:(e,t)=>{Sn(e,t)},onAgentTerminalSize:En,onPaneSplitResizeStart:yn,onCodeResizeStart:pn(`left`),t:L}),qn=ht?V.filePreview.mode===`diff`?V.filePreview.source===`git`&&V.filePreview.section&&Hn?(0,J.jsx)(`div`,{className:`editor-surface diff-editor-surface`,"data-testid":`preview-diff-editor`,children:(0,J.jsx)(a,{height:`100%`,original:V.filePreview.originalContent??``,modified:V.filePreview.modifiedContent??``,originalModelPath:`${V.filePreview.path}.original`,modifiedModelPath:V.filePreview.path,language:Ca(V.filePreview.path),theme:`vs-dark`,options:{automaticLayout:!0,readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6,useShadows:!1,alwaysConsumeMouseWheel:!1},wordWrap:`on`,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, monospace`,fontSize:R.fontSize,lineNumbersMinChars:3,renderWhitespace:`selection`}},`${V.filePreview.path}:${V.filePreview.section??`diff`}`)}):(0,J.jsx)(`pre`,{className:`diff code-surface`,children:V.filePreview.diff||L(`noDiffAvailable`)}):(0,J.jsx)(`div`,{className:`editor-surface`,"data-testid":`preview-editor`,children:(0,J.jsx)(l,{height:`100%`,path:V.filePreview.path,language:Ca(V.filePreview.path),value:V.filePreview.content,onChange:e=>tn(e??``),theme:`vs-dark`,options:{automaticLayout:!0,fontFamily:`JetBrains Mono, Cascadia Mono, ui-monospace, monospace`,fontSize:R.fontSize,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6,useShadows:!1,alwaysConsumeMouseWheel:!1},wordWrap:`on`,padding:{top:R.paddingY,bottom:R.paddingY},lineNumbersMinChars:3,renderWhitespace:`selection`}},V.filePreview.path)}):(0,J.jsx)(`div`,{className:`preview-empty`,children:L(`selectFileFromNavigator`)}),Jn=nt?(0,J.jsx)(Ec,{container:De.current,locale:e,isExpanded:w,width:r.layout.rightWidth,codeSidebarView:S,previewPathLabel:Bn,previewFileName:Rn,editorContent:qn,fileParentLabel:Er,sidebar:{view:S,fileTree:V.fileTree,rootPath:V.project?.path,selectedPath:V.filePreview.path,repoCollapsedPaths:pe,gitChangeGroups:Mn,activeGitChangeKey:Ln,commitMessage:d,onCommitMessageChange:f,onFileSelect:Jt,onToggleRepoCollapse:e=>{me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onRefresh:()=>{jt(V.id)},onStageAll:()=>{on()},onUnstageAll:()=>{sn()},onDiscardAll:()=>{cn()},onCommit:()=>{ln()},onGitChangeSelect:e=>{$t(e)},onGitChangeAction:(e,t)=>{en(e,t)}},fileSearch:{query:st,activeIndex:ct,showDropdown:dt,dropdownStyle:lt,results:U.map(({node:e})=>e),searchShellRef:Oe,inputRef:ke,onChange:e=>{A(t=>ja(t,e))},onFocus:e=>{A(t=>Ma(t,e))},onBlur:Zt,onKeyDown:Qt,onHover:e=>{A(t=>Ia(t,e))},onSelect:e=>{let t=U.find(t=>t.node.absolutePath===e.absolutePath)?.node??U.find(t=>t.node.path===e.path)?.node;t&&Xt(t)}},onSetSidebarView:C,onToggleExpanded:()=>{gn()},t:L}):null,Yn=(0,J.jsx)(Dc,{visible:!w&&H,progressPercent:Wn,progressTone:Gn,activeTerminal:q?{id:q.id,output:q.output??``}:void 0,terminals:V.terminals.map(e=>({id:e.id,title:mt(e.title)})),shellTerminalRef:P,theme:u,fontSize:R.terminalFontSize,autoFocus:H&&!w,onTerminalData:Tn,onTerminalSize:wn,onResizeStart:pn(`right-split`),onSelect:dn,onCloseActive:()=>{q&&fn(q.id)},onAdd:()=>{un()},t:L});return(0,J.jsxs)(`div`,{ref:De,className:`app`,style:On,"data-theme":u,children:[(0,J.jsx)(Yi,{isSettingsRoute:!1,locale:e,workspaceTabs:kn,onSwitchWorkspace:It,onAddTab:Pt,onRemoveTab:Ft,onOpenSettings:n,onCloseSettings:()=>{},onOpenCommandPalette:Qe,t:L}),(0,J.jsx)(js,{locale:e,isFocusMode:D,isCodeExpanded:w,showAgentPanel:hn,showCodePanel:nt,showTerminalPanel:H,rightSplit:r.layout.rightSplit,workspaceFolderName:zn,branchName:V.git.branch,changeCount:Vn,agentPanel:Kn,codePanel:Jn,terminalPanel:Yn,onToggleRightPane:mn,t:L}),ie&&(0,J.jsx)(ws,{locale:e,inputRef:je,query:oe,activeIndex:ce,actions:An,activeAction:jn,onClose:$e,onQueryChange:se,onActivateIndex:O,onRunAction:bn}),(0,J.jsx)(`div`,{className:`toast-container`,children:m.map(e=>(0,J.jsx)(`button`,{className:`toast`,onClick:()=>Gt(e.sessionId),children:e.text},e.id))}),g&&(0,J.jsx)(Es,{locale:e,worktree:g,view:v,collapsedPaths:he,onClose:()=>_(null),onViewChange:y,onFileSelect:Jt,onToggleCollapse:e=>{ge(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t:L}),(0,J.jsx)(Ds,{visible:r.overlay.visible,target:r.overlay.target,input:r.overlay.input,canUseWsl:T,folderBrowser:te,onUpdateTarget:Rt,onBrowseDirectory:Bt,onStartWorkspace:Vt,t:L})]})}function jc(){let[e,t]=(0,p.useState)(()=>wn()),[n,r]=(0,p.useState)(()=>na()),[i,a]=(0,p.useState)(`/workspace`),o=Ge(),s=R(),c=s.pathname===`/settings`?`settings`:`workspace`;(0,p.useEffect)(()=>{Tn(e)},[e]),(0,p.useEffect)(()=>{try{ra(n)}catch{}},[n]),(0,p.useEffect)(()=>{s.pathname.startsWith(`/workspace`)&&a(s.pathname||`/workspace`)},[s.pathname]);let l=e=>{o(e===`settings`?`/settings`:i)},u=e=>{t(e),En(e)};return(0,J.jsx)(Ar,{locale:e,onSelectLocale:u,children:(0,J.jsxs)(_t,{children:[(0,J.jsx)(ht,{path:`/`,element:(0,J.jsx)(mt,{to:`/workspace`,replace:!0})}),(0,J.jsx)(ht,{path:`/workspace`,element:(0,J.jsx)(Ac,{locale:e,appSettings:n,onOpenSettings:()=>l(`settings`)})}),(0,J.jsx)(ht,{path:`/workspace/:workspaceId`,element:(0,J.jsx)(Ac,{locale:e,appSettings:n,onOpenSettings:()=>l(`settings`)})}),(0,J.jsx)(ht,{path:`/settings`,element:(0,J.jsx)(Cs,{locale:e,appSettings:n,onSelectLocale:u,onCommitSettings:e=>{r(ta(e))},onCloseSettings:()=>o(i)})}),(0,J.jsx)(ht,{path:`*`,element:(0,J.jsx)(mt,{to:c===`settings`?`/settings`:i,replace:!0})})]})})}function Mc(){return(0,J.jsx)(en,{children:(0,J.jsx)(jc,{})})}f.createRoot(document.getElementById(`root`)).render((0,J.jsx)(p.StrictMode,{children:(0,J.jsx)(r,{children:(0,J.jsx)(Mc,{})})}));