@jingyi0605/codingns 0.3.0 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/{TerminalPage-Dfw1QUqW.js → TerminalPage-CgrfstRm.js} +19 -19
- package/dist/public/assets/index-Cek6u0b9.css +1 -0
- package/dist/public/assets/index-THHY79si.js +122 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +2 -0
- package/dist/server/config/env.js +35 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/auth/auth-service.d.ts +18 -1
- package/dist/server/modules/auth/auth-service.js +168 -7
- package/dist/server/modules/auth/auth-service.js.map +1 -1
- package/dist/server/modules/butler/butler-codex-model-policy.d.ts +1 -0
- package/dist/server/modules/butler/butler-codex-model-policy.js +36 -0
- package/dist/server/modules/butler/butler-codex-model-policy.js.map +1 -0
- package/dist/server/modules/butler/butler-control-session-service.d.ts +13 -1
- package/dist/server/modules/butler/butler-control-session-service.js +55 -231
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-controller.d.ts +17 -0
- package/dist/server/modules/butler/butler-controller.js +20 -1
- package/dist/server/modules/butler/butler-controller.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.js +7 -3
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-analysis-service.d.ts +36 -0
- package/dist/server/modules/butler/butler-inbox-analysis-service.js +375 -0
- package/dist/server/modules/butler/butler-inbox-analysis-service.js.map +1 -0
- package/dist/server/modules/butler/butler-inbox-instruction-adapter.d.ts +23 -0
- package/dist/server/modules/butler/butler-inbox-instruction-adapter.js +96 -0
- package/dist/server/modules/butler/butler-inbox-instruction-adapter.js.map +1 -0
- package/dist/server/modules/butler/butler-inbox-service.d.ts +39 -2
- package/dist/server/modules/butler/butler-inbox-service.js +392 -2
- package/dist/server/modules/butler/butler-inbox-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +8 -0
- package/dist/server/modules/butler/butler-session-service.js +205 -53
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-summary-service.d.ts +1 -0
- package/dist/server/modules/butler/butler-session-summary-service.js +48 -23
- package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.d.ts +13 -0
- package/dist/server/modules/butler/butler-workspace-context.js +223 -0
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -0
- package/dist/server/modules/client/client-controller.d.ts +6 -0
- package/dist/server/modules/client/client-controller.js +30 -8
- package/dist/server/modules/client/client-controller.js.map +1 -1
- package/dist/server/modules/client/client-service.d.ts +22 -10
- package/dist/server/modules/client/client-service.js +77 -100
- package/dist/server/modules/client/client-service.js.map +1 -1
- package/dist/server/modules/client/npm-global-package-service.d.ts +21 -0
- package/dist/server/modules/client/npm-global-package-service.js +210 -0
- package/dist/server/modules/client/npm-global-package-service.js.map +1 -0
- package/dist/server/modules/client/service-update-task-service.d.ts +15 -0
- package/dist/server/modules/client/service-update-task-service.js +147 -0
- package/dist/server/modules/client/service-update-task-service.js.map +1 -0
- package/dist/server/modules/client/service-update-types.d.ts +30 -0
- package/dist/server/modules/client/service-update-types.js +2 -0
- package/dist/server/modules/client/service-update-types.js.map +1 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.d.ts +36 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +317 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -0
- package/dist/server/modules/model-switch/model-switch-controller.d.ts +11 -0
- package/dist/server/modules/model-switch/model-switch-controller.js +30 -0
- package/dist/server/modules/model-switch/model-switch-controller.js.map +1 -0
- package/dist/server/modules/model-switch/model-switch-service.d.ts +16 -0
- package/dist/server/modules/model-switch/model-switch-service.js +29 -0
- package/dist/server/modules/model-switch/model-switch-service.js.map +1 -0
- package/dist/server/modules/preferences/profile-service.d.ts +1 -0
- package/dist/server/modules/preferences/profile-service.js +9 -0
- package/dist/server/modules/preferences/profile-service.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +3 -0
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/session-activity-authority-service.d.ts +3 -1
- package/dist/server/modules/sessions/session-activity-authority-service.js +3 -0
- package/dist/server/modules/sessions/session-activity-authority-service.js.map +1 -1
- package/dist/server/modules/sessions/session-activity-inspector.d.ts +1 -1
- package/dist/server/modules/sessions/session-activity-inspector.js +43 -16
- package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.d.ts +3 -3
- package/dist/server/modules/sessions/session-controller.js +3 -3
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +3 -0
- package/dist/server/modules/sessions/session-history-service.js +259 -39
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +7 -3
- package/dist/server/modules/sessions/session-live-runtime-service.js +47 -11
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-message-attachment-service.d.ts +8 -8
- package/dist/server/modules/sessions/session-message-attachment-service.js +25 -34
- package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-error-mapper.js +7 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
- package/dist/server/modules/tailscale/tailscale-manager.js +5 -1
- package/dist/server/modules/tailscale/tailscale-manager.js.map +1 -1
- package/dist/server/modules/tasks/task-lane-executors.js +3 -0
- package/dist/server/modules/tasks/task-lane-executors.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +3 -1
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/command-template-service.js +10 -1
- package/dist/server/modules/terminal/command-template-service.js.map +1 -1
- package/dist/server/modules/terminal/template-port-runtime.d.ts +12 -1
- package/dist/server/modules/terminal/template-port-runtime.js +189 -17
- package/dist/server/modules/terminal/template-port-runtime.js.map +1 -1
- package/dist/server/modules/terminal/terminal-service.js +30 -3
- package/dist/server/modules/terminal/terminal-service.js.map +1 -1
- package/dist/server/modules/workspace/workspace-code-composition.js +95 -2
- package/dist/server/modules/workspace/workspace-code-composition.js.map +1 -1
- package/dist/server/routes/butler.js +4 -0
- package/dist/server/routes/butler.js.map +1 -1
- package/dist/server/routes/client.js +2 -0
- package/dist/server/routes/client.js.map +1 -1
- package/dist/server/routes/sessions.js +1 -1
- package/dist/server/routes/sessions.js.map +1 -1
- package/dist/server/routes/system.d.ts +2 -1
- package/dist/server/routes/system.js +3 -1
- package/dist/server/routes/system.js.map +1 -1
- package/dist/server/server/create-server.d.ts +4 -0
- package/dist/server/server/create-server.js +51 -7
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/errors/app-error.d.ts +2 -0
- package/dist/server/shared/errors/app-error.js +2 -0
- package/dist/server/shared/errors/app-error.js.map +1 -1
- package/dist/server/shared/http/error-handler.d.ts +2 -1
- package/dist/server/shared/http/error-handler.js +3 -2
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/storage/repositories/auth-login-attempt-repository.d.ts +9 -0
- package/dist/server/storage/repositories/auth-login-attempt-repository.js +59 -0
- package/dist/server/storage/repositories/auth-login-attempt-repository.js.map +1 -0
- package/dist/server/storage/repositories/butler-control-session-repository.d.ts +3 -0
- package/dist/server/storage/repositories/butler-control-session-repository.js +80 -4
- package/dist/server/storage/repositories/butler-control-session-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-inbox-item-repository.js +54 -3
- package/dist/server/storage/repositories/butler-inbox-item-repository.js.map +1 -1
- package/dist/server/storage/repositories/terminal-instance-repository.js +1 -1
- package/dist/server/storage/repositories/terminal-instance-repository.js.map +1 -1
- package/dist/server/storage/repositories/user-preference-profile-repository.js +6 -3
- package/dist/server/storage/repositories/user-preference-profile-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +127 -0
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +19 -1
- package/dist/server/types/domain.d.ts +37 -1
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +23 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +162 -0
- package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +89 -33
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +18 -2
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +3 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +238 -53
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +6 -2
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/public/assets/index-DR2rPNi7.css +0 -1
- package/dist/public/assets/index-DTOruahn.js +0 -114
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPage-CgrfstRm.js","assets/TerminalPage-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var TA=Object.defineProperty;var NA=(e,t,r)=>t in e?TA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ot=(e,t,r)=>NA(e,typeof t!="symbol"?t+"":t,r);function wT(e,t){for(var r=0;r<t.length;r++){const s=t[r];if(typeof s!="string"&&!Array.isArray(s)){for(const i in s)if(i!=="default"&&!(i in e)){const l=Object.getOwnPropertyDescriptor(s,i);l&&Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:()=>s[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function r(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=r(i);fetch(i.href,l)}})();function pu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qp={exports:{}},pc={},Jp={exports:{}},Tn={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react.production.min.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var yk;function PA(){if(yk)return Tn;yk=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),g=Symbol.iterator;function w(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,C={};function T(U,X,R){this.props=U,this.context=X,this.refs=C,this.updater=R||k}T.prototype.isReactComponent={},T.prototype.setState=function(U,X){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,X,"setState")},T.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function j(){}j.prototype=T.prototype;function N(U,X,R){this.props=U,this.context=X,this.refs=C,this.updater=R||k}var D=N.prototype=new j;D.constructor=N,y(D,T.prototype),D.isPureReactComponent=!0;var F=Array.isArray,W=Object.prototype.hasOwnProperty,E={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function M(U,X,R){var Se,se={},J=null,Ne=null;if(X!=null)for(Se in X.ref!==void 0&&(Ne=X.ref),X.key!==void 0&&(J=""+X.key),X)W.call(X,Se)&&!I.hasOwnProperty(Se)&&(se[Se]=X[Se]);var Ee=arguments.length-2;if(Ee===1)se.children=R;else if(1<Ee){for(var ie=Array(Ee),xe=0;xe<Ee;xe++)ie[xe]=arguments[xe+2];se.children=ie}if(U&&U.defaultProps)for(Se in Ee=U.defaultProps,Ee)se[Se]===void 0&&(se[Se]=Ee[Se]);return{$$typeof:e,type:U,key:J,ref:Ne,props:se,_owner:E.current}}function _(U,X){return{$$typeof:e,type:U.type,key:X,ref:U.ref,props:U.props,_owner:U._owner}}function L(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function Q(U){var X={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(R){return X[R]})}var O=/\/+/g;function ne(U,X){return typeof U=="object"&&U!==null&&U.key!=null?Q(""+U.key):X.toString(36)}function Y(U,X,R,Se,se){var J=typeof U;(J==="undefined"||J==="boolean")&&(U=null);var Ne=!1;if(U===null)Ne=!0;else switch(J){case"string":case"number":Ne=!0;break;case"object":switch(U.$$typeof){case e:case t:Ne=!0}}if(Ne)return Ne=U,se=se(Ne),U=Se===""?"."+ne(Ne,0):Se,F(se)?(R="",U!=null&&(R=U.replace(O,"$&/")+"/"),Y(se,X,R,"",function(xe){return xe})):se!=null&&(L(se)&&(se=_(se,R+(!se.key||Ne&&Ne.key===se.key?"":(""+se.key).replace(O,"$&/")+"/")+U)),X.push(se)),1;if(Ne=0,Se=Se===""?".":Se+":",F(U))for(var Ee=0;Ee<U.length;Ee++){J=U[Ee];var ie=Se+ne(J,Ee);Ne+=Y(J,X,R,ie,se)}else if(ie=w(U),typeof ie=="function")for(U=ie.call(U),Ee=0;!(J=U.next()).done;)J=J.value,ie=Se+ne(J,Ee++),Ne+=Y(J,X,R,ie,se);else if(J==="object")throw X=String(U),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.");return Ne}function G(U,X,R){if(U==null)return U;var Se=[],se=0;return Y(U,Se,"","",function(J){return X.call(R,J,se++)}),Se}function te(U){if(U._status===-1){var X=U._result;X=X(),X.then(function(R){(U._status===0||U._status===-1)&&(U._status=1,U._result=R)},function(R){(U._status===0||U._status===-1)&&(U._status=2,U._result=R)}),U._status===-1&&(U._status=0,U._result=X)}if(U._status===1)return U._result.default;throw U._result}var K={current:null},z={transition:null},q={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:z,ReactCurrentOwner:E};function P(){throw Error("act(...) is not supported in production builds of React.")}return Tn.Children={map:G,forEach:function(U,X,R){G(U,function(){X.apply(this,arguments)},R)},count:function(U){var X=0;return G(U,function(){X++}),X},toArray:function(U){return G(U,function(X){return X})||[]},only:function(U){if(!L(U))throw Error("React.Children.only expected to receive a single React element child.");return U}},Tn.Component=T,Tn.Fragment=r,Tn.Profiler=i,Tn.PureComponent=N,Tn.StrictMode=s,Tn.Suspense=m,Tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,Tn.act=P,Tn.cloneElement=function(U,X,R){if(U==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+U+".");var Se=y({},U.props),se=U.key,J=U.ref,Ne=U._owner;if(X!=null){if(X.ref!==void 0&&(J=X.ref,Ne=E.current),X.key!==void 0&&(se=""+X.key),U.type&&U.type.defaultProps)var Ee=U.type.defaultProps;for(ie in X)W.call(X,ie)&&!I.hasOwnProperty(ie)&&(Se[ie]=X[ie]===void 0&&Ee!==void 0?Ee[ie]:X[ie])}var ie=arguments.length-2;if(ie===1)Se.children=R;else if(1<ie){Ee=Array(ie);for(var xe=0;xe<ie;xe++)Ee[xe]=arguments[xe+2];Se.children=Ee}return{$$typeof:e,type:U.type,key:se,ref:J,props:Se,_owner:Ne}},Tn.createContext=function(U){return U={$$typeof:c,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},U.Provider={$$typeof:l,_context:U},U.Consumer=U},Tn.createElement=M,Tn.createFactory=function(U){var X=M.bind(null,U);return X.type=U,X},Tn.createRef=function(){return{current:null}},Tn.forwardRef=function(U){return{$$typeof:d,render:U}},Tn.isValidElement=L,Tn.lazy=function(U){return{$$typeof:v,_payload:{_status:-1,_result:U},_init:te}},Tn.memo=function(U,X){return{$$typeof:f,type:U,compare:X===void 0?null:X}},Tn.startTransition=function(U){var X=z.transition;z.transition={};try{U()}finally{z.transition=X}},Tn.unstable_act=P,Tn.useCallback=function(U,X){return K.current.useCallback(U,X)},Tn.useContext=function(U){return K.current.useContext(U)},Tn.useDebugValue=function(){},Tn.useDeferredValue=function(U){return K.current.useDeferredValue(U)},Tn.useEffect=function(U,X){return K.current.useEffect(U,X)},Tn.useId=function(){return K.current.useId()},Tn.useImperativeHandle=function(U,X,R){return K.current.useImperativeHandle(U,X,R)},Tn.useInsertionEffect=function(U,X){return K.current.useInsertionEffect(U,X)},Tn.useLayoutEffect=function(U,X){return K.current.useLayoutEffect(U,X)},Tn.useMemo=function(U,X){return K.current.useMemo(U,X)},Tn.useReducer=function(U,X,R){return K.current.useReducer(U,X,R)},Tn.useRef=function(U){return K.current.useRef(U)},Tn.useState=function(U){return K.current.useState(U)},Tn.useSyncExternalStore=function(U,X,R){return K.current.useSyncExternalStore(U,X,R)},Tn.useTransition=function(){return K.current.useTransition()},Tn.version="18.3.1",Tn}var kk;function Ab(){return kk||(kk=1,Jp.exports=PA()),Jp.exports}/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react-jsx-runtime.production.min.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var xk;function DA(){if(xk)return pc;xk=1;var e=Ab(),t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,m,f){var v,g={},w=null,k=null;f!==void 0&&(w=""+f),m.key!==void 0&&(w=""+m.key),m.ref!==void 0&&(k=m.ref);for(v in m)s.call(m,v)&&!l.hasOwnProperty(v)&&(g[v]=m[v]);if(d&&d.defaultProps)for(v in m=d.defaultProps,m)g[v]===void 0&&(g[v]=m[v]);return{$$typeof:t,type:d,key:w,ref:k,props:g,_owner:i.current}}return pc.Fragment=r,pc.jsx=c,pc.jsxs=c,pc}var Sk;function RA(){return Sk||(Sk=1,Qp.exports=DA()),Qp.exports}var n=RA(),Sd={},Zp={exports:{}},Ss={},ef={exports:{}},tf={};/**
|
|
19
|
+
* @license React
|
|
20
|
+
* scheduler.production.min.js
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the MIT license found in the
|
|
25
|
+
* LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/var Ck;function MA(){return Ck||(Ck=1,(function(e){function t(z,q){var P=z.length;z.push(q);e:for(;0<P;){var U=P-1>>>1,X=z[U];if(0<i(X,q))z[U]=q,z[P]=X,P=U;else break e}}function r(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var q=z[0],P=z.pop();if(P!==q){z[0]=P;e:for(var U=0,X=z.length,R=X>>>1;U<R;){var Se=2*(U+1)-1,se=z[Se],J=Se+1,Ne=z[J];if(0>i(se,P))J<X&&0>i(Ne,se)?(z[U]=Ne,z[J]=P,U=J):(z[U]=se,z[Se]=P,U=Se);else if(J<X&&0>i(Ne,P))z[U]=Ne,z[J]=P,U=J;else break e}}return q}function i(z,q){var P=z.sortIndex-q.sortIndex;return P!==0?P:z.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],f=[],v=1,g=null,w=3,k=!1,y=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function D(z){for(var q=r(f);q!==null;){if(q.callback===null)s(f);else if(q.startTime<=z)s(f),q.sortIndex=q.expirationTime,t(m,q);else break;q=r(f)}}function F(z){if(C=!1,D(z),!y)if(r(m)!==null)y=!0,te(W);else{var q=r(f);q!==null&&K(F,q.startTime-z)}}function W(z,q){y=!1,C&&(C=!1,j(M),M=-1),k=!0;var P=w;try{for(D(q),g=r(m);g!==null&&(!(g.expirationTime>q)||z&&!Q());){var U=g.callback;if(typeof U=="function"){g.callback=null,w=g.priorityLevel;var X=U(g.expirationTime<=q);q=e.unstable_now(),typeof X=="function"?g.callback=X:g===r(m)&&s(m),D(q)}else s(m);g=r(m)}if(g!==null)var R=!0;else{var Se=r(f);Se!==null&&K(F,Se.startTime-q),R=!1}return R}finally{g=null,w=P,k=!1}}var E=!1,I=null,M=-1,_=5,L=-1;function Q(){return!(e.unstable_now()-L<_)}function O(){if(I!==null){var z=e.unstable_now();L=z;var q=!0;try{q=I(!0,z)}finally{q?ne():(E=!1,I=null)}}else E=!1}var ne;if(typeof N=="function")ne=function(){N(O)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,G=Y.port2;Y.port1.onmessage=O,ne=function(){G.postMessage(null)}}else ne=function(){T(O,0)};function te(z){I=z,E||(E=!0,ne())}function K(z,q){M=T(function(){z(e.unstable_now())},q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){y||k||(y=!0,te(W))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return r(m)},e.unstable_next=function(z){switch(w){case 1:case 2:case 3:var q=3;break;default:q=w}var P=w;w=q;try{return z()}finally{w=P}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,q){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var P=w;w=z;try{return q()}finally{w=P}},e.unstable_scheduleCallback=function(z,q,P){var U=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?U+P:U):P=U,z){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=P+X,z={id:v++,callback:q,priorityLevel:z,startTime:P,expirationTime:X,sortIndex:-1},P>U?(z.sortIndex=P,t(f,z),r(m)===null&&z===r(f)&&(C?(j(M),M=-1):C=!0,K(F,P-U))):(z.sortIndex=X,t(m,z),y||k||(y=!0,te(W))),z},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(z){var q=w;return function(){var P=w;w=q;try{return z.apply(this,arguments)}finally{w=P}}}})(tf)),tf}var jk;function AA(){return jk||(jk=1,ef.exports=MA()),ef.exports}/**
|
|
27
|
+
* @license React
|
|
28
|
+
* react-dom.production.min.js
|
|
29
|
+
*
|
|
30
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the MIT license found in the
|
|
33
|
+
* LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/var Tk;function IA(){if(Tk)return Ss;Tk=1;var e=Ab(),t=AA();function r(a){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+a,h=1;h<arguments.length;h++)u+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+a+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,i={};function l(a,u){c(a,u),c(a+"Capture",u)}function c(a,u){for(i[a]=u,a=0;a<u.length;a++)s.add(u[a])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},g={};function w(a){return m.call(g,a)?!0:m.call(v,a)?!1:f.test(a)?g[a]=!0:(v[a]=!0,!1)}function k(a,u,h,b){if(h!==null&&h.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return b?!1:h!==null?!h.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function y(a,u,h,b){if(u===null||typeof u>"u"||k(a,u,h,b))return!0;if(b)return!1;if(h!==null)switch(h.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function C(a,u,h,b,x,S,A){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=b,this.attributeNamespace=x,this.mustUseProperty=h,this.propertyName=a,this.type=u,this.sanitizeURL=S,this.removeEmptyString=A}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){T[a]=new C(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var u=a[0];T[u]=new C(u,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){T[a]=new C(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){T[a]=new C(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){T[a]=new C(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){T[a]=new C(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){T[a]=new C(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){T[a]=new C(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){T[a]=new C(a,5,!1,a.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var u=a.replace(j,N);T[u]=new C(u,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var u=a.replace(j,N);T[u]=new C(u,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var u=a.replace(j,N);T[u]=new C(u,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){T[a]=new C(a,1,!1,a.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){T[a]=new C(a,1,!1,a.toLowerCase(),null,!0,!0)});function D(a,u,h,b){var x=T.hasOwnProperty(u)?T[u]:null;(x!==null?x.type!==0:b||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(y(u,h,x,b)&&(h=null),b||x===null?w(u)&&(h===null?a.removeAttribute(u):a.setAttribute(u,""+h)):x.mustUseProperty?a[x.propertyName]=h===null?x.type===3?!1:"":h:(u=x.attributeName,b=x.attributeNamespace,h===null?a.removeAttribute(u):(x=x.type,h=x===3||x===4&&h===!0?"":""+h,b?a.setAttributeNS(b,u,h):a.setAttribute(u,h))))}var F=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),E=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),Q=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),G=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),z=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=z&&a[z]||a["@@iterator"],typeof a=="function"?a:null)}var P=Object.assign,U;function X(a){if(U===void 0)try{throw Error()}catch(h){var u=h.stack.trim().match(/\n( *(at )?)/);U=u&&u[1]||""}return`
|
|
35
|
+
`+U+a}var R=!1;function Se(a,u){if(!a||R)return"";R=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(Ie){var b=Ie}Reflect.construct(a,[],u)}else{try{u.call()}catch(Ie){b=Ie}a.call(u.prototype)}else{try{throw Error()}catch(Ie){b=Ie}a()}}catch(Ie){if(Ie&&b&&typeof Ie.stack=="string"){for(var x=Ie.stack.split(`
|
|
36
|
+
`),S=b.stack.split(`
|
|
37
|
+
`),A=x.length-1,ee=S.length-1;1<=A&&0<=ee&&x[A]!==S[ee];)ee--;for(;1<=A&&0<=ee;A--,ee--)if(x[A]!==S[ee]){if(A!==1||ee!==1)do if(A--,ee--,0>ee||x[A]!==S[ee]){var le=`
|
|
38
|
+
`+x[A].replace(" at new "," at ");return a.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",a.displayName)),le}while(1<=A&&0<=ee);break}}}finally{R=!1,Error.prepareStackTrace=h}return(a=a?a.displayName||a.name:"")?X(a):""}function se(a){switch(a.tag){case 5:return X(a.type);case 16:return X("Lazy");case 13:return X("Suspense");case 19:return X("SuspenseList");case 0:case 2:case 15:return a=Se(a.type,!1),a;case 11:return a=Se(a.type.render,!1),a;case 1:return a=Se(a.type,!0),a;default:return""}}function J(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case I:return"Fragment";case E:return"Portal";case _:return"Profiler";case M:return"StrictMode";case ne:return"Suspense";case Y:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case Q:return(a.displayName||"Context")+".Consumer";case L:return(a._context.displayName||"Context")+".Provider";case O:var u=a.render;return a=a.displayName,a||(a=u.displayName||u.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case G:return u=a.displayName||null,u!==null?u:J(a.type)||"Memo";case te:u=a._payload,a=a._init;try{return J(a(u))}catch{}}return null}function Ne(a){var u=a.type;switch(a.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=u.render,a=a.displayName||a.name||"",u.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return J(u);case 8:return u===M?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function Ee(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ie(a){var u=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function xe(a){var u=ie(a)?"checked":"value",h=Object.getOwnPropertyDescriptor(a.constructor.prototype,u),b=""+a[u];if(!a.hasOwnProperty(u)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var x=h.get,S=h.set;return Object.defineProperty(a,u,{configurable:!0,get:function(){return x.call(this)},set:function(A){b=""+A,S.call(this,A)}}),Object.defineProperty(a,u,{enumerable:h.enumerable}),{getValue:function(){return b},setValue:function(A){b=""+A},stopTracking:function(){a._valueTracker=null,delete a[u]}}}}function lt(a){a._valueTracker||(a._valueTracker=xe(a))}function Oe(a){if(!a)return!1;var u=a._valueTracker;if(!u)return!0;var h=u.getValue(),b="";return a&&(b=ie(a)?a.checked?"true":"false":a.value),a=b,a!==h?(u.setValue(a),!0):!1}function bt(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function Ct(a,u){var h=u.checked;return P({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??a._wrapperState.initialChecked})}function nt(a,u){var h=u.defaultValue==null?"":u.defaultValue,b=u.checked!=null?u.checked:u.defaultChecked;h=Ee(u.value!=null?u.value:h),a._wrapperState={initialChecked:b,initialValue:h,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function et(a,u){u=u.checked,u!=null&&D(a,"checked",u,!1)}function De(a,u){et(a,u);var h=Ee(u.value),b=u.type;if(h!=null)b==="number"?(h===0&&a.value===""||a.value!=h)&&(a.value=""+h):a.value!==""+h&&(a.value=""+h);else if(b==="submit"||b==="reset"){a.removeAttribute("value");return}u.hasOwnProperty("value")?Ye(a,u.type,h):u.hasOwnProperty("defaultValue")&&Ye(a,u.type,Ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(a.defaultChecked=!!u.defaultChecked)}function Ue(a,u,h){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var b=u.type;if(!(b!=="submit"&&b!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+a._wrapperState.initialValue,h||u===a.value||(a.value=u),a.defaultValue=u}h=a.name,h!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,h!==""&&(a.name=h)}function Ye(a,u,h){(u!=="number"||bt(a.ownerDocument)!==a)&&(h==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+h&&(a.defaultValue=""+h))}var ye=Array.isArray;function He(a,u,h,b){if(a=a.options,u){u={};for(var x=0;x<h.length;x++)u["$"+h[x]]=!0;for(h=0;h<a.length;h++)x=u.hasOwnProperty("$"+a[h].value),a[h].selected!==x&&(a[h].selected=x),x&&b&&(a[h].defaultSelected=!0)}else{for(h=""+Ee(h),u=null,x=0;x<a.length;x++){if(a[x].value===h){a[x].selected=!0,b&&(a[x].defaultSelected=!0);return}u!==null||a[x].disabled||(u=a[x])}u!==null&&(u.selected=!0)}}function je(a,u){if(u.dangerouslySetInnerHTML!=null)throw Error(r(91));return P({},u,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Fe(a,u){var h=u.value;if(h==null){if(h=u.children,u=u.defaultValue,h!=null){if(u!=null)throw Error(r(92));if(ye(h)){if(1<h.length)throw Error(r(93));h=h[0]}u=h}u==null&&(u=""),h=u}a._wrapperState={initialValue:Ee(h)}}function Ve(a,u){var h=Ee(u.value),b=Ee(u.defaultValue);h!=null&&(h=""+h,h!==a.value&&(a.value=h),u.defaultValue==null&&a.defaultValue!==h&&(a.defaultValue=h)),b!=null&&(a.defaultValue=""+b)}function kt(a){var u=a.textContent;u===a._wrapperState.initialValue&&u!==""&&u!==null&&(a.value=u)}function me(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Me(a,u){return a==null||a==="http://www.w3.org/1999/xhtml"?me(u):a==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Xe,ze=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,h,b,x){MSApp.execUnsafeLocalFunction(function(){return a(u,h,b,x)})}:a})(function(a,u){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=u;else{for(Xe=Xe||document.createElement("div"),Xe.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Xe.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;u.firstChild;)a.appendChild(u.firstChild)}});function vt(a,u){if(u){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=u;return}}a.textContent=u}var ht={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},pe=["Webkit","ms","Moz","O"];Object.keys(ht).forEach(function(a){pe.forEach(function(u){u=u+a.charAt(0).toUpperCase()+a.substring(1),ht[u]=ht[a]})});function $e(a,u,h){return u==null||typeof u=="boolean"||u===""?"":h||typeof u!="number"||u===0||ht.hasOwnProperty(a)&&ht[a]?(""+u).trim():u+"px"}function Nt(a,u){a=a.style;for(var h in u)if(u.hasOwnProperty(h)){var b=h.indexOf("--")===0,x=$e(h,u[h],b);h==="float"&&(h="cssFloat"),b?a.setProperty(h,x):a[h]=x}}var Rt=P({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ft(a,u){if(u){if(Rt[a]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(r(137,a));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(r(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(r(61))}if(u.style!=null&&typeof u.style!="object")throw Error(r(62))}}function Wt(a,u){if(a.indexOf("-")===-1)return typeof u.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Kt=null;function un(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var ae=null,Be=null,It=null;function jt(a){if(a=Zl(a)){if(typeof ae!="function")throw Error(r(280));var u=a.stateNode;u&&(u=Ou(u),ae(a.stateNode,a.type,u))}}function Cn(a){Be?It?It.push(a):It=[a]:Be=a}function on(){if(Be){var a=Be,u=It;if(It=Be=null,jt(a),u)for(a=0;a<u.length;a++)jt(u[a])}}function Wn(a,u){return a(u)}function Rn(){}var $t=!1;function dn(a,u,h){if($t)return a(u,h);$t=!0;try{return Wn(a,u,h)}finally{$t=!1,(Be!==null||It!==null)&&(Rn(),on())}}function gn(a,u){var h=a.stateNode;if(h===null)return null;var b=Ou(h);if(b===null)return null;h=b[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(a=a.type,b=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!b;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(r(231,u,typeof h));return h}var Z=!1;if(d)try{var ce={};Object.defineProperty(ce,"passive",{get:function(){Z=!0}}),window.addEventListener("test",ce,ce),window.removeEventListener("test",ce,ce)}catch{Z=!1}function ge(a,u,h,b,x,S,A,ee,le){var Ie=Array.prototype.slice.call(arguments,3);try{u.apply(h,Ie)}catch(rt){this.onError(rt)}}var Ce=!1,We=null,qe=!1,Pt=null,Ke={onError:function(a){Ce=!0,We=a}};function at(a,u,h,b,x,S,A,ee,le){Ce=!1,We=null,ge.apply(Ke,arguments)}function ft(a,u,h,b,x,S,A,ee,le){if(at.apply(this,arguments),Ce){if(Ce){var Ie=We;Ce=!1,We=null}else throw Error(r(198));qe||(qe=!0,Pt=Ie)}}function ct(a){var u=a,h=a;if(a.alternate)for(;u.return;)u=u.return;else{a=u;do u=a,(u.flags&4098)!==0&&(h=u.return),a=u.return;while(a)}return u.tag===3?h:null}function oe(a){if(a.tag===13){var u=a.memoizedState;if(u===null&&(a=a.alternate,a!==null&&(u=a.memoizedState)),u!==null)return u.dehydrated}return null}function Re(a){if(ct(a)!==a)throw Error(r(188))}function _t(a){var u=a.alternate;if(!u){if(u=ct(a),u===null)throw Error(r(188));return u!==a?null:a}for(var h=a,b=u;;){var x=h.return;if(x===null)break;var S=x.alternate;if(S===null){if(b=x.return,b!==null){h=b;continue}break}if(x.child===S.child){for(S=x.child;S;){if(S===h)return Re(x),a;if(S===b)return Re(x),u;S=S.sibling}throw Error(r(188))}if(h.return!==b.return)h=x,b=S;else{for(var A=!1,ee=x.child;ee;){if(ee===h){A=!0,h=x,b=S;break}if(ee===b){A=!0,b=x,h=S;break}ee=ee.sibling}if(!A){for(ee=S.child;ee;){if(ee===h){A=!0,h=S,b=x;break}if(ee===b){A=!0,b=S,h=x;break}ee=ee.sibling}if(!A)throw Error(r(189))}}if(h.alternate!==b)throw Error(r(190))}if(h.tag!==3)throw Error(r(188));return h.stateNode.current===h?a:u}function Ut(a){return a=_t(a),a!==null?Qt(a):null}function Qt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var u=Qt(a);if(u!==null)return u;a=a.sibling}return null}var ln=t.unstable_scheduleCallback,jn=t.unstable_cancelCallback,Jn=t.unstable_shouldYield,bn=t.unstable_requestPaint,Jt=t.unstable_now,ur=t.unstable_getCurrentPriorityLevel,vn=t.unstable_ImmediatePriority,yn=t.unstable_UserBlockingPriority,kn=t.unstable_NormalPriority,Nn=t.unstable_LowPriority,xt=t.unstable_IdlePriority,Zt=null,we=null;function Ge(a){if(we&&typeof we.onCommitFiberRoot=="function")try{we.onCommitFiberRoot(Zt,a,void 0,(a.current.flags&128)===128)}catch{}}var St=Math.clz32?Math.clz32:Vn,Sn=Math.log,_n=Math.LN2;function Vn(a){return a>>>=0,a===0?32:31-(Sn(a)/_n|0)|0}var zn=64,rr=4194304;function Gn(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function xr(a,u){var h=a.pendingLanes;if(h===0)return 0;var b=0,x=a.suspendedLanes,S=a.pingedLanes,A=h&268435455;if(A!==0){var ee=A&~x;ee!==0?b=Gn(ee):(S&=A,S!==0&&(b=Gn(S)))}else A=h&~x,A!==0?b=Gn(A):S!==0&&(b=Gn(S));if(b===0)return 0;if(u!==0&&u!==b&&(u&x)===0&&(x=b&-b,S=u&-u,x>=S||x===16&&(S&4194240)!==0))return u;if((b&4)!==0&&(b|=h&16),u=a.entangledLanes,u!==0)for(a=a.entanglements,u&=b;0<u;)h=31-St(u),x=1<<h,b|=a[h],u&=~x;return b}function Kr(a,u){switch(a){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Yr(a,u){for(var h=a.suspendedLanes,b=a.pingedLanes,x=a.expirationTimes,S=a.pendingLanes;0<S;){var A=31-St(S),ee=1<<A,le=x[A];le===-1?((ee&h)===0||(ee&b)!==0)&&(x[A]=Kr(ee,u)):le<=u&&(a.expiredLanes|=ee),S&=~ee}}function Xr(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Lr(){var a=zn;return zn<<=1,(zn&4194240)===0&&(zn=64),a}function es(a){for(var u=[],h=0;31>h;h++)u.push(a);return u}function sr(a,u,h){a.pendingLanes|=u,u!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,u=31-St(u),a[u]=h}function Hr(a,u){var h=a.pendingLanes&~u;a.pendingLanes=u,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=u,a.mutableReadLanes&=u,a.entangledLanes&=u,u=a.entanglements;var b=a.eventTimes;for(a=a.expirationTimes;0<h;){var x=31-St(h),S=1<<x;u[x]=0,b[x]=-1,a[x]=-1,h&=~S}}function dr(a,u){var h=a.entangledLanes|=u;for(a=a.entanglements;h;){var b=31-St(h),x=1<<b;x&u|a[b]&u&&(a[b]|=u),h&=~x}}var wt=0;function ir(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var tn,hr,ar,ue,Qe,yt=!1,Lt=[],fn=null,mn=null,nn=null,Un=new Map,Fr=new Map,zr=[],Xt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Cr(a,u){switch(a){case"focusin":case"focusout":fn=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":nn=null;break;case"pointerover":case"pointerout":Un.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fr.delete(u.pointerId)}}function V(a,u,h,b,x,S){return a===null||a.nativeEvent!==S?(a={blockedOn:u,domEventName:h,eventSystemFlags:b,nativeEvent:S,targetContainers:[x]},u!==null&&(u=Zl(u),u!==null&&hr(u)),a):(a.eventSystemFlags|=b,u=a.targetContainers,x!==null&&u.indexOf(x)===-1&&u.push(x),a)}function fe(a,u,h,b,x){switch(u){case"focusin":return fn=V(fn,a,u,h,b,x),!0;case"dragenter":return mn=V(mn,a,u,h,b,x),!0;case"mouseover":return nn=V(nn,a,u,h,b,x),!0;case"pointerover":var S=x.pointerId;return Un.set(S,V(Un.get(S)||null,a,u,h,b,x)),!0;case"gotpointercapture":return S=x.pointerId,Fr.set(S,V(Fr.get(S)||null,a,u,h,b,x)),!0}return!1}function ve(a){var u=Ja(a.target);if(u!==null){var h=ct(u);if(h!==null){if(u=h.tag,u===13){if(u=oe(h),u!==null){a.blockedOn=u,Qe(a.priority,function(){ar(h)});return}}else if(u===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function it(a){if(a.blockedOn!==null)return!1;for(var u=a.targetContainers;0<u.length;){var h=mr(a.domEventName,a.eventSystemFlags,u[0],a.nativeEvent);if(h===null){h=a.nativeEvent;var b=new h.constructor(h.type,h);Kt=b,h.target.dispatchEvent(b),Kt=null}else return u=Zl(h),u!==null&&hr(u),a.blockedOn=h,!1;u.shift()}return!0}function tt(a,u,h){it(a)&&h.delete(u)}function Tt(){yt=!1,fn!==null&&it(fn)&&(fn=null),mn!==null&&it(mn)&&(mn=null),nn!==null&&it(nn)&&(nn=null),Un.forEach(tt),Fr.forEach(tt)}function cn(a,u){a.blockedOn===u&&(a.blockedOn=null,yt||(yt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Tt)))}function In(a){function u(x){return cn(x,a)}if(0<Lt.length){cn(Lt[0],a);for(var h=1;h<Lt.length;h++){var b=Lt[h];b.blockedOn===a&&(b.blockedOn=null)}}for(fn!==null&&cn(fn,a),mn!==null&&cn(mn,a),nn!==null&&cn(nn,a),Un.forEach(u),Fr.forEach(u),h=0;h<zr.length;h++)b=zr[h],b.blockedOn===a&&(b.blockedOn=null);for(;0<zr.length&&(h=zr[0],h.blockedOn===null);)ve(h),h.blockedOn===null&&zr.shift()}var Hn=F.ReactCurrentBatchConfig,ts=!0;function gs(a,u,h,b){var x=wt,S=Hn.transition;Hn.transition=null;try{wt=1,Ls(a,u,h,b)}finally{wt=x,Hn.transition=S}}function or(a,u,h,b){var x=wt,S=Hn.transition;Hn.transition=null;try{wt=4,Ls(a,u,h,b)}finally{wt=x,Hn.transition=S}}function Ls(a,u,h,b){if(ts){var x=mr(a,u,h,b);if(x===null)Um(a,u,b,ns,h),Cr(a,b);else if(fe(x,a,u,h,b))b.stopPropagation();else if(Cr(a,b),u&4&&-1<Xt.indexOf(a)){for(;x!==null;){var S=Zl(x);if(S!==null&&tn(S),S=mr(a,u,h,b),S===null&&Um(a,u,b,ns,h),S===x)break;x=S}x!==null&&b.stopPropagation()}else Um(a,u,b,null,h)}}var ns=null;function mr(a,u,h,b){if(ns=null,a=un(b),a=Ja(a),a!==null)if(u=ct(a),u===null)a=null;else if(h=u.tag,h===13){if(a=oe(u),a!==null)return a;a=null}else if(h===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;a=null}else u!==a&&(a=null);return ns=a,null}function pa(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ur()){case vn:return 1;case yn:return 4;case kn:case Nn:return 16;case xt:return 536870912;default:return 16}default:return 16}}var rs=null,ji=null,Qr=null;function qr(){if(Qr)return Qr;var a,u=ji,h=u.length,b,x="value"in rs?rs.value:rs.textContent,S=x.length;for(a=0;a<h&&u[a]===x[a];a++);var A=h-a;for(b=1;b<=A&&u[h-b]===x[S-b];b++);return Qr=x.slice(a,1<b?1-b:void 0)}function ci(a){var u=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&u===13&&(a=13)):a=u,a===10&&(a=13),32<=a||a===13?a:0}function ui(){return!0}function Ti(){return!1}function _r(a){function u(h,b,x,S,A){this._reactName=h,this._targetInst=x,this.type=b,this.nativeEvent=S,this.target=A,this.currentTarget=null;for(var ee in a)a.hasOwnProperty(ee)&&(h=a[ee],this[ee]=h?h(S):S[ee]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?ui:Ti,this.isPropagationStopped=Ti,this}return P(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=ui)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=ui)},persist:function(){},isPersistent:ui}),u}var $={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},be=_r($),st=P({},$,{view:0,detail:0}),At=_r(st),en,ds,Ni,Gi=P({},st,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:fa,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Ni&&(Ni&&a.type==="mousemove"?(en=a.screenX-Ni.screenX,ds=a.screenY-Ni.screenY):ds=en=0,Ni=a),en)},movementY:function(a){return"movementY"in a?a.movementY:ds}}),Ki=_r(Gi),Ga=P({},Gi,{dataTransfer:0}),_o=_r(Ga),Ka=P({},st,{relatedTarget:0}),Fs=_r(Ka),zl=P({},$,{animationName:0,elapsedTime:0,pseudoElement:0}),Oo=_r(zl),ql=P({},$,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),$l=_r(ql),Bo=P({},$,{data:0}),Yi=_r(Bo),Wo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Uo={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ho={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zo(a){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(a):(a=Ho[a])?!!u[a]:!1}function fa(){return zo}var qo=P({},st,{key:function(a){if(a.key){var u=Wo[a.key]||a.key;if(u!=="Unidentified")return u}return a.type==="keypress"?(a=ci(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?Uo[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:fa,charCode:function(a){return a.type==="keypress"?ci(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?ci(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),Ya=_r(qo),$o=P({},Gi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vs=_r($o),Xa=P({},st,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:fa}),H=_r(Xa),de=P({},$,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ae=_r(de),dt=P({},Gi,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),mt=_r(dt),pn=[9,13,27,32],zt=d&&"CompositionEvent"in window,B=null;d&&"documentMode"in document&&(B=document.documentMode);var re=d&&"TextEvent"in window&&!B,Te=d&&(!zt||B&&8<B&&11>=B),Je=" ",Dt=!1;function Mt(a,u){switch(a){case"keyup":return pn.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vt(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Mn=!1;function Pn(a,u){switch(a){case"compositionend":return Vt(u);case"keypress":return u.which!==32?null:(Dt=!0,Je);case"textInput":return a=u.data,a===Je&&Dt?null:a;default:return null}}function Ht(a,u){if(Mn)return a==="compositionend"||!zt&&Mt(a,u)?(a=qr(),Qr=ji=rs=null,Mn=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return Te&&u.locale!=="ko"?null:u.data;default:return null}}var jr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function bs(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u==="input"?!!jr[a.type]:u==="textarea"}function ss(a,u,h,b){Cn(b),u=Lu(u,"onChange"),0<u.length&&(h=new be("onChange","change",null,h,b),a.push({event:h,listeners:u}))}var _s=null,Pi=null;function Vl(a){Fw(a,0)}function Di(a){var u=Xo(a);if(Oe(u))return a}function Qa(a,u){if(a==="change")return u}var ww=!1;if(d){var Am;if(d){var Im="oninput"in document;if(!Im){var yw=document.createElement("div");yw.setAttribute("oninput","return;"),Im=typeof yw.oninput=="function"}Am=Im}else Am=!1;ww=Am&&(!document.documentMode||9<document.documentMode)}function kw(){_s&&(_s.detachEvent("onpropertychange",xw),Pi=_s=null)}function xw(a){if(a.propertyName==="value"&&Di(Pi)){var u=[];ss(u,Pi,a,un(a)),dn(Vl,u)}}function PM(a,u,h){a==="focusin"?(kw(),_s=u,Pi=h,_s.attachEvent("onpropertychange",xw)):a==="focusout"&&kw()}function DM(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Di(Pi)}function RM(a,u){if(a==="click")return Di(u)}function MM(a,u){if(a==="input"||a==="change")return Di(u)}function AM(a,u){return a===u&&(a!==0||1/a===1/u)||a!==a&&u!==u}var di=typeof Object.is=="function"?Object.is:AM;function Gl(a,u){if(di(a,u))return!0;if(typeof a!="object"||a===null||typeof u!="object"||u===null)return!1;var h=Object.keys(a),b=Object.keys(u);if(h.length!==b.length)return!1;for(b=0;b<h.length;b++){var x=h[b];if(!m.call(u,x)||!di(a[x],u[x]))return!1}return!0}function Sw(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Cw(a,u){var h=Sw(a);a=0;for(var b;h;){if(h.nodeType===3){if(b=a+h.textContent.length,a<=u&&b>=u)return{node:h,offset:u-a};a=b}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Sw(h)}}function jw(a,u){return a&&u?a===u?!0:a&&a.nodeType===3?!1:u&&u.nodeType===3?jw(a,u.parentNode):"contains"in a?a.contains(u):a.compareDocumentPosition?!!(a.compareDocumentPosition(u)&16):!1:!1}function Tw(){for(var a=window,u=bt();u instanceof a.HTMLIFrameElement;){try{var h=typeof u.contentWindow.location.href=="string"}catch{h=!1}if(h)a=u.contentWindow;else break;u=bt(a.document)}return u}function Em(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u&&(u==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||u==="textarea"||a.contentEditable==="true")}function IM(a){var u=Tw(),h=a.focusedElem,b=a.selectionRange;if(u!==h&&h&&h.ownerDocument&&jw(h.ownerDocument.documentElement,h)){if(b!==null&&Em(h)){if(u=b.start,a=b.end,a===void 0&&(a=u),"selectionStart"in h)h.selectionStart=u,h.selectionEnd=Math.min(a,h.value.length);else if(a=(u=h.ownerDocument||document)&&u.defaultView||window,a.getSelection){a=a.getSelection();var x=h.textContent.length,S=Math.min(b.start,x);b=b.end===void 0?S:Math.min(b.end,x),!a.extend&&S>b&&(x=b,b=S,S=x),x=Cw(h,S);var A=Cw(h,b);x&&A&&(a.rangeCount!==1||a.anchorNode!==x.node||a.anchorOffset!==x.offset||a.focusNode!==A.node||a.focusOffset!==A.offset)&&(u=u.createRange(),u.setStart(x.node,x.offset),a.removeAllRanges(),S>b?(a.addRange(u),a.extend(A.node,A.offset)):(u.setEnd(A.node,A.offset),a.addRange(u)))}}for(u=[],a=h;a=a.parentNode;)a.nodeType===1&&u.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<u.length;h++)a=u[h],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var EM=d&&"documentMode"in document&&11>=document.documentMode,Vo=null,Lm=null,Kl=null,Fm=!1;function Nw(a,u,h){var b=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Fm||Vo==null||Vo!==bt(b)||(b=Vo,"selectionStart"in b&&Em(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Kl&&Gl(Kl,b)||(Kl=b,b=Lu(Lm,"onSelect"),0<b.length&&(u=new be("onSelect","select",null,u,h),a.push({event:u,listeners:b}),u.target=Vo)))}function Au(a,u){var h={};return h[a.toLowerCase()]=u.toLowerCase(),h["Webkit"+a]="webkit"+u,h["Moz"+a]="moz"+u,h}var Go={animationend:Au("Animation","AnimationEnd"),animationiteration:Au("Animation","AnimationIteration"),animationstart:Au("Animation","AnimationStart"),transitionend:Au("Transition","TransitionEnd")},_m={},Pw={};d&&(Pw=document.createElement("div").style,"AnimationEvent"in window||(delete Go.animationend.animation,delete Go.animationiteration.animation,delete Go.animationstart.animation),"TransitionEvent"in window||delete Go.transitionend.transition);function Iu(a){if(_m[a])return _m[a];if(!Go[a])return a;var u=Go[a],h;for(h in u)if(u.hasOwnProperty(h)&&h in Pw)return _m[a]=u[h];return a}var Dw=Iu("animationend"),Rw=Iu("animationiteration"),Mw=Iu("animationstart"),Aw=Iu("transitionend"),Iw=new Map,Ew="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ga(a,u){Iw.set(a,u),l(u,[a])}for(var Om=0;Om<Ew.length;Om++){var Bm=Ew[Om],LM=Bm.toLowerCase(),FM=Bm[0].toUpperCase()+Bm.slice(1);ga(LM,"on"+FM)}ga(Dw,"onAnimationEnd"),ga(Rw,"onAnimationIteration"),ga(Mw,"onAnimationStart"),ga("dblclick","onDoubleClick"),ga("focusin","onFocus"),ga("focusout","onBlur"),ga(Aw,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_M=new Set("cancel close invalid load scroll toggle".split(" ").concat(Yl));function Lw(a,u,h){var b=a.type||"unknown-event";a.currentTarget=h,ft(b,u,void 0,a),a.currentTarget=null}function Fw(a,u){u=(u&4)!==0;for(var h=0;h<a.length;h++){var b=a[h],x=b.event;b=b.listeners;e:{var S=void 0;if(u)for(var A=b.length-1;0<=A;A--){var ee=b[A],le=ee.instance,Ie=ee.currentTarget;if(ee=ee.listener,le!==S&&x.isPropagationStopped())break e;Lw(x,ee,Ie),S=le}else for(A=0;A<b.length;A++){if(ee=b[A],le=ee.instance,Ie=ee.currentTarget,ee=ee.listener,le!==S&&x.isPropagationStopped())break e;Lw(x,ee,Ie),S=le}}}if(qe)throw a=Pt,qe=!1,Pt=null,a}function lr(a,u){var h=u[Gm];h===void 0&&(h=u[Gm]=new Set);var b=a+"__bubble";h.has(b)||(_w(u,a,2,!1),h.add(b))}function Wm(a,u,h){var b=0;u&&(b|=4),_w(h,a,b,u)}var Eu="_reactListening"+Math.random().toString(36).slice(2);function Xl(a){if(!a[Eu]){a[Eu]=!0,s.forEach(function(h){h!=="selectionchange"&&(_M.has(h)||Wm(h,!1,a),Wm(h,!0,a))});var u=a.nodeType===9?a:a.ownerDocument;u===null||u[Eu]||(u[Eu]=!0,Wm("selectionchange",!1,u))}}function _w(a,u,h,b){switch(pa(u)){case 1:var x=gs;break;case 4:x=or;break;default:x=Ls}h=x.bind(null,u,h,a),x=void 0,!Z||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(x=!0),b?x!==void 0?a.addEventListener(u,h,{capture:!0,passive:x}):a.addEventListener(u,h,!0):x!==void 0?a.addEventListener(u,h,{passive:x}):a.addEventListener(u,h,!1)}function Um(a,u,h,b,x){var S=b;if((u&1)===0&&(u&2)===0&&b!==null)e:for(;;){if(b===null)return;var A=b.tag;if(A===3||A===4){var ee=b.stateNode.containerInfo;if(ee===x||ee.nodeType===8&&ee.parentNode===x)break;if(A===4)for(A=b.return;A!==null;){var le=A.tag;if((le===3||le===4)&&(le=A.stateNode.containerInfo,le===x||le.nodeType===8&&le.parentNode===x))return;A=A.return}for(;ee!==null;){if(A=Ja(ee),A===null)return;if(le=A.tag,le===5||le===6){b=S=A;continue e}ee=ee.parentNode}}b=b.return}dn(function(){var Ie=S,rt=un(h),ut=[];e:{var Ze=Iw.get(a);if(Ze!==void 0){var Et=be,qt=a;switch(a){case"keypress":if(ci(h)===0)break e;case"keydown":case"keyup":Et=Ya;break;case"focusin":qt="focus",Et=Fs;break;case"focusout":qt="blur",Et=Fs;break;case"beforeblur":case"afterblur":Et=Fs;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Et=Ki;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Et=_o;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Et=H;break;case Dw:case Rw:case Mw:Et=Oo;break;case Aw:Et=Ae;break;case"scroll":Et=At;break;case"wheel":Et=mt;break;case"copy":case"cut":case"paste":Et=$l;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Et=Vs}var Gt=(u&4)!==0,Tr=!Gt&&a==="scroll",ke=Gt?Ze!==null?Ze+"Capture":null:Ze;Gt=[];for(var he=Ie,Pe;he!==null;){Pe=he;var gt=Pe.stateNode;if(Pe.tag===5&>!==null&&(Pe=gt,ke!==null&&(gt=gn(he,ke),gt!=null&&Gt.push(Ql(he,gt,Pe)))),Tr)break;he=he.return}0<Gt.length&&(Ze=new Et(Ze,qt,null,h,rt),ut.push({event:Ze,listeners:Gt}))}}if((u&7)===0){e:{if(Ze=a==="mouseover"||a==="pointerover",Et=a==="mouseout"||a==="pointerout",Ze&&h!==Kt&&(qt=h.relatedTarget||h.fromElement)&&(Ja(qt)||qt[Xi]))break e;if((Et||Ze)&&(Ze=rt.window===rt?rt:(Ze=rt.ownerDocument)?Ze.defaultView||Ze.parentWindow:window,Et?(qt=h.relatedTarget||h.toElement,Et=Ie,qt=qt?Ja(qt):null,qt!==null&&(Tr=ct(qt),qt!==Tr||qt.tag!==5&&qt.tag!==6)&&(qt=null)):(Et=null,qt=Ie),Et!==qt)){if(Gt=Ki,gt="onMouseLeave",ke="onMouseEnter",he="mouse",(a==="pointerout"||a==="pointerover")&&(Gt=Vs,gt="onPointerLeave",ke="onPointerEnter",he="pointer"),Tr=Et==null?Ze:Xo(Et),Pe=qt==null?Ze:Xo(qt),Ze=new Gt(gt,he+"leave",Et,h,rt),Ze.target=Tr,Ze.relatedTarget=Pe,gt=null,Ja(rt)===Ie&&(Gt=new Gt(ke,he+"enter",qt,h,rt),Gt.target=Pe,Gt.relatedTarget=Tr,gt=Gt),Tr=gt,Et&&qt)t:{for(Gt=Et,ke=qt,he=0,Pe=Gt;Pe;Pe=Ko(Pe))he++;for(Pe=0,gt=ke;gt;gt=Ko(gt))Pe++;for(;0<he-Pe;)Gt=Ko(Gt),he--;for(;0<Pe-he;)ke=Ko(ke),Pe--;for(;he--;){if(Gt===ke||ke!==null&&Gt===ke.alternate)break t;Gt=Ko(Gt),ke=Ko(ke)}Gt=null}else Gt=null;Et!==null&&Ow(ut,Ze,Et,Gt,!1),qt!==null&&Tr!==null&&Ow(ut,Tr,qt,Gt,!0)}}e:{if(Ze=Ie?Xo(Ie):window,Et=Ze.nodeName&&Ze.nodeName.toLowerCase(),Et==="select"||Et==="input"&&Ze.type==="file")var Yt=Qa;else if(bs(Ze))if(ww)Yt=MM;else{Yt=DM;var rn=PM}else(Et=Ze.nodeName)&&Et.toLowerCase()==="input"&&(Ze.type==="checkbox"||Ze.type==="radio")&&(Yt=RM);if(Yt&&(Yt=Yt(a,Ie))){ss(ut,Yt,h,rt);break e}rn&&rn(a,Ze,Ie),a==="focusout"&&(rn=Ze._wrapperState)&&rn.controlled&&Ze.type==="number"&&Ye(Ze,"number",Ze.value)}switch(rn=Ie?Xo(Ie):window,a){case"focusin":(bs(rn)||rn.contentEditable==="true")&&(Vo=rn,Lm=Ie,Kl=null);break;case"focusout":Kl=Lm=Vo=null;break;case"mousedown":Fm=!0;break;case"contextmenu":case"mouseup":case"dragend":Fm=!1,Nw(ut,h,rt);break;case"selectionchange":if(EM)break;case"keydown":case"keyup":Nw(ut,h,rt)}var sn;if(zt)e:{switch(a){case"compositionstart":var hn="onCompositionStart";break e;case"compositionend":hn="onCompositionEnd";break e;case"compositionupdate":hn="onCompositionUpdate";break e}hn=void 0}else Mn?Mt(a,h)&&(hn="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(hn="onCompositionStart");hn&&(Te&&h.locale!=="ko"&&(Mn||hn!=="onCompositionStart"?hn==="onCompositionEnd"&&Mn&&(sn=qr()):(rs=rt,ji="value"in rs?rs.value:rs.textContent,Mn=!0)),rn=Lu(Ie,hn),0<rn.length&&(hn=new Yi(hn,a,null,h,rt),ut.push({event:hn,listeners:rn}),sn?hn.data=sn:(sn=Vt(h),sn!==null&&(hn.data=sn)))),(sn=re?Pn(a,h):Ht(a,h))&&(Ie=Lu(Ie,"onBeforeInput"),0<Ie.length&&(rt=new Yi("onBeforeInput","beforeinput",null,h,rt),ut.push({event:rt,listeners:Ie}),rt.data=sn))}Fw(ut,u)})}function Ql(a,u,h){return{instance:a,listener:u,currentTarget:h}}function Lu(a,u){for(var h=u+"Capture",b=[];a!==null;){var x=a,S=x.stateNode;x.tag===5&&S!==null&&(x=S,S=gn(a,h),S!=null&&b.unshift(Ql(a,S,x)),S=gn(a,u),S!=null&&b.push(Ql(a,S,x))),a=a.return}return b}function Ko(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Ow(a,u,h,b,x){for(var S=u._reactName,A=[];h!==null&&h!==b;){var ee=h,le=ee.alternate,Ie=ee.stateNode;if(le!==null&&le===b)break;ee.tag===5&&Ie!==null&&(ee=Ie,x?(le=gn(h,S),le!=null&&A.unshift(Ql(h,le,ee))):x||(le=gn(h,S),le!=null&&A.push(Ql(h,le,ee)))),h=h.return}A.length!==0&&a.push({event:u,listeners:A})}var OM=/\r\n?/g,BM=/\u0000|\uFFFD/g;function Bw(a){return(typeof a=="string"?a:""+a).replace(OM,`
|
|
39
|
+
`).replace(BM,"")}function Fu(a,u,h){if(u=Bw(u),Bw(a)!==u&&h)throw Error(r(425))}function _u(){}var Hm=null,zm=null;function qm(a,u){return a==="textarea"||a==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var $m=typeof setTimeout=="function"?setTimeout:void 0,WM=typeof clearTimeout=="function"?clearTimeout:void 0,Ww=typeof Promise=="function"?Promise:void 0,UM=typeof queueMicrotask=="function"?queueMicrotask:typeof Ww<"u"?function(a){return Ww.resolve(null).then(a).catch(HM)}:$m;function HM(a){setTimeout(function(){throw a})}function Vm(a,u){var h=u,b=0;do{var x=h.nextSibling;if(a.removeChild(h),x&&x.nodeType===8)if(h=x.data,h==="/$"){if(b===0){a.removeChild(x),In(u);return}b--}else h!=="$"&&h!=="$?"&&h!=="$!"||b++;h=x}while(h);In(u)}function ba(a){for(;a!=null;a=a.nextSibling){var u=a.nodeType;if(u===1||u===3)break;if(u===8){if(u=a.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return a}function Uw(a){a=a.previousSibling;for(var u=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"){if(u===0)return a;u--}else h==="/$"&&u++}a=a.previousSibling}return null}var Yo=Math.random().toString(36).slice(2),Ri="__reactFiber$"+Yo,Jl="__reactProps$"+Yo,Xi="__reactContainer$"+Yo,Gm="__reactEvents$"+Yo,zM="__reactListeners$"+Yo,qM="__reactHandles$"+Yo;function Ja(a){var u=a[Ri];if(u)return u;for(var h=a.parentNode;h;){if(u=h[Xi]||h[Ri]){if(h=u.alternate,u.child!==null||h!==null&&h.child!==null)for(a=Uw(a);a!==null;){if(h=a[Ri])return h;a=Uw(a)}return u}a=h,h=a.parentNode}return null}function Zl(a){return a=a[Ri]||a[Xi],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Xo(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(r(33))}function Ou(a){return a[Jl]||null}var Km=[],Qo=-1;function va(a){return{current:a}}function cr(a){0>Qo||(a.current=Km[Qo],Km[Qo]=null,Qo--)}function Zn(a,u){Qo++,Km[Qo]=a.current,a.current=u}var wa={},is=va(wa),vs=va(!1),Za=wa;function Jo(a,u){var h=a.type.contextTypes;if(!h)return wa;var b=a.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===u)return b.__reactInternalMemoizedMaskedChildContext;var x={},S;for(S in h)x[S]=u[S];return b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=u,a.__reactInternalMemoizedMaskedChildContext=x),x}function ws(a){return a=a.childContextTypes,a!=null}function Bu(){cr(vs),cr(is)}function Hw(a,u,h){if(is.current!==wa)throw Error(r(168));Zn(is,u),Zn(vs,h)}function zw(a,u,h){var b=a.stateNode;if(u=u.childContextTypes,typeof b.getChildContext!="function")return h;b=b.getChildContext();for(var x in b)if(!(x in u))throw Error(r(108,Ne(a)||"Unknown",x));return P({},h,b)}function Wu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||wa,Za=is.current,Zn(is,a),Zn(vs,vs.current),!0}function qw(a,u,h){var b=a.stateNode;if(!b)throw Error(r(169));h?(a=zw(a,u,Za),b.__reactInternalMemoizedMergedChildContext=a,cr(vs),cr(is),Zn(is,a)):cr(vs),Zn(vs,h)}var Qi=null,Uu=!1,Ym=!1;function $w(a){Qi===null?Qi=[a]:Qi.push(a)}function $M(a){Uu=!0,$w(a)}function ya(){if(!Ym&&Qi!==null){Ym=!0;var a=0,u=wt;try{var h=Qi;for(wt=1;a<h.length;a++){var b=h[a];do b=b(!0);while(b!==null)}Qi=null,Uu=!1}catch(x){throw Qi!==null&&(Qi=Qi.slice(a+1)),ln(vn,ya),x}finally{wt=u,Ym=!1}}return null}var Zo=[],el=0,Hu=null,zu=0,Gs=[],Ks=0,eo=null,Ji=1,Zi="";function to(a,u){Zo[el++]=zu,Zo[el++]=Hu,Hu=a,zu=u}function Vw(a,u,h){Gs[Ks++]=Ji,Gs[Ks++]=Zi,Gs[Ks++]=eo,eo=a;var b=Ji;a=Zi;var x=32-St(b)-1;b&=~(1<<x),h+=1;var S=32-St(u)+x;if(30<S){var A=x-x%5;S=(b&(1<<A)-1).toString(32),b>>=A,x-=A,Ji=1<<32-St(u)+x|h<<x|b,Zi=S+a}else Ji=1<<S|h<<x|b,Zi=a}function Xm(a){a.return!==null&&(to(a,1),Vw(a,1,0))}function Qm(a){for(;a===Hu;)Hu=Zo[--el],Zo[el]=null,zu=Zo[--el],Zo[el]=null;for(;a===eo;)eo=Gs[--Ks],Gs[Ks]=null,Zi=Gs[--Ks],Gs[Ks]=null,Ji=Gs[--Ks],Gs[Ks]=null}var Os=null,Bs=null,pr=!1,hi=null;function Gw(a,u){var h=Js(5,null,null,0);h.elementType="DELETED",h.stateNode=u,h.return=a,u=a.deletions,u===null?(a.deletions=[h],a.flags|=16):u.push(h)}function Kw(a,u){switch(a.tag){case 5:var h=a.type;return u=u.nodeType!==1||h.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(a.stateNode=u,Os=a,Bs=ba(u.firstChild),!0):!1;case 6:return u=a.pendingProps===""||u.nodeType!==3?null:u,u!==null?(a.stateNode=u,Os=a,Bs=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(h=eo!==null?{id:Ji,overflow:Zi}:null,a.memoizedState={dehydrated:u,treeContext:h,retryLane:1073741824},h=Js(18,null,null,0),h.stateNode=u,h.return=a,a.child=h,Os=a,Bs=null,!0):!1;default:return!1}}function Jm(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Zm(a){if(pr){var u=Bs;if(u){var h=u;if(!Kw(a,u)){if(Jm(a))throw Error(r(418));u=ba(h.nextSibling);var b=Os;u&&Kw(a,u)?Gw(b,h):(a.flags=a.flags&-4097|2,pr=!1,Os=a)}}else{if(Jm(a))throw Error(r(418));a.flags=a.flags&-4097|2,pr=!1,Os=a}}}function Yw(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Os=a}function qu(a){if(a!==Os)return!1;if(!pr)return Yw(a),pr=!0,!1;var u;if((u=a.tag!==3)&&!(u=a.tag!==5)&&(u=a.type,u=u!=="head"&&u!=="body"&&!qm(a.type,a.memoizedProps)),u&&(u=Bs)){if(Jm(a))throw Xw(),Error(r(418));for(;u;)Gw(a,u),u=ba(u.nextSibling)}if(Yw(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(317));e:{for(a=a.nextSibling,u=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"){if(u===0){Bs=ba(a.nextSibling);break e}u--}else h!=="$"&&h!=="$!"&&h!=="$?"||u++}a=a.nextSibling}Bs=null}}else Bs=Os?ba(a.stateNode.nextSibling):null;return!0}function Xw(){for(var a=Bs;a;)a=ba(a.nextSibling)}function tl(){Bs=Os=null,pr=!1}function ep(a){hi===null?hi=[a]:hi.push(a)}var VM=F.ReactCurrentBatchConfig;function ec(a,u,h){if(a=h.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(r(309));var b=h.stateNode}if(!b)throw Error(r(147,a));var x=b,S=""+a;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===S?u.ref:(u=function(A){var ee=x.refs;A===null?delete ee[S]:ee[S]=A},u._stringRef=S,u)}if(typeof a!="string")throw Error(r(284));if(!h._owner)throw Error(r(290,a))}return a}function $u(a,u){throw a=Object.prototype.toString.call(u),Error(r(31,a==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":a))}function Qw(a){var u=a._init;return u(a._payload)}function Jw(a){function u(ke,he){if(a){var Pe=ke.deletions;Pe===null?(ke.deletions=[he],ke.flags|=16):Pe.push(he)}}function h(ke,he){if(!a)return null;for(;he!==null;)u(ke,he),he=he.sibling;return null}function b(ke,he){for(ke=new Map;he!==null;)he.key!==null?ke.set(he.key,he):ke.set(he.index,he),he=he.sibling;return ke}function x(ke,he){return ke=Pa(ke,he),ke.index=0,ke.sibling=null,ke}function S(ke,he,Pe){return ke.index=Pe,a?(Pe=ke.alternate,Pe!==null?(Pe=Pe.index,Pe<he?(ke.flags|=2,he):Pe):(ke.flags|=2,he)):(ke.flags|=1048576,he)}function A(ke){return a&&ke.alternate===null&&(ke.flags|=2),ke}function ee(ke,he,Pe,gt){return he===null||he.tag!==6?(he=$p(Pe,ke.mode,gt),he.return=ke,he):(he=x(he,Pe),he.return=ke,he)}function le(ke,he,Pe,gt){var Yt=Pe.type;return Yt===I?rt(ke,he,Pe.props.children,gt,Pe.key):he!==null&&(he.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===te&&Qw(Yt)===he.type)?(gt=x(he,Pe.props),gt.ref=ec(ke,he,Pe),gt.return=ke,gt):(gt=fd(Pe.type,Pe.key,Pe.props,null,ke.mode,gt),gt.ref=ec(ke,he,Pe),gt.return=ke,gt)}function Ie(ke,he,Pe,gt){return he===null||he.tag!==4||he.stateNode.containerInfo!==Pe.containerInfo||he.stateNode.implementation!==Pe.implementation?(he=Vp(Pe,ke.mode,gt),he.return=ke,he):(he=x(he,Pe.children||[]),he.return=ke,he)}function rt(ke,he,Pe,gt,Yt){return he===null||he.tag!==7?(he=co(Pe,ke.mode,gt,Yt),he.return=ke,he):(he=x(he,Pe),he.return=ke,he)}function ut(ke,he,Pe){if(typeof he=="string"&&he!==""||typeof he=="number")return he=$p(""+he,ke.mode,Pe),he.return=ke,he;if(typeof he=="object"&&he!==null){switch(he.$$typeof){case W:return Pe=fd(he.type,he.key,he.props,null,ke.mode,Pe),Pe.ref=ec(ke,null,he),Pe.return=ke,Pe;case E:return he=Vp(he,ke.mode,Pe),he.return=ke,he;case te:var gt=he._init;return ut(ke,gt(he._payload),Pe)}if(ye(he)||q(he))return he=co(he,ke.mode,Pe,null),he.return=ke,he;$u(ke,he)}return null}function Ze(ke,he,Pe,gt){var Yt=he!==null?he.key:null;if(typeof Pe=="string"&&Pe!==""||typeof Pe=="number")return Yt!==null?null:ee(ke,he,""+Pe,gt);if(typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case W:return Pe.key===Yt?le(ke,he,Pe,gt):null;case E:return Pe.key===Yt?Ie(ke,he,Pe,gt):null;case te:return Yt=Pe._init,Ze(ke,he,Yt(Pe._payload),gt)}if(ye(Pe)||q(Pe))return Yt!==null?null:rt(ke,he,Pe,gt,null);$u(ke,Pe)}return null}function Et(ke,he,Pe,gt,Yt){if(typeof gt=="string"&>!==""||typeof gt=="number")return ke=ke.get(Pe)||null,ee(he,ke,""+gt,Yt);if(typeof gt=="object"&>!==null){switch(gt.$$typeof){case W:return ke=ke.get(gt.key===null?Pe:gt.key)||null,le(he,ke,gt,Yt);case E:return ke=ke.get(gt.key===null?Pe:gt.key)||null,Ie(he,ke,gt,Yt);case te:var rn=gt._init;return Et(ke,he,Pe,rn(gt._payload),Yt)}if(ye(gt)||q(gt))return ke=ke.get(Pe)||null,rt(he,ke,gt,Yt,null);$u(he,gt)}return null}function qt(ke,he,Pe,gt){for(var Yt=null,rn=null,sn=he,hn=he=0,Gr=null;sn!==null&&hn<Pe.length;hn++){sn.index>hn?(Gr=sn,sn=null):Gr=sn.sibling;var Bn=Ze(ke,sn,Pe[hn],gt);if(Bn===null){sn===null&&(sn=Gr);break}a&&sn&&Bn.alternate===null&&u(ke,sn),he=S(Bn,he,hn),rn===null?Yt=Bn:rn.sibling=Bn,rn=Bn,sn=Gr}if(hn===Pe.length)return h(ke,sn),pr&&to(ke,hn),Yt;if(sn===null){for(;hn<Pe.length;hn++)sn=ut(ke,Pe[hn],gt),sn!==null&&(he=S(sn,he,hn),rn===null?Yt=sn:rn.sibling=sn,rn=sn);return pr&&to(ke,hn),Yt}for(sn=b(ke,sn);hn<Pe.length;hn++)Gr=Et(sn,ke,hn,Pe[hn],gt),Gr!==null&&(a&&Gr.alternate!==null&&sn.delete(Gr.key===null?hn:Gr.key),he=S(Gr,he,hn),rn===null?Yt=Gr:rn.sibling=Gr,rn=Gr);return a&&sn.forEach(function(Da){return u(ke,Da)}),pr&&to(ke,hn),Yt}function Gt(ke,he,Pe,gt){var Yt=q(Pe);if(typeof Yt!="function")throw Error(r(150));if(Pe=Yt.call(Pe),Pe==null)throw Error(r(151));for(var rn=Yt=null,sn=he,hn=he=0,Gr=null,Bn=Pe.next();sn!==null&&!Bn.done;hn++,Bn=Pe.next()){sn.index>hn?(Gr=sn,sn=null):Gr=sn.sibling;var Da=Ze(ke,sn,Bn.value,gt);if(Da===null){sn===null&&(sn=Gr);break}a&&sn&&Da.alternate===null&&u(ke,sn),he=S(Da,he,hn),rn===null?Yt=Da:rn.sibling=Da,rn=Da,sn=Gr}if(Bn.done)return h(ke,sn),pr&&to(ke,hn),Yt;if(sn===null){for(;!Bn.done;hn++,Bn=Pe.next())Bn=ut(ke,Bn.value,gt),Bn!==null&&(he=S(Bn,he,hn),rn===null?Yt=Bn:rn.sibling=Bn,rn=Bn);return pr&&to(ke,hn),Yt}for(sn=b(ke,sn);!Bn.done;hn++,Bn=Pe.next())Bn=Et(sn,ke,hn,Bn.value,gt),Bn!==null&&(a&&Bn.alternate!==null&&sn.delete(Bn.key===null?hn:Bn.key),he=S(Bn,he,hn),rn===null?Yt=Bn:rn.sibling=Bn,rn=Bn);return a&&sn.forEach(function(jA){return u(ke,jA)}),pr&&to(ke,hn),Yt}function Tr(ke,he,Pe,gt){if(typeof Pe=="object"&&Pe!==null&&Pe.type===I&&Pe.key===null&&(Pe=Pe.props.children),typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case W:e:{for(var Yt=Pe.key,rn=he;rn!==null;){if(rn.key===Yt){if(Yt=Pe.type,Yt===I){if(rn.tag===7){h(ke,rn.sibling),he=x(rn,Pe.props.children),he.return=ke,ke=he;break e}}else if(rn.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===te&&Qw(Yt)===rn.type){h(ke,rn.sibling),he=x(rn,Pe.props),he.ref=ec(ke,rn,Pe),he.return=ke,ke=he;break e}h(ke,rn);break}else u(ke,rn);rn=rn.sibling}Pe.type===I?(he=co(Pe.props.children,ke.mode,gt,Pe.key),he.return=ke,ke=he):(gt=fd(Pe.type,Pe.key,Pe.props,null,ke.mode,gt),gt.ref=ec(ke,he,Pe),gt.return=ke,ke=gt)}return A(ke);case E:e:{for(rn=Pe.key;he!==null;){if(he.key===rn)if(he.tag===4&&he.stateNode.containerInfo===Pe.containerInfo&&he.stateNode.implementation===Pe.implementation){h(ke,he.sibling),he=x(he,Pe.children||[]),he.return=ke,ke=he;break e}else{h(ke,he);break}else u(ke,he);he=he.sibling}he=Vp(Pe,ke.mode,gt),he.return=ke,ke=he}return A(ke);case te:return rn=Pe._init,Tr(ke,he,rn(Pe._payload),gt)}if(ye(Pe))return qt(ke,he,Pe,gt);if(q(Pe))return Gt(ke,he,Pe,gt);$u(ke,Pe)}return typeof Pe=="string"&&Pe!==""||typeof Pe=="number"?(Pe=""+Pe,he!==null&&he.tag===6?(h(ke,he.sibling),he=x(he,Pe),he.return=ke,ke=he):(h(ke,he),he=$p(Pe,ke.mode,gt),he.return=ke,ke=he),A(ke)):h(ke,he)}return Tr}var nl=Jw(!0),Zw=Jw(!1),Vu=va(null),Gu=null,rl=null,tp=null;function np(){tp=rl=Gu=null}function rp(a){var u=Vu.current;cr(Vu),a._currentValue=u}function sp(a,u,h){for(;a!==null;){var b=a.alternate;if((a.childLanes&u)!==u?(a.childLanes|=u,b!==null&&(b.childLanes|=u)):b!==null&&(b.childLanes&u)!==u&&(b.childLanes|=u),a===h)break;a=a.return}}function sl(a,u){Gu=a,tp=rl=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&u)!==0&&(ys=!0),a.firstContext=null)}function Ys(a){var u=a._currentValue;if(tp!==a)if(a={context:a,memoizedValue:u,next:null},rl===null){if(Gu===null)throw Error(r(308));rl=a,Gu.dependencies={lanes:0,firstContext:a}}else rl=rl.next=a;return u}var no=null;function ip(a){no===null?no=[a]:no.push(a)}function ey(a,u,h,b){var x=u.interleaved;return x===null?(h.next=h,ip(u)):(h.next=x.next,x.next=h),u.interleaved=h,ea(a,b)}function ea(a,u){a.lanes|=u;var h=a.alternate;for(h!==null&&(h.lanes|=u),h=a,a=a.return;a!==null;)a.childLanes|=u,h=a.alternate,h!==null&&(h.childLanes|=u),h=a,a=a.return;return h.tag===3?h.stateNode:null}var ka=!1;function ap(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ty(a,u){a=a.updateQueue,u.updateQueue===a&&(u.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function ta(a,u){return{eventTime:a,lane:u,tag:0,payload:null,callback:null,next:null}}function xa(a,u,h){var b=a.updateQueue;if(b===null)return null;if(b=b.shared,(On&2)!==0){var x=b.pending;return x===null?u.next=u:(u.next=x.next,x.next=u),b.pending=u,ea(a,h)}return x=b.interleaved,x===null?(u.next=u,ip(b)):(u.next=x.next,x.next=u),b.interleaved=u,ea(a,h)}function Ku(a,u,h){if(u=u.updateQueue,u!==null&&(u=u.shared,(h&4194240)!==0)){var b=u.lanes;b&=a.pendingLanes,h|=b,u.lanes=h,dr(a,h)}}function ny(a,u){var h=a.updateQueue,b=a.alternate;if(b!==null&&(b=b.updateQueue,h===b)){var x=null,S=null;if(h=h.firstBaseUpdate,h!==null){do{var A={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};S===null?x=S=A:S=S.next=A,h=h.next}while(h!==null);S===null?x=S=u:S=S.next=u}else x=S=u;h={baseState:b.baseState,firstBaseUpdate:x,lastBaseUpdate:S,shared:b.shared,effects:b.effects},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=u:a.next=u,h.lastBaseUpdate=u}function Yu(a,u,h,b){var x=a.updateQueue;ka=!1;var S=x.firstBaseUpdate,A=x.lastBaseUpdate,ee=x.shared.pending;if(ee!==null){x.shared.pending=null;var le=ee,Ie=le.next;le.next=null,A===null?S=Ie:A.next=Ie,A=le;var rt=a.alternate;rt!==null&&(rt=rt.updateQueue,ee=rt.lastBaseUpdate,ee!==A&&(ee===null?rt.firstBaseUpdate=Ie:ee.next=Ie,rt.lastBaseUpdate=le))}if(S!==null){var ut=x.baseState;A=0,rt=Ie=le=null,ee=S;do{var Ze=ee.lane,Et=ee.eventTime;if((b&Ze)===Ze){rt!==null&&(rt=rt.next={eventTime:Et,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var qt=a,Gt=ee;switch(Ze=u,Et=h,Gt.tag){case 1:if(qt=Gt.payload,typeof qt=="function"){ut=qt.call(Et,ut,Ze);break e}ut=qt;break e;case 3:qt.flags=qt.flags&-65537|128;case 0:if(qt=Gt.payload,Ze=typeof qt=="function"?qt.call(Et,ut,Ze):qt,Ze==null)break e;ut=P({},ut,Ze);break e;case 2:ka=!0}}ee.callback!==null&&ee.lane!==0&&(a.flags|=64,Ze=x.effects,Ze===null?x.effects=[ee]:Ze.push(ee))}else Et={eventTime:Et,lane:Ze,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},rt===null?(Ie=rt=Et,le=ut):rt=rt.next=Et,A|=Ze;if(ee=ee.next,ee===null){if(ee=x.shared.pending,ee===null)break;Ze=ee,ee=Ze.next,Ze.next=null,x.lastBaseUpdate=Ze,x.shared.pending=null}}while(!0);if(rt===null&&(le=ut),x.baseState=le,x.firstBaseUpdate=Ie,x.lastBaseUpdate=rt,u=x.shared.interleaved,u!==null){x=u;do A|=x.lane,x=x.next;while(x!==u)}else S===null&&(x.shared.lanes=0);io|=A,a.lanes=A,a.memoizedState=ut}}function ry(a,u,h){if(a=u.effects,u.effects=null,a!==null)for(u=0;u<a.length;u++){var b=a[u],x=b.callback;if(x!==null){if(b.callback=null,b=h,typeof x!="function")throw Error(r(191,x));x.call(b)}}}var tc={},Mi=va(tc),nc=va(tc),rc=va(tc);function ro(a){if(a===tc)throw Error(r(174));return a}function op(a,u){switch(Zn(rc,u),Zn(nc,a),Zn(Mi,tc),a=u.nodeType,a){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:Me(null,"");break;default:a=a===8?u.parentNode:u,u=a.namespaceURI||null,a=a.tagName,u=Me(u,a)}cr(Mi),Zn(Mi,u)}function il(){cr(Mi),cr(nc),cr(rc)}function sy(a){ro(rc.current);var u=ro(Mi.current),h=Me(u,a.type);u!==h&&(Zn(nc,a),Zn(Mi,h))}function lp(a){nc.current===a&&(cr(Mi),cr(nc))}var wr=va(0);function Xu(a){for(var u=a;u!==null;){if(u.tag===13){var h=u.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var cp=[];function up(){for(var a=0;a<cp.length;a++)cp[a]._workInProgressVersionPrimary=null;cp.length=0}var Qu=F.ReactCurrentDispatcher,dp=F.ReactCurrentBatchConfig,so=0,yr=null,Or=null,$r=null,Ju=!1,sc=!1,ic=0,GM=0;function as(){throw Error(r(321))}function hp(a,u){if(u===null)return!1;for(var h=0;h<u.length&&h<a.length;h++)if(!di(a[h],u[h]))return!1;return!0}function mp(a,u,h,b,x,S){if(so=S,yr=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Qu.current=a===null||a.memoizedState===null?QM:JM,a=h(b,x),sc){S=0;do{if(sc=!1,ic=0,25<=S)throw Error(r(301));S+=1,$r=Or=null,u.updateQueue=null,Qu.current=ZM,a=h(b,x)}while(sc)}if(Qu.current=td,u=Or!==null&&Or.next!==null,so=0,$r=Or=yr=null,Ju=!1,u)throw Error(r(300));return a}function pp(){var a=ic!==0;return ic=0,a}function Ai(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $r===null?yr.memoizedState=$r=a:$r=$r.next=a,$r}function Xs(){if(Or===null){var a=yr.alternate;a=a!==null?a.memoizedState:null}else a=Or.next;var u=$r===null?yr.memoizedState:$r.next;if(u!==null)$r=u,Or=a;else{if(a===null)throw Error(r(310));Or=a,a={memoizedState:Or.memoizedState,baseState:Or.baseState,baseQueue:Or.baseQueue,queue:Or.queue,next:null},$r===null?yr.memoizedState=$r=a:$r=$r.next=a}return $r}function ac(a,u){return typeof u=="function"?u(a):u}function fp(a){var u=Xs(),h=u.queue;if(h===null)throw Error(r(311));h.lastRenderedReducer=a;var b=Or,x=b.baseQueue,S=h.pending;if(S!==null){if(x!==null){var A=x.next;x.next=S.next,S.next=A}b.baseQueue=x=S,h.pending=null}if(x!==null){S=x.next,b=b.baseState;var ee=A=null,le=null,Ie=S;do{var rt=Ie.lane;if((so&rt)===rt)le!==null&&(le=le.next={lane:0,action:Ie.action,hasEagerState:Ie.hasEagerState,eagerState:Ie.eagerState,next:null}),b=Ie.hasEagerState?Ie.eagerState:a(b,Ie.action);else{var ut={lane:rt,action:Ie.action,hasEagerState:Ie.hasEagerState,eagerState:Ie.eagerState,next:null};le===null?(ee=le=ut,A=b):le=le.next=ut,yr.lanes|=rt,io|=rt}Ie=Ie.next}while(Ie!==null&&Ie!==S);le===null?A=b:le.next=ee,di(b,u.memoizedState)||(ys=!0),u.memoizedState=b,u.baseState=A,u.baseQueue=le,h.lastRenderedState=b}if(a=h.interleaved,a!==null){x=a;do S=x.lane,yr.lanes|=S,io|=S,x=x.next;while(x!==a)}else x===null&&(h.lanes=0);return[u.memoizedState,h.dispatch]}function gp(a){var u=Xs(),h=u.queue;if(h===null)throw Error(r(311));h.lastRenderedReducer=a;var b=h.dispatch,x=h.pending,S=u.memoizedState;if(x!==null){h.pending=null;var A=x=x.next;do S=a(S,A.action),A=A.next;while(A!==x);di(S,u.memoizedState)||(ys=!0),u.memoizedState=S,u.baseQueue===null&&(u.baseState=S),h.lastRenderedState=S}return[S,b]}function iy(){}function ay(a,u){var h=yr,b=Xs(),x=u(),S=!di(b.memoizedState,x);if(S&&(b.memoizedState=x,ys=!0),b=b.queue,bp(cy.bind(null,h,b,a),[a]),b.getSnapshot!==u||S||$r!==null&&$r.memoizedState.tag&1){if(h.flags|=2048,oc(9,ly.bind(null,h,b,x,u),void 0,null),Vr===null)throw Error(r(349));(so&30)!==0||oy(h,u,x)}return x}function oy(a,u,h){a.flags|=16384,a={getSnapshot:u,value:h},u=yr.updateQueue,u===null?(u={lastEffect:null,stores:null},yr.updateQueue=u,u.stores=[a]):(h=u.stores,h===null?u.stores=[a]:h.push(a))}function ly(a,u,h,b){u.value=h,u.getSnapshot=b,uy(u)&&dy(a)}function cy(a,u,h){return h(function(){uy(u)&&dy(a)})}function uy(a){var u=a.getSnapshot;a=a.value;try{var h=u();return!di(a,h)}catch{return!0}}function dy(a){var u=ea(a,1);u!==null&&gi(u,a,1,-1)}function hy(a){var u=Ai();return typeof a=="function"&&(a=a()),u.memoizedState=u.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ac,lastRenderedState:a},u.queue=a,a=a.dispatch=XM.bind(null,yr,a),[u.memoizedState,a]}function oc(a,u,h,b){return a={tag:a,create:u,destroy:h,deps:b,next:null},u=yr.updateQueue,u===null?(u={lastEffect:null,stores:null},yr.updateQueue=u,u.lastEffect=a.next=a):(h=u.lastEffect,h===null?u.lastEffect=a.next=a:(b=h.next,h.next=a,a.next=b,u.lastEffect=a)),a}function my(){return Xs().memoizedState}function Zu(a,u,h,b){var x=Ai();yr.flags|=a,x.memoizedState=oc(1|u,h,void 0,b===void 0?null:b)}function ed(a,u,h,b){var x=Xs();b=b===void 0?null:b;var S=void 0;if(Or!==null){var A=Or.memoizedState;if(S=A.destroy,b!==null&&hp(b,A.deps)){x.memoizedState=oc(u,h,S,b);return}}yr.flags|=a,x.memoizedState=oc(1|u,h,S,b)}function py(a,u){return Zu(8390656,8,a,u)}function bp(a,u){return ed(2048,8,a,u)}function fy(a,u){return ed(4,2,a,u)}function gy(a,u){return ed(4,4,a,u)}function by(a,u){if(typeof u=="function")return a=a(),u(a),function(){u(null)};if(u!=null)return a=a(),u.current=a,function(){u.current=null}}function vy(a,u,h){return h=h!=null?h.concat([a]):null,ed(4,4,by.bind(null,u,a),h)}function vp(){}function wy(a,u){var h=Xs();u=u===void 0?null:u;var b=h.memoizedState;return b!==null&&u!==null&&hp(u,b[1])?b[0]:(h.memoizedState=[a,u],a)}function yy(a,u){var h=Xs();u=u===void 0?null:u;var b=h.memoizedState;return b!==null&&u!==null&&hp(u,b[1])?b[0]:(a=a(),h.memoizedState=[a,u],a)}function ky(a,u,h){return(so&21)===0?(a.baseState&&(a.baseState=!1,ys=!0),a.memoizedState=h):(di(h,u)||(h=Lr(),yr.lanes|=h,io|=h,a.baseState=!0),u)}function KM(a,u){var h=wt;wt=h!==0&&4>h?h:4,a(!0);var b=dp.transition;dp.transition={};try{a(!1),u()}finally{wt=h,dp.transition=b}}function xy(){return Xs().memoizedState}function YM(a,u,h){var b=Ta(a);if(h={lane:b,action:h,hasEagerState:!1,eagerState:null,next:null},Sy(a))Cy(u,h);else if(h=ey(a,u,h,b),h!==null){var x=ms();gi(h,a,b,x),jy(h,u,b)}}function XM(a,u,h){var b=Ta(a),x={lane:b,action:h,hasEagerState:!1,eagerState:null,next:null};if(Sy(a))Cy(u,x);else{var S=a.alternate;if(a.lanes===0&&(S===null||S.lanes===0)&&(S=u.lastRenderedReducer,S!==null))try{var A=u.lastRenderedState,ee=S(A,h);if(x.hasEagerState=!0,x.eagerState=ee,di(ee,A)){var le=u.interleaved;le===null?(x.next=x,ip(u)):(x.next=le.next,le.next=x),u.interleaved=x;return}}catch{}finally{}h=ey(a,u,x,b),h!==null&&(x=ms(),gi(h,a,b,x),jy(h,u,b))}}function Sy(a){var u=a.alternate;return a===yr||u!==null&&u===yr}function Cy(a,u){sc=Ju=!0;var h=a.pending;h===null?u.next=u:(u.next=h.next,h.next=u),a.pending=u}function jy(a,u,h){if((h&4194240)!==0){var b=u.lanes;b&=a.pendingLanes,h|=b,u.lanes=h,dr(a,h)}}var td={readContext:Ys,useCallback:as,useContext:as,useEffect:as,useImperativeHandle:as,useInsertionEffect:as,useLayoutEffect:as,useMemo:as,useReducer:as,useRef:as,useState:as,useDebugValue:as,useDeferredValue:as,useTransition:as,useMutableSource:as,useSyncExternalStore:as,useId:as,unstable_isNewReconciler:!1},QM={readContext:Ys,useCallback:function(a,u){return Ai().memoizedState=[a,u===void 0?null:u],a},useContext:Ys,useEffect:py,useImperativeHandle:function(a,u,h){return h=h!=null?h.concat([a]):null,Zu(4194308,4,by.bind(null,u,a),h)},useLayoutEffect:function(a,u){return Zu(4194308,4,a,u)},useInsertionEffect:function(a,u){return Zu(4,2,a,u)},useMemo:function(a,u){var h=Ai();return u=u===void 0?null:u,a=a(),h.memoizedState=[a,u],a},useReducer:function(a,u,h){var b=Ai();return u=h!==void 0?h(u):u,b.memoizedState=b.baseState=u,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:u},b.queue=a,a=a.dispatch=YM.bind(null,yr,a),[b.memoizedState,a]},useRef:function(a){var u=Ai();return a={current:a},u.memoizedState=a},useState:hy,useDebugValue:vp,useDeferredValue:function(a){return Ai().memoizedState=a},useTransition:function(){var a=hy(!1),u=a[0];return a=KM.bind(null,a[1]),Ai().memoizedState=a,[u,a]},useMutableSource:function(){},useSyncExternalStore:function(a,u,h){var b=yr,x=Ai();if(pr){if(h===void 0)throw Error(r(407));h=h()}else{if(h=u(),Vr===null)throw Error(r(349));(so&30)!==0||oy(b,u,h)}x.memoizedState=h;var S={value:h,getSnapshot:u};return x.queue=S,py(cy.bind(null,b,S,a),[a]),b.flags|=2048,oc(9,ly.bind(null,b,S,h,u),void 0,null),h},useId:function(){var a=Ai(),u=Vr.identifierPrefix;if(pr){var h=Zi,b=Ji;h=(b&~(1<<32-St(b)-1)).toString(32)+h,u=":"+u+"R"+h,h=ic++,0<h&&(u+="H"+h.toString(32)),u+=":"}else h=GM++,u=":"+u+"r"+h.toString(32)+":";return a.memoizedState=u},unstable_isNewReconciler:!1},JM={readContext:Ys,useCallback:wy,useContext:Ys,useEffect:bp,useImperativeHandle:vy,useInsertionEffect:fy,useLayoutEffect:gy,useMemo:yy,useReducer:fp,useRef:my,useState:function(){return fp(ac)},useDebugValue:vp,useDeferredValue:function(a){var u=Xs();return ky(u,Or.memoizedState,a)},useTransition:function(){var a=fp(ac)[0],u=Xs().memoizedState;return[a,u]},useMutableSource:iy,useSyncExternalStore:ay,useId:xy,unstable_isNewReconciler:!1},ZM={readContext:Ys,useCallback:wy,useContext:Ys,useEffect:bp,useImperativeHandle:vy,useInsertionEffect:fy,useLayoutEffect:gy,useMemo:yy,useReducer:gp,useRef:my,useState:function(){return gp(ac)},useDebugValue:vp,useDeferredValue:function(a){var u=Xs();return Or===null?u.memoizedState=a:ky(u,Or.memoizedState,a)},useTransition:function(){var a=gp(ac)[0],u=Xs().memoizedState;return[a,u]},useMutableSource:iy,useSyncExternalStore:ay,useId:xy,unstable_isNewReconciler:!1};function mi(a,u){if(a&&a.defaultProps){u=P({},u),a=a.defaultProps;for(var h in a)u[h]===void 0&&(u[h]=a[h]);return u}return u}function wp(a,u,h,b){u=a.memoizedState,h=h(b,u),h=h==null?u:P({},u,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var nd={isMounted:function(a){return(a=a._reactInternals)?ct(a)===a:!1},enqueueSetState:function(a,u,h){a=a._reactInternals;var b=ms(),x=Ta(a),S=ta(b,x);S.payload=u,h!=null&&(S.callback=h),u=xa(a,S,x),u!==null&&(gi(u,a,x,b),Ku(u,a,x))},enqueueReplaceState:function(a,u,h){a=a._reactInternals;var b=ms(),x=Ta(a),S=ta(b,x);S.tag=1,S.payload=u,h!=null&&(S.callback=h),u=xa(a,S,x),u!==null&&(gi(u,a,x,b),Ku(u,a,x))},enqueueForceUpdate:function(a,u){a=a._reactInternals;var h=ms(),b=Ta(a),x=ta(h,b);x.tag=2,u!=null&&(x.callback=u),u=xa(a,x,b),u!==null&&(gi(u,a,b,h),Ku(u,a,b))}};function Ty(a,u,h,b,x,S,A){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(b,S,A):u.prototype&&u.prototype.isPureReactComponent?!Gl(h,b)||!Gl(x,S):!0}function Ny(a,u,h){var b=!1,x=wa,S=u.contextType;return typeof S=="object"&&S!==null?S=Ys(S):(x=ws(u)?Za:is.current,b=u.contextTypes,S=(b=b!=null)?Jo(a,x):wa),u=new u(h,S),a.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=nd,a.stateNode=u,u._reactInternals=a,b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=x,a.__reactInternalMemoizedMaskedChildContext=S),u}function Py(a,u,h,b){a=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(h,b),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(h,b),u.state!==a&&nd.enqueueReplaceState(u,u.state,null)}function yp(a,u,h,b){var x=a.stateNode;x.props=h,x.state=a.memoizedState,x.refs={},ap(a);var S=u.contextType;typeof S=="object"&&S!==null?x.context=Ys(S):(S=ws(u)?Za:is.current,x.context=Jo(a,S)),x.state=a.memoizedState,S=u.getDerivedStateFromProps,typeof S=="function"&&(wp(a,u,S,h),x.state=a.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(u=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),u!==x.state&&nd.enqueueReplaceState(x,x.state,null),Yu(a,h,x,b),x.state=a.memoizedState),typeof x.componentDidMount=="function"&&(a.flags|=4194308)}function al(a,u){try{var h="",b=u;do h+=se(b),b=b.return;while(b);var x=h}catch(S){x=`
|
|
40
|
+
Error generating stack: `+S.message+`
|
|
41
|
+
`+S.stack}return{value:a,source:u,stack:x,digest:null}}function kp(a,u,h){return{value:a,source:null,stack:h??null,digest:u??null}}function xp(a,u){try{console.error(u.value)}catch(h){setTimeout(function(){throw h})}}var eA=typeof WeakMap=="function"?WeakMap:Map;function Dy(a,u,h){h=ta(-1,h),h.tag=3,h.payload={element:null};var b=u.value;return h.callback=function(){cd||(cd=!0,_p=b),xp(a,u)},h}function Ry(a,u,h){h=ta(-1,h),h.tag=3;var b=a.type.getDerivedStateFromError;if(typeof b=="function"){var x=u.value;h.payload=function(){return b(x)},h.callback=function(){xp(a,u)}}var S=a.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(h.callback=function(){xp(a,u),typeof b!="function"&&(Ca===null?Ca=new Set([this]):Ca.add(this));var A=u.stack;this.componentDidCatch(u.value,{componentStack:A!==null?A:""})}),h}function My(a,u,h){var b=a.pingCache;if(b===null){b=a.pingCache=new eA;var x=new Set;b.set(u,x)}else x=b.get(u),x===void 0&&(x=new Set,b.set(u,x));x.has(h)||(x.add(h),a=pA.bind(null,a,u,h),u.then(a,a))}function Ay(a){do{var u;if((u=a.tag===13)&&(u=a.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return a;a=a.return}while(a!==null);return null}function Iy(a,u,h,b,x){return(a.mode&1)===0?(a===u?a.flags|=65536:(a.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(u=ta(-1,1),u.tag=2,xa(h,u,1))),h.lanes|=1),a):(a.flags|=65536,a.lanes=x,a)}var tA=F.ReactCurrentOwner,ys=!1;function hs(a,u,h,b){u.child=a===null?Zw(u,null,h,b):nl(u,a.child,h,b)}function Ey(a,u,h,b,x){h=h.render;var S=u.ref;return sl(u,x),b=mp(a,u,h,b,S,x),h=pp(),a!==null&&!ys?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~x,na(a,u,x)):(pr&&h&&Xm(u),u.flags|=1,hs(a,u,b,x),u.child)}function Ly(a,u,h,b,x){if(a===null){var S=h.type;return typeof S=="function"&&!qp(S)&&S.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(u.tag=15,u.type=S,Fy(a,u,S,b,x)):(a=fd(h.type,null,b,u,u.mode,x),a.ref=u.ref,a.return=u,u.child=a)}if(S=a.child,(a.lanes&x)===0){var A=S.memoizedProps;if(h=h.compare,h=h!==null?h:Gl,h(A,b)&&a.ref===u.ref)return na(a,u,x)}return u.flags|=1,a=Pa(S,b),a.ref=u.ref,a.return=u,u.child=a}function Fy(a,u,h,b,x){if(a!==null){var S=a.memoizedProps;if(Gl(S,b)&&a.ref===u.ref)if(ys=!1,u.pendingProps=b=S,(a.lanes&x)!==0)(a.flags&131072)!==0&&(ys=!0);else return u.lanes=a.lanes,na(a,u,x)}return Sp(a,u,h,b,x)}function _y(a,u,h){var b=u.pendingProps,x=b.children,S=a!==null?a.memoizedState:null;if(b.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},Zn(ll,Ws),Ws|=h;else{if((h&1073741824)===0)return a=S!==null?S.baseLanes|h:h,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:a,cachePool:null,transitions:null},u.updateQueue=null,Zn(ll,Ws),Ws|=a,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=S!==null?S.baseLanes:h,Zn(ll,Ws),Ws|=b}else S!==null?(b=S.baseLanes|h,u.memoizedState=null):b=h,Zn(ll,Ws),Ws|=b;return hs(a,u,x,h),u.child}function Oy(a,u){var h=u.ref;(a===null&&h!==null||a!==null&&a.ref!==h)&&(u.flags|=512,u.flags|=2097152)}function Sp(a,u,h,b,x){var S=ws(h)?Za:is.current;return S=Jo(u,S),sl(u,x),h=mp(a,u,h,b,S,x),b=pp(),a!==null&&!ys?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~x,na(a,u,x)):(pr&&b&&Xm(u),u.flags|=1,hs(a,u,h,x),u.child)}function By(a,u,h,b,x){if(ws(h)){var S=!0;Wu(u)}else S=!1;if(sl(u,x),u.stateNode===null)sd(a,u),Ny(u,h,b),yp(u,h,b,x),b=!0;else if(a===null){var A=u.stateNode,ee=u.memoizedProps;A.props=ee;var le=A.context,Ie=h.contextType;typeof Ie=="object"&&Ie!==null?Ie=Ys(Ie):(Ie=ws(h)?Za:is.current,Ie=Jo(u,Ie));var rt=h.getDerivedStateFromProps,ut=typeof rt=="function"||typeof A.getSnapshotBeforeUpdate=="function";ut||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(ee!==b||le!==Ie)&&Py(u,A,b,Ie),ka=!1;var Ze=u.memoizedState;A.state=Ze,Yu(u,b,A,x),le=u.memoizedState,ee!==b||Ze!==le||vs.current||ka?(typeof rt=="function"&&(wp(u,h,rt,b),le=u.memoizedState),(ee=ka||Ty(u,h,ee,b,Ze,le,Ie))?(ut||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(u.flags|=4194308)):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=b,u.memoizedState=le),A.props=b,A.state=le,A.context=Ie,b=ee):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),b=!1)}else{A=u.stateNode,ty(a,u),ee=u.memoizedProps,Ie=u.type===u.elementType?ee:mi(u.type,ee),A.props=Ie,ut=u.pendingProps,Ze=A.context,le=h.contextType,typeof le=="object"&&le!==null?le=Ys(le):(le=ws(h)?Za:is.current,le=Jo(u,le));var Et=h.getDerivedStateFromProps;(rt=typeof Et=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(ee!==ut||Ze!==le)&&Py(u,A,b,le),ka=!1,Ze=u.memoizedState,A.state=Ze,Yu(u,b,A,x);var qt=u.memoizedState;ee!==ut||Ze!==qt||vs.current||ka?(typeof Et=="function"&&(wp(u,h,Et,b),qt=u.memoizedState),(Ie=ka||Ty(u,h,Ie,b,Ze,qt,le)||!1)?(rt||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(b,qt,le),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(b,qt,le)),typeof A.componentDidUpdate=="function"&&(u.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof A.componentDidUpdate!="function"||ee===a.memoizedProps&&Ze===a.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||ee===a.memoizedProps&&Ze===a.memoizedState||(u.flags|=1024),u.memoizedProps=b,u.memoizedState=qt),A.props=b,A.state=qt,A.context=le,b=Ie):(typeof A.componentDidUpdate!="function"||ee===a.memoizedProps&&Ze===a.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||ee===a.memoizedProps&&Ze===a.memoizedState||(u.flags|=1024),b=!1)}return Cp(a,u,h,b,S,x)}function Cp(a,u,h,b,x,S){Oy(a,u);var A=(u.flags&128)!==0;if(!b&&!A)return x&&qw(u,h,!1),na(a,u,S);b=u.stateNode,tA.current=u;var ee=A&&typeof h.getDerivedStateFromError!="function"?null:b.render();return u.flags|=1,a!==null&&A?(u.child=nl(u,a.child,null,S),u.child=nl(u,null,ee,S)):hs(a,u,ee,S),u.memoizedState=b.state,x&&qw(u,h,!0),u.child}function Wy(a){var u=a.stateNode;u.pendingContext?Hw(a,u.pendingContext,u.pendingContext!==u.context):u.context&&Hw(a,u.context,!1),op(a,u.containerInfo)}function Uy(a,u,h,b,x){return tl(),ep(x),u.flags|=256,hs(a,u,h,b),u.child}var jp={dehydrated:null,treeContext:null,retryLane:0};function Tp(a){return{baseLanes:a,cachePool:null,transitions:null}}function Hy(a,u,h){var b=u.pendingProps,x=wr.current,S=!1,A=(u.flags&128)!==0,ee;if((ee=A)||(ee=a!==null&&a.memoizedState===null?!1:(x&2)!==0),ee?(S=!0,u.flags&=-129):(a===null||a.memoizedState!==null)&&(x|=1),Zn(wr,x&1),a===null)return Zm(u),a=u.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((u.mode&1)===0?u.lanes=1:a.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(A=b.children,a=b.fallback,S?(b=u.mode,S=u.child,A={mode:"hidden",children:A},(b&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=A):S=gd(A,b,0,null),a=co(a,b,h,null),S.return=u,a.return=u,S.sibling=a,u.child=S,u.child.memoizedState=Tp(h),u.memoizedState=jp,a):Np(u,A));if(x=a.memoizedState,x!==null&&(ee=x.dehydrated,ee!==null))return nA(a,u,A,b,ee,x,h);if(S){S=b.fallback,A=u.mode,x=a.child,ee=x.sibling;var le={mode:"hidden",children:b.children};return(A&1)===0&&u.child!==x?(b=u.child,b.childLanes=0,b.pendingProps=le,u.deletions=null):(b=Pa(x,le),b.subtreeFlags=x.subtreeFlags&14680064),ee!==null?S=Pa(ee,S):(S=co(S,A,h,null),S.flags|=2),S.return=u,b.return=u,b.sibling=S,u.child=b,b=S,S=u.child,A=a.child.memoizedState,A=A===null?Tp(h):{baseLanes:A.baseLanes|h,cachePool:null,transitions:A.transitions},S.memoizedState=A,S.childLanes=a.childLanes&~h,u.memoizedState=jp,b}return S=a.child,a=S.sibling,b=Pa(S,{mode:"visible",children:b.children}),(u.mode&1)===0&&(b.lanes=h),b.return=u,b.sibling=null,a!==null&&(h=u.deletions,h===null?(u.deletions=[a],u.flags|=16):h.push(a)),u.child=b,u.memoizedState=null,b}function Np(a,u){return u=gd({mode:"visible",children:u},a.mode,0,null),u.return=a,a.child=u}function rd(a,u,h,b){return b!==null&&ep(b),nl(u,a.child,null,h),a=Np(u,u.pendingProps.children),a.flags|=2,u.memoizedState=null,a}function nA(a,u,h,b,x,S,A){if(h)return u.flags&256?(u.flags&=-257,b=kp(Error(r(422))),rd(a,u,A,b)):u.memoizedState!==null?(u.child=a.child,u.flags|=128,null):(S=b.fallback,x=u.mode,b=gd({mode:"visible",children:b.children},x,0,null),S=co(S,x,A,null),S.flags|=2,b.return=u,S.return=u,b.sibling=S,u.child=b,(u.mode&1)!==0&&nl(u,a.child,null,A),u.child.memoizedState=Tp(A),u.memoizedState=jp,S);if((u.mode&1)===0)return rd(a,u,A,null);if(x.data==="$!"){if(b=x.nextSibling&&x.nextSibling.dataset,b)var ee=b.dgst;return b=ee,S=Error(r(419)),b=kp(S,b,void 0),rd(a,u,A,b)}if(ee=(A&a.childLanes)!==0,ys||ee){if(b=Vr,b!==null){switch(A&-A){case 4:x=2;break;case 16:x=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(b.suspendedLanes|A))!==0?0:x,x!==0&&x!==S.retryLane&&(S.retryLane=x,ea(a,x),gi(b,a,x,-1))}return zp(),b=kp(Error(r(421))),rd(a,u,A,b)}return x.data==="$?"?(u.flags|=128,u.child=a.child,u=fA.bind(null,a),x._reactRetry=u,null):(a=S.treeContext,Bs=ba(x.nextSibling),Os=u,pr=!0,hi=null,a!==null&&(Gs[Ks++]=Ji,Gs[Ks++]=Zi,Gs[Ks++]=eo,Ji=a.id,Zi=a.overflow,eo=u),u=Np(u,b.children),u.flags|=4096,u)}function zy(a,u,h){a.lanes|=u;var b=a.alternate;b!==null&&(b.lanes|=u),sp(a.return,u,h)}function Pp(a,u,h,b,x){var S=a.memoizedState;S===null?a.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:b,tail:h,tailMode:x}:(S.isBackwards=u,S.rendering=null,S.renderingStartTime=0,S.last=b,S.tail=h,S.tailMode=x)}function qy(a,u,h){var b=u.pendingProps,x=b.revealOrder,S=b.tail;if(hs(a,u,b.children,h),b=wr.current,(b&2)!==0)b=b&1|2,u.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=u.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&zy(a,h,u);else if(a.tag===19)zy(a,h,u);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===u)break e;for(;a.sibling===null;){if(a.return===null||a.return===u)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}b&=1}if(Zn(wr,b),(u.mode&1)===0)u.memoizedState=null;else switch(x){case"forwards":for(h=u.child,x=null;h!==null;)a=h.alternate,a!==null&&Xu(a)===null&&(x=h),h=h.sibling;h=x,h===null?(x=u.child,u.child=null):(x=h.sibling,h.sibling=null),Pp(u,!1,x,h,S);break;case"backwards":for(h=null,x=u.child,u.child=null;x!==null;){if(a=x.alternate,a!==null&&Xu(a)===null){u.child=x;break}a=x.sibling,x.sibling=h,h=x,x=a}Pp(u,!0,h,null,S);break;case"together":Pp(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function sd(a,u){(u.mode&1)===0&&a!==null&&(a.alternate=null,u.alternate=null,u.flags|=2)}function na(a,u,h){if(a!==null&&(u.dependencies=a.dependencies),io|=u.lanes,(h&u.childLanes)===0)return null;if(a!==null&&u.child!==a.child)throw Error(r(153));if(u.child!==null){for(a=u.child,h=Pa(a,a.pendingProps),u.child=h,h.return=u;a.sibling!==null;)a=a.sibling,h=h.sibling=Pa(a,a.pendingProps),h.return=u;h.sibling=null}return u.child}function rA(a,u,h){switch(u.tag){case 3:Wy(u),tl();break;case 5:sy(u);break;case 1:ws(u.type)&&Wu(u);break;case 4:op(u,u.stateNode.containerInfo);break;case 10:var b=u.type._context,x=u.memoizedProps.value;Zn(Vu,b._currentValue),b._currentValue=x;break;case 13:if(b=u.memoizedState,b!==null)return b.dehydrated!==null?(Zn(wr,wr.current&1),u.flags|=128,null):(h&u.child.childLanes)!==0?Hy(a,u,h):(Zn(wr,wr.current&1),a=na(a,u,h),a!==null?a.sibling:null);Zn(wr,wr.current&1);break;case 19:if(b=(h&u.childLanes)!==0,(a.flags&128)!==0){if(b)return qy(a,u,h);u.flags|=128}if(x=u.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),Zn(wr,wr.current),b)break;return null;case 22:case 23:return u.lanes=0,_y(a,u,h)}return na(a,u,h)}var $y,Dp,Vy,Gy;$y=function(a,u){for(var h=u.child;h!==null;){if(h.tag===5||h.tag===6)a.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},Dp=function(){},Vy=function(a,u,h,b){var x=a.memoizedProps;if(x!==b){a=u.stateNode,ro(Mi.current);var S=null;switch(h){case"input":x=Ct(a,x),b=Ct(a,b),S=[];break;case"select":x=P({},x,{value:void 0}),b=P({},b,{value:void 0}),S=[];break;case"textarea":x=je(a,x),b=je(a,b),S=[];break;default:typeof x.onClick!="function"&&typeof b.onClick=="function"&&(a.onclick=_u)}Ft(h,b);var A;h=null;for(Ie in x)if(!b.hasOwnProperty(Ie)&&x.hasOwnProperty(Ie)&&x[Ie]!=null)if(Ie==="style"){var ee=x[Ie];for(A in ee)ee.hasOwnProperty(A)&&(h||(h={}),h[A]="")}else Ie!=="dangerouslySetInnerHTML"&&Ie!=="children"&&Ie!=="suppressContentEditableWarning"&&Ie!=="suppressHydrationWarning"&&Ie!=="autoFocus"&&(i.hasOwnProperty(Ie)?S||(S=[]):(S=S||[]).push(Ie,null));for(Ie in b){var le=b[Ie];if(ee=x!=null?x[Ie]:void 0,b.hasOwnProperty(Ie)&&le!==ee&&(le!=null||ee!=null))if(Ie==="style")if(ee){for(A in ee)!ee.hasOwnProperty(A)||le&&le.hasOwnProperty(A)||(h||(h={}),h[A]="");for(A in le)le.hasOwnProperty(A)&&ee[A]!==le[A]&&(h||(h={}),h[A]=le[A])}else h||(S||(S=[]),S.push(Ie,h)),h=le;else Ie==="dangerouslySetInnerHTML"?(le=le?le.__html:void 0,ee=ee?ee.__html:void 0,le!=null&&ee!==le&&(S=S||[]).push(Ie,le)):Ie==="children"?typeof le!="string"&&typeof le!="number"||(S=S||[]).push(Ie,""+le):Ie!=="suppressContentEditableWarning"&&Ie!=="suppressHydrationWarning"&&(i.hasOwnProperty(Ie)?(le!=null&&Ie==="onScroll"&&lr("scroll",a),S||ee===le||(S=[])):(S=S||[]).push(Ie,le))}h&&(S=S||[]).push("style",h);var Ie=S;(u.updateQueue=Ie)&&(u.flags|=4)}},Gy=function(a,u,h,b){h!==b&&(u.flags|=4)};function lc(a,u){if(!pr)switch(a.tailMode){case"hidden":u=a.tail;for(var h=null;u!==null;)u.alternate!==null&&(h=u),u=u.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var b=null;h!==null;)h.alternate!==null&&(b=h),h=h.sibling;b===null?u||a.tail===null?a.tail=null:a.tail.sibling=null:b.sibling=null}}function os(a){var u=a.alternate!==null&&a.alternate.child===a.child,h=0,b=0;if(u)for(var x=a.child;x!==null;)h|=x.lanes|x.childLanes,b|=x.subtreeFlags&14680064,b|=x.flags&14680064,x.return=a,x=x.sibling;else for(x=a.child;x!==null;)h|=x.lanes|x.childLanes,b|=x.subtreeFlags,b|=x.flags,x.return=a,x=x.sibling;return a.subtreeFlags|=b,a.childLanes=h,u}function sA(a,u,h){var b=u.pendingProps;switch(Qm(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return os(u),null;case 1:return ws(u.type)&&Bu(),os(u),null;case 3:return b=u.stateNode,il(),cr(vs),cr(is),up(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(a===null||a.child===null)&&(qu(u)?u.flags|=4:a===null||a.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,hi!==null&&(Wp(hi),hi=null))),Dp(a,u),os(u),null;case 5:lp(u);var x=ro(rc.current);if(h=u.type,a!==null&&u.stateNode!=null)Vy(a,u,h,b,x),a.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!b){if(u.stateNode===null)throw Error(r(166));return os(u),null}if(a=ro(Mi.current),qu(u)){b=u.stateNode,h=u.type;var S=u.memoizedProps;switch(b[Ri]=u,b[Jl]=S,a=(u.mode&1)!==0,h){case"dialog":lr("cancel",b),lr("close",b);break;case"iframe":case"object":case"embed":lr("load",b);break;case"video":case"audio":for(x=0;x<Yl.length;x++)lr(Yl[x],b);break;case"source":lr("error",b);break;case"img":case"image":case"link":lr("error",b),lr("load",b);break;case"details":lr("toggle",b);break;case"input":nt(b,S),lr("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!S.multiple},lr("invalid",b);break;case"textarea":Fe(b,S),lr("invalid",b)}Ft(h,S),x=null;for(var A in S)if(S.hasOwnProperty(A)){var ee=S[A];A==="children"?typeof ee=="string"?b.textContent!==ee&&(S.suppressHydrationWarning!==!0&&Fu(b.textContent,ee,a),x=["children",ee]):typeof ee=="number"&&b.textContent!==""+ee&&(S.suppressHydrationWarning!==!0&&Fu(b.textContent,ee,a),x=["children",""+ee]):i.hasOwnProperty(A)&&ee!=null&&A==="onScroll"&&lr("scroll",b)}switch(h){case"input":lt(b),Ue(b,S,!0);break;case"textarea":lt(b),kt(b);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(b.onclick=_u)}b=x,u.updateQueue=b,b!==null&&(u.flags|=4)}else{A=x.nodeType===9?x:x.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=me(h)),a==="http://www.w3.org/1999/xhtml"?h==="script"?(a=A.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof b.is=="string"?a=A.createElement(h,{is:b.is}):(a=A.createElement(h),h==="select"&&(A=a,b.multiple?A.multiple=!0:b.size&&(A.size=b.size))):a=A.createElementNS(a,h),a[Ri]=u,a[Jl]=b,$y(a,u,!1,!1),u.stateNode=a;e:{switch(A=Wt(h,b),h){case"dialog":lr("cancel",a),lr("close",a),x=b;break;case"iframe":case"object":case"embed":lr("load",a),x=b;break;case"video":case"audio":for(x=0;x<Yl.length;x++)lr(Yl[x],a);x=b;break;case"source":lr("error",a),x=b;break;case"img":case"image":case"link":lr("error",a),lr("load",a),x=b;break;case"details":lr("toggle",a),x=b;break;case"input":nt(a,b),x=Ct(a,b),lr("invalid",a);break;case"option":x=b;break;case"select":a._wrapperState={wasMultiple:!!b.multiple},x=P({},b,{value:void 0}),lr("invalid",a);break;case"textarea":Fe(a,b),x=je(a,b),lr("invalid",a);break;default:x=b}Ft(h,x),ee=x;for(S in ee)if(ee.hasOwnProperty(S)){var le=ee[S];S==="style"?Nt(a,le):S==="dangerouslySetInnerHTML"?(le=le?le.__html:void 0,le!=null&&ze(a,le)):S==="children"?typeof le=="string"?(h!=="textarea"||le!=="")&&vt(a,le):typeof le=="number"&&vt(a,""+le):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(i.hasOwnProperty(S)?le!=null&&S==="onScroll"&&lr("scroll",a):le!=null&&D(a,S,le,A))}switch(h){case"input":lt(a),Ue(a,b,!1);break;case"textarea":lt(a),kt(a);break;case"option":b.value!=null&&a.setAttribute("value",""+Ee(b.value));break;case"select":a.multiple=!!b.multiple,S=b.value,S!=null?He(a,!!b.multiple,S,!1):b.defaultValue!=null&&He(a,!!b.multiple,b.defaultValue,!0);break;default:typeof x.onClick=="function"&&(a.onclick=_u)}switch(h){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return os(u),null;case 6:if(a&&u.stateNode!=null)Gy(a,u,a.memoizedProps,b);else{if(typeof b!="string"&&u.stateNode===null)throw Error(r(166));if(h=ro(rc.current),ro(Mi.current),qu(u)){if(b=u.stateNode,h=u.memoizedProps,b[Ri]=u,(S=b.nodeValue!==h)&&(a=Os,a!==null))switch(a.tag){case 3:Fu(b.nodeValue,h,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Fu(b.nodeValue,h,(a.mode&1)!==0)}S&&(u.flags|=4)}else b=(h.nodeType===9?h:h.ownerDocument).createTextNode(b),b[Ri]=u,u.stateNode=b}return os(u),null;case 13:if(cr(wr),b=u.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(pr&&Bs!==null&&(u.mode&1)!==0&&(u.flags&128)===0)Xw(),tl(),u.flags|=98560,S=!1;else if(S=qu(u),b!==null&&b.dehydrated!==null){if(a===null){if(!S)throw Error(r(318));if(S=u.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(r(317));S[Ri]=u}else tl(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;os(u),S=!1}else hi!==null&&(Wp(hi),hi=null),S=!0;if(!S)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=h,u):(b=b!==null,b!==(a!==null&&a.memoizedState!==null)&&b&&(u.child.flags|=8192,(u.mode&1)!==0&&(a===null||(wr.current&1)!==0?Br===0&&(Br=3):zp())),u.updateQueue!==null&&(u.flags|=4),os(u),null);case 4:return il(),Dp(a,u),a===null&&Xl(u.stateNode.containerInfo),os(u),null;case 10:return rp(u.type._context),os(u),null;case 17:return ws(u.type)&&Bu(),os(u),null;case 19:if(cr(wr),S=u.memoizedState,S===null)return os(u),null;if(b=(u.flags&128)!==0,A=S.rendering,A===null)if(b)lc(S,!1);else{if(Br!==0||a!==null&&(a.flags&128)!==0)for(a=u.child;a!==null;){if(A=Xu(a),A!==null){for(u.flags|=128,lc(S,!1),b=A.updateQueue,b!==null&&(u.updateQueue=b,u.flags|=4),u.subtreeFlags=0,b=h,h=u.child;h!==null;)S=h,a=b,S.flags&=14680066,A=S.alternate,A===null?(S.childLanes=0,S.lanes=a,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=A.childLanes,S.lanes=A.lanes,S.child=A.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=A.memoizedProps,S.memoizedState=A.memoizedState,S.updateQueue=A.updateQueue,S.type=A.type,a=A.dependencies,S.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),h=h.sibling;return Zn(wr,wr.current&1|2),u.child}a=a.sibling}S.tail!==null&&Jt()>cl&&(u.flags|=128,b=!0,lc(S,!1),u.lanes=4194304)}else{if(!b)if(a=Xu(A),a!==null){if(u.flags|=128,b=!0,h=a.updateQueue,h!==null&&(u.updateQueue=h,u.flags|=4),lc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!A.alternate&&!pr)return os(u),null}else 2*Jt()-S.renderingStartTime>cl&&h!==1073741824&&(u.flags|=128,b=!0,lc(S,!1),u.lanes=4194304);S.isBackwards?(A.sibling=u.child,u.child=A):(h=S.last,h!==null?h.sibling=A:u.child=A,S.last=A)}return S.tail!==null?(u=S.tail,S.rendering=u,S.tail=u.sibling,S.renderingStartTime=Jt(),u.sibling=null,h=wr.current,Zn(wr,b?h&1|2:h&1),u):(os(u),null);case 22:case 23:return Hp(),b=u.memoizedState!==null,a!==null&&a.memoizedState!==null!==b&&(u.flags|=8192),b&&(u.mode&1)!==0?(Ws&1073741824)!==0&&(os(u),u.subtreeFlags&6&&(u.flags|=8192)):os(u),null;case 24:return null;case 25:return null}throw Error(r(156,u.tag))}function iA(a,u){switch(Qm(u),u.tag){case 1:return ws(u.type)&&Bu(),a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 3:return il(),cr(vs),cr(is),up(),a=u.flags,(a&65536)!==0&&(a&128)===0?(u.flags=a&-65537|128,u):null;case 5:return lp(u),null;case 13:if(cr(wr),a=u.memoizedState,a!==null&&a.dehydrated!==null){if(u.alternate===null)throw Error(r(340));tl()}return a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 19:return cr(wr),null;case 4:return il(),null;case 10:return rp(u.type._context),null;case 22:case 23:return Hp(),null;case 24:return null;default:return null}}var id=!1,ls=!1,aA=typeof WeakSet=="function"?WeakSet:Set,Bt=null;function ol(a,u){var h=a.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(b){Sr(a,u,b)}else h.current=null}function Rp(a,u,h){try{h()}catch(b){Sr(a,u,b)}}var Ky=!1;function oA(a,u){if(Hm=ts,a=Tw(),Em(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var b=h.getSelection&&h.getSelection();if(b&&b.rangeCount!==0){h=b.anchorNode;var x=b.anchorOffset,S=b.focusNode;b=b.focusOffset;try{h.nodeType,S.nodeType}catch{h=null;break e}var A=0,ee=-1,le=-1,Ie=0,rt=0,ut=a,Ze=null;t:for(;;){for(var Et;ut!==h||x!==0&&ut.nodeType!==3||(ee=A+x),ut!==S||b!==0&&ut.nodeType!==3||(le=A+b),ut.nodeType===3&&(A+=ut.nodeValue.length),(Et=ut.firstChild)!==null;)Ze=ut,ut=Et;for(;;){if(ut===a)break t;if(Ze===h&&++Ie===x&&(ee=A),Ze===S&&++rt===b&&(le=A),(Et=ut.nextSibling)!==null)break;ut=Ze,Ze=ut.parentNode}ut=Et}h=ee===-1||le===-1?null:{start:ee,end:le}}else h=null}h=h||{start:0,end:0}}else h=null;for(zm={focusedElem:a,selectionRange:h},ts=!1,Bt=u;Bt!==null;)if(u=Bt,a=u.child,(u.subtreeFlags&1028)!==0&&a!==null)a.return=u,Bt=a;else for(;Bt!==null;){u=Bt;try{var qt=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(qt!==null){var Gt=qt.memoizedProps,Tr=qt.memoizedState,ke=u.stateNode,he=ke.getSnapshotBeforeUpdate(u.elementType===u.type?Gt:mi(u.type,Gt),Tr);ke.__reactInternalSnapshotBeforeUpdate=he}break;case 3:var Pe=u.stateNode.containerInfo;Pe.nodeType===1?Pe.textContent="":Pe.nodeType===9&&Pe.documentElement&&Pe.removeChild(Pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(gt){Sr(u,u.return,gt)}if(a=u.sibling,a!==null){a.return=u.return,Bt=a;break}Bt=u.return}return qt=Ky,Ky=!1,qt}function cc(a,u,h){var b=u.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var x=b=b.next;do{if((x.tag&a)===a){var S=x.destroy;x.destroy=void 0,S!==void 0&&Rp(u,h,S)}x=x.next}while(x!==b)}}function ad(a,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var h=u=u.next;do{if((h.tag&a)===a){var b=h.create;h.destroy=b()}h=h.next}while(h!==u)}}function Mp(a){var u=a.ref;if(u!==null){var h=a.stateNode;switch(a.tag){case 5:a=h;break;default:a=h}typeof u=="function"?u(a):u.current=a}}function Yy(a){var u=a.alternate;u!==null&&(a.alternate=null,Yy(u)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(u=a.stateNode,u!==null&&(delete u[Ri],delete u[Jl],delete u[Gm],delete u[zM],delete u[qM])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function Xy(a){return a.tag===5||a.tag===3||a.tag===4}function Qy(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Xy(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Ap(a,u,h){var b=a.tag;if(b===5||b===6)a=a.stateNode,u?h.nodeType===8?h.parentNode.insertBefore(a,u):h.insertBefore(a,u):(h.nodeType===8?(u=h.parentNode,u.insertBefore(a,h)):(u=h,u.appendChild(a)),h=h._reactRootContainer,h!=null||u.onclick!==null||(u.onclick=_u));else if(b!==4&&(a=a.child,a!==null))for(Ap(a,u,h),a=a.sibling;a!==null;)Ap(a,u,h),a=a.sibling}function Ip(a,u,h){var b=a.tag;if(b===5||b===6)a=a.stateNode,u?h.insertBefore(a,u):h.appendChild(a);else if(b!==4&&(a=a.child,a!==null))for(Ip(a,u,h),a=a.sibling;a!==null;)Ip(a,u,h),a=a.sibling}var Jr=null,pi=!1;function Sa(a,u,h){for(h=h.child;h!==null;)Jy(a,u,h),h=h.sibling}function Jy(a,u,h){if(we&&typeof we.onCommitFiberUnmount=="function")try{we.onCommitFiberUnmount(Zt,h)}catch{}switch(h.tag){case 5:ls||ol(h,u);case 6:var b=Jr,x=pi;Jr=null,Sa(a,u,h),Jr=b,pi=x,Jr!==null&&(pi?(a=Jr,h=h.stateNode,a.nodeType===8?a.parentNode.removeChild(h):a.removeChild(h)):Jr.removeChild(h.stateNode));break;case 18:Jr!==null&&(pi?(a=Jr,h=h.stateNode,a.nodeType===8?Vm(a.parentNode,h):a.nodeType===1&&Vm(a,h),In(a)):Vm(Jr,h.stateNode));break;case 4:b=Jr,x=pi,Jr=h.stateNode.containerInfo,pi=!0,Sa(a,u,h),Jr=b,pi=x;break;case 0:case 11:case 14:case 15:if(!ls&&(b=h.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){x=b=b.next;do{var S=x,A=S.destroy;S=S.tag,A!==void 0&&((S&2)!==0||(S&4)!==0)&&Rp(h,u,A),x=x.next}while(x!==b)}Sa(a,u,h);break;case 1:if(!ls&&(ol(h,u),b=h.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=h.memoizedProps,b.state=h.memoizedState,b.componentWillUnmount()}catch(ee){Sr(h,u,ee)}Sa(a,u,h);break;case 21:Sa(a,u,h);break;case 22:h.mode&1?(ls=(b=ls)||h.memoizedState!==null,Sa(a,u,h),ls=b):Sa(a,u,h);break;default:Sa(a,u,h)}}function Zy(a){var u=a.updateQueue;if(u!==null){a.updateQueue=null;var h=a.stateNode;h===null&&(h=a.stateNode=new aA),u.forEach(function(b){var x=gA.bind(null,a,b);h.has(b)||(h.add(b),b.then(x,x))})}}function fi(a,u){var h=u.deletions;if(h!==null)for(var b=0;b<h.length;b++){var x=h[b];try{var S=a,A=u,ee=A;e:for(;ee!==null;){switch(ee.tag){case 5:Jr=ee.stateNode,pi=!1;break e;case 3:Jr=ee.stateNode.containerInfo,pi=!0;break e;case 4:Jr=ee.stateNode.containerInfo,pi=!0;break e}ee=ee.return}if(Jr===null)throw Error(r(160));Jy(S,A,x),Jr=null,pi=!1;var le=x.alternate;le!==null&&(le.return=null),x.return=null}catch(Ie){Sr(x,u,Ie)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)ek(u,a),u=u.sibling}function ek(a,u){var h=a.alternate,b=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(fi(u,a),Ii(a),b&4){try{cc(3,a,a.return),ad(3,a)}catch(Gt){Sr(a,a.return,Gt)}try{cc(5,a,a.return)}catch(Gt){Sr(a,a.return,Gt)}}break;case 1:fi(u,a),Ii(a),b&512&&h!==null&&ol(h,h.return);break;case 5:if(fi(u,a),Ii(a),b&512&&h!==null&&ol(h,h.return),a.flags&32){var x=a.stateNode;try{vt(x,"")}catch(Gt){Sr(a,a.return,Gt)}}if(b&4&&(x=a.stateNode,x!=null)){var S=a.memoizedProps,A=h!==null?h.memoizedProps:S,ee=a.type,le=a.updateQueue;if(a.updateQueue=null,le!==null)try{ee==="input"&&S.type==="radio"&&S.name!=null&&et(x,S),Wt(ee,A);var Ie=Wt(ee,S);for(A=0;A<le.length;A+=2){var rt=le[A],ut=le[A+1];rt==="style"?Nt(x,ut):rt==="dangerouslySetInnerHTML"?ze(x,ut):rt==="children"?vt(x,ut):D(x,rt,ut,Ie)}switch(ee){case"input":De(x,S);break;case"textarea":Ve(x,S);break;case"select":var Ze=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!S.multiple;var Et=S.value;Et!=null?He(x,!!S.multiple,Et,!1):Ze!==!!S.multiple&&(S.defaultValue!=null?He(x,!!S.multiple,S.defaultValue,!0):He(x,!!S.multiple,S.multiple?[]:"",!1))}x[Jl]=S}catch(Gt){Sr(a,a.return,Gt)}}break;case 6:if(fi(u,a),Ii(a),b&4){if(a.stateNode===null)throw Error(r(162));x=a.stateNode,S=a.memoizedProps;try{x.nodeValue=S}catch(Gt){Sr(a,a.return,Gt)}}break;case 3:if(fi(u,a),Ii(a),b&4&&h!==null&&h.memoizedState.isDehydrated)try{In(u.containerInfo)}catch(Gt){Sr(a,a.return,Gt)}break;case 4:fi(u,a),Ii(a);break;case 13:fi(u,a),Ii(a),x=a.child,x.flags&8192&&(S=x.memoizedState!==null,x.stateNode.isHidden=S,!S||x.alternate!==null&&x.alternate.memoizedState!==null||(Fp=Jt())),b&4&&Zy(a);break;case 22:if(rt=h!==null&&h.memoizedState!==null,a.mode&1?(ls=(Ie=ls)||rt,fi(u,a),ls=Ie):fi(u,a),Ii(a),b&8192){if(Ie=a.memoizedState!==null,(a.stateNode.isHidden=Ie)&&!rt&&(a.mode&1)!==0)for(Bt=a,rt=a.child;rt!==null;){for(ut=Bt=rt;Bt!==null;){switch(Ze=Bt,Et=Ze.child,Ze.tag){case 0:case 11:case 14:case 15:cc(4,Ze,Ze.return);break;case 1:ol(Ze,Ze.return);var qt=Ze.stateNode;if(typeof qt.componentWillUnmount=="function"){b=Ze,h=Ze.return;try{u=b,qt.props=u.memoizedProps,qt.state=u.memoizedState,qt.componentWillUnmount()}catch(Gt){Sr(b,h,Gt)}}break;case 5:ol(Ze,Ze.return);break;case 22:if(Ze.memoizedState!==null){rk(ut);continue}}Et!==null?(Et.return=Ze,Bt=Et):rk(ut)}rt=rt.sibling}e:for(rt=null,ut=a;;){if(ut.tag===5){if(rt===null){rt=ut;try{x=ut.stateNode,Ie?(S=x.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(ee=ut.stateNode,le=ut.memoizedProps.style,A=le!=null&&le.hasOwnProperty("display")?le.display:null,ee.style.display=$e("display",A))}catch(Gt){Sr(a,a.return,Gt)}}}else if(ut.tag===6){if(rt===null)try{ut.stateNode.nodeValue=Ie?"":ut.memoizedProps}catch(Gt){Sr(a,a.return,Gt)}}else if((ut.tag!==22&&ut.tag!==23||ut.memoizedState===null||ut===a)&&ut.child!==null){ut.child.return=ut,ut=ut.child;continue}if(ut===a)break e;for(;ut.sibling===null;){if(ut.return===null||ut.return===a)break e;rt===ut&&(rt=null),ut=ut.return}rt===ut&&(rt=null),ut.sibling.return=ut.return,ut=ut.sibling}}break;case 19:fi(u,a),Ii(a),b&4&&Zy(a);break;case 21:break;default:fi(u,a),Ii(a)}}function Ii(a){var u=a.flags;if(u&2){try{e:{for(var h=a.return;h!==null;){if(Xy(h)){var b=h;break e}h=h.return}throw Error(r(160))}switch(b.tag){case 5:var x=b.stateNode;b.flags&32&&(vt(x,""),b.flags&=-33);var S=Qy(a);Ip(a,S,x);break;case 3:case 4:var A=b.stateNode.containerInfo,ee=Qy(a);Ap(a,ee,A);break;default:throw Error(r(161))}}catch(le){Sr(a,a.return,le)}a.flags&=-3}u&4096&&(a.flags&=-4097)}function lA(a,u,h){Bt=a,tk(a)}function tk(a,u,h){for(var b=(a.mode&1)!==0;Bt!==null;){var x=Bt,S=x.child;if(x.tag===22&&b){var A=x.memoizedState!==null||id;if(!A){var ee=x.alternate,le=ee!==null&&ee.memoizedState!==null||ls;ee=id;var Ie=ls;if(id=A,(ls=le)&&!Ie)for(Bt=x;Bt!==null;)A=Bt,le=A.child,A.tag===22&&A.memoizedState!==null?sk(x):le!==null?(le.return=A,Bt=le):sk(x);for(;S!==null;)Bt=S,tk(S),S=S.sibling;Bt=x,id=ee,ls=Ie}nk(a)}else(x.subtreeFlags&8772)!==0&&S!==null?(S.return=x,Bt=S):nk(a)}}function nk(a){for(;Bt!==null;){var u=Bt;if((u.flags&8772)!==0){var h=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:ls||ad(5,u);break;case 1:var b=u.stateNode;if(u.flags&4&&!ls)if(h===null)b.componentDidMount();else{var x=u.elementType===u.type?h.memoizedProps:mi(u.type,h.memoizedProps);b.componentDidUpdate(x,h.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var S=u.updateQueue;S!==null&&ry(u,S,b);break;case 3:var A=u.updateQueue;if(A!==null){if(h=null,u.child!==null)switch(u.child.tag){case 5:h=u.child.stateNode;break;case 1:h=u.child.stateNode}ry(u,A,h)}break;case 5:var ee=u.stateNode;if(h===null&&u.flags&4){h=ee;var le=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":le.autoFocus&&h.focus();break;case"img":le.src&&(h.src=le.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var Ie=u.alternate;if(Ie!==null){var rt=Ie.memoizedState;if(rt!==null){var ut=rt.dehydrated;ut!==null&&In(ut)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}ls||u.flags&512&&Mp(u)}catch(Ze){Sr(u,u.return,Ze)}}if(u===a){Bt=null;break}if(h=u.sibling,h!==null){h.return=u.return,Bt=h;break}Bt=u.return}}function rk(a){for(;Bt!==null;){var u=Bt;if(u===a){Bt=null;break}var h=u.sibling;if(h!==null){h.return=u.return,Bt=h;break}Bt=u.return}}function sk(a){for(;Bt!==null;){var u=Bt;try{switch(u.tag){case 0:case 11:case 15:var h=u.return;try{ad(4,u)}catch(le){Sr(u,h,le)}break;case 1:var b=u.stateNode;if(typeof b.componentDidMount=="function"){var x=u.return;try{b.componentDidMount()}catch(le){Sr(u,x,le)}}var S=u.return;try{Mp(u)}catch(le){Sr(u,S,le)}break;case 5:var A=u.return;try{Mp(u)}catch(le){Sr(u,A,le)}}}catch(le){Sr(u,u.return,le)}if(u===a){Bt=null;break}var ee=u.sibling;if(ee!==null){ee.return=u.return,Bt=ee;break}Bt=u.return}}var cA=Math.ceil,od=F.ReactCurrentDispatcher,Ep=F.ReactCurrentOwner,Qs=F.ReactCurrentBatchConfig,On=0,Vr=null,Dr=null,Zr=0,Ws=0,ll=va(0),Br=0,uc=null,io=0,ld=0,Lp=0,dc=null,ks=null,Fp=0,cl=1/0,ra=null,cd=!1,_p=null,Ca=null,ud=!1,ja=null,dd=0,hc=0,Op=null,hd=-1,md=0;function ms(){return(On&6)!==0?Jt():hd!==-1?hd:hd=Jt()}function Ta(a){return(a.mode&1)===0?1:(On&2)!==0&&Zr!==0?Zr&-Zr:VM.transition!==null?(md===0&&(md=Lr()),md):(a=wt,a!==0||(a=window.event,a=a===void 0?16:pa(a.type)),a)}function gi(a,u,h,b){if(50<hc)throw hc=0,Op=null,Error(r(185));sr(a,h,b),((On&2)===0||a!==Vr)&&(a===Vr&&((On&2)===0&&(ld|=h),Br===4&&Na(a,Zr)),xs(a,b),h===1&&On===0&&(u.mode&1)===0&&(cl=Jt()+500,Uu&&ya()))}function xs(a,u){var h=a.callbackNode;Yr(a,u);var b=xr(a,a===Vr?Zr:0);if(b===0)h!==null&&jn(h),a.callbackNode=null,a.callbackPriority=0;else if(u=b&-b,a.callbackPriority!==u){if(h!=null&&jn(h),u===1)a.tag===0?$M(ak.bind(null,a)):$w(ak.bind(null,a)),UM(function(){(On&6)===0&&ya()}),h=null;else{switch(ir(b)){case 1:h=vn;break;case 4:h=yn;break;case 16:h=kn;break;case 536870912:h=xt;break;default:h=kn}h=pk(h,ik.bind(null,a))}a.callbackPriority=u,a.callbackNode=h}}function ik(a,u){if(hd=-1,md=0,(On&6)!==0)throw Error(r(327));var h=a.callbackNode;if(ul()&&a.callbackNode!==h)return null;var b=xr(a,a===Vr?Zr:0);if(b===0)return null;if((b&30)!==0||(b&a.expiredLanes)!==0||u)u=pd(a,b);else{u=b;var x=On;On|=2;var S=lk();(Vr!==a||Zr!==u)&&(ra=null,cl=Jt()+500,oo(a,u));do try{hA();break}catch(ee){ok(a,ee)}while(!0);np(),od.current=S,On=x,Dr!==null?u=0:(Vr=null,Zr=0,u=Br)}if(u!==0){if(u===2&&(x=Xr(a),x!==0&&(b=x,u=Bp(a,x))),u===1)throw h=uc,oo(a,0),Na(a,b),xs(a,Jt()),h;if(u===6)Na(a,b);else{if(x=a.current.alternate,(b&30)===0&&!uA(x)&&(u=pd(a,b),u===2&&(S=Xr(a),S!==0&&(b=S,u=Bp(a,S))),u===1))throw h=uc,oo(a,0),Na(a,b),xs(a,Jt()),h;switch(a.finishedWork=x,a.finishedLanes=b,u){case 0:case 1:throw Error(r(345));case 2:lo(a,ks,ra);break;case 3:if(Na(a,b),(b&130023424)===b&&(u=Fp+500-Jt(),10<u)){if(xr(a,0)!==0)break;if(x=a.suspendedLanes,(x&b)!==b){ms(),a.pingedLanes|=a.suspendedLanes&x;break}a.timeoutHandle=$m(lo.bind(null,a,ks,ra),u);break}lo(a,ks,ra);break;case 4:if(Na(a,b),(b&4194240)===b)break;for(u=a.eventTimes,x=-1;0<b;){var A=31-St(b);S=1<<A,A=u[A],A>x&&(x=A),b&=~S}if(b=x,b=Jt()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*cA(b/1960))-b,10<b){a.timeoutHandle=$m(lo.bind(null,a,ks,ra),b);break}lo(a,ks,ra);break;case 5:lo(a,ks,ra);break;default:throw Error(r(329))}}}return xs(a,Jt()),a.callbackNode===h?ik.bind(null,a):null}function Bp(a,u){var h=dc;return a.current.memoizedState.isDehydrated&&(oo(a,u).flags|=256),a=pd(a,u),a!==2&&(u=ks,ks=h,u!==null&&Wp(u)),a}function Wp(a){ks===null?ks=a:ks.push.apply(ks,a)}function uA(a){for(var u=a;;){if(u.flags&16384){var h=u.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var b=0;b<h.length;b++){var x=h[b],S=x.getSnapshot;x=x.value;try{if(!di(S(),x))return!1}catch{return!1}}}if(h=u.child,u.subtreeFlags&16384&&h!==null)h.return=u,u=h;else{if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Na(a,u){for(u&=~Lp,u&=~ld,a.suspendedLanes|=u,a.pingedLanes&=~u,a=a.expirationTimes;0<u;){var h=31-St(u),b=1<<h;a[h]=-1,u&=~b}}function ak(a){if((On&6)!==0)throw Error(r(327));ul();var u=xr(a,0);if((u&1)===0)return xs(a,Jt()),null;var h=pd(a,u);if(a.tag!==0&&h===2){var b=Xr(a);b!==0&&(u=b,h=Bp(a,b))}if(h===1)throw h=uc,oo(a,0),Na(a,u),xs(a,Jt()),h;if(h===6)throw Error(r(345));return a.finishedWork=a.current.alternate,a.finishedLanes=u,lo(a,ks,ra),xs(a,Jt()),null}function Up(a,u){var h=On;On|=1;try{return a(u)}finally{On=h,On===0&&(cl=Jt()+500,Uu&&ya())}}function ao(a){ja!==null&&ja.tag===0&&(On&6)===0&&ul();var u=On;On|=1;var h=Qs.transition,b=wt;try{if(Qs.transition=null,wt=1,a)return a()}finally{wt=b,Qs.transition=h,On=u,(On&6)===0&&ya()}}function Hp(){Ws=ll.current,cr(ll)}function oo(a,u){a.finishedWork=null,a.finishedLanes=0;var h=a.timeoutHandle;if(h!==-1&&(a.timeoutHandle=-1,WM(h)),Dr!==null)for(h=Dr.return;h!==null;){var b=h;switch(Qm(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&Bu();break;case 3:il(),cr(vs),cr(is),up();break;case 5:lp(b);break;case 4:il();break;case 13:cr(wr);break;case 19:cr(wr);break;case 10:rp(b.type._context);break;case 22:case 23:Hp()}h=h.return}if(Vr=a,Dr=a=Pa(a.current,null),Zr=Ws=u,Br=0,uc=null,Lp=ld=io=0,ks=dc=null,no!==null){for(u=0;u<no.length;u++)if(h=no[u],b=h.interleaved,b!==null){h.interleaved=null;var x=b.next,S=h.pending;if(S!==null){var A=S.next;S.next=x,b.next=A}h.pending=b}no=null}return a}function ok(a,u){do{var h=Dr;try{if(np(),Qu.current=td,Ju){for(var b=yr.memoizedState;b!==null;){var x=b.queue;x!==null&&(x.pending=null),b=b.next}Ju=!1}if(so=0,$r=Or=yr=null,sc=!1,ic=0,Ep.current=null,h===null||h.return===null){Br=1,uc=u,Dr=null;break}e:{var S=a,A=h.return,ee=h,le=u;if(u=Zr,ee.flags|=32768,le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ie=le,rt=ee,ut=rt.tag;if((rt.mode&1)===0&&(ut===0||ut===11||ut===15)){var Ze=rt.alternate;Ze?(rt.updateQueue=Ze.updateQueue,rt.memoizedState=Ze.memoizedState,rt.lanes=Ze.lanes):(rt.updateQueue=null,rt.memoizedState=null)}var Et=Ay(A);if(Et!==null){Et.flags&=-257,Iy(Et,A,ee,S,u),Et.mode&1&&My(S,Ie,u),u=Et,le=Ie;var qt=u.updateQueue;if(qt===null){var Gt=new Set;Gt.add(le),u.updateQueue=Gt}else qt.add(le);break e}else{if((u&1)===0){My(S,Ie,u),zp();break e}le=Error(r(426))}}else if(pr&&ee.mode&1){var Tr=Ay(A);if(Tr!==null){(Tr.flags&65536)===0&&(Tr.flags|=256),Iy(Tr,A,ee,S,u),ep(al(le,ee));break e}}S=le=al(le,ee),Br!==4&&(Br=2),dc===null?dc=[S]:dc.push(S),S=A;do{switch(S.tag){case 3:S.flags|=65536,u&=-u,S.lanes|=u;var ke=Dy(S,le,u);ny(S,ke);break e;case 1:ee=le;var he=S.type,Pe=S.stateNode;if((S.flags&128)===0&&(typeof he.getDerivedStateFromError=="function"||Pe!==null&&typeof Pe.componentDidCatch=="function"&&(Ca===null||!Ca.has(Pe)))){S.flags|=65536,u&=-u,S.lanes|=u;var gt=Ry(S,ee,u);ny(S,gt);break e}}S=S.return}while(S!==null)}uk(h)}catch(Yt){u=Yt,Dr===h&&h!==null&&(Dr=h=h.return);continue}break}while(!0)}function lk(){var a=od.current;return od.current=td,a===null?td:a}function zp(){(Br===0||Br===3||Br===2)&&(Br=4),Vr===null||(io&268435455)===0&&(ld&268435455)===0||Na(Vr,Zr)}function pd(a,u){var h=On;On|=2;var b=lk();(Vr!==a||Zr!==u)&&(ra=null,oo(a,u));do try{dA();break}catch(x){ok(a,x)}while(!0);if(np(),On=h,od.current=b,Dr!==null)throw Error(r(261));return Vr=null,Zr=0,Br}function dA(){for(;Dr!==null;)ck(Dr)}function hA(){for(;Dr!==null&&!Jn();)ck(Dr)}function ck(a){var u=mk(a.alternate,a,Ws);a.memoizedProps=a.pendingProps,u===null?uk(a):Dr=u,Ep.current=null}function uk(a){var u=a;do{var h=u.alternate;if(a=u.return,(u.flags&32768)===0){if(h=sA(h,u,Ws),h!==null){Dr=h;return}}else{if(h=iA(h,u),h!==null){h.flags&=32767,Dr=h;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Br=6,Dr=null;return}}if(u=u.sibling,u!==null){Dr=u;return}Dr=u=a}while(u!==null);Br===0&&(Br=5)}function lo(a,u,h){var b=wt,x=Qs.transition;try{Qs.transition=null,wt=1,mA(a,u,h,b)}finally{Qs.transition=x,wt=b}return null}function mA(a,u,h,b){do ul();while(ja!==null);if((On&6)!==0)throw Error(r(327));h=a.finishedWork;var x=a.finishedLanes;if(h===null)return null;if(a.finishedWork=null,a.finishedLanes=0,h===a.current)throw Error(r(177));a.callbackNode=null,a.callbackPriority=0;var S=h.lanes|h.childLanes;if(Hr(a,S),a===Vr&&(Dr=Vr=null,Zr=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||ud||(ud=!0,pk(kn,function(){return ul(),null})),S=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||S){S=Qs.transition,Qs.transition=null;var A=wt;wt=1;var ee=On;On|=4,Ep.current=null,oA(a,h),ek(h,a),IM(zm),ts=!!Hm,zm=Hm=null,a.current=h,lA(h),bn(),On=ee,wt=A,Qs.transition=S}else a.current=h;if(ud&&(ud=!1,ja=a,dd=x),S=a.pendingLanes,S===0&&(Ca=null),Ge(h.stateNode),xs(a,Jt()),u!==null)for(b=a.onRecoverableError,h=0;h<u.length;h++)x=u[h],b(x.value,{componentStack:x.stack,digest:x.digest});if(cd)throw cd=!1,a=_p,_p=null,a;return(dd&1)!==0&&a.tag!==0&&ul(),S=a.pendingLanes,(S&1)!==0?a===Op?hc++:(hc=0,Op=a):hc=0,ya(),null}function ul(){if(ja!==null){var a=ir(dd),u=Qs.transition,h=wt;try{if(Qs.transition=null,wt=16>a?16:a,ja===null)var b=!1;else{if(a=ja,ja=null,dd=0,(On&6)!==0)throw Error(r(331));var x=On;for(On|=4,Bt=a.current;Bt!==null;){var S=Bt,A=S.child;if((Bt.flags&16)!==0){var ee=S.deletions;if(ee!==null){for(var le=0;le<ee.length;le++){var Ie=ee[le];for(Bt=Ie;Bt!==null;){var rt=Bt;switch(rt.tag){case 0:case 11:case 15:cc(8,rt,S)}var ut=rt.child;if(ut!==null)ut.return=rt,Bt=ut;else for(;Bt!==null;){rt=Bt;var Ze=rt.sibling,Et=rt.return;if(Yy(rt),rt===Ie){Bt=null;break}if(Ze!==null){Ze.return=Et,Bt=Ze;break}Bt=Et}}}var qt=S.alternate;if(qt!==null){var Gt=qt.child;if(Gt!==null){qt.child=null;do{var Tr=Gt.sibling;Gt.sibling=null,Gt=Tr}while(Gt!==null)}}Bt=S}}if((S.subtreeFlags&2064)!==0&&A!==null)A.return=S,Bt=A;else e:for(;Bt!==null;){if(S=Bt,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:cc(9,S,S.return)}var ke=S.sibling;if(ke!==null){ke.return=S.return,Bt=ke;break e}Bt=S.return}}var he=a.current;for(Bt=he;Bt!==null;){A=Bt;var Pe=A.child;if((A.subtreeFlags&2064)!==0&&Pe!==null)Pe.return=A,Bt=Pe;else e:for(A=he;Bt!==null;){if(ee=Bt,(ee.flags&2048)!==0)try{switch(ee.tag){case 0:case 11:case 15:ad(9,ee)}}catch(Yt){Sr(ee,ee.return,Yt)}if(ee===A){Bt=null;break e}var gt=ee.sibling;if(gt!==null){gt.return=ee.return,Bt=gt;break e}Bt=ee.return}}if(On=x,ya(),we&&typeof we.onPostCommitFiberRoot=="function")try{we.onPostCommitFiberRoot(Zt,a)}catch{}b=!0}return b}finally{wt=h,Qs.transition=u}}return!1}function dk(a,u,h){u=al(h,u),u=Dy(a,u,1),a=xa(a,u,1),u=ms(),a!==null&&(sr(a,1,u),xs(a,u))}function Sr(a,u,h){if(a.tag===3)dk(a,a,h);else for(;u!==null;){if(u.tag===3){dk(u,a,h);break}else if(u.tag===1){var b=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(Ca===null||!Ca.has(b))){a=al(h,a),a=Ry(u,a,1),u=xa(u,a,1),a=ms(),u!==null&&(sr(u,1,a),xs(u,a));break}}u=u.return}}function pA(a,u,h){var b=a.pingCache;b!==null&&b.delete(u),u=ms(),a.pingedLanes|=a.suspendedLanes&h,Vr===a&&(Zr&h)===h&&(Br===4||Br===3&&(Zr&130023424)===Zr&&500>Jt()-Fp?oo(a,0):Lp|=h),xs(a,u)}function hk(a,u){u===0&&((a.mode&1)===0?u=1:(u=rr,rr<<=1,(rr&130023424)===0&&(rr=4194304)));var h=ms();a=ea(a,u),a!==null&&(sr(a,u,h),xs(a,h))}function fA(a){var u=a.memoizedState,h=0;u!==null&&(h=u.retryLane),hk(a,h)}function gA(a,u){var h=0;switch(a.tag){case 13:var b=a.stateNode,x=a.memoizedState;x!==null&&(h=x.retryLane);break;case 19:b=a.stateNode;break;default:throw Error(r(314))}b!==null&&b.delete(u),hk(a,h)}var mk;mk=function(a,u,h){if(a!==null)if(a.memoizedProps!==u.pendingProps||vs.current)ys=!0;else{if((a.lanes&h)===0&&(u.flags&128)===0)return ys=!1,rA(a,u,h);ys=(a.flags&131072)!==0}else ys=!1,pr&&(u.flags&1048576)!==0&&Vw(u,zu,u.index);switch(u.lanes=0,u.tag){case 2:var b=u.type;sd(a,u),a=u.pendingProps;var x=Jo(u,is.current);sl(u,h),x=mp(null,u,b,a,x,h);var S=pp();return u.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,ws(b)?(S=!0,Wu(u)):S=!1,u.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,ap(u),x.updater=nd,u.stateNode=x,x._reactInternals=u,yp(u,b,a,h),u=Cp(null,u,b,!0,S,h)):(u.tag=0,pr&&S&&Xm(u),hs(null,u,x,h),u=u.child),u;case 16:b=u.elementType;e:{switch(sd(a,u),a=u.pendingProps,x=b._init,b=x(b._payload),u.type=b,x=u.tag=vA(b),a=mi(b,a),x){case 0:u=Sp(null,u,b,a,h);break e;case 1:u=By(null,u,b,a,h);break e;case 11:u=Ey(null,u,b,a,h);break e;case 14:u=Ly(null,u,b,mi(b.type,a),h);break e}throw Error(r(306,b,""))}return u;case 0:return b=u.type,x=u.pendingProps,x=u.elementType===b?x:mi(b,x),Sp(a,u,b,x,h);case 1:return b=u.type,x=u.pendingProps,x=u.elementType===b?x:mi(b,x),By(a,u,b,x,h);case 3:e:{if(Wy(u),a===null)throw Error(r(387));b=u.pendingProps,S=u.memoizedState,x=S.element,ty(a,u),Yu(u,b,null,h);var A=u.memoizedState;if(b=A.element,S.isDehydrated)if(S={element:b,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},u.updateQueue.baseState=S,u.memoizedState=S,u.flags&256){x=al(Error(r(423)),u),u=Uy(a,u,b,h,x);break e}else if(b!==x){x=al(Error(r(424)),u),u=Uy(a,u,b,h,x);break e}else for(Bs=ba(u.stateNode.containerInfo.firstChild),Os=u,pr=!0,hi=null,h=Zw(u,null,b,h),u.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(tl(),b===x){u=na(a,u,h);break e}hs(a,u,b,h)}u=u.child}return u;case 5:return sy(u),a===null&&Zm(u),b=u.type,x=u.pendingProps,S=a!==null?a.memoizedProps:null,A=x.children,qm(b,x)?A=null:S!==null&&qm(b,S)&&(u.flags|=32),Oy(a,u),hs(a,u,A,h),u.child;case 6:return a===null&&Zm(u),null;case 13:return Hy(a,u,h);case 4:return op(u,u.stateNode.containerInfo),b=u.pendingProps,a===null?u.child=nl(u,null,b,h):hs(a,u,b,h),u.child;case 11:return b=u.type,x=u.pendingProps,x=u.elementType===b?x:mi(b,x),Ey(a,u,b,x,h);case 7:return hs(a,u,u.pendingProps,h),u.child;case 8:return hs(a,u,u.pendingProps.children,h),u.child;case 12:return hs(a,u,u.pendingProps.children,h),u.child;case 10:e:{if(b=u.type._context,x=u.pendingProps,S=u.memoizedProps,A=x.value,Zn(Vu,b._currentValue),b._currentValue=A,S!==null)if(di(S.value,A)){if(S.children===x.children&&!vs.current){u=na(a,u,h);break e}}else for(S=u.child,S!==null&&(S.return=u);S!==null;){var ee=S.dependencies;if(ee!==null){A=S.child;for(var le=ee.firstContext;le!==null;){if(le.context===b){if(S.tag===1){le=ta(-1,h&-h),le.tag=2;var Ie=S.updateQueue;if(Ie!==null){Ie=Ie.shared;var rt=Ie.pending;rt===null?le.next=le:(le.next=rt.next,rt.next=le),Ie.pending=le}}S.lanes|=h,le=S.alternate,le!==null&&(le.lanes|=h),sp(S.return,h,u),ee.lanes|=h;break}le=le.next}}else if(S.tag===10)A=S.type===u.type?null:S.child;else if(S.tag===18){if(A=S.return,A===null)throw Error(r(341));A.lanes|=h,ee=A.alternate,ee!==null&&(ee.lanes|=h),sp(A,h,u),A=S.sibling}else A=S.child;if(A!==null)A.return=S;else for(A=S;A!==null;){if(A===u){A=null;break}if(S=A.sibling,S!==null){S.return=A.return,A=S;break}A=A.return}S=A}hs(a,u,x.children,h),u=u.child}return u;case 9:return x=u.type,b=u.pendingProps.children,sl(u,h),x=Ys(x),b=b(x),u.flags|=1,hs(a,u,b,h),u.child;case 14:return b=u.type,x=mi(b,u.pendingProps),x=mi(b.type,x),Ly(a,u,b,x,h);case 15:return Fy(a,u,u.type,u.pendingProps,h);case 17:return b=u.type,x=u.pendingProps,x=u.elementType===b?x:mi(b,x),sd(a,u),u.tag=1,ws(b)?(a=!0,Wu(u)):a=!1,sl(u,h),Ny(u,b,x),yp(u,b,x,h),Cp(null,u,b,!0,a,h);case 19:return qy(a,u,h);case 22:return _y(a,u,h)}throw Error(r(156,u.tag))};function pk(a,u){return ln(a,u)}function bA(a,u,h,b){this.tag=a,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Js(a,u,h,b){return new bA(a,u,h,b)}function qp(a){return a=a.prototype,!(!a||!a.isReactComponent)}function vA(a){if(typeof a=="function")return qp(a)?1:0;if(a!=null){if(a=a.$$typeof,a===O)return 11;if(a===G)return 14}return 2}function Pa(a,u){var h=a.alternate;return h===null?(h=Js(a.tag,u,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=u,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&14680064,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,u=a.dependencies,h.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h}function fd(a,u,h,b,x,S){var A=2;if(b=a,typeof a=="function")qp(a)&&(A=1);else if(typeof a=="string")A=5;else e:switch(a){case I:return co(h.children,x,S,u);case M:A=8,x|=8;break;case _:return a=Js(12,h,u,x|2),a.elementType=_,a.lanes=S,a;case ne:return a=Js(13,h,u,x),a.elementType=ne,a.lanes=S,a;case Y:return a=Js(19,h,u,x),a.elementType=Y,a.lanes=S,a;case K:return gd(h,x,S,u);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case L:A=10;break e;case Q:A=9;break e;case O:A=11;break e;case G:A=14;break e;case te:A=16,b=null;break e}throw Error(r(130,a==null?a:typeof a,""))}return u=Js(A,h,u,x),u.elementType=a,u.type=b,u.lanes=S,u}function co(a,u,h,b){return a=Js(7,a,b,u),a.lanes=h,a}function gd(a,u,h,b){return a=Js(22,a,b,u),a.elementType=K,a.lanes=h,a.stateNode={isHidden:!1},a}function $p(a,u,h){return a=Js(6,a,null,u),a.lanes=h,a}function Vp(a,u,h){return u=Js(4,a.children!==null?a.children:[],a.key,u),u.lanes=h,u.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},u}function wA(a,u,h,b,x){this.tag=u,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=es(0),this.expirationTimes=es(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=es(0),this.identifierPrefix=b,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function Gp(a,u,h,b,x,S,A,ee,le){return a=new wA(a,u,h,ee,le),u===1?(u=1,S===!0&&(u|=8)):u=0,S=Js(3,null,null,u),a.current=S,S.stateNode=a,S.memoizedState={element:b,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},ap(S),a}function yA(a,u,h){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:E,key:b==null?null:""+b,children:a,containerInfo:u,implementation:h}}function fk(a){if(!a)return wa;a=a._reactInternals;e:{if(ct(a)!==a||a.tag!==1)throw Error(r(170));var u=a;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(ws(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(r(171))}if(a.tag===1){var h=a.type;if(ws(h))return zw(a,h,u)}return u}function gk(a,u,h,b,x,S,A,ee,le){return a=Gp(h,b,!0,a,x,S,A,ee,le),a.context=fk(null),h=a.current,b=ms(),x=Ta(h),S=ta(b,x),S.callback=u??null,xa(h,S,x),a.current.lanes=x,sr(a,x,b),xs(a,b),a}function bd(a,u,h,b){var x=u.current,S=ms(),A=Ta(x);return h=fk(h),u.context===null?u.context=h:u.pendingContext=h,u=ta(S,A),u.payload={element:a},b=b===void 0?null:b,b!==null&&(u.callback=b),a=xa(x,u,A),a!==null&&(gi(a,x,A,S),Ku(a,x,A)),A}function vd(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function bk(a,u){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<u?h:u}}function Kp(a,u){bk(a,u),(a=a.alternate)&&bk(a,u)}function kA(){return null}var vk=typeof reportError=="function"?reportError:function(a){console.error(a)};function Yp(a){this._internalRoot=a}wd.prototype.render=Yp.prototype.render=function(a){var u=this._internalRoot;if(u===null)throw Error(r(409));bd(a,u,null,null)},wd.prototype.unmount=Yp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var u=a.containerInfo;ao(function(){bd(null,a,null,null)}),u[Xi]=null}};function wd(a){this._internalRoot=a}wd.prototype.unstable_scheduleHydration=function(a){if(a){var u=ue();a={blockedOn:null,target:a,priority:u};for(var h=0;h<zr.length&&u!==0&&u<zr[h].priority;h++);zr.splice(h,0,a),h===0&&ve(a)}};function Xp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function yd(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function wk(){}function xA(a,u,h,b,x){if(x){if(typeof b=="function"){var S=b;b=function(){var Ie=vd(A);S.call(Ie)}}var A=gk(u,b,a,0,null,!1,!1,"",wk);return a._reactRootContainer=A,a[Xi]=A.current,Xl(a.nodeType===8?a.parentNode:a),ao(),A}for(;x=a.lastChild;)a.removeChild(x);if(typeof b=="function"){var ee=b;b=function(){var Ie=vd(le);ee.call(Ie)}}var le=Gp(a,0,!1,null,null,!1,!1,"",wk);return a._reactRootContainer=le,a[Xi]=le.current,Xl(a.nodeType===8?a.parentNode:a),ao(function(){bd(u,le,h,b)}),le}function kd(a,u,h,b,x){var S=h._reactRootContainer;if(S){var A=S;if(typeof x=="function"){var ee=x;x=function(){var le=vd(A);ee.call(le)}}bd(u,A,a,x)}else A=xA(h,u,a,x,b);return vd(A)}tn=function(a){switch(a.tag){case 3:var u=a.stateNode;if(u.current.memoizedState.isDehydrated){var h=Gn(u.pendingLanes);h!==0&&(dr(u,h|1),xs(u,Jt()),(On&6)===0&&(cl=Jt()+500,ya()))}break;case 13:ao(function(){var b=ea(a,1);if(b!==null){var x=ms();gi(b,a,1,x)}}),Kp(a,1)}},hr=function(a){if(a.tag===13){var u=ea(a,134217728);if(u!==null){var h=ms();gi(u,a,134217728,h)}Kp(a,134217728)}},ar=function(a){if(a.tag===13){var u=Ta(a),h=ea(a,u);if(h!==null){var b=ms();gi(h,a,u,b)}Kp(a,u)}},ue=function(){return wt},Qe=function(a,u){var h=wt;try{return wt=a,u()}finally{wt=h}},ae=function(a,u,h){switch(u){case"input":if(De(a,h),u=h.name,h.type==="radio"&&u!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<h.length;u++){var b=h[u];if(b!==a&&b.form===a.form){var x=Ou(b);if(!x)throw Error(r(90));Oe(b),De(b,x)}}}break;case"textarea":Ve(a,h);break;case"select":u=h.value,u!=null&&He(a,!!h.multiple,u,!1)}},Wn=Up,Rn=ao;var SA={usingClientEntryPoint:!1,Events:[Zl,Xo,Ou,Cn,on,Up]},mc={findFiberByHostInstance:Ja,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},CA={bundleType:mc.bundleType,version:mc.version,rendererPackageName:mc.rendererPackageName,rendererConfig:mc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:F.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Ut(a),a===null?null:a.stateNode},findFiberByHostInstance:mc.findFiberByHostInstance||kA,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xd.isDisabled&&xd.supportsFiber)try{Zt=xd.inject(CA),we=xd}catch{}}return Ss.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=SA,Ss.createPortal=function(a,u){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Xp(u))throw Error(r(200));return yA(a,u,null,h)},Ss.createRoot=function(a,u){if(!Xp(a))throw Error(r(299));var h=!1,b="",x=vk;return u!=null&&(u.unstable_strictMode===!0&&(h=!0),u.identifierPrefix!==void 0&&(b=u.identifierPrefix),u.onRecoverableError!==void 0&&(x=u.onRecoverableError)),u=Gp(a,1,!1,null,null,h,!1,b,x),a[Xi]=u.current,Xl(a.nodeType===8?a.parentNode:a),new Yp(u)},Ss.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var u=a._reactInternals;if(u===void 0)throw typeof a.render=="function"?Error(r(188)):(a=Object.keys(a).join(","),Error(r(268,a)));return a=Ut(u),a=a===null?null:a.stateNode,a},Ss.flushSync=function(a){return ao(a)},Ss.hydrate=function(a,u,h){if(!yd(u))throw Error(r(200));return kd(null,a,u,!0,h)},Ss.hydrateRoot=function(a,u,h){if(!Xp(a))throw Error(r(405));var b=h!=null&&h.hydratedSources||null,x=!1,S="",A=vk;if(h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(S=h.identifierPrefix),h.onRecoverableError!==void 0&&(A=h.onRecoverableError)),u=gk(u,null,a,1,h??null,x,!1,S,A),a[Xi]=u.current,Xl(a),b)for(a=0;a<b.length;a++)h=b[a],x=h._getVersion,x=x(h._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[h,x]:u.mutableSourceEagerHydrationData.push(h,x);return new wd(u)},Ss.render=function(a,u,h){if(!yd(u))throw Error(r(200));return kd(null,a,u,!1,h)},Ss.unmountComponentAtNode=function(a){if(!yd(a))throw Error(r(40));return a._reactRootContainer?(ao(function(){kd(null,null,a,!1,function(){a._reactRootContainer=null,a[Xi]=null})}),!0):!1},Ss.unstable_batchedUpdates=Up,Ss.unstable_renderSubtreeIntoContainer=function(a,u,h,b){if(!yd(h))throw Error(r(200));if(a==null||a._reactInternals===void 0)throw Error(r(38));return kd(a,u,h,!1,b)},Ss.version="18.3.1-next-f1338f8080-20240426",Ss}var Nk;function yT(){if(Nk)return Zp.exports;Nk=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Zp.exports=IA(),Zp.exports}var Pk;function EA(){if(Pk)return Sd;Pk=1;var e=yT();return Sd.createRoot=e.createRoot,Sd.hydrateRoot=e.hydrateRoot,Sd}var LA=EA();const FA=pu(LA);var p=Ab();const _A=pu(p),OA=wT({__proto__:null,default:_A},[p]),Ib="default-host";function kT(e,t){return t?e.hosts.find(r=>r.id===t)??null:null}function za(e){return kT(e,e.activeHostId)??e.hosts[0]??null}function Eb(e){var t;return((t=za(e))==null?void 0:t.baseUrl)??null}function BA(e){return e==="http:"||e==="https:"}function Ci(e){const t=e.trim();if(!t)throw new Error("EMPTY_SERVER_URL");const r=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//.test(t)?t:`http://${t}`,s=new URL(r);if(!BA(s.protocol))throw new Error("INVALID_SERVER_PROTOCOL");s.hash="",s.search="";const i=s.pathname.replace(/\/+$/,"");return`${s.origin}${i==="/"?"":i}`}const yi="codingns.auth.remembered-login";function fu(){return typeof window<"u"&&typeof window.localStorage<"u"}function WA(e){return e.isNativeMobile?!0:e.isDesktop?e.ui.osFamily==="windows"||e.ui.osFamily==="macos":!1}function UA(e){const t={credentials:null,legacyServerBaseUrl:null};if(!fu())return t;const r=window.localStorage.getItem(yi);if(!r)return t;try{const s=JSON.parse(r);if(Lb(s))return{credentials:e?s[e]??null:null,legacyServerBaseUrl:null};const i=ST(s);if(!i||!e)return{credentials:null,legacyServerBaseUrl:(i==null?void 0:i.serverBaseUrl)??null};const l={hostId:e,username:i.username,password:i.password,savedAt:Date.now()},c={[e]:l};return window.localStorage.setItem(yi,JSON.stringify(c)),{credentials:l,legacyServerBaseUrl:i.serverBaseUrl}}catch{return window.localStorage.removeItem(yi),t}}function HA(e){if(!fu())return;const t=xT(),r={hostId:e.hostId,username:e.username.trim(),password:e.password,savedAt:Date.now()};!r.hostId||!r.username||!r.password||window.localStorage.setItem(yi,JSON.stringify({...t,[r.hostId]:r}))}function zA(e){if(!fu())return;const t=window.localStorage.getItem(yi);if(t)try{const r=JSON.parse(t);if(Lb(r))return;const s=ST(r);if(!s){window.localStorage.removeItem(yi);return}window.localStorage.setItem(yi,JSON.stringify({...s,serverBaseUrl:Ci(e)}))}catch{window.localStorage.removeItem(yi)}}function qA(e){if(!fu()||!e)return;const t=xT();if(!t[e])return;const r={...t};if(delete r[e],Object.keys(r).length===0){window.localStorage.removeItem(yi);return}window.localStorage.setItem(yi,JSON.stringify(r))}function xT(){if(!fu())return{};const e=window.localStorage.getItem(yi);if(!e)return{};try{const t=JSON.parse(e);return Lb(t)?t:{}}catch{return{}}}function Lb(e){return typeof e!="object"||e===null||Array.isArray(e)?!1:Object.values(e).every(t=>$A(t))}function $A(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.hostId=="string"&&typeof t.username=="string"&&typeof t.password=="string"&&typeof t.savedAt=="number"&&t.username.trim().length>0&&t.password.length>0}function ST(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.username!="string"||typeof t.password!="string"||typeof t.serverBaseUrl!="string")return null;const r=t.username.trim(),s=t.password,i=Ci(t.serverBaseUrl);return!r||!s?null:{username:r,password:s,serverBaseUrl:i}}function CT(e={}){return{x:e.x??null,y:e.y??null,width:e.width??1200,height:e.height??780,minWidth:e.minWidth??720,minHeight:e.minHeight??480}}function VA(e){return{windowId:e.windowId,kind:e.kind,workspaceId:e.workspaceId??null,sessionId:e.sessionId??null,mode:e.mode??"docked",bounds:CT(e.bounds),focusOwner:e.focusOwner??null}}function xl(e){return{...e,bounds:{...e.bounds}}}function GA(e){return{descriptors:Object.fromEntries(Object.entries(e.descriptors).map(([r,s])=>[r,xl(s)])),openWindowIds:[...e.openWindowIds],lastActiveWindowId:e.lastActiveWindowId}}function Dk(){return{descriptors:{},openWindowIds:[],lastActiveWindowId:null}}function KA(e,t){return{...e,...t,windowId:e.windowId,bounds:CT({...e.bounds,...t.bounds})}}class YA{constructor(){ot(this,"state",Dk());ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>GA(this.state))}registerDescriptor(t){const r=xl(t),s=this.state.openWindowIds.includes(r.windowId);return this.state={...this.state,descriptors:{...this.state.descriptors,[r.windowId]:r},lastActiveWindowId:s?r.windowId:this.state.lastActiveWindowId},this.emit(),xl(r)}updateDescriptor(t,r){const s=this.state.descriptors[t];if(!s)return null;const i=KA(s,r);return this.state={...this.state,descriptors:{...this.state.descriptors,[t]:i}},this.emit(),xl(i)}getDescriptor(t){const r=this.state.descriptors[t];return r?xl(r):null}getWindows(){return Object.values(this.state.descriptors).map(t=>({descriptor:xl(t),isOpen:this.state.openWindowIds.includes(t.windowId)}))}markWindowOpen(t){if(!this.state.descriptors[t])return!1;const r=this.state.openWindowIds.filter(s=>s!==t);return this.state={...this.state,openWindowIds:[...r,t],lastActiveWindowId:t},this.emit(),!0}markWindowClosed(t){if(!this.state.openWindowIds.includes(t))return!1;const r=this.state.openWindowIds.filter(s=>s!==t);return this.state={...this.state,openWindowIds:r,lastActiveWindowId:this.state.lastActiveWindowId===t?r.at(-1)??null:this.state.lastActiveWindowId},this.emit(),!0}isWindowOpen(t){return this.state.openWindowIds.includes(t)}removeWindow(t){if(!this.state.descriptors[t])return!1;const r={...this.state.descriptors};delete r[t];const s=this.state.openWindowIds.filter(i=>i!==t);return this.state={descriptors:r,openWindowIds:s,lastActiveWindowId:this.state.lastActiveWindowId===t?s.at(-1)??null:this.state.lastActiveWindowId},this.emit(),!0}clear(){const t=this.state.openWindowIds.length>0||this.state.lastActiveWindowId!==null||Object.keys(this.state.descriptors).length>0;this.state=Dk(),t&&this.emit()}emit(){for(const t of this.listeners)t()}}function XA(){return new YA}const QA=XA();function JA(){return QA}const ZA=JA();function jT(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function TT(){var l,c;if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase(),t=navigator.userAgentData,r=((l=t==null?void 0:t.platform)==null?void 0:l.toLowerCase())??((c=navigator.platform)==null?void 0:c.toLowerCase())??"",s=`${r} ${e}`,i=r.includes("mac")&&navigator.maxTouchPoints>1;return s.includes("android")?"android":s.includes("iphone")||s.includes("ipad")||s.includes("ipod")||i?"ios":s.includes("mac")?"macos":s.includes("win")?"windows":s.includes("linux")?"linux":"unknown"}function eI(e){var t;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:typeof window<"u"&&Number.isFinite(window.innerWidth)&&window.innerWidth>0?window.innerWidth:typeof document<"u"&&Number.isFinite((t=document.documentElement)==null?void 0:t.clientWidth)&&document.documentElement.clientWidth>0?document.documentElement.clientWidth:1280}function tI(e){const t=eI(e);return t<768?"compact":t<1024?"medium":"expanded"}function nI(e){const t=TT();return e==="desktop"?{osFamily:t,windowControlsStyle:t==="macos"?"traffic-lights":t==="windows"?"windows":"none",prefersDesktopChrome:!0,prefersOverlayTitlebar:t==="macos",prefersSystemFontStack:!0}:{osFamily:t,windowControlsStyle:"none",prefersDesktopChrome:!1,prefersOverlayTitlebar:!1,prefersSystemFontStack:!0}}function xn(e){return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:e}}async function Rr(e,t){return Oc(e,t)}async function Oc(e,t){if(!jT())return xn("当前运行环境不支持桌面壳能力。");try{return{ok:!0,value:await window.__TAURI_INTERNALS__.invoke(e,t)}}catch(r){return{ok:!1,errorCode:"SHELL_BRIDGE_ERROR",detail:r instanceof Error?r.message:"桌面壳调用失败。"}}}function rI(e){switch(e){case"selection":return 10;case"action":return[12];case"gesture":return[10,18,10];case"success":return[16,30,20];case"warning":return[20,36,18];case"error":return[24,40,24,40,20];default:return 10}}function NT(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}async function PT(e){if(NT())try{navigator.vibrate(rI(e))}catch{return}}async function Fb(e,t){if(typeof window>"u"||typeof Notification>"u")return xn("当前环境不支持系统通知。");try{if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return xn("系统通知权限未授予。");const r=new Notification(e,{body:t});return r.onerror=()=>{},{ok:!0}}catch(r){return{ok:!1,errorCode:"NOTIFICATION_FAILED",detail:r instanceof Error?r.message:"系统通知发送失败。"}}}class sI{constructor(){ot(this,"supported",!1)}openExternal(t){return typeof window>"u"?Promise.resolve(xn("当前环境无法打开外部链接。")):(window.open(t,"_blank","noopener,noreferrer"),Promise.resolve({ok:!0}))}showNotification(t,r){return Fb(t,r)}writeClipboardText(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}setWindowState(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}readDesktopConfig(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}writeDesktopConfig(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}getRuntimeInfo(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}checkForUpdate(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}installUpdate(){return Promise.resolve({ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前不是桌面端运行环境。"})}getAndroidRuntimeInfo(){return Promise.resolve(xn("当前不是 Android 原生运行环境。"))}installAndroidUpdate(){return Promise.resolve({ok:!1,status:"failed",detail:"当前不是 Android 原生运行环境。"})}rollbackToPreviousVersion(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}pickDirectory(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}createWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}closeWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}focusWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}listWindows(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}isWindowOpen(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}getWindowDescriptor(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}syncWindowDescriptor(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}updateWindowBounds(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}}class iI{constructor(){ot(this,"supported",NT())}trigger(t){return PT(t)}}class aI{constructor(){ot(this,"supported",!0)}openExternal(t){return Rr("open_external",{url:t})}async showNotification(t,r){const s=await Fb(t,r);return s.ok?s:Rr("show_notification",{title:t,body:r})}writeClipboardText(t){return Rr("copy_text",{text:t})}setWindowState(t){return Rr("set_window_state",{state:t})}readDesktopConfig(){return Rr("read_desktop_config")}writeDesktopConfig(t){return Rr("write_desktop_config",{patch:t})}getRuntimeInfo(){return Rr("get_runtime_info")}checkForUpdate(t){return Rr("check_for_update",{channel:t})}async installUpdate(t){const r=await Rr("install_update",{channel:t});return r.ok?r.value??{ok:!0}:{ok:!1,errorCode:r.errorCode,detail:r.detail}}getAndroidRuntimeInfo(){return Promise.resolve(xn("当前不是 Android 原生运行环境。"))}installAndroidUpdate(){return Promise.resolve({ok:!1,status:"failed",detail:"当前不是 Android 原生运行环境。"})}rollbackToPreviousVersion(){return Rr("rollback_to_previous_version")}pickDirectory(){return Rr("pick_directory")}createWindow(t){return Rr("create_window",{descriptor:t})}closeWindow(t){return Rr("close_window",{windowId:t})}focusWindow(t){return Rr("focus_window",{windowId:t})}listWindows(){return Rr("list_windows")}isWindowOpen(t){return Rr("is_window_open",{windowId:t})}getWindowDescriptor(t){return typeof t=="string"?Rr("get_window_descriptor",{windowId:t}):Rr("get_window_descriptor")}syncWindowDescriptor(t){return Rr("sync_window_descriptor",{descriptor:t})}updateWindowBounds(t,r){return Rr("update_window_bounds",{windowId:t,bounds:r})}}class oI{constructor(){ot(this,"supported",!0)}async trigger(t){(await Oc("perform_haptic_feedback",{kind:t})).ok||await PT(t)}}class lI{constructor(t){ot(this,"supported",!0);this.platform=t}openExternal(t){return typeof window>"u"?Promise.resolve(xn("当前环境无法打开外部链接。")):(window.open(t,"_blank","noopener,noreferrer"),Promise.resolve({ok:!0}))}showNotification(t,r){return Fb(t,r)}writeClipboardText(t){return Oc("copy_text",{text:t})}setWindowState(){return Promise.resolve(xn("当前平台不支持窗口控制。"))}readDesktopConfig(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}writeDesktopConfig(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}getRuntimeInfo(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}checkForUpdate(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}installUpdate(){return Promise.resolve({ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前不是桌面端运行环境。"})}getAndroidRuntimeInfo(){return this.platform!=="android"?Promise.resolve(xn("当前不是 Android 原生运行环境。")):Oc("get_android_runtime_info")}async installAndroidUpdate(t){if(this.platform!=="android")return{ok:!1,status:"failed",detail:"当前不是 Android 原生运行环境。"};const r=await Oc("install_android_update",{manifest:t});return r.ok?r.value??{ok:!1,status:"failed",detail:"Android 更新结果为空。"}:{ok:!1,status:"failed",detail:r.detail}}rollbackToPreviousVersion(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}pickDirectory(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}createWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}closeWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}focusWindow(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}listWindows(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}isWindowOpen(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}getWindowDescriptor(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}syncWindowDescriptor(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}updateWindowBounds(){return Promise.resolve(xn("当前不是桌面端运行环境。"))}}function DT(){if(!jT())return"web";const e=TT();return e==="ios"?"ios":e==="android"?"android":"desktop"}function $s(e={}){const t=DT(),r=tI(e.viewportWidth),s=t==="ios"||t==="android";return{platform:t,isDesktop:t==="desktop",isWeb:t==="web",isMobile:r!=="expanded",isNativeMobile:s,viewportClass:r,ui:nI(t),bridge:t==="desktop"?new aI:s?new lI(t):new sI,windows:ZA,haptics:s?new oI:new iI}}const Ig="codingns.client.runtime-config";function _b(e){return e==="desktop"||e==="ios"||e==="android"}function Eg(e){return e==="en"||e==="en-US"?"en-US":"zh-CN"}function cI(){return typeof navigator>"u"?"zh-CN":Eg(navigator.language)}function Rk(e){return e==="acceptEdits"||e==="bypassPermissions"?e:"default"}function RT(){return typeof window<"u"&&typeof window.localStorage<"u"}function uI(){if(!RT())return null;const e=window.localStorage.getItem(Ig);if(!e)return null;try{return JSON.parse(e)}catch{return window.localStorage.removeItem(Ig),null}}function MT(e){RT()&&window.localStorage.setItem(Ig,JSON.stringify(e))}function dI(){var e;return typeof window>"u"||!((e=window.location)!=null&&e.origin)?null:window.location.origin}function hI(e){if(!e)return null;try{return Ci(e)}catch{return null}}function AT(e){if(e==="web"){const t=hI(dI());if(t)return t}return Ci("http://127.0.0.1:3002")}function IT(){return new Date().toISOString()}function Ea(e){return typeof e=="string"&&e.trim()?e.trim():null}function Mk(e,t){return Ea(e)??t}function ET(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function LT(e){try{const t=new URL(e),r=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${r}`}catch{return e}}function Dh(e,t,r={}){const s=Ci(e);return{id:Ea(r.id)??Ib,name:Ea(r.name)??LT(s),baseUrl:s,kind:r.kind??ET(s),createdAt:Mk(r.createdAt,t),updatedAt:Mk(r.updatedAt,t),lastConnectedAt:Ea(r.lastConnectedAt)??null,lastUserId:Ea(r.lastUserId)??null,lastUsername:Ea(r.lastUsername)??null}}function mI(e){return typeof e=="object"&&e!==null}function pI(e,t){if(!Array.isArray(e))return[];const r=new Set,s=[];for(let i=0;i<e.length;i+=1){const l=e[i];if(!mI(l))continue;const c=Ea(l.baseUrl);if(c)try{const d=i===0?Ib:`host-${i+1}`,m=Dh(c,t,{...l,id:Ea(l.id)??d});if(r.has(m.id))continue;r.add(m.id),s.push(m)}catch{continue}}return s}function fI(e){return typeof e=="object"&&e!==null}function gI(e,t,r){const s=Ci(t),i=za(e);return i?e.hosts.map(l=>l.id===i.id?Dh(s,r,{...l,name:LT(s),kind:ET(s),createdAt:l.createdAt,updatedAt:r}):l):[Dh(s,r)]}function Ob(e){const t=IT();return{platform:e,activeHostId:Ib,hosts:[Dh(AT(e),t)],releaseChannel:"stable",autoReconnect:!0,autoCheckUpdate:e==="desktop",language:cI(),defaultPermissionMode:"default"}}function Rh(e,t){var m;if(!t||!fI(t))return e;const r=t.platform??e.platform,s=Ob(r),i=IT();if(!_b(r))return{platform:r,activeHostId:s.activeHostId,hosts:s.hosts,releaseChannel:t.releaseChannel??e.releaseChannel,autoReconnect:t.autoReconnect??e.autoReconnect,autoCheckUpdate:t.autoCheckUpdate??e.autoCheckUpdate,language:Eg(t.language??e.language),defaultPermissionMode:Rk(t.defaultPermissionMode??e.defaultPermissionMode)};let l=t.hosts!==void 0?pI(t.hosts,i):e.hosts;t.hostBaseUrl&&(l=gI(e,t.hostBaseUrl,i)),l.length===0&&(l=s.hosts);const c=t.activeHostId??e.activeHostId,d=l.some(f=>f.id===c)?c:((m=l[0])==null?void 0:m.id)??null;return{platform:r,activeHostId:d,hosts:l,releaseChannel:t.releaseChannel??e.releaseChannel,autoReconnect:t.autoReconnect??e.autoReconnect,autoCheckUpdate:t.autoCheckUpdate??e.autoCheckUpdate,language:Eg(t.language??e.language),defaultPermissionMode:Rk(t.defaultPermissionMode??e.defaultPermissionMode)}}function FT(e,t){return Rh(Ob(t),e)}async function bI(){const e=$s(),t=Ob(e.platform),r=uI();let s=null;if(e.isDesktop){const l=await e.bridge.readDesktopConfig();l.ok&&l.value&&(s=l.value)}const i=Rh(Rh(t,r),s);return MT(i),i}async function vI(e,t){var l;const r=Rh(e,t);MT(r);const s=(l=za(r))==null?void 0:l.baseUrl;s&&zA(s);const i=$s();return i.isDesktop&&await i.bridge.writeDesktopConfig(r),r}function wI(){return FT(null,DT())}class yI{constructor(){ot(this,"state",wI());ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state)}hydrate(t){this.state=FT(t,this.state.platform),this.emit()}async initialize(){const t=await bI();return this.hydrate(t),t}async update(t){const r=await vI(this.state,t);return this.hydrate(r),r}emit(){for(const t of this.listeners)t()}}const En=new yI;function Rl(e){return p.useSyncExternalStore(En.subscribe,()=>e(En.getState()))}class Ur extends Error{constructor(r,s){super(s.detail);ot(this,"status");ot(this,"errorCode");ot(this,"field");ot(this,"data");this.name="ApiError",this.status=r,this.errorCode=s.error_code,this.field=s.field,this.data=s.data}}function kI(e){return e.endsWith("/")?e:`${e}/`}function xI(e){return e.replace(/^\/+/,"")}function Bb(){const e=En.getState();return Eb(e)??AT(e.platform)}function Wb(e,t=Bb()){return new URL(xI(e),kI(t)).toString()}function _T(e,t=Bb()){const r=new URL(Wb(e,t));return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}class SI{async request(t,r={}){const s=await this.performRequest(t,r);if(s.status===204||s.status===205)return;const i=await s.text();if(i)return JSON.parse(i)}async requestBlob(t,r={}){return(await this.performRequest(t,r)).blob()}async performRequest(t,r){var d;const s=new Headers(r.headers),i=r.body!==void 0&&r.body!==null,l=Wb(t,r.baseUrl??Bb());if(i&&!s.has("Content-Type")&&s.set("Content-Type","application/json"),!r.skipAuth){const m=(d=br.getState().session)==null?void 0:d.accessToken;if(!m)throw br.clear(),new Ur(401,{detail:"当前没有可用的登录态",error_code:"UNAUTHORIZED"});s.set("Authorization",`Bearer ${m}`)}let c;try{c=await fetch(l,{...r,headers:s})}catch(m){const f=m instanceof Error?m.message:"未知网络错误";throw new Ur(0,{detail:`请求 ${l} 失败:${f}`,error_code:"NETWORK_ERROR"})}if(!c.ok){const m=await CI(c);if(OT(c.status,m.error_code)&&!r.skipAuth&&!r.retryAfterRefresh){const f=await br.refresh();if(f.status==="refreshed")return this.performRequest(t,{...r,retryAfterRefresh:!0});throw f.status==="invalid"?new Ur(401,{detail:"登录态已经失效,请重新登录",error_code:"UNAUTHORIZED"}):new Ur(0,{detail:"登录态暂时无法恢复,请稍后重试",error_code:"AUTH_REFRESH_UNAVAILABLE"})}throw!r.skipAuth&&TI(c.status,m.error_code)&&(sessionStorage.setItem(Lg,String(Date.now())),br.clear()),new Ur(c.status,m)}return c}}const _e=new SI;async function CI(e){const t=await e.text();if(!t)return Ak(e.status);try{const r=JSON.parse(t);if(typeof r.detail=="string"&&typeof r.error_code=="string")return{detail:r.detail,error_code:r.error_code,field:typeof r.field=="string"?r.field:void 0,data:jI(r.data)?r.data:void 0,timestamp:typeof r.timestamp=="string"?r.timestamp:void 0}}catch{}return Ak(e.status,t)}function Ak(e,t){return{detail:(t==null?void 0:t.trim())||`请求失败(HTTP ${e})`,error_code:e===401?"UNAUTHORIZED":"HTTP_ERROR"}}function jI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function OT(e,t){return e!==401?!1:t==="UNAUTHORIZED"||t==="TOKEN_EXPIRED"||t==="TOKEN_INVALID"}function TI(e,t){return e===403&&t==="BOOTSTRAP_REQUIRED"?!0:OT(e,t)}const Lg="codingns.auth_expired_at";function NI(){const e=sessionStorage.getItem(Lg);return e?(sessionStorage.removeItem(Lg),Date.now()-Number(e)<5e3):!1}function PI(e){return _e.request("/api/public/bootstrap-status",{baseUrl:e,skipAuth:!0})}function DI(e,t){return _e.request("/api/public/setup",{method:"POST",body:JSON.stringify(e),baseUrl:t,skipAuth:!0})}function RI(e,t){return _e.request("/api/auth/login",{method:"POST",body:JSON.stringify(e),baseUrl:t,skipAuth:!0})}function MI(e,t){return _e.request("/api/auth/refresh",{method:"POST",body:JSON.stringify(e),baseUrl:t,skipAuth:!0})}const Cd="codingns.auth.session";class AI{constructor(){ot(this,"state",{status:"anonymous",session:null});ot(this,"listeners",new Set);ot(this,"sessionMap",{});ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);this.syncCurrentHostSession(),En.subscribe(()=>{this.syncCurrentHostSession()})}async login(t,r){const s=await RI(t,r);return this.setSession(s),s}async bootstrap(t,r,s){await DI({username:t,password:r},s)}hydrate(t){if(!t){this.clear();return}this.setSession(t)}async refresh(){const t=this.state.session,r=t==null?void 0:t.refreshToken,s=this.getCurrentHost();if(!r)return this.clear(),{status:"invalid",session:null};this.state={...this.state,status:"refreshing"},this.emit();try{const i=await MI({refreshToken:r},s==null?void 0:s.baseUrl);return this.setSession(i,s),{status:"refreshed",session:i}}catch(i){return OI(i)?(this.clear(),{status:"invalid",session:null}):(this.state={status:t?"authenticated":"anonymous",session:t},this.emit(),{status:"deferred",session:t,error:i})}}clear(){const t=this.getCurrentHost();if(!t){this.sessionMap={},this.persistSessionMap(),this.updateState({status:"anonymous",session:null});return}if(this.sessionMap[t.id]){const r={...this.sessionMap};delete r[t.id],this.sessionMap=r,this.persistSessionMap()}this.updateState({status:"anonymous",session:null})}setSession(t,r=this.getCurrentHost()){r&&(this.sessionMap={...this.sessionMap,[r.id]:{hostId:r.id,session:t,savedAt:Date.now()}},this.persistSessionMap(),En.update({hosts:En.getState().hosts.map(s=>s.id===r.id?{...s,lastConnectedAt:new Date().toISOString(),lastUserId:t.user.userId,lastUsername:t.user.username,updatedAt:new Date().toISOString()}:s)}).catch(()=>{}),this.updateState({status:"authenticated",session:t}))}syncCurrentHostSession(){var l;const t=this.getCurrentHost(),{sessionMap:r,migrated:s}=this.readSessionMapFromStorage(t);this.sessionMap=r,s&&this.persistSessionMap();const i=t?((l=r[t.id])==null?void 0:l.session)??null:null;this.updateState({status:i?"authenticated":"anonymous",session:i})}getCurrentHost(){return za(En.getState())}readSessionMapFromStorage(t){if(typeof window>"u"||typeof window.localStorage>"u")return{sessionMap:{},migrated:!1};const r=window.localStorage.getItem(Cd);if(!r)return{sessionMap:{},migrated:!1};try{const s=JSON.parse(r);if(EI(s))return{sessionMap:s,migrated:!1};const i=FI(s,t);if(i)return{sessionMap:i,migrated:!0}}catch{}return window.localStorage.removeItem(Cd),{sessionMap:{},migrated:!1}}persistSessionMap(){if(!(typeof window>"u"||typeof window.localStorage>"u")){if(Object.keys(this.sessionMap).length===0){window.localStorage.removeItem(Cd);return}window.localStorage.setItem(Cd,JSON.stringify(this.sessionMap))}}updateState(t){this.state.status===t.status&&this.state.session===t.session||(this.state=t,this.emit())}emit(){for(const t of this.listeners)t()}}const br=new AI;function gu(e){return p.useSyncExternalStore(br.subscribe,()=>e(br.getState()))}function II(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.hostId=="string"&&typeof t.savedAt=="number"&&Ub(t.session)}function EI(e){return typeof e!="object"||e===null||Array.isArray(e)?!1:Object.values(e).every(t=>II(t))}function LI(e){return typeof e!="object"||e===null?!1:"session"in e&&Ub(e.session)}function Ub(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.accessToken=="string"&&typeof t.refreshToken=="string"&&typeof t.expiresIn=="number"&&typeof t.user=="object"&&t.user!==null}function FI(e,t){const r=(t==null?void 0:t.id)??null;if(!r)return null;if(LI(e)){const s=_I(e.serverBaseUrl,t)??r;return{[s]:{hostId:s,session:e.session,savedAt:Date.now()}}}return Ub(e)?{[r]:{hostId:r,session:e,savedAt:Date.now()}}:null}function _I(e,t){if(!e)return(t==null?void 0:t.id)??null;const s=En.getState().hosts.find(i=>i.baseUrl===e);return(s==null?void 0:s.id)??(t==null?void 0:t.id)??null}function OI(e){return e instanceof Ur?e.status===401?!0:e.status===403&&e.errorCode==="BOOTSTRAP_REQUIRED":!1}const BT="/api/preferences/profile";async function BI(){return _e.request(BT)}async function WT(e){return _e.request(BT,{method:"PUT",body:JSON.stringify(e)})}const am=["claude-code","codex","opencode","gemini","kimi"],UT="codingns.account.preferences.shadow",WI="codingns.client.runtime-config",UI="codingns-theme",HI="composer-selected-model:",zI="composer-reasoning-level:";function bu(){return typeof window<"u"&&typeof window.localStorage<"u"}function Hb(e){return e==="en-US"||e==="en"?"en-US":e==="zh-CN"?"zh-CN":null}function qI(){return typeof navigator>"u"?"zh-CN":Hb(navigator.language)??"zh-CN"}function HT(e){return e==="light"||e==="dark"||e==="sky-blue"||e==="eye-green"?e:null}function $I(){return typeof window>"u"||typeof window.matchMedia!="function"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function VI(e){return typeof e=="boolean"?e:null}function zT(e){return e==="acceptEdits"||e==="bypassPermissions"||e==="default"?e:null}function qT(e){return e==="low"||e==="medium"||e==="high"||e==="xhigh"?e:null}function $T(){return{"claude-code":{defaultModel:null,defaultReasoningLevel:null},codex:{defaultModel:null,defaultReasoningLevel:null},opencode:{defaultModel:null,defaultReasoningLevel:null},gemini:{defaultModel:null,defaultReasoningLevel:null},kimi:{defaultModel:null,defaultReasoningLevel:null}}}function VT(){return{initialized:!0,profile:{language:qI(),theme:$I(),autoTheme:!1,defaultPermissionMode:"default"},providers:$T(),updatedAt:null,source:"default"}}function GI(){const e=En.getState(),t={language:e.language,defaultPermissionMode:e.defaultPermissionMode};if(!bu())return t;const r=window.localStorage.getItem(WI);if(!r)return t;try{const s=JSON.parse(r);return{language:Hb(s.language)??t.language,defaultPermissionMode:zT(s.defaultPermissionMode)??t.defaultPermissionMode}}catch{return t}}function KI(){return bu()?HT(window.localStorage.getItem(UI)):null}function YI(){var t;if(!bu())return;const e={};for(const r of am){const s=((t=window.localStorage.getItem(`${HI}${r}`))==null?void 0:t.trim())||null,i=qT(window.localStorage.getItem(`${zI}${r}`));s===null&&i===null||(e[r]={defaultModel:s,defaultReasoningLevel:i})}return Object.keys(e).length>0?e:void 0}function GT(){const e=GI(),t=KI(),r=YI(),s={};return e.language&&(s.language=e.language),t&&(s.theme=t),e.defaultPermissionMode&&(s.defaultPermissionMode=e.defaultPermissionMode),r&&(s.providers=r),KT(s)?s:null}function KT(e){return e?e.language!==void 0||e.theme!==void 0||e.autoTheme!==void 0||e.defaultPermissionMode!==void 0||e.providers!==void 0&&Object.keys(e.providers).length>0:!1}function Mh(e){var s;const t=VT(),r=$T();for(const i of am){const l=(s=e==null?void 0:e.providers)==null?void 0:s[i];r[i]={defaultModel:typeof(l==null?void 0:l.defaultModel)=="string"&&l.defaultModel.trim()||null,defaultReasoningLevel:qT(l==null?void 0:l.defaultReasoningLevel)??null}}return{language:Hb(e==null?void 0:e.language)??t.profile.language,theme:HT(e==null?void 0:e.theme)??t.profile.theme,autoTheme:VI(e==null?void 0:e.autoTheme)??t.profile.autoTheme,defaultPermissionMode:zT(e==null?void 0:e.defaultPermissionMode)??t.profile.defaultPermissionMode,providers:r,updatedAt:typeof(e==null?void 0:e.updatedAt)=="string"?e.updatedAt:null}}function XI(){var t,r,s,i;if(!bu())return null;const e=window.localStorage.getItem(UT);if(!e)return null;try{const l=JSON.parse(e),c=Mh({language:(t=l.profile)==null?void 0:t.language,theme:(r=l.profile)==null?void 0:r.theme,autoTheme:(s=l.profile)==null?void 0:s.autoTheme,defaultPermissionMode:(i=l.profile)==null?void 0:i.defaultPermissionMode,providers:l.providers,updatedAt:l.updatedAt});return{profile:{language:c.language,theme:c.theme,autoTheme:c.autoTheme,defaultPermissionMode:c.defaultPermissionMode},providers:c.providers,updatedAt:c.updatedAt}}catch{return null}}function Ah(e){if(!bu())return;const t={profile:e.profile,providers:e.providers,updatedAt:e.updatedAt};window.localStorage.setItem(UT,JSON.stringify(t))}function dl(){const e=VT(),t=GT(),r=t?YT(e,t,"default"):e,s=XI();return s?{initialized:!0,profile:s.profile,providers:s.providers,updatedAt:s.updatedAt,source:"shadow"}:r}function Fg(e,t){return{initialized:!0,profile:{language:e.language,theme:e.theme,autoTheme:e.autoTheme,defaultPermissionMode:e.defaultPermissionMode},providers:e.providers,updatedAt:e.updatedAt,source:t}}function YT(e,t,r){const s={...e.providers};if(t.providers)for(const i of am){const l=t.providers[i];l&&(s[i]={defaultModel:l.defaultModel!==void 0?l.defaultModel??null:e.providers[i].defaultModel,defaultReasoningLevel:l.defaultReasoningLevel!==void 0?l.defaultReasoningLevel??null:e.providers[i].defaultReasoningLevel})}return{initialized:!0,profile:{language:t.language??e.profile.language,theme:t.theme??e.profile.theme,autoTheme:t.autoTheme??e.profile.autoTheme,defaultPermissionMode:t.defaultPermissionMode??e.profile.defaultPermissionMode},providers:s,updatedAt:e.updatedAt,source:r}}async function QI(){const e=Mh(await BI());if(e.updatedAt===null){const r=GT();if(KT(r)){const s=Mh(await WT(r)),i=Fg(s,"remote");return Ah(i),i}}const t=Fg(e,"remote");return Ah(t),t}class JI{constructor(){ot(this,"state",dl());ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);En.subscribe(()=>{br.getState().session||this.state.source==="remote"||this.hydrate(dl())})}hydrate(t){this.state=t,this.emit()}resetToLocalFallback(){this.hydrate(dl())}async initialize(){if(!br.getState().session){const t=dl();return this.hydrate(t),t}return this.refreshForAuthenticatedUser()}async refreshForAuthenticatedUser(){if(!br.getState().session){const t=dl();return this.hydrate(t),t}try{const t=await QI();return this.hydrate(t),t}catch{const t=dl();return this.hydrate(t),t}}async updateProfile(t){const r=this.state,s=YT(r,t,r.source);if(this.hydrate(s),!br.getState().session)return Ah(s),s;try{const i=Mh(await WT(t)),l=Fg(i,"remote");return Ah(l),this.hydrate(l),l}catch(i){throw this.hydrate(r),i}}async updateProviderPreference(t,r){return this.updateProfile({providers:{[t]:r}})}emit(){for(const t of this.listeners)t()}}const xi=new JI;function _g(e){return p.useSyncExternalStore(xi.subscribe,()=>e(xi.getState()))}function nf(e){return am.includes(e)}function ZI(){return xi.initialize()}function Qc(e){return xi.updateProfile(e)}function ca(e){return _g(t=>e({profile:{...t.profile,providers:t.providers,updatedAt:t.updatedAt},isFetching:!1,error:null}))}async function eE(){const e=$s();return await En.initialize(),await ZI(),{platform:e.platform}}var $n=yT();const tE=pu($n),nE=wT({__proto__:null,default:tE},[$n]);/**
|
|
42
|
+
* @remix-run/router v1.23.2
|
|
43
|
+
*
|
|
44
|
+
* Copyright (c) Remix Software Inc.
|
|
45
|
+
*
|
|
46
|
+
* This source code is licensed under the MIT license found in the
|
|
47
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
48
|
+
*
|
|
49
|
+
* @license MIT
|
|
50
|
+
*/function gr(){return gr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},gr.apply(this,arguments)}var Ar;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Ar||(Ar={}));const Ik="popstate";function rE(e){e===void 0&&(e={});function t(s,i){let{pathname:l,search:c,hash:d}=s.location;return Jc("",{pathname:l,search:c,hash:d},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function r(s,i){return typeof i=="string"?i:vu(i)}return iE(t,r,null,e)}function An(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function No(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function sE(){return Math.random().toString(36).substr(2,8)}function Ek(e,t){return{usr:e.state,key:e.key,idx:t}}function Jc(e,t,r,s){return r===void 0&&(r=null),gr({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?qa(t):t,{state:r,key:t&&t.key||s||sE()})}function vu(e){let{pathname:t="/",search:r="",hash:s=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function qa(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let s=e.indexOf("?");s>=0&&(t.search=e.substr(s),e=e.substr(0,s)),e&&(t.pathname=e)}return t}function iE(e,t,r,s){s===void 0&&(s={});let{window:i=document.defaultView,v5Compat:l=!1}=s,c=i.history,d=Ar.Pop,m=null,f=v();f==null&&(f=0,c.replaceState(gr({},c.state,{idx:f}),""));function v(){return(c.state||{idx:null}).idx}function g(){d=Ar.Pop;let T=v(),j=T==null?null:T-f;f=T,m&&m({action:d,location:C.location,delta:j})}function w(T,j){d=Ar.Push;let N=Jc(C.location,T,j);f=v()+1;let D=Ek(N,f),F=C.createHref(N);try{c.pushState(D,"",F)}catch(W){if(W instanceof DOMException&&W.name==="DataCloneError")throw W;i.location.assign(F)}l&&m&&m({action:d,location:C.location,delta:1})}function k(T,j){d=Ar.Replace;let N=Jc(C.location,T,j);f=v();let D=Ek(N,f),F=C.createHref(N);c.replaceState(D,"",F),l&&m&&m({action:d,location:C.location,delta:0})}function y(T){let j=i.location.origin!=="null"?i.location.origin:i.location.href,N=typeof T=="string"?T:vu(T);return N=N.replace(/ $/,"%20"),An(j,"No window.location.(origin|href) available to create URL for href: "+N),new URL(N,j)}let C={get action(){return d},get location(){return e(i,c)},listen(T){if(m)throw new Error("A history only accepts one active listener");return i.addEventListener(Ik,g),m=T,()=>{i.removeEventListener(Ik,g),m=null}},createHref(T){return t(i,T)},createURL:y,encodeLocation(T){let j=y(T);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:w,replace:k,go(T){return c.go(T)}};return C}var qn;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(qn||(qn={}));const aE=new Set(["lazy","caseSensitive","path","id","index","children"]);function oE(e){return e.index===!0}function Ih(e,t,r,s){return r===void 0&&(r=[]),s===void 0&&(s={}),e.map((i,l)=>{let c=[...r,String(l)],d=typeof i.id=="string"?i.id:c.join("-");if(An(i.index!==!0||!i.children,"Cannot specify children on an index route"),An(!s[d],'Found a route id collision on id "'+d+`". Route id's must be globally unique within Data Router usages`),oE(i)){let m=gr({},i,t(i),{id:d});return s[d]=m,m}else{let m=gr({},i,t(i),{id:d,children:void 0});return s[d]=m,i.children&&(m.children=Ih(i.children,t,c,s)),m}})}function bo(e,t,r){return r===void 0&&(r="/"),hh(e,t,r,!1)}function hh(e,t,r,s){let i=typeof t=="string"?qa(t):t,l=wu(i.pathname||"/",r);if(l==null)return null;let c=XT(e);cE(c);let d=null;for(let m=0;d==null&&m<c.length;++m){let f=yE(l);d=vE(c[m],f,s)}return d}function lE(e,t){let{route:r,pathname:s,params:i}=e;return{id:r.id,pathname:s,params:i,data:t[r.id],handle:r.handle}}function XT(e,t,r,s){t===void 0&&(t=[]),r===void 0&&(r=[]),s===void 0&&(s="");let i=(l,c,d)=>{let m={relativePath:d===void 0?l.path||"":d,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};m.relativePath.startsWith("/")&&(An(m.relativePath.startsWith(s),'Absolute route path "'+m.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),m.relativePath=m.relativePath.slice(s.length));let f=Ua([s,m.relativePath]),v=r.concat(m);l.children&&l.children.length>0&&(An(l.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),XT(l.children,t,v,f)),!(l.path==null&&!l.index)&&t.push({path:f,score:gE(f,l.index),routesMeta:v})};return e.forEach((l,c)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))i(l,c);else for(let m of QT(l.path))i(l,c,m)}),t}function QT(e){let t=e.split("/");if(t.length===0)return[];let[r,...s]=t,i=r.endsWith("?"),l=r.replace(/\?$/,"");if(s.length===0)return i?[l,""]:[l];let c=QT(s.join("/")),d=[];return d.push(...c.map(m=>m===""?l:[l,m].join("/"))),i&&d.push(...c),d.map(m=>e.startsWith("/")&&m===""?"/":m)}function cE(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:bE(t.routesMeta.map(s=>s.childrenIndex),r.routesMeta.map(s=>s.childrenIndex)))}const uE=/^:[\w-]+$/,dE=3,hE=2,mE=1,pE=10,fE=-2,Lk=e=>e==="*";function gE(e,t){let r=e.split("/"),s=r.length;return r.some(Lk)&&(s+=fE),t&&(s+=hE),r.filter(i=>!Lk(i)).reduce((i,l)=>i+(uE.test(l)?dE:l===""?mE:pE),s)}function bE(e,t){return e.length===t.length&&e.slice(0,-1).every((s,i)=>s===t[i])?e[e.length-1]-t[t.length-1]:0}function vE(e,t,r){r===void 0&&(r=!1);let{routesMeta:s}=e,i={},l="/",c=[];for(let d=0;d<s.length;++d){let m=s[d],f=d===s.length-1,v=l==="/"?t:t.slice(l.length)||"/",g=Ir({path:m.relativePath,caseSensitive:m.caseSensitive,end:f},v),w=m.route;if(!g&&f&&r&&!s[s.length-1].route.index&&(g=Ir({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},v)),!g)return null;Object.assign(i,g.params),c.push({params:i,pathname:Ua([l,g.pathname]),pathnameBase:CE(Ua([l,g.pathnameBase])),route:w}),g.pathnameBase!=="/"&&(l=Ua([l,g.pathnameBase]))}return c}function Ir(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,s]=wE(e.path,e.caseSensitive,e.end),i=t.match(r);if(!i)return null;let l=i[0],c=l.replace(/(.)\/+$/,"$1"),d=i.slice(1);return{params:s.reduce((f,v,g)=>{let{paramName:w,isOptional:k}=v;if(w==="*"){let C=d[g]||"";c=l.slice(0,l.length-C.length).replace(/(.)\/+$/,"$1")}const y=d[g];return k&&!y?f[w]=void 0:f[w]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:l,pathnameBase:c,pattern:e}}function wE(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),No(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 s=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,d,m)=>(s.push({paramName:d,isOptional:m!=null}),m?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(s.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),s]}function yE(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return No(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function wu(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,s=e.charAt(r);return s&&s!=="/"?null:e.slice(r)||"/"}const kE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xE=e=>kE.test(e);function SE(e,t){t===void 0&&(t="/");let{pathname:r,search:s="",hash:i=""}=typeof e=="string"?qa(e):e,l;if(r)if(xE(r))l=r;else{if(r.includes("//")){let c=r;r=r.replace(/\/\/+/g,"/"),No(!1,"Pathnames cannot have embedded double slashes - normalizing "+(c+" -> "+r))}r.startsWith("/")?l=Fk(r.substring(1),"/"):l=Fk(r,t)}else l=t;return{pathname:l,search:jE(s),hash:TE(i)}}function Fk(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?r.length>1&&r.pop():i!=="."&&r.push(i)}),r.length>1?r.join("/"):"/"}function rf(e,t,r,s){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function JT(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function zb(e,t){let r=JT(e);return t?r.map((s,i)=>i===r.length-1?s.pathname:s.pathnameBase):r.map(s=>s.pathnameBase)}function qb(e,t,r,s){s===void 0&&(s=!1);let i;typeof e=="string"?i=qa(e):(i=gr({},e),An(!i.pathname||!i.pathname.includes("?"),rf("?","pathname","search",i)),An(!i.pathname||!i.pathname.includes("#"),rf("#","pathname","hash",i)),An(!i.search||!i.search.includes("#"),rf("#","search","hash",i)));let l=e===""||i.pathname==="",c=l?"/":i.pathname,d;if(c==null)d=r;else{let g=t.length-1;if(!s&&c.startsWith("..")){let w=c.split("/");for(;w[0]==="..";)w.shift(),g-=1;i.pathname=w.join("/")}d=g>=0?t[g]:"/"}let m=SE(i,d),f=c&&c!=="/"&&c.endsWith("/"),v=(l||c===".")&&r.endsWith("/");return!m.pathname.endsWith("/")&&(f||v)&&(m.pathname+="/"),m}const Ua=e=>e.join("/").replace(/\/\/+/g,"/"),CE=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),jE=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,TE=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;class Eh{constructor(t,r,s,i){i===void 0&&(i=!1),this.status=t,this.statusText=r||"",this.internal=i,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}}function Zc(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const ZT=["post","put","patch","delete"],NE=new Set(ZT),PE=["get",...ZT],DE=new Set(PE),RE=new Set([301,302,303,307,308]),ME=new Set([307,308]),sf={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},AE={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},fc={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},$b=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,IE=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),eN="remix-router-transitions";function EE(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u",s=!r;An(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let i;if(e.mapRouteProperties)i=e.mapRouteProperties;else if(e.detectErrorBoundary){let Z=e.detectErrorBoundary;i=ce=>({hasErrorBoundary:Z(ce)})}else i=IE;let l={},c=Ih(e.routes,i,void 0,l),d,m=e.basename||"/",f=e.dataStrategy||OE,v=e.patchRoutesOnNavigation,g=gr({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),w=null,k=new Set,y=null,C=null,T=null,j=e.hydrationData!=null,N=bo(c,e.history.location,m),D=!1,F=null;if(N==null&&!v){let Z=Ps(404,{pathname:e.history.location.pathname}),{matches:ce,route:ge}=Gk(c);N=ce,F={[ge.id]:Z}}N&&!e.hydrationData&&Rn(N,c,e.history.location.pathname).active&&(N=null);let W;if(N)if(N.some(Z=>Z.route.lazy))W=!1;else if(!N.some(Z=>Z.route.loader))W=!0;else if(g.v7_partialHydration){let Z=e.hydrationData?e.hydrationData.loaderData:null,ce=e.hydrationData?e.hydrationData.errors:null;if(ce){let ge=N.findIndex(Ce=>ce[Ce.route.id]!==void 0);W=N.slice(0,ge+1).every(Ce=>!Bg(Ce.route,Z,ce))}else W=N.every(ge=>!Bg(ge.route,Z,ce))}else W=e.hydrationData!=null;else if(W=!1,N=[],g.v7_partialHydration){let Z=Rn(null,c,e.history.location.pathname);Z.active&&Z.matches&&(D=!0,N=Z.matches)}let E,I={historyAction:e.history.action,location:e.history.location,matches:N,initialized:W,navigation:sf,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||F,fetchers:new Map,blockers:new Map},M=Ar.Pop,_=!1,L,Q=!1,O=new Map,ne=null,Y=!1,G=!1,te=[],K=new Set,z=new Map,q=0,P=-1,U=new Map,X=new Set,R=new Map,Se=new Map,se=new Set,J=new Map,Ne=new Map,Ee;function ie(){if(w=e.history.listen(Z=>{let{action:ce,location:ge,delta:Ce}=Z;if(Ee){Ee(),Ee=void 0;return}No(Ne.size===0||Ce!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let We=ae({currentLocation:I.location,nextLocation:ge,historyAction:ce});if(We&&Ce!=null){let qe=new Promise(Pt=>{Ee=Pt});e.history.go(Ce*-1),un(We,{state:"blocked",location:ge,proceed(){un(We,{state:"proceeding",proceed:void 0,reset:void 0,location:ge}),qe.then(()=>e.history.go(Ce))},reset(){let Pt=new Map(I.blockers);Pt.set(We,fc),Oe({blockers:Pt})}});return}return et(ce,ge)}),r){JE(t,O);let Z=()=>ZE(t,O);t.addEventListener("pagehide",Z),ne=()=>t.removeEventListener("pagehide",Z)}return I.initialized||et(Ar.Pop,I.location,{initialHydration:!0}),E}function xe(){w&&w(),ne&&ne(),k.clear(),L&&L.abort(),I.fetchers.forEach((Z,ce)=>ht(ce)),I.blockers.forEach((Z,ce)=>Kt(ce))}function lt(Z){return k.add(Z),()=>k.delete(Z)}function Oe(Z,ce){ce===void 0&&(ce={}),I=gr({},I,Z);let ge=[],Ce=[];g.v7_fetcherPersist&&I.fetchers.forEach((We,qe)=>{We.state==="idle"&&(se.has(qe)?Ce.push(qe):ge.push(qe))}),se.forEach(We=>{!I.fetchers.has(We)&&!z.has(We)&&Ce.push(We)}),[...k].forEach(We=>We(I,{deletedFetchers:Ce,viewTransitionOpts:ce.viewTransitionOpts,flushSync:ce.flushSync===!0})),g.v7_fetcherPersist?(ge.forEach(We=>I.fetchers.delete(We)),Ce.forEach(We=>ht(We))):Ce.forEach(We=>se.delete(We))}function bt(Z,ce,ge){var Ce,We;let{flushSync:qe}=ge===void 0?{}:ge,Pt=I.actionData!=null&&I.navigation.formMethod!=null&&vi(I.navigation.formMethod)&&I.navigation.state==="loading"&&((Ce=Z.state)==null?void 0:Ce._isRedirect)!==!0,Ke;ce.actionData?Object.keys(ce.actionData).length>0?Ke=ce.actionData:Ke=null:Pt?Ke=I.actionData:Ke=null;let at=ce.loaderData?$k(I.loaderData,ce.loaderData,ce.matches||[],ce.errors):I.loaderData,ft=I.blockers;ft.size>0&&(ft=new Map(ft),ft.forEach((Re,_t)=>ft.set(_t,fc)));let ct=_===!0||I.navigation.formMethod!=null&&vi(I.navigation.formMethod)&&((We=Z.state)==null?void 0:We._isRedirect)!==!0;d&&(c=d,d=void 0),Y||M===Ar.Pop||(M===Ar.Push?e.history.push(Z,Z.state):M===Ar.Replace&&e.history.replace(Z,Z.state));let oe;if(M===Ar.Pop){let Re=O.get(I.location.pathname);Re&&Re.has(Z.pathname)?oe={currentLocation:I.location,nextLocation:Z}:O.has(Z.pathname)&&(oe={currentLocation:Z,nextLocation:I.location})}else if(Q){let Re=O.get(I.location.pathname);Re?Re.add(Z.pathname):(Re=new Set([Z.pathname]),O.set(I.location.pathname,Re)),oe={currentLocation:I.location,nextLocation:Z}}Oe(gr({},ce,{actionData:Ke,loaderData:at,historyAction:M,location:Z,initialized:!0,navigation:sf,revalidation:"idle",restoreScrollPosition:Wn(Z,ce.matches||I.matches),preventScrollReset:ct,blockers:ft}),{viewTransitionOpts:oe,flushSync:qe===!0}),M=Ar.Pop,_=!1,Q=!1,Y=!1,G=!1,te=[]}async function Ct(Z,ce){if(typeof Z=="number"){e.history.go(Z);return}let ge=Og(I.location,I.matches,m,g.v7_prependBasename,Z,g.v7_relativeSplatPath,ce==null?void 0:ce.fromRouteId,ce==null?void 0:ce.relative),{path:Ce,submission:We,error:qe}=_k(g.v7_normalizeFormMethod,!1,ge,ce),Pt=I.location,Ke=Jc(I.location,Ce,ce&&ce.state);Ke=gr({},Ke,e.history.encodeLocation(Ke));let at=ce&&ce.replace!=null?ce.replace:void 0,ft=Ar.Push;at===!0?ft=Ar.Replace:at===!1||We!=null&&vi(We.formMethod)&&We.formAction===I.location.pathname+I.location.search&&(ft=Ar.Replace);let ct=ce&&"preventScrollReset"in ce?ce.preventScrollReset===!0:void 0,oe=(ce&&ce.flushSync)===!0,Re=ae({currentLocation:Pt,nextLocation:Ke,historyAction:ft});if(Re){un(Re,{state:"blocked",location:Ke,proceed(){un(Re,{state:"proceeding",proceed:void 0,reset:void 0,location:Ke}),Ct(Z,ce)},reset(){let _t=new Map(I.blockers);_t.set(Re,fc),Oe({blockers:_t})}});return}return await et(ft,Ke,{submission:We,pendingError:qe,preventScrollReset:ct,replace:ce&&ce.replace,enableViewTransition:ce&&ce.viewTransition,flushSync:oe})}function nt(){if(Me(),Oe({revalidation:"loading"}),I.navigation.state!=="submitting"){if(I.navigation.state==="idle"){et(I.historyAction,I.location,{startUninterruptedRevalidation:!0});return}et(M||I.historyAction,I.navigation.location,{overrideNavigation:I.navigation,enableViewTransition:Q===!0})}}async function et(Z,ce,ge){L&&L.abort(),L=null,M=Z,Y=(ge&&ge.startUninterruptedRevalidation)===!0,on(I.location,I.matches),_=(ge&&ge.preventScrollReset)===!0,Q=(ge&&ge.enableViewTransition)===!0;let Ce=d||c,We=ge&&ge.overrideNavigation,qe=ge!=null&&ge.initialHydration&&I.matches&&I.matches.length>0&&!D?I.matches:bo(Ce,ce,m),Pt=(ge&&ge.flushSync)===!0;if(qe&&I.initialized&&!G&&qE(I.location,ce)&&!(ge&&ge.submission&&vi(ge.submission.formMethod))){bt(ce,{matches:qe},{flushSync:Pt});return}let Ke=Rn(qe,Ce,ce.pathname);if(Ke.active&&Ke.matches&&(qe=Ke.matches),!qe){let{error:Ut,notFoundMatches:Qt,route:ln}=Be(ce.pathname);bt(ce,{matches:Qt,loaderData:{},errors:{[ln.id]:Ut}},{flushSync:Pt});return}L=new AbortController;let at=hl(e.history,ce,L.signal,ge&&ge.submission),ft;if(ge&&ge.pendingError)ft=[vo(qe).route.id,{type:qn.error,error:ge.pendingError}];else if(ge&&ge.submission&&vi(ge.submission.formMethod)){let Ut=await De(at,ce,ge.submission,qe,Ke.active,{replace:ge.replace,flushSync:Pt});if(Ut.shortCircuited)return;if(Ut.pendingActionResult){let[Qt,ln]=Ut.pendingActionResult;if(Hs(ln)&&Zc(ln.error)&&ln.error.status===404){L=null,bt(ce,{matches:Ut.matches,loaderData:{},errors:{[Qt]:ln.error}});return}}qe=Ut.matches||qe,ft=Ut.pendingActionResult,We=af(ce,ge.submission),Pt=!1,Ke.active=!1,at=hl(e.history,at.url,at.signal)}let{shortCircuited:ct,matches:oe,loaderData:Re,errors:_t}=await Ue(at,ce,qe,Ke.active,We,ge&&ge.submission,ge&&ge.fetcherSubmission,ge&&ge.replace,ge&&ge.initialHydration===!0,Pt,ft);ct||(L=null,bt(ce,gr({matches:oe||qe},Vk(ft),{loaderData:Re,errors:_t})))}async function De(Z,ce,ge,Ce,We,qe){qe===void 0&&(qe={}),Me();let Pt=XE(ce,ge);if(Oe({navigation:Pt},{flushSync:qe.flushSync===!0}),We){let ft=await $t(Ce,ce.pathname,Z.signal);if(ft.type==="aborted")return{shortCircuited:!0};if(ft.type==="error"){let ct=vo(ft.partialMatches).route.id;return{matches:ft.partialMatches,pendingActionResult:[ct,{type:qn.error,error:ft.error}]}}else if(ft.matches)Ce=ft.matches;else{let{notFoundMatches:ct,error:oe,route:Re}=Be(ce.pathname);return{matches:ct,pendingActionResult:[Re.id,{type:qn.error,error:oe}]}}}let Ke,at=Dc(Ce,ce);if(!at.route.action&&!at.route.lazy)Ke={type:qn.error,error:Ps(405,{method:Z.method,pathname:ce.pathname,routeId:at.route.id})};else if(Ke=(await kt("action",I,Z,[at],Ce,null))[at.route.id],Z.signal.aborted)return{shortCircuited:!0};if(ko(Ke)){let ft;return qe&&qe.replace!=null?ft=qe.replace:ft=Hk(Ke.response.headers.get("Location"),new URL(Z.url),m,e.history)===I.location.pathname+I.location.search,await Ve(Z,Ke,!0,{submission:ge,replace:ft}),{shortCircuited:!0}}if(Fa(Ke))throw Ps(400,{type:"defer-action"});if(Hs(Ke)){let ft=vo(Ce,at.route.id);return(qe&&qe.replace)!==!0&&(M=Ar.Push),{matches:Ce,pendingActionResult:[ft.route.id,Ke]}}return{matches:Ce,pendingActionResult:[at.route.id,Ke]}}async function Ue(Z,ce,ge,Ce,We,qe,Pt,Ke,at,ft,ct){let oe=We||af(ce,qe),Re=qe||Pt||Yk(oe),_t=!Y&&(!g.v7_partialHydration||!at);if(Ce){if(_t){let Zt=Ye(ct);Oe(gr({navigation:oe},Zt!==void 0?{actionData:Zt}:{}),{flushSync:ft})}let xt=await $t(ge,ce.pathname,Z.signal);if(xt.type==="aborted")return{shortCircuited:!0};if(xt.type==="error"){let Zt=vo(xt.partialMatches).route.id;return{matches:xt.partialMatches,loaderData:{},errors:{[Zt]:xt.error}}}else if(xt.matches)ge=xt.matches;else{let{error:Zt,notFoundMatches:we,route:Ge}=Be(ce.pathname);return{matches:we,loaderData:{},errors:{[Ge.id]:Zt}}}}let Ut=d||c,[Qt,ln]=Bk(e.history,I,ge,Re,ce,g.v7_partialHydration&&at===!0,g.v7_skipActionErrorRevalidation,G,te,K,se,R,X,Ut,m,ct);if(It(xt=>!(ge&&ge.some(Zt=>Zt.route.id===xt))||Qt&&Qt.some(Zt=>Zt.route.id===xt)),P=++q,Qt.length===0&&ln.length===0){let xt=Rt();return bt(ce,gr({matches:ge,loaderData:{},errors:ct&&Hs(ct[1])?{[ct[0]]:ct[1].error}:null},Vk(ct),xt?{fetchers:new Map(I.fetchers)}:{}),{flushSync:ft}),{shortCircuited:!0}}if(_t){let xt={};if(!Ce){xt.navigation=oe;let Zt=Ye(ct);Zt!==void 0&&(xt.actionData=Zt)}ln.length>0&&(xt.fetchers=ye(ln)),Oe(xt,{flushSync:ft})}ln.forEach(xt=>{$e(xt.key),xt.controller&&z.set(xt.key,xt.controller)});let jn=()=>ln.forEach(xt=>$e(xt.key));L&&L.signal.addEventListener("abort",jn);let{loaderResults:Jn,fetcherResults:bn}=await me(I,ge,Qt,ln,Z);if(Z.signal.aborted)return{shortCircuited:!0};L&&L.signal.removeEventListener("abort",jn),ln.forEach(xt=>z.delete(xt.key));let Jt=jd(Jn);if(Jt)return await Ve(Z,Jt.result,!0,{replace:Ke}),{shortCircuited:!0};if(Jt=jd(bn),Jt)return X.add(Jt.key),await Ve(Z,Jt.result,!0,{replace:Ke}),{shortCircuited:!0};let{loaderData:ur,errors:vn}=qk(I,ge,Jn,ct,ln,bn,J);J.forEach((xt,Zt)=>{xt.subscribe(we=>{(we||xt.done)&&J.delete(Zt)})}),g.v7_partialHydration&&at&&I.errors&&(vn=gr({},I.errors,vn));let yn=Rt(),kn=Ft(P),Nn=yn||kn||ln.length>0;return gr({matches:ge,loaderData:ur,errors:vn},Nn?{fetchers:new Map(I.fetchers)}:{})}function Ye(Z){if(Z&&!Hs(Z[1]))return{[Z[0]]:Z[1].data};if(I.actionData)return Object.keys(I.actionData).length===0?null:I.actionData}function ye(Z){return Z.forEach(ce=>{let ge=I.fetchers.get(ce.key),Ce=gc(void 0,ge?ge.data:void 0);I.fetchers.set(ce.key,Ce)}),new Map(I.fetchers)}function He(Z,ce,ge,Ce){if(s)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");$e(Z);let We=(Ce&&Ce.flushSync)===!0,qe=d||c,Pt=Og(I.location,I.matches,m,g.v7_prependBasename,ge,g.v7_relativeSplatPath,ce,Ce==null?void 0:Ce.relative),Ke=bo(qe,Pt,m),at=Rn(Ke,qe,Pt);if(at.active&&at.matches&&(Ke=at.matches),!Ke){ze(Z,ce,Ps(404,{pathname:Pt}),{flushSync:We});return}let{path:ft,submission:ct,error:oe}=_k(g.v7_normalizeFormMethod,!0,Pt,Ce);if(oe){ze(Z,ce,oe,{flushSync:We});return}let Re=Dc(Ke,ft),_t=(Ce&&Ce.preventScrollReset)===!0;if(ct&&vi(ct.formMethod)){je(Z,ce,ft,Re,Ke,at.active,We,_t,ct);return}R.set(Z,{routeId:ce,path:ft}),Fe(Z,ce,ft,Re,Ke,at.active,We,_t,ct)}async function je(Z,ce,ge,Ce,We,qe,Pt,Ke,at){Me(),R.delete(Z);function ft(St){if(!St.route.action&&!St.route.lazy){let Sn=Ps(405,{method:at.formMethod,pathname:ge,routeId:ce});return ze(Z,ce,Sn,{flushSync:Pt}),!0}return!1}if(!qe&&ft(Ce))return;let ct=I.fetchers.get(Z);Xe(Z,QE(at,ct),{flushSync:Pt});let oe=new AbortController,Re=hl(e.history,ge,oe.signal,at);if(qe){let St=await $t(We,new URL(Re.url).pathname,Re.signal,Z);if(St.type==="aborted")return;if(St.type==="error"){ze(Z,ce,St.error,{flushSync:Pt});return}else if(St.matches){if(We=St.matches,Ce=Dc(We,ge),ft(Ce))return}else{ze(Z,ce,Ps(404,{pathname:ge}),{flushSync:Pt});return}}z.set(Z,oe);let _t=q,Qt=(await kt("action",I,Re,[Ce],We,Z))[Ce.route.id];if(Re.signal.aborted){z.get(Z)===oe&&z.delete(Z);return}if(g.v7_fetcherPersist&&se.has(Z)){if(ko(Qt)||Hs(Qt)){Xe(Z,Ia(void 0));return}}else{if(ko(Qt))if(z.delete(Z),P>_t){Xe(Z,Ia(void 0));return}else return X.add(Z),Xe(Z,gc(at)),Ve(Re,Qt,!1,{fetcherSubmission:at,preventScrollReset:Ke});if(Hs(Qt)){ze(Z,ce,Qt.error);return}}if(Fa(Qt))throw Ps(400,{type:"defer-action"});let ln=I.navigation.location||I.location,jn=hl(e.history,ln,oe.signal),Jn=d||c,bn=I.navigation.state!=="idle"?bo(Jn,I.navigation.location,m):I.matches;An(bn,"Didn't find any matches after fetcher action");let Jt=++q;U.set(Z,Jt);let ur=gc(at,Qt.data);I.fetchers.set(Z,ur);let[vn,yn]=Bk(e.history,I,bn,at,ln,!1,g.v7_skipActionErrorRevalidation,G,te,K,se,R,X,Jn,m,[Ce.route.id,Qt]);yn.filter(St=>St.key!==Z).forEach(St=>{let Sn=St.key,_n=I.fetchers.get(Sn),Vn=gc(void 0,_n?_n.data:void 0);I.fetchers.set(Sn,Vn),$e(Sn),St.controller&&z.set(Sn,St.controller)}),Oe({fetchers:new Map(I.fetchers)});let kn=()=>yn.forEach(St=>$e(St.key));oe.signal.addEventListener("abort",kn);let{loaderResults:Nn,fetcherResults:xt}=await me(I,bn,vn,yn,jn);if(oe.signal.aborted)return;oe.signal.removeEventListener("abort",kn),U.delete(Z),z.delete(Z),yn.forEach(St=>z.delete(St.key));let Zt=jd(Nn);if(Zt)return Ve(jn,Zt.result,!1,{preventScrollReset:Ke});if(Zt=jd(xt),Zt)return X.add(Zt.key),Ve(jn,Zt.result,!1,{preventScrollReset:Ke});let{loaderData:we,errors:Ge}=qk(I,bn,Nn,void 0,yn,xt,J);if(I.fetchers.has(Z)){let St=Ia(Qt.data);I.fetchers.set(Z,St)}Ft(Jt),I.navigation.state==="loading"&&Jt>P?(An(M,"Expected pending action"),L&&L.abort(),bt(I.navigation.location,{matches:bn,loaderData:we,errors:Ge,fetchers:new Map(I.fetchers)})):(Oe({errors:Ge,loaderData:$k(I.loaderData,we,bn,Ge),fetchers:new Map(I.fetchers)}),G=!1)}async function Fe(Z,ce,ge,Ce,We,qe,Pt,Ke,at){let ft=I.fetchers.get(Z);Xe(Z,gc(at,ft?ft.data:void 0),{flushSync:Pt});let ct=new AbortController,oe=hl(e.history,ge,ct.signal);if(qe){let Qt=await $t(We,new URL(oe.url).pathname,oe.signal,Z);if(Qt.type==="aborted")return;if(Qt.type==="error"){ze(Z,ce,Qt.error,{flushSync:Pt});return}else if(Qt.matches)We=Qt.matches,Ce=Dc(We,ge);else{ze(Z,ce,Ps(404,{pathname:ge}),{flushSync:Pt});return}}z.set(Z,ct);let Re=q,Ut=(await kt("loader",I,oe,[Ce],We,Z))[Ce.route.id];if(Fa(Ut)&&(Ut=await Vb(Ut,oe.signal,!0)||Ut),z.get(Z)===ct&&z.delete(Z),!oe.signal.aborted){if(se.has(Z)){Xe(Z,Ia(void 0));return}if(ko(Ut))if(P>Re){Xe(Z,Ia(void 0));return}else{X.add(Z),await Ve(oe,Ut,!1,{preventScrollReset:Ke});return}if(Hs(Ut)){ze(Z,ce,Ut.error);return}An(!Fa(Ut),"Unhandled fetcher deferred data"),Xe(Z,Ia(Ut.data))}}async function Ve(Z,ce,ge,Ce){let{submission:We,fetcherSubmission:qe,preventScrollReset:Pt,replace:Ke}=Ce===void 0?{}:Ce;ce.response.headers.has("X-Remix-Revalidate")&&(G=!0);let at=ce.response.headers.get("Location");An(at,"Expected a Location header on the redirect Response"),at=Hk(at,new URL(Z.url),m,e.history);let ft=Jc(I.location,at,{_isRedirect:!0});if(r){let Qt=!1;if(ce.response.headers.has("X-Remix-Reload-Document"))Qt=!0;else if($b.test(at)){const ln=e.history.createURL(at);Qt=ln.origin!==t.location.origin||wu(ln.pathname,m)==null}if(Qt){Ke?t.location.replace(at):t.location.assign(at);return}}L=null;let ct=Ke===!0||ce.response.headers.has("X-Remix-Replace")?Ar.Replace:Ar.Push,{formMethod:oe,formAction:Re,formEncType:_t}=I.navigation;!We&&!qe&&oe&&Re&&_t&&(We=Yk(I.navigation));let Ut=We||qe;if(ME.has(ce.response.status)&&Ut&&vi(Ut.formMethod))await et(ct,ft,{submission:gr({},Ut,{formAction:at}),preventScrollReset:Pt||_,enableViewTransition:ge?Q:void 0});else{let Qt=af(ft,We);await et(ct,ft,{overrideNavigation:Qt,fetcherSubmission:qe,preventScrollReset:Pt||_,enableViewTransition:ge?Q:void 0})}}async function kt(Z,ce,ge,Ce,We,qe){let Pt,Ke={};try{Pt=await BE(f,Z,ce,ge,Ce,We,qe,l,i)}catch(at){return Ce.forEach(ft=>{Ke[ft.route.id]={type:qn.error,error:at}}),Ke}for(let[at,ft]of Object.entries(Pt))if($E(ft)){let ct=ft.result;Ke[at]={type:qn.redirect,response:HE(ct,ge,at,We,m,g.v7_relativeSplatPath)}}else Ke[at]=await UE(ft);return Ke}async function me(Z,ce,ge,Ce,We){let qe=Z.matches,Pt=kt("loader",Z,We,ge,ce,null),Ke=Promise.all(Ce.map(async ct=>{if(ct.matches&&ct.match&&ct.controller){let Re=(await kt("loader",Z,hl(e.history,ct.path,ct.controller.signal),[ct.match],ct.matches,ct.key))[ct.match.route.id];return{[ct.key]:Re}}else return Promise.resolve({[ct.key]:{type:qn.error,error:Ps(404,{pathname:ct.path})}})})),at=await Pt,ft=(await Ke).reduce((ct,oe)=>Object.assign(ct,oe),{});return await Promise.all([KE(ce,at,We.signal,qe,Z.loaderData),YE(ce,ft,Ce)]),{loaderResults:at,fetcherResults:ft}}function Me(){G=!0,te.push(...It()),R.forEach((Z,ce)=>{z.has(ce)&&K.add(ce),$e(ce)})}function Xe(Z,ce,ge){ge===void 0&&(ge={}),I.fetchers.set(Z,ce),Oe({fetchers:new Map(I.fetchers)},{flushSync:(ge&&ge.flushSync)===!0})}function ze(Z,ce,ge,Ce){Ce===void 0&&(Ce={});let We=vo(I.matches,ce);ht(Z),Oe({errors:{[We.route.id]:ge},fetchers:new Map(I.fetchers)},{flushSync:(Ce&&Ce.flushSync)===!0})}function vt(Z){return Se.set(Z,(Se.get(Z)||0)+1),se.has(Z)&&se.delete(Z),I.fetchers.get(Z)||AE}function ht(Z){let ce=I.fetchers.get(Z);z.has(Z)&&!(ce&&ce.state==="loading"&&U.has(Z))&&$e(Z),R.delete(Z),U.delete(Z),X.delete(Z),g.v7_fetcherPersist&&se.delete(Z),K.delete(Z),I.fetchers.delete(Z)}function pe(Z){let ce=(Se.get(Z)||0)-1;ce<=0?(Se.delete(Z),se.add(Z),g.v7_fetcherPersist||ht(Z)):Se.set(Z,ce),Oe({fetchers:new Map(I.fetchers)})}function $e(Z){let ce=z.get(Z);ce&&(ce.abort(),z.delete(Z))}function Nt(Z){for(let ce of Z){let ge=vt(ce),Ce=Ia(ge.data);I.fetchers.set(ce,Ce)}}function Rt(){let Z=[],ce=!1;for(let ge of X){let Ce=I.fetchers.get(ge);An(Ce,"Expected fetcher: "+ge),Ce.state==="loading"&&(X.delete(ge),Z.push(ge),ce=!0)}return Nt(Z),ce}function Ft(Z){let ce=[];for(let[ge,Ce]of U)if(Ce<Z){let We=I.fetchers.get(ge);An(We,"Expected fetcher: "+ge),We.state==="loading"&&($e(ge),U.delete(ge),ce.push(ge))}return Nt(ce),ce.length>0}function Wt(Z,ce){let ge=I.blockers.get(Z)||fc;return Ne.get(Z)!==ce&&Ne.set(Z,ce),ge}function Kt(Z){I.blockers.delete(Z),Ne.delete(Z)}function un(Z,ce){let ge=I.blockers.get(Z)||fc;An(ge.state==="unblocked"&&ce.state==="blocked"||ge.state==="blocked"&&ce.state==="blocked"||ge.state==="blocked"&&ce.state==="proceeding"||ge.state==="blocked"&&ce.state==="unblocked"||ge.state==="proceeding"&&ce.state==="unblocked","Invalid blocker state transition: "+ge.state+" -> "+ce.state);let Ce=new Map(I.blockers);Ce.set(Z,ce),Oe({blockers:Ce})}function ae(Z){let{currentLocation:ce,nextLocation:ge,historyAction:Ce}=Z;if(Ne.size===0)return;Ne.size>1&&No(!1,"A router only supports one blocker at a time");let We=Array.from(Ne.entries()),[qe,Pt]=We[We.length-1],Ke=I.blockers.get(qe);if(!(Ke&&Ke.state==="proceeding")&&Pt({currentLocation:ce,nextLocation:ge,historyAction:Ce}))return qe}function Be(Z){let ce=Ps(404,{pathname:Z}),ge=d||c,{matches:Ce,route:We}=Gk(ge);return It(),{notFoundMatches:Ce,route:We,error:ce}}function It(Z){let ce=[];return J.forEach((ge,Ce)=>{(!Z||Z(Ce))&&(ge.cancel(),ce.push(Ce),J.delete(Ce))}),ce}function jt(Z,ce,ge){if(y=Z,T=ce,C=ge||null,!j&&I.navigation===sf){j=!0;let Ce=Wn(I.location,I.matches);Ce!=null&&Oe({restoreScrollPosition:Ce})}return()=>{y=null,T=null,C=null}}function Cn(Z,ce){return C&&C(Z,ce.map(Ce=>lE(Ce,I.loaderData)))||Z.key}function on(Z,ce){if(y&&T){let ge=Cn(Z,ce);y[ge]=T()}}function Wn(Z,ce){if(y){let ge=Cn(Z,ce),Ce=y[ge];if(typeof Ce=="number")return Ce}return null}function Rn(Z,ce,ge){if(v)if(Z){if(Object.keys(Z[0].params).length>0)return{active:!0,matches:hh(ce,ge,m,!0)}}else return{active:!0,matches:hh(ce,ge,m,!0)||[]};return{active:!1,matches:null}}async function $t(Z,ce,ge,Ce){if(!v)return{type:"success",matches:Z};let We=Z;for(;;){let qe=d==null,Pt=d||c,Ke=l;try{await v({signal:ge,path:ce,matches:We,fetcherKey:Ce,patch:(ct,oe)=>{ge.aborted||Uk(ct,oe,Pt,Ke,i)}})}catch(ct){return{type:"error",error:ct,partialMatches:We}}finally{qe&&!ge.aborted&&(c=[...c])}if(ge.aborted)return{type:"aborted"};let at=bo(Pt,ce,m);if(at)return{type:"success",matches:at};let ft=hh(Pt,ce,m,!0);if(!ft||We.length===ft.length&&We.every((ct,oe)=>ct.route.id===ft[oe].route.id))return{type:"success",matches:null};We=ft}}function dn(Z){l={},d=Ih(Z,i,void 0,l)}function gn(Z,ce){let ge=d==null;Uk(Z,ce,d||c,l,i),ge&&(c=[...c],Oe({}))}return E={get basename(){return m},get future(){return g},get state(){return I},get routes(){return c},get window(){return t},initialize:ie,subscribe:lt,enableScrollRestoration:jt,navigate:Ct,fetch:He,revalidate:nt,createHref:Z=>e.history.createHref(Z),encodeLocation:Z=>e.history.encodeLocation(Z),getFetcher:vt,deleteFetcher:pe,dispose:xe,getBlocker:Wt,deleteBlocker:Kt,patchRoutes:gn,_internalFetchControllers:z,_internalActiveDeferreds:J,_internalSetRoutes:dn},E}function LE(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Og(e,t,r,s,i,l,c,d){let m,f;if(c){m=[];for(let g of t)if(m.push(g),g.route.id===c){f=g;break}}else m=t,f=t[t.length-1];let v=qb(i||".",zb(m,l),wu(e.pathname,r)||e.pathname,d==="path");if(i==null&&(v.search=e.search,v.hash=e.hash),(i==null||i===""||i===".")&&f){let g=Gb(v.search);if(f.route.index&&!g)v.search=v.search?v.search.replace(/^\?/,"?index&"):"?index";else if(!f.route.index&&g){let w=new URLSearchParams(v.search),k=w.getAll("index");w.delete("index"),k.filter(C=>C).forEach(C=>w.append("index",C));let y=w.toString();v.search=y?"?"+y:""}}return s&&r!=="/"&&(v.pathname=v.pathname==="/"?r:Ua([r,v.pathname])),vu(v)}function _k(e,t,r,s){if(!s||!LE(s))return{path:r};if(s.formMethod&&!GE(s.formMethod))return{path:r,error:Ps(405,{method:s.formMethod})};let i=()=>({path:r,error:Ps(400,{type:"invalid-body"})}),l=s.formMethod||"get",c=e?l.toUpperCase():l.toLowerCase(),d=rN(r);if(s.body!==void 0){if(s.formEncType==="text/plain"){if(!vi(c))return i();let w=typeof s.body=="string"?s.body:s.body instanceof FormData||s.body instanceof URLSearchParams?Array.from(s.body.entries()).reduce((k,y)=>{let[C,T]=y;return""+k+C+"="+T+`
|
|
51
|
+
`},""):String(s.body);return{path:r,submission:{formMethod:c,formAction:d,formEncType:s.formEncType,formData:void 0,json:void 0,text:w}}}else if(s.formEncType==="application/json"){if(!vi(c))return i();try{let w=typeof s.body=="string"?JSON.parse(s.body):s.body;return{path:r,submission:{formMethod:c,formAction:d,formEncType:s.formEncType,formData:void 0,json:w,text:void 0}}}catch{return i()}}}An(typeof FormData=="function","FormData is not available in this environment");let m,f;if(s.formData)m=Wg(s.formData),f=s.formData;else if(s.body instanceof FormData)m=Wg(s.body),f=s.body;else if(s.body instanceof URLSearchParams)m=s.body,f=zk(m);else if(s.body==null)m=new URLSearchParams,f=new FormData;else try{m=new URLSearchParams(s.body),f=zk(m)}catch{return i()}let v={formMethod:c,formAction:d,formEncType:s&&s.formEncType||"application/x-www-form-urlencoded",formData:f,json:void 0,text:void 0};if(vi(v.formMethod))return{path:r,submission:v};let g=qa(r);return t&&g.search&&Gb(g.search)&&m.append("index",""),g.search="?"+m,{path:vu(g),submission:v}}function Ok(e,t,r){r===void 0&&(r=!1);let s=e.findIndex(i=>i.route.id===t);return s>=0?e.slice(0,r?s+1:s):e}function Bk(e,t,r,s,i,l,c,d,m,f,v,g,w,k,y,C){let T=C?Hs(C[1])?C[1].error:C[1].data:void 0,j=e.createURL(t.location),N=e.createURL(i),D=r;l&&t.errors?D=Ok(r,Object.keys(t.errors)[0],!0):C&&Hs(C[1])&&(D=Ok(r,C[0]));let F=C?C[1].statusCode:void 0,W=c&&F&&F>=400,E=D.filter((M,_)=>{let{route:L}=M;if(L.lazy)return!0;if(L.loader==null)return!1;if(l)return Bg(L,t.loaderData,t.errors);if(FE(t.loaderData,t.matches[_],M)||m.some(ne=>ne===M.route.id))return!0;let Q=t.matches[_],O=M;return Wk(M,gr({currentUrl:j,currentParams:Q.params,nextUrl:N,nextParams:O.params},s,{actionResult:T,actionStatus:F,defaultShouldRevalidate:W?!1:d||j.pathname+j.search===N.pathname+N.search||j.search!==N.search||tN(Q,O)}))}),I=[];return g.forEach((M,_)=>{if(l||!r.some(Y=>Y.route.id===M.routeId)||v.has(_))return;let L=bo(k,M.path,y);if(!L){I.push({key:_,routeId:M.routeId,path:M.path,matches:null,match:null,controller:null});return}let Q=t.fetchers.get(_),O=Dc(L,M.path),ne=!1;w.has(_)?ne=!1:f.has(_)?(f.delete(_),ne=!0):Q&&Q.state!=="idle"&&Q.data===void 0?ne=d:ne=Wk(O,gr({currentUrl:j,currentParams:t.matches[t.matches.length-1].params,nextUrl:N,nextParams:r[r.length-1].params},s,{actionResult:T,actionStatus:F,defaultShouldRevalidate:W?!1:d})),ne&&I.push({key:_,routeId:M.routeId,path:M.path,matches:L,match:O,controller:new AbortController})}),[E,I]}function Bg(e,t,r){if(e.lazy)return!0;if(!e.loader)return!1;let s=t!=null&&t[e.id]!==void 0,i=r!=null&&r[e.id]!==void 0;return!s&&i?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!s&&!i}function FE(e,t,r){let s=!t||r.route.id!==t.route.id,i=e[r.route.id]===void 0;return s||i}function tN(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Wk(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Uk(e,t,r,s,i){var l;let c;if(e){let f=s[e];An(f,"No route found to patch children into: routeId = "+e),f.children||(f.children=[]),c=f.children}else c=r;let d=t.filter(f=>!c.some(v=>nN(f,v))),m=Ih(d,i,[e||"_","patch",String(((l=c)==null?void 0:l.length)||"0")],s);c.push(...m)}function nN(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,s)=>{var i;return(i=t.children)==null?void 0:i.some(l=>nN(r,l))}):!1}async function _E(e,t,r){if(!e.lazy)return;let s=await e.lazy();if(!e.lazy)return;let i=r[e.id];An(i,"No route found in manifest");let l={};for(let c in s){let m=i[c]!==void 0&&c!=="hasErrorBoundary";No(!m,'Route "'+i.id+'" has a static property "'+c+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+c+'" will be ignored.')),!m&&!aE.has(c)&&(l[c]=s[c])}Object.assign(i,l),Object.assign(i,gr({},t(i),{lazy:void 0}))}async function OE(e){let{matches:t}=e,r=t.filter(i=>i.shouldLoad);return(await Promise.all(r.map(i=>i.resolve()))).reduce((i,l,c)=>Object.assign(i,{[r[c].route.id]:l}),{})}async function BE(e,t,r,s,i,l,c,d,m,f){let v=l.map(k=>k.route.lazy?_E(k.route,m,d):void 0),g=l.map((k,y)=>{let C=v[y],T=i.some(N=>N.route.id===k.route.id);return gr({},k,{shouldLoad:T,resolve:async N=>(N&&s.method==="GET"&&(k.route.lazy||k.route.loader)&&(T=!0),T?WE(t,s,k,C,N,f):Promise.resolve({type:qn.data,result:void 0}))})}),w=await e({matches:g,request:s,params:l[0].params,fetcherKey:c,context:f});try{await Promise.all(v)}catch{}return w}async function WE(e,t,r,s,i,l){let c,d,m=f=>{let v,g=new Promise((y,C)=>v=C);d=()=>v(),t.signal.addEventListener("abort",d);let w=y=>typeof f!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+e+'" [routeId: '+r.route.id+"]"))):f({request:t,params:r.params,context:l},...y!==void 0?[y]:[]),k=(async()=>{try{return{type:"data",result:await(i?i(C=>w(C)):w())}}catch(y){return{type:"error",result:y}}})();return Promise.race([k,g])};try{let f=r.route[e];if(s)if(f){let v,[g]=await Promise.all([m(f).catch(w=>{v=w}),s]);if(v!==void 0)throw v;c=g}else if(await s,f=r.route[e],f)c=await m(f);else if(e==="action"){let v=new URL(t.url),g=v.pathname+v.search;throw Ps(405,{method:t.method,pathname:g,routeId:r.route.id})}else return{type:qn.data,result:void 0};else if(f)c=await m(f);else{let v=new URL(t.url),g=v.pathname+v.search;throw Ps(404,{pathname:g})}An(c.result!==void 0,"You defined "+(e==="action"?"an action":"a loader")+" for route "+('"'+r.route.id+"\" but didn't return anything from your `"+e+"` ")+"function. Please return a value or `null`.")}catch(f){return{type:qn.error,result:f}}finally{d&&t.signal.removeEventListener("abort",d)}return c}async function UE(e){let{result:t,type:r}=e;if(sN(t)){let g;try{let w=t.headers.get("Content-Type");w&&/\bapplication\/json\b/.test(w)?t.body==null?g=null:g=await t.json():g=await t.text()}catch(w){return{type:qn.error,error:w}}return r===qn.error?{type:qn.error,error:new Eh(t.status,t.statusText,g),statusCode:t.status,headers:t.headers}:{type:qn.data,data:g,statusCode:t.status,headers:t.headers}}if(r===qn.error){if(Kk(t)){var s,i;if(t.data instanceof Error){var l,c;return{type:qn.error,error:t.data,statusCode:(l=t.init)==null?void 0:l.status,headers:(c=t.init)!=null&&c.headers?new Headers(t.init.headers):void 0}}return{type:qn.error,error:new Eh(((s=t.init)==null?void 0:s.status)||500,void 0,t.data),statusCode:Zc(t)?t.status:void 0,headers:(i=t.init)!=null&&i.headers?new Headers(t.init.headers):void 0}}return{type:qn.error,error:t,statusCode:Zc(t)?t.status:void 0}}if(VE(t)){var d,m;return{type:qn.deferred,deferredData:t,statusCode:(d=t.init)==null?void 0:d.status,headers:((m=t.init)==null?void 0:m.headers)&&new Headers(t.init.headers)}}if(Kk(t)){var f,v;return{type:qn.data,data:t.data,statusCode:(f=t.init)==null?void 0:f.status,headers:(v=t.init)!=null&&v.headers?new Headers(t.init.headers):void 0}}return{type:qn.data,data:t}}function HE(e,t,r,s,i,l){let c=e.headers.get("Location");if(An(c,"Redirects returned/thrown from loaders/actions must have a Location header"),!$b.test(c)){let d=s.slice(0,s.findIndex(m=>m.route.id===r)+1);c=Og(new URL(t.url),d,i,!0,c,l),e.headers.set("Location",c)}return e}function Hk(e,t,r,s){let i=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if($b.test(e)){let l=e,c=l.startsWith("//")?new URL(t.protocol+l):new URL(l);if(i.includes(c.protocol))throw new Error("Invalid redirect location");let d=wu(c.pathname,r)!=null;if(c.origin===t.origin&&d)return c.pathname+c.search+c.hash}try{let l=s.createURL(e);if(i.includes(l.protocol))throw new Error("Invalid redirect location")}catch{}return e}function hl(e,t,r,s){let i=e.createURL(rN(t)).toString(),l={signal:r};if(s&&vi(s.formMethod)){let{formMethod:c,formEncType:d}=s;l.method=c.toUpperCase(),d==="application/json"?(l.headers=new Headers({"Content-Type":d}),l.body=JSON.stringify(s.json)):d==="text/plain"?l.body=s.text:d==="application/x-www-form-urlencoded"&&s.formData?l.body=Wg(s.formData):l.body=s.formData}return new Request(i,l)}function Wg(e){let t=new URLSearchParams;for(let[r,s]of e.entries())t.append(r,typeof s=="string"?s:s.name);return t}function zk(e){let t=new FormData;for(let[r,s]of e.entries())t.append(r,s);return t}function zE(e,t,r,s,i){let l={},c=null,d,m=!1,f={},v=r&&Hs(r[1])?r[1].error:void 0;return e.forEach(g=>{if(!(g.route.id in t))return;let w=g.route.id,k=t[w];if(An(!ko(k),"Cannot handle redirect results in processLoaderData"),Hs(k)){let y=k.error;v!==void 0&&(y=v,v=void 0),c=c||{};{let C=vo(e,w);c[C.route.id]==null&&(c[C.route.id]=y)}l[w]=void 0,m||(m=!0,d=Zc(k.error)?k.error.status:500),k.headers&&(f[w]=k.headers)}else Fa(k)?(s.set(w,k.deferredData),l[w]=k.deferredData.data,k.statusCode!=null&&k.statusCode!==200&&!m&&(d=k.statusCode),k.headers&&(f[w]=k.headers)):(l[w]=k.data,k.statusCode&&k.statusCode!==200&&!m&&(d=k.statusCode),k.headers&&(f[w]=k.headers))}),v!==void 0&&r&&(c={[r[0]]:v},l[r[0]]=void 0),{loaderData:l,errors:c,statusCode:d||200,loaderHeaders:f}}function qk(e,t,r,s,i,l,c){let{loaderData:d,errors:m}=zE(t,r,s,c);return i.forEach(f=>{let{key:v,match:g,controller:w}=f,k=l[v];if(An(k,"Did not find corresponding fetcher result"),!(w&&w.signal.aborted))if(Hs(k)){let y=vo(e.matches,g==null?void 0:g.route.id);m&&m[y.route.id]||(m=gr({},m,{[y.route.id]:k.error})),e.fetchers.delete(v)}else if(ko(k))An(!1,"Unhandled fetcher revalidation redirect");else if(Fa(k))An(!1,"Unhandled fetcher deferred data");else{let y=Ia(k.data);e.fetchers.set(v,y)}}),{loaderData:d,errors:m}}function $k(e,t,r,s){let i=gr({},t);for(let l of r){let c=l.route.id;if(t.hasOwnProperty(c)?t[c]!==void 0&&(i[c]=t[c]):e[c]!==void 0&&l.route.loader&&(i[c]=e[c]),s&&s.hasOwnProperty(c))break}return i}function Vk(e){return e?Hs(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function vo(e,t){return(t?e.slice(0,e.findIndex(s=>s.route.id===t)+1):[...e]).reverse().find(s=>s.route.hasErrorBoundary===!0)||e[0]}function Gk(e){let t=e.length===1?e[0]:e.find(r=>r.index||!r.path||r.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Ps(e,t){let{pathname:r,routeId:s,method:i,type:l,message:c}=t===void 0?{}:t,d="Unknown Server Error",m="Unknown @remix-run/router error";return e===400?(d="Bad Request",i&&r&&s?m="You made a "+i+' request to "'+r+'" but '+('did not provide a `loader` for route "'+s+'", ')+"so there is no way to handle the request.":l==="defer-action"?m="defer() is not supported in actions":l==="invalid-body"&&(m="Unable to encode submission body")):e===403?(d="Forbidden",m='Route "'+s+'" does not match URL "'+r+'"'):e===404?(d="Not Found",m='No route matches URL "'+r+'"'):e===405&&(d="Method Not Allowed",i&&r&&s?m="You made a "+i.toUpperCase()+' request to "'+r+'" but '+('did not provide an `action` for route "'+s+'", ')+"so there is no way to handle the request.":i&&(m='Invalid request method "'+i.toUpperCase()+'"')),new Eh(e||500,d,new Error(m),!0)}function jd(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[s,i]=t[r];if(ko(i))return{key:s,result:i}}}function rN(e){let t=typeof e=="string"?qa(e):e;return vu(gr({},t,{hash:""}))}function qE(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function $E(e){return sN(e.result)&&RE.has(e.result.status)}function Fa(e){return e.type===qn.deferred}function Hs(e){return e.type===qn.error}function ko(e){return(e&&e.type)===qn.redirect}function Kk(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function VE(e){let t=e;return t&&typeof t=="object"&&typeof t.data=="object"&&typeof t.subscribe=="function"&&typeof t.cancel=="function"&&typeof t.resolveData=="function"}function sN(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function GE(e){return DE.has(e.toLowerCase())}function vi(e){return NE.has(e.toLowerCase())}async function KE(e,t,r,s,i){let l=Object.entries(t);for(let c=0;c<l.length;c++){let[d,m]=l[c],f=e.find(w=>(w==null?void 0:w.route.id)===d);if(!f)continue;let v=s.find(w=>w.route.id===f.route.id),g=v!=null&&!tN(v,f)&&(i&&i[f.route.id])!==void 0;Fa(m)&&g&&await Vb(m,r,!1).then(w=>{w&&(t[d]=w)})}}async function YE(e,t,r){for(let s=0;s<r.length;s++){let{key:i,routeId:l,controller:c}=r[s],d=t[i];e.find(f=>(f==null?void 0:f.route.id)===l)&&Fa(d)&&(An(c,"Expected an AbortController for revalidating fetcher deferred result"),await Vb(d,c.signal,!0).then(f=>{f&&(t[i]=f)}))}}async function Vb(e,t,r){if(r===void 0&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:qn.data,data:e.deferredData.unwrappedData}}catch(i){return{type:qn.error,error:i}}return{type:qn.data,data:e.deferredData.data}}}function Gb(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function Dc(e,t){let r=typeof t=="string"?qa(t).search:t.search;if(e[e.length-1].route.index&&Gb(r||""))return e[e.length-1];let s=JT(e);return s[s.length-1]}function Yk(e){let{formMethod:t,formAction:r,formEncType:s,text:i,formData:l,json:c}=e;if(!(!t||!r||!s)){if(i!=null)return{formMethod:t,formAction:r,formEncType:s,formData:void 0,json:void 0,text:i};if(l!=null)return{formMethod:t,formAction:r,formEncType:s,formData:l,json:void 0,text:void 0};if(c!==void 0)return{formMethod:t,formAction:r,formEncType:s,formData:void 0,json:c,text:void 0}}}function af(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function XE(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function gc(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function QE(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Ia(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function JE(e,t){try{let r=e.sessionStorage.getItem(eN);if(r){let s=JSON.parse(r);for(let[i,l]of Object.entries(s||{}))l&&Array.isArray(l)&&t.set(i,new Set(l||[]))}}catch{}}function ZE(e,t){if(t.size>0){let r={};for(let[s,i]of t)r[s]=[...i];try{e.sessionStorage.setItem(eN,JSON.stringify(r))}catch(s){No(!1,"Failed to save applied view transitions in sessionStorage ("+s+").")}}}/**
|
|
52
|
+
* React Router v6.30.3
|
|
53
|
+
*
|
|
54
|
+
* Copyright (c) Remix Software Inc.
|
|
55
|
+
*
|
|
56
|
+
* This source code is licensed under the MIT license found in the
|
|
57
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
58
|
+
*
|
|
59
|
+
* @license MIT
|
|
60
|
+
*/function Lh(){return Lh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Lh.apply(this,arguments)}const om=p.createContext(null),iN=p.createContext(null),yu=p.createContext(null),Kb=p.createContext(null),da=p.createContext({outlet:null,matches:[],isDataRoute:!1}),aN=p.createContext(null);function ku(){return p.useContext(Kb)!=null}function oi(){return ku()||An(!1),p.useContext(Kb).location}function oN(e){p.useContext(yu).static||p.useLayoutEffect(e)}function vr(){let{isDataRoute:e}=p.useContext(da);return e?m1():e1()}function e1(){ku()||An(!1);let e=p.useContext(om),{basename:t,future:r,navigator:s}=p.useContext(yu),{matches:i}=p.useContext(da),{pathname:l}=oi(),c=JSON.stringify(zb(i,r.v7_relativeSplatPath)),d=p.useRef(!1);return oN(()=>{d.current=!0}),p.useCallback(function(f,v){if(v===void 0&&(v={}),!d.current)return;if(typeof f=="number"){s.go(f);return}let g=qb(f,JSON.parse(c),l,v.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:Ua([t,g.pathname])),(v.replace?s.replace:s.push)(g,v.state,v)},[t,s,c,l,e])}const t1=p.createContext(null);function n1(e){let t=p.useContext(da).outlet;return t&&p.createElement(t1.Provider,{value:e},t)}function Eo(){let{matches:e}=p.useContext(da),t=e[e.length-1];return t?t.params:{}}function r1(e,t,r,s){ku()||An(!1);let{navigator:i}=p.useContext(yu),{matches:l}=p.useContext(da),c=l[l.length-1],d=c?c.params:{};c&&c.pathname;let m=c?c.pathnameBase:"/";c&&c.route;let f=oi(),v;v=f;let g=v.pathname||"/",w=g;if(m!=="/"){let C=m.replace(/^\//,"").split("/");w="/"+g.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=bo(e,{pathname:w});return l1(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:Ua([m,i.encodeLocation?i.encodeLocation(C.pathname).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?m:Ua([m,i.encodeLocation?i.encodeLocation(C.pathnameBase).pathname:C.pathnameBase])})),l,r,s)}function s1(){let e=h1(),t=Zc(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},t),r?p.createElement("pre",{style:i},r):null,null)}const i1=p.createElement(s1,null);class a1 extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?p.createElement(da.Provider,{value:this.props.routeContext},p.createElement(aN.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function o1(e){let{routeContext:t,match:r,children:s}=e,i=p.useContext(om);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),p.createElement(da.Provider,{value:t},s)}function l1(e,t,r,s){var i;if(t===void 0&&(t=[]),r===void 0&&(r=null),s===void 0&&(s=null),e==null){var l;if(!r)return null;if(r.errors)e=r.matches;else if((l=s)!=null&&l.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let c=e,d=(i=r)==null?void 0:i.errors;if(d!=null){let v=c.findIndex(g=>g.route.id&&(d==null?void 0:d[g.route.id])!==void 0);v>=0||An(!1),c=c.slice(0,Math.min(c.length,v+1))}let m=!1,f=-1;if(r&&s&&s.v7_partialHydration)for(let v=0;v<c.length;v++){let g=c[v];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(f=v),g.route.id){let{loaderData:w,errors:k}=r,y=g.route.loader&&w[g.route.id]===void 0&&(!k||k[g.route.id]===void 0);if(g.route.lazy||y){m=!0,f>=0?c=c.slice(0,f+1):c=[c[0]];break}}}return c.reduceRight((v,g,w)=>{let k,y=!1,C=null,T=null;r&&(k=d&&g.route.id?d[g.route.id]:void 0,C=g.route.errorElement||i1,m&&(f<0&&w===0?(p1("route-fallback"),y=!0,T=null):f===w&&(y=!0,T=g.route.hydrateFallbackElement||null)));let j=t.concat(c.slice(0,w+1)),N=()=>{let D;return k?D=C:y?D=T:g.route.Component?D=p.createElement(g.route.Component,null):g.route.element?D=g.route.element:D=v,p.createElement(o1,{match:g,routeContext:{outlet:v,matches:j,isDataRoute:r!=null},children:D})};return r&&(g.route.ErrorBoundary||g.route.errorElement||w===0)?p.createElement(a1,{location:r.location,revalidation:r.revalidation,component:C,error:k,children:N(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):N()},null)}var lN=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(lN||{}),cN=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(cN||{});function c1(e){let t=p.useContext(om);return t||An(!1),t}function u1(e){let t=p.useContext(iN);return t||An(!1),t}function d1(e){let t=p.useContext(da);return t||An(!1),t}function uN(e){let t=d1(),r=t.matches[t.matches.length-1];return r.route.id||An(!1),r.route.id}function h1(){var e;let t=p.useContext(aN),r=u1(),s=uN();return t!==void 0?t:(e=r.errors)==null?void 0:e[s]}function m1(){let{router:e}=c1(lN.UseNavigateStable),t=uN(cN.UseNavigateStable),r=p.useRef(!1);return oN(()=>{r.current=!0}),p.useCallback(function(i,l){l===void 0&&(l={}),r.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,Lh({fromRouteId:t},l)))},[e,t])}const Xk={};function p1(e,t,r){Xk[e]||(Xk[e]=!0)}function f1(e,t){e==null||e.v7_startTransition,(e==null?void 0:e.v7_relativeSplatPath)===void 0&&(!t||t.v7_relativeSplatPath),t&&(t.v7_fetcherPersist,t.v7_normalizeFormMethod,t.v7_partialHydration,t.v7_skipActionErrorRevalidation)}function $a(e){let{to:t,replace:r,state:s,relative:i}=e;ku()||An(!1);let{future:l,static:c}=p.useContext(yu),{matches:d}=p.useContext(da),{pathname:m}=oi(),f=vr(),v=qb(t,zb(d,l.v7_relativeSplatPath),m,i==="path"),g=JSON.stringify(v);return p.useEffect(()=>f(JSON.parse(g),{replace:r,state:s,relative:i}),[f,g,i,r,s]),null}function Ug(e){return n1(e.context)}function g1(e){let{basename:t="/",children:r=null,location:s,navigationType:i=Ar.Pop,navigator:l,static:c=!1,future:d}=e;ku()&&An(!1);let m=t.replace(/^\/*/,"/"),f=p.useMemo(()=>({basename:m,navigator:l,static:c,future:Lh({v7_relativeSplatPath:!1},d)}),[m,d,l,c]);typeof s=="string"&&(s=qa(s));let{pathname:v="/",search:g="",hash:w="",state:k=null,key:y="default"}=s,C=p.useMemo(()=>{let T=wu(v,m);return T==null?null:{location:{pathname:T,search:g,hash:w,state:k,key:y},navigationType:i}},[m,v,g,w,k,y,i]);return C==null?null:p.createElement(yu.Provider,{value:f},p.createElement(Kb.Provider,{children:r,value:C}))}new Promise(()=>{});function b1(e){let t={hasErrorBoundary:e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&Object.assign(t,{element:p.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:p.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:p.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}/**
|
|
61
|
+
* React Router DOM v6.30.3
|
|
62
|
+
*
|
|
63
|
+
* Copyright (c) Remix Software Inc.
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the MIT license found in the
|
|
66
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
67
|
+
*
|
|
68
|
+
* @license MIT
|
|
69
|
+
*/function Fh(){return Fh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Fh.apply(this,arguments)}function Hg(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let s=e[r];return t.concat(Array.isArray(s)?s.map(i=>[r,i]):[[r,s]])},[]))}function v1(e,t){let r=Hg(e);return t&&t.forEach((s,i)=>{r.has(i)||t.getAll(i).forEach(l=>{r.append(i,l)})}),r}const w1="6";try{window.__reactRouterVersion=w1}catch{}function y1(e,t){return EE({basename:void 0,future:Fh({},void 0,{v7_prependBasename:!0}),history:rE({window:void 0}),hydrationData:k1(),routes:e,mapRouteProperties:b1,dataStrategy:void 0,patchRoutesOnNavigation:void 0,window:void 0}).initialize()}function k1(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=Fh({},t,{errors:x1(t.errors)})),t}function x1(e){if(!e)return null;let t=Object.entries(e),r={};for(let[s,i]of t)if(i&&i.__type==="RouteErrorResponse")r[s]=new Eh(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let l=window[i.__subType];if(typeof l=="function")try{let c=new l(i.message);c.stack="",r[s]=c}catch{}}if(r[s]==null){let l=new Error(i.message);l.stack="",r[s]=l}}else r[s]=i;return r}const S1=p.createContext({isTransitioning:!1}),C1=p.createContext(new Map),j1="startTransition",Qk=OA[j1],T1="flushSync",Jk=nE[T1];function N1(e){Qk?Qk(e):e()}function bc(e){Jk?Jk(e):e()}class P1{constructor(){this.status="pending",this.promise=new Promise((t,r)=>{this.resolve=s=>{this.status==="pending"&&(this.status="resolved",t(s))},this.reject=s=>{this.status==="pending"&&(this.status="rejected",r(s))}})}}function D1(e){let{fallbackElement:t,router:r,future:s}=e,[i,l]=p.useState(r.state),[c,d]=p.useState(),[m,f]=p.useState({isTransitioning:!1}),[v,g]=p.useState(),[w,k]=p.useState(),[y,C]=p.useState(),T=p.useRef(new Map),{v7_startTransition:j}=s||{},N=p.useCallback(M=>{j?N1(M):M()},[j]),D=p.useCallback((M,_)=>{let{deletedFetchers:L,flushSync:Q,viewTransitionOpts:O}=_;M.fetchers.forEach((Y,G)=>{Y.data!==void 0&&T.current.set(G,Y.data)}),L.forEach(Y=>T.current.delete(Y));let ne=r.window==null||r.window.document==null||typeof r.window.document.startViewTransition!="function";if(!O||ne){Q?bc(()=>l(M)):N(()=>l(M));return}if(Q){bc(()=>{w&&(v&&v.resolve(),w.skipTransition()),f({isTransitioning:!0,flushSync:!0,currentLocation:O.currentLocation,nextLocation:O.nextLocation})});let Y=r.window.document.startViewTransition(()=>{bc(()=>l(M))});Y.finished.finally(()=>{bc(()=>{g(void 0),k(void 0),d(void 0),f({isTransitioning:!1})})}),bc(()=>k(Y));return}w?(v&&v.resolve(),w.skipTransition(),C({state:M,currentLocation:O.currentLocation,nextLocation:O.nextLocation})):(d(M),f({isTransitioning:!0,flushSync:!1,currentLocation:O.currentLocation,nextLocation:O.nextLocation}))},[r.window,w,v,T,N]);p.useLayoutEffect(()=>r.subscribe(D),[r,D]),p.useEffect(()=>{m.isTransitioning&&!m.flushSync&&g(new P1)},[m]),p.useEffect(()=>{if(v&&c&&r.window){let M=c,_=v.promise,L=r.window.document.startViewTransition(async()=>{N(()=>l(M)),await _});L.finished.finally(()=>{g(void 0),k(void 0),d(void 0),f({isTransitioning:!1})}),k(L)}},[N,c,v,r.window]),p.useEffect(()=>{v&&c&&i.location.key===c.location.key&&v.resolve()},[v,w,i.location,c]),p.useEffect(()=>{!m.isTransitioning&&y&&(d(y.state),f({isTransitioning:!0,flushSync:!1,currentLocation:y.currentLocation,nextLocation:y.nextLocation}),C(void 0))},[m.isTransitioning,y]),p.useEffect(()=>{},[]);let F=p.useMemo(()=>({createHref:r.createHref,encodeLocation:r.encodeLocation,go:M=>r.navigate(M),push:(M,_,L)=>r.navigate(M,{state:_,preventScrollReset:L==null?void 0:L.preventScrollReset}),replace:(M,_,L)=>r.navigate(M,{replace:!0,state:_,preventScrollReset:L==null?void 0:L.preventScrollReset})}),[r]),W=r.basename||"/",E=p.useMemo(()=>({router:r,navigator:F,static:!1,basename:W}),[r,F,W]),I=p.useMemo(()=>({v7_relativeSplatPath:r.future.v7_relativeSplatPath}),[r.future.v7_relativeSplatPath]);return p.useEffect(()=>f1(s,r.future),[s,r.future]),p.createElement(p.Fragment,null,p.createElement(om.Provider,{value:E},p.createElement(iN.Provider,{value:i},p.createElement(C1.Provider,{value:T.current},p.createElement(S1.Provider,{value:m},p.createElement(g1,{basename:W,location:i.location,navigationType:i.historyAction,navigator:F,future:I},i.initialized||r.future.v7_partialHydration?p.createElement(R1,{routes:r.routes,future:r.future,state:i}):t))))),null)}const R1=p.memo(M1);function M1(e){let{routes:t,future:r,state:s}=e;return r1(t,void 0,s,r)}var Zk;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Zk||(Zk={}));var ex;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(ex||(ex={}));function A1(e){let t=p.useRef(Hg(e)),r=p.useRef(!1),s=oi(),i=p.useMemo(()=>v1(s.search,r.current?null:t.current),[s.search]),l=vr(),c=p.useCallback((d,m)=>{const f=Hg(typeof d=="function"?d(i):d);r.current=!0,l("?"+f,m)},[l,i]);return[i,c]}const I1="modulepreload",E1=function(e){return"/"+e},tx={},Ml=function(t,r,s){let i=Promise.resolve();if(r&&r.length>0){let c=function(f){return Promise.all(f.map(v=>Promise.resolve(v).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));i=c(r.map(f=>{if(f=E1(f),f in tx)return;tx[f]=!0;const v=f.endsWith(".css"),g=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const w=document.createElement("link");if(w.rel=v?"stylesheet":I1,v||(w.as="script"),w.crossOrigin="",w.href=f,m&&w.setAttribute("nonce",m),document.head.appendChild(w),v)return new Promise((k,y)=>{w.addEventListener("load",k),w.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return i.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})},L1="desktop://window-lifecycle",dN=p.createContext(null),F1=["--desktop-macos-traffic-light-center-y","--desktop-macos-traffic-light-leading-inset","--desktop-macos-traffic-light-safe-zone-width","--desktop-macos-titlebar-height","--desktop-macos-traffic-light-button-diameter"];function _1(e){if(typeof document>"u")return;const{documentElement:t,body:r}=document;t.dataset.runtimePlatform=e.platform,t.dataset.osFamily=e.ui.osFamily,t.dataset.windowControls=e.ui.windowControlsStyle,t.dataset.viewportClass=e.viewportClass,t.dataset.overlayTitlebar=String(e.ui.prefersOverlayTitlebar),r&&(r.dataset.runtimePlatform=e.platform,r.dataset.osFamily=e.ui.osFamily,r.dataset.windowControls=e.ui.windowControlsStyle,r.dataset.viewportClass=e.viewportClass,r.dataset.overlayTitlebar=String(e.ui.prefersOverlayTitlebar))}function zg(){var e;if(!(typeof document>"u"))for(const t of F1)document.documentElement.style.removeProperty(t),(e=document.body)==null||e.style.removeProperty(t)}function O1(e){if(typeof document>"u")return;if(!e){zg();return}const t=[document.documentElement,document.body].filter(s=>!!s),r=[["--desktop-macos-traffic-light-center-y",`${e.trafficLightCenterY}px`],["--desktop-macos-traffic-light-leading-inset",`${e.trafficLightLeadingInset}px`],["--desktop-macos-traffic-light-safe-zone-width",`${e.trafficLightSafeZoneWidth}px`],["--desktop-macos-titlebar-height",`${e.titlebarHeight}px`],["--desktop-macos-traffic-light-button-diameter",`${e.trafficLightButtonDiameter}px`]];for(const s of t)for(const[i,l]of r)s.style.setProperty(i,l)}function B1(){if(!(typeof window>"u"))return window.innerWidth}function W1({children:e}){const[t,r]=p.useState(()=>B1()),s=p.useMemo(()=>$s({viewportWidth:t}),[t]);return p.useEffect(()=>{if(typeof window>"u")return;function i(){r(window.innerWidth)}return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},[]),p.useEffect(()=>{_1(s)},[s]),p.useEffect(()=>()=>{zg()},[]),p.useEffect(()=>{let i=!1,l=null;return!s.isDesktop||!s.bridge.supported?()=>{i=!0}:(Ml(()=>Promise.resolve().then(()=>hF),void 0).then(async({listen:c})=>{const d=await c(L1,m=>{const f=m.payload,v=f==null?void 0:f.descriptor;v!=null&&v.windowId&&(s.windows.registerDescriptor(v),f.isOpen?s.windows.markWindowOpen(v.windowId):s.windows.markWindowClosed(v.windowId))});if(i){d();return}l=d}).catch(()=>{}),()=>{i=!0,l==null||l()})},[s]),p.useEffect(()=>{let i=!1,l=null;async function c(){var m,f;const d=await s.bridge.getRuntimeInfo();i||O1(d.ok?(f=(m=d.value)==null?void 0:m.windowChrome)==null?void 0:f.macosTitlebar:null)}return!s.isDesktop||s.ui.osFamily!=="macos"||!s.ui.prefersOverlayTitlebar?(zg(),()=>{i=!0}):(c(),Ml(()=>Promise.resolve().then(()=>vF),void 0).then(async({getCurrentWindow:d})=>{const m=await d().onScaleChanged(()=>{c()});if(i){m();return}l=m}).catch(()=>{}),()=>{i=!0,l==null||l()})},[s]),n.jsx(dN.Provider,{value:s,children:e})}function nr(){return p.useContext(dN)??$s()}const U1={common:{appName:"CodingNS",loading:"Loading...",retry:"Retry",back:"Back",save:"Save",logout:"Log out",unknown:"Unknown session",close:"Close",cancel:"Cancel",language:"Language"},auth:{loginTitle:"Resume your coding session",loginSubtitle:"INITIALIZING DEVELOPMENT ENVIRONMENT...",serverPreset:"Server Preset",serverCustomOption:"Use custom server",serverAddress:"Server Address",serverPlaceholder:"For example: http://127.0.0.1:3002",serverHint:"Login, realtime messages, and terminals all connect through this host. Point the client at the Host API endpoint such as http://127.0.0.1:3002; frontend dev ports like 4174 or 5173 are not meant for packaged clients and only work for temporary debugging when proxying and CORS are configured correctly.",serverInvalid:"Invalid server address. Check it and try again.",serverCurrent:"Current Server",bootstrapTitle:"Complete the first-time bootstrap",bootstrapSubtitle:"This Host does not have an admin account yet. Create the minimal login entry first.",username:"Username",password:"Password",rememberPassword:"Remember Password",confirmPassword:"Confirm Password",submitLogin:"Enter Workspace",submitBootstrap:"Create Admin Account",bootstrapSuccess:"Bootstrap completed. You can log in now.",bootstrapMismatch:"The two passwords do not match.",authUnavailable:"Host is unreachable right now. Check the server and try again.",logoutSuccess:"The current login state has been cleared.",demoBanner:"Demo environment — all account data is public and cleared on logout",demoSessionExpired:"Demo session expired. Please log in again.",captcha:"Captcha",captchaPlaceholder:"Enter the characters in the image",captchaHint:"After three failed attempts, complete the captcha before trying again.",captchaImageAlt:"Login captcha image",serverSettings:"Server Settings",serverSettingsTitle:"Server Configuration",saveServerSettings:"Save Settings"},settings:{title:"Settings",appearance:"Appearance",appearanceSectionSummary:"Language, theme, and interface colors",language:"Language",languageDescription:"Choose the display language used by the interface.",theme:"Theme",themeDescription:"Choose the color theme that fits the way you work.",autoTheme:"Follow system theme automatically",autoThemeDescription:"When enabled, switch between day and night mode based on the system or browser color scheme.",fileManager:"File Manager",workspaceSessionSortMode:"Workspace session sort order",workspaceSessionSortModeDescription:"Controls the default sort order for session lists across the workspace. This setting only applies to the current device.",sessionSortModeCreatedAt:"By session created time",sessionSortModeUpdatedAt:"By session updated time",sessionSortModeTitle:"By session name",showSystemFiles:"Show system files",showSystemFilesDescription:"Display common macOS and Windows system files in the file manager, such as .DS_Store and Thumbs.db. This setting only applies to the current device.",serverConnection:"Server Connection",serverConnectionSectionSummary:"Server address and reconnection behavior",remoteAccess:"Remote Access",remoteAccessSectionSummary:"Check status and manage Tailscale remote access.",modelManagement:"Model Management",modelManagementSectionSummary:"Read cc-switch presets and quickly switch models for Codex, Claude Code, Gemini, and OpenCode.",modelManagementNavValue:"Quick switch",modelManagementTitle:"Quick Model Switching",modelManagementDescription:"This page does not add or edit presets. It only exposes the presets already managed by cc-switch so you can switch quickly.",modelManagementRefresh:"Refresh Models",modelManagementRefreshSuccess:"Model presets refreshed.",modelManagementLoadFailed:"Failed to load model presets.",modelManagementScannedAt:"Last Scanned",modelManagementScannedAtUnknown:"Not scanned yet",modelManagementCurrentProfile:"Current Profile",modelManagementCurrentModel:"Current Model",modelManagementCurrentPreset:"Current Preset",modelManagementModelUnknown:"Unknown",modelManagementPresetMissing:"Not set",modelManagementCurrentTag:"Current",modelManagementOpenSwitcher:"Switch Profile",modelManagementModalTitle:"Provider Profile Switching",modelManagementModalDescription:"Review the existing cc-switch profiles by app and switch the active one here.",modelManagementTabsLabel:"Model app tabs",modelManagementSwitchAction:"Switch",modelManagementSwitchSuccess:"{app} switched to {preset}.",modelManagementOptionsEmpty:"No switchable presets were found.",modelManagementStatusReady:"Ready",modelManagementStatusUnconfigured:"Unconfigured",modelManagementStatusUnavailable:"CLI unavailable",modelManagementStatusError:"Read failed",skills:"Skills",skillsSectionSummary:"Read and sync the local skills owned by each CLI. No marketplace and no remote catalog in this phase.",skillsNavValue:"Local sync",skillManagerTitle:"Local Skill Management",skillManagerDescription:"Read the local skill folders used by Codex, Claude Code, Gemini, and OpenCode, then import unmanaged entries or sync them again.",skillSummaryManagedSkills:"Managed skills",skillSummaryManagedEntries:"Managed folders",skillSummaryUnmanagedEntries:"Unmanaged folders",skillSummaryConflictedEntries:"Conflicts",skillSummaryDiagnostics:"Diagnostics",skillManageAction:"Configure Skills",skillConfigModalTitle:"Skill Configuration",skillConfigModalDescription:"Review managed, unmanaged, conflicted, and diagnostic results here, then import or sync as needed.",skillRefresh:"Refresh Overview",skillRefreshSuccess:"Skill overview refreshed.",skillScannedAt:"Last Scanned",skillManagedListTitle:"Managed Skills",skillManagedEmpty:"There are no managed skills yet.",skillUnmanagedListTitle:"Unmanaged Skills",skillUnmanagedEmpty:"No unmanaged skills were found.",skillConflictedListTitle:"Conflicts",skillConflictedEmpty:"No conflicted entries were found.",skillDiagnosticsTitle:"Diagnostics",skillDiagnosticsEmpty:"No extra diagnostics right now.",skillDirectoryName:"Directory Name",skillSsotPath:"SSOT Path",skillSourceCli:"Source CLI",skillDirectoryPath:"Directory Path",skillImportAction:"Import & Manage",skillImportSuccess:"{name} was imported and is now managed from {target}.",skillSyncAction:"Sync Again",skillSyncSuccess:"{name} was synced again.",skillSyncTargetMissing:"This skill is not bound to any target CLI yet, so it cannot be synced again.",skillLoadFailed:"Failed to load the skill overview.",skillTargetCodex:"Codex",skillTargetClaudeCode:"Claude Code",skillTargetGemini:"Gemini",skillTargetOpenCode:"OpenCode",skillBindingPending:"Pending",skillBindingSynced:"Synced",skillBindingFailed:"Failed",skillBindingConflicted:"Conflicted",securityPrivacy:"Security & Privacy",securityPrivacySectionSummary:"Session permissions, risk boundaries, and default approval policy",softwareUpdate:"Software Update",softwareUpdateSectionSummary:"Server and client versions",serverAddress:"Server Address",serverDescription:"Login, API requests, and realtime connections all use this Host entry, while the frontend UI is bundled inside the client itself.",tailscaleBrand:"Tailscale",tailscaleSectionTitle:"Tailscale Access",tailscaleSectionDescription:"Let this Host stay reachable across your devices with Tailscale.",tailscaleCurrentState:"Current State",tailscaleSwitchLabel:"Enabled",tailscaleStatusIndicator:"Status",tailscaleServerAddress:"Server Address",tailscaleAccountName:"Account",tailscaleIpAddress:"IP Address",tailscaleConfigure:"Configure",tailscaleConfigModalTitle:"Configure Tailscale",tailscaleConfigModalDescription:"Edit connectivity settings",tailscaleControlServer:"Control Server",tailscaleControlServerDescription:"Leave empty to use the default control server.",tailscaleControlServerPlaceholder:"Leave empty to use the default control server",tailscaleHostname:"Hostname",tailscaleHostnameDescription:"Optional.",tailscaleHostnamePlaceholder:"For example: codingns-host",tailscaleReachableBaseUrl:"Reachable Base URL",tailscaleTailnetFqdn:"Tailnet FQDN",tailscaleTailnetIpv4:"Tailnet IPv4",tailscaleTailnetIpv6:"Tailnet IPv6",tailscaleDetailAddresses:"Detailed Addresses",tailscaleRefresh:"Refresh",tailscaleInstallAction:"Install Tailscale",tailscaleInstallOpenFailed:"Failed to open the Tailscale install page.",tailscaleEnable:"Enable Tailscale",tailscaleDisable:"Disable Tailscale",tailscaleLogin:"Bind Account",tailscaleLogout:"Unbind Account",tailscaleUnavailable:"Unavailable",tailscaleLoadFailed:"Failed to load Tailscale status.",tailscalePhaseDisabled:"Disabled",tailscalePhaseBlockedUninitialized:"Blocked until bootstrap finishes",tailscalePhaseStarting:"Starting",tailscalePhaseNeedsLogin:"Waiting for login",tailscalePhaseRunning:"Running",tailscalePhaseStopping:"Stopping",tailscalePhaseError:"Error",tailscaleOverviewDisabled:"Remote access is not enabled yet.",tailscaleOverviewBlockedUninitialized:"Finish bootstrap before enabling remote access.",tailscaleOverviewStarting:"Connecting to Tailscale. Please wait.",tailscaleOverviewNeedsLogin:"Tailscale is enabled, but account binding is still required.",tailscaleOverviewRunning:"This instance is reachable through Tailscale now.",tailscaleOverviewStopping:"Remote access is being turned off.",tailscaleOverviewError:"Remote access hit an error. Refresh or reconfigure it first.",releaseChannel:"Release Channel",releaseChannelDescription:"Stable or beta",releaseStable:"Stable",releaseBeta:"Beta",autoReconnect:"Auto Reconnect",autoReconnectDescription:"Retry HTTP and WebSocket links automatically when Host is briefly unavailable.",autoCheckUpdate:"Auto Check Client Updates",autoCheckUpdateDescription:"Clients only",defaultPermissionMode:"Default Session Permissions",defaultPermissionModeDescription:"Controls the default tool permissions for new and resumed sessions. Full access disables approval prompts and should only be used for trusted projects and environments.",permissionModeDefault:"Follow CLI defaults",permissionModeAcceptEdits:"Allow workspace edits without asking",permissionModeBypassPermissions:"Full access without asking",enabled:"Enabled",disabled:"Disabled",serverUpdate:"Server Update",serverUpdateDescription:"",clientUpdate:"Client Update",clientUpdateDescription:"",serverCurrentVersion:"Server Current Version",serverTargetVersion:"Server Target Version",serverPackageName:"npm Package",serverUpdateCommand:"Upgrade Command",serverCheckNow:"Check Server",serverOpenPage:"Open npm",serverLatestUnknown:"Unavailable",serverUpdateReady:"New version found",serverUpToDate:"Up to date",serverCheckFailed:"Check failed",serverOpenPageFailed:"Failed to open page",releaseCurrentVersion:"Current Version",releaseTargetVersion:"Target Version",releaseTargetTag:"Target Tag",releasePublishedAt:"Published At",releaseUnknownVersion:"Unknown",releaseNotes:"What's New",releaseNotesEmpty:"No details",releaseCheckNow:"Check Client",releaseInstallNow:"Install",releaseOpenPage:"Open Release",releaseRollback:"Rollback",releaseUpdateReady:"New version found",releaseUpToDate:"Up to date",releaseCheckFailed:"Check failed",releaseInstallerMissing:"A new version is available, but this release does not include a supported installer yet.",releaseSignatureMissing:"A new version is available, but this release does not provide checksum information yet.",releaseInstallStarted:"Install started",releaseInstallFailed:"Install failed",releasePageOpenFailed:"Failed to open page",androidInstallerStarted:"Handed off to the Android installer. You can still cancel there.",androidInstallPermissionRequired:"Allow installs from this source before retrying.",androidInstallCancelled:"Install was cancelled or not completed. You can try again.",androidInstallSucceeded:"The new version has been detected as installed.",releaseRollbackStarted:"Rollback started",releaseRollbackFailed:"Rollback failed",clientUpdateUnsupported:"Install updates are not supported here",logout:"Log out"},home:{title:"Continue from a session, not from a backend table",subtitle:"Pick a workspace and session here first. The real work starts in the next step.",terminalsEntry:"Open Terminal",workspaceSection:"Workspaces",sessionSection:"Recent Sessions",emptyWorkspaces:"No workspace has been imported yet. Import one on the Host side first, and the entry will appear here.",emptySessions:"There is no session to continue in the current workspace yet.",noActivity:"No activity yet"},terminal:{title:"Terminal",heroTitle:"Keep the real PTY on Host, keep the control surface in the workspace",heroSubtitle:"This page does not fake output and does not mix terminal with process management. It only consumes the real terminal stream managed by Host.",workspaceSection:"Workspace & Terminal",workspaceField:"Current Workspace",shellField:"Shell for New Terminal",runtimeField:"Runtime",runtimeAutoOption:"Auto",runtimeAutoShortLabel:"auto",runtimeAutoDescription:"Use the Host default policy for this terminal runtime.",runtimePersistentLabel:"Persistent Session",runtimePersistentShortLabel:"persist",runtimeTmuxDescription:"Use a persistent external session, ideal for development terminals that should stay alive.",runtimeWindowsPersistentDescription:"Use a Windows persistent session backed by ConPTY so the shell can survive Host restarts.",runtimeEmbeddedDescription:"Managed directly by the current Host and useful as the lightweight fallback.",runtimeConptyPowerShellLabel:"PowerShell Persistent",runtimeConptyCmdLabel:"CMD Persistent",runtimeConptyGitBashLabel:"Git Bash Persistent",runtimeMissingDialogTitle:"tmux is not installed on this system",runtimeMissingDialogDescription:"The tmux runtime cannot create a persistent terminal right now. Install tmux first, or temporarily switch to embedded-pty to continue.",runtimeMissingInstallDescription:"Installing tmux is recommended if you want terminals to survive Host restarts.",runtimeMissingInstallMacArm:"macOS (Apple Silicon / Homebrew): arch -arm64 brew install tmux",runtimeMissingInstallMacIntel:"macOS (Intel Mac / Homebrew): brew install tmux",runtimeMissingInstallDebian:"Ubuntu / Debian: sudo apt install tmux",runtimeMissingInstallFedora:"Fedora: sudo dnf install tmux",runtimeMissingFallbackDescription:"If you switch to embedded-pty now, the terminal can still start, but it will not stay as an external persistent session.",runtimeMissingKeepAction:"Not now",runtimeMissingFallbackAction:"Switch to embedded-pty",runtimeMissingFallbackPending:"Switching...",shellUnavailable:"Unavailable",workspaceLoadFailed:"The workspace or terminal list is not available right now.",terminalSection:"Terminal Instances",templateSection:"Command Templates",stageEmptyTitle:"No terminal selected yet",stageEmptySubtitle:"Create a terminal first, or run a command template.",emptyTerminals:"There is no terminal instance in the current workspace yet.",emptyTemplates:"There is no command template in the current workspace yet.",createButton:"Create Terminal",creating:"Creating terminal...",creationPendingDescription:"Host is starting the real PTY. This pane will take over as soon as the stream is ready.",defaultTerminalName:"Workspace Terminal",created:"The terminal has been created and connected to Host.",createFailed:"Failed to create terminal.",closeButton:"Close Terminal",closing:"Closing terminal...",closed:"The terminal close request has been submitted.",closeCompleted:"Terminal closed.",closePendingDescription:"The close request has been sent to Host. The page stays responsive and keeps syncing the final result in the background.",closeSyncDelayed:"Host is still finishing the close in the background. The list will keep syncing on the next refresh.",closeFailed:"Failed to close terminal.",inputLabel:"Send command to current terminal",inputPlaceholder:"For example: npm test",sendButton:"Send to Terminal",inputFailed:"Failed to send terminal input.",outputEmpty:"The terminal is connected, but there is no output yet.",outputTruncated:"Some output exceeded the cache window while disconnected. Only the retained part has been restored.",connectedHint:"Current output is coming from the real PTY stream on Host.",moreActions:"Terminal Actions",duplicateAction:"Duplicate Tab",duplicateSuccess:"A new terminal tab has been created with the same setup.",duplicateFailed:"Failed to duplicate the terminal tab.",disconnectAction:"Disconnect",disconnected:"Terminal connection has been disconnected.",reconnectAction:"Reconnect",reconnectRequested:"Reconnect request sent.",deleteAction:"Delete",deleting:"Deleting terminal...",deleted:"Terminal record deleted.",deletePendingDescription:"The delete request has been sent to Host. The page stays responsive and keeps syncing the list in the background.",deleteSyncDelayed:"Host is still finishing the delete in the background. The list will keep syncing on the next refresh.",deleteFailed:"Failed to delete the terminal record.",closePendingBadge:"Closing",deletePendingBadge:"Deleting",pinAction:"Pin",unpinAction:"Unpin",zoomLabel:"Terminal Zoom",zoomInAction:"Zoom in terminal display",zoomOutAction:"Zoom out terminal display",zoomResetAction:"Reset terminal zoom",toolbarToggleAction:"Open terminal toolbar",mobileSwipeHint:"Swipe left or right to switch terminals",mobileSwipePosition:"{current} / {total}",mobileDrawerAction:"Open quick terminal list",mobileDrawerTitle:"Quick Terminals",mobileDrawerDescription:"Swipe right to reveal the list, then tap to jump to another terminal.",mobilePinnedSectionTitle:"Pinned Terminals",mobileDrawerEmptyTitle:"No terminals yet",mobileDrawerEmptyDescription:"Create one first and the quick switcher will appear here.",mobileCreateSheetTitle:"Create Terminal",mobileCreateShellLabel:"Terminal Type",mobileCreateShellDescription:"Pick the shell for this terminal instead of squeezing desktop dropdowns onto mobile.",mobileCreateRuntimeLabel:"Session Type",mobileCreateRuntimeDescription:"Choose whether this terminal should stay persistent or only live in the current runtime.",mobileCreateLoadingShells:"Loading available terminal types for this system...",mobileCreateConfirm:"Create this terminal",createDialogTitle:"Create Terminal",createDialogShellDescription:"Choose the shell for this terminal before creation. On Windows we should not silently fall back to CMD anymore.",createDialogRuntimeDescription:"Choose whether this terminal should stay persistent or only live in the current runtime.",createDialogConfirm:"Create Terminal",mobileRuntimePersistentTitle:"Persistent Session",mobileRuntimePersistentDescription:"Best for development terminals that should stay alive and reconnect as a recoverable session.",mobileRuntimeSessionTitle:"runtime (current session)",mobileRuntimeSessionDescription:"Managed directly by the current Host. Lighter, but not an external persistent session.",mobileWorkspaceSwitcherPlaceholder:"Choose Workspace",mobileEmptyTitle:"No terminal content yet",mobileEmptyDescription:"Create a terminal first, or swipe right to open the quick list and switch to an existing one.",layoutLabel:"Layout",layoutSingleAction:"Single pane",layoutVerticalAction:"Split left and right",layoutHorizontalAction:"Split top and bottom",saveLogAction:"Save Log",saveLogSuccess:"The terminal log has been saved.",saveLogFailed:"Failed to save the terminal log.",logEmpty:"There is no terminal log to save yet.",bindToPaneAction:"Bind to current pane",bindToPrimaryPaneAction:"Bind to main pane",bindToSecondaryPaneAction:"Bind to side pane",panePrimary:"Main Pane",paneSecondary:"Side Pane",splitEmptySubtitle:"Pick a tab or create a terminal first, then bind it to this pane.",statusBadge:{creating:"starting",running:"running",closed:"closed",error:"error"},recoveryComplete:"Recovered to the terminal from before refresh. Key cached output has been restored.",recoveryTruncated:"Recovered to the previous terminal, but some disconnected output exceeded the cache window.",recoveryIdleClosed:"The previous terminal was auto-closed by Host after being idle too long. You are seeing the output kept before close.",reconnect:"Reconnect",liveConnected:"Live stream connected",templateName:"Template Name",templateCommand:"Main Command",templateArgs:"Arguments (space separated)",templateCreateButton:"Save Template",templateCreated:"The command template has been saved.",templateCreateFailed:"Failed to save the command template.",templateRunSent:"The command template has been sent to the current terminal.",templateRunCreatedTerminal:"The command template started in a new terminal.",templateRunFailed:"Failed to run the command template.",connection:{connected:"Connected",reconnecting:"Reconnecting",reconnect_failed:"Reconnect failed",closed:"Closed"}},conversation:{titleFallback:"Continue Conversation",historyLoading:"Loading message history from Host...",historyLoadingOlder:"Loading older messages...",historyLoadFailed:"Message history is not available right now. Try again later.",timelineEmpty:"There are no messages in this session yet. Your first message will go straight into the Host chain.",turnAbortedUser:"The previous turn was stopped by you.",turnAbortedUnexpected:"The previous turn was interrupted unexpectedly and did not finish cleanly.",turnAbortedGeneric:"The previous turn was interrupted before it finished cleanly.",scrollToBottomAction:"Jump to bottom",rawRefLabel:"Source",copyAction:"Copy",copyContentSuccess:"Content copied.",copyContentFailed:"Failed to copy the content.",selectionTodoAction:"Todo",selectionActionButton:"Action",selectionActionSubmit:"Open action child session",selectionActionPromptLabel:"What should it do",selectionActionPromptPlaceholder:"For example: explain this, turn it into notes, or send it to a specific API",selectionActionIncludeContext:"Include current context",selectionActionContextUnavailable:"This selection spans multiple messages, so context inheritance is disabled for safety.",selectionActionDefaultPrompt:"Please process this content.",selectionActionQuotedLabel:"Selected text",selectionActionFailed:"Failed to create the action child session.",actionSessionBadge:"Action",actionInheritedSelectionSummary:'Collapsed the selected text from "{parentTitle}" by default.',forkFromHereAction:"Fork from here",forkingAction:"Forking...",forkMessageSucceeded:"Created a new branch from this message.",forkMessageFailed:"Failed to fork from this message.",forkDraftLabel:"Fork Quote",forkDraftEmpty:"This message does not contain text to quote.",forkDraftClear:"Cancel this fork quote",forkTargetProviderLabel:"Target CLI",forkTargetModelLabel:"Target Model",forkTargetSummary:"Source CLI: {sourceProvider} · Target CLI: {targetProvider}",forkInlineModelLoading:"Loading model options...",forkInlineNativeHint:"Stay on the same CLI and use native fork.",forkInlineCrossHint:"Switched to another CLI. The child session will be reconstructed from text history.",forkSwitchConfirmTitle:"Switch to another CLI?",forkSwitchConfirmDescription:"Using the same CLI keeps the native fork experience. Switching CLI changes this into a cross-provider fork.",forkSwitchConfirmKeepTitle:"Will keep",forkSwitchConfirmKeepBody:"User messages and assistant text before the fork point.",forkSwitchConfirmConvertTitle:"Will convert",forkSwitchConfirmConvertBody:"Reusable text history will be rebuilt into the new CLI session.",forkSwitchConfirmDropTitle:"Will lose",forkSwitchConfirmDropBody:"Tool calls, permission prompts, attachments, and running state.",forkSwitchConfirmAction:"Confirm switch",forkSwitchKeepNative:"Keep native",forkProviderNativeUnsupported:"This provider does not support native fork yet",forkProviderReconstructedUnsupported:"This provider cannot be used as a cross-provider fork target yet",loadMore:"Load More",composerPlaceholder:"State the next step clearly. Let the rest continue inside this session.",sendButton:"Send Message",queueTitle:"Queued Messages",queueDescription:"After the current run finishes, these messages will be processed automatically in order.",queueOrderPrefix:"Queue Position",queueStatusQueued:"Queued",queueStatusFailed:"Dispatch Failed",queueDelete:"Delete",queueDeleting:"Deleting",queueImageOnly:"Image attachments only",sendGuidanceButton:"Add Guidance",queueGuidanceButton:"Queue Guidance",queueSteer:"Steer",queueSteering:"Steering",resendButton:"Resend",quickPhraseTrigger:"Quick Phrases",quickPhraseModalTitle:"Quick Phrases",quickPhraseModalDescription:"Keep the prompts you reuse often in one place and drop them straight into the current composer.",quickPhraseCreateLabel:"New Phrase",quickPhraseOpenCreateAction:"Add Phrase",quickPhraseCreateModalTitle:"Create Quick Phrase",quickPhraseCreateModalDescription:"Save a reusable prompt on its own so it is ready across devices whenever you need it.",quickPhraseCreatePlaceholder:"Write a phrase you want to reuse later.",quickPhraseCreateAction:"Add Phrase",quickPhraseListLabel:"Quick phrase list",quickPhraseEmpty:"There are no quick phrases yet. Add the first one you actually reuse.",quickPhraseOrderLabel:"Item {index}",quickPhraseMoveUp:"Move phrase up",quickPhraseMoveDown:"Move phrase down",quickPhraseDelete:"Delete phrase",quickPhraseSaveFailed:"Failed to save quick phrases. Try again later.",sendingState:"Sending",sentState:"Synced",failedState:"Send failed",contextUsageTitle:"Context Usage",contextUsageUnavailable:"Context usage is not available yet",contextUsageEstimated:"Window is estimated",contextUsageCachedTokens:"{count} cached",contextUsageSourceProviderLog:"window from provider log",contextUsageSourceProviderRuntime:"window from provider runtime",contextUsageSourceProviderConfig:"window from provider config",contextUsageSourceModelMap:"window from model map",headerWorkspace:"Workspace",headerProvider:"Provider",headerCapability:"Capability Summary",connectionConnected:"Connected",connectionReconnecting:"Reconnecting",connectionReconnectFailed:"Reconnect failed",connectionClosed:"Connection closed",runtimeErrorTitle:"Session run failed",permissionRequestSectionTitle:"Pending approvals",permissionRequestSectionDescription:"Provider-side approvals are unified here so you do not need to learn three different dialogs.",permissionRequestToastTitle:"Approval needed",permissionRequestReplyFailed:"Failed to reply to the approval request.",permissionRequestSubmitting:"Submitting...",permissionRequestReasonLabel:"Reason",permissionRequestCommandLabel:"Command",permissionRequestToolLabel:"Tool",permissionRequestCwdLabel:"Working directory",permissionRequestPathsLabel:"Related paths",permissionRequestPermissionsLabel:"Requested permissions",permissionRequestReadLabel:"Read",permissionRequestWriteLabel:"Write",permissionRequestNetworkLabel:"Network",permissionRequestQuestionsLabel:"Questions",permissionRequestDetailLabel:"Details",permissionRequestEmpty:"None",permissionRequestUnknown:"Unknown",permissionRequestKindCommand:"Command",permissionRequestKindFileChange:"File Change",permissionRequestKindPermissions:"Permissions",permissionRequestKindUserInput:"User Input",permissionRequestKindToolCall:"Tool Call",reconnectExplain:"The realtime link is broken. The system is replaying missing messages.",reconnectFailedExplain:"Automatic recovery failed. Retry manually, or reopen the session later.",capabilityDenied:"This action is not supported in the current session.",capabilitySendDisabled:"The current provider does not support sending new messages.",capabilityAttachmentDisabled:"This session does not support attachment input yet.",capabilityInterruptDisabled:"This session does not support interruption.",sidebarTitle:"Current Session Context",sidebarSubtitle:"This sidebar only keeps the minimum capability summary. It does not turn the page into an admin console.",reconnectButton:"Restore Realtime Sync",headerResumedAt:"Last Resumed",headerLastSyncAt:"Last Synced",historyPages:"History Pages",syncStatusIdle:"Sync Idle",syncStatusSyncing:"Syncing",syncStatusError:"Sync Error",capabilityResume:"Resumable",capabilitySend:"Send Enabled",capabilityInterrupt:"Interrupt Enabled",capabilityTools:"Tool Calls",attachmentsLabel:"Attachments",filePanelTitle:"File Manager",filePanelSubtitle:"File capabilities here only serve the current session. This is not a heavy IDE shell.",filePanelNoWorkspace:"There is no selected workspace yet. Browsing or attaching files is unavailable.",filePanelRefresh:"Refresh",filePanelCopyPath:"Copy Path",filePanelCopyAbsolutePath:"Copy Absolute Path",filePanelCopyRelativePath:"Copy Relative Path",filePanelCopyAbsolutePathSuccess:"Absolute path copied.",filePanelCopyRelativePathSuccess:"Relative path copied.",filePanelCopyPathFailed:"Failed to copy the path.",filePanelCopy:"Copy",filePanelCut:"Cut",filePanelPaste:"Paste",filePanelCopySelectionSuccess:"{count} item(s) copied. Paste them into a target folder.",filePanelCutSelectionSuccess:"{count} item(s) cut. Paste them into a target folder.",filePanelPasteSuccess:"{count} item(s) pasted.",filePanelPasteFailed:"Paste failed. Check the target folder and name conflicts.",filePanelSelectionCount:"{count} item(s) selected",filePanelClipboardCopyReady:"{count} item(s) ready to copy",filePanelClipboardCutReady:"{count} item(s) ready to move",filePanelOpenFile:"Open File",filePanelExpandDirectory:"Expand Folder",filePanelCollapseDirectory:"Collapse Folder",filePanelActionsMenu:"File Actions",filePanelSearchPlaceholder:"Enter a file name or path fragment",filePanelSearchButton:"Search",filePanelShowSearch:"Open Search",filePanelHideSearch:"Hide Search",filePanelSearchEmpty:"No matching files found.",filePanelSearchResults:"Search Results",filePanelSearchFailed:"File search failed. Try again later.",filePanelBrowse:"Workspace Files",filePanelCollapseCurrent:"Collapse Current",filePanelCollapseAll:"Collapse All",filePanelBackDirectory:"Go to Parent",filePanelEmptyDirectory:"There are no files to show in this directory.",filePanelRecentTitle:"Recently Opened",filePanelEmptyRecent:"There is no recently opened file yet.",filePanelContextTitle:"Attached Files",filePanelEmptyContexts:"No file is attached to the current session yet.",filePanelEditorTitle:"Preview & Editor",filePanelEditorPlaceholder:"This is a lightweight text editor, not a full IDE.",filePanelSelectHint:"Pick a file first from browse, search, or recent items.",filePanelUnsupported:"This file cannot be edited directly in the sidebar right now.",filePanelAttach:"Attach to Session",filePanelAttached:"Attached",filePanelDetach:"Detach",filePanelSave:"Save",filePanelSaving:"Saving...",filePanelLoadFailed:"Failed to load the file panel.",filePanelOpenFailed:"Failed to open the file.",filePanelSaveSuccess:"File saved.",filePanelSaveFailed:"Failed to save the file.",fileViewerHint:"Opened in {language} mode. Preview and save after editing are supported.",fileViewerModeLabel:"File View Mode",fileViewerPreview:"Preview",fileViewerCode:"Code",fileViewerEdit:"Edit",fileViewerPlainText:"Plain Text",fileViewerImage:"Image",fileViewerPdf:"PDF",fileViewerRefreshPreview:"Refresh",fileViewerRefreshFailed:"Failed to refresh the file preview.",fileViewerOpenExternal:"Open Externally",fileViewerOpenExternalFailed:"Failed to open the file externally.",fileViewerZoomIn:"Zoom In",fileViewerZoomOut:"Zoom Out",fileViewerFit:"Fit",fileViewerActualSize:"Actual Size",fileViewerFitWidth:"Fit Width",fileViewerPreviousPage:"Previous Page",fileViewerNextPage:"Next Page",fileViewerPageIndicator:"Page {page}",fileViewerSizeLabel:"Viewer Size",fileViewerSizeDefault:"Default",fileViewerSizeWide:"Wide",fileViewerSizeFull:"Full",fileViewerImageUnavailable:"The image preview is unavailable right now. Try refreshing or opening it externally.",fileViewerPdfUnavailable:"The PDF preview is unavailable right now. Try refreshing or opening it externally.",fileViewerEnterFullscreen:"Full Screen",fileViewerExitFullscreen:"Exit",fileViewerOpenInBrowser:"Open in Browser",fileViewerOpenInBrowserFailed:"Failed to open the browser preview.",fileViewerHtmlPreviewLoading:"Loading the HTML preview...",fileViewerHtmlPreviewUnavailable:"The HTML preview is unavailable right now. Switch to code view instead.",fileViewerHtmlPreviewFailed:"Failed to create the HTML preview link.",filePanelAttachSuccess:"The file has been attached to the current session.",filePanelAttachFailed:"Failed to attach the file.",filePanelDetachSuccess:"The file has been detached from the current session.",filePanelDetachFailed:"Failed to detach the file.",filePanelNewFile:"New File",filePanelNewDirectory:"New Directory",filePanelUpload:"Upload File",filePanelDownload:"Download File",filePanelUploadSuccess:"{name} uploaded.",filePanelUploadFailed:"Failed to upload the file.",filePanelDownloadSuccess:"Started downloading {name}.",filePanelDownloadFailed:"Failed to download the file.",filePanelDelete:"Delete",filePanelDeleting:"Deleting...",filePanelDeleteSuccess:"Deleted {name}.",filePanelDeleteConfirmTitle:"Confirm Deletion",filePanelDeleteConfirmDescription:"The selected item will be removed from this workspace immediately and cannot be undone.",filePanelDeleteSelectionConfirm:"Delete the selected {count} items?",filePanelDeleteSelectionSuccess:"Deleted {count} items.",filePanelRenameMove:"Rename / Move",filePanelMutateFailed:"File operation failed. Check the path and current state.",filePanelCreateFilePrompt:"Enter the relative path of the file to create",filePanelCreateDirectoryPrompt:"Enter the relative path of the directory to create",filePanelFilterChanges:"Changes Only",filePanelShowAll:"Show All",filePanelNoChanges:"No changed files.",filePanelBinaryPreview:"Binary files cannot be previewed.",filePanelDeleteFileConfirm:"Delete this file? {path}",filePanelDeleteDirectoryConfirm:"Delete this folder? {path}",filePanelRenameMovePrompt:"Enter the new relative path",unavailableAction:"Unavailable",roleUser:"User",roleAssistant:"Assistant",roleTool:"Tool",roleSystem:"System"},git:{title:"Git Context",subtitle:"This is the session-side support area. It only handles Git facts inside the current workspace.",loading:"Loading Git context for the current workspace...",refresh:"Refresh",panelLoadFailed:"Git context is not available right now.",ahead:"Ahead",behind:"Behind",dirty:"Dirty",clean:"Clean",changeCount:"{count} changed files in the current workspace",noChanges:"There are no pending changes right now.",changesTitle:"Current Changes",rulesFirstHint:"Rules come first. Drafts must not bypass validation.",stage:"Stage",unstage:"Unstage",preview:"Preview",stageFailed:"Stage operation failed.",diffTitle:"Diff Preview",diffLoadFailed:"Diff content is not available right now.",binaryDiff:"This file is a binary change. The sidebar does not render its content directly.",stagedDiff:"Staged diff",worktreeDiff:"Working tree diff",emptyDiff:"There is no text diff to display right now.",diffTruncated:"The diff is too long and has been truncated for safety.",commitTitle:"Commit Draft",defaultRuleName:"Default Commit Rule",language:"Language",maxLength:"Max Length",bodyRequired:"Body Required",bodyOptional:"Body Optional",issueRequired:"Issue Required",issueOptional:"Issue Optional",commitSubject:"Commit Subject",commitSubjectPlaceholder:"Enter the commit message here",commitBody:"Commit Body",commitBodyPlaceholder:"Explain the change clearly. Do not write empty words.",commitFooter:"Commit Footer",commitFooterPlaceholder:"For example: Refs: #123",generateDraft:"AI Draft",validate:"Validate Draft",commit:"Commit",draftFailed:"Failed to generate the commit draft.",validateFailed:"Commit rule validation failed.",commitFailed:"Commit failed.",commitSuccess:"The commit has been written to the current repository.",validationPassed:"Rule validation passed. You can continue to commit.",validationFailed:"Rule validation failed. Fix the issues below first.",branchTitle:"Branch",branchPlaceholder:"Enter the branch name to switch to or create",switchBranch:"Switch",createBranch:"Create",branchFailed:"Branch operation failed.",historyTitle:"Recent History",historyHint:"Only keep the latest few entries here. This is not a graphical history tree.",noHistory:"There is no commit history to show right now.",viewAllVersions:"View All Versions",viewAllVersionsDescription:"Loaded commit history for the current repository. Total entries: {count}.",viewCommitChanges:"View Changed Files and DIFF",copyCommitMessage:"Copy Commit Message",copyCommitMessageSuccess:"The commit message has been copied.",copyCommitVersion:"Copy Git Version",copyCommitVersionSuccess:"The Git version has been copied.",commitDetailTitle:"Commit Detail",commitDetailDescription:"Showing the full change for commit {hash}.",commitDetailLoading:"Loading commit detail...",commitDetailEmpty:"There is no commit detail to show right now.",commitDetailLoadFailed:"The commit detail is not available right now.",commitVersionLabel:"Git Version",commitHashLabel:"Commit Hash",commitAuthorLabel:"Author",commitTimeLabel:"Commit Time",commitMessageLabel:"Commit Message",changedFilesTitle:"Changed Files",commitDiffLabel:"Commit DIFF",renamedFromLabel:"Renamed from {path}",explainCommitTitle:"Explain Commit Change",explainCommitDescription:"Choose a CLI provider first, then start a new session to analyze this commit.",explainCommitAction:"Explain Change",startExplainCommit:"Start Explaining",explainCommitStarted:"The explanation session has been created.",explainCommitFailed:"Failed to explain the commit change.",remoteTitle:"Remote Sync",remoteReady:"A remote is configured for the current repository.",remoteMissing:"The current repository has no remote configured yet.",fetch:"Fetch",pull:"Pull",push:"Push",pushNow:"Push Now",publish:"Publish",remoteFailed:"Remote sync failed.",remoteAuthAction:"Remote Auth",remoteAuthTitle:"Configure Remote Authentication",remoteAuthDescription:"Enter the username, password, or token to use for authenticated remote operations in this page session.",remoteAuthDescriptionGithub:"The current remote points to GitHub. For GitHub HTTPS Git operations, use a Personal Access Token (PAT) instead of your GitHub login password.",remoteAuthStatusLabel:"Authentication",remoteAuthConfigured:"Configured",remoteAuthNotConfigured:"Not Configured",remoteAuthGithubPatLabel:"Personal Access Token (PAT)",remoteAuthGithubPatPlaceholder:"Enter GitHub PAT",remoteAuthGithubUsernamePlaceholder:"Enter GitHub username",remoteAuthGithubPatHint:"GitHub does not support account passwords for Git HTTPS authentication. In basic mode, enter GitHub username + PAT. In token mode, you can paste the PAT directly.",remoteAuthRemember:"Remember On Host",remoteAuthSessionHint:"By default this only applies to the current page session. If you enable “Remember On Host”, the credential will be stored on the Host after a successful remote sync and reused later.",remoteAuthRememberHint:"When remember is enabled, this credential will be written to the Host after the remote sync succeeds.",remoteAuthSave:"Save Auth",remoteAuthSaved:"Remote authentication saved. Retry the remote sync now.",remoteAuthCleared:"Remote authentication for this page session has been cleared.",selectRemoteTitle:"Select Remote to Push",selectRemoteDesc:"Select remote repositories to push to. Multiple selection supported.",noRemotes:"No remote repositories are configured.",pushSelected:"Push ({count})",pushing:"Pushing…",pushAllSuccess:"Successfully pushed to {count} remote(s).",errors:{unauthorized:"The current login is no longer valid. Log in again and retry.",workspaceNotFound:"The workspace bound to the current session does not exist. Check whether it is still available.",invalidWorkspace:"The current workspace config is invalid. The Git sidebar must not operate outside the repo root.",notGitRepository:"The current workspace is not a Git repository. The Git sidebar will not fake a state.",repoNotFound:"No usable Git repository root was found for the current workspace.",pathOutOfWorkspace:"The Git target is outside the current workspace repository boundary. The operation was blocked.",invalidTarget:"The Git target path is invalid. Refresh the sidebar and try again.",notStaged:"The target file is not staged yet. Check the current change state first.",emptyStagedChanges:"The staging area is empty. Stage the changes before committing.",branchConflict:"The current branch has conflicts or is not a fast-forward update. Sync and resolve differences first.",branchNotFound:"The target branch does not exist. Check the branch name first.",remoteNotFound:"The current repository does not have a usable origin remote yet.",remoteAuthFailed:"Remote repository authentication failed. Check the current credentials first.",pushFailed:"Push failed. Check remote state and local commits first.",pullFailed:"Pull failed. Check the remote branch state first.",remoteFailed:"Remote sync failed. Check Git output and network state.",commitValidationFailed:"The commit draft has not passed validation yet. Fix validation issues first.",commandTimeout:"The Git operation timed out. Check repository state and network conditions."}},theme:{light:"浅色",dark:"深色",skyBlue:"赛博",eyeGreen:"护眼",switchLabel:"Theme"},locale:{zhCN:"Simplified Chinese",enUS:"English"}},H1={common:{appName:"CodingNS",loading:"正在准备会话工作区…",retry:"重新尝试",back:"返回",save:"保存",close:"关闭",cancel:"取消",logout:"退出登录",unknown:"未命名会话"},auth:{loginTitle:"继续你的编码会话",loginSubtitle:"INITIALIZING DEVELOPMENT ENVIRONMENT...",serverPreset:"服务器列表",serverCustomOption:"使用自定义服务器",serverAddress:"服务器地址",serverPlaceholder:"例如:http://127.0.0.1:3002",serverHint:"登录、实时消息和终端都会连接到这里。客户端应填写 Host API 地址,例如 http://127.0.0.1:3002;4174、5173 这类前端开发端口不是给正式客户端直接连接的,只有代理和跨域都配好时才适合临时调试。",serverInvalid:"服务器地址无效,请检查后再试。",serverCurrent:"当前服务器",bootstrapTitle:"先完成首次初始化",bootstrapSubtitle:"这个 Host 还没有管理员账号,先创建一个最小登录入口。",username:"用户名",password:"密码",rememberPassword:"保存密码",confirmPassword:"确认密码",submitLogin:"进入工作台",submitBootstrap:"创建管理员账号",bootstrapSuccess:"初始化完成,现在可以登录了。",bootstrapMismatch:"两次输入的密码不一致。",authUnavailable:"暂时连不上 Host,请确认服务可访问。",logoutSuccess:"当前登录态已经清空。",demoBanner:"演示环境 — 所有账号数据公开可见,注销后自动清除",demoSessionExpired:"演示会话已过期,请重新登录",captcha:"图形验证码",captchaPlaceholder:"输入图中的字符",captchaHint:"连续输错三次后,需要先完成图形验证码才能继续登录。",captchaImageAlt:"登录图形验证码",serverSettings:"服务器设置",serverSettingsTitle:"服务器配置",saveServerSettings:"保存设置"},settings:{title:"设置",appearance:"外观",appearanceSectionSummary:"语言、主题与界面配色",language:"语言",languageDescription:"选择界面显示语言,切换后立即应用到当前页面。",theme:"主题",themeDescription:"选择适合你的界面配色方案",autoTheme:"自动跟随系统主题",autoThemeDescription:"开启后根据系统或浏览器的深浅色偏好自动切换日间和夜间模式。",fileManager:"文件管理",workspaceSessionSortMode:"工作区的会话显示排序方式",workspaceSessionSortModeDescription:"控制工作区里各处会话列表的默认排序,只影响当前设备。",sessionSortModeCreatedAt:"按照会话创建时间",sessionSortModeUpdatedAt:"按照会话更新时间",sessionSortModeTitle:"按照会话名称",showSystemFiles:"显示系统文件",showSystemFilesDescription:"在文件管理里显示 macOS 和 Windows 常见的系统文件,例如 .DS_Store、Thumbs.db。这个开关只影响当前设备。",serverConnection:"服务器连接",serverConnectionSectionSummary:"服务器地址与连接恢复策略",remoteAccess:"远程访问",remoteAccessSectionSummary:"查看状态并管理 Tailscale 远程访问。",modelManagement:"模型管理",modelManagementSectionSummary:"快速切换模型配置文件",modelManagementNavValue:"快速切换",modelManagementTitle:"模型快速切换",modelManagementDescription:"这里不新增也不编辑预设,只把 cc-switch 已有预设图形化展示出来,方便你一键切换。",modelManagementRefresh:"刷新模型",modelManagementRefreshSuccess:"模型预设列表已刷新。",modelManagementLoadFailed:"模型预设加载失败。",modelManagementScannedAt:"最近扫描",modelManagementScannedAtUnknown:"暂未扫描",modelManagementCurrentProfile:"当前配置文件",modelManagementCurrentModel:"当前模型",modelManagementCurrentPreset:"当前预设",modelManagementModelUnknown:"未识别",modelManagementPresetMissing:"未设置",modelManagementCurrentTag:"当前",modelManagementOpenSwitcher:"切换配置",modelManagementModalTitle:"供应商配置切换",modelManagementModalDescription:"这里按应用查看 cc-switch 已有配置文件,并切换当前启用项。",modelManagementTabsLabel:"模型应用标签",modelManagementSwitchAction:"切换",modelManagementSwitchSuccess:"{app} 已切换到 {preset}。",modelManagementOptionsEmpty:"当前没有可切换的预设。",modelManagementStatusReady:"可切换",modelManagementStatusUnconfigured:"未配置",modelManagementStatusUnavailable:"CLI 不可用",modelManagementStatusError:"读取失败",skills:"Skills",skillsSectionSummary:"读取并同步各个 CLI 自己的本地 skill,不做市场,不接远端仓库。",skillsNavValue:"本地同步",skillManagerTitle:"本地 Skill 管理",skillManagerDescription:"统一读取 Codex、Claude Code、Gemini、OpenCode 的 skill 目录,支持导入未纳管项并重新同步。",skillSummaryManagedSkills:"受管 skill",skillSummaryManagedEntries:"已纳管目录",skillSummaryUnmanagedEntries:"未纳管目录",skillSummaryConflictedEntries:"冲突目录",skillSummaryDiagnostics:"诊断",skillManageAction:"SKILL配置",skillConfigModalTitle:"SKILL配置",skillConfigModalDescription:"这里统一查看受管、未纳管、冲突和诊断结果,并执行导入或重新同步。",skillRefresh:"刷新概况",skillRefreshSuccess:"Skill 概况已刷新。",skillScannedAt:"最近扫描",skillManagedListTitle:"已纳管 Skill",skillManagedEmpty:"当前还没有纳管中的 skill。",skillUnmanagedListTitle:"未纳管 Skill",skillUnmanagedEmpty:"当前没有发现未纳管的 skill。",skillConflictedListTitle:"冲突项",skillConflictedEmpty:"当前没有发现冲突项。",skillDiagnosticsTitle:"诊断",skillDiagnosticsEmpty:"当前没有额外诊断信息。",skillDirectoryName:"目录名",skillSsotPath:"统一存储目录",skillSourceCli:"来源 CLI",skillDirectoryPath:"目录路径",skillImportAction:"导入并纳管",skillImportSuccess:"已导入 {name},并纳管到 {target}。",skillSyncAction:"重新同步",skillSyncSuccess:"已重新同步 {name}。",skillSyncTargetMissing:"这个 skill 还没有绑定任何目标 CLI,暂时无法重新同步。",skillLoadFailed:"Skill 概况加载失败。",skillTargetCodex:"Codex",skillTargetClaudeCode:"Claude Code",skillTargetGemini:"Gemini",skillTargetOpenCode:"OpenCode",skillBindingPending:"待同步",skillBindingSynced:"已同步",skillBindingFailed:"同步失败",skillBindingConflicted:"内容冲突",securityPrivacy:"安全与隐私",securityPrivacySectionSummary:"会话权限、风险边界与默认授权策略",softwareUpdate:"软件更新",softwareUpdateSectionSummary:"服务端和客户端版本",serverAddress:"服务器地址",serverDescription:"客户端的登录、接口请求和实时连接都通过这个 Host 入口工作;前端界面资源由应用自身携带。",tailscaleBrand:"Tailscale",tailscaleSectionTitle:"Tailscale 接入",tailscaleSectionDescription:"让这台 Host 通过 Tailscale 在你的设备间可访问。",tailscaleCurrentState:"当前状态",tailscaleSwitchLabel:"启用开关",tailscaleStatusIndicator:"状态指示器",tailscaleServerAddress:"服务器地址",tailscaleAccountName:"账号名",tailscaleIpAddress:"IP 地址",tailscaleConfigure:"配置",tailscaleConfigModalTitle:"配置 Tailscale",tailscaleConfigModalDescription:"修改接入参数",tailscaleControlServer:"Control Server",tailscaleControlServerDescription:"留空时使用默认 control server。",tailscaleControlServerPlaceholder:"留空表示使用默认 control server",tailscaleHostname:"设备名称",tailscaleHostnameDescription:"可选。",tailscaleHostnamePlaceholder:"例如:codingns-host",tailscaleReachableBaseUrl:"外部访问地址",tailscaleTailnetFqdn:"Tailnet FQDN",tailscaleTailnetIpv4:"Tailnet IPv4",tailscaleTailnetIpv6:"Tailnet IPv6",tailscaleDetailAddresses:"详细地址",tailscaleRefresh:"刷新状态",tailscaleInstallAction:"安装 Tailscale",tailscaleInstallOpenFailed:"打开 Tailscale 安装页面失败。",tailscaleEnable:"启用 Tailscale",tailscaleDisable:"停用 Tailscale",tailscaleLogin:"开始绑定",tailscaleLogout:"解绑账号",tailscaleUnavailable:"暂不可用",tailscaleLoadFailed:"Tailscale 状态读取失败。",tailscalePhaseDisabled:"未启用",tailscalePhaseBlockedUninitialized:"实例未初始化,已阻断暴露",tailscalePhaseStarting:"正在启动",tailscalePhaseNeedsLogin:"等待绑定账号",tailscalePhaseRunning:"运行中",tailscalePhaseStopping:"正在停止",tailscalePhaseError:"状态异常",tailscaleOverviewDisabled:"当前还没有启用远程访问。",tailscaleOverviewBlockedUninitialized:"先完成初始化,再启用远程访问。",tailscaleOverviewStarting:"正在接入 Tailscale,请稍等。",tailscaleOverviewNeedsLogin:"启用完成后,还需要绑定账号。",tailscaleOverviewRunning:"当前实例已经可以通过 Tailscale 访问。",tailscaleOverviewStopping:"正在关闭远程访问。",tailscaleOverviewError:"远程访问状态异常,请先刷新或重新配置。",releaseChannel:"发布通道",releaseChannelDescription:"稳定版或测试版",releaseStable:"稳定版",releaseBeta:"测试版",autoReconnect:"自动重连",autoReconnectDescription:"当 Host 短暂不可达时,自动尝试恢复 HTTP 和 WebSocket 链路。",autoCheckUpdate:"自动检查客户端更新",autoCheckUpdateDescription:"仅客户端",defaultPermissionMode:"默认会话权限",defaultPermissionModeDescription:"控制新建和继续会话时默认使用的工具权限。完整权限会关闭询问,只适合你已经信任当前项目和运行环境时使用。",permissionModeDefault:"跟随 CLI 默认策略",permissionModeAcceptEdits:"允许编辑工作区,不询问",permissionModeBypassPermissions:"完整权限,不询问",enabled:"已启用",disabled:"已关闭",serverUpdate:"服务端更新",serverUpdateDescription:"",clientUpdate:"客户端更新",clientUpdateDescription:"",serverCurrentVersion:"服务端当前版本",serverTargetVersion:"服务端目标版本",serverPackageName:"npm 包名",serverUpdateCommand:"升级命令",serverCheckNow:"检查服务端",serverOpenPage:"打开 npm",serverLatestUnknown:"暂未获取",serverUpdateReady:"发现新版本",serverUpToDate:"已是最新版本",serverCheckFailed:"检查失败",serverOpenPageFailed:"打开页面失败",releaseCurrentVersion:"当前版本",releaseTargetVersion:"目标版本",releaseTargetTag:"目标 Tag",releasePublishedAt:"发布时间",releaseUnknownVersion:"未知",releaseNotes:"更新内容",releaseNotesEmpty:"暂无更新内容",releaseCheckNow:"检查客户端",releaseInstallNow:"安装更新",releaseOpenPage:"打开发布页",releaseRollback:"回退版本",releaseUpdateReady:"发现新版本",releaseUpToDate:"已是最新版本",releaseCheckFailed:"检查失败",releaseInstallerMissing:"有新版本,暂无安装包",releaseSignatureMissing:"有新版本,缺少校验信息",releaseInstallStarted:"安装已开始",releaseInstallFailed:"安装失败",releasePageOpenFailed:"打开页面失败",androidInstallerStarted:"已交给系统安装器,安装完成前你仍可以取消",androidInstallPermissionRequired:"请先允许当前应用安装未知来源应用",androidInstallCancelled:"安装已取消或未完成,可重新触发安装",androidInstallSucceeded:"已检测到新版本完成安装",releaseRollbackStarted:"已开始回退",releaseRollbackFailed:"回退失败",clientUpdateUnsupported:"当前不支持安装更新",logout:"退出登录"},home:{title:"从一条会话继续,而不是从后台表格开始",subtitle:"这里先挑一个工作区和会话,真正的工作区在下一步。",terminalsEntry:"进入终端页",workspaceSection:"工作区",sessionSection:"最近会话",emptyWorkspaces:"还没有导入工作区。先在 Host 侧导入后,这里会出现入口。",emptySessions:"当前工作区还没有可继续的会话。",noActivity:"暂时还没有活动"},terminal:{title:"终端",heroTitle:"把真实 PTY 留在 Host,把操作入口留在工作台",heroSubtitle:"这里不伪造输出,不把终端和进程搅在一起,只消费 Host 统一托管的真实终端流。",workspaceSection:"工作区与终端",workspaceField:"当前工作区",shellField:"新终端使用的 Shell",runtimeField:"Runtime",runtimeAutoOption:"自动选择",runtimeAutoShortLabel:"auto",runtimeAutoDescription:"按 Host 默认策略选择当前终端 runtime。",runtimePersistentLabel:"持久会话",runtimePersistentShortLabel:"持久",runtimeTmuxDescription:"持久化外部会话,适合需要后台常驻的开发终端。",runtimeWindowsPersistentDescription:"使用基于 ConPTY 的 Windows 持久化会话,让终端在 Host 重启后仍可继续保留。",runtimeEmbeddedDescription:"由当前 Host 直接托管,适合作为轻量回退方案。",runtimeConptyPowerShellLabel:"PowerShell 持久会话",runtimeConptyCmdLabel:"CMD 持久会话",runtimeConptyGitBashLabel:"Git Bash 持久会话",runtimeMissingDialogTitle:"当前系统没有安装 tmux",runtimeMissingDialogDescription:"tmux runtime 无法继续创建持久化终端。你可以先安装 tmux,或者临时切换到 embedded-pty 继续。",runtimeMissingInstallDescription:"建议优先安装 tmux,这样终端才能在 Host 重启后继续保留。",runtimeMissingInstallMacArm:"macOS(Apple Silicon / Homebrew):arch -arm64 brew install tmux",runtimeMissingInstallMacIntel:"macOS(Intel Mac / Homebrew):brew install tmux",runtimeMissingInstallDebian:"Ubuntu / Debian:sudo apt install tmux",runtimeMissingInstallFedora:"Fedora:sudo dnf install tmux",runtimeMissingFallbackDescription:"如果现在先切到 embedded-pty,本次终端可以继续创建,但它不会作为外部持久会话保留。",runtimeMissingKeepAction:"先不切换",runtimeMissingFallbackAction:"切换到 embedded-pty 并继续",runtimeMissingFallbackPending:"正在切换…",shellUnavailable:"当前不可用",workspaceLoadFailed:"工作区或终端列表暂时没有拉回来。",terminalSection:"终端实例",templateSection:"命令模板",stageEmptyTitle:"还没有选中终端",stageEmptySubtitle:"先创建一个终端,或者运行一个命令模板。",emptyTerminals:"当前工作区还没有终端实例。",emptyTemplates:"当前工作区还没有命令模板。",createButton:"新建终端",creating:"正在创建终端…",creationPendingDescription:"Host 正在启动真实 PTY,连上以后这个窗口会立刻接管显示。",defaultTerminalName:"工作终端",created:"终端已经创建并接入 Host。",createFailed:"终端创建失败。",closeButton:"关闭终端",closing:"正在关闭终端…",closed:"终端关闭请求已经提交。",closeCompleted:"终端已关闭。",closePendingDescription:"关闭请求已经发给 Host,前台不会阻塞,系统会继续同步最终结果。",closeSyncDelayed:"Host 还在后台处理关闭,列表会在后续刷新时继续同步。",closeFailed:"终端关闭失败。",inputLabel:"向当前终端发送命令",inputPlaceholder:"例如:pnpm test",sendButton:"发送到终端",inputFailed:"终端输入发送失败。",outputEmpty:"终端已经连上,但暂时还没有输出。",outputTruncated:"断线期间有一段输出超出缓存窗口,当前只补回了仍保留的部分。",connectedHint:"当前输出来自 Host 真实 PTY 流。",moreActions:"终端操作",duplicateAction:"复制标签",duplicateSuccess:"已按当前终端配置新建一个标签。",duplicateFailed:"复制终端标签失败。",disconnectAction:"断开",disconnected:"终端连接已断开。",reconnectAction:"重连",reconnectRequested:"终端重连请求已发出。",deleteAction:"删除",deleting:"正在删除终端…",deleted:"终端记录已删除。",deletePendingDescription:"删除请求已经发给 Host,前台不会阻塞,系统会在后台继续同步列表。",deleteSyncDelayed:"Host 还在后台处理删除,列表会在后续刷新时继续同步。",deleteFailed:"终端记录删除失败。",closePendingBadge:"关闭中",deletePendingBadge:"删除中",pinAction:"固定",unpinAction:"取消固定",zoomLabel:"终端缩放",zoomInAction:"放大终端显示",zoomOutAction:"缩小终端显示",zoomResetAction:"恢复默认缩放",toolbarToggleAction:"展开终端工具栏",mobileSwipeHint:"左右滑动切换终端",mobileSwipePosition:"{current} / {total}",mobileDrawerAction:"打开快捷终端列表",mobileDrawerTitle:"快捷终端",mobileDrawerDescription:"右滑呼出列表,点一下就切到别的终端。",mobilePinnedSectionTitle:"已固定终端",mobileDrawerEmptyTitle:"当前还没有终端",mobileDrawerEmptyDescription:"先新建一个终端,这里才会出现可切换的列表。",mobileCreateSheetTitle:"新建终端",mobileCreateShellLabel:"终端类型",mobileCreateShellDescription:"先选这次要开的 Shell,别把桌面端那套下拉框搬到手机上。",mobileCreateRuntimeLabel:"会话方式",mobileCreateRuntimeDescription:"再决定它是持久保留,还是只作为当前 runtime 会话。",mobileCreateLoadingShells:"正在读取当前系统可用的终端类型…",mobileCreateConfirm:"创建这个终端",createDialogTitle:"新建终端",createDialogShellDescription:"先选这次要开的 Shell,再创建终端。Windows 下不再偷偷按默认值直接起。",createDialogRuntimeDescription:"再决定它是持久保留,还是只作为当前 runtime 会话。",createDialogConfirm:"创建终端",mobileRuntimePersistentTitle:"持久会话",mobileRuntimePersistentDescription:"适合需要一直挂着的开发终端,创建后会作为可恢复会话保留。",mobileRuntimeSessionTitle:"runtime(当前会话)",mobileRuntimeSessionDescription:"直接由当前 Host 托管,创建更轻,但不会保留成外部持久会话。",mobileWorkspaceSwitcherPlaceholder:"选择项目",mobileEmptyTitle:"这里还没有终端内容",mobileEmptyDescription:"先新建一个终端,或者右滑呼出快捷列表,切到当前工作区已有的终端。",layoutLabel:"分栏布局",layoutSingleAction:"单栏显示",layoutVerticalAction:"左右分栏",layoutHorizontalAction:"上下分栏",saveLogAction:"保存日志",saveLogSuccess:"终端日志已保存。",saveLogFailed:"终端日志保存失败。",logEmpty:"当前终端还没有可保存的日志内容。",bindToPaneAction:"绑定到当前分栏",bindToPrimaryPaneAction:"绑定到主分栏",bindToSecondaryPaneAction:"绑定到副分栏",panePrimary:"主分栏",paneSecondary:"副分栏",splitEmptySubtitle:"先点一个标签,或者新建一个终端,把它绑定到当前分栏。",statusBadge:{creating:"启动中",running:"运行中",closed:"已关闭",error:"异常"},recoveryComplete:"已回到刷新前的终端,缓存内的关键输出已经补回。",recoveryTruncated:"已恢复到上一个终端,但断线期间的部分输出已经超出缓存窗口。",recoveryIdleClosed:"上一个终端已因空闲超时被 Host 自动关闭,你现在看到的是关闭前保留的输出。",reconnect:"手动重连",liveConnected:"实时流已接入",templateName:"模板名称",templateCommand:"主命令",templateArgs:"参数(空格分隔)",templateCreateButton:"保存模板",templateCreated:"命令模板已经保存。",templateCreateFailed:"命令模板保存失败。",templateRunSent:"命令模板已经发送到当前终端。",templateRunCreatedTerminal:"命令模板已在新终端中启动。",templateRunFailed:"命令模板执行失败。",connection:{connected:"已连接",reconnecting:"正在重连",reconnect_failed:"重连失败",closed:"已关闭"}},conversation:{titleFallback:"继续对话",historyLoading:"正在从 Host 拉取消息历史…",historyLoadingOlder:"正在加载更早的消息…",historyLoadFailed:"历史消息暂时没有拉回来,可以稍后再试。",timelineEmpty:"这条会话还没有消息。你发出的第一句话会直接进入 Host 链路。",turnAbortedUser:"上一轮已由你手动停止。",turnAbortedUnexpected:"上一轮意外中断,没有正常结束。",turnAbortedGeneric:"上一轮已中断,没有正常结束。",scrollToBottomAction:"回到底部",rawRefLabel:"来源",copyAction:"复制",copyContentSuccess:"内容已复制。",copyContentFailed:"内容复制失败。",selectionTodoAction:"代办",selectionActionButton:"操作",selectionActionSubmit:"新开操作子会话",selectionActionPromptLabel:"你想让它做什么",selectionActionPromptPlaceholder:"比如:解释这段话、整理成笔记,或调用指定接口处理它",selectionActionIncludeContext:"包含当前上下文",selectionActionContextUnavailable:"当前选区跨了多条消息,没法安全继承上下文,只能按无上下文新建子会话。",selectionActionDefaultPrompt:"请处理这段内容。",selectionActionQuotedLabel:"选中文本",selectionActionFailed:"创建操作子会话失败。",actionSessionBadge:"操作",actionInheritedSelectionSummary:"已默认折叠来自“{parentTitle}”的一段选中文本。",forkFromHereAction:"从这里分叉",forkingAction:"正在分叉…",forkMessageSucceeded:"已从这条消息创建新分支。",forkMessageFailed:"从这条消息分叉失败。",forkDraftLabel:"分叉引用",forkDraftEmpty:"这条消息没有可引用的文本内容。",forkDraftClear:"取消这次分叉引用",forkTargetProviderLabel:"目标 CLI",forkTargetModelLabel:"目标模型",forkTargetSummary:"源 CLI:{sourceProvider} · 目标 CLI:{targetProvider}",forkInlineModelLoading:"正在读取模型列表…",forkInlineNativeHint:"保持同一 CLI,继续走原生分叉。",forkInlineCrossHint:"已切到不同 CLI,将按文本历史重建新会话。",forkSwitchConfirmTitle:"切换到其他 CLI?",forkSwitchConfirmDescription:"同一 CLI 会尽量保留原生分叉体验;切到其他 CLI 会改成跨供应商分叉。",forkSwitchConfirmKeepTitle:"会保留",forkSwitchConfirmKeepBody:"分叉点之前的用户消息和助手文本。",forkSwitchConfirmConvertTitle:"会转换",forkSwitchConfirmConvertBody:"可继承文本会重建到新的 CLI 会话里。",forkSwitchConfirmDropTitle:"会丢失",forkSwitchConfirmDropBody:"工具调用、权限交互、附件和运行中状态。",forkSwitchConfirmAction:"确认切换",forkSwitchKeepNative:"保持原生",forkProviderNativeUnsupported:"当前 provider 还不支持原生 fork",forkProviderReconstructedUnsupported:"当前 provider 还不能作为跨 provider 分叉目标",loadMore:"加载更多消息",composerPlaceholder:"把下一步交代清楚,剩下的交给这条会话继续跑。",sendButton:"发送消息",queueTitle:"待发队列",queueDescription:"当前这轮结束后,队列里的消息会按顺序自动继续处理。",queueOrderPrefix:"队列序号",queueStatusQueued:"等待中",queueStatusFailed:"发送失败",queueDelete:"删除",queueDeleting:"删除中",queueImageOnly:"仅图片附件",sendGuidanceButton:"追加引导",queueGuidanceButton:"加入队列",queueSteer:"引导",queueSteering:"引导中",resendButton:"重试发送",quickPhraseTrigger:"快捷短语",quickPhraseModalTitle:"快捷短语",quickPhraseModalDescription:"这里集中管理你常用的会话指令,点一下就能直接填回当前输入框。",quickPhraseCreateLabel:"新增短语",quickPhraseOpenCreateAction:"新增短语",quickPhraseCreateModalTitle:"新增快捷短语",quickPhraseCreateModalDescription:"把常用指令单独存起来,后面在任何设备上都能直接复用。",quickPhraseCreatePlaceholder:"输入一条常用短语,保存后下次可以直接复用。",quickPhraseCreateAction:"添加短语",quickPhraseListLabel:"快捷短语列表",quickPhraseEmpty:"还没有可用的快捷短语,先加一条最常用的。",quickPhraseOrderLabel:"第 {index} 条",quickPhraseMoveUp:"上移短语",quickPhraseMoveDown:"下移短语",quickPhraseDelete:"删除短语",quickPhraseSaveFailed:"快捷短语保存失败,请稍后再试。",sendingState:"发送中",sentState:"已同步",failedState:"发送失败",contextUsageTitle:"当前上下文占用",contextUsageUnavailable:"当前上下文占用暂时不可用",contextUsageEstimated:"上限为估算值",contextUsageCachedTokens:"缓存命中 {count}",contextUsageSourceProviderLog:"上限来自 provider 运行日志",contextUsageSourceProviderRuntime:"上限来自 provider runtime",contextUsageSourceProviderConfig:"上限来自 provider 配置",contextUsageSourceModelMap:"上限来自模型映射",headerWorkspace:"工作区",headerProvider:"Provider",headerCapability:"能力摘要",connectionConnected:"已连接",connectionReconnecting:"正在重连",connectionReconnectFailed:"重连失败",connectionClosed:"连接已关闭",runtimeErrorTitle:"会话运行失败",reconnectExplain:"实时链路断开了,系统正在补回缺失消息。",reconnectFailedExplain:"自动恢复没有成功。你可以手动重试,或者稍后重新进入会话。",capabilityDenied:"当前会话不支持这个动作",capabilitySendDisabled:"当前 provider 不支持发送新消息",capabilityAttachmentDisabled:"当前会话还不支持附件输入",capabilityInterruptDisabled:"当前会话不支持中断运行",sidebarTitle:"当前会话上下文",sidebarSubtitle:"这里只保留最小能力摘要,不把页面做成后台控制台。",reconnectButton:"手动恢复实时同步",headerResumedAt:"最近续接",headerLastSyncAt:"最近同步",historyPages:"历史分页",syncStatusIdle:"同步空闲",syncStatusSyncing:"同步中",syncStatusError:"同步异常",capabilityResume:"可续接",capabilitySend:"可发送",capabilityInterrupt:"可中断",capabilityTools:"工具调用",attachmentsLabel:"附件",filePanelTitle:"文件管理",filePanelSubtitle:"这里的文件能力只服务当前会话,不把页面拉成重型 IDE。",filePanelNoWorkspace:"当前还没有选中项目,暂时不能浏览或挂载文件。",filePanelRefresh:"刷新",filePanelCopyPath:"复制路径",filePanelCopyAbsolutePath:"复制绝对路径",filePanelCopyRelativePath:"复制相对路径",filePanelCopyAbsolutePathSuccess:"绝对路径已复制。",filePanelCopyRelativePathSuccess:"相对路径已复制。",filePanelCopyPathFailed:"路径复制失败。",filePanelCopy:"复制",filePanelCut:"剪切",filePanelPaste:"粘贴",filePanelCopySelectionSuccess:"已复制 {count} 项,可到目标目录粘贴。",filePanelCutSelectionSuccess:"已剪切 {count} 项,可到目标目录粘贴。",filePanelPasteSuccess:"已粘贴 {count} 项。",filePanelPasteFailed:"粘贴失败,请检查目标目录和重名冲突。",filePanelSelectionCount:"已选 {count} 项",filePanelClipboardCopyReady:"剪贴板中有 {count} 个待复制项目",filePanelClipboardCutReady:"剪贴板中有 {count} 个待移动项目",filePanelOpenFile:"打开文件",filePanelExpandDirectory:"展开文件夹",filePanelCollapseDirectory:"折叠文件夹",filePanelActionsMenu:"文件操作",filePanelSearchPlaceholder:"输入文件名或路径片段",filePanelSearchButton:"搜索",filePanelShowSearch:"打开搜索",filePanelHideSearch:"收起搜索",filePanelSearchEmpty:"没有找到匹配的文件。",filePanelSearchResults:"搜索结果",filePanelSearchFailed:"文件搜索失败,请稍后再试。",filePanelBrowse:"工作区文件",filePanelCollapseCurrent:"折叠当前选中",filePanelCollapseAll:"全部折叠",filePanelBackDirectory:"返回上级",filePanelEmptyDirectory:"这个目录里暂时没有可显示的文件。",filePanelRecentTitle:"最近打开",filePanelEmptyRecent:"最近还没有打开记录。",filePanelContextTitle:"已挂载文件",filePanelEmptyContexts:"当前会话还没有挂载文件管理。",filePanelEditorTitle:"预览与编辑",filePanelEditorPlaceholder:"这里只做轻量文本编辑,不在这里做完整 IDE。",filePanelSelectHint:"先从目录、搜索或最近打开里选一个文件。",filePanelUnsupported:"这个文件当前不能在侧栏里直接编辑。",filePanelAttach:"挂到会话",filePanelAttached:"已挂载",filePanelDetach:"解绑",filePanelSave:"保存",filePanelSaving:"保存中",filePanelLoadFailed:"文件管理面板加载失败。",filePanelOpenFailed:"文件打开失败。",filePanelSaveSuccess:"文件已经保存。",filePanelSaveFailed:"文件保存失败。",fileViewerHint:"当前以 {language} 模式打开,支持预览与编辑保存。",fileViewerModeLabel:"文件查看模式",fileViewerPreview:"预览",fileViewerCode:"代码",fileViewerEdit:"编辑",fileViewerPlainText:"纯文本",fileViewerImage:"图片",fileViewerPdf:"PDF",fileViewerRefreshPreview:"刷新",fileViewerRefreshFailed:"文件预览刷新失败。",fileViewerOpenExternal:"外部打开",fileViewerOpenExternalFailed:"外部打开失败。",fileViewerZoomIn:"放大",fileViewerZoomOut:"缩小",fileViewerFit:"适配",fileViewerActualSize:"原始大小",fileViewerFitWidth:"适宽",fileViewerPreviousPage:"上一页",fileViewerNextPage:"下一页",fileViewerPageIndicator:"第 {page} 页",fileViewerSizeLabel:"查看器尺寸",fileViewerSizeDefault:"默认",fileViewerSizeWide:"加宽",fileViewerSizeFull:"铺满",fileViewerImageUnavailable:"当前无法显示图片预览,请尝试刷新或外部打开。",fileViewerPdfUnavailable:"当前无法显示 PDF 预览,请尝试刷新或外部打开。",fileViewerEnterFullscreen:"全屏",fileViewerExitFullscreen:"退出",fileViewerOpenInBrowser:"在浏览器中打开",fileViewerOpenInBrowserFailed:"打开浏览器预览失败。",fileViewerHtmlPreviewLoading:"正在加载 HTML 预览...",fileViewerHtmlPreviewUnavailable:"当前无法显示 HTML 预览,请先切到代码模式查看。",fileViewerHtmlPreviewFailed:"HTML 预览链接生成失败。",filePanelAttachSuccess:"文件已经挂到当前会话。",filePanelAttachFailed:"文件挂载失败。",filePanelDetachSuccess:"文件已经从当前会话解绑。",filePanelDetachFailed:"文件解绑失败。",filePanelNewFile:"新建文件",filePanelNewDirectory:"新建目录",filePanelUpload:"上传文件",filePanelDownload:"下载文件",filePanelUploadSuccess:"已上传 {name}。",filePanelUploadFailed:"文件上传失败。",filePanelDownloadSuccess:"已开始下载 {name}。",filePanelDownloadFailed:"文件下载失败。",filePanelDelete:"删除",filePanelDeleting:"删除中...",filePanelDeleteSuccess:"已删除 {name}。",filePanelDeleteConfirmTitle:"确认删除",filePanelDeleteConfirmDescription:"删除后会立即从当前项目移除,这一步不能撤销。",filePanelDeleteSelectionConfirm:"确认删除选中的 {count} 项吗?",filePanelDeleteSelectionSuccess:"已删除 {count} 项。",filePanelRenameMove:"重命名/移动",filePanelMutateFailed:"文件操作失败,请检查路径和当前状态。",filePanelCreateFilePrompt:"输入要创建的相对文件路径",filePanelCreateDirectoryPrompt:"输入要创建的相对目录路径",filePanelFilterChanges:"仅显示变更",filePanelShowAll:"显示全部",filePanelNoChanges:"当前没有变更文件。",filePanelBinaryPreview:"二进制文件不支持预览。",filePanelDeleteFileConfirm:"确认删除这个文件吗?{path}",filePanelDeleteDirectoryConfirm:"确认删除这个文件夹吗?{path}",filePanelRenameMovePrompt:"输入新的相对路径",unavailableAction:"当前不可用",roleUser:"你",roleAssistant:"助手",roleTool:"工具",roleSystem:"系统"},git:{title:"Git 上下文",subtitle:"这里是会话侧边的辅助区,只处理当前工作区里的 Git 事实。",loading:"正在读取当前工作区的 Git 上下文。",refresh:"刷新",panelLoadFailed:"Git 上下文暂时没有加载出来。",ahead:"领先",behind:"落后",dirty:"有改动",clean:"已干净",changeCount:"当前有 {count} 个变更文件",noChanges:"当前没有待处理改动。",changesTitle:"当前变更",rulesFirstHint:"规则先于生成,草稿不能绕过校验。",stage:"暂存",unstage:"取消暂存",preview:"预览",stageFailed:"暂存操作失败。",diffTitle:"差异预览",diffLoadFailed:"差异内容暂时没有拉回来。",binaryDiff:"这个文件是二进制改动,侧栏不直接展示内容。",stagedDiff:"暂存区 diff",worktreeDiff:"工作区 diff",emptyDiff:"当前没有可展示的文本差异。",diffTruncated:"差异内容过长,已经做了截断保护。",commitTitle:"提交草稿",defaultRuleName:"默认提交规则",language:"语言",maxLength:"长度",bodyRequired:"正文必填",bodyOptional:"正文可选",issueRequired:"Issue 必填",issueOptional:"Issue 可选",commitSubject:"提交标题",commitSubjectPlaceholder:"在这里输入提交信息",commitBody:"提交正文",commitBodyPlaceholder:"把这次改动说清楚,别写空话。",commitFooter:"提交脚注",commitFooterPlaceholder:"例如:Refs: #123",generateDraft:"AI 起草",validate:"校验草稿",commit:"执行提交",draftFailed:"提交草稿生成失败。",validateFailed:"提交规则校验失败。",commitFailed:"提交失败。",commitSuccess:"提交已经写入当前仓库。",validationPassed:"规则校验通过,可以继续提交。",validationFailed:"规则校验没有通过,先把下面的问题修掉。",branchTitle:"分支",branchPlaceholder:"输入要切换或创建的分支名",switchBranch:"切换",createBranch:"新建",branchFailed:"分支操作失败。",historyTitle:"最近历史",historyHint:"只放最近几条,不做图形历史树。",noHistory:"当前没有可展示的提交历史。",viewAllVersions:"查看所有版本",viewAllVersionsDescription:"这里展示当前仓库已加载的版本历史,共 {count} 条。",viewCommitChanges:"查看更改文件与 DIFF",copyCommitMessage:"复制提交信息",copyCommitMessageSuccess:"提交信息已复制。",copyCommitVersion:"复制 Git 版本号",copyCommitVersionSuccess:"Git 版本号已复制。",commitDetailTitle:"版本详情",commitDetailDescription:"当前查看提交 {hash} 的完整改动。",commitDetailLoading:"正在读取提交详情…",commitDetailEmpty:"当前没有可展示的提交详情。",commitDetailLoadFailed:"提交详情暂时没有拉回来。",commitVersionLabel:"Git 版本号",commitHashLabel:"提交 Hash",commitAuthorLabel:"作者",commitTimeLabel:"提交时间",commitMessageLabel:"提交信息",changedFilesTitle:"变更文件",commitDiffLabel:"提交 DIFF",renamedFromLabel:"从 {path} 重命名",explainCommitTitle:"解释版本更改",explainCommitDescription:"先选择一个 CLI 供应商,再新建会话分析这个提交。",explainCommitAction:"解释更改",startExplainCommit:"开始解释",explainCommitStarted:"解释会话已经创建。",explainCommitFailed:"解释更改失败。",remoteTitle:"远程同步",remoteReady:"当前仓库已配置远程。",remoteMissing:"当前仓库还没有远程。",fetch:"Fetch",pull:"Pull",push:"Push",pushNow:"立即推送",publish:"Publish",remoteFailed:"远程同步失败。",remoteAuthAction:"远程认证",remoteAuthTitle:"设置远程仓库认证",remoteAuthDescription:"需要认证的远程仓库,在这里填写本次页面会话使用的用户名、密码或 token。",remoteAuthDescriptionGithub:"检测到当前远程仓库来自 GitHub。GitHub 的 HTTPS Git 操作请使用 Personal Access Token (PAT),不要填写 GitHub 登录密码。",remoteAuthStatusLabel:"认证状态",remoteAuthConfigured:"已配置",remoteAuthNotConfigured:"未配置",remoteAuthGithubPatLabel:"Personal Access Token (PAT)",remoteAuthGithubPatPlaceholder:"输入 GitHub PAT",remoteAuthGithubUsernamePlaceholder:"输入 GitHub 用户名",remoteAuthGithubPatHint:"GitHub 不支持用账号密码做 Git HTTPS 认证。basic 模式请填写 GitHub 用户名 + PAT;token 模式可以直接填写 PAT。",remoteAuthRemember:"记住账号密码到 Host",remoteAuthSessionHint:"默认只在当前页面会话里生效;勾选“记住账号密码到 Host”后,远程同步成功时会写到 Host,后续自动复用。",remoteAuthRememberHint:"勾选记住后,本次远程同步成功时会把认证写到 Host。",remoteAuthSave:"保存认证",remoteAuthSaved:"远程仓库认证已保存,请重新执行同步。",remoteAuthCleared:"已清除当前页面会话里的远程认证设置。",selectRemoteTitle:"选择推送仓库",selectRemoteDesc:"勾选要推送到的远程仓库,支持多选。",noRemotes:"当前仓库没有配置任何远程仓库。",pushSelected:"推送 ({count})",pushing:"推送中…",pushAllSuccess:"已成功推送到 {count} 个远程仓库。",errors:{unauthorized:"当前登录态已经失效,请重新登录后再试。",workspaceNotFound:"当前会话绑定的工作区不存在,先确认工作区是否还可用。",invalidWorkspace:"当前工作区配置无效,Git 侧栏不能脱离仓库根目录执行。",notGitRepository:"当前工作区不是 Git 仓库,Git 侧栏不会伪造状态。",repoNotFound:"当前工作区找不到可用的 Git 仓库根目录。",pathOutOfWorkspace:"Git 目标超出了当前工作区仓库边界,操作已被拦截。",invalidTarget:"Git 目标路径无效,请先刷新侧栏后重试。",notStaged:"目标文件还不在暂存区里,先确认当前变更状态。",emptyStagedChanges:"暂存区为空,先把要提交的改动放进暂存区。",branchConflict:"当前分支存在冲突或不是快进更新,先同步并处理差异。",branchNotFound:"目标分支不存在,先确认分支名是否正确。",remoteNotFound:"当前仓库还没有可用的 origin 远程,先配置远程再同步。",remoteAuthFailed:"远程仓库认证失败,请先确认当前仓库凭据可用。",pushFailed:"推送失败,请先检查远程状态和本地提交。",pullFailed:"拉取失败,请先确认远程分支状态。",remoteFailed:"远程同步失败,请检查 Git 输出和网络状态。",commitValidationFailed:"提交草稿还没通过规则校验,先把校验问题修掉。",commandTimeout:"Git 操作超时了,先确认仓库状态和网络环境。"}}},z1=[{id:"zh-CN",labelKey:"locale.zhCN"},{id:"en-US",labelKey:"locale.enUS"}];function Yb({variant:e="default",className:t}){const r=ca(i=>i.profile.language);function s(i){i!==r&&Qc({language:i}).catch(()=>{})}return n.jsxs("label",{className:`language-switcher language-switcher-${e}${t?` ${t}`:""}`,children:[n.jsx("span",{className:"language-switcher-label",children:o("common.language")}),n.jsx("div",{className:"language-switcher-options",role:"group","aria-label":o("common.language"),children:z1.map(i=>n.jsx("button",{type:"button",className:`language-switcher-option${r===i.id?" active":""}`,"aria-pressed":r===i.id,onClick:()=>s(i.id),children:o(i.labelKey)},i.id))})]})}const q1={common:{close:"关闭",cancel:"取消",logout:"退出登录",language:"语言"},locale:{zhCN:"简体中文",enUS:"English"},settings:{title:"设置",appearance:"外观",language:"语言",languageDescription:"选择界面显示语言,切换后立即应用到当前页面。",theme:"主题",themeDescription:"选择适合你的界面配色方案",connection:"连接与更新",serverAddress:"服务地址",serverDescription:"桌面端和 H5 都通过这个 Host 入口工作。",releaseChannel:"发布通道",releaseChannelDescription:"稳定版或测试版",releaseStable:"Stable",releaseBeta:"Beta",autoReconnect:"自动重连",autoReconnectDescription:"当 Host 短暂不可达时,自动尝试恢复 HTTP 和 WebSocket 链路。",autoCheckUpdate:"自动检查客户端更新",autoCheckUpdateDescription:"仅客户端",notificationSettings:"通知",notificationSettingsDescription:"单独控制会话相关的系统通知提醒。",notifyOnPermissionRequest:"会话等待审批时通知",notifyOnPermissionRequestDescription:"后台会话出现新的权限申请时推送通知。",notifyOnSessionCompleted:"会话完成时通知",notifyOnSessionCompletedDescription:"后台会话变为已完成时推送通知。",notifyOnSessionFailed:"会话异常时通知",notifyOnSessionFailedDescription:"后台会话运行失败时推送通知。",enabled:"已启用",disabled:"已关闭",serverUpdate:"服务端更新",serverUpdateDescription:"",clientUpdate:"客户端更新",clientUpdateDescription:"",serverCurrentVersion:"服务端当前版本",serverTargetVersion:"服务端目标版本",serverPackageName:"npm 包名",serverUpdateCommand:"升级命令",serverCheckNow:"检查服务端",serverInstallNow:"安装更新",serverOpenPage:"打开 npm",serverLatestUnknown:"暂未获取",serverUpdateReady:"发现新版本",serverUpToDate:"已是最新版本",serverCheckFailed:"检查失败",serverInstallQueued:"已加入更新队列",serverInstalling:"正在安装更新",serverInstallSucceeded:"更新已完成",serverInstallFailed:"安装失败",serverInstallCancelled:"安装已取消",serverInstallTimeout:"安装超时",serverRestartRequired:"新版本已安装,重启 Host 后生效",serverOpenPageFailed:"打开页面失败",runtimePlatform:"当前运行平台",runtimePlatformDescription:"用来确认现在是 Web/H5、Desktop、iOS 还是 Android 运行环境。",platformDesktop:"Desktop",platformWeb:"Web",platformIos:"iOS",platformAndroid:"Android",releaseDesktopOnly:"当前是 Web/H5 运行环境,不支持桌面更新。",releaseCurrentVersion:"当前版本",releaseTargetVersion:"目标版本",releaseUnknownVersion:"未知",releaseNotes:"更新内容",releaseNotesEmpty:"暂无更新内容",releaseCheckNow:"检查客户端",releaseInstallNow:"安装更新",releaseOpenPage:"打开发布页",releaseManualOnly:"当前版本只能手动安装",releaseUpdateReady:"发现新版本",releaseUpToDate:"已是最新版本",releaseCheckFailed:"检查失败",releaseInstallStarted:"安装已开始",releaseInstallFailed:"安装失败",releasePageOpenFailed:"打开发布页失败",androidInstallerStarted:"已交给系统安装器,安装完成前你仍可以取消",androidInstallPermissionRequired:"请先允许当前应用安装未知来源应用",androidInstallCancelled:"安装已取消或未完成,可重新触发安装",androidInstallSucceeded:"已检测到新版本完成安装",clientUpdateUnsupported:"当前不支持安装更新",account:"账号",logout:"退出登录",logoutDescription:"退出当前账号并返回登录页面",advancedSettings:"高级设置",parallelTaskDebug:"并行任务调试",parallelTaskDebugDescription:"打开后才会启用运行时采样,用来实时看后台任务、调度器和主线程压力指标。",parallelTaskDebugAction:"打开调试面板",parallelTaskDebugModalTitle:"并行任务调试",parallelTaskDebugModalDescription:"这个窗口打开时才会继续采集任务活动和 event loop 指标,关掉后立即停止。",parallelTaskDebugClose:"关闭并行任务调试",parallelTaskDebugLoading:"正在建立观测会话并拉取快照…",parallelTaskDebugLoadFailed:"加载并行任务调试信息失败",parallelTaskDebugEmpty:"当前没有可展示的执行记录。",parallelTaskDebugStatusActive:"采集中",parallelTaskDebugStatusError:"采集异常",parallelTaskDebugObservedAt:"最后更新",parallelTaskDebugSessionExpireAt:"会话到期时间",parallelTaskDebugSessionTtl:"会话 TTL",parallelTaskDebugCollectorState:"采集器状态",parallelTaskDebugCollectorEnabled:"已启用",parallelTaskDebugCollectorDisabled:"未启用",parallelTaskDebugAutoRefresh:"每秒自动刷新",parallelTaskDebugCountersTitle:"总指标",parallelTaskDebugTaskMetricsTitle:"后台任务指标",parallelTaskDebugSchedulerTitle:"调度器指标",parallelTaskDebugEventLoopTitle:"Event Loop",parallelTaskDebugRecentActivitiesTitle:"最近执行记录",parallelTaskDebugWaitAvg:"平均等待",parallelTaskDebugRunAvg:"平均执行",parallelTaskDebugRunMax:"最长执行",parallelTaskDebugStartedCount:"启动次数",parallelTaskDebugFinishedCount:"完成次数",parallelTaskDebugFailedCount:"失败次数",parallelTaskDebugCacheHitCount:"缓存命中",parallelTaskDebugIdle:"空转",parallelTaskDebugBusy:"已命中任务",parallelTaskDebugTickTotal:"tick 总数",parallelTaskDebugIdleTickTotal:"空转 tick",parallelTaskDebugTaskCountTotal:"命中任务",parallelTaskDebugSchedulerErrorTotal:"异常次数",parallelTaskDebugLastDuration:"上次耗时",parallelTaskDebugNextDelay:"下次延迟",parallelTaskDebugEventLoopResolution:"采样粒度",parallelTaskDebugEventLoopMean:"平均延迟",parallelTaskDebugEventLoopP95:"P95 延迟",parallelTaskDebugEventLoopP99:"P99 延迟",parallelTaskDebugEventLoopMax:"最大延迟",parallelTaskDebugTaskKey:"任务 Key",parallelTaskDebugStatus:"状态",parallelTaskDebugAttempt:"尝试",parallelTaskDebugWaitMs:"等待",parallelTaskDebugRunMs:"执行",parallelTaskDebugSource:"来源",parallelTaskDebugError:"错误",parallelTaskDebugMetricEnqueue:"入队",parallelTaskDebugMetricDedupe:"去重",parallelTaskDebugMetricStarted:"已启动",parallelTaskDebugMetricFinished:"已完成",parallelTaskDebugMetricFailed:"失败",parallelTaskDebugMetricCancelled:"已取消",parallelTaskDebugMetricTimeout:"超时",parallelTaskDebugMetricCacheHit:"缓存命中",parallelTaskDebugLaneRequestMainThread:"请求主线程",parallelTaskDebugLaneHostBackground:"Host 后台",parallelTaskDebugLaneHelperProcess:"Helper 进程",parallelTaskDebugLaneExternalProcess:"外部进程",parallelTaskDebugEventEnqueued:"入队",parallelTaskDebugEventDeduped:"去重复用",parallelTaskDebugEventStarted:"开始",parallelTaskDebugEventFinished:"完成",parallelTaskDebugEventFailed:"失败",parallelTaskDebugEventCancelled:"取消",parallelTaskDebugEventTimeout:"超时",parallelTaskDebugEventCacheHit:"命中缓存",parallelTaskDebugTaskStatusQueued:"排队中",parallelTaskDebugTaskStatusRunning:"运行中",parallelTaskDebugTaskStatusSucceeded:"已成功",parallelTaskDebugTaskStatusFailed:"已失败",parallelTaskDebugTaskStatusCancelled:"已取消",parallelTaskDebugTaskStatusTimeout:"已超时"},shell:{title:"工作台",subtitle:"管理代码项目里的 AI 会话",mobileWorkspacesEntry:"工作区",mobileTerminalsEntry:"终端",mobileSessionsEntry:"对话",mobileToolsEntry:"工具",mobileSettingsEntry:"设置",mobileNavigationAction:"打开工作台菜单",mobileSearchAction:"打开搜索",mobileAuxiliaryAction:"打开工具面板",mobileRevealNavigationAction:"显示主导航",mobileHideNavigationAction:"收起主导航",mobileConversationPreviewTitle:"快速预览",mobileConversationCurrentWorkspaceSection:"当前工作区",mobileConversationCollapsePreviewAction:"收起预览",mobileConversationRestorePreviewAction:"恢复会话预览",iosMoreAction:"更多操作",androidMoreAction:"更多操作",conversationEntry:"对话",terminalsEntry:"终端",butlerEntry:"助手",globalNotificationsAction:"通知",globalNotificationsUnreadAria:"未读通知 {count}",globalNotificationsPanelTitle:"通知中心",globalNotificationsPanelDescription:"这里集中看需要你拍板、代办分析结果、跟进状态和验证失败的提醒。",globalNotificationsEmpty:"当前没有新的全局通知。",globalNotificationsShowArchived:"显示已归档通知",globalNotificationsArchiveAction:"归档",globalNotificationsRemoveArchiveAction:"移除归档",globalNotificationsArchiveFailed:"通知归档更新失败",globalNotificationKindWaitingUser:"等待你决定",globalNotificationKindTodoAnalyzed:"代办分析完成",globalNotificationKindTodoAnalyzeFailed:"代办分析失败",globalNotificationKindFollowUpFailed:"跟进失败",globalNotificationKindFollowUpCompleted:"跟进完成",globalNotificationKindVerificationFailed:"验证失败",globalNotificationTodoAnalyzedTitle:"代办分析完成:{title}",globalNotificationTodoAnalyzeFailedTitle:"代办分析失败:{title}",globalNotificationFollowUpWaitingTitle:"需要你决定:{title}",globalNotificationFollowUpFailedTitle:"跟进失败:{title}",globalNotificationFollowUpCompletedTitle:"跟进完成:{title}",globalNotificationVerificationFailedTitle:"验证失败:{title}",globalNotificationVerificationFailedFallback:"最近一次验证没有通过,请尽快查看。",searchEntry:"搜索",butlerInitTitle:"初始化助手",butlerInitDescription:"先设置助手的称呼、provider 和工作方式。助手工作目录和第一版 AGENTS.md 会由系统自动创建。",butlerInitPreviewTitle:"当前预览",butlerInitPreviewDescription:"这不是花架子,下面这些选择会直接决定首版规则的语气和汇报方式。",butlerInitBasicsTitle:"基础设置",butlerInitBasicsDescription:"先把名字、provider 和规则载体定下来,别让初始化阶段长成配置地狱。",butlerInitPersonaTitle:"表达方式",butlerInitPersonaDescription:"语气、语言和总结风格决定它怎么说,不决定它会不会胡来。",butlerInitPreferenceTitle:"默认偏好",butlerInitPreferenceDescription:"这里控制它默认先盯什么风险、先汇报什么结果。",butlerInitRuleLabel:"规则载体",butlerInitTipAutoWorkspace:"系统会自动创建助手目录和首版 AGENTS.md,你现在只需要定默认偏好。",butlerInitTipProviderSwitch:"Provider 后续还能切,不用在第一次初始化时把自己困死。",butlerInitTipReportPriority:"汇报优先级会影响它先告诉你风险、阻塞,还是验证结果。",butlerDisplayNameLabel:"助手称呼",butlerDisplayNamePlaceholder:"例如:阿尔文、小助手",butlerDisplayNameHint:"这是助手的自称,系统会写入 AGENTS.md 首版规则。",butlerProviderLabel:"Provider",butlerWorkspacePathLabel:"助手工作目录",butlerWorkspacePathPlaceholder:"例如:/Users/you/WorkFile/butler-home",butlerAgentsModeLabel:"AGENTS 模式",butlerAgentsModeInline:"内联",butlerAgentsModeFile:"文件",butlerAgentsModeInlineDescription:"内联:系统按你的初始化选项生成规则,后续由系统管理为主。",butlerAgentsModeFileDescription:"文件:系统会在助手独立工作目录下写入 AGENTS.md,后续可以直接改这个文件。",butlerAgentsFilePathLabel:"AGENTS.md 文件路径",butlerAgentsFilePathPlaceholder:"例如:/Users/you/WorkFile/butler-home/AGENTS.md",butlerAgentsContentLabel:"AGENTS 规则内容",butlerAgentsContentPlaceholder:"输入助手的工作规则和解答风格",butlerAgentsContentHint:"这里维护助手的正式规则正文,保存后会直接回写 Butler 专用 AGENTS.md 或内联规则。",butlerPersonaToneLabel:"语气",butlerPersonaLanguageLabel:"使用语言",butlerPersonaSummaryStyleLabel:"总结风格",butlerFocusRiskPreferenceLabel:"风险倾向",butlerFocusReportPriorityLabel:"汇报优先级(逗号分隔)",butlerFocusReportPriorityPlaceholder:"例如:risk,blocker,verification",butlerToneDirect:"直接明确",butlerToneSteady:"稳健克制",butlerToneFriendly:"友好耐心",butlerLanguageZhCn:"中文优先",butlerLanguageEnUs:"英文优先",butlerLanguageBilingual:"中英双语",butlerSummaryBrief:"简明扫一眼",butlerSummaryStructured:"分段清晰",butlerSummaryThorough:"详细展开",butlerRiskConservative:"保守稳妥",butlerRiskBalanced:"推进/风险平衡",butlerRiskProactive:"主动预警",butlerReportPriorityPresetLabel:"汇报优先级",butlerReportRiskFirst:"风险优先",butlerReportBlockerFirst:"阻塞优先",butlerReportVerificationFirst:"验证优先",butlerReportProgressFirst:"进展优先",butlerSummaryDebounceLabel:"会话摘要防抖",butlerSummaryDebounceOption1Minute:"1 分钟",butlerSummaryDebounceOption3Minutes:"3 分钟",butlerSummaryDebounceOption5Minutes:"5 分钟(默认)",butlerSummaryDebounceOption10Minutes:"10 分钟",butlerSummaryDebounceOption15Minutes:"15 分钟",butlerSummaryDebounceOption30Minutes:"30 分钟",butlerSettingsTitle:"助手设置",butlerSettingsSaveAction:"保存设置",butlerSettingsSaving:"保存中...",butlerSettingsSaved:"助手设置已保存",butlerSettingsSaveFailed:"保存助手设置失败",butlerInitSubmitting:"初始化中...",butlerInitSubmit:"完成初始化",butlerInitSuccess:"助手初始化成功",butlerInitFailed:"助手初始化失败",butlerInitNameRequired:"请先输入助手称呼",butlerInitWorkspaceRequired:"请先填写助手工作目录",butlerInitAgentsFileRequired:"文件模式下请填写 AGENTS.md 路径",butlerWorkbenchTitle:"助手工作台",butlerWorkbenchSubtitle:"在这里与助手对话,并查看聚合上下文和动作事件。",butlerWorkspaceHint:"助手工作目录:{workspacePath}",butlerDisplayNameActiveHint:"当前助手称呼:{displayName}",butlerNewSessionAction:"新建会话",butlerNewSessionStarted:"已为助手新建会话",butlerNewSessionFailed:"新建助手会话失败",butlerRefreshAction:"刷新",butlerHistoryAction:"历史消息",butlerHistoryTitle:"助手历史消息",butlerHistoryDescription:"这里保留所有 Butler 会话,代办分析和普通聊天都会持久化保存。",butlerHistoryEmpty:"还没有助手历史会话。",butlerHistoryOpenAction:"打开这条会话",butlerCurrentSessionBadge:"当前会话",butlerControlSessionKindChat:"普通聊天",butlerControlSessionKindTodoAnalysis:"代办分析",butlerLoadingTitle:"助手页面加载中",butlerLoadingDescription:"正在整理当前助手的会话、摘要和控制状态,请稍候。",butlerSidebarInfoTab:"信息",butlerSidebarAutomationTab:"自动化",butlerSidebarSettingsTab:"设置",butlerSidebarTabsLabel:"助手信息栏标签",butlerSidebarLoadFailed:"助手信息栏读取失败",butlerInfoContextTitle:"当前上下文",butlerInfoContextDescription:"这里先告诉你助手这一轮正在看什么,不把无关信息一股脑塞进来。",butlerInfoCurrentScopeLabel:"当前范围",butlerInfoCurrentScopeProject:"项目:{projectName}",butlerInfoCurrentScopeGlobal:"全局总览",butlerInfoManagedProjectsLabel:"已跟踪项目",butlerInfoManagedProjectsValue:"活跃 {activeCount} / 全部 {totalCount}",butlerInfoCurrentContextProjectHint:"当前已经切到 {projectName},助手后续补查会优先围绕这个项目展开。",butlerInfoCurrentContextGlobalHint:"当前还是全局视角,只有你点进项目或追问细节时,助手才继续补查更深的信息。",butlerInfoProjectSelectedAction:"当前已选中",butlerInfoProjectViewAction:"查看这个项目",butlerInfoProjectBlockedBadge:"有阻塞",butlerInfoProjectRiskBadge:"风险:{riskLevel}",butlerInfoProjectRiskShortBadge:"风险 {riskLevel}",butlerInfoProjectLastActivityBadge:"最近活跃:{updatedAt}",butlerInfoLatestSessionAction:"打开最近会话",butlerInfoProgressTitle:"当前进展",butlerInfoAttentionTitle:"需要留意",butlerInfoNextStepTitle:"建议下一步",butlerInfoFollowUpRecordsTitle:"会话跟进",butlerInfoFollowUpRecordsDescription:"这里只显示最近 5 条会话跟进状态,完整历史通过按钮展开查看。",butlerInfoFollowUpRecordsEmpty:"还没有会话跟进记录。",butlerInfoFollowUpUntitled:"未命名会话",butlerInfoFollowUpFallback:"最近更新时间:{updatedAt}",butlerFollowUpHistoryAction:"查看历史",butlerFollowUpHistoryTitle:"会话跟进历史",butlerFollowUpHistoryDescription:"这里查看完整的会话跟进状态历史,并可继续下钻轮次详情。",butlerInfoVerificationRecordsTitle:"会话验证",butlerInfoVerificationRecordsDescription:"这里看全局的功能验证记录。",butlerInfoVerificationRecordsEmpty:"还没有会话验证记录。",butlerInfoVerificationFallback:"当前状态:{status}",butlerInfoTodoRecordsTitle:"代办进度",butlerInfoTodoRecordsDescription:"这里看当前汇总出来的代办推进情况。",butlerInfoTodoRecordsEmpty:"还没有代办进度记录。",butlerInfoShowCompletedAction:"显示已完成记录",butlerInfoTodoItemTitle:"代办 {index}",butlerInfoTodoPending:"待处理",butlerInfoTodoInProgress:"进行中",butlerInfoTodoClosed:"已关闭",butlerTodoLifecyclePending:"待分析",butlerTodoLifecycleAnalyzing:"分析中",butlerTodoLifecycleAnalyzed:"已生成提示词",butlerTodoLifecycleSessionCreated:"已创建会话",butlerTodoLifecycleFollowUpActive:"助手处理中",butlerTodoLifecycleCompleted:"已完成",butlerTodoLifecycleFailed:"处理失败",butlerTodoLifecycleEmpty:"这条代办还没有生成分析摘要。",butlerTodoPromptPreviewAction:"查看开发提示词",butlerTodoAnalyzeAction:"分析仓库",butlerTodoReanalyzeAction:"重新分析",butlerTodoAnalyzeRunning:"分析中...",butlerTodoAnalyzeQueued:"已加入后台分析队列",butlerTodoAnalyzeSucceeded:"已生成开发提示词",butlerTodoAnalyzeFailed:"代办仓库分析失败",butlerTodoAnalyzeFirstAction:"先分析代办",butlerTodoWaitForPromptAction:"等待分析完成",butlerTodoStartSessionAction:"创建会话",butlerTodoStartSessionRunning:"创建中...",butlerTodoCopyPromptAction:"复制提示词",butlerTodoOpenSessionAction:"打开会话",butlerTodoCopyPromptSucceeded:"开发提示词已复制",butlerTodoStartSessionSucceeded:"已为代办创建开发会话",butlerTodoStartSessionFailed:"代办会话创建失败",butlerAutomationTasksTitle:"自动化任务",butlerAutomationTasksDescription:"这里只看自动化任务本身:有哪些任务、现在什么状态、下一次什么时候运行。",butlerAutomationTasksEmpty:"当前还没有自动化任务。",butlerAutomationRunsTitle:"最近运行记录",butlerAutomationRunsDescription:"这里只看自动化任务最近执行了什么,以及每次运行的结果。",butlerAutomationRunsEmpty:"最近还没有自动化运行记录。",butlerAutomationStatusActive:"进行中",butlerAutomationStatusWaitingUser:"等你决定",butlerAutomationStatusCompleted:"已完成",butlerAutomationStatusFailed:"失败",butlerAutomationStatusCancelled:"已取消",butlerAutomationTaskTypeLabel:"任务类型",butlerAutomationTaskTypeManual:"手动计划任务",butlerAutomationTaskTypeInterval:"定时计划任务",butlerAutomationTaskTypeCron:"Cron 计划任务",butlerAutomationTaskTypeFollowUp:"条件跟进任务",butlerAutomationTaskEnabled:"已启用",butlerAutomationTaskDisabled:"已停用",butlerAutomationTaskLastRunLabel:"最近运行",butlerAutomationTaskNextRunLabel:"下一次运行",butlerAutomationRunSourceLabel:"来源",butlerAutomationRunSourcePatrol:"计划任务运行",butlerAutomationRunSourceFollowUp:"条件跟进运行",butlerAutomationRunSummaryLabel:"运行结果",butlerAutomationRunProcessedAtLabel:"运行时间",butlerAutomationRunEmptySummary:"本次运行没有返回摘要。",butlerAutomationPatrolRunTitle:"巡视任务运行",butlerAutomationObjectiveLabel:"当前目标",butlerAutomationLatestAssessmentLabel:"最近判断",butlerAutomationWaitingReasonLabel:"等你决定什么",butlerAutomationNextCheckLabel:"下一次查看",butlerAutomationFinishedAtLabel:"结束时间",butlerAutomationViewRoundsAction:"查看每轮详情",butlerAutomationRoundDetailsTitle:"跟进轮次详情",butlerAutomationRoundDetailsDescription:"查看这个跟进任务每一轮的判断和动作。",butlerAutomationRoundLoading:"正在读取跟进轮次详情...",butlerAutomationRoundLoadFailed:"读取跟进轮次详情失败",butlerAutomationRoundEmpty:"当前还没有可展示的跟进轮次详情。",butlerAutomationRoundLabel:"第 {round} 轮",butlerAutomationRoundProcessedAtLabel:"处理时间",butlerAutomationRoundStatusLabel:"任务状态",butlerAutomationRoundObservedStateLabel:"会话运行状态",butlerAutomationRoundSummaryLabel:"这一轮判断",butlerAutomationRoundWaitingReasonLabel:"等待原因",butlerAutomationRoundPromptLabel:"代理发送内容",butlerAutomationRoundKindStarted:"开始跟进",butlerAutomationRoundKindContinue:"已直接续接",butlerAutomationRoundKindQueued:"已进入消息队列",butlerAutomationRoundKindWaitingUser:"等待用户处理",butlerAutomationRoundKindCompleted:"确认完成",butlerAutomationRoundKindFailed:"跟进失败",butlerAutomationRoundKindCancelled:"手动终止",butlerAutomationRoundKindLimitReached:"达到轮数上限",butlerInboxAction:"收件箱",butlerInboxModalTitle:"收件箱",butlerInboxModalDescription:"在这里记录项目代办,并按项目维护当前推进情况。",butlerInboxLoading:"正在读取收件箱...",butlerInboxLoadFailed:"收件箱读取失败",butlerInboxProjectsEmpty:"还没有可绑定的项目,请先在管家里管理项目。",butlerInboxEmpty:"还没有收件箱记录。",butlerInboxCreateTitle:"新增代办",butlerInboxEditingTitle:"编辑代办",butlerInboxFormDescription:"每条代办都必须绑定到一个项目,后续助手才能围绕它继续跟进。",butlerInboxListTitle:"当前代办",butlerInboxListDescription:"这里会列出你管理的项目代办,方便统一收口处理。",butlerInboxShowClosedAction:"显示已关闭",butlerInboxQuickStatusLabel:"快速设置进度",butlerInboxProjectLabel:"绑定项目",butlerInboxTypeLabel:"类型",butlerInboxTitleLabel:"标题",butlerInboxTitlePlaceholder:"例如:登录页验证码收尾",butlerInboxContentLabel:"内容",butlerInboxContentPlaceholder:"写清楚当前问题、目标或你希望助手后续继续推进的点。",butlerInboxStatusLabel:"进度",butlerInboxTypeTask:"任务",butlerInboxTypeBug:"缺陷",butlerInboxTypeFeature:"新功能",butlerInboxTypeChange:"修改",butlerInboxStatusPending:"待处理",butlerInboxStatusInProgress:"进行中",butlerInboxStatusClosed:"已关闭",butlerInboxCreateAction:"新增代办",butlerInboxUpdateAction:"保存修改",butlerInboxCancelEditAction:"取消编辑",butlerInboxEditAction:"编辑",butlerInboxDeleteAction:"删除",butlerInboxCreated:"代办已新增",butlerInboxUpdated:"代办已更新",butlerInboxDeleted:"代办已删除",butlerInboxSaveFailed:"代办保存失败",butlerInboxDeleteFailed:"代办删除失败",butlerProviderSwitched:"Provider 已切换",butlerProviderSwitchedDescription:"已切换到 {provider},当前视图已重置并重新加载。",butlerProviderSwitchFailed:"Provider 切换失败",butlerAttachmentUnsupported:"助手对话暂不支持附件",butlerOverviewTitle:"整体情况",butlerOverviewDescription:"这里会先帮你整理当前最值得关注的内容。",butlerMetricProjectCount:"项目",butlerMetricBlockedCount:"阻塞",butlerMetricHighRiskCount:"高风险",butlerTopRisksTitle:"优先风险",butlerNextActionsTitle:"建议动作",butlerOverviewEmpty:"暂无",butlerOverviewLoading:"正在读取助手聚合摘要...",butlerEventsTitle:"最近操作",butlerEventsDescription:"助手最近帮你做过什么,这里会记下来。",butlerEventsEmpty:"暂无动作事件",butlerLoadFailed:"助手工作台加载失败",butlerContextStrategyTitle:"按需上下文",butlerContextStrategyDescription:"默认只给助手全局摘要,只有你点到某个项目时,才再向后端补拉该项目的会话、记忆、巡视和验证摘要。",butlerConversationTitle:"与助手对话",butlerConversationDescription:"这个对话窗口只属于 {displayName}。需要细节时,{displayName} 会先用聚合摘要回答,再按需直达后端补查具体项目、会话、巡视或验证信息。",butlerComposerPlaceholder:"直接对 {displayName} 说你现在想搞清楚什么",butlerProjectsTitle:"项目",butlerProjectsDescription:"选一个项目,助手就会继续帮你查它的进展和记录。",butlerProjectsEmpty:"暂无可下钻的项目",butlerProjectWorkspaceLabel:"所属工作区:{workspaceId}",butlerProjectSummaryEmpty:"暂无可用摘要",butlerProjectOpenDetailAction:"查看详情",butlerProjectSyncAction:"同步到时间线",butlerProjectSyncSucceeded:"已把项目 {projectName} 同步到助手时间线",butlerProjectActionRequiresSession:"先和助手说一句话,然后再让它继续处理项目。",butlerProjectContextTitle:"当前项目",butlerProjectContextDescription:"这里会显示这个项目的会话、记录和结果。",butlerProjectContextEmpty:"先从上面的项目列表或动作事件里选一个项目。",butlerProjectContextLoading:"正在读取项目关联信息...",butlerProjectContextMeta:"项目状态:{status} · 风险级别:{riskLevel}",butlerProjectActionSucceeded:"助手动作已执行",butlerProjectActionFailed:"助手动作失败",butlerProjectActionPending:"处理中...",butlerProjectSessionsTitle:"项目会话",butlerProjectMemoriesTitle:"项目记忆",butlerProjectPatrolsTitle:"巡视记录",butlerProjectVerificationsTitle:"验证记录",butlerProjectOpenConversationAction:"打开真实会话",butlerProjectResumeAction:"续接会话",butlerProjectResumeSucceeded:"已续接会话:{sessionTitle}",butlerProjectStartPatrolAction:"发起巡视",butlerProjectPatrolSucceeded:"已为 {projectName} 发起巡视",butlerProjectStartVerificationAction:"发起验证",butlerProjectVerificationSucceeded:"已为 {projectName} 发起验证",butlerProjectMemoryMeta:"类型:{memoryType} · 状态:{status}",butlerProjectSessionMeta:"角色:{role} · 状态:{status}",butlerProjectPatrolMeta:"状态:{status} · 风险:{riskLevel}",butlerProjectVerificationMeta:"类型:{verificationType} · 状态:{status}",butlerProjectRunSummaryEmpty:"暂无摘要",butlerProjectFocusAction:"定位这条记录",butlerProjectUpdatedAtLabel:"更新时间:{updatedAt}",butlerFocusedBadge:"当前定位",searchModalTitle:"搜索",searchModalDescription:"支持搜会话标题,或在当前工作区里搜代码文件。",searchModeLabel:"搜索模式",searchModeSessions:"会话",searchModeCode:"代码",searchKeywordLabel:"关键词",searchWorkspaceLabel:"工作区",searchSessionPlaceholder:"输入会话名称、工作区或 provider",searchCodePlaceholder:"输入文件名或路径片段",searchSessionHint:"输入关键词后,这里会立即列出匹配的会话。",searchCodeHint:"选一个工作区,然后搜文件名或路径。",searchSessionEmpty:"没找到匹配的会话。",searchCodeEmpty:"没找到匹配的文件。",searchCodeFailed:"代码搜索失败,请稍后重试。",searchSubmit:"开始搜索",filesEntry:"文件",gitEntry:"GIT",terminalManagerEntry:"进程管理",workspaceSectionTitle:"工作区",goBack:"后退",goForward:"前进",workspaceCount:"项目",sessionCount:"会话",manageWorkspaceAction:"管理项目",manageWorkspaceTitle:"管理项目",manageWorkspaceDescription:"默认只列出当前已加载的项目,展开后可以查看路径、Git 摘要、代码类型组成,也可以从当前工作台列表里移除。",manageWorkspaceImportAction:"导入项目",manageWorkspaceCloneAction:"Clone项目",manageWorkspaceEmpty:"当前没有可管理的项目。",manageWorkspaceLoading:"正在读取项目详情...",manageWorkspaceLoadFailed:"项目详情加载失败",manageWorkspacePathLabel:"路径",manageWorkspaceGitCommitCount:"Git 提交版本数",manageWorkspaceGitInfoLabel:"Git 仓库信息",manageWorkspaceRepoRoot:"仓库根目录",manageWorkspaceCurrentBranch:"当前分支",manageWorkspaceRemoteLabel:"远程",manageWorkspaceNoRemote:"未配置远程",manageWorkspaceNotGit:"当前项目不是 Git 仓库。",manageWorkspaceCodeCompositionLabel:"代码类型组成",manageWorkspaceCodeCompositionFiles:"文件",manageWorkspaceCodeCompositionOther:"其他",manageWorkspaceNoCodeComposition:"暂时没有识别到可统计的代码文件。",manageWorkspaceCodeTruncated:"文件过多,只统计了前 {count} 个可识别文件。",manageWorkspaceColorLabel:"背景颜色",manageWorkspaceColorSelectSwatch:"使用颜色 {color}",manageWorkspaceColorClearAction:"清除颜色",manageWorkspaceColorUnset:"未设置,当前使用默认颜色",manageWorkspaceColorSaveFailed:"工作区颜色保存失败",manageWorkspaceRemoveAction:"移除项目",manageWorkspaceRemoving:"移除中...",manageWorkspaceRemoveSuccess:"项目已从当前工作台移除",manageWorkspaceRemoveFailed:"移除项目失败",manageWorkspaceRemoveConfirmTitle:"确认移除项目",manageWorkspaceRemoveConfirmDescription:"这只会把项目从当前工作台列表移除,不会删除任何磁盘数据或历史记录。后续重新加载同一路径时,旧记录会直接恢复显示。",manageWorkspaceRemoveConfirmTarget:"确定移除「{name}」吗?",manageWorkspaceRemoveConfirmAction:"确认移除",importWorkspaceTitle:"添加项目",importWorkspaceHint:"导入本地代码目录",importExpand:"展开",importCollapse:"收起",importPathLabel:"项目路径",importPathPlaceholder:"输入项目文件夹路径",importNameLabel:"项目名称",importNamePlaceholder:"可选",importSubmit:"添加项目",importSubmitting:"添加中...",importChooseFolder:"选择文件夹",importPickFolderFailed:"打开文件夹选择器失败",importDesktopDropHint:"支持把本地项目文件夹直接拖到这个区域",importHint:"输入本地代码目录后就能开始工作",importServerDirectoryHint:"浏览并选择运行服务器上的项目目录",importBrowserTitle:"选择服务器目录",importBrowserDescription:"这里浏览的是项目运行所在服务器上的目录,不是当前设备的本地目录。",importBrowserCurrentPath:"当前目录",importBrowserRoots:"根目录",importBrowserOpenParent:"返回上一级",importBrowserOpenPath:"打开路径",importBrowserCreateDirectory:"新建文件夹",importBrowserCreateDirectoryTitle:"新建文件夹",importBrowserCreateDirectoryDescription:"只在当前服务器目录下新建一层子文件夹,不接受带路径的输入。",importBrowserCreateDirectoryLabel:"文件夹名称",importBrowserCreateDirectoryPlaceholder:"输入新文件夹名称",importBrowserCreateDirectorySuccess:"文件夹已创建",importBrowserCreateDirectoryFailed:"新建文件夹失败",importBrowserCreateDirectorySubmit:"确认新建",importBrowserCreatingDirectory:"新建中...",importBrowserEmpty:"当前目录下没有可选的子目录",importBrowserBrowseFailed:"加载服务器目录失败",importBrowserSubmit:"导入当前目录",importPathRequired:"请输入项目路径",importSuccess:"项目已添加",importFailed:"添加失败",cloneWorkspaceTitle:"Clone项目",cloneWorkspaceHint:"从 Git 仓库拉取代码到服务端目录,完成后直接加入项目列表。",cloneSubmit:"Clone项目",cloneSubmitting:"Clone 中...",cloneRepositoryLabel:"Git 仓库地址",cloneRepositoryPlaceholder:"例如:https://github.com/org/repo.git",cloneParentPathLabel:"目标父目录",cloneParentPathPlaceholder:"选择后端服务上已存在的目录",cloneDirectoryNameLabel:"新项目目录名",cloneDirectoryNamePlaceholder:"留空时默认使用仓库名",clonePickDirectory:"选择目录",cloneAuthModeLabel:"认证方式",cloneAuthModeNone:"无认证",cloneAuthModeBasic:"用户名 + 密码",cloneAuthModeToken:"Token",cloneUsernameLabel:"用户名",cloneUsernamePlaceholder:"输入 Git 用户名",clonePasswordLabel:"密码",clonePasswordPlaceholder:"输入 Git 密码",cloneTokenLabel:"Token",cloneTokenPlaceholder:"输入 access token",cloneTokenUsernamePlaceholder:"可选,留空时默认使用 git",cloneRepoRequired:"请输入 Git 仓库地址",clonePathRequired:"请选择目标父目录",cloneSuccess:"项目已成功 Clone",cloneFailed:"Clone 失败",cloneHint:"目标父目录必须已经存在,Clone 时会在这个目录下新建仓库文件夹。",cloneBrowserTitle:"选择 Clone 目标父目录",cloneBrowserDescription:"这里选的是服务端已存在的父目录,Clone 时会在其下新建一个项目文件夹。",cloneBrowserSubmit:"使用当前目录",refreshNavigation:"刷新",desktopChromeLabel:"桌面工作台",windowMinimize:"最小化窗口",windowMaximize:"最大化或还原窗口",windowClose:"关闭窗口",contextOpenSession:"打开会话",navigationLoadFailed:"加载失败,请重试",emptyNavigationTitle:"还没有项目",emptyNavigationBody:"添加本地代码目录开始工作",emptyWorkspaceSessions:"暂无会话",favoriteSectionTitle:"收藏会话",favoriteSectionEmpty:"收藏后的会话会固定放在这里,方便你快速回到常用链路。",worktreeSectionTitle:"子工作树",worktreeSectionExpand:"展开子工作树",worktreeSectionCollapse:"收起子工作树",worktreeMergePanelLabel:"工作树合并",worktreeMergePanelTitle:"合回直接父工作区",worktreeMergeExpandDetails:"展开详情",worktreeMergeCollapseDetails:"收起详情",worktreeMergePreviewAction:"预检",worktreeMergePreviewRefresh:"预检",worktreeMergePreviewIdle:"尚未预检",worktreeMergePreviewLoading:"预检中...",worktreeMergeReady:"可以合并",worktreeMergeBlocked:"当前不能合并",worktreeMergeApplying:"合并中...",worktreeMergeApplyAction:"合并",worktreeMergeApplySuccess:"子工作树已经合回直接父工作区",worktreeMergeApplyFailed:"合并子工作树失败",worktreeMergePreviewFailed:"读取工作树合并预检失败",worktreeMergeAlreadyMerged:"已合回直接父工作区",worktreeMergeMergedHint:"代码已经合回直接父工作区,下一步可以继续做清理。",worktreeMergeMergedDirtyHint:"提交历史已经同步到父工作区,但当前子工作树还有未处理事项,暂时不能清理。",worktreeMergeChecklistTitle:"合并检查清单",worktreeMergeChecklistSourceState:"工作树状态正常",worktreeMergeChecklistSourceStateBlocked:"当前子工作树状态异常,系统暂时没有把它当作活跃工作树",worktreeMergeChecklistSourceClean:"子工作区已清理",worktreeMergeChecklistSourceCleanBlocked:"当前子工作树存在未提交改动,请先提交",worktreeMergeChecklistTargetClean:"父工作区可接收合并",worktreeMergeChecklistTargetCleanBlocked:"直接父工作区存在未提交改动,不能接收合并",worktreeMergeChecklistChildren:"没有活跃子工作树",worktreeMergeChecklistChildrenBlocked:"当前子工作树下面还有活跃子节点,必须先从叶子节点开始回收",worktreeMergeChecklistCommits:"存在待合并提交",worktreeMergeChecklistCommitsBlocked:"当前子工作树没有领先父工作区的提交",worktreeMergeChecklistConflicts:"合并不会产生冲突",worktreeMergeChecklistConflictsBlocked:"检测到合并冲突,先处理冲突后再继续",worktreeMergeChecklistResultPending:"等待预检结果",worktreeMergeChecklistResultReady:"可以执行合并",worktreeMergeChecklistResultReadyDetail:"所有条件已满足,可以开始合并",worktreeMergeChecklistResultBlocked:"暂时不能执行合并",worktreeMergeChecklistResultBlockedDetail:"上面的阻塞项解决后,才可以继续",worktreeMergeChecklistResultMerged:"已完成合并,可继续清理",worktreeMergeCompactPending:"待预检",worktreeMergeCompactChecking:"预检中",worktreeMergeCompactReady:"可合并",worktreeMergeCompactBlocked:"受阻",worktreeMergeCompactMerged:"已合并",worktreeMergeCompactMerging:"合并中",worktreeMergeCompactCleaning:"清理中",worktreeMergeCompactInactive:"状态异常",worktreeMergeCompactDirty:"未提交",worktreeMergeCompactTargetDirty:"父区脏",worktreeMergeCompactConflict:"有冲突",worktreeMergeCompactChildren:"有子树",worktreeMergeCompactNoCommits:"无提交",worktreeCleanupAction:"清理",worktreeCleanupRunning:"清理中...",worktreeCleanupSuccess:"工作树已经清理完成",worktreeCleanupFailed:"清理工作树失败",worktreeCleanupModalTitle:"确认清理工作树",worktreeCleanupModalDescription:"默认只清理工作树目录和系统记录。只有分支已经合并进父分支后,才允许额外删除分支。",worktreeCleanupConfirm:"确认清理 {name} 吗?默认会保留 git 分支。",worktreeCleanupDeleteBranchLabel:"同时删除分支 {branch}",worktreeCleanupDeleteBranchHint:"只有分支已经合并进父分支后,才允许删除分支。",worktreeCleanupDeleteBranchAction:"清理并删除分支",worktreeCleanupDeleteBranchSuccess:"工作树和分支 {branch} 已清理完成",worktreeCleanupDeleteBranchPartialFailed:"工作树已清理,但分支 {branch} 删除失败",worktreeMergeCurrentBranch:"当前分支:{branch}",worktreeMergeParentBranch:"父分支:{branch}",worktreeMergeTargetWorkspace:"目标父工作区:{name}",worktreeMergeAheadBehindPending:"提交差异:待预检",worktreeMergeAheadBehind:"提交差异:领先 {ahead} / 落后 {behind}",worktreeMergeBaseCommit:"merge base:{commit}",worktreeMergeConflictLabel:"冲突文件",favoriteAction:"收藏会话",unfavoriteAction:"取消收藏",favoriteAdded:"会话已加入收藏",favoriteRemoved:"会话已取消收藏",favoriteToggleFailed:"收藏状态更新失败",sessionMoreAction:"更多操作",sessionStateInferred:"推断",renameAction:"重命名",renameSuccess:"会话名称已更新",renameFailed:"会话重命名失败",renameModalTitle:"重命名会话",renameModalDescription:"改成你自己能一眼认出来的名字,只改标题,不改消息内容。",renameInputLabel:"会话名称",renameInputPlaceholder:"输入新的会话名称",renamingSession:"保存中...",archiveFolderLabel:"归档会话",archiveFolderAction:"打开归档文件夹",archiveAction:"归档会话",archiveCurrentSessionAction:"归档当前会话",archiveAdded:"会话已归档",archiveConfirmTitle:"确认归档会话",archiveConfirmDescription:"归档后,这条会话会从当前工作区主列表里隐藏,你仍然可以在归档区恢复它。",unarchiveAction:"取消归档",archiveRestored:"会话已恢复到主列表",archiveModalTitle:"归档会话",archiveModalDescription:"这里列出当前项目暂时隐藏的会话,需要时可以恢复到主列表。",archiveEmpty:"这个项目还没有归档会话。",archiveViewAction:"查看归档会话",subagentBadge:"子代理",sessionForkSession:"会话分叉",sessionForkMessage:"消息分叉",sessionForkReconstructed:"重建分叉",subagentExpand:"展开子代理列表",subagentCollapse:"收起子代理列表",subagentExpandMore:"展开更多子会话",favoriteExpandMore:"显示更多收藏",sessionExpandMore:"显示更多会话",archiveExpandMore:"查看更多归档会话",worktreeCollapse:"收起工作树",worktreeExpand:"展开工作树",workspaceCollapse:"收起项目",workspaceExpand:"展开项目",reorderWorkspace:"拖拽调整项目顺序",switchWorkspace:"切换到此项目",workspaceReorderFailed:"项目排序保存失败",workspaceCollapseStateSaveFailed:"项目折叠状态保存失败",workspaceHomeSwitcherLabel:"切换工作区",workspaceHomeSwitcherTitle:"工作区",hostWorkspaceSwitcherTitle:"HOST 与工作区",hostSwitcherAriaLabel:"切换 HOST",hostSwitcherTitle:"HOST 切换",hostSwitcherCurrentBadge:"当前",hostSwitcherNodeBadge:"HOST",hostSwitcherAddAction:"新增 HOST",hostSwitcherNameLabel:"HOST 名称",hostSwitcherNamePlaceholder:"例如:办公室 Host",hostSwitcherUrlLabel:"HOST 地址",hostSwitcherUrlPlaceholder:"例如:http://192.168.1.20:3002",hostSwitcherSaveAction:"保存 HOST",hostSwitcherSwitching:"切换中",hostSwitcherWorkspaceCount:"{count} 个工作区",hostSwitcherWorkspaceCountWithUser:"{username} · {count} 个工作区",hostSwitchFailed:"切换 HOST 失败",hostSwitchUnreachable:"{name} 当前不可达",hostSwitchMissing:"目标 HOST 不存在",hostAddInvalidUrl:"HOST 地址无效",hostAddDuplicate:"这个 HOST 已经存在",hostAddFailed:"新增 HOST 失败",hostAddSuccess:"已新增 HOST:{name}",mobileWorktreeBadge:"工作树",workspaceHomeStatusSectionTitle:"当前工作区",workspaceHomeViewAllAction:"查看全部会话",workspaceHomeMetricActive:"活动",workspaceHomeMetricUnread:"通知",workspaceHomeMetricTerminal:"终端",workspaceHomeMetricChanges:"变更",workspaceHomeActiveSessionsSectionTitle:"活动会话",workspaceHomeQuickLaunchStatusLabel:"快捷启动进程",workspaceHomeQuickLaunchRunning:"运行中",workspaceHomeQuickLaunchStopped:"未运行",workspaceHomeWaitingInputLabel:"等待输入",workspaceHomeButlerLabel:"助手",mobileButlerEntry:"助手",mobileConversationToolCloseAction:"返回对话",mobileConversationToolTabsLabel:"文件、Git 与进程标签",mobileConversationToolProcessesTab:"进程",mobileButlerEmptyTitle:"助手还没准备好",mobileButlerEmptyBody:"当前还没有完成助手初始化,先在桌面端做完首轮初始化,再回到手机端看跟进和自动化。",butlerProjectSyncEmptyState:"直接给助手一句明确目标,它就会在这里继续推进当前工作。",mobileButlerSummaryTitle:"当前工作区摘要",mobileButlerSummaryProjects:"项目",mobileButlerSummaryFollowUps:"进行中任务",mobileButlerSummaryWaitingUser:"待你处理",mobileButlerSummaryInbox:"未完成代办",mobileButlerAssistantWorkspaceLabel:"助手工作目录",mobileButlerAssistantToneLabel:"沟通风格",mobileButlerAssistantLanguageLabel:"工作语言",mobileButlerAssistantUpdatedAtLabel:"最近更新",workspaceOverviewTitle:"把项目入口放到看得见的地方",workspaceOverviewBody:"先选项目,再决定是继续已有会话,还是开一条新的工作链路。",workspaceListBody:"这里保留当前工作台里的全部项目,并把高频操作直接放到首页。",workspaceDetailTitle:"项目详情",workspaceDetailSummaryTitle:"项目概览",workspaceDetailSummaryBody:"先看当前项目路径、Git 摘要和代码规模,再决定下一步去哪做事。",workspaceDetailMissingTitle:"没找到这个项目",workspaceDetailMissingBody:"这个项目可能已经被移除,或者当前快照还没加载到它。",workspaceDetailDebugTitle:"服务状态",manageWorkspaceDebugDescription:"查看当前项目里的服务识别结果、最近一次启动情况和支持说明。",workspaceDetailDebugAnalyzeFailed:"读取服务状态失败",workspaceDetailDebugFrameworkLabel:"识别类型",workspaceDetailDebugConfidenceLabel:"识别把握",workspaceDetailDebugCompatibilityLabel:"可用程度",workspaceDetailDebugInjectionLabel:"推荐处理方式",workspaceDetailDebugRuntimeStatusLabel:"当前状态",workspaceDetailDebugFailureStageLabel:"卡住位置",workspaceDetailDebugServiceDiscoveryLabel:"服务地址处理",workspaceDetailDebugHmrLabel:"热更新处理",workspaceDetailDebugCallbackLabel:"回调处理",workspaceDetailDebugAiFallbackLabel:"人工处理策略",workspaceDetailDebugFrameworkNoteLabel:"说明",workspaceDetailDebugReasonsLabel:"当前说明",workspaceDetailDebugFilesLabel:"参考文件",workspaceDetailDebugFailureStageEmpty:"暂无",workspaceDetailDebugRuntimeEmpty:"当前还没有运行记录。",workspaceDetailDebugFrameworkNoteEmpty:"当前没有额外兼容说明。",workspaceDetailDebugEmptyReasons:"暂无",workspaceDetailDebugEmptyFiles:"暂无",workspaceDetailDebugConfidenceHigh:"高",workspaceDetailDebugConfidenceMedium:"中",workspaceDetailDebugConfidenceLow:"低",workspaceDetailDebugCompatibilitySupported:"可以直接使用",workspaceDetailDebugCompatibilityConditional:"需要补充处理",workspaceDetailDebugCompatibilityUnsupported:"暂不建议直接使用",workspaceDetailDebugCompatibilityUnknown:"未知",workspaceDetailDebugInjectionCli:"启动参数",workspaceDetailDebugInjectionEnv:"环境变量",workspaceDetailDebugInjectionOverride:"调整启动命令",workspaceDetailDebugInjectionAiFallback:"需要人工辅助",workspaceDetailDebugInjectionNone:"暂不自动处理",workspaceDetailDebugRuntimePreparing:"准备中",workspaceDetailDebugRuntimeRunning:"运行中",workspaceDetailDebugRuntimeFailed:"启动失败",workspaceDetailDebugRuntimeStopped:"已停止",workspaceDetailDebugRuntimeNotStarted:"未启动",workspaceDetailDebugRequirementRequired:"需要补充",workspaceDetailDebugRequirementNotRequired:"不需要补充",workspaceDetailDebugAiPolicyNever:"不建议自动处理",workspaceDetailDebugAiPolicyConditional:"视情况处理",workspaceDetailDebugAiPolicyAllowed:"可以处理",workspaceDetailDebugRuntimeServicesTitle:"最近一次启动",workspaceDetailDebugRuntimeHistoryTitle:"最近几次启动记录",workspaceDetailDebugRuntimeHistoryTimeLabel:"启动时间",workspaceDetailDebugRuntimeHistoryServiceLabel:"涉及服务",workspaceDetailDebugRuntimeHistoryResultLabel:"结果",workspaceDetailDebugRuntimeHistoryTitleWithIndex:"启动记录 #{id}",workspaceDetailDebugRuntimeHistoryFailedSummary:"这次启动里,{services} 没有正常启动。",workspaceDetailDebugRuntimeHistoryGenericSummary:"这里保留最近几次启动结果,方便回看问题是否重复出现。",workspaceDetailDebugRuntimeHistoryNoServices:"暂无",workspaceDetailDebugRuntimeHistoryResultRunning:"仍在运行",workspaceDetailDebugRuntimeHistoryResultFailed:"启动失败",workspaceDetailDebugRuntimeHistoryResultStopped:"已结束",workspaceDetailDebugRuntimeHistoryResultPreparing:"准备中",workspaceDetailDebugRuntimeServicePortLabel:"分配端口",workspaceDetailDebugRuntimeServiceBindingLabel:"端口状态",workspaceDetailDebugRuntimeServiceProcessLabel:"服务进程",workspaceDetailDebugRuntimeServiceFailureLabel:"问题位置",workspaceDetailDebugRuntimeServiceAiLabel:"人工处理记录",workspaceDetailDebugDetectedServicesTitle:"识别到的服务",workspaceDetailDebugServicePathLabel:"所在位置",workspaceDetailDebugServiceFrameworkLabel:"识别结果",workspaceDetailDebugServiceCommandLabel:"启动方式",workspaceDetailDebugServiceRequirementsLabel:"需要补充处理",workspaceDetailDebugServiceActionLabel:"建议动作",workspaceDetailDebugOpenPageAction:"服务调试",workspaceDetailDebugPageTitle:"服务调试",workspaceDetailDebugPageDescription:"这里集中查看当前项目里的服务、最近一次启动情况和支持说明。",workspaceDetailDebugPageHeroEyebrow:"项目服务概览",workspaceDetailDebugOverallStatusLabel:"整体状态",workspaceDetailDebugOverallSummaryLabel:"整体说明",workspaceDetailDebugOverallStatusSupported:"可以直接启动",workspaceDetailDebugOverallStatusConditional:"部分服务还要补充设置",workspaceDetailDebugOverallStatusBlocked:"当前不建议整体直接启动",workspaceDetailDebugOverallSummaryEmpty:"暂时还没拿到可用的服务检查结果。",workspaceDetailDebugOverallSummaryMixed:"当前识别到 {webCount} 个网页服务,以及 {desktopCount} 个桌面壳服务。桌面壳服务会单独展示,不参与网页服务的自动处理。",workspaceDetailDebugOverallSummaryDesktopOnly:"当前识别到 {count} 个桌面壳服务,还没有明确识别出网页服务。",workspaceDetailDebugOverallSummaryWebOnly:"当前识别到 {count} 个可以参与网页调试的服务。",workspaceDetailDebugSummaryServiceCountLabel:"服务总数",workspaceDetailDebugSummaryWebCountLabel:"网页服务",workspaceDetailDebugSummaryDesktopShellCountLabel:"桌面壳服务",workspaceDetailDebugSummaryWebServicesChip:"{count} 个网页服务",workspaceDetailDebugSummaryDesktopShellChip:"{count} 个桌面壳",workspaceDetailDebugSummaryUnsupportedChip:"{count} 个阻断项",workspaceDetailDebugAutoInjectionEligible:"当前网页服务已经满足自动处理条件",workspaceDetailDebugAutoInjectionBlocked:"当前还不建议把整个项目当成可自动处理目标",workspaceDetailDebugDesktopShellSummaryHint:"桌面壳服务单独识别,不参与网页服务协调",workspaceDetailDebugCompatibilityBreakdown:"可直接使用 {supported} / 需要补充 {conditional} / 暂不建议 {unsupported}",workspaceDetailDebugLastAnalyzedAtLabel:"最近检查时间",workspaceDetailDebugTargetSourceRepo:"检查范围:仓库根目录",workspaceDetailDebugTargetSourceWorktree:"检查范围:当前工作树",workspaceDetailDebugRequirementsNone:"目前没有额外要求",workspaceDetailDebugServiceSectionDescription:"把项目拆成单个服务来看,方便确认哪些可以直接启动,哪些还要补充设置。",workspaceDetailDebugRuntimeSectionDescription:"这里只显示最近一次启动结果,方便快速确认是哪一个服务没有正常跑起来。",workspaceDetailDebugMatrixSectionDescription:"这里展示不同类型服务的默认支持情况,帮助你判断下一步怎么处理。",workspaceDetailDebugMatrixTitle:"支持说明",workspaceDetailDebugMatrixOpenAction:"查看支持矩阵",workspaceDetailDebugMatrixModalDescription:"把不同服务类型的默认支持情况放到一张矩阵里,别再靠长列表硬扫。",workspaceDetailDebugMatrixFrameworkHeader:"框架",workspaceDetailDebugMatrixCompatibilityHeader:"支持",workspaceDetailDebugMatrixInjectionHeader:"方式",workspaceDetailDebugMatrixDiscoveryHeader:"发现",workspaceDetailDebugMatrixHmrHeader:"HMR",workspaceDetailDebugMatrixCallbackHeader:"回调",workspaceDetailDebugMatrixAiHeader:"人工",workspaceDetailDebugMatrixNotesHeader:"说明",workspaceDetailDebugMatrixCompatibilitySupportedShort:"可直接",workspaceDetailDebugMatrixCompatibilityConditionalShort:"先补充",workspaceDetailDebugMatrixCompatibilityUnsupportedShort:"不建议",workspaceDetailDebugMatrixCompatibilityUnknownShort:"未知",workspaceDetailDebugMatrixInjectionCliShort:"参数",workspaceDetailDebugMatrixInjectionEnvShort:"环境",workspaceDetailDebugMatrixInjectionOverrideShort:"改命令",workspaceDetailDebugMatrixInjectionAiFallbackShort:"人工",workspaceDetailDebugMatrixInjectionNoneShort:"无",workspaceDetailDebugMatrixRequirementRequiredShort:"需处理",workspaceDetailDebugMatrixRequirementNotRequiredShort:"无需",workspaceDetailDebugMatrixAiNeverShort:"不处理",workspaceDetailDebugMatrixAiConditionalShort:"视情况",workspaceDetailDebugMatrixAiAllowedShort:"可处理",workspaceDetailDebugMatrixLegendSummary:"表格里的图标含义是:勾表示默认可过,警示表示启动前还要补设置,叉表示当前不建议自动处理。下面把短表头补成人话,省得你猜。",workspaceDetailDebugMatrixDiscoveryNote:"服务地址、代理、rewrites 这一类处理。",workspaceDetailDebugMatrixHmrNote:"热更新、前端开发长连这类处理。",workspaceDetailDebugMatrixCallbackNote:"登录回调、OAuth、Webhook 这类回调入口。",workspaceDetailDebugMatrixAiNote:"遇到边界情况时,是否允许转人工辅助。",workspaceDetailDebugFailureStageServiceDiscovery:"还缺少服务地址相关处理",workspaceDetailDebugFailureStageHmr:"还缺少热更新相关处理",workspaceDetailDebugFailureStageCallback:"还缺少回调处理",workspaceDetailDebugFailureStageAiFallbackRequired:"需要转人工处理",workspaceDetailDebugFailureStageAdapterSelection:"还没找到合适的启动方式",workspaceDetailDebugFailureStageLaunchRequirements:"启动前还有条件没有满足",workspaceDetailDebugFailureStageCommandExecution:"启动命令没有正常执行",workspaceDetailDebugFailureStageProcessExit:"服务启动后很快退出了",workspaceDetailDebugFailureStageProcessRuntimeError:"服务运行时出现错误",workspaceDetailDebugFailureStageStaleRuntimeBinding:"这次启动记录已经失效",workspaceDetailDebugFailureStageUnknown:"未知阶段({code})",workspaceDetailDebugBindingAllocated:"已分配",workspaceDetailDebugBindingListening:"可访问",workspaceDetailDebugBindingFailed:"未就绪",workspaceDetailDebugBindingReleased:"已释放",workspaceDetailDebugBindingUnknown:"未知",workspaceDetailDebugProcessCreating:"启动中",workspaceDetailDebugProcessRunning:"运行中",workspaceDetailDebugProcessClosed:"已结束",workspaceDetailDebugProcessError:"异常",workspaceDetailDebugProcessUnknown:"未知",workspaceDetailDebugPortEmpty:"暂无",workspaceDetailDebugRoleFrontend:"网页服务",workspaceDetailDebugRoleBackend:"后端服务",workspaceDetailDebugRoleWorker:"后台任务",workspaceDetailDebugRoleMock:"模拟服务",workspaceDetailDebugRoleDesktopShell:"桌面壳服务",workspaceDetailDebugRoleCustom:"自定义",workspaceDetailDebugServiceOverviewSupported:"这个服务已经识别清楚,按推荐方式处理后通常可以直接启动。",workspaceDetailDebugServiceOverviewConditional:"这个服务已经识别出来,但启动前还需要补充一些设置或配套处理。",workspaceDetailDebugServiceOverviewUnsupported:"这个服务目前不建议直接自动处理,建议先手动确认启动方式。",workspaceDetailDebugServiceOverviewUnknown:"这个服务还没有识别清楚,先保留结果,后续再补充判断。",workspaceDetailDebugServiceOverviewDesktopShell:"这是桌面壳服务,会单独展示,不参与网页服务的自动端口处理。",workspaceDetailDebugServiceActionSupported:"可直接启动",workspaceDetailDebugServiceActionConditional:"先补配置",workspaceDetailDebugServiceActionUnsupported:"建议手动处理",workspaceDetailDebugServiceActionUnknown:"先确认服务类型",workspaceDetailDebugServiceActionDesktopShell:"按桌面壳方式单独处理",workspaceDetailDebugAiEditEmpty:"无",workspaceDetailDebugAiEditPending:"待处理",workspaceDetailDebugAiEditApplied:"已应用",workspaceDetailDebugAiEditRolledBack:"已回滚",workspaceDetailDebugAiEditRejected:"已拒绝",workspaceSessionListBody:"项目里的会话、收藏和归档操作都收在这里,不再让你先去翻侧栏。",recentSessionsSectionTitle:"最近会话",recentSessionsSectionBody:"先回到最近在做的事情,别让手机端还要你猜入口。",currentWorkspaceSectionTitle:"当前项目会话",currentWorkspaceSectionBody:"当前项目下的会话都集中在这里,方便继续刚才的上下文。",sessionIndexTitle:"会话入口单独成页",sessionIndexBody:"最近、收藏、当前项目三块分开看,手机上找会话别再靠侧栏折叠。",toolsMoreAction:"更多",toolsSwipeHint:"左右滑动切换文件管理和 Git 管理",toolsSwipePosition:"{current} / {total}",toolFilesBody:"查看项目文件、变更文件和代码上下文,不再靠桌面右栏概念。",toolGitBody:"把当前项目的 Git 状态、提交和分支操作收进一个明确入口。",toolTerminalsBody:"进入终端主页面,处理输入密集和滚动密集的操作。",toolProcessesBody:"查看当前项目的终端模板、运行状态和进程入口。",toolsWorkspaceRequiredBody:"先选一个项目,再打开对应的工具页。",createSession:"新建会话",createSessionModalTitle:"选择新会话类型",createSessionModalDescription:"先选会话类型,再启动真正的会话进程。",createSessionWorkspaceLabel:"选择工作区",createSessionProviderLabel:"选择供应商",createSessionTarget:"当前项目",createWorktreeSectionTitle:"子工作区",createWorktreeSectionDescription:"先从当前项目分出子工作区,再决定用哪个供应商开新会话。",createWorktreeAction:"新增子工作区",createWorktreeCollapseAction:"收起子工作区表单",createWorktreeBranchLabel:"分支名",createWorktreeBranchPlaceholder:"例如:feat/login-codex",createWorktreeBranchRequired:"请先输入子工作区分支名",createWorktreeBranchInvalid:"分支名只能包含英文、数字、-、_、/,并且不能以 / 开头、结尾或连续出现 /",createWorktreeDisplayNameLabel:"显示名称(可选)",createWorktreeDisplayNamePlaceholder:"默认沿用分支名",createWorktreeBaseRefLabel:"从哪个分支/提交创建(可选)",createWorktreeBaseRefPlaceholder:"默认沿用当前分支",createWorktreeBaseRefHint:"可选当前仓库的本地分支 {localCount} 个、远端分支 {remoteCount} 个、标签 {tagCount} 个;也可以手填 commit hash。",createWorktreeBaseRefLoading:"正在读取当前仓库的分支和标签...",createWorktreeBaseRefLoadFailed:"分支和标签列表读取失败,仍然可以手动输入分支、标签或 commit hash。",createWorktreeBaseRefLocalGroup:"本地分支",createWorktreeBaseRefRemoteGroup:"远端分支",createWorktreeBaseRefTagGroup:"标签",createWorktreeBaseRefCurrentBadge:"当前分支",createWorktreeBaseRefRecommendedBadge:"推荐",createWorktreeBaseRefEmpty:"没有找到匹配项。你也可以直接输入想使用的分支、标签或 commit hash。",createWorktreeBaseRefToggle:"展开可选分支和标签",createWorktreeHelpAction:"填写说明",createWorktreeHelpTitle:"这三个内容怎么填",createWorktreeHelpBranchTitle:"分支名",createWorktreeHelpBranchBody:"这是新子工作区自己的名字,后面在列表里也会用它区分。一般填类似 feat/login 这种短名字就够了。",createWorktreeHelpDisplayNameTitle:"显示名称",createWorktreeHelpDisplayNameBody:"如果你想让列表里更好认,可以填一个更直白的名字。不填也没关系,系统会直接用分支名。",createWorktreeHelpBaseRefTitle:"从哪个分支/提交创建",createWorktreeHelpBaseRefBody:"这决定新子工作区从哪里开始。大多数时候保持默认就行;只有你想从别的分支、标签,或者某次提交继续时再改。",createWorktreeSubmit:"创建子工作区",createWorktreeSubmitting:"创建中...",createWorktreeSucceeded:"子工作区已创建:{name}",createWorktreeFailed:"创建子工作区失败",providerClaudeCode:"Claude Code",providerCodexDescription:"创建 Codex 会话,适合继续当前默认工作流。",providerClaudeDescription:"创建 Claude Code 会话,适合切换另一条会话链路。",providerOpenCodeDescription:"创建 OpenCode 会话,适合通过 OpenCode server 延续当前上下文。",providerGeminiDescription:"创建 Gemini 会话,适合接入 Gemini CLI 的原生工作流。",providerKimiDescription:"创建 Kimi 会话,适合接入 Kimi CLI 的原生工作流。",providerOptionHint:"选择后会立即创建会话",providerChecking:"检查中...",startClaude:"Claude",startCodex:"Codex",startingSession:"创建中...",startClaudeSuccess:"Claude 会话已创建",startCodexSuccess:"Codex 会话已创建",startSessionFailed:"创建失败",auxiliaryTitle:"信息",auxiliarySubtitle:"文件与 Git 状态",expandAuxiliary:"展开",collapseAuxiliary:"收起",auxiliaryEmptyTitle:"选择一个会话",auxiliaryEmptyBody:"会话文件和 Git 信息将显示在这里",batchSelectSessions:"批量选择会话",batchSelectionMode:"批量选择",selectAllSessions:"全选",clearSelectedSessions:"清空选择",batchArchiveAction:"归档已选",batchArchiving:"归档中...",batchArchiveSuccess:"已归档选中的会话",batchArchivePartialFailed:"部分会话归档失败,请重试",batchArchiveFailed:"批量归档失败",hideSessionSidebar:"隐藏会话列表",showSessionSidebar:"显示会话列表",hideInfoSidebar:"隐藏信息栏",showInfoSidebar:"显示信息栏",centerTabsLabel:"中间区域标签",infoTabsLabel:"信息栏标签",leftResizerLabel:"调整左侧宽度",rightResizerLabel:"调整右侧宽度",filesPanelEmpty:"先导入或选中一个项目,文件管理才能显示。",gitPanelEmpty:"先导入或选中一个工作区,Git 信息才能显示。",infoPanelDeferred:"左侧会话列表优先加载,右侧附属面板稍后再挂载。"},workbench:{emptyEyebrow:"开始",emptyTitle:"先选一个会话",emptyBody:"从左侧继续之前的内容,或新建一个会话。",emptyResumeTitle:"继续",emptyResumeBody:"回到上次停下的地方。",emptyNewTitle:"新建",emptyNewBody:"把新问题放进新会话。",emptyCompanionTitle:"查看辅助信息",emptyCompanionBody:"需要文件、Git 或终端时,再看右侧。",emptyTip:"准备好后,从左侧选一个会话开始。"},conversation:{resendButton:"重发",historyLoading:"加载中...",historyLoadingOlder:"加载更早的消息...",historyLoadFailed:"加载失败",inheritedContextLoading:"正在整理从父会话继承的上下文...",inheritedContextMessageLabel:"继承自某条消息之前的上下文",inheritedContextSessionLabel:"继承自主会话的上下文",inheritedContextSummary:"已默认折叠从“{parentTitle}”继承的 {count} 条消息。",actionInheritedSelectionSummary:"已默认折叠来自“{parentTitle}”的一段选中文本。",inheritedContextExpand:"展开完整上文",inheritedContextCollapse:"收起继承上文",inheritedContextParentFallback:"父会话",timelineEmpty:"开始对话",composerPlaceholder:"把下一步交代清楚,剩下的交给这条会话继续跑。",sendButton:"发送消息",attachFiles:"附加文件",attachmentSourceSheetTitle:"添加附件",attachmentSourceSheetDescription:"可以从文件中选择一个或多个文件,也可以直接拍照。",attachmentTakePhoto:"拍照",attachmentTakePhotoHint:"直接打开相机添加一张照片",attachmentChooseFromLibrary:"从文件中选择",attachmentChooseFromLibraryHint:"通过系统文件选择器添加一个或多个文件",pasteImagesHint:"支持直接粘贴文件",attachmentImageOnly:"当前只支持图片附件",attachmentReadFailed:"附件读取失败,请重试",attachmentPreviewAlt:"已选图片预览",attachmentPreviewOpen:"打开附件",attachmentPreviewClose:"关闭预览",attachmentPreviewLoading:"附件加载中",attachmentPreviewUnavailable:"附件暂时不可用",attachmentDownload:"下载附件",attachmentDropHint:"拖拽文件到这里即可添加",imageAttachmentLabel:"图片附件",fileAttachmentLabel:"文件附件",imagePreviewTitle:"图片预览",imagePreviewHint:"点击遮罩或按 Esc 可以关闭预览",removeAttachment:"移除附件",selectionTodoAction:"代办",selectionActionButton:"操作",selectionActionSubmit:"新开操作子会话",selectionActionPromptLabel:"你想让它做什么",selectionActionPromptPlaceholder:"比如:解释这段话、整理成笔记,或调用指定接口处理它",selectionActionIncludeContext:"包含当前上下文",selectionActionContextUnavailable:"当前选区跨了多条消息,没法安全继承上下文,只能按无上下文新建子会话。",selectionActionDefaultPrompt:"请处理这段内容。",selectionActionQuotedLabel:"选中文本",selectionActionFailed:"创建操作子会话失败。",actionSessionBadge:"操作",modelSelectorLabel:"选择模型",modelUseCliDefault:"默认",modelUseCodexConfig:"跟随当前 Codex 配置",modelUseOpenCodeConfig:"跟随当前 OpenCode 配置",reasoningSelectorLabel:"选择推理强度",reasoningLow:"低",reasoningMedium:"中",reasoningHigh:"高",reasoningMaximum:"极高",slashMenu:"命令",slashMenuTitle:"快捷命令",slashCommandPlan:"先让对方给出执行路线",slashCommandReview:"直接进入代码审查模式",slashCommandExplain:"要求用更清楚的方式解释",toolInputLabel:"输入",toolResultLabel:"结果",toolResultEmpty:"暂无输出",toolPreviewCommand:"命令",toolPreviewTerminal:"终端",toolStatusRunning:"运行中",toolStatusFailed:"已失败",toolStatusCompleted:"已完成",runtimeThinkingPlaceholder:"{provider} 正在思考...",applyPatchEditedLabel:"已编辑",applyPatchAddedLabel:"已新增",applyPatchDeletedLabel:"已删除",applyPatchDialogTitle:"Patch 变更预览",applyPatchDialogDescription:"这里按文件显示 apply_patch 将要执行的变更。",applyPatchOpenDiff:"查看 diff",applyPatchAddedStat:"新增",applyPatchRemovedStat:"减少",applyPatchEmpty:"这个 patch 暂时没有可展示的文件变更。",titleFallback:"继续对话",draftTitleCodex:"New Codex session",draftTitleClaude:"New Claude Code session",draftTitleOpenCode:"New OpenCode session",draftTitleGemini:"New Gemini session",draftTitleKimi:"New Kimi session",headerWorkspace:"工作区",headerWorkspaceUnknown:"未知工作区",headerProvider:"Provider",headerConnection:"连接",headerRuntime:"运行态",providerCodex:"Codex",branchTreeAction:"分支树",branchTreeTitle:"分支树",branchTreeDescription:"这里只看当前会话所在的父子链,不把整个工作区会话列表混进来。",branchTreeUpstreamLabel:"上游链路",branchTreeCurrentLabel:"当前会话",branchTreeChildrenLabel:"下游分支",branchTreeCurrentBadge:"当前",branchTreeArchivedBadge:"已归档",branchTreeEmpty:"这条会话当前还没有下游分支。",branchTreeMapTitle:"分支关系图",branchTreeMapDescription:"这里会把当前会话所在主干和所有关联分支一起展开。",branchTreePreviewTitle:"会话预览",branchTreePreviewDescription:"点一下节点就会浮出最近几条消息,再决定要不要切过去。",branchTreePreviewLoading:"正在读取这条会话的最近消息...",branchTreePreviewFailed:"会话预览读取失败。",branchTreePreviewEmpty:"这条会话最近没有可预览的消息。",branchTreeResizeHandle:"调整分支树宽度",branchTreeZoomInAction:"放大分支图",branchTreeZoomOutAction:"缩小分支图",branchTreeZoomResetAction:"重置分支图缩放",branchTreeSwitchAction:"切换到这个会话",branchTreeCurrentAction:"已在当前会话",branchTreeToolMessageFallback:"工具消息",branchTreeMessageEmpty:"这条消息当前没有可展示的正文。",moreSessionActions:"更多会话操作",moreSessionActionsTitle:"更多会话操作",moreSessionActionsDescription:"分支树和助手入口统一收在这里,避免移动端标题栏被按钮挤满。",branchTreeTab:"分支树",aiAssistantTab:"助手",aiAssistantTabDescription:"这里保留当前会话的助手入口,需要继续跟进或发起验证时直接点下面这个按钮。",providerClaude:"Claude",providerOpenCode:"OpenCode",providerGemini:"Gemini",providerKimi:"Kimi",capabilitySend:"可发送",queueTitle:"待发队列",queueDescription:"当前运行结束后,会按顺序自动继续处理下面的消息。",queueOrderPrefix:"等待顺序",queueStatusQueued:"等待中",queueStatusFailed:"续跑失败",queueDelete:"删除",queueDeleting:"删除中",permissionRequestSectionTitle:"待处理审批",permissionRequestSectionDescription:"这里把供应商原生的权限申请统一收口,不再让你面对三套不同的确认框。",permissionRequestToastTitle:"需要审批",backgroundPermissionToastDescription:"{title} · {requestTitle}",backgroundCompletionToastTitle:"会话已完成",backgroundCompletionToastDescription:"{title}",backgroundFailureToastTitle:"会话异常",backgroundFailureToastDescription:"{title} · {detail}",permissionRequestReplyFailed:"回复权限申请失败。",permissionRequestSubmitting:"提交中...",permissionRequestReasonLabel:"原因",permissionRequestCommandLabel:"命令",permissionRequestToolLabel:"工具",permissionRequestCwdLabel:"工作目录",permissionRequestPathsLabel:"相关路径",permissionRequestPermissionsLabel:"申请权限",permissionRequestReadLabel:"读取",permissionRequestWriteLabel:"写入",permissionRequestNetworkLabel:"网络",permissionRequestQuestionsLabel:"补充问题",permissionRequestDetailLabel:"详情",permissionRequestEmpty:"无",permissionRequestUnknown:"未知",permissionRequestKindCommand:"命令",permissionRequestKindFileChange:"文件改动",permissionRequestKindPermissions:"权限扩展",permissionRequestKindUserInput:"补充输入",permissionRequestKindToolCall:"工具调用",queueImageOnly:"只包含图片附件",sendGuidanceButton:"追加指导",queueGuidanceButton:"加入队列",capabilityDenied:"受限",capabilitySendDisabled:"发送受限",connectionConnected:"实时已连接",connectionReconnecting:"正在重连",connectionReconnectFailed:"重连失败",connectionClosed:"连接已关闭",runtimeIdle:"空闲",runtimeStarting:"启动中",runtimeRunning:"运行中",runtimeReconnecting:"恢复中",runtimeStale:"运行待确认",runtimeUnknown:"状态待确认",runtimeCompleted:"已完成",runtimeInterrupted:"已中断",runtimeFailed:"失败",rulesMessageTitle:"规则信息",rulesMessageHint:"这是一段会话启动规则,默认折叠显示,需要时再展开查看。",rulesMessageExpand:"展开规则",rulesMessageCollapse:"收起规则",systemPromptTitle:"系统提示",systemPromptHint:"这是 Kimi 会话开头的系统提示词,默认折叠显示,需要时再展开查看。",systemPromptExpand:"展开提示词",systemPromptCollapse:"收起提示词",taskProgressButton:"任务进度({count})",taskProgressModalTitle:"任务进度",taskProgressModalDescription:"当前会话已记录 {count} 条任务,这里直接看最新进度。",taskProgressExplanationTitle:"本轮更新说明",taskProgressSummaryTotal:"总数",taskProgressStatusPending:"待处理",taskProgressStatusInProgress:"进行中",taskProgressStatusCompleted:"已完成",taskProgressStatusFailed:"已失败",taskProgressStatusCancelled:"已取消",taskCardPlanTitle:"计划更新",taskCardTodoTitle:"任务更新",taskCardPlanUpdated:"最新计划",taskCardTodoUpdated:"最新任务列表",taskCardRawExpand:"展开原始调用",taskCardRawCollapse:"收起原始调用",taskCardSummaryTotal:"共 {count} 项",taskCardSummaryInProgress:"进行中 {count}",taskCardSummaryPending:"待处理 {count}",taskCardSummaryCompleted:"已完成 {count}",taskCardSummaryFailed:"已失败 {count}",butlerActionButton:"助手",butlerActionModalTitle:"助手动作",butlerActionModalDescription:"让助手继续跟进当前开发会话,或发起一次开发验证。",butlerActionLoading:"正在连接助手记录...",butlerActionLoadFailed:"读取助手动作信息失败",butlerActionProjectLabel:"当前项目",butlerActionSessionLabel:"当前会话",butlerFollowUpAction:"跟进当前会话",butlerFollowUpActionDescription:"让助手持续盯住这条开发会话,并在结束或阻塞后继续推动。",butlerFollowUpObjectiveLabel:"跟进目标",butlerFollowUpObjectivePlaceholder:"例如:帮我把这个会话的功能真正做完,若 spec 还有未完成项就继续补齐。",butlerFollowUpCompletionCriteriaLabel:"结束条件",butlerFollowUpCompletionCriteriaPlaceholder:"例如:只有当当前功能按既定需求完成,且不再存在必须继续推进的未完成项时,才停止自动跟进。",butlerFollowUpRoundLimitLabel:"最多自动跟进轮数",butlerFollowUpRoundLimitHint:"达到上限后,助手会停止自动续接,避免无限扩展会话。",butlerCurrentFollowUpLabel:"当前跟进任务",butlerCurrentFollowUpProgress:"已自动推进 {current} / {max} 轮",butlerStopFollowUpAction:"停止当前跟进",butlerFollowUpObjectiveRequired:"请先写清楚这次希望助手持续推动的目标",butlerVerificationAction:"发起开发验证",butlerVerificationActionDescription:"让助手从用户视角对当前会话对应功能发起一次验证。",butlerFollowUpStarted:"已交给助手继续跟进",butlerFollowUpStartedDescription:"助手会继续跟进 {projectName} 的当前开发会话。",butlerFollowUpFailed:"助手跟进启动失败",butlerFollowUpStopped:"已停止当前助手跟进",butlerFollowUpStoppedDescription:"当前会话的自动跟进已经停止,不会继续自动续接。",butlerFollowUpStopFailed:"停止助手跟进失败",butlerVerificationStarted:"已发起开发验证",butlerVerificationStartedDescription:"助手会对 {projectName} 发起一次开发验证。",butlerVerificationFailed:"开发验证启动失败",butlerAnalysisTitle:"助手分析过程",butlerAnalysisLoadFailed:"读取助手分析失败",butlerAnalysisObjectiveLabel:"当前目标",butlerAnalysisStatusLabel:"当前判断",butlerAnalysisSummaryLabel:"最近分析",butlerAnalysisWaitingReasonLabel:"等待原因",butlerAnalysisEmpty:"当前还没有可展示的助手分析记录。",butlerProxyMessageBadge:"代理发送",butlerOriginDetailTitle:"对应的助手跟进",butlerOriginDetailLoading:"正在读取对应的助手跟进记录...",butlerOriginDetailLoadFailed:"读取对应的助手跟进记录失败",butlerOriginDetailObjectiveLabel:"跟进目标",butlerOriginDetailStatusLabel:"当前状态",butlerOriginDetailSummaryLabel:"最近分析",butlerOriginDetailWaitingReasonLabel:"等待原因",thinkingLabel:"思考中",filePanelWorkspaceTab:"工作区",filePanelSessionTab:"本次会话",filePanelSessionViewLabel:"本次会话视图",filePanelSessionTreeView:"树状",filePanelSessionListView:"列表",filePanelSessionLoading:"正在整理本次会话修改的文件...",filePanelSessionEmpty:"这条会话还没识别到可暂存的修改文件。",filePanelSessionNoSession:"当前只选中了项目,还没选中会话,无法查看“本次会话”文件。",filePanelSessionStageAll:"全部暂存",filePanelSessionStageSuccess:"已把本次会话的修改加入暂存区。",filePanelSessionLoadFailed:"本次会话修改文件加载失败。",filePanelSessionSummary:"已识别文件",filePanelSessionUnstagedSummary:"未暂存",filePanelSessionDeleted:"已删除",filePanelOpenExternalWindow:"在新窗口打开",filePanelOpenExternalFailed:"打开文件外部窗口失败。"},desktopWindow:{invalidWindowId:"缺少窗口 ID,无法加载外部窗口。",loadDescriptorFailed:"读取窗口描述失败。",unsupportedKind:"暂不支持渲染 {kind} 窗口。"},git:{recentVersionsTitle:"最近版本",stagedChangesTitle:"暂存的更改",expandRecentVersions:"展开最近版本",collapseRecentVersions:"折叠最近版本",stagedLabel:"暂存区",workingTreeLabel:"工作区",changeTreeHint:"按目录层级展示当前变更",discard:"放弃改动",discardFailed:"放弃改动失败",operationMenu:"操作菜单",currentBranch:"当前分支",resizePanels:"调整文件区和最近版本高度",switchBranchTo:"切换到",undoLastCommit:"撤销上次提交",undoLastCommitFailed:"撤销上次提交失败",undoLastCommitSuccess:"已撤销上次提交",historyKindLocal:"本地",historyKindRemote:"远程",historyKindShared:"已同步",pushNow:"推送",commitNow:"提交",refreshNow:"刷新",openExternalWindow:"在新窗口打开 Git",openExternalFailed:"打开 Git 外部窗口失败。",stageAll:"暂存全部",unstageAll:"取消暂存全部",discardAll:"放弃全部改动",selectedFiles:"已选文件",clearSelection:"清空选中",selectFile:"选中文件",discardConfirm:"确认放弃这些改动吗?{path}",historyItemMenu:"版本操作",copyCommitHash:"复制 Commit Hash",copyCommitHashSuccess:"Commit Hash 已复制。",copyCommitSubject:"复制提交标题",copyCommitSubjectSuccess:"提交标题已复制。"},terminalManager:{workspaceField:"当前工作区",refresh:"刷新列表",loadFailed:"终端管理面板加载失败",shellLoadFailed:"终端 Shell 列表加载失败",emptyWorkspaceBody:"还没有可用工作区。",noCurrentWorkspaceBody:"先选中一条会话,进程管理才能绑定对应的工作区。",emptyTerminalBody:"当前工作区还没有终端实例。",emptyTemplateBody:"还没有快捷启动项,可以先保存一条命令或脚本。",shellField:"新终端 Shell",shellUnavailable:"当前不可用",cwdField:"启动目录",cwdLabel:"目录",cwdPlaceholder:"留空时默认使用工作区根目录",modeField:"启动方式",commandMode:"命令",scriptMode:"脚本",quickLaunchTitle:"快捷启动",quickLaunchDescription:"先保存启动方式,需要时一键拉起到新终端。",desktopPanelDescription:"默认只看启动决策所需的信息,路径和命令行收进详情层。",openExternalWindow:"在新窗口打开",openExternalFailed:"打开进程管理外部窗口失败。",runningCountLabel:"运行中",portWatchCountLabel:"已监控端口",terminalCountLabel:"终端数",templateSectionTitle:"启动项",templateSectionDescription:"右侧优先显示启动项的端口状态,看清楚是否已被占用。",openCreateModalAction:"添加快捷启动项",createModalTitle:"添加快捷启动项",createModalDescription:"在这里保存命令或脚本,可以附带端口,后面就能一键启动并判断是否在跑。",editAction:"编辑启动项",editModalTitle:"编辑快捷启动项",editModalDescription:"直接修改这条快捷启动的名称、命令、目录和端口配置。",saveTemplateChangesAction:"保存修改",templateUpdating:"保存修改中...",templateUpdateSuccess:"快捷启动项已更新。",templateUpdateFailed:"快捷启动项更新失败",removeAction:"移除启动项",templateRemoving:"移除中...",removeConfirmTitle:"确认移除启动项",removeConfirmAction:"确认移除",removeConfirmTarget:"确认移除“{name}”吗?移除后将不再出现在快捷启动列表中。",removeRunningConfirmTarget:"“{name}”对应的进程还在跑。现在移除的是启动项配置,不会自动结束已经运行的进程。确认继续吗?",templateDeleteSuccess:"快捷启动项已移除。",templateDeleteFailed:"快捷启动项移除失败",terminalSectionTitle:"终端实例",terminalSectionDescription:"这里显示当前工作区由 CodingNS 托管的终端。",closeAction:"关闭终端",closing:"关闭中...",closeSuccess:"终端关闭请求已提交。",closeFailed:"终端关闭失败",createTerminalAction:"新建空终端",creatingTerminal:"创建中...",createTerminalSuccess:"新终端已创建。",createTerminalFailed:"新终端创建失败",defaultTerminalName:"工作终端",templateNameField:"名称",templateNamePlaceholder:"留空时会自动生成",commandField:"启动命令",commandPlaceholder:"例如:npm",scriptPathField:"脚本路径",scriptPathPlaceholder:"例如:scripts/dev.ps1 或 scripts/dev.sh",argsField:"参数",argsPlaceholder:"例如:run dev 或 --watch",portField:"监听端口",portLabel:"端口",portPlaceholder:"例如:3000",proxyField:"反向代理",proxyToggleLabel:"开启反向代理",proxyEnabled:"代理已启用",proxyEnabledDescription:"开启后会生成随机 URL 码,可通过 /proxy/地址访问当前开发服务。",proxyDisabledDescription:"未开启反向代理",proxyPortRequired:"开启反向代理时,必须同时配置端口",openProxyUrlAction:"在浏览器打开代理地址",openProxyUrlFailed:"打开代理地址失败",invalidPort:"端口必须是 1 到 65535 的整数",saveLaunchAction:"保存为快速启动",templateSaving:"保存中...",templateSaveSuccess:"快捷启动项已保存。",templateSaveFailed:"快捷启动项保存失败",runTemplateAction:"启动到新终端",runningTemplate:"启动中...",templateRunSuccess:"快捷启动已发送到新终端。",templateRunFailed:"快捷启动执行失败",showDetailsAction:"显示详细信息",hideDetailsAction:"隐藏详细信息",detailsSectionTitle:"启动项详情",commandPreviewLabel:"启动命令",processIdLabel:"监听进程 PID",processGroupIdLabel:"进程组 PGID",processCommandLabel:"监听命令行",parentProcessIdLabel:"父进程 PID",parentProcessCommandLabel:"父进程命令行",terminationScopeLabel:"结束范围",terminationScopeProcess:"仅监听进程",terminationScopeProcessGroup:"整个进程组",stopProcessAction:"结束进程",stoppingProcess:"结束中...",stopProcessSuccess:"监听进程或所属进程组已结束。",stopProcessFailed:"结束监听进程或进程组失败",defaultCommandName:"新启动命令",defaultScriptName:"新启动脚本",lastActiveAt:"最近活跃",updatedAt:"最后更新",processCommandFallback:"这个进程没有暴露命令行",portUnset:"未配置端口",portUnsetDescription:"没有端口时,只能启动,不能自动判断服务是否在跑。",portOccupied:"进程已启动",portAvailable:"端口暂未被占用",portAvailableDescription:"这个启动项对应的端口目前还没有监听进程。",statusRunning:"运行中",statusStopped:"未运行",exitCode:"Exit Code",runningValue:"运行中"},theme:{light:"浅色",dark:"深色",skyBlue:"赛博",eyeGreen:"护眼",switchLabel:"主题"}},$1={common:{close:"Close",cancel:"Cancel",logout:"Log out",language:"Language"},locale:{zhCN:"Simplified Chinese",enUS:"English"},settings:{title:"Settings",appearance:"Appearance",language:"Language",languageDescription:"Choose the display language used by the interface. The page updates immediately.",theme:"Theme",themeDescription:"Choose the color theme that fits the way you work.",connection:"Connection & Updates",serverAddress:"Server Address",serverDescription:"Desktop and H5 both work through this host entry.",releaseChannel:"Release Channel",releaseChannelDescription:"Stable or beta",releaseStable:"Stable",releaseBeta:"Beta",autoReconnect:"Auto Reconnect",autoReconnectDescription:"Retry HTTP and WebSocket links automatically when Host is briefly unavailable.",autoCheckUpdate:"Auto Check Client Updates",autoCheckUpdateDescription:"Clients only",notificationSettings:"Notifications",notificationSettingsDescription:"Control each session-related system notification independently.",notifyOnPermissionRequest:"Notify on permission requests",notifyOnPermissionRequestDescription:"Notify when a background session needs a new permission approval.",notifyOnSessionCompleted:"Notify when sessions complete",notifyOnSessionCompletedDescription:"Notify when a background session finishes.",notifyOnSessionFailed:"Notify when sessions fail",notifyOnSessionFailedDescription:"Notify when a background session fails.",enabled:"Enabled",disabled:"Disabled",serverUpdate:"Server Update",serverUpdateDescription:"",clientUpdate:"Client Update",clientUpdateDescription:"",serverCurrentVersion:"Server Current Version",serverTargetVersion:"Server Target Version",serverPackageName:"npm Package",serverUpdateCommand:"Upgrade Command",serverCheckNow:"Check Server",serverInstallNow:"Install",serverOpenPage:"Open npm",serverLatestUnknown:"Unavailable",serverUpdateReady:"New version found",serverUpToDate:"Up to date",serverCheckFailed:"Check failed",serverInstallQueued:"Queued",serverInstalling:"Installing update",serverInstallSucceeded:"Update completed",serverInstallFailed:"Install failed",serverInstallCancelled:"Install cancelled",serverInstallTimeout:"Install timed out",serverRestartRequired:"New version installed. Restart Host to apply it.",serverOpenPageFailed:"Failed to open page",runtimePlatform:"Runtime Platform",runtimePlatformDescription:"Shows whether the app is running in Web/H5, Desktop, iOS, or Android.",platformDesktop:"Desktop",platformWeb:"Web",platformIos:"iOS",platformAndroid:"Android",releaseDesktopOnly:"Desktop updates are not available in the current Web/H5 runtime.",releaseCurrentVersion:"Current Version",releaseTargetVersion:"Target Version",releaseUnknownVersion:"Unknown",releaseNotes:"What's New",releaseNotesEmpty:"No details",releaseCheckNow:"Check Client",releaseInstallNow:"Install",releaseOpenPage:"Open Release",releaseManualOnly:"This version requires manual installation",releaseUpdateReady:"New version found",releaseUpToDate:"Up to date",releaseCheckFailed:"Check failed",releaseInstallStarted:"Install started",releaseInstallFailed:"Install failed",releasePageOpenFailed:"Failed to open release page",androidInstallerStarted:"Handed off to the Android installer. You can still cancel there.",androidInstallPermissionRequired:"Allow installs from this source before retrying.",androidInstallCancelled:"Install was cancelled or not completed. You can try again.",androidInstallSucceeded:"The new version has been detected as installed.",clientUpdateUnsupported:"Install updates are not supported here",account:"Account",logout:"Log out",logoutDescription:"Sign out of the current account and return to the login page.",advancedSettings:"Advanced Settings",parallelTaskDebug:"Parallel Task Debug",parallelTaskDebugDescription:"Runtime sampling stays off until you open this panel. Use it to inspect background tasks, schedulers, and main-thread pressure in real time.",parallelTaskDebugAction:"Open Debug Panel",parallelTaskDebugModalTitle:"Parallel Task Debug",parallelTaskDebugModalDescription:"Task activity and event loop sampling only stay active while this window is open. Closing it stops collection immediately.",parallelTaskDebugClose:"Close parallel task debug",parallelTaskDebugLoading:"Opening observability session and loading runtime snapshot...",parallelTaskDebugLoadFailed:"Failed to load parallel task debug information",parallelTaskDebugEmpty:"No execution records are available right now.",parallelTaskDebugStatusActive:"Collecting",parallelTaskDebugStatusError:"Collection Error",parallelTaskDebugObservedAt:"Last Updated",parallelTaskDebugSessionExpireAt:"Session Expires At",parallelTaskDebugSessionTtl:"Session TTL",parallelTaskDebugCollectorState:"Collector State",parallelTaskDebugCollectorEnabled:"Enabled",parallelTaskDebugCollectorDisabled:"Disabled",parallelTaskDebugAutoRefresh:"Auto refresh every second",parallelTaskDebugCountersTitle:"Overall Counters",parallelTaskDebugTaskMetricsTitle:"Background Task Metrics",parallelTaskDebugSchedulerTitle:"Scheduler Metrics",parallelTaskDebugEventLoopTitle:"Event Loop",parallelTaskDebugRecentActivitiesTitle:"Recent Execution Records",parallelTaskDebugWaitAvg:"Average Wait",parallelTaskDebugRunAvg:"Average Run",parallelTaskDebugRunMax:"Longest Run",parallelTaskDebugStartedCount:"Started",parallelTaskDebugFinishedCount:"Finished",parallelTaskDebugFailedCount:"Failed",parallelTaskDebugCacheHitCount:"Cache Hits",parallelTaskDebugIdle:"Idle",parallelTaskDebugBusy:"Busy",parallelTaskDebugTickTotal:"Tick Total",parallelTaskDebugIdleTickTotal:"Idle Ticks",parallelTaskDebugTaskCountTotal:"Task Hits",parallelTaskDebugSchedulerErrorTotal:"Errors",parallelTaskDebugLastDuration:"Last Duration",parallelTaskDebugNextDelay:"Next Delay",parallelTaskDebugEventLoopResolution:"Resolution",parallelTaskDebugEventLoopMean:"Mean Delay",parallelTaskDebugEventLoopP95:"P95 Delay",parallelTaskDebugEventLoopP99:"P99 Delay",parallelTaskDebugEventLoopMax:"Max Delay",parallelTaskDebugTaskKey:"Task Key",parallelTaskDebugStatus:"Status",parallelTaskDebugAttempt:"Attempt",parallelTaskDebugWaitMs:"Wait",parallelTaskDebugRunMs:"Run",parallelTaskDebugSource:"Source",parallelTaskDebugError:"Error",parallelTaskDebugMetricEnqueue:"Enqueue",parallelTaskDebugMetricDedupe:"Dedupe",parallelTaskDebugMetricStarted:"Started",parallelTaskDebugMetricFinished:"Finished",parallelTaskDebugMetricFailed:"Failed",parallelTaskDebugMetricCancelled:"Cancelled",parallelTaskDebugMetricTimeout:"Timeout",parallelTaskDebugMetricCacheHit:"Cache Hit",parallelTaskDebugLaneRequestMainThread:"Request Main Thread",parallelTaskDebugLaneHostBackground:"Host Background",parallelTaskDebugLaneHelperProcess:"Helper Process",parallelTaskDebugLaneExternalProcess:"External Process",parallelTaskDebugEventEnqueued:"Enqueued",parallelTaskDebugEventDeduped:"Deduped",parallelTaskDebugEventStarted:"Started",parallelTaskDebugEventFinished:"Finished",parallelTaskDebugEventFailed:"Failed",parallelTaskDebugEventCancelled:"Cancelled",parallelTaskDebugEventTimeout:"Timeout",parallelTaskDebugEventCacheHit:"Cache Hit",parallelTaskDebugTaskStatusQueued:"Queued",parallelTaskDebugTaskStatusRunning:"Running",parallelTaskDebugTaskStatusSucceeded:"Succeeded",parallelTaskDebugTaskStatusFailed:"Failed",parallelTaskDebugTaskStatusCancelled:"Cancelled",parallelTaskDebugTaskStatusTimeout:"Timeout"},shell:{title:"Workbench",subtitle:"Manage AI sessions inside code projects",mobileWorkspacesEntry:"Workspaces",mobileTerminalsEntry:"Terminal",mobileSessionsEntry:"Conversation",mobileToolsEntry:"Tools",mobileSettingsEntry:"Settings",mobileNavigationAction:"Open workbench menu",mobileSearchAction:"Open search",mobileAuxiliaryAction:"Open tools panel",mobileRevealNavigationAction:"Show primary navigation",mobileHideNavigationAction:"Hide primary navigation",mobileConversationPreviewTitle:"Quick Preview",mobileConversationCurrentWorkspaceSection:"Current Workspace",mobileConversationCollapsePreviewAction:"Hide Preview",mobileConversationRestorePreviewAction:"Restore Session Preview",iosMoreAction:"More actions",androidMoreAction:"More actions",conversationEntry:"Conversation",terminalsEntry:"Terminal",butlerEntry:"Assistant",globalNotificationsAction:"Notifications",globalNotificationsUnreadAria:"{count} unread notifications",globalNotificationsPanelTitle:"Notification Center",globalNotificationsPanelDescription:"Review items waiting for your decision, todo analysis results, follow-up updates, and failed verifications.",globalNotificationsEmpty:"There are no new global notifications right now.",globalNotificationsShowArchived:"Show archived notifications",globalNotificationsArchiveAction:"Archive",globalNotificationsRemoveArchiveAction:"Remove Archive",globalNotificationsArchiveFailed:"Failed to update notification archive state",globalNotificationKindWaitingUser:"Waiting for You",globalNotificationKindTodoAnalyzed:"Todo Analyzed",globalNotificationKindTodoAnalyzeFailed:"Todo Analysis Failed",globalNotificationKindFollowUpFailed:"Follow-up Failed",globalNotificationKindFollowUpCompleted:"Follow-up Completed",globalNotificationKindVerificationFailed:"Verification Failed",globalNotificationTodoAnalyzedTitle:"Todo analysis completed: {title}",globalNotificationTodoAnalyzeFailedTitle:"Todo analysis failed: {title}",globalNotificationFollowUpWaitingTitle:"Needs your decision: {title}",globalNotificationFollowUpFailedTitle:"Follow-up failed: {title}",globalNotificationFollowUpCompletedTitle:"Follow-up completed: {title}",globalNotificationVerificationFailedTitle:"Verification failed: {title}",globalNotificationVerificationFailedFallback:"The latest verification did not pass. Please review it soon.",searchEntry:"Search",butlerInitTitle:"Initialize Assistant",butlerInitDescription:"Set the Butler name, provider, and work style first. The dedicated workspace and first AGENTS.md will be created automatically.",butlerInitPreviewTitle:"Live Preview",butlerInitPreviewDescription:"These choices directly shape the first rule set, so show the result instead of dumping a plain form.",butlerInitBasicsTitle:"Basics",butlerInitBasicsDescription:"Lock in the name, provider, and rule storage first so initialization does not become config soup.",butlerInitPersonaTitle:"Expression Style",butlerInitPersonaDescription:"Tone, language, and summary style decide how Butler speaks, not whether it gets to be sloppy.",butlerInitPreferenceTitle:"Default Priorities",butlerInitPreferenceDescription:"This decides which risks Butler watches first and what it surfaces first in reports.",butlerInitRuleLabel:"Rule Format",butlerInitTipAutoWorkspace:"The system creates the Butler workspace and first AGENTS.md automatically, so you only set the defaults here.",butlerInitTipProviderSwitch:"You can switch provider later, so do not overthink the first initialization pass.",butlerInitTipReportPriority:"Report priority changes whether Butler leads with risk, blockers, or verification results.",butlerDisplayNameLabel:"Butler Name",butlerDisplayNamePlaceholder:"Example: Arvin, Butler",butlerDisplayNameHint:"This is the Butler's self-name. The system writes it into the first generated AGENTS.md.",butlerProviderLabel:"Provider",butlerWorkspacePathLabel:"Butler Workspace Path",butlerWorkspacePathPlaceholder:"Example: /Users/you/WorkFile/butler-home",butlerAgentsModeLabel:"AGENTS Mode",butlerAgentsModeInline:"Inline",butlerAgentsModeFile:"File",butlerAgentsModeInlineDescription:"Inline: the system generates rules from your initialization choices and manages them for you.",butlerAgentsModeFileDescription:"File: the system writes AGENTS.md into the Butler workspace so you can edit the file directly later.",butlerAgentsFilePathLabel:"AGENTS.md File Path",butlerAgentsFilePathPlaceholder:"Example: /Users/you/WorkFile/butler-home/AGENTS.md",butlerAgentsContentLabel:"AGENTS Instructions",butlerAgentsContentPlaceholder:"Describe the Butler's work rules and response style",butlerAgentsContentHint:"Maintain Butler's formal rules here. Saving will write back to the dedicated AGENTS.md or inline instructions.",butlerPersonaToneLabel:"Tone",butlerPersonaLanguageLabel:"Language",butlerPersonaSummaryStyleLabel:"Summary Style",butlerFocusRiskPreferenceLabel:"Risk Preference",butlerFocusReportPriorityLabel:"Report Priorities (comma-separated)",butlerFocusReportPriorityPlaceholder:"Example: risk,blocker,verification",butlerToneDirect:"Direct and Clear",butlerToneSteady:"Steady and Controlled",butlerToneFriendly:"Friendly and Patient",butlerLanguageZhCn:"Chinese First",butlerLanguageEnUs:"English First",butlerLanguageBilingual:"Bilingual",butlerSummaryBrief:"Brief",butlerSummaryStructured:"Structured",butlerSummaryThorough:"Thorough",butlerRiskConservative:"Conservative",butlerRiskBalanced:"Balanced",butlerRiskProactive:"Proactive",butlerReportPriorityPresetLabel:"Report Priority",butlerReportRiskFirst:"Risk First",butlerReportBlockerFirst:"Blockers First",butlerReportVerificationFirst:"Verification First",butlerReportProgressFirst:"Progress First",butlerSummaryDebounceLabel:"Session Summary Debounce",butlerSummaryDebounceOption1Minute:"1 minute",butlerSummaryDebounceOption3Minutes:"3 minutes",butlerSummaryDebounceOption5Minutes:"5 minutes (default)",butlerSummaryDebounceOption10Minutes:"10 minutes",butlerSummaryDebounceOption15Minutes:"15 minutes",butlerSummaryDebounceOption30Minutes:"30 minutes",butlerSettingsTitle:"Butler Settings",butlerSettingsSaveAction:"Save Settings",butlerSettingsSaving:"Saving...",butlerSettingsSaved:"Butler settings saved",butlerSettingsSaveFailed:"Failed to save Butler settings",butlerInitSubmitting:"Initializing...",butlerInitSubmit:"Initialize Butler",butlerInitSuccess:"Assistant initialized",butlerInitFailed:"Failed to initialize Assistant",butlerInitNameRequired:"Assistant name is required",butlerInitWorkspaceRequired:"Assistant workspace path is required",butlerInitAgentsFileRequired:"AGENTS.md path is required in file mode",butlerWorkbenchTitle:"Assistant Workbench",butlerWorkbenchSubtitle:"Chat with Butler here and review aggregated context with action events.",butlerWorkspaceHint:"Butler workspace: {workspacePath}",butlerDisplayNameActiveHint:"Current Butler name: {displayName}",butlerNewSessionAction:"New Session",butlerNewSessionStarted:"Started a fresh Butler session",butlerNewSessionFailed:"Failed to start a fresh Butler session",butlerRefreshAction:"Refresh",butlerHistoryAction:"History",butlerHistoryTitle:"Assistant History",butlerHistoryDescription:"All assistant sessions are kept here, including todo analysis runs and regular chats.",butlerHistoryEmpty:"There is no assistant history yet.",butlerHistoryOpenAction:"Open Session",butlerCurrentSessionBadge:"Current",butlerControlSessionKindChat:"Chat",butlerControlSessionKindTodoAnalysis:"Todo Analysis",butlerLoadingTitle:"Loading Butler",butlerLoadingDescription:"Pulling the current assistant session, summaries, and control state. Please wait a moment.",butlerSidebarInfoTab:"Info",butlerSidebarAutomationTab:"Automation",butlerSidebarSettingsTab:"Settings",butlerSidebarTabsLabel:"Butler sidebar tabs",butlerSidebarLoadFailed:"Failed to load Butler sidebar",butlerInfoContextTitle:"Current Context",butlerInfoContextDescription:"Show only what the Butler is using in this round, without flooding the panel with unrelated details.",butlerInfoCurrentScopeLabel:"Current Scope",butlerInfoCurrentScopeProject:"Project: {projectName}",butlerInfoCurrentScopeGlobal:"Global Overview",butlerInfoManagedProjectsLabel:"Tracked Projects",butlerInfoManagedProjectsValue:"Active {activeCount} / Total {totalCount}",butlerInfoCurrentContextProjectHint:"{projectName} is selected, so follow-up lookups will stay centered on this project first.",butlerInfoCurrentContextGlobalHint:"The Butler is still in global view. It only drills down when you pick a project or ask for details.",butlerInfoProjectSelectedAction:"Currently Selected",butlerInfoProjectViewAction:"View Project",butlerInfoProjectBlockedBadge:"Blocked",butlerInfoProjectRiskBadge:"Risk: {riskLevel}",butlerInfoProjectRiskShortBadge:"Risk {riskLevel}",butlerInfoProjectLastActivityBadge:"Active: {updatedAt}",butlerInfoLatestSessionAction:"Open Latest Session",butlerInfoProgressTitle:"Current Progress",butlerInfoAttentionTitle:"Watch For",butlerInfoNextStepTitle:"Next Step",butlerInfoFollowUpRecordsTitle:"Follow-up Records",butlerInfoFollowUpRecordsDescription:"Only the latest 5 follow-up states are shown here; open the full history for more.",butlerInfoFollowUpRecordsEmpty:"No follow-up records yet.",butlerInfoFollowUpUntitled:"Untitled Session",butlerInfoFollowUpFallback:"Last updated: {updatedAt}",butlerFollowUpHistoryAction:"View History",butlerFollowUpHistoryTitle:"Follow-up History",butlerFollowUpHistoryDescription:"Review the complete follow-up status history and continue drilling into round details.",butlerInfoVerificationRecordsTitle:"Verification Records",butlerInfoVerificationRecordsDescription:"A global view of feature verification records.",butlerInfoVerificationRecordsEmpty:"No verification records yet.",butlerInfoVerificationFallback:"Current status: {status}",butlerInfoTodoRecordsTitle:"Todo Progress",butlerInfoTodoRecordsDescription:"A global view of current todo progress.",butlerInfoTodoRecordsEmpty:"No todo progress records yet.",butlerInfoShowCompletedAction:"Show completed",butlerInfoTodoItemTitle:"Todo {index}",butlerInfoTodoPending:"Pending",butlerInfoTodoInProgress:"In Progress",butlerInfoTodoClosed:"Closed",butlerTodoLifecyclePending:"Pending analysis",butlerTodoLifecycleAnalyzing:"Analyzing",butlerTodoLifecycleAnalyzed:"Prompt ready",butlerTodoLifecycleSessionCreated:"Session created",butlerTodoLifecycleFollowUpActive:"Assistant working",butlerTodoLifecycleCompleted:"Completed",butlerTodoLifecycleFailed:"Failed",butlerTodoLifecycleEmpty:"No analysis summary has been generated for this todo yet.",butlerTodoPromptPreviewAction:"View prompt",butlerTodoAnalyzeAction:"Analyze repo",butlerTodoReanalyzeAction:"Analyze again",butlerTodoAnalyzeRunning:"Analyzing...",butlerTodoAnalyzeQueued:"Queued for background analysis",butlerTodoAnalyzeSucceeded:"Development prompt generated",butlerTodoAnalyzeFailed:"Failed to analyze the todo repository context",butlerTodoAnalyzeFirstAction:"Analyze first",butlerTodoWaitForPromptAction:"Waiting for prompt",butlerTodoStartSessionAction:"Create session",butlerTodoStartSessionRunning:"Creating...",butlerTodoCopyPromptAction:"Copy prompt",butlerTodoOpenSessionAction:"Open session",butlerTodoCopyPromptSucceeded:"Prompt copied",butlerTodoStartSessionSucceeded:"Created a development session for the todo",butlerTodoStartSessionFailed:"Failed to create a development session for the todo",butlerAutomationTasksTitle:"Automation Tasks",butlerAutomationTasksDescription:"Only automation tasks live here: what exists, what state it is in, and when it runs next.",butlerAutomationTasksEmpty:"No automation tasks yet.",butlerAutomationRunsTitle:"Recent Automation Runs",butlerAutomationRunsDescription:"This view only shows recent automation executions and their outcomes.",butlerAutomationRunsEmpty:"No automation run records yet.",butlerAutomationStatusActive:"Running",butlerAutomationStatusWaitingUser:"Waiting for You",butlerAutomationStatusCompleted:"Completed",butlerAutomationStatusFailed:"Failed",butlerAutomationStatusCancelled:"Cancelled",butlerAutomationTaskTypeLabel:"Task type",butlerAutomationTaskTypeManual:"Manual plan task",butlerAutomationTaskTypeInterval:"Scheduled plan task",butlerAutomationTaskTypeCron:"Cron plan task",butlerAutomationTaskTypeFollowUp:"Conditional follow-up task",butlerAutomationTaskEnabled:"Enabled",butlerAutomationTaskDisabled:"Disabled",butlerAutomationTaskLastRunLabel:"Last run",butlerAutomationTaskNextRunLabel:"Next run",butlerAutomationRunSourceLabel:"Source",butlerAutomationRunSourcePatrol:"Plan task run",butlerAutomationRunSourceFollowUp:"Conditional follow-up run",butlerAutomationRunSummaryLabel:"Outcome",butlerAutomationRunProcessedAtLabel:"Processed at",butlerAutomationRunEmptySummary:"No summary was returned for this run.",butlerAutomationPatrolRunTitle:"Patrol Task Run",butlerAutomationViewRoundsAction:"View Round Details",butlerAutomationRoundDetailsTitle:"Follow-up Round Details",butlerAutomationRoundDetailsDescription:"Review each Butler follow-up round for this task.",butlerAutomationRoundLoading:"Loading follow-up round details...",butlerAutomationRoundLoadFailed:"Failed to load follow-up round details",butlerAutomationRoundEmpty:"There are no follow-up round details yet.",butlerAutomationRoundLabel:"Round {round}",butlerAutomationRoundProcessedAtLabel:"Processed at",butlerAutomationRoundStatusLabel:"Task status",butlerAutomationRoundObservedStateLabel:"Session runtime state",butlerAutomationRoundSummaryLabel:"Round decision",butlerAutomationRoundWaitingReasonLabel:"Waiting reason",butlerAutomationRoundPromptLabel:"Proxy-sent content",butlerAutomationRoundKindStarted:"Follow-up started",butlerAutomationRoundKindContinue:"Resumed immediately",butlerAutomationRoundKindQueued:"Queued for send",butlerAutomationRoundKindWaitingUser:"Waiting for user",butlerAutomationRoundKindCompleted:"Marked completed",butlerAutomationRoundKindFailed:"Follow-up failed",butlerAutomationRoundKindCancelled:"Stopped manually",butlerAutomationRoundKindLimitReached:"Round limit reached",butlerInboxAction:"Inbox",butlerInboxModalTitle:"Inbox",butlerInboxModalDescription:"Track project todos here and keep their current progress tied to real projects.",butlerInboxLoading:"Loading inbox...",butlerInboxLoadFailed:"Failed to load inbox",butlerInboxProjectsEmpty:"No managed project is available to bind yet.",butlerInboxEmpty:"No inbox records yet.",butlerInboxCreateTitle:"Add Todo",butlerInboxEditingTitle:"Edit Todo",butlerInboxFormDescription:"Every todo must be bound to a project so the assistant can keep following it later.",butlerInboxListTitle:"Current Todos",butlerInboxListDescription:"This list shows todos across your managed projects so you can handle them in one place.",butlerInboxShowClosedAction:"Show closed",butlerInboxQuickStatusLabel:"Quick status update",butlerInboxProjectLabel:"Project",butlerInboxTypeLabel:"Type",butlerInboxTitleLabel:"Title",butlerInboxTitlePlaceholder:"For example: Finish login captcha flow",butlerInboxContentLabel:"Details",butlerInboxContentPlaceholder:"Describe the current issue, target, or what you want the assistant to keep pushing forward.",butlerInboxStatusLabel:"Progress",butlerInboxTypeTask:"Task",butlerInboxTypeBug:"Bug",butlerInboxTypeFeature:"Feature",butlerInboxTypeChange:"Change",butlerInboxStatusPending:"Pending",butlerInboxStatusInProgress:"In Progress",butlerInboxStatusClosed:"Closed",butlerInboxCreateAction:"Add Todo",butlerInboxUpdateAction:"Save Changes",butlerInboxCancelEditAction:"Cancel Edit",butlerInboxEditAction:"Edit",butlerInboxDeleteAction:"Delete",butlerInboxCreated:"Todo created",butlerInboxUpdated:"Todo updated",butlerInboxDeleted:"Todo deleted",butlerInboxSaveFailed:"Failed to save todo",butlerInboxDeleteFailed:"Failed to delete todo",butlerProviderSwitched:"Provider switched",butlerProviderSwitchedDescription:"Switched to {provider}. The current view was reset and reloaded.",butlerProviderSwitchFailed:"Failed to switch provider",butlerAttachmentUnsupported:"Attachments are not supported in Butler chat yet",butlerOverviewTitle:"Overview",butlerOverviewDescription:"This area pulls together the most important things to pay attention to right now.",butlerMetricProjectCount:"Projects",butlerMetricBlockedCount:"Blocked",butlerMetricHighRiskCount:"High Risk",butlerTopRisksTitle:"Top Risks",butlerNextActionsTitle:"Next Actions",butlerOverviewEmpty:"No data",butlerOverviewLoading:"Loading Butler context summary...",butlerEventsTitle:"Recent Actions",butlerEventsDescription:"Anything Butler just helped you do is listed here.",butlerEventsEmpty:"No action events yet",butlerLoadFailed:"Failed to load Butler workbench",butlerContextStrategyTitle:"Context On Demand",butlerContextStrategyDescription:"Butler only receives the global summary by default. Project sessions, memories, patrols, and verifications are fetched from the backend only after you drill into a specific project.",butlerConversationTitle:"Talk to Assistant",butlerConversationDescription:"This conversation belongs to {displayName} only. When details are needed, {displayName} answers from the aggregated summary first, then pulls the relevant project, session, patrol, or verification data from the backend on demand.",butlerComposerPlaceholder:"Tell {displayName} what you want to inspect or decide next",butlerProjectsTitle:"Projects",butlerProjectsDescription:"Pick a project here and Butler will continue with its latest progress and records.",butlerProjectsEmpty:"No projects available for drilldown",butlerProjectWorkspaceLabel:"Workspace: {workspaceId}",butlerProjectSummaryEmpty:"No summary available yet",butlerProjectOpenDetailAction:"Open Details",butlerProjectSyncAction:"Sync to Timeline",butlerProjectSyncSucceeded:"Project {projectName} was synced into Butler's timeline",butlerProjectActionRequiresSession:"Send Butler a message first, then ask it to continue working on a project.",butlerProjectContextTitle:"Current Project",butlerProjectContextDescription:"This area shows the sessions, records, and results tied to the project you selected.",butlerProjectContextEmpty:"Pick a project from the list or action events first.",butlerProjectContextLoading:"Loading project-related context...",butlerProjectContextMeta:"Project status: {status} · Risk level: {riskLevel}",butlerProjectActionSucceeded:"Butler action completed",butlerProjectActionFailed:"Butler action failed",butlerProjectActionPending:"Processing...",butlerProjectSessionsTitle:"Project Sessions",butlerProjectMemoriesTitle:"Project Memories",butlerProjectPatrolsTitle:"Patrol Runs",butlerProjectVerificationsTitle:"Verification Runs",butlerProjectOpenConversationAction:"Open Real Session",butlerProjectResumeAction:"Resume Session",butlerProjectResumeSucceeded:"Session resumed: {sessionTitle}",butlerProjectStartPatrolAction:"Start Patrol",butlerProjectPatrolSucceeded:"Started a patrol for {projectName}",butlerProjectStartVerificationAction:"Start Verification",butlerProjectVerificationSucceeded:"Started a verification for {projectName}",butlerProjectMemoryMeta:"Type: {memoryType} · Status: {status}",butlerProjectSessionMeta:"Role: {role} · Status: {status}",butlerProjectPatrolMeta:"Status: {status} · Risk: {riskLevel}",butlerProjectVerificationMeta:"Type: {verificationType} · Status: {status}",butlerProjectRunSummaryEmpty:"No summary yet",butlerProjectFocusAction:"Focus This Record",butlerProjectUpdatedAtLabel:"Updated: {updatedAt}",butlerFocusedBadge:"Focused",searchModalTitle:"Search",searchModalDescription:"Search sessions by title, or search code files inside the selected workspace.",searchModeLabel:"Search mode",searchModeSessions:"Sessions",searchModeCode:"Code",searchKeywordLabel:"Keyword",searchWorkspaceLabel:"Workspace",searchSessionPlaceholder:"Search by session title, workspace, or provider",searchCodePlaceholder:"Search by file name or path fragment",searchSessionHint:"Type a keyword to instantly filter matching sessions.",searchCodeHint:"Pick a workspace, then search by file name or path.",searchSessionEmpty:"No matching sessions found.",searchCodeEmpty:"No matching files found.",searchCodeFailed:"Code search failed. Please try again later.",searchSubmit:"Search",filesEntry:"Files",gitEntry:"GIT",terminalManagerEntry:"Process Manager",workspaceSectionTitle:"Workspaces",goBack:"Back",goForward:"Forward",workspaceCount:"Projects",sessionCount:"Sessions",manageWorkspaceAction:"Manage Projects",manageWorkspaceTitle:"Manage Projects",manageWorkspaceDescription:"The list starts with the currently loaded projects. Expand one to inspect its path, Git summary, and code composition, or remove it from the current workbench list.",manageWorkspaceImportAction:"Import Project",manageWorkspaceCloneAction:"Clone Project",manageWorkspaceEmpty:"There are no projects to manage right now.",manageWorkspaceLoading:"Loading project details...",manageWorkspaceLoadFailed:"Failed to load project details.",manageWorkspacePathLabel:"Path",manageWorkspaceGitCommitCount:"Git Commit Count",manageWorkspaceGitInfoLabel:"Git Repository Info",manageWorkspaceRepoRoot:"Repository Root",manageWorkspaceCurrentBranch:"Current Branch",manageWorkspaceRemoteLabel:"Remote",manageWorkspaceNoRemote:"No remote configured",manageWorkspaceNotGit:"This project is not a Git repository.",manageWorkspaceCodeCompositionLabel:"Code Composition",manageWorkspaceCodeCompositionFiles:"files",manageWorkspaceCodeCompositionOther:"Other",manageWorkspaceNoCodeComposition:"No recognizable code files were found for composition stats.",manageWorkspaceCodeTruncated:"The project is large, so only the first {count} recognizable files were counted.",manageWorkspaceColorLabel:"Background Color",manageWorkspaceColorSelectSwatch:"Use color {color}",manageWorkspaceColorClearAction:"Clear Color",manageWorkspaceColorUnset:"Not set. The default worktree color is in use.",manageWorkspaceColorSaveFailed:"Failed to save the workspace color.",manageWorkspaceRemoveAction:"Remove Project",manageWorkspaceRemoving:"Removing...",manageWorkspaceRemoveSuccess:"Project removed from the current workbench list",manageWorkspaceRemoveFailed:"Failed to remove the project",manageWorkspaceRemoveConfirmTitle:"Confirm Project Removal",manageWorkspaceRemoveConfirmDescription:"This only removes the project from the current workbench list. It does not delete any files on disk or historical records. If you load the same path again later, the old records will appear again.",manageWorkspaceRemoveConfirmTarget:'Remove "{name}" from the current workbench?',manageWorkspaceRemoveConfirmAction:"Remove Project",importWorkspaceTitle:"Add Project",importWorkspaceHint:"Import a local code directory",importExpand:"Expand",importCollapse:"Collapse",importPathLabel:"Project Path",importPathPlaceholder:"Enter the project folder path",importNameLabel:"Project Name",importNamePlaceholder:"Optional",importSubmit:"Add Project",importSubmitting:"Adding...",importChooseFolder:"Choose Folder",importPickFolderFailed:"Failed to open the folder picker",importDesktopDropHint:"You can drag a local project folder directly into this area",importHint:"Enter a local code directory and start working",importServerDirectoryHint:"Browse and select the project directory on the server",importBrowserTitle:"Select Server Directory",importBrowserDescription:"You are browsing directories on the server, not on the current device.",importBrowserCurrentPath:"Current Path",importBrowserRoots:"Root Directories",importBrowserOpenParent:"Go Up",importBrowserOpenPath:"Open Path",importBrowserCreateDirectory:"New Folder",importBrowserCreateDirectoryTitle:"New Folder",importBrowserCreateDirectoryDescription:"Create a single child folder in the current server path. Path separators are not accepted.",importBrowserCreateDirectoryLabel:"Folder Name",importBrowserCreateDirectoryPlaceholder:"Enter the new folder name",importBrowserCreateDirectorySuccess:"Folder created",importBrowserCreateDirectoryFailed:"Failed to create folder",importBrowserCreateDirectorySubmit:"Create Folder",importBrowserCreatingDirectory:"Creating...",importBrowserEmpty:"No subdirectory is available in the current path",importBrowserBrowseFailed:"Failed to load server directories",importBrowserSubmit:"Import Current Directory",importPathRequired:"Enter the project path",importSuccess:"Project added",importFailed:"Failed to add project",cloneWorkspaceTitle:"Clone Project",cloneWorkspaceHint:"Clone a Git repository into a server directory and add it to the project list.",cloneSubmit:"Clone Project",cloneSubmitting:"Cloning...",cloneRepositoryLabel:"Git Repository URL",cloneRepositoryPlaceholder:"For example: https://github.com/org/repo.git",cloneParentPathLabel:"Target Parent Directory",cloneParentPathPlaceholder:"Choose an existing directory on the backend server",cloneDirectoryNameLabel:"New Project Directory Name",cloneDirectoryNamePlaceholder:"Defaults to the repository name when left empty",clonePickDirectory:"Choose Directory",cloneAuthModeLabel:"Authentication",cloneAuthModeNone:"No Authentication",cloneAuthModeBasic:"Username + Password",cloneAuthModeToken:"Token",cloneUsernameLabel:"Username",cloneUsernamePlaceholder:"Enter Git username",clonePasswordLabel:"Password",clonePasswordPlaceholder:"Enter Git password",cloneTokenLabel:"Token",cloneTokenPlaceholder:"Enter access token",cloneTokenUsernamePlaceholder:"Optional, defaults to git when left empty",cloneRepoRequired:"Enter the Git repository URL",clonePathRequired:"Select the target parent directory",cloneSuccess:"Project cloned successfully",cloneFailed:"Clone failed",cloneHint:"The target parent directory must already exist. Clone creates a new repository folder under it.",cloneBrowserTitle:"Select Clone Parent Directory",cloneBrowserDescription:"Choose an existing server-side parent directory. Clone will create a new project folder under it.",cloneBrowserSubmit:"Use Current Directory",refreshNavigation:"Refresh",desktopChromeLabel:"Desktop Workbench",windowMinimize:"Minimize Window",windowMaximize:"Maximize or Restore Window",windowClose:"Close Window",contextOpenSession:"Open Session",navigationLoadFailed:"Load failed. Retry.",emptyNavigationTitle:"No project yet",emptyNavigationBody:"Add a local code directory to start working",emptyWorkspaceSessions:"No sessions",favoriteSectionTitle:"Pinned Sessions",favoriteSectionEmpty:"Pinned sessions stay here for quick access.",worktreeSectionTitle:"Child Worktrees",worktreeSectionExpand:"Expand Child Worktrees",worktreeSectionCollapse:"Collapse Child Worktrees",worktreeMergePanelLabel:"Worktree Merge",worktreeMergePanelTitle:"Merge Into Direct Parent",worktreeMergePreviewAction:"Preview",worktreeMergePreviewRefresh:"Preview",worktreeMergePreviewIdle:"Preview not loaded",worktreeMergePreviewLoading:"Checking...",worktreeMergeReady:"Ready to merge",worktreeMergeBlocked:"Merge blocked",worktreeMergeApplying:"Merging...",worktreeMergeApplyAction:"Merge",worktreeMergeApplySuccess:"The worktree has been merged into its direct parent",worktreeMergeApplyFailed:"Failed to merge worktree",worktreeMergePreviewFailed:"Failed to load merge preview",worktreeMergeAlreadyMerged:"Already merged into parent",worktreeMergeMergedHint:"The code is already back in the parent. Cleanup can be done next.",worktreeMergeMergedDirtyHint:"Committed history is already in the parent, but this worktree still has pending work and cannot be cleaned up yet.",worktreeMergeChecklistTitle:"Merge Checklist",worktreeMergeChecklistSourceState:"Worktree state is valid",worktreeMergeChecklistSourceStateBlocked:"The worktree state is inconsistent. The system is not treating it as an active worktree yet.",worktreeMergeChecklistSourceClean:"Source worktree is clean",worktreeMergeChecklistSourceCleanBlocked:"The source worktree still has uncommitted changes. Commit them first.",worktreeMergeChecklistTargetClean:"Parent workspace is clean",worktreeMergeChecklistTargetCleanBlocked:"The direct parent workspace has uncommitted changes and cannot receive the merge.",worktreeMergeChecklistChildren:"No active child worktrees",worktreeMergeChecklistChildrenBlocked:"There are still active child worktrees under this node. Clean leaf nodes first.",worktreeMergeChecklistCommits:"There are commits to merge",worktreeMergeChecklistCommitsBlocked:"This worktree has no commits ahead of the parent workspace.",worktreeMergeChecklistConflicts:"No merge conflicts detected",worktreeMergeChecklistConflictsBlocked:"Merge conflicts were detected. Resolve them before continuing.",worktreeMergeChecklistResultPending:"Waiting for preview",worktreeMergeChecklistResultReady:"Merge can proceed",worktreeMergeChecklistResultReadyDetail:"All checks passed. You can start the merge now.",worktreeMergeChecklistResultBlocked:"Merge cannot proceed yet",worktreeMergeChecklistResultBlockedDetail:"Resolve the blockers above before continuing.",worktreeMergeChecklistResultMerged:"Merged. Cleanup can continue",worktreeMergeCompactPending:"Pending",worktreeMergeCompactChecking:"Checking",worktreeMergeCompactReady:"Ready",worktreeMergeCompactBlocked:"Blocked",worktreeMergeCompactMerged:"Merged",worktreeMergeCompactMerging:"Merging",worktreeMergeCompactCleaning:"Cleaning",worktreeMergeCompactInactive:"State Error",worktreeMergeCompactDirty:"Dirty",worktreeMergeCompactTargetDirty:"Parent Dirty",worktreeMergeCompactConflict:"Conflict",worktreeMergeCompactChildren:"Has Children",worktreeMergeCompactNoCommits:"No Commits",worktreeCleanupAction:"Cleanup",worktreeCleanupRunning:"Cleaning...",worktreeCleanupSuccess:"The worktree has been cleaned up",worktreeCleanupFailed:"Failed to clean up worktree",worktreeCleanupModalTitle:"Confirm Worktree Cleanup",worktreeCleanupModalDescription:"Cleanup removes the worktree directory and app metadata by default. Deleting the branch is only available after it has been merged into the parent branch.",worktreeCleanupConfirm:"Clean up {name}? The git branch will be kept by default.",worktreeCleanupDeleteBranchLabel:"Also delete branch {branch}",worktreeCleanupDeleteBranchHint:"Branch deletion is only available after the branch has been merged into the parent branch.",worktreeCleanupDeleteBranchAction:"Cleanup and Delete Branch",worktreeCleanupDeleteBranchSuccess:"The worktree and branch {branch} have been cleaned up",worktreeCleanupDeleteBranchPartialFailed:"The worktree was cleaned up, but branch {branch} could not be deleted",worktreeMergeCurrentBranch:"Current branch: {branch}",worktreeMergeParentBranch:"Parent branch: {branch}",worktreeMergeTargetWorkspace:"Target parent: {name}",worktreeMergeAheadBehind:"Commit delta: ahead {ahead} / behind {behind}",worktreeMergeBaseCommit:"merge base: {commit}",worktreeMergeConflictLabel:"Conflicting files",favoriteAction:"Pin Session",unfavoriteAction:"Unpin",favoriteAdded:"Session pinned",favoriteRemoved:"Session unpinned",favoriteToggleFailed:"Failed to update pinned state",sessionMoreAction:"More Actions",sessionStateInferred:"Inferred",renameAction:"Rename",renameSuccess:"Session name updated",renameFailed:"Failed to rename session",renameModalTitle:"Rename Session",renameModalDescription:"Use a name you can recognize at a glance. This changes only the title, not the content.",renameInputLabel:"Session Name",renameInputPlaceholder:"Enter a new session name",renamingSession:"Saving...",archiveFolderLabel:"Archived Sessions",archiveFolderAction:"Open Archive Folder",archiveAction:"Archive Session",archiveCurrentSessionAction:"Archive Current Session",archiveAdded:"Session archived",archiveConfirmTitle:"Archive This Session",archiveConfirmDescription:"After archiving, this session will be hidden from the main list for the current workspace, and you can still restore it from archive.",unarchiveAction:"Restore from Archive",archiveRestored:"Session restored to the main list",archiveModalTitle:"Archived Sessions",archiveModalDescription:"This list shows sessions temporarily hidden in the current project. Restore them when needed.",archiveEmpty:"There are no archived sessions in this project yet.",archiveViewAction:"View Archived Sessions",subagentBadge:"Sub-agent",sessionForkSession:"Session Fork",sessionForkMessage:"Message Fork",sessionForkReconstructed:"Reconstructed Fork",subagentExpand:"Expand Sub-agent List",subagentCollapse:"Collapse Sub-agent List",subagentExpandMore:"Show More Sub-agents",favoriteExpandMore:"Show More Pinned",sessionExpandMore:"Show More Sessions",archiveExpandMore:"Show More Archived Sessions",worktreeCollapse:"Collapse Worktree",worktreeExpand:"Expand Worktree",workspaceCollapse:"Collapse Project",workspaceExpand:"Expand Project",reorderWorkspace:"Drag to Reorder Projects",switchWorkspace:"Switch to Project",workspaceReorderFailed:"Failed to save project order.",workspaceCollapseStateSaveFailed:"Failed to save project collapse state.",workspaceHomeSwitcherLabel:"Switch Workspace",workspaceHomeSwitcherTitle:"Workspace",hostWorkspaceSwitcherTitle:"Hosts and Workspaces",hostSwitcherAriaLabel:"Switch Host",hostSwitcherTitle:"Hosts",hostSwitcherCurrentBadge:"Current",hostSwitcherNodeBadge:"HOST",hostSwitcherAddAction:"Add Host",hostSwitcherNameLabel:"Host Name",hostSwitcherNamePlaceholder:"For example: Office Host",hostSwitcherUrlLabel:"Host URL",hostSwitcherUrlPlaceholder:"For example: http://192.168.1.20:3002",hostSwitcherSaveAction:"Save Host",hostSwitcherSwitching:"Switching",hostSwitcherWorkspaceCount:"{count} workspaces",hostSwitcherWorkspaceCountWithUser:"{username} · {count} workspaces",hostSwitchFailed:"Failed to switch host.",hostSwitchUnreachable:"{name} is unreachable right now.",hostSwitchMissing:"The target host no longer exists.",hostAddInvalidUrl:"The host URL is invalid.",hostAddDuplicate:"This host already exists.",hostAddFailed:"Failed to add the host.",hostAddSuccess:"Added host: {name}",mobileWorktreeBadge:"Worktree",workspaceHomeStatusSectionTitle:"Current Workspace",workspaceHomeViewAllAction:"View All Sessions",workspaceHomeMetricActive:"Active",workspaceHomeMetricUnread:"Notifications",workspaceHomeMetricTerminal:"Terminals",workspaceHomeMetricChanges:"Changes",workspaceHomeActiveSessionsSectionTitle:"Active Sessions",workspaceHomeQuickLaunchStatusLabel:"Quick Launch Process",workspaceHomeQuickLaunchRunning:"Running",workspaceHomeQuickLaunchStopped:"Stopped",workspaceHomeWaitingInputLabel:"Waiting Input",workspaceHomeButlerLabel:"Assistant",mobileButlerEntry:"Assistant",mobileConversationToolCloseAction:"Back to Conversation",mobileConversationToolTabsLabel:"Files, Git, and Processes Tabs",mobileConversationToolProcessesTab:"Processes",mobileButlerEmptyTitle:"Assistant is not ready yet",mobileButlerEmptyBody:"The first assistant setup has not been completed yet. Finish the initial setup on desktop, then come back on mobile to review follow-ups and automations.",butlerProjectSyncEmptyState:"Give the assistant a concrete goal and it will continue the work here.",mobileButlerSummaryTitle:"Workspace Summary",mobileButlerSummaryProjects:"Projects",mobileButlerSummaryFollowUps:"Active Tasks",mobileButlerSummaryWaitingUser:"Waiting on You",mobileButlerSummaryInbox:"Open Todos",mobileButlerAssistantWorkspaceLabel:"Butler Workspace",mobileButlerAssistantToneLabel:"Tone",mobileButlerAssistantLanguageLabel:"Language",mobileButlerAssistantUpdatedAtLabel:"Updated",workspaceOverviewTitle:"Put project entry points where you can actually see them",workspaceOverviewBody:"Choose a project first, then decide whether to continue or start a new session.",workspaceListBody:"Keep every loaded project here and surface the frequent actions on the page.",workspaceDetailTitle:"Project Details",workspaceDetailSummaryTitle:"Project Overview",workspaceDetailSummaryBody:"See the path, Git summary, and code footprint first, then jump into the right tool.",workspaceDetailMissingTitle:"Project not found",workspaceDetailMissingBody:"This project may have been removed, or the current snapshot has not loaded it yet.",workspaceDetailDebugTitle:"Service Status",manageWorkspaceDebugDescription:"Review detected services, recent start status, and support guidance for the current project.",workspaceDetailDebugAnalyzeFailed:"Failed to load service status",workspaceDetailDebugFrameworkLabel:"Detected Type",workspaceDetailDebugConfidenceLabel:"Confidence",workspaceDetailDebugCompatibilityLabel:"Readiness",workspaceDetailDebugInjectionLabel:"Recommended Handling",workspaceDetailDebugRuntimeStatusLabel:"Current Status",workspaceDetailDebugFailureStageLabel:"Blocked At",workspaceDetailDebugServiceDiscoveryLabel:"Service Address Handling",workspaceDetailDebugHmrLabel:"Hot Reload Handling",workspaceDetailDebugCallbackLabel:"Callback Handling",workspaceDetailDebugAiFallbackLabel:"Manual Handling Policy",workspaceDetailDebugFrameworkNoteLabel:"Notes",workspaceDetailDebugReasonsLabel:"Summary",workspaceDetailDebugFilesLabel:"Reference Files",workspaceDetailDebugFailureStageEmpty:"None",workspaceDetailDebugRuntimeEmpty:"No runtime record yet.",workspaceDetailDebugFrameworkNoteEmpty:"No extra compatibility note.",workspaceDetailDebugEmptyReasons:"None",workspaceDetailDebugEmptyFiles:"None",workspaceDetailDebugConfidenceHigh:"High",workspaceDetailDebugConfidenceMedium:"Medium",workspaceDetailDebugConfidenceLow:"Low",workspaceDetailDebugCompatibilitySupported:"Ready to Use",workspaceDetailDebugCompatibilityConditional:"Needs More Setup",workspaceDetailDebugCompatibilityUnsupported:"Not Recommended Yet",workspaceDetailDebugCompatibilityUnknown:"Unknown",workspaceDetailDebugInjectionCli:"Startup Args",workspaceDetailDebugInjectionEnv:"Environment",workspaceDetailDebugInjectionOverride:"Adjust Command",workspaceDetailDebugInjectionAiFallback:"Needs Manual Help",workspaceDetailDebugInjectionNone:"Do Not Auto Handle Yet",workspaceDetailDebugRuntimePreparing:"Preparing",workspaceDetailDebugRuntimeRunning:"Running",workspaceDetailDebugRuntimeFailed:"Start Failed",workspaceDetailDebugRuntimeStopped:"Stopped",workspaceDetailDebugRuntimeNotStarted:"Not Started",workspaceDetailDebugRequirementRequired:"Needs Extra Setup",workspaceDetailDebugRequirementNotRequired:"No Extra Setup",workspaceDetailDebugAiPolicyNever:"Do Not Auto Handle",workspaceDetailDebugAiPolicyConditional:"Case by Case",workspaceDetailDebugAiPolicyAllowed:"Allowed",workspaceDetailDebugRuntimeServicesTitle:"Most Recent Start",workspaceDetailDebugRuntimeHistoryTitle:"Recent Starts",workspaceDetailDebugRuntimeHistoryTimeLabel:"Started At",workspaceDetailDebugRuntimeHistoryServiceLabel:"Services",workspaceDetailDebugRuntimeHistoryResultLabel:"Result",workspaceDetailDebugRuntimeHistoryTitleWithIndex:"Run #{id}",workspaceDetailDebugRuntimeHistoryFailedSummary:"{services} did not start correctly in this run.",workspaceDetailDebugRuntimeHistoryGenericSummary:"Recent start records are kept here so repeated failures are easier to spot.",workspaceDetailDebugRuntimeHistoryNoServices:"None",workspaceDetailDebugRuntimeHistoryResultRunning:"Still Running",workspaceDetailDebugRuntimeHistoryResultFailed:"Start Failed",workspaceDetailDebugRuntimeHistoryResultStopped:"Stopped",workspaceDetailDebugRuntimeHistoryResultPreparing:"Preparing",workspaceDetailDebugRuntimeServicePortLabel:"Assigned Port",workspaceDetailDebugRuntimeServiceBindingLabel:"Port State",workspaceDetailDebugRuntimeServiceProcessLabel:"Process",workspaceDetailDebugRuntimeServiceFailureLabel:"Issue Stage",workspaceDetailDebugRuntimeServiceAiLabel:"Manual Handling Record",workspaceDetailDebugDetectedServicesTitle:"Detected Services",workspaceDetailDebugServicePathLabel:"Location",workspaceDetailDebugServiceFrameworkLabel:"Detected As",workspaceDetailDebugServiceCommandLabel:"Start Command",workspaceDetailDebugServiceRequirementsLabel:"Extra Setup Needed",workspaceDetailDebugServiceActionLabel:"Recommended Action",workspaceDetailDebugOpenPageAction:"Service Debug",workspaceDetailDebugPageTitle:"Service Debug",workspaceDetailDebugPageDescription:"See detected services, recent start results, and support guidance for this workspace.",workspaceDetailDebugPageHeroEyebrow:"Service Overview",workspaceDetailDebugOverallStatusLabel:"Overall Status",workspaceDetailDebugOverallSummaryLabel:"Summary",workspaceDetailDebugOverallStatusSupported:"Ready to Start",workspaceDetailDebugOverallStatusConditional:"Some Services Need More Setup",workspaceDetailDebugOverallStatusBlocked:"Do Not Start Everything Yet",workspaceDetailDebugOverallSummaryEmpty:"No usable service check result is available yet.",workspaceDetailDebugOverallSummaryMixed:"Detected {webCount} web services and {desktopCount} desktop-shell services. Desktop shells are shown separately and excluded from web auto handling.",workspaceDetailDebugOverallSummaryDesktopOnly:"Detected {count} desktop-shell services and no clear web service yet.",workspaceDetailDebugOverallSummaryWebOnly:"Detected {count} web services that can join the web debug flow.",workspaceDetailDebugSummaryServiceCountLabel:"Total Services",workspaceDetailDebugSummaryWebCountLabel:"Web Services",workspaceDetailDebugSummaryDesktopShellCountLabel:"Desktop Shells",workspaceDetailDebugSummaryWebServicesChip:"{count} web services",workspaceDetailDebugSummaryDesktopShellChip:"{count} desktop shells",workspaceDetailDebugSummaryUnsupportedChip:"{count} blocking items",workspaceDetailDebugAutoInjectionEligible:"Current web services are ready for automatic handling",workspaceDetailDebugAutoInjectionBlocked:"Do not treat this whole project as auto-ready yet",workspaceDetailDebugDesktopShellSummaryHint:"Desktop shell services are shown separately from web service handling",workspaceDetailDebugCompatibilityBreakdown:"Ready {supported} / Needs setup {conditional} / Not recommended {unsupported}",workspaceDetailDebugLastAnalyzedAtLabel:"Last Check",workspaceDetailDebugTargetSourceRepo:"Scope: Repository Root",workspaceDetailDebugTargetSourceWorktree:"Scope: Current Worktree",workspaceDetailDebugRequirementsNone:"No extra setup required",workspaceDetailDebugServiceSectionDescription:"View the project one service at a time so you can tell what is ready and what still needs setup.",workspaceDetailDebugRuntimeSectionDescription:"This only shows the most recent start result so you can quickly see which service failed to come up.",workspaceDetailDebugMatrixSectionDescription:"This section explains the default support level for each detected service type.",workspaceDetailDebugMatrixTitle:"Support Guidance",workspaceDetailDebugMatrixOpenAction:"Open Support Matrix",workspaceDetailDebugMatrixModalDescription:"Use a real matrix table so people can scan support rules without reading a wall of cards.",workspaceDetailDebugMatrixFrameworkHeader:"Framework",workspaceDetailDebugMatrixCompatibilityHeader:"Support",workspaceDetailDebugMatrixInjectionHeader:"Mode",workspaceDetailDebugMatrixDiscoveryHeader:"Discovery",workspaceDetailDebugMatrixHmrHeader:"HMR",workspaceDetailDebugMatrixCallbackHeader:"Callback",workspaceDetailDebugMatrixAiHeader:"Manual",workspaceDetailDebugMatrixNotesHeader:"Notes",workspaceDetailDebugMatrixCompatibilitySupportedShort:"Ready",workspaceDetailDebugMatrixCompatibilityConditionalShort:"Needs Setup",workspaceDetailDebugMatrixCompatibilityUnsupportedShort:"Avoid",workspaceDetailDebugMatrixCompatibilityUnknownShort:"Unknown",workspaceDetailDebugMatrixInjectionCliShort:"CLI",workspaceDetailDebugMatrixInjectionEnvShort:"ENV",workspaceDetailDebugMatrixInjectionOverrideShort:"CMD",workspaceDetailDebugMatrixInjectionAiFallbackShort:"Manual",workspaceDetailDebugMatrixInjectionNoneShort:"None",workspaceDetailDebugMatrixRequirementRequiredShort:"Needs Work",workspaceDetailDebugMatrixRequirementNotRequiredShort:"Not Needed",workspaceDetailDebugMatrixAiNeverShort:"Do Not Use",workspaceDetailDebugMatrixAiConditionalShort:"Conditional",workspaceDetailDebugMatrixAiAllowedShort:"Allowed",workspaceDetailDebugMatrixLegendSummary:"Icon meanings: check means the default path is clear, warning means you still need setup, and cross means this path is not recommended for automatic handling yet.",workspaceDetailDebugMatrixDiscoveryNote:"Service address handling such as proxy, rewrites, and discovery.",workspaceDetailDebugMatrixHmrNote:"Hot reload and other long-lived frontend dev connections.",workspaceDetailDebugMatrixCallbackNote:"Callback-style entries such as OAuth, login callback, or webhook.",workspaceDetailDebugMatrixAiNote:"Whether edge cases are allowed to fall back to manual help.",workspaceDetailDebugFailureStageServiceDiscovery:"Still needs service address handling",workspaceDetailDebugFailureStageHmr:"Still needs hot reload handling",workspaceDetailDebugFailureStageCallback:"Still needs callback handling",workspaceDetailDebugFailureStageAiFallbackRequired:"Needs manual review",workspaceDetailDebugFailureStageAdapterSelection:"No suitable start method was found",workspaceDetailDebugFailureStageLaunchRequirements:"Some launch requirements are still missing",workspaceDetailDebugFailureStageCommandExecution:"The start command did not run correctly",workspaceDetailDebugFailureStageProcessExit:"The service exited right after start",workspaceDetailDebugFailureStageProcessRuntimeError:"The service hit a runtime error",workspaceDetailDebugFailureStageStaleRuntimeBinding:"This start record is no longer valid",workspaceDetailDebugFailureStageUnknown:"Unknown stage ({code})",workspaceDetailDebugBindingAllocated:"Assigned",workspaceDetailDebugBindingListening:"Reachable",workspaceDetailDebugBindingFailed:"Not Ready",workspaceDetailDebugBindingReleased:"Released",workspaceDetailDebugBindingUnknown:"Unknown",workspaceDetailDebugProcessCreating:"Starting",workspaceDetailDebugProcessRunning:"Running",workspaceDetailDebugProcessClosed:"Stopped",workspaceDetailDebugProcessError:"Error",workspaceDetailDebugProcessUnknown:"Unknown",workspaceDetailDebugPortEmpty:"None",workspaceDetailDebugRoleFrontend:"Web Service",workspaceDetailDebugRoleBackend:"Backend Service",workspaceDetailDebugRoleWorker:"Background Worker",workspaceDetailDebugRoleMock:"Mock Service",workspaceDetailDebugRoleDesktopShell:"Desktop Shell",workspaceDetailDebugRoleCustom:"Custom",workspaceDetailDebugServiceOverviewSupported:"This service is clearly identified and is usually ready to start once you follow the recommended handling.",workspaceDetailDebugServiceOverviewConditional:"This service is identified, but still needs a few extra setup steps before it can start cleanly.",workspaceDetailDebugServiceOverviewUnsupported:"This service is not recommended for direct automatic handling yet. Confirm the start flow manually first.",workspaceDetailDebugServiceOverviewUnknown:"This service has not been identified clearly yet. The current result is kept for later review.",workspaceDetailDebugServiceOverviewDesktopShell:"This is a desktop shell service. It is shown separately and does not participate in automatic web-port handling.",workspaceDetailDebugServiceActionSupported:"Start Directly",workspaceDetailDebugServiceActionConditional:"Complete Setup First",workspaceDetailDebugServiceActionUnsupported:"Handle Manually",workspaceDetailDebugServiceActionUnknown:"Confirm Service Type First",workspaceDetailDebugServiceActionDesktopShell:"Handle as Desktop Shell",workspaceDetailDebugAiEditEmpty:"None",workspaceDetailDebugAiEditPending:"Pending",workspaceDetailDebugAiEditApplied:"Applied",workspaceDetailDebugAiEditRolledBack:"Rolled Back",workspaceDetailDebugAiEditRejected:"Rejected",workspaceSessionListBody:"Project sessions, favorites, and archive actions live here instead of hiding in a sidebar.",recentSessionsSectionTitle:"Recent Sessions",recentSessionsSectionBody:"Jump back into the work you touched most recently.",currentWorkspaceSectionTitle:"Current Project Sessions",currentWorkspaceSectionBody:"Keep the sessions for the current project together so the context stays obvious.",sessionIndexTitle:"Sessions deserve their own page",sessionIndexBody:"Recent, favorites, and current-project sessions are split into clear sections for mobile.",toolsMoreAction:"More",toolsSwipeHint:"Swipe left or right to switch between files and Git",toolsSwipePosition:"{current} / {total}",toolFilesBody:"Browse project files, changed files, and code context without relying on a desktop sidebar.",toolGitBody:"Open a clear Git entry for status, commits, and branches in the current project.",toolTerminalsBody:"Open the full terminal page for input-heavy and scroll-heavy tasks.",toolProcessesBody:"Review terminal templates, runtime status, and process entry points for the current project.",toolsWorkspaceRequiredBody:"Pick a project before opening this tool page.",createSession:"New Session",createSessionModalTitle:"Choose Session Type",createSessionModalDescription:"Pick the session type first, then start the actual session process.",createSessionWorkspaceLabel:"Choose Workspace",createSessionProviderLabel:"Choose Provider",createSessionTarget:"Current Project",createWorktreeSectionTitle:"Child Workspace",createWorktreeSectionDescription:"Create a child workspace from the current project first, then choose the provider for the new session.",createWorktreeAction:"Add Child Workspace",createWorktreeCollapseAction:"Hide Child Workspace Form",createWorktreeBranchLabel:"Branch Name",createWorktreeBranchPlaceholder:"For example: feat/login-codex",createWorktreeBranchRequired:"Enter the child workspace branch name first.",createWorktreeBranchInvalid:"Branch names may only contain letters, numbers, -, _, and /. They cannot start or end with / or contain //.",createWorktreeDisplayNameLabel:"Display Name (Optional)",createWorktreeDisplayNamePlaceholder:"Defaults to the branch name",createWorktreeBaseRefLabel:"Create From Branch/Commit (Optional)",createWorktreeBaseRefPlaceholder:"Defaults to the current branch",createWorktreeBaseRefHint:"You can choose from {localCount} local branches, {remoteCount} remote branches, and {tagCount} tags, or enter a commit hash manually.",createWorktreeBaseRefLoading:"Loading branches and tags from the current repository...",createWorktreeBaseRefLoadFailed:"Failed to load branches and tags. You can still enter a branch, tag, or commit hash manually.",createWorktreeBaseRefLocalGroup:"Local Branches",createWorktreeBaseRefRemoteGroup:"Remote Branches",createWorktreeBaseRefTagGroup:"Tags",createWorktreeBaseRefCurrentBadge:"Current",createWorktreeBaseRefRecommendedBadge:"Recommended",createWorktreeBaseRefEmpty:"No matches found. You can still enter a branch, tag, or commit hash manually.",createWorktreeBaseRefToggle:"Show available branches and tags",createWorktreeHelpAction:"How to Fill This",createWorktreeHelpTitle:"What These Fields Mean",createWorktreeHelpBranchTitle:"Branch Name",createWorktreeHelpBranchBody:"This is the name of the new child workspace. It is also what you will see in the list later. A short name like feat/login is usually enough.",createWorktreeHelpDisplayNameTitle:"Display Name",createWorktreeHelpDisplayNameBody:"Use this if you want a clearer name in the list. If you leave it empty, the branch name will be used automatically.",createWorktreeHelpBaseRefTitle:"Create From Branch/Commit",createWorktreeHelpBaseRefBody:"This decides where the new child workspace starts from. Most of the time, you can keep the default. Only change it if you want to start from another branch, tag, or specific commit.",createWorktreeSubmit:"Create Child Workspace",createWorktreeSubmitting:"Creating...",createWorktreeSucceeded:"Child workspace created: {name}",createWorktreeFailed:"Failed to create child workspace",providerClaudeCode:"Claude Code",providerCodexDescription:"Create a Codex session for the current default workflow.",providerClaudeDescription:"Create a Claude Code session when you want to switch to another conversation chain.",providerOpenCodeDescription:"Create an OpenCode session to continue context via the OpenCode service.",providerGeminiDescription:"Create a Gemini session for the native Gemini CLI workflow.",providerKimiDescription:"Create a Kimi session for the native Kimi CLI workflow.",providerOptionHint:"A session is created immediately after selection",providerChecking:"Checking...",startClaude:"Claude",startCodex:"Codex",startingSession:"Creating...",startClaudeSuccess:"Claude session created",startCodexSuccess:"Codex session created",startSessionFailed:"Failed to create session",auxiliaryTitle:"Info",auxiliarySubtitle:"Files and Git status",expandAuxiliary:"Expand",collapseAuxiliary:"Collapse",auxiliaryEmptyTitle:"Select a session",auxiliaryEmptyBody:"Session files and Git info will appear here",batchSelectSessions:"Select Sessions in Bulk",batchSelectionMode:"Batch Selection",selectAllSessions:"Select All",clearSelectedSessions:"Clear Selection",batchArchiveAction:"Archive Selected",batchArchiving:"Archiving...",batchArchiveSuccess:"Selected sessions archived",batchArchivePartialFailed:"Some sessions failed to archive. Retry.",batchArchiveFailed:"Batch archive failed",hideSessionSidebar:"Hide Session List",showSessionSidebar:"Show Session List",hideInfoSidebar:"Hide Info Sidebar",showInfoSidebar:"Show Info Sidebar",centerTabsLabel:"Center Area Tabs",infoTabsLabel:"Info Sidebar Tabs",leftResizerLabel:"Resize Left Sidebar",rightResizerLabel:"Resize Right Sidebar",filesPanelEmpty:"Import or select a workspace first to use file management.",gitPanelEmpty:"Import or select a workspace first to view Git info.",infoPanelDeferred:"The left session list loads first. The right auxiliary panel mounts slightly later."},workbench:{emptyEyebrow:"Start",emptyTitle:"Choose a session first",emptyBody:"Continue from the left, or create a new session.",emptyResumeTitle:"Continue",emptyResumeBody:"Go back to where you stopped.",emptyNewTitle:"New session",emptyNewBody:"Put a new question into a clean session.",emptyCompanionTitle:"Side details",emptyCompanionBody:"Open files, Git, or terminal on the right when needed.",emptyTip:"When you are ready, pick a session from the left."},conversation:{resendButton:"Resend",historyLoading:"Loading...",historyLoadingOlder:"Loading older messages...",historyLoadFailed:"Load failed",inheritedContextLoading:"Preparing inherited context from the parent session...",inheritedContextMessageLabel:"Inherited context before the forked message",inheritedContextSessionLabel:"Inherited context from the parent session",inheritedContextSummary:'Collapsed {count} inherited messages from "{parentTitle}" by default.',actionInheritedSelectionSummary:'Collapsed the selected text from "{parentTitle}" by default.',inheritedContextExpand:"Show inherited context",inheritedContextCollapse:"Hide inherited context",inheritedContextParentFallback:"Parent session",timelineEmpty:"Start Conversation",composerPlaceholder:"State the next step clearly. Let the session continue from there.",sendButton:"Send Message",attachFiles:"Attach File",attachmentSourceSheetTitle:"Add Files",attachmentSourceSheetDescription:"Choose one or more files from the system picker, or capture a photo.",attachmentTakePhoto:"Take Photo",attachmentTakePhotoHint:"Open the camera and attach a new photo",attachmentChooseFromLibrary:"Choose Files",attachmentChooseFromLibraryHint:"Open the system file picker and add one or more files",pasteImagesHint:"Supports pasting files directly",attachmentImageOnly:"Only image attachments are supported right now",attachmentReadFailed:"Failed to read attachment. Retry.",attachmentPreviewAlt:"Selected image preview",attachmentPreviewOpen:"Open attachment",attachmentPreviewClose:"Close preview",attachmentPreviewLoading:"Loading attachment...",attachmentPreviewUnavailable:"Attachment unavailable",attachmentDownload:"Download attachment",attachmentDropHint:"Drop files here to attach them",imageAttachmentLabel:"Image Attachment",fileAttachmentLabel:"File Attachment",imagePreviewTitle:"Image Preview",imagePreviewHint:"Click the backdrop or press Esc to close the preview",removeAttachment:"Remove Attachment",selectionTodoAction:"Todo",selectionActionButton:"Action",selectionActionSubmit:"Open action child session",selectionActionPromptLabel:"What should it do",selectionActionPromptPlaceholder:"For example: explain this, turn it into notes, or send it to a specific API",selectionActionIncludeContext:"Include current context",selectionActionContextUnavailable:"This selection spans multiple messages, so context inheritance is disabled for safety.",selectionActionDefaultPrompt:"Please process this content.",selectionActionQuotedLabel:"Selected text",selectionActionFailed:"Failed to create the action child session.",actionSessionBadge:"Action",modelSelectorLabel:"Model",modelUseCliDefault:"Default",modelUseCodexConfig:"Follow current Codex config",modelUseOpenCodeConfig:"Follow current OpenCode config",reasoningSelectorLabel:"Reasoning Effort",reasoningLow:"Low",reasoningMedium:"Medium",reasoningHigh:"High",reasoningMaximum:"Maximum",slashMenu:"Commands",slashMenuTitle:"Quick Commands",slashCommandPlan:"Ask for an execution plan first",slashCommandReview:"Switch directly to code review mode",slashCommandExplain:"Ask for a clearer explanation",toolInputLabel:"Input",toolResultLabel:"Result",toolResultEmpty:"No output yet",toolPreviewCommand:"Command",toolPreviewTerminal:"Terminal",toolStatusRunning:"Running",toolStatusFailed:"Failed",toolStatusCompleted:"Completed",runtimeThinkingPlaceholder:"{provider} is thinking...",applyPatchEditedLabel:"Edited",applyPatchAddedLabel:"Added",applyPatchDeletedLabel:"Deleted",applyPatchDialogTitle:"Patch Change Preview",applyPatchDialogDescription:"This shows the file-level changes that apply_patch is about to perform.",applyPatchOpenDiff:"View Diff",applyPatchAddedStat:"Added",applyPatchRemovedStat:"Removed",applyPatchEmpty:"This patch does not contain any file change that can be displayed right now.",titleFallback:"Continue Conversation",draftTitleCodex:"New Codex session",draftTitleClaude:"New Claude Code session",draftTitleOpenCode:"New OpenCode session",draftTitleGemini:"New Gemini session",draftTitleKimi:"New Kimi session",headerWorkspace:"Workspace",headerWorkspaceUnknown:"Unknown Workspace",headerProvider:"Provider",headerConnection:"Connection",headerRuntime:"Runtime",providerCodex:"Codex",branchTreeAction:"Branch Tree",branchTreeTitle:"Branch Tree",branchTreeDescription:"This panel only shows the parent-child chain around the current session.",branchTreeUpstreamLabel:"Upstream Chain",branchTreeCurrentLabel:"Current Session",branchTreeChildrenLabel:"Child Branches",branchTreeCurrentBadge:"Current",branchTreeArchivedBadge:"Archived",branchTreeEmpty:"This session does not have any child branches yet.",branchTreeMapTitle:"Branch Map",branchTreeMapDescription:"This view expands the full branch family around the current session.",branchTreePreviewTitle:"Session Preview",branchTreePreviewDescription:"Click a node to float its latest messages before switching.",branchTreePreviewLoading:"Loading recent messages for this session...",branchTreePreviewFailed:"Failed to load the session preview.",branchTreePreviewEmpty:"There are no recent messages to preview for this session.",branchTreeResizeHandle:"Resize branch tree width",branchTreeZoomInAction:"Zoom in branch map",branchTreeZoomOutAction:"Zoom out branch map",branchTreeZoomResetAction:"Reset branch map zoom",branchTreeSwitchAction:"Switch to This Session",branchTreeCurrentAction:"Already Current",branchTreeToolMessageFallback:"tool message",branchTreeMessageEmpty:"This message does not have visible text.",moreSessionActions:"More session actions",moreSessionActionsTitle:"More Session Actions",moreSessionActionsDescription:"Branch navigation and assistant actions live here so the mobile header stays clean.",branchTreeTab:"Branch Tree",aiAssistantTab:"Assistant",aiAssistantTabDescription:"Use the assistant entry here when you want to continue follow-up or start verification for this session.",providerClaude:"Claude",providerOpenCode:"OpenCode",providerGemini:"Gemini",providerKimi:"Kimi",capabilitySend:"Send Enabled",queueTitle:"Queued Messages",queueDescription:"After the current run finishes, these messages will be processed automatically in order.",queueOrderPrefix:"Queue Position",queueStatusQueued:"Queued",queueStatusFailed:"Dispatch Failed",queueDelete:"Delete",queueDeleting:"Deleting",permissionRequestSectionTitle:"Pending approvals",permissionRequestSectionDescription:"Provider-side approvals are unified here so you do not need to learn three different dialogs.",permissionRequestToastTitle:"Approval needed",backgroundPermissionToastDescription:"{title} · {requestTitle}",backgroundCompletionToastTitle:"Session completed",backgroundCompletionToastDescription:"{title}",backgroundFailureToastTitle:"Session failed",backgroundFailureToastDescription:"{title} · {detail}",permissionRequestReplyFailed:"Failed to reply to the approval request.",permissionRequestSubmitting:"Submitting...",permissionRequestReasonLabel:"Reason",permissionRequestCommandLabel:"Command",permissionRequestToolLabel:"Tool",permissionRequestCwdLabel:"Working directory",permissionRequestPathsLabel:"Related paths",permissionRequestPermissionsLabel:"Requested permissions",permissionRequestReadLabel:"Read",permissionRequestWriteLabel:"Write",permissionRequestNetworkLabel:"Network",permissionRequestQuestionsLabel:"Questions",permissionRequestDetailLabel:"Details",permissionRequestEmpty:"None",permissionRequestUnknown:"Unknown",permissionRequestKindCommand:"Command",permissionRequestKindFileChange:"File Change",permissionRequestKindPermissions:"Permissions",permissionRequestKindUserInput:"User Input",permissionRequestKindToolCall:"Tool Call",queueImageOnly:"Image attachments only",sendGuidanceButton:"Add Guidance",queueGuidanceButton:"Queue Guidance",capabilityDenied:"Restricted",capabilitySendDisabled:"Sending disabled",connectionConnected:"Realtime connected",connectionReconnecting:"Reconnecting",connectionReconnectFailed:"Reconnect failed",connectionClosed:"Connection closed",runtimeIdle:"Idle",runtimeStarting:"Starting",runtimeRunning:"Running",runtimeReconnecting:"Recovering",runtimeStale:"Awaiting confirmation",runtimeUnknown:"Status pending",runtimeCompleted:"Completed",runtimeInterrupted:"Interrupted",runtimeFailed:"Failed",rulesMessageTitle:"Rules",rulesMessageHint:"This is the startup rule block for the session. It is collapsed by default and can be expanded when needed.",rulesMessageExpand:"Expand Rules",rulesMessageCollapse:"Collapse Rules",systemPromptTitle:"System Prompt",systemPromptHint:"This is the Kimi startup system prompt for the session. It is collapsed by default and can be expanded when needed.",systemPromptExpand:"Expand Prompt",systemPromptCollapse:"Collapse Prompt",taskProgressButton:"Task Progress ({count})",taskProgressModalTitle:"Task Progress",taskProgressModalDescription:"This session has recorded {count} tasks. Check the latest progress here.",taskProgressExplanationTitle:"Latest Update Note",taskProgressSummaryTotal:"Total",taskProgressStatusPending:"Pending",taskProgressStatusInProgress:"In Progress",taskProgressStatusCompleted:"Completed",taskProgressStatusFailed:"Failed",taskProgressStatusCancelled:"Cancelled",taskCardPlanTitle:"Plan Update",taskCardTodoTitle:"Task Update",taskCardPlanUpdated:"Latest Plan",taskCardTodoUpdated:"Latest Task List",taskCardRawExpand:"Show Raw Call",taskCardRawCollapse:"Hide Raw Call",taskCardSummaryTotal:"{count} total",taskCardSummaryInProgress:"{count} in progress",taskCardSummaryPending:"{count} pending",taskCardSummaryCompleted:"{count} completed",taskCardSummaryFailed:"{count} failed",butlerActionButton:"Assistant",butlerActionModalTitle:"Butler Actions",butlerActionModalDescription:"Ask Butler to continue this development session or start a development verification run.",butlerActionLoading:"Loading Butler action context...",butlerActionLoadFailed:"Failed to load Butler action context",butlerActionProjectLabel:"Project",butlerActionSessionLabel:"Session",butlerFollowUpAction:"Follow Up This Session",butlerFollowUpActionDescription:"Let Butler keep watching this session and continue pushing it after each stop or blocker.",butlerFollowUpObjectiveLabel:"Follow-up Goal",butlerFollowUpObjectivePlaceholder:"Example: finish this feature for me; if the spec still has unfinished work, keep going.",butlerFollowUpCompletionCriteriaLabel:"Finish Conditions",butlerFollowUpCompletionCriteriaPlaceholder:"Example: only stop once the current feature is finished against the agreed requirements.",butlerFollowUpRoundLimitLabel:"Max Auto Follow-up Rounds",butlerFollowUpRoundLimitHint:"Once the limit is reached, Butler stops auto-resuming so the session does not expand forever.",butlerCurrentFollowUpLabel:"Current Follow-up",butlerCurrentFollowUpProgress:"Auto-continued {current} / {max} rounds",butlerStopFollowUpAction:"Stop Current Follow-up",butlerFollowUpObjectiveRequired:"Please describe the goal you want Butler to keep pushing",butlerVerificationAction:"Start Development Verification",butlerVerificationActionDescription:"Let Butler start a user-facing verification run for the feature behind this session.",butlerFollowUpStarted:"Butler follow-up started",butlerFollowUpStartedDescription:"Butler will continue following the current development session for {projectName}.",butlerFollowUpFailed:"Failed to start Butler follow-up",butlerFollowUpStopped:"Current Butler follow-up stopped",butlerFollowUpStoppedDescription:"Automatic follow-up for the current session has been stopped and will not auto-resume.",butlerFollowUpStopFailed:"Failed to stop Butler follow-up",butlerVerificationStarted:"Development verification started",butlerVerificationStartedDescription:"Butler will start a development verification run for {projectName}.",butlerVerificationFailed:"Failed to start development verification",butlerAnalysisTitle:"Butler Analysis",butlerAnalysisLoadFailed:"Failed to load Butler analysis",butlerAnalysisObjectiveLabel:"Objective",butlerAnalysisStatusLabel:"Decision",butlerAnalysisSummaryLabel:"Latest analysis",butlerAnalysisWaitingReasonLabel:"Waiting reason",butlerAnalysisEmpty:"There is no Butler analysis record yet.",butlerProxyMessageBadge:"Sent by Butler",butlerOriginDetailTitle:"Related Butler Follow-up",butlerOriginDetailLoading:"Loading the related Butler follow-up...",butlerOriginDetailLoadFailed:"Failed to load the related Butler follow-up",butlerOriginDetailObjectiveLabel:"Objective",butlerOriginDetailStatusLabel:"Status",butlerOriginDetailSummaryLabel:"Latest analysis",butlerOriginDetailWaitingReasonLabel:"Waiting reason",thinkingLabel:"Thinking",filePanelWorkspaceTab:"Workspace",filePanelSessionTab:"Session",filePanelSessionViewLabel:"Session File View",filePanelSessionTreeView:"Tree",filePanelSessionListView:"List",filePanelSessionLoading:"Collecting files changed in this session...",filePanelSessionEmpty:"No cacheable changed files have been detected in this session yet.",filePanelSessionNoSession:"Only the workspace is selected right now. Pick a session before viewing session-scoped files.",filePanelSessionStageAll:"Stage All",filePanelSessionStageSuccess:"Changes from this session have been added to the staging area.",filePanelSessionLoadFailed:"Failed to load changed files for this session.",filePanelSessionSummary:"Detected Files",filePanelSessionUnstagedSummary:"Unstaged",filePanelSessionDeleted:"Deleted",filePanelOpenExternalWindow:"Open in New Window",filePanelOpenExternalFailed:"Failed to open the file window externally."},desktopWindow:{invalidWindowId:"The external window is missing a window id.",loadDescriptorFailed:"Failed to load the window descriptor.",unsupportedKind:"Rendering the {kind} window is not supported yet."},git:{recentVersionsTitle:"Recent Versions",stagedChangesTitle:"Staged Changes",expandRecentVersions:"Expand Recent Versions",collapseRecentVersions:"Collapse Recent Versions",stagedLabel:"Staged",workingTreeLabel:"Working Tree",changeTreeHint:"Show current changes by directory hierarchy",discard:"Discard Changes",discardFailed:"Failed to discard changes",operationMenu:"Actions",currentBranch:"Current Branch",resizePanels:"Resize file and recent-version panels",switchBranchTo:"Switch To",undoLastCommit:"Undo Last Commit",undoLastCommitFailed:"Failed to undo last commit",undoLastCommitSuccess:"Last commit undone",historyKindLocal:"Local",historyKindRemote:"Remote",historyKindShared:"Synced",pushNow:"Push",commitNow:"Commit",refreshNow:"Refresh",openExternalWindow:"Open Git in New Window",openExternalFailed:"Failed to open the Git window externally.",stageAll:"Stage All",unstageAll:"Unstage All",discardAll:"Discard All Changes",selectedFiles:"Selected Files",clearSelection:"Clear Selection",selectFile:"Select File",discardConfirm:"Discard these changes? {path}",historyItemMenu:"Commit Actions",copyCommitHash:"Copy Commit Hash",copyCommitHashSuccess:"Commit hash copied.",copyCommitSubject:"Copy Commit Title",copyCommitSubjectSuccess:"Commit title copied."},terminalManager:{workspaceField:"Current Workspace",refresh:"Refresh List",loadFailed:"Failed to load the terminal management panel",shellLoadFailed:"Failed to load the terminal shell list",emptyWorkspaceBody:"There is no available workspace yet.",noCurrentWorkspaceBody:"Select a session first so process management can bind to its workspace.",emptyTerminalBody:"There is no terminal instance in the current workspace yet.",emptyTemplateBody:"There is no quick launch item yet. Save a command or script first.",shellField:"Shell for New Terminal",shellUnavailable:"Unavailable",cwdField:"Startup Directory",cwdLabel:"Directory",cwdPlaceholder:"Defaults to the workspace root when left empty",modeField:"Launch Mode",commandMode:"Command",scriptMode:"Script",quickLaunchTitle:"Quick Launch",quickLaunchDescription:"Save a launch preset here so you can start it in a new terminal with one click later.",desktopPanelDescription:"Keep the default view focused on launch decisions, while paths and command lines stay inside the details layer.",openExternalWindow:"Open in New Window",openExternalFailed:"Failed to open the process management window externally.",runningCountLabel:"Running",portWatchCountLabel:"Watched Ports",terminalCountLabel:"Terminals",templateSectionTitle:"Launch Items",templateSectionDescription:"The right side prioritizes the port status of launch items so you can see whether a service is already in use.",openCreateModalAction:"Add Quick Launch Item",createModalTitle:"Add Quick Launch Item",createModalDescription:"Save a command or script here. You can attach a port and then start it with one click while checking whether it is already running.",editAction:"Edit Launch Item",editModalTitle:"Edit Quick Launch Item",editModalDescription:"Update the name, command, directory, and port for this quick launch item.",saveTemplateChangesAction:"Save Changes",templateUpdating:"Saving changes...",templateUpdateSuccess:"Quick launch item updated.",templateUpdateFailed:"Failed to update quick launch item",removeAction:"Remove Launch Item",templateRemoving:"Removing...",removeConfirmTitle:"Remove Quick Launch Item",removeConfirmAction:"Remove Item",removeConfirmTarget:'Remove "{name}"? It will disappear from the quick launch list after removal.',removeRunningConfirmTarget:'"{name}" is still running. Removing it only deletes the launch item configuration and will not stop the active process. Continue?',templateDeleteSuccess:"Quick launch item removed.",templateDeleteFailed:"Failed to remove quick launch item",terminalSectionTitle:"Terminal Instances",terminalSectionDescription:"This area shows terminals currently managed by CodingNS for the workspace.",closeAction:"Close Terminal",closing:"Closing...",closeSuccess:"Terminal close request submitted.",closeFailed:"Failed to close terminal",createTerminalAction:"New Empty Terminal",creatingTerminal:"Creating...",createTerminalSuccess:"New terminal created.",createTerminalFailed:"Failed to create a new terminal",defaultTerminalName:"Workspace Terminal",templateNameField:"Name",templateNamePlaceholder:"Generated automatically when left empty",commandField:"Launch Command",commandPlaceholder:"For example: npm",scriptPathField:"Script Path",scriptPathPlaceholder:"For example: scripts/dev.ps1 or scripts/dev.sh",argsField:"Arguments",argsPlaceholder:"For example: run dev or --watch",portField:"Listening Port",portLabel:"Port",portPlaceholder:"For example: 3000",proxyField:"Reverse Proxy",proxyToggleLabel:"Enable Reverse Proxy",proxyEnabled:"Proxy Enabled",proxyEnabledDescription:"When enabled, the system generates a random URL code and exposes your dev service under /proxy/.",proxyDisabledDescription:"Reverse proxy is disabled",proxyPortRequired:"A listening port is required when reverse proxy is enabled",openProxyUrlAction:"Open Proxy URL",openProxyUrlFailed:"Failed to open proxy URL",invalidPort:"Port must be an integer between 1 and 65535",saveLaunchAction:"Save as Quick Launch",templateSaving:"Saving...",templateSaveSuccess:"Quick launch item saved.",templateSaveFailed:"Failed to save quick launch item",runTemplateAction:"Run in New Terminal",runningTemplate:"Starting...",templateRunSuccess:"Quick launch item sent to a new terminal.",templateRunFailed:"Failed to run quick launch item",showDetailsAction:"Show details",hideDetailsAction:"Hide details",detailsSectionTitle:"Launch item details",commandPreviewLabel:"Launch Command",processIdLabel:"Listener PID",processGroupIdLabel:"Process Group PGID",processCommandLabel:"Listener Command Line",parentProcessIdLabel:"Parent PID",parentProcessCommandLabel:"Parent Command Line",terminationScopeLabel:"Stop Scope",terminationScopeProcess:"Listener only",terminationScopeProcessGroup:"Whole process group",stopProcessAction:"Stop Process",stoppingProcess:"Stopping...",stopProcessSuccess:"The listening process or its process group has been stopped.",stopProcessFailed:"Failed to stop the listening process or process group",defaultCommandName:"New Launch Command",defaultScriptName:"New Launch Script",lastActiveAt:"Last Active",updatedAt:"Updated At",processCommandFallback:"This process did not expose its command line",portUnset:"Port Not Configured",portUnsetDescription:"Without a port, the item can only be started. The system cannot determine automatically whether the service is running.",portOccupied:"Process Started",portAvailable:"Port Available",portAvailableDescription:"There is currently no listening process on the port used by this launch item.",statusRunning:"Running",statusStopped:"Stopped",exitCode:"Exit Code",runningValue:"Running"},theme:{light:"浅色",dark:"深色",skyBlue:"赛博",eyeGreen:"护眼",switchLabel:"Theme"}},hN={"zh-CN":H1,"en-US":U1},V1={butlerInitTitle:"设置助手",butlerInitDescription:"先完成几个基本设置。",butlerInitPreviewTitle:"当前效果",butlerInitPreviewDescription:"",butlerInitBasicsTitle:"基本信息",butlerInitBasicsDescription:"",butlerInitPersonaTitle:"说话方式",butlerInitPersonaDescription:"",butlerInitPreferenceTitle:"默认偏好",butlerInitPreferenceDescription:"",butlerInitRuleLabel:"规则方式",butlerInitPreviewRuleLabel:"管理方式",butlerInitTipAutoWorkspace:"",butlerInitTipProviderSwitch:"",butlerInitTipReportPriority:"",butlerDisplayNameLabel:"助手称呼",butlerDisplayNamePlaceholder:"例如:小助手",butlerDisplayNameHint:"这个名字会显示在助手页面里。",butlerProviderLabel:"助手引擎",butlerAgentsModeLabel:"规则方式",butlerAgentsModeInline:"自动管理",butlerAgentsModeFile:"手动编辑",butlerAgentsModeInlineDescription:"规则由系统自动管理。",butlerAgentsModeFileDescription:"会生成一份可编辑的规则文件。",butlerPersonaToneLabel:"语气",butlerPersonaLanguageLabel:"使用语言",butlerPersonaSummaryStyleLabel:"回答风格",butlerFocusRiskPreferenceLabel:"处理方式",butlerFocusReportPriorityLabel:"优先提醒",butlerToneDirect:"直接",butlerToneSteady:"稳重",butlerToneFriendly:"亲切",butlerLanguageZhCn:"中文",butlerLanguageEnUs:"英文",butlerLanguageBilingual:"中英双语",butlerSummaryBrief:"简洁",butlerSummaryStructured:"清晰",butlerSummaryThorough:"详细",butlerRiskConservative:"保守稳妥",butlerRiskBalanced:"平衡",butlerRiskProactive:"主动提醒",butlerReportPriorityPresetLabel:"优先提醒",butlerSummaryDebounceLabel:"摘要节奏",butlerSettingsTitle:"助手设置",butlerSettingsSaveAction:"保存设置",butlerSettingsSaving:"保存中...",butlerSettingsSaved:"助手设置已保存",butlerSettingsSaveFailed:"保存助手设置失败",butlerInitSubmitting:"保存中...",butlerInitSubmit:"完成设置",butlerInitSuccess:"助手已设置完成",butlerInitFailed:"助手设置失败",butlerInitNameRequired:"请先填写助手名称"},G1={butlerInitTitle:"Set Up Butler",butlerInitDescription:"Finish a few basic settings first.",butlerInitPreviewTitle:"Preview",butlerInitPreviewDescription:"",butlerInitBasicsTitle:"Basic Info",butlerInitBasicsDescription:"",butlerInitPersonaTitle:"Voice",butlerInitPersonaDescription:"",butlerInitPreferenceTitle:"Default Preferences",butlerInitPreferenceDescription:"",butlerInitRuleLabel:"Rule Style",butlerInitPreviewRuleLabel:"Mode",butlerInitTipAutoWorkspace:"",butlerInitTipProviderSwitch:"",butlerInitTipReportPriority:"",butlerDisplayNameLabel:"Butler Name",butlerDisplayNamePlaceholder:"Example: Butler",butlerDisplayNameHint:"This name appears on the Butler page.",butlerProviderLabel:"Engine",butlerAgentsModeLabel:"Rule Style",butlerAgentsModeInline:"Auto",butlerAgentsModeFile:"Editable File",butlerAgentsModeInlineDescription:"Rules are managed automatically.",butlerAgentsModeFileDescription:"An editable rule file will be created.",butlerPersonaToneLabel:"Tone",butlerPersonaLanguageLabel:"Language",butlerPersonaSummaryStyleLabel:"Reply Style",butlerFocusRiskPreferenceLabel:"Work Style",butlerFocusReportPriorityLabel:"Priority",butlerToneDirect:"Direct",butlerToneSteady:"Steady",butlerToneFriendly:"Friendly",butlerLanguageZhCn:"Chinese",butlerLanguageEnUs:"English",butlerLanguageBilingual:"Bilingual",butlerSummaryBrief:"Brief",butlerSummaryStructured:"Clear",butlerSummaryThorough:"Detailed",butlerRiskConservative:"Conservative",butlerRiskBalanced:"Balanced",butlerRiskProactive:"Proactive",butlerReportPriorityPresetLabel:"Priority",butlerSummaryDebounceLabel:"Summary Cadence",butlerSettingsTitle:"Butler Settings",butlerSettingsSaveAction:"Save Settings",butlerSettingsSaving:"Saving...",butlerSettingsSaved:"Butler settings saved",butlerSettingsSaveFailed:"Failed to save Butler settings",butlerInitSubmitting:"Saving...",butlerInitSubmit:"Finish Setup",butlerInitSuccess:"Butler is ready",butlerInitFailed:"Failed to save Butler settings",butlerInitNameRequired:"Please enter a Butler name"};function nx(e,t){const r=e.shell;return{...e,shell:{...r&&typeof r=="object"?r:{},...t}}}const mN={"zh-CN":nx(q1,V1),"en-US":nx($1,G1)};function _h(e,t){const r=e.split(".");let s=t;for(const i of r){if(!s||typeof s=="string")return e;const l=s[i];if(l==null)return e;s=l}return typeof s=="string"?s:e}function K1(){return xi.getState().profile.language??"zh-CN"}function o(e,t){const s=K1()==="en-US"?["en-US","zh-CN"]:["zh-CN"];for(const i of s){const l=_h(e,mN[i]);if(l!==e)return of(l,t);const c=_h(e,hN[i]);if(c!==e)return of(c,t)}return of(e,t)}function of(e,t){return t?e.replace(/\{([^}]+)\}/g,(r,s)=>{const i=t[s];return i==null?r:String(i)}):e}function Y1({children:e,language:t}){return p.useEffect(()=>{document.documentElement.setAttribute("lang",t)},[t]),e}function X1(){const e=ca(t=>t.profile.language);return t=>{const r=e==="en-US"?["en-US","zh-CN"]:["zh-CN"];for(const s of r){const i=_h(t,mN[s]);if(i!==t)return i;const l=_h(t,hN[s]);if(l!==t)return l}return t}}const pN=[{id:"light",labelKey:"theme.light",color:"#f6f4ef"},{id:"dark",labelKey:"theme.dark",color:"#1b1b1b"},{id:"sky-blue",labelKey:"theme.skyBlue",color:"#00f0ff"},{id:"eye-green",labelKey:"theme.eyeGreen",color:"#16a34a"}];function fN(e){return o(e.labelKey)}function Q1(){return typeof window>"u"||typeof window.matchMedia!="function"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function gN(e,t){return t?Q1():e}function J1(){const{theme:e,autoTheme:t}=xi.getState().profile;return gN(e,t)}function Z1(e){Qc({theme:e,autoTheme:!1}).catch(()=>{})}function eL(e){Qc({autoTheme:e}).catch(()=>{})}function bN(e){typeof window>"u"||document.documentElement.setAttribute("data-theme",e)}function vN(){const e=ca(s=>s.profile.theme),t=ca(s=>s.profile.autoTheme);return{theme:gN(e,t),selectedTheme:e,autoTheme:t,setTheme:Z1,setAutoTheme:eL}}function tL(){bN(J1())}function nL({children:e}){const t=ca(s=>s.profile.theme),r=ca(s=>s.profile.autoTheme);return p.useEffect(()=>{tL()},[t,r]),p.useEffect(()=>{if(!r||typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{bN(s.matches?"dark":"light")};return i(),typeof s.addEventListener=="function"?(s.addEventListener("change",i),()=>s.removeEventListener("change",i)):(s.addListener(i),()=>s.removeListener(i))},[r]),n.jsx(n.Fragment,{children:e})}const rL={showToast:()=>"",dismissToast:()=>{}},wN=p.createContext(rL);function sL(){return`toast-${Math.random().toString(36).slice(2,10)}`}function iL({toast:e,onDismiss:t}){const{id:r,title:s,description:i,tone:l,durationMs:c,action:d}=e;return p.useEffect(()=>{if(c===null)return;const m=window.setTimeout(()=>{t(r)},c);return()=>{window.clearTimeout(m)}},[c,r,t,s,i,l]),n.jsxs("article",{className:"toast-card","data-tone":l,role:l==="error"?"alert":"status",children:[n.jsxs("div",{className:"toast-body",children:[n.jsx("strong",{className:"toast-title",children:s}),i?n.jsx("p",{className:"toast-description",children:i}):null]}),n.jsxs("div",{className:"toast-actions",children:[d?n.jsx("button",{className:"toast-action",type:"button",onClick:()=>{d.onClick(),t(r)},children:d.label}):null,n.jsx("button",{className:"toast-dismiss",type:"button","aria-label":"关闭通知",onClick:()=>t(r),children:"×"})]})]})}function aL({children:e}){const[t,r]=p.useState([]),s=p.useCallback(c=>{r(d=>d.filter(m=>m.id!==c))},[]),i=p.useCallback(c=>{const d=c.id??sL(),m={id:d,title:c.title,description:c.description,tone:c.tone??"info",durationMs:c.durationMs===void 0?4200:c.durationMs,action:c.action};return r(f=>{const v=f.findIndex(w=>w.id===d);if(v===-1)return[...f,m];const g=[...f];return g[v]=m,g}),d},[]),l=p.useMemo(()=>({showToast:i,dismissToast:s}),[s,i]);return n.jsxs(wN.Provider,{value:l,children:[e,n.jsx("div",{className:"toast-viewport","aria-live":"polite","aria-atomic":"false",children:t.map(c=>n.jsx(iL,{toast:c,onDismiss:s},c.id))})]})}function Qn(){return p.useContext(wN)}const mh="0.3.5",yN=p.createContext(mh);function oL({children:e}){const t=nr(),[r,s]=p.useState(mh);return p.useEffect(()=>{let i=!1;return t.isDesktop?(t.bridge.getRuntimeInfo().then(l=>{var d,m;if(i)return;const c=l.ok?(m=(d=l.value)==null?void 0:d.version)==null?void 0:m.trim():"";s(c||mh)}),()=>{i=!0}):(s(mh),()=>{i=!0})},[t]),n.jsx(yN.Provider,{value:r,children:e})}function kN(){return p.useContext(yN)}async function xN(){const e=$s(),t=En.getState(),r=await e.bridge.checkForUpdate(t.releaseChannel);if(!r.ok||!r.value)throw new Error(r.detail??"更新检查失败。");return r.value}async function lL(){const e=$s(),t=En.getState();return e.bridge.installUpdate(t.releaseChannel)}function cL(){const e=Rl(s=>s.platform),t=Rl(s=>s.autoCheckUpdate),r=p.useRef(!1);return p.useEffect(()=>{if(r.current||e!=="desktop"||!t)return;r.current=!0;let s=!1;async function i(){var l;try{const c=await xN();if(s||!c.hasUpdate)return;await $s().bridge.showNotification(o("settings.releaseUpdateReady"),((l=c.manifest)==null?void 0:l.version)??c.currentVersion)}catch{}}return i(),()=>{s=!0}},[t,e]),null}class uL{constructor(){ot(this,"state",{epoch:0,activeHostId:En.getState().activeHostId});ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);En.subscribe(()=>{const t=En.getState().activeHostId;t!==this.state.activeHostId&&(this.state={epoch:this.state.epoch+1,activeHostId:t},this.emit())})}emit(){for(const t of this.listeners)t()}}const rx=new uL;function dL(){return p.useSyncExternalStore(rx.subscribe,()=>{const e=rx.getState();return`${e.activeHostId??"anonymous"}:${e.epoch}`})}const SN="codingns.server.base-url.history",CN=6,jN="__custom__";function TN(){return typeof window<"u"&&typeof window.localStorage<"u"}function hL(){return typeof window>"u"||!window.location.origin?null:window.location.origin}function NN(e){if(!e)return null;try{return Ci(e)}catch{return null}}function mL(){if(!TN())return[];const e=window.localStorage.getItem(SN);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(r=>typeof r=="string"?NN(r):null).filter(r=>!!r):[]}catch{return[]}}function pL(e){const t=new Set,r=[];for(const s of e)!s||t.has(s)||(t.add(s),r.push(s));return r}function fL(e,t){const r=mL();return pL([e,...t,...r,NN(hL())]).slice(0,CN)}function gL(e){TN()&&window.localStorage.setItem(SN,JSON.stringify(e.slice(0,CN)))}class bL{constructor(){ot(this,"state",this.createState(En.getState()));ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);En.subscribe(()=>{const t=this.createState(En.getState());t.baseUrl===this.state.baseUrl&&t.options.length===this.state.options.length&&t.options.every((r,s)=>r===this.state.options[s])||(this.state=t,this.emit())})}setBaseUrl(t){const r=En.getState(),s=za(r);if(!s)return!1;const i=Ci(t),l=i!==s.baseUrl,c=r.hosts.map(d=>d.id===s.id?{...d,baseUrl:i,name:new URL(i).host,updatedAt:new Date().toISOString()}:d);return this.state=this.createState({...r,hosts:c}),this.emit(),En.update({hosts:c}),l}reset(){this.state=this.createState(En.getState()),this.emit()}createState(t){const r=za(t),s=(r==null?void 0:r.baseUrl)??"",i=fL(s,t.hosts.map(l=>l.baseUrl));return gL(i),{baseUrl:s,options:i}}emit(){for(const t of this.listeners)t()}}const Oh=new bL;function Bh(e){return p.useSyncExternalStore(Oh.subscribe,()=>e(Oh.getState()))}function vL(e,t){return t.includes(e)?e:jN}function wL(){return jN}const PN={login(e,t){return br.login(e,t)},bootstrap(e,t,r){return br.bootstrap(e,t,r)},refresh(){return br.refresh()},logout(){br.clear()}};function yL(){const e=vr(),t=Bh(C=>C.baseUrl),[r,s]=p.useState("admin"),[i,l]=p.useState(""),[c,d]=p.useState(""),[m,f]=p.useState(null),[v,g]=p.useState("error"),[w,k]=p.useState(!1);async function y(C){if(C.preventDefault(),i!==c){g("error"),f(o("auth.bootstrapMismatch"));return}k(!0),f(null);try{await PN.bootstrap(r,i),g("success"),f(o("auth.bootstrapSuccess")),window.setTimeout(()=>e("/login",{replace:!0}),500)}catch(T){g("error"),T instanceof Ur?f(T.message):f(o("auth.authUnavailable"))}finally{k(!1)}}return n.jsx("main",{className:"page-center app-shell",children:n.jsxs("section",{className:"auth-card surface-card",children:[n.jsx("h1",{children:o("auth.bootstrapTitle")}),n.jsx("p",{className:"status-text",children:o("auth.bootstrapSubtitle")}),n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("auth.serverCurrent")}),n.jsx("span",{className:"auth-server-value",children:t})]}),n.jsxs("form",{className:"auth-form",onSubmit:y,children:[n.jsxs("label",{className:"field-group",children:[n.jsx("span",{children:o("auth.username")}),n.jsx("input",{value:r,onChange:C=>s(C.target.value)})]}),n.jsxs("label",{className:"field-group",children:[n.jsx("span",{children:o("auth.password")}),n.jsx("input",{type:"password",value:i,onChange:C=>l(C.target.value)})]}),n.jsxs("label",{className:"field-group",children:[n.jsx("span",{children:o("auth.confirmPassword")}),n.jsx("input",{type:"password",value:c,onChange:C=>d(C.target.value)})]}),m?n.jsx("p",{className:"status-text","data-tone":v,children:m}):null,n.jsx("button",{className:"primary-button",type:"submit",disabled:w,children:o(w?"common.loading":"auth.submitBootstrap")})]})]})})}async function DN(e){try{return{...await PI(e),reachable:!0}}catch{return{initialized:!1,reachable:!1}}}function kL({isOpen:e,onClose:t,onSave:r,theme:s="dark"}){const i=Bh(N=>N.baseUrl),l=Bh(N=>N.options),c=wL(),[d,m]=p.useState(i),[f,v]=p.useState(null),g=p.useMemo(()=>{try{return Ci(d)}catch{return null}},[d]),w=vL(g??d,l),k="server-settings-preset",y="server-settings-address";if(p.useEffect(()=>{e&&(m(i),v(null))},[e,i]),!e)return null;function C(){if(!g){v(o("auth.serverInvalid"));return}Oh.setBaseUrl(g),r==null||r(g),t()}function T(N){N.target===N.currentTarget&&t()}function j(){g&&m(g)}return n.jsx("div",{className:"server-settings-modal-backdrop","data-theme":s,onClick:T,role:"dialog","aria-modal":"true","aria-labelledby":"server-settings-title",children:n.jsxs("div",{className:"server-settings-modal",children:[n.jsxs("div",{className:"server-settings-modal-header",children:[n.jsx("div",{className:"cyber-header-line"}),n.jsxs("h2",{id:"server-settings-title",className:"cyber-title",children:[n.jsx("span",{className:"cyber-title-icon",children:"◈"}),o("auth.serverSettingsTitle")]}),n.jsx("div",{className:"cyber-header-line"}),n.jsx("button",{className:"server-settings-close",onClick:t,"aria-label":o("common.close"),children:"×"})]}),n.jsxs("div",{className:"server-settings-modal-content",children:[n.jsxs("label",{className:"field-group cyber-field",htmlFor:k,children:[n.jsx("span",{className:"cyber-label",children:o("auth.serverPreset")}),n.jsxs("div",{className:"cyber-select-wrapper",children:[n.jsxs("select",{id:k,"aria-label":o("auth.serverPreset"),className:"cyber-select",value:w,onChange:N=>{const D=N.target.value;D!==c&&(m(D),v(null))},children:[l.map(N=>n.jsx("option",{value:N,children:N},N)),n.jsx("option",{value:c,children:o("auth.serverCustomOption")})]}),n.jsx("span",{className:"cyber-select-arrow",children:"▼"})]})]}),n.jsxs("label",{className:"field-group cyber-field",htmlFor:y,children:[n.jsx("span",{className:"cyber-label",children:o("auth.serverAddress")}),n.jsxs("div",{className:"cyber-input-wrapper",children:[n.jsx("input",{id:y,"aria-label":o("auth.serverAddress"),className:"cyber-input",value:d,placeholder:o("auth.serverPlaceholder"),onBlur:j,onChange:N=>{m(N.target.value),v(null)}}),n.jsx("div",{className:"cyber-input-glow"})]})]}),n.jsxs("p",{className:"cyber-hint",children:[n.jsx("span",{className:"cyber-hint-icon",children:"ℹ"}),o("auth.serverHint")]}),f?n.jsxs("p",{className:"cyber-status","data-tone":"error",children:[n.jsx("span",{className:"cyber-status-icon",children:"⚠"}),f]}):null]}),n.jsxs("div",{className:"server-settings-modal-footer",children:[n.jsx("button",{className:"cyber-button cyber-button-secondary",onClick:t,children:o("common.cancel")}),n.jsxs("button",{className:"cyber-button cyber-button-primary",onClick:C,children:[n.jsx("span",{className:"cyber-button-glow"}),n.jsx("span",{className:"cyber-button-text",children:o("auth.saveServerSettings")})]})]})]})})}const sx="width=device-width, initial-scale=1.0, viewport-fit=cover",xL="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover";function SL(){const e=p.useRef(null);return p.useEffect(()=>{const t=e.current;if(!t)return;const r=t.getContext("2d");if(!r)return;let s;const i=()=>{c(),d()};let l=[];const c=()=>{t.width=window.innerWidth,t.height=window.innerHeight},d=()=>{l=[];const f=Math.min(50,Math.floor(t.width*t.height/25e3));for(let v=0;v<f;v++)l.push({x:Math.random()*t.width,y:Math.random()*t.height,vx:(Math.random()-.5)*.5,vy:(Math.random()-.5)*.5,size:Math.random()*2+1,opacity:Math.random()*.5+.2})},m=()=>{r.clearRect(0,0,t.width,t.height),l.forEach((f,v)=>{f.x+=f.vx,f.y+=f.vy,f.x<0&&(f.x=t.width),f.x>t.width&&(f.x=0),f.y<0&&(f.y=t.height),f.y>t.height&&(f.y=0),r.beginPath(),r.arc(f.x,f.y,f.size,0,Math.PI*2),r.fillStyle=`rgba(10, 132, 255, ${f.opacity})`,r.fill(),l.slice(v+1).forEach(g=>{const w=f.x-g.x,k=f.y-g.y,y=Math.sqrt(w*w+k*k);y<150&&(r.beginPath(),r.moveTo(f.x,f.y),r.lineTo(g.x,g.y),r.strokeStyle=`rgba(10, 132, 255, ${.1*(1-y/150)})`,r.stroke())})}),s=requestAnimationFrame(m)};return c(),d(),m(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i),cancelAnimationFrame(s)}},[]),n.jsx("canvas",{ref:e,className:"particle-canvas"})}function CL({text:e}){return n.jsx("span",{className:"glitch-text","data-text":e,children:e})}function jL({text:e}){const[t,r]=p.useState(""),[s,i]=p.useState(!0);return p.useEffect(()=>{let l=0,c=null;const d=setInterval(()=>{l<=e.length?(r(e.slice(0,l)),l++):(clearInterval(d),c=window.setTimeout(()=>i(!1),1e3))},50);return()=>{clearInterval(d),c!==null&&window.clearTimeout(c)}},[e]),n.jsxs("span",{className:"typewriter-text",children:[t,s&&n.jsx("span",{className:"typewriter-cursor",children:"_"})]})}function TL(e){const t=e==null?void 0:e.captcha;if(typeof t!="object"||t===null)return null;const r=t.captchaId,s=t.imageDataUrl;return typeof r!="string"||typeof s!="string"?null:{captchaId:r,imageDataUrl:s}}function NL(){const e=vr(),t=X1(),[r]=A1(),s=nr(),i=kN(),l=Rl(xe=>xe.activeHostId),c=_b(s.platform),d=p.useMemo(()=>WA(s),[s]),m=p.useMemo(()=>d?UA(l):{credentials:null,legacyServerBaseUrl:null},[l,d]),f=m.credentials,v=m.legacyServerBaseUrl,[g,w]=p.useState(()=>(f==null?void 0:f.username)??"admin"),[k,y]=p.useState(()=>(f==null?void 0:f.password)??""),[C,T]=p.useState(null),[j,N]=p.useState(""),[D,F]=p.useState(()=>!!f),W=Bh(xe=>xe.baseUrl),[E,I]=p.useState(W),[M,_]=p.useState(null),[L,Q]=p.useState(!1),[O,ne]=p.useState(!1),[Y,G]=p.useState(null),[te,K]=p.useState(!1),z=gu(xe=>xe.session),q=p.useMemo(()=>r.get("returnTo")??"/",[r]),{theme:P}=vN(),U=p.useRef(!1),X=s.isNativeMobile,R=p.useMemo(()=>P==="light"?"light":"dark",[P]);p.useEffect(()=>{w((f==null?void 0:f.username)??"admin"),y((f==null?void 0:f.password)??""),T(null),N(""),F(!!f)},[f]),p.useEffect(()=>{if(typeof document>"u")return;const xe=document.querySelector('meta[name="viewport"]');if(!(xe instanceof HTMLMetaElement))return;const lt=xe.getAttribute("content")??sx;return X?xe.setAttribute("content",xL):xe.setAttribute("content",sx),()=>{xe.setAttribute("content",lt)}},[X]),p.useEffect(()=>{U.current||(U.current=!0,!(!d||!v||v===W)&&(Oh.setBaseUrl(v),I(v)))},[W,d,v]),p.useEffect(()=>{if(z){e(q,{replace:!0});return}if(!E)return;let xe=!1;return DN(E).then(lt=>{xe||(lt.demoMode&&(K(!0),NI()&&_(t("auth.demoSessionExpired"))),lt.reachable&&!lt.initialized&&e("/bootstrap",{replace:!0}))}).catch(()=>{xe||_(t("auth.authUnavailable"))}),()=>{xe=!0}},[z,e,E,q,t]);async function Se(xe){xe.preventDefault(),Q(!0),_(null),I(W),d&&!D&&l&&qA(l);try{const lt=C?{username:g,password:k,captchaId:C.captchaId,captchaCode:j}:{username:g,password:k};await PN.login(lt,W),T(null),N(""),await xi.refreshForAuthenticatedUser(),d&&D&&l&&HA({hostId:l,username:g,password:k}),e(q,{replace:!0})}catch(lt){if(lt instanceof Ur){if(lt.errorCode==="BOOTSTRAP_REQUIRED"){e("/bootstrap",{replace:!0});return}const Oe=TL(lt.data);Oe?(T(Oe),N("")):lt.errorCode==="INVALID_CREDENTIALS"&&(T(null),N("")),_(lt.message)}else _(t("auth.authUnavailable"))}finally{Q(!1)}}function se(xe){w(xe),C&&(T(null),N(""))}function J(xe){I(xe),_(null)}const Ne="login-username",Ee="login-password",ie="login-captcha";return n.jsxs("main",{className:"cyber-login-page","data-theme":R,"data-native-mobile":X?"true":"false",children:[n.jsxs("div",{className:"cyber-bg",children:[n.jsx("div",{className:"cyber-grid"}),n.jsx("div",{className:"cyber-glow cyber-glow-1"}),n.jsx("div",{className:"cyber-glow cyber-glow-2"}),n.jsx(SL,{})]}),n.jsx("div",{className:"scanlines"}),n.jsxs("div",{className:"cyber-login-container",children:[n.jsx("div",{className:"cyber-login-toolbar",children:n.jsx(Yb,{variant:"compact"})}),n.jsxs("div",{className:"cyber-login-content",children:[n.jsxs("div",{className:"cyber-brand",children:[n.jsx("div",{className:"cyber-logo",children:n.jsx("img",{src:"/logo.png",alt:"CodingNS",className:"cyber-logo-svg"})}),n.jsx("h1",{className:"cyber-brand-title",children:n.jsx(CL,{text:"CodingNS"})}),n.jsx("p",{className:"cyber-brand-subtitle",children:n.jsx(jL,{text:t("auth.loginSubtitle")})})]}),n.jsxs("div",{className:"cyber-card",children:[n.jsx("div",{className:"cyber-corner corner-tl"}),n.jsx("div",{className:"cyber-corner corner-tr"}),n.jsx("div",{className:"cyber-corner corner-bl"}),n.jsx("div",{className:"cyber-corner corner-br"}),n.jsxs("div",{className:"cyber-card-header",children:[n.jsx("div",{className:"cyber-line"}),n.jsx("span",{className:"cyber-card-label",children:t("auth.loginTitle").toUpperCase()}),n.jsx("div",{className:"cyber-line"})]}),te?n.jsxs("div",{className:"cyber-demo-banner",children:[n.jsx("span",{className:"cyber-demo-icon",children:"⚠"}),n.jsx("span",{children:t("auth.demoBanner")})]}):null,n.jsxs("form",{className:"cyber-form",onSubmit:Se,children:[n.jsxs("div",{className:`cyber-field ${Y==="username"?"focused":""}`,children:[n.jsx("div",{className:"cyber-field-border",children:n.jsx("div",{className:"cyber-field-border-glow"})}),n.jsxs("label",{className:"cyber-field-label",htmlFor:Ne,children:[n.jsx("span",{className:"cyber-field-icon",children:"❯"}),t("auth.username")]}),n.jsx("input",{id:Ne,"aria-label":t("auth.username"),className:"cyber-input",value:g,onChange:xe=>se(xe.target.value),onFocus:()=>G("username"),onBlur:()=>G(null),autoComplete:"username"})]}),n.jsxs("div",{className:`cyber-field ${Y==="password"?"focused":""}`,children:[n.jsx("div",{className:"cyber-field-border",children:n.jsx("div",{className:"cyber-field-border-glow"})}),n.jsxs("label",{className:"cyber-field-label",htmlFor:Ee,children:[n.jsx("span",{className:"cyber-field-icon",children:"⚷"}),t("auth.password")]}),n.jsx("input",{id:Ee,"aria-label":t("auth.password"),className:"cyber-input",type:"password",value:k,onChange:xe=>y(xe.target.value),onFocus:()=>G("password"),onBlur:()=>G(null),autoComplete:"current-password"})]}),C?n.jsxs("div",{className:"cyber-captcha-panel",children:[n.jsx("img",{alt:t("auth.captchaImageAlt"),className:"cyber-captcha-image",draggable:!1,src:C.imageDataUrl}),n.jsx("p",{className:"cyber-captcha-hint",children:t("auth.captchaHint")}),n.jsxs("div",{className:`cyber-field ${Y==="captcha"?"focused":""}`,children:[n.jsx("div",{className:"cyber-field-border",children:n.jsx("div",{className:"cyber-field-border-glow"})}),n.jsxs("label",{className:"cyber-field-label",htmlFor:ie,children:[n.jsx("span",{className:"cyber-field-icon",children:"#"}),t("auth.captcha")]}),n.jsx("input",{id:ie,"aria-label":t("auth.captcha"),className:"cyber-input",placeholder:t("auth.captchaPlaceholder"),value:j,onChange:xe=>N(xe.target.value),onFocus:()=>G("captcha"),onBlur:()=>G(null),autoComplete:"one-time-code"})]})]}):null,d?n.jsxs("label",{className:"cyber-remember-toggle",children:[n.jsx("input",{"aria-label":t("auth.rememberPassword"),type:"checkbox",checked:D,onChange:xe=>F(xe.target.checked)}),n.jsx("span",{children:t("auth.rememberPassword")})]}):null,M?n.jsxs("div",{className:"cyber-status","data-tone":"error",children:[n.jsx("span",{className:"cyber-status-icon",children:"⚠"}),n.jsx("span",{children:M})]}):null,n.jsxs("button",{className:`cyber-submit ${L?"loading":""}`,type:"submit",disabled:L,children:[n.jsx("span",{className:"cyber-submit-glow"}),n.jsx("span",{className:"cyber-submit-border"}),n.jsx("span",{className:"cyber-submit-text",children:L?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cyber-spinner"}),t("common.loading")]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cyber-submit-icon",children:"➤"}),t("auth.submitLogin")]})})]})]}),c?n.jsxs("div",{className:"cyber-footer",children:[n.jsxs("div",{className:"cyber-divider",children:[n.jsx("span",{className:"cyber-divider-line"}),n.jsx("span",{className:"cyber-divider-text",children:"//"}),n.jsx("span",{className:"cyber-divider-line"})]}),n.jsxs("button",{className:"cyber-server-btn",onClick:()=>ne(!0),type:"button",children:[n.jsx("span",{className:"cyber-server-icon",children:"⚙"}),n.jsx("span",{className:"cyber-server-text",children:t("auth.serverSettings")}),n.jsx("span",{className:"cyber-server-current",children:W})]})]}):null]})]}),n.jsxs("div",{className:"cyber-version",children:[n.jsxs("span",{className:"cyber-version-text",children:["v",i]}),n.jsx("span",{className:"cyber-version-divider",children:"|"}),n.jsx("span",{className:"cyber-version-text",children:"SYSTEM READY"})]})]}),c?n.jsx(kL,{isOpen:O,onClose:()=>ne(!1),onSave:J,theme:R}):null]})}function li(){return nr().haptics}function RN(e,t){const r=new Map(e.map(l=>[t.getId(l),l])),s=new Map,i=[];for(const l of e){const c=PL(l,r,t);if(!c){i.push(l);continue}const d=s.get(c)??[];s.set(c,[...d,l])}return[...i].sort(t.compare).map(l=>IN(l,0,s,t,new Set))}function zi(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function MN(e){return e.flatMap(t=>[t.item,...MN(zi(t))])}function ii(e){return e.flatMap(t=>[t,...ii(zi(t))])}function lm(e,t){return e.some(r=>t(r.item)||lm(zi(r),t))}function AN(e,t,r){return e?r(e.item)===t?!0:zi(e).some(s=>AN(s,t,r)):!1}function la(e,t,r){for(const s of e){const i=r(s.item);if(i===t)return[];const l=la(zi(s),t,r);if(AN(s,t,r)&&l.length>=0)return[i,...l]}return[]}function IN(e,t,r,s,i){const l=s.getId(e),c=new Set(i);c.add(l);const d=[...r.get(l)??[]].filter(m=>!c.has(s.getId(m))).sort(s.compare).map(m=>IN(m,t+1,r,s,c));return{item:e,depth:t,children:d}}function PL(e,t,r){const s=ix(r.getParentId(e));if(!s)return null;const i=t.get(s);if(!i)return null;const l=new Set([r.getId(e)]);let c=i;for(;c;){const d=r.getId(c);if(l.has(d))return null;l.add(d);const m=ix(r.getParentId(c));if(!m||(c=t.get(m),!c))return s}return s}function ix(e){const t=e==null?void 0:e.trim();return t||null}function Ts(){return"/workspaces"}function Ms(e){return`/workspaces/${encodeURIComponent(e)}`}function DL(e){return`${Ms(e)}/debug`}function Si(e){return`${Ms(e)}/sessions`}function Yn(e,t){return`${Si(e)}/${encodeURIComponent(t)}`}function EN(e,t){const r=`${Ms(e)}/tools`;if(!t)return r;const s=new URLSearchParams({tab:t});return`${r}?${s.toString()}`}function LN(e){return`${Ms(e)}/tools/files`}function FN(e){return`${Ms(e)}/tools/git`}function Xb(e){return`${Ms(e)}/tools/processes`}function xo(e){return`${Ms(e)}/terminals`}function Ui(e,t){const r=`${Ms(e)}/butler`;if(!t)return r;const s=new URLSearchParams({tab:t});return`${r}?${s.toString()}`}function _N(e){return e.flatMap(t=>[...t.sessions.map(r=>({session:r,workspace:t.workspace})),...BN(t.childWorktrees??[])]).sort((t,r)=>(r.session.lastMessageAt??r.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function Wh(e){return RN(e,{getId:t=>t.session.sessionId,getParentId:t=>{var r;return((r=t.session.parentSessionId)==null?void 0:r.trim())||null},compare:ML})}function ON(e,t){const r=RL(),s=new URLSearchParams({provider:t});return`${Yn(e,r)}?${s.toString()}`}function RL(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ML(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function BN(e){return e.flatMap(t=>[...t.sessions.map(r=>({session:r,workspace:t.workspace})),...BN(t.children)])}const AL="mobile.tools.last-primary-tool";function WN(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(AL)==="git"?"git":"files"}catch{return"files"}}function Qb(e){var s;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const l=Ir(i.pattern,e),c=((s=l==null?void 0:l.params.workspaceId)==null?void 0:s.trim())??null;if(c)return{workspaceId:c,routeKind:i.routeKind,legacy:!1}}const r=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of r)if(Ir(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function IL(e,t){const r=Qb(e);if((r==null?void 0:r.routeKind)==="git")return"git";if((r==null?void 0:r.routeKind)==="files")return"files";const s=new URLSearchParams(t).get("tab");return s==="git"?"git":s==="files"?"files":WN()}function Jb(e,t){const r=Qb(e);return(r==null?void 0:r.routeKind)==="processes"&&r.workspaceId?xo(r.workspaceId):r!=null&&r.workspaceId?EN(r.workspaceId,IL(e,t)):r!=null&&r.legacy?WN()==="git"?"/tools?tab=git":"/tools?tab=files":null}function Zb({activeEntry:e,presentation:t,pathname:r,search:s,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const l=Qb(r);return l?l.routeKind==="processes"?{title:o("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(l.routeKind==="home"||l.routeKind==="files"||l.routeKind==="git",null):null}const UN=p.createContext({composerPortalTarget:null});function ev({composerPortalTarget:e,children:t}){return n.jsx(UN.Provider,{value:{composerPortalTarget:e},children:t})}function tv(){return p.useContext(UN)}function nv(e,t,r){const[s,i]=p.useState(void 0);return p.useEffect(()=>{const l=e.current,c=t.current;if(!r||!l||!c){i(void 0),l&&l.style.removeProperty("--mobile-conversation-tabbar-height");return}const d=l,m=c;function f(){if(!e.current||!m.isConnected)return;const g=`${Math.round(m.getBoundingClientRect().height)}px`;d.style.setProperty("--mobile-conversation-tabbar-height",g),i(g)}f();const v=typeof ResizeObserver<"u"?new ResizeObserver(f):null;return v==null||v.observe(m),window.addEventListener("resize",f),()=>{v==null||v.disconnect(),window.removeEventListener("resize",f),d.style.removeProperty("--mobile-conversation-tabbar-height")}},[r,e,t]),s}const EL=3e3,Td=10,ax=84,ox=.36;function rv({enabled:e,rootRef:t,suspended:r=!1,resetKey:s}){const i=p.useRef(null),l=p.useRef(null),c=p.useRef("visible"),d=p.useRef(1),[m,f]=p.useState("visible"),[v,g]=p.useState(1);p.useEffect(()=>{c.current=m},[m]),p.useEffect(()=>{d.current=v},[v]);function w(){uo(i),i.current=window.setTimeout(()=>{k()},EL)}function k(){f("hidden"),g(0)}function y(){f("visible"),g(1),w()}p.useEffect(()=>{if(uo(i),!e){uo(i),f("visible"),g(1);return}if(r){f("hidden"),g(0);return}return y(),()=>{uo(i)}},[e,s,r]),p.useEffect(()=>()=>{uo(i)},[]),p.useEffect(()=>{if(!e||r){l.current=null;return}const T=t.current;if(!T)return;function j(M){if(M.touches.length!==1){l.current=null;return}const _=M.touches[0],L=ux(M.target);if(!_||!L){l.current=null;return}l.current={surface:L,startX:_.clientX,startY:_.clientY,pointerType:"touch",initialState:c.current==="visible"?"visible":"hidden",touchId:_.identifier,dragging:!1,latestProgress:d.current},c.current==="visible"&&uo(i)}function N(M){const _=l.current;if(!_||_.pointerType!=="touch")return;const L=lf(M.touches,_.touchId);if(!L)return;const Q=L.clientX-_.startX,O=L.clientY-_.startY;if(_.surface==="conversation"){if(Math.abs(O)<=Td||Math.abs(O)<=Math.abs(Q))return;l.current=null,_.initialState==="visible"&&k();return}const ne=_.initialState==="hidden"?-O:O;ne<=Td&&!_.dragging||(hx(M),_.dragging=!0,_.latestProgress=lx(_.initialState,ne),f("dragging"),g(_.latestProgress))}function D(M){const _=l.current;if(!(!_||_.pointerType!=="touch"||!lf(M.changedTouches,_.touchId))){if(l.current=null,!_.dragging){_.initialState==="visible"&&w();return}cx(_.initialState,_.latestProgress,y,f,g)}}function F(M){const _=l.current;if(!(!_||_.pointerType!=="touch"||!lf(M.changedTouches,_.touchId))){if(l.current=null,!_.dragging){_.initialState==="visible"&&w();return}if(_.initialState==="visible"){y();return}f("hidden"),g(0)}}function W(M){if(M.pointerType!=="touch")return;const _=ux(M.target);if(!_){l.current=null;return}if(l.current={surface:_,startX:M.clientX,startY:M.clientY,pointerType:"pointer",initialState:c.current==="visible"?"visible":"hidden",pointerId:M.pointerId,captureTarget:M.target instanceof Element?M.target:null,dragging:!1,latestProgress:d.current},M.target instanceof Element)try{M.target.setPointerCapture(M.pointerId)}catch{}c.current==="visible"&&uo(i)}function E(M){const _=l.current;if(!_||_.pointerType!=="pointer")return;const L=M.clientX-_.startX,Q=M.clientY-_.startY;if(_.surface==="conversation"){if(Math.abs(Q)<=Td||Math.abs(Q)<=Math.abs(L))return;l.current=null,_.initialState==="visible"&&k();return}const O=_.initialState==="hidden"?-Q:Q;O<=Td&&!_.dragging||(hx(M),_.dragging=!0,_.latestProgress=lx(_.initialState,O),f("dragging"),g(_.latestProgress))}function I(M){const _=l.current;if(!(!_||_.pointerType!=="pointer"||_.pointerId!==M.pointerId)){if(l.current=null,LL(_),!_.dragging){_.initialState==="visible"&&w();return}cx(_.initialState,_.latestProgress,y,f,g)}}return T.addEventListener("touchstart",j,{passive:!0}),T.addEventListener("pointerdown",W,{passive:!0}),window.addEventListener("touchmove",N,{passive:!1}),window.addEventListener("touchend",D),window.addEventListener("touchcancel",F),window.addEventListener("pointermove",E,{passive:!1}),window.addEventListener("pointerup",I),window.addEventListener("pointercancel",I),()=>{T.removeEventListener("touchstart",j),T.removeEventListener("pointerdown",W),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",D),window.removeEventListener("touchcancel",F),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I)}},[e,t,r]);const C=e&&!r?v:e?0:1;return{state:r&&e?"hidden":m,progress:C,isOpen:C>.01}}function uo(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function lx(e,t){return dx(e==="hidden"?t/ax:1-t/ax,0,1)}function cx(e,t,r,s,i){if(e==="hidden"){if(t>=ox){r();return}s("hidden"),i(0);return}if(t<=1-ox){s("hidden"),i(0);return}r()}function LL(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function lf(e,t){if(typeof t!="number")return e[0]??null;for(let r=0;r<e.length;r+=1){const s=e[r];if((s==null?void 0:s.identifier)===t)return s}return null}function ux(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function dx(e,t,r){return Math.min(Math.max(e,t),r)}function hx(e){e.cancelable&&e.preventDefault()}function xu({viewportClass:e,activeEntry:t,hasNavigationPanel:r,hasAuxiliaryPanel:s,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&r&&s?"expanded":t==="butler"&&s?"medium-auxiliary":r?"medium-navigation":s?"medium-auxiliary":"compact"}function cm(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function HN(e){return e==="medium-navigation"||e==="expanded"}function zN(e){return e==="medium-auxiliary"||e==="expanded"}function sv({viewportClass:e,activeEntry:t,hasNavigationPanel:r,hasAuxiliaryPanel:s,preferCompactLayout:i=!1,children:l,navigationPanel:c,auxiliaryPanel:d}){const m=xu({viewportClass:e,activeEntry:t,hasNavigationPanel:r,hasAuxiliaryPanel:s,preferCompactLayout:i}),f=HN(m)&&c,v=zN(m)&&d;return n.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":m,children:[f?n.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:c}):null,n.jsx("div",{className:"mobile-adaptive-pane-main",children:l}),v?n.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:d}):null]})}function FL({activeEntry:e,presentation:t="default",children:r,navigationPanel:s,auxiliaryPanel:i,onNavigateWorkspaces:l,onNavigateTerminals:c,onNavigateSessions:d,onNavigateButler:m,onNavigateToolProcesses:f,onNavigateSettings:v}){const g=nr(),w=li(),k=oi(),y=vr(),C=p.useRef(null),T=p.useRef(null),[j,N]=p.useState(null),D=t==="conversation-focus",F=cm({isNativeMobile:g.isNativeMobile,viewportClass:g.viewportClass}),W=rv({enabled:D,rootRef:C,resetKey:`${k.pathname}${k.search}`}),E=xu({viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),I=Zb({activeEntry:e,presentation:t,pathname:k.pathname,search:k.search,moreButtonLabel:o("shell.androidMoreAction")}),M=[{key:"workspaces",label:o("shell.mobileWorkspacesEntry"),icon:n.jsx(BL,{}),onClick:l},{key:"sessions",label:o("shell.mobileSessionsEntry"),icon:n.jsx(WL,{}),onClick:d},{key:"terminals",label:o("shell.mobileButlerEntry"),icon:n.jsx(HL,{}),onClick:m},{key:"butler",label:o("shell.mobileTerminalsEntry"),icon:n.jsx(UL,{}),onClick:c},{key:"settings",label:o("shell.mobileSettingsEntry"),icon:n.jsx(zL,{}),onClick:v}],_=D?{"--mobile-conversation-tabbar-progress":W.progress.toFixed(4)}:void 0;nv(C,T,D);function L(){const O=Jb(k.pathname,k.search);if(!O){c();return}y(O,{replace:!0})}const Q=n.jsx("nav",{ref:T,className:"android-workbench-bottom-nav","aria-label":o("shell.title"),children:M.map(O=>n.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":O.key===e,"aria-current":O.key===e?"page":void 0,onClick:()=>{O.key!==e&&w.trigger("selection"),O.onClick()},children:[n.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:O.icon}),n.jsx("span",{className:"android-workbench-bottom-nav-label",children:O.label})]},O.key))});return n.jsx(ev,{composerPortalTarget:D?j:null,children:n.jsxs("div",{ref:C,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":E,"data-tabbar-open":D?W.isOpen:!0,"data-conversation-tabbar-state":D?W.state:"default",style:_,children:[I?n.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[n.jsxs("div",{className:"android-workbench-topbar-leading",children:[I.showBackButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":o("common.back"),onClick:L,children:n.jsx(_L,{})}):null,n.jsx("div",{className:"android-workbench-topbar-copy",children:n.jsx("h1",{children:I.title})})]}),n.jsx("div",{className:"android-workbench-topbar-actions",children:I.showMoreButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":I.moreButtonLabel,onClick:f,children:n.jsx(OL,{})}):null})]}):null,n.jsx("div",{className:"android-workbench-content",children:n.jsx(sv,{viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:s,auxiliaryPanel:i,children:r})}),D?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:N,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:Q})]}):Q]})})}function _L(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function OL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function BL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function WL(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function UL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function HL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function zL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const qL=120,Rc={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function qg(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function $L(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function VL(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(qg);return e.length>0?Math.max(...e):0}function mx(){if(typeof window>"u")return Rc;const e=window.visualViewport,t=VL(),r=(e==null?void 0:e.height)??t,s=qg(r)?Math.round(r):null,i=qg(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,l=s===null?0:Math.max(0,Math.round(t-s-i));return{viewportHeight:s,keyboardInset:l,keyboardOpen:$L(typeof document<"u"?document.activeElement:null)&&l>=qL}}function cf(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(s=>s instanceof HTMLElement).forEach(s=>{if(!e){delete s.dataset.mobileKeyboardOpen,delete s.dataset.mobileViewportBound,s.style.removeProperty("--mobile-shell-viewport-height"),s.style.removeProperty("--mobile-shell-keyboard-inset");return}s.dataset.mobileKeyboardOpen=String(t.keyboardOpen),s.dataset.mobileViewportBound="true",t.viewportHeight===null?s.style.removeProperty("--mobile-shell-viewport-height"):s.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),s.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function GL(e){const[t,r]=p.useState(()=>e?mx():Rc),s=p.useRef(null);return p.useEffect(()=>{if(!e){r(Rc),cf(!1,Rc);return}function i(){r(mx())}function l(){s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{s.current=null,i()},0)}i();const c=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),c==null||c.addEventListener("resize",i),c==null||c.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",l),()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),c==null||c.removeEventListener("resize",i),c==null||c.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",l),cf(!1,Rc)}},[e]),p.useEffect(()=>{cf(e,t)},[e,t]),t}function KL({activeEntry:e,presentation:t="default",children:r,navigationPanel:s,auxiliaryPanel:i,onNavigateWorkspaces:l,onNavigateTerminals:c,onNavigateSessions:d,onNavigateButler:m,onNavigateToolProcesses:f,onNavigateSettings:v}){const g=nr(),w=li(),k=oi(),y=vr(),C=p.useRef(null),T=p.useRef(null),[j,N]=p.useState(null),D=t==="conversation-focus",F=cm({isNativeMobile:g.isNativeMobile,viewportClass:g.viewportClass}),W=rv({enabled:D,rootRef:C,resetKey:`${k.pathname}${k.search}`}),E=xu({viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:F}),I=Zb({activeEntry:e,presentation:t,pathname:k.pathname,search:k.search,moreButtonLabel:o("shell.iosMoreAction")}),M=[{key:"workspaces",label:o("shell.mobileWorkspacesEntry"),icon:n.jsx(QL,{}),onClick:l},{key:"sessions",label:o("shell.mobileSessionsEntry"),icon:n.jsx(JL,{}),onClick:d},{key:"terminals",label:o("shell.mobileButlerEntry"),icon:n.jsx(eF,{}),onClick:m},{key:"butler",label:o("shell.mobileTerminalsEntry"),icon:n.jsx(ZL,{}),onClick:c},{key:"settings",label:o("shell.mobileSettingsEntry"),icon:n.jsx(tF,{}),onClick:v}],_=D?{"--mobile-conversation-tabbar-progress":W.progress.toFixed(4)}:void 0;nv(C,T,D);function L(){const O=Jb(k.pathname,k.search);if(!O){c();return}y(O,{replace:!0})}const Q=n.jsx("nav",{ref:T,className:"ios-workbench-tabbar","aria-label":o("shell.title"),children:M.map(O=>n.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":O.key===e,"aria-current":O.key===e?"page":void 0,onClick:()=>{O.key!==e&&w.trigger("selection"),O.onClick()},children:[n.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:O.icon}),n.jsx("span",{className:"ios-workbench-tabbar-label",children:O.label})]},O.key))});return n.jsx(ev,{composerPortalTarget:D?j:null,children:n.jsxs("div",{ref:C,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":E,"data-tabbar-open":D?W.isOpen:!0,"data-conversation-tabbar-state":D?W.state:"default",style:_,children:[I?n.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[n.jsx("div",{className:"ios-workbench-nav-leading",children:I.showBackButton?n.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":o("common.back"),onClick:L,children:[n.jsx(YL,{}),n.jsx("span",{children:o("common.back")})]}):null}),n.jsx("div",{className:"ios-workbench-nav-copy",children:n.jsx("h1",{children:I.title})}),n.jsx("div",{className:"ios-workbench-nav-actions",children:I.showMoreButton?n.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":I.moreButtonLabel,onClick:f,children:n.jsx(XL,{})}):null})]}):null,n.jsx("div",{className:"ios-workbench-content",children:n.jsx(sv,{viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:F,navigationPanel:s,auxiliaryPanel:i,children:r})}),D?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:N,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:Q})]}):Q]})})}function YL(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.jsx("path",{d:"m15 18-6-6 6-6"})})}function XL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function QL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function JL(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ZL(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function eF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function tF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function nF(e){const t=nr();return t.platform==="ios"?n.jsx(KL,{...e}):t.platform==="android"?n.jsx(FL,{...e}):n.jsx(rF,{...e})}function rF({activeEntry:e,presentation:t="default",children:r,navigationPanel:s,auxiliaryPanel:i,onNavigateWorkspaces:l,onNavigateTerminals:c,onNavigateSessions:d,onNavigateButler:m,onNavigateToolProcesses:f,onNavigateSettings:v}){const g=nr(),w=li(),k=oi(),y=vr(),C=p.useRef(null),T=p.useRef(null),[j,N]=p.useState(null),D=GL(g.platform==="web"),F=g.platform==="web"&&D.keyboardOpen,W=t==="conversation-focus",E=cm({isNativeMobile:g.isNativeMobile,viewportClass:g.viewportClass}),I=rv({enabled:W,rootRef:C,suspended:F,resetKey:`${k.pathname}${k.search}`}),M=xu({viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:E}),_=Zb({activeEntry:e,presentation:t,pathname:k.pathname,search:k.search,moreButtonLabel:o("shell.iosMoreAction")}),L=[{key:"workspaces",label:o("shell.mobileWorkspacesEntry"),icon:n.jsx(aF,{}),onClick:l},{key:"sessions",label:o("shell.mobileSessionsEntry"),icon:n.jsx(oF,{}),onClick:d},{key:"terminals",label:o("shell.mobileButlerEntry"),icon:n.jsx(cF,{}),onClick:m},{key:"butler",label:o("shell.mobileTerminalsEntry"),icon:n.jsx(lF,{}),onClick:c},{key:"settings",label:o("shell.mobileSettingsEntry"),icon:n.jsx(uF,{}),onClick:v}],Q=W?{"--mobile-conversation-tabbar-progress":I.progress.toFixed(4)}:void 0;nv(C,T,W);function O(){const Y=Jb(k.pathname,k.search);if(!Y){c();return}y(Y,{replace:!0})}const ne=n.jsx("nav",{ref:T,className:"mobile-workbench-tabbar","aria-label":o("shell.title"),hidden:F,children:L.map(Y=>n.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":Y.key===e,"aria-current":Y.key===e?"page":void 0,onClick:()=>{Y.key!==e&&w.trigger("selection"),Y.onClick()},children:[n.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:Y.icon}),n.jsx("span",{className:"mobile-workbench-tabbar-label",children:Y.label})]},Y.key))});return n.jsx(ev,{composerPortalTarget:W?j:null,children:n.jsxs("div",{ref:C,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":g.platform,"data-mobile-keyboard-open":F,"data-pane-layout":M,"data-tabbar-open":F?!1:W?I.isOpen:!0,"data-conversation-tabbar-state":W?I.state:"default",style:Q,children:[_?n.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[n.jsxs("div",{className:"mobile-workbench-header-leading",children:[_.showBackButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":o("common.back"),onClick:O,children:n.jsx(sF,{})}):null,n.jsx("div",{className:"mobile-workbench-header-copy",children:n.jsx("h1",{children:_.title})})]}),n.jsx("div",{className:"mobile-workbench-header-actions",children:_.showMoreButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":_.moreButtonLabel,onClick:f,children:n.jsx(iF,{})}):null})]}):null,n.jsx("div",{className:"mobile-workbench-content",children:n.jsx(sv,{viewportClass:g.viewportClass,activeEntry:e,hasNavigationPanel:!!s,hasAuxiliaryPanel:!!i,preferCompactLayout:E,navigationPanel:s,auxiliaryPanel:i,children:r})}),W?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:N,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ne})]}):ne]})})}function sF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function iF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function aF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function oF(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function lF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function cF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function uF(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class qN{constructor(t){ot(this,"maxAttempts");ot(this,"baseDelayMs");ot(this,"reconnectAttempts",0);ot(this,"reconnectTimer",null);ot(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!En.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class $N{constructor(t){ot(this,"socket",null);ot(this,"disposed",!1);ot(this,"authRecoveryInFlight",!1);ot(this,"pendingRefresh",!1);ot(this,"fileTreeSubscription",null);ot(this,"gitWorkspaceId",null);ot(this,"terminalManagerWorkspaceId",null);ot(this,"workspaceManagementWorkspaceId",null);ot(this,"pendingFileTreeRefresh",null);ot(this,"pendingGitRefreshWorkspaceId",null);ot(this,"pendingTerminalManagerRefreshWorkspaceId",null);ot(this,"pendingWorkspaceManagementRefreshWorkspaceId",null);ot(this,"fileTreeListeners",new Set);ot(this,"gitListeners",new Set);ot(this,"terminalManagerListeners",new Set);ot(this,"workspaceManagementListeners",new Set);ot(this,"connectionManager");this.options=t,this.connectionManager=new qN({onReconnect:r=>{this.connect(r)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!px(t)){this.pendingRefresh=!0;return}t.send(JSON.stringify({type:"workbench.refresh"})),this.pendingRefresh=!1}subscribeFileTree(t,r){this.fileTreeSubscription={workspaceId:t,paths:fx(r)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths})}requestFileTreeRefresh(t,r){const s=fx(r),i={type:"fileTree.refresh",workspaceId:t,paths:s};this.sendWhenReady(i)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:s}}subscribeGit(t){this.gitWorkspaceId=t,this.sendWhenReady({type:"git.subscribe",workspaceId:t})}requestGitRefresh(t){this.sendWhenReady({type:"git.refresh",workspaceId:t})?this.pendingGitRefreshWorkspaceId=null:this.pendingGitRefreshWorkspaceId=t}subscribeTerminalManager(t){this.terminalManagerWorkspaceId=t,this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t})}requestTerminalManagerRefresh(t){this.sendWhenReady({type:"terminalManager.refresh",workspaceId:t})?this.pendingTerminalManagerRefreshWorkspaceId=null:this.pendingTerminalManagerRefreshWorkspaceId=t}subscribeWorkspaceManagement(t){this.workspaceManagementWorkspaceId=t,this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t})}requestWorkspaceManagementRefresh(t){this.sendWhenReady({type:"workspaceManagement.refresh",workspaceId:t})?this.pendingWorkspaceManagementRefreshWorkspaceId=null:this.pendingWorkspaceManagementRefreshWorkspaceId=t}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var l;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const r=(l=br.getState().session)==null?void 0:l.accessToken;if(!r){this.options.onUnauthorized();return}const s=`${_T("/ws")}?access_token=${encodeURIComponent(r)}`,i=new WebSocket(s);this.socket=i,i.addEventListener("open",()=>{i.send(JSON.stringify({type:"workbench.subscribe"})),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&i.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths),this.gitWorkspaceId&&i.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitWorkspaceId})),this.pendingGitRefreshWorkspaceId&&this.requestGitRefresh(this.pendingGitRefreshWorkspaceId),this.terminalManagerWorkspaceId&&i.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerWorkspaceId})),this.pendingTerminalManagerRefreshWorkspaceId&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefreshWorkspaceId),this.workspaceManagementWorkspaceId&&i.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementWorkspaceId})),this.pendingWorkspaceManagementRefreshWorkspaceId&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefreshWorkspaceId)}),i.addEventListener("message",c=>{var m,f,v,g,w,k,y,C;const d=JSON.parse(c.data);if(d.type==="system.connected"){this.connectionManager.markConnected();return}if(d.type==="session.error"){d.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(d.type==="fileTree.snapshot"){(f=(m=this.options).onFileTreeSnapshot)==null||f.call(m,d.snapshot),this.fileTreeListeners.forEach(T=>T(d.snapshot));return}if(d.type==="git.snapshot"){(g=(v=this.options).onGitSnapshot)==null||g.call(v,d.snapshot),this.gitListeners.forEach(T=>T(d.snapshot));return}if(d.type==="terminalManager.snapshot"){(k=(w=this.options).onTerminalManagerSnapshot)==null||k.call(w,d.snapshot),this.terminalManagerListeners.forEach(T=>T(d.snapshot));return}if(d.type==="workspaceManagement.snapshot"){(C=(y=this.options).onWorkspaceManagementSnapshot)==null||C.call(y,d.snapshot),this.workspaceManagementListeners.forEach(T=>T(d.snapshot));return}d.type==="workbench.snapshot"&&dF(d.snapshot)&&this.options.onSnapshot(d.snapshot)}),i.addEventListener("close",()=>{this.disposed||this.socket!==i||this.connectionManager.markDisconnected()}),i.addEventListener("error",()=>{this.disposed||this.socket!==i||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),br.refresh().then(r=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(r.status==="refreshed"){this.connectionManager.reconnectNow();return}if(r.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const r=this.socket;return px(r)?(r.send(JSON.stringify(t)),!0):!1}}function px(e){const t=typeof WebSocket.OPEN=="number"?WebSocket.OPEN:1;return e!==null&&e.readyState===t}function dF(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function fx(e){const t=new Set;for(const r of e??[""])t.add(r.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Wr(e,t,r,s){if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function La(e,t,r,s,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var ho,Zs,ml,Nd,ph;const Is="__TAURI_TO_IPC_KEY__";function VN(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class GN{constructor(t){ho.set(this,void 0),Zs.set(this,0),ml.set(this,[]),Nd.set(this,void 0),La(this,ho,t||(()=>{})),this.id=VN(r=>{const s=r.index;if("end"in r){s==Wr(this,Zs,"f")?this.cleanupCallback():La(this,Nd,s);return}const i=r.message;if(s==Wr(this,Zs,"f")){for(Wr(this,ho,"f").call(this,i),La(this,Zs,Wr(this,Zs,"f")+1);Wr(this,Zs,"f")in Wr(this,ml,"f");){const l=Wr(this,ml,"f")[Wr(this,Zs,"f")];Wr(this,ho,"f").call(this,l),delete Wr(this,ml,"f")[Wr(this,Zs,"f")],La(this,Zs,Wr(this,Zs,"f")+1)}Wr(this,Zs,"f")===Wr(this,Nd,"f")&&this.cleanupCallback()}else Wr(this,ml,"f")[s]=i})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(t){La(this,ho,t)}get onmessage(){return Wr(this,ho,"f")}[(ho=new WeakMap,Zs=new WeakMap,ml=new WeakMap,Nd=new WeakMap,Is)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Is]()}}async function Le(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}class KN{get rid(){return Wr(this,ph,"f")}constructor(t){ph.set(this,void 0),La(this,ph,t)}async close(){return Le("plugin:resources|close",{rid:this.rid})}}ph=new WeakMap;class iv{constructor(...t){this.type="Logical",t.length===1?"Logical"in t[0]?(this.width=t[0].Logical.width,this.height=t[0].Logical.height):(this.width=t[0].width,this.height=t[0].height):(this.width=t[0],this.height=t[1])}toPhysical(t){return new Ha(this.width*t,this.height*t)}[Is](){return{width:this.width,height:this.height}}toJSON(){return this[Is]()}}class Ha{constructor(...t){this.type="Physical",t.length===1?"Physical"in t[0]?(this.width=t[0].Physical.width,this.height=t[0].Physical.height):(this.width=t[0].width,this.height=t[0].height):(this.width=t[0],this.height=t[1])}toLogical(t){return new iv(this.width/t,this.height/t)}[Is](){return{width:this.width,height:this.height}}toJSON(){return this[Is]()}}class pl{constructor(t){this.size=t}toLogical(t){return this.size instanceof iv?this.size:this.size.toLogical(t)}toPhysical(t){return this.size instanceof Ha?this.size:this.size.toPhysical(t)}[Is](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[Is]()}}class av{constructor(...t){this.type="Logical",t.length===1?"Logical"in t[0]?(this.x=t[0].Logical.x,this.y=t[0].Logical.y):(this.x=t[0].x,this.y=t[0].y):(this.x=t[0],this.y=t[1])}toPhysical(t){return new ni(this.x*t,this.y*t)}[Is](){return{x:this.x,y:this.y}}toJSON(){return this[Is]()}}class ni{constructor(...t){this.type="Physical",t.length===1?"Physical"in t[0]?(this.x=t[0].Physical.x,this.y=t[0].Physical.y):(this.x=t[0].x,this.y=t[0].y):(this.x=t[0],this.y=t[1])}toLogical(t){return new av(this.x/t,this.y/t)}[Is](){return{x:this.x,y:this.y}}toJSON(){return this[Is]()}}class _a{constructor(t){this.position=t}toLogical(t){return this.position instanceof av?this.position:this.position.toLogical(t)}toPhysical(t){return this.position instanceof ni?this.position:this.position.toPhysical(t)}[Is](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[Is]()}}var Ns;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(Ns||(Ns={}));async function YN(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await Le("plugin:event|unlisten",{event:e,eventId:t})}async function ov(e,t,r){var s;const i=typeof(r==null?void 0:r.target)=="string"?{kind:"AnyLabel",label:r.target}:(s=r==null?void 0:r.target)!==null&&s!==void 0?s:{kind:"Any"};return Le("plugin:event|listen",{event:e,target:i,handler:VN(t)}).then(l=>async()=>YN(e,l))}async function XN(e,t,r){return ov(e,s=>{YN(e,s.id),t(s)},r)}async function QN(e,t){await Le("plugin:event|emit",{event:e,payload:t})}async function JN(e,t,r){await Le("plugin:event|emit_to",{target:typeof e=="string"?{kind:"AnyLabel",label:e}:e,event:t,payload:r})}const hF=Object.freeze(Object.defineProperty({__proto__:null,get TauriEvent(){return Ns},emit:QN,emitTo:JN,listen:ov,once:XN},Symbol.toStringTag,{value:"Module"}));class Bc extends KN{constructor(t){super(t)}static async new(t,r,s){return Le("plugin:image|new",{rgba:Bi(t),width:r,height:s}).then(i=>new Bc(i))}static async fromBytes(t){return Le("plugin:image|from_bytes",{bytes:Bi(t)}).then(r=>new Bc(r))}static async fromPath(t){return Le("plugin:image|from_path",{path:t}).then(r=>new Bc(r))}async rgba(){return Le("plugin:image|rgba",{rid:this.rid}).then(t=>new Uint8Array(t))}async size(){return Le("plugin:image|size",{rid:this.rid})}}function Bi(e){return e==null?null:typeof e=="string"?e:e instanceof Bc?e.rid:e}var Uh;(function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"})(Uh||(Uh={}));class ZN{constructor(t){this._preventDefault=!1,this.event=t.event,this.id=t.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var $g;(function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"})($g||($g={}));function um(){return new lv(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function fh(){return Le("plugin:window|get_all_windows").then(e=>e.map(t=>new lv(t,{skip:!0})))}const uf=["tauri://created","tauri://error"];class lv{constructor(t,r={}){var s;this.label=t,this.listeners=Object.create(null),r!=null&&r.skip||Le("plugin:window|create",{options:{...r,parent:typeof r.parent=="string"?r.parent:(s=r.parent)===null||s===void 0?void 0:s.label,label:t}}).then(async()=>this.emit("tauri://created")).catch(async i=>this.emit("tauri://error",i))}static async getByLabel(t){var r;return(r=(await fh()).find(s=>s.label===t))!==null&&r!==void 0?r:null}static getCurrent(){return um()}static async getAll(){return fh()}static async getFocusedWindow(){for(const t of await fh())if(await t.isFocused())return t;return null}async listen(t,r){return this._handleTauriEvent(t,r)?()=>{const s=this.listeners[t];s.splice(s.indexOf(r),1)}:ov(t,r,{target:{kind:"Window",label:this.label}})}async once(t,r){return this._handleTauriEvent(t,r)?()=>{const s=this.listeners[t];s.splice(s.indexOf(r),1)}:XN(t,r,{target:{kind:"Window",label:this.label}})}async emit(t,r){if(uf.includes(t)){for(const s of this.listeners[t]||[])s({event:t,id:-1,payload:r});return}return QN(t,r)}async emitTo(t,r,s){if(uf.includes(r)){for(const i of this.listeners[r]||[])i({event:r,id:-1,payload:s});return}return JN(t,r,s)}_handleTauriEvent(t,r){return uf.includes(t)?(t in this.listeners?this.listeners[t].push(r):this.listeners[t]=[r],!0):!1}async scaleFactor(){return Le("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return Le("plugin:window|inner_position",{label:this.label}).then(t=>new ni(t))}async outerPosition(){return Le("plugin:window|outer_position",{label:this.label}).then(t=>new ni(t))}async innerSize(){return Le("plugin:window|inner_size",{label:this.label}).then(t=>new Ha(t))}async outerSize(){return Le("plugin:window|outer_size",{label:this.label}).then(t=>new Ha(t))}async isFullscreen(){return Le("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return Le("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return Le("plugin:window|is_maximized",{label:this.label})}async isFocused(){return Le("plugin:window|is_focused",{label:this.label})}async isDecorated(){return Le("plugin:window|is_decorated",{label:this.label})}async isResizable(){return Le("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return Le("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return Le("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return Le("plugin:window|is_closable",{label:this.label})}async isVisible(){return Le("plugin:window|is_visible",{label:this.label})}async title(){return Le("plugin:window|title",{label:this.label})}async theme(){return Le("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return Le("plugin:window|is_always_on_top",{label:this.label})}async center(){return Le("plugin:window|center",{label:this.label})}async requestUserAttention(t){let r=null;return t&&(t===Uh.Critical?r={type:"Critical"}:r={type:"Informational"}),Le("plugin:window|request_user_attention",{label:this.label,value:r})}async setResizable(t){return Le("plugin:window|set_resizable",{label:this.label,value:t})}async setEnabled(t){return Le("plugin:window|set_enabled",{label:this.label,value:t})}async isEnabled(){return Le("plugin:window|is_enabled",{label:this.label})}async setMaximizable(t){return Le("plugin:window|set_maximizable",{label:this.label,value:t})}async setMinimizable(t){return Le("plugin:window|set_minimizable",{label:this.label,value:t})}async setClosable(t){return Le("plugin:window|set_closable",{label:this.label,value:t})}async setTitle(t){return Le("plugin:window|set_title",{label:this.label,value:t})}async maximize(){return Le("plugin:window|maximize",{label:this.label})}async unmaximize(){return Le("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return Le("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return Le("plugin:window|minimize",{label:this.label})}async unminimize(){return Le("plugin:window|unminimize",{label:this.label})}async show(){return Le("plugin:window|show",{label:this.label})}async hide(){return Le("plugin:window|hide",{label:this.label})}async close(){return Le("plugin:window|close",{label:this.label})}async destroy(){return Le("plugin:window|destroy",{label:this.label})}async setDecorations(t){return Le("plugin:window|set_decorations",{label:this.label,value:t})}async setShadow(t){return Le("plugin:window|set_shadow",{label:this.label,value:t})}async setEffects(t){return Le("plugin:window|set_effects",{label:this.label,value:t})}async clearEffects(){return Le("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(t){return Le("plugin:window|set_always_on_top",{label:this.label,value:t})}async setAlwaysOnBottom(t){return Le("plugin:window|set_always_on_bottom",{label:this.label,value:t})}async setContentProtected(t){return Le("plugin:window|set_content_protected",{label:this.label,value:t})}async setSize(t){return Le("plugin:window|set_size",{label:this.label,value:t instanceof pl?t:new pl(t)})}async setMinSize(t){return Le("plugin:window|set_min_size",{label:this.label,value:t instanceof pl?t:t?new pl(t):null})}async setMaxSize(t){return Le("plugin:window|set_max_size",{label:this.label,value:t instanceof pl?t:t?new pl(t):null})}async setSizeConstraints(t){function r(s){return s?{Logical:s}:null}return Le("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:r(t==null?void 0:t.minWidth),minHeight:r(t==null?void 0:t.minHeight),maxWidth:r(t==null?void 0:t.maxWidth),maxHeight:r(t==null?void 0:t.maxHeight)}})}async setPosition(t){return Le("plugin:window|set_position",{label:this.label,value:t instanceof _a?t:new _a(t)})}async setFullscreen(t){return Le("plugin:window|set_fullscreen",{label:this.label,value:t})}async setSimpleFullscreen(t){return Le("plugin:window|set_simple_fullscreen",{label:this.label,value:t})}async setFocus(){return Le("plugin:window|set_focus",{label:this.label})}async setFocusable(t){return Le("plugin:window|set_focusable",{label:this.label,value:t})}async setIcon(t){return Le("plugin:window|set_icon",{label:this.label,value:Bi(t)})}async setSkipTaskbar(t){return Le("plugin:window|set_skip_taskbar",{label:this.label,value:t})}async setCursorGrab(t){return Le("plugin:window|set_cursor_grab",{label:this.label,value:t})}async setCursorVisible(t){return Le("plugin:window|set_cursor_visible",{label:this.label,value:t})}async setCursorIcon(t){return Le("plugin:window|set_cursor_icon",{label:this.label,value:t})}async setBackgroundColor(t){return Le("plugin:window|set_background_color",{color:t})}async setCursorPosition(t){return Le("plugin:window|set_cursor_position",{label:this.label,value:t instanceof _a?t:new _a(t)})}async setIgnoreCursorEvents(t){return Le("plugin:window|set_ignore_cursor_events",{label:this.label,value:t})}async startDragging(){return Le("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(t){return Le("plugin:window|start_resize_dragging",{label:this.label,value:t})}async setBadgeCount(t){return Le("plugin:window|set_badge_count",{label:this.label,value:t})}async setBadgeLabel(t){return Le("plugin:window|set_badge_label",{label:this.label,value:t})}async setOverlayIcon(t){return Le("plugin:window|set_overlay_icon",{label:this.label,value:t?Bi(t):void 0})}async setProgressBar(t){return Le("plugin:window|set_progress_bar",{label:this.label,value:t})}async setVisibleOnAllWorkspaces(t){return Le("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:t})}async setTitleBarStyle(t){return Le("plugin:window|set_title_bar_style",{label:this.label,value:t})}async setTheme(t){return Le("plugin:window|set_theme",{label:this.label,value:t})}async onResized(t){return this.listen(Ns.WINDOW_RESIZED,r=>{r.payload=new Ha(r.payload),t(r)})}async onMoved(t){return this.listen(Ns.WINDOW_MOVED,r=>{r.payload=new ni(r.payload),t(r)})}async onCloseRequested(t){return this.listen(Ns.WINDOW_CLOSE_REQUESTED,async r=>{const s=new ZN(r);await t(s),s.isPreventDefault()||await this.destroy()})}async onDragDropEvent(t){const r=await this.listen(Ns.DRAG_ENTER,c=>{t({...c,payload:{type:"enter",paths:c.payload.paths,position:new ni(c.payload.position)}})}),s=await this.listen(Ns.DRAG_OVER,c=>{t({...c,payload:{type:"over",position:new ni(c.payload.position)}})}),i=await this.listen(Ns.DRAG_DROP,c=>{t({...c,payload:{type:"drop",paths:c.payload.paths,position:new ni(c.payload.position)}})}),l=await this.listen(Ns.DRAG_LEAVE,c=>{t({...c,payload:{type:"leave"}})});return()=>{r(),i(),s(),l()}}async onFocusChanged(t){const r=await this.listen(Ns.WINDOW_FOCUS,i=>{t({...i,payload:!0})}),s=await this.listen(Ns.WINDOW_BLUR,i=>{t({...i,payload:!1})});return()=>{r(),s()}}async onScaleChanged(t){return this.listen(Ns.WINDOW_SCALE_FACTOR_CHANGED,t)}async onThemeChanged(t){return this.listen(Ns.WINDOW_THEME_CHANGED,t)}}var gx;(function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"})(gx||(gx={}));var bx;(function(e){e.Default="default",e.FluentOverlay="fluentOverlay"})(bx||(bx={}));var Vg;(function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"})(Vg||(Vg={}));var Gg;(function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"})(Gg||(Gg={}));function dm(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:new ni(e.position),size:new Ha(e.size),workArea:{position:new ni(e.workArea.position),size:new Ha(e.workArea.size)}}}async function mF(){return Le("plugin:window|current_monitor").then(dm)}async function pF(){return Le("plugin:window|primary_monitor").then(dm)}async function fF(e,t){return Le("plugin:window|monitor_from_point",{x:e,y:t}).then(dm)}async function gF(){return Le("plugin:window|available_monitors").then(e=>e.map(dm))}async function bF(){return Le("plugin:window|cursor_position").then(e=>new ni(e))}const vF=Object.freeze(Object.defineProperty({__proto__:null,CloseRequestedEvent:ZN,get Effect(){return Vg},get EffectState(){return Gg},LogicalPosition:av,LogicalSize:iv,PhysicalPosition:ni,PhysicalSize:Ha,get ProgressBarStatus(){return $g},get UserAttentionType(){return Uh},Window:lv,availableMonitors:gF,currentMonitor:mF,cursorPosition:bF,getAllWindows:fh,getCurrentWindow:um,monitorFromPoint:fF,primaryMonitor:pF},Symbol.toStringTag,{value:"Module"})),wF=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function cv(e){return e instanceof HTMLElement?!e.closest(wF):!0}async function uv(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await um().startDragging()}const Hh=.78,yF=1;function kF(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function eP(e,t,r,s){const i=Math.hypot(r-e,s-t),l=Math.min(1,i/120);return Hh+(yF-Hh)*l}function Oa(e){return Math.round(Number.isFinite(e)?e:0)}function xF(e){if(!kF())return null;const t=Oa(e.x),r=Oa(e.y);let s=!1,i=Promise.resolve();const l=(d,m)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(d,m)}).catch(()=>{}),i),c=async()=>{s||(s=!0,await l("close_detach_preview"))};return l("show_detach_preview",{title:e.title,x:t,y:r,scale:Hh}),{updatePosition(d,m){if(s)return;const f=Oa(d),v=Oa(m);l("update_detach_preview_position",{x:f,y:v,scale:eP(t,r,f,v)})},complete(){return c()},cancel(){return c()}}}function SF(e){if(typeof document>"u")return null;const t=Oa(e.x),r=Oa(e.y),s=document.createElement("div");s.className="desktop-window-detach-animation",s.setAttribute("aria-hidden","true"),s.dataset.state="preview",s.style.left=`${t}px`,s.style.top=`${r}px`,s.style.setProperty("--detach-preview-scale",Hh.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const l=document.createElement("strong");l.className="desktop-window-detach-animation-title",l.textContent=e.title;const c=document.createElement("div");c.className="desktop-window-detach-animation-body",i.append(l),s.append(i,c),document.body.append(s);let d=!1;const m=()=>{d||(d=!0,s.remove())};return{updatePosition(f,v){if(d)return;const g=Oa(f),w=Oa(v),k=eP(t,r,g,w);s.style.left=`${g}px`,s.style.top=`${w}px`,s.style.setProperty("--detach-preview-scale",k.toFixed(3))},async complete(){m()},async cancel(){m()}}}function vx(e){return xF(e)??SF(e)}const CF={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"进程管理",defaultFocusOwner:"terminal-manager-panel"}};function jF(e){return{...e,bounds:{...e.bounds}}}function TF(e,t,r){t&&(e.windows.registerDescriptor(t),r?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function NF(e){return CF[e]}function PF(e,t){return`${e}-${t}`}async function dv(e,t,r){const s=r.workspaceId.trim(),i=NF(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!s)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const l=PF(t,s),c=e.windows.getDescriptor(l),d=c?jF(c):null,m=e.windows.isWindowOpen(l),f=VA({windowId:l,kind:t,workspaceId:s,sessionId:r.sessionId??(d==null?void 0:d.sessionId)??null,mode:"external",bounds:d==null?void 0:d.bounds,focusOwner:r.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(f);const v=await e.bridge.createWindow(f);return v.ok?(e.windows.markWindowOpen(l),{ok:!0,value:f}):(d?TF(e,d,m):e.windows.removeWindow(l),{ok:!1,errorCode:v.errorCode,detail:v.detail})}function DF(e,t){return dv(e,"files",t)}function RF(e,t){return dv(e,"git",t)}function MF(e,t){return dv(e,"processes",t)}var gh,bh;function tP(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(r=>"rid"in r?r:tP(r));else if("action"in e&&e.action){const r=new GN;return r.onmessage=e.action,delete e.action,{...e,handler:r}}return e}async function Ll(e,t){const r=new GN;if(t&&typeof t=="object"&&("action"in t&&t.action&&(r.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Bi(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Bi(t.icon)),"items"in t&&t.items)){let s=function(i){var l;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((l=i.item.About)===null||l===void 0)&&l.icon)&&(i.item.About.icon=Bi(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Bi(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(s)),tP(i))};t.items=t.items.map(s)}return Le("plugin:menu|new",{kind:e,options:t,handler:r})}class Fl extends KN{get id(){return Wr(this,gh,"f")}get kind(){return Wr(this,bh,"f")}constructor(t,r,s){super(t),gh.set(this,void 0),bh.set(this,void 0),La(this,gh,r),La(this,bh,s)}}gh=new WeakMap,bh=new WeakMap;class hv extends Fl{constructor(t,r){super(t,r,"MenuItem")}static async new(t){return Ll("MenuItem",t).then(([r,s])=>new hv(r,s))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class mv extends Fl{constructor(t,r){super(t,r,"Check")}static async new(t){return Ll("Check",t).then(([r,s])=>new mv(r,s))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return Le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return Le("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var wx;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(wx||(wx={}));class pv extends Fl{constructor(t,r){super(t,r,"Icon")}static async new(t){return Ll("Icon",t).then(([r,s])=>new pv(r,s))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Bi(t)})}}class fv extends Fl{constructor(t,r){super(t,r,"Predefined")}static async new(t){return Ll("Predefined",t).then(([r,s])=>new fv(r,s))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function jl([e,t,r]){switch(r){case"Submenu":return new gv(e,t);case"Predefined":return new fv(e,t);case"Check":return new mv(e,t);case"Icon":return new pv(e,t);case"MenuItem":default:return new hv(e,t)}}class gv extends Fl{constructor(t,r){super(t,r,"Submenu")}static async new(t){return Ll("Submenu",t).then(([r,s])=>new gv(r,s))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r)})}async insert(t,r){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s),position:r})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(jl)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(jl))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(r=>r?jl(r):null)}async popup(t,r){var s;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(s=r==null?void 0:r.label)!==null&&s!==void 0?s:null,at:t instanceof _a?t:t?new _a(t):null})}async setAsWindowsMenuForNSApp(){return Le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return Le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Bi(t)})}}class Cl extends Fl{constructor(t,r){super(t,r,"Menu")}static async new(t){return Ll("Menu",t).then(([r,s])=>new Cl(r,s))}static async default(){return Le("plugin:menu|create_default").then(([t,r])=>new Cl(t,r))}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r)})}async insert(t,r){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s),position:r})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(jl)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(jl))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(r=>r?jl(r):null)}async popup(t,r){var s;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(s=r==null?void 0:r.label)!==null&&s!==void 0?s:null,at:t instanceof _a?t:t?new _a(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Cl(t[0],t[1]):null)}async setAsWindowMenu(t){var r;return Le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(r=t==null?void 0:t.label)!==null&&r!==void 0?r:null}).then(s=>s?new Cl(s[0],s[1]):null)}}async function bv(e){if(e.length===0)return;await(await Cl.new({items:e.map(r=>({id:r.id,text:r.label,enabled:!r.disabled,accelerator:r.accelerator,action:()=>{r.onSelect()}}))})).popup(void 0,um())}const vh="codingns.workspace.session-display-sort-mode",wh="codingns.file-panel.show-system-files",vv="codingns.notification.preferences",fl={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function Al(){return typeof window<"u"&&typeof window.localStorage<"u"}function AF(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function yx(){if(!Al())return"createdAt";const e=window.localStorage.getItem(vh);return AF(e)?e:"createdAt"}function kx(){return Al()?window.localStorage.getItem(wh)==="1":!1}function df(e){return typeof e=="boolean"}function xx(){if(!Al())return fl;const e=window.localStorage.getItem(vv);if(!e)return fl;try{const t=JSON.parse(e);return{notifyOnPermissionRequest:df(t.notifyOnPermissionRequest)?t.notifyOnPermissionRequest:fl.notifyOnPermissionRequest,notifyOnSessionCompleted:df(t.notifyOnSessionCompleted)?t.notifyOnSessionCompleted:fl.notifyOnSessionCompleted,notifyOnSessionFailed:df(t.notifyOnSessionFailed)?t.notifyOnSessionFailed:fl.notifyOnSessionFailed}}catch{return fl}}function Sx(e,t){return e.notifyOnPermissionRequest===t.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===t.notifyOnSessionCompleted&&e.notifyOnSessionFailed===t.notifyOnSessionFailed}function IF(e){Al()&&window.localStorage.setItem(vv,JSON.stringify(e))}class EF{constructor(){ot(this,"state",{sessionDisplaySortMode:yx(),showSystemFiles:kx(),notificationPreferences:xx()});ot(this,"listeners",new Set);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);ot(this,"handleStorage",t=>{if(t.key!==null&&t.key!==vh&&t.key!==wh&&t.key!==vv)return;const r=yx(),s=kx(),i=xx(),l=this.state.sessionDisplaySortMode===r,c=this.state.showSystemFiles===s,d=Sx(this.state.notificationPreferences,i);l&&c&&d||(this.state={sessionDisplaySortMode:r,showSystemFiles:s,notificationPreferences:i},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(t){Al()&&(t==="createdAt"?window.localStorage.removeItem(vh):window.localStorage.setItem(vh,t)),this.state.sessionDisplaySortMode!==t&&(this.state={...this.state,sessionDisplaySortMode:t},this.emit())}setShowSystemFiles(t){Al()&&(t?window.localStorage.setItem(wh,"1"):window.localStorage.removeItem(wh)),this.state.showSystemFiles!==t&&(this.state={...this.state,showSystemFiles:t},this.emit())}setNotificationPreferences(t){const r={...this.state.notificationPreferences,...t};Sx(this.state.notificationPreferences,r)||(IF(r),this.state={...this.state,notificationPreferences:r},this.emit())}emit(){for(const t of this.listeners)t()}}const wo=new EF;function ai(e){return p.useSyncExternalStore(wo.subscribe,()=>e(wo.getState()))}const Mc=new Map;function nP(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function Cx(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Er(e,t){const r=Mc.get(e);if(r&&!Cx(r.savedAt,t))return r.value;if(!nP())return null;const s=window.sessionStorage.getItem(e);if(!s)return null;try{const i=JSON.parse(s);return!i||Cx(i.savedAt,t)?(window.sessionStorage.removeItem(e),Mc.delete(e),null):(Mc.set(e,i),i.value)}catch{return window.sessionStorage.removeItem(e),Mc.delete(e),null}}function As(e,t){const r={savedAt:Date.now(),value:t};if(Mc.set(e,r),!!nP())try{window.sessionStorage.setItem(e,JSON.stringify(r))}catch{}}const LF="codingns.debug.perf";function FF(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(LF)==="1"}catch{return!1}}function Ot(e,t){if(!FF()||typeof performance>"u")return;const r=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${r}ms`,t);return}console.info(`[perf-ui] ${e} ${r}ms`)}function _F(){return _e.request("/api/workspaces")}async function rP(){try{return await _e.request("/api/workbench")}catch(e){if(!(e instanceof Ur)||e.status!==404)throw e;const t=await _F();return{items:await Promise.all(t.items.map(async s=>({workspace:s,sessions:(await $F(s.id)).items})))}}}function OF(e){return _e.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function BF(e){return _e.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function sP(e){return _e.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function WF(e){return _e.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function UF(e,t=5){const r=new URLSearchParams;return r.set("limit",String(t)),_e.request(`/api/debug-targets/${encodeURIComponent(e)}/runtimes?${r.toString()}`)}function HF(){return _e.request("/api/framework-compatibility-matrix")}function zF(e){return _e.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function iP(e,t){return _e.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(t)})}function aP(e){const t=new URLSearchParams;return e!=null&&e.trim()&&t.set("path",e.trim()),_e.request(`/api/workspaces/browse${t.size>0?`?${t.toString()}`:""}`)}function qF(e){return _e.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function $F(e){return _e.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function wv(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}`)}function VF(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function GF(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function oP(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:t})})}function lP(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:t})})}function KF(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:t})})}function YF(e){return _e.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function XF(e){return _e.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function QF(e){return _e.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function JF(e,t){return _e.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(t??{})})}function ZF(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function cP(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function e_(){return _e.request("/api/preferences/quick-phrases")}function t_(e){return _e.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function _l(e,t){const r=new URLSearchParams;return t!=null&&t.trim()&&r.set("workspaceId",t.trim()),_e.request(`/api/providers/${encodeURIComponent(e)}/capabilities${r.size>0?`?${r.toString()}`:""}`)}async function yv(e,t){const r=await Promise.allSettled(e.map(async i=>[i,await _l(i,t)])),s=[];for(const i of r){if(i.status!=="fulfilled")continue;const[l,c]=i.value;s.push([l,c])}return Object.fromEntries(s)}function kv(e,t,r,s="forward"){const i=new URLSearchParams;return i.set("limit",String(r)),i.set("direction",s),_e.request(`/api/sessions/${encodeURIComponent(e)}/messages?${i.toString()}`)}function n_(e,t){return _e.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content`)}function r_(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})}function uP(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(t)})}function xv(e){return _e.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function Sv(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(t)})}function s_(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function i_(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(t)})}function a_(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}`,{method:"DELETE"})}function o_(e,t){return _e.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}/steer`,{method:"POST"})}function Kg(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function dP(e){return _e.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function l_(e,t,r){return _e.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(t)}/reply`,{method:"POST",body:JSON.stringify(r)})}function hP(e){return _e.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function mP(e,t,r){const s=new URLSearchParams({workspaceId:e,path:t,staged:String(r)});return _e.request(`/api/git/diff?${s.toString()}`)}function pP(e,t){return _e.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function c_(e,t){return _e.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function u_(e,t){return _e.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function d_(e,t){return _e.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function h_(e,t){return _e.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function m_(e){return _e.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function jx(e,t=5,r=null){const s=new URLSearchParams({workspaceId:e,limit:String(t)});return r&&s.set("cursor",r),_e.request(`/api/git/history?${s.toString()}`)}function p_(e,t){const r=new URLSearchParams({workspaceId:e,commitHash:t});return _e.request(`/api/git/commit-detail?${r.toString()}`)}function fP(e){return _e.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function f_(e){return _e.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function g_(e,t,r){return _e.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:r})})}function Tx(e,t,r,s,i){return _e.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...r?{remote:r}:{},...s?{auth:s}:{},...i?{remember:i}:{}})})}function Nx(e){return _e.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}const b_="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",gP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",v_="/assets/gemini-D4G1NbrE.png",w_="/assets/kimi-BWNNSh7e.png",y_="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",k_=new Set(["low","medium","high","xhigh"]),x_=["claude-code","codex","opencode","gemini","kimi"],Wc=["codex","claude-code","opencode","gemini","kimi"],bP={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:b_,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:gP,defaultRunInputMode:"none",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:y_,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:v_,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:w_,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,foldRulesMessagesByDefault:!0}},S_=Array.from(new Set(Object.values(bP).map(e=>e.icon)));let Px=!1;function C_(e){return x_.includes(e)}function ha(e){return!e||!C_(e)?null:bP[e]}function j_(e){return[{id:"provider-default",name:o(e),usesProviderDefault:!0}]}function T_(e){const t=ha(e);return j_((t==null?void 0:t.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function vP(e){return!!(e&&ha(e))}function N_(e){const t=ha(e);return o((t==null?void 0:t.draftTitleKey)??"conversation.draftTitleCodex")}function qs(e,t="compact"){const r=ha(e);return r?t==="full"&&r.fullDisplayNameKey?o(r.fullDisplayNameKey):o(r.displayNameKey):(e==null?void 0:e.trim())||o("conversation.providerCodex")}function wP(e){const t=ha(e);return(t==null?void 0:t.icon)??gP}function yP(){Px||typeof window>"u"||(Px=!0,S_.forEach(e=>{const t=new window.Image;t.decoding="async",t.src=e,typeof t.decode=="function"&&t.decode().catch(()=>{})}))}function Ba(e){const t=ha(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(t==null?void 0:t.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(t==null?void 0:t.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(t==null?void 0:t.supportsAttachments)??!0,supportsPermissionPrompt:(t==null?void 0:t.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,modelOptions:T_(e),defaultReasoningLevel:t==null?void 0:t.defaultReasoningLevel,limitations:[]}}function P_(e){return(e==null?void 0:e.provider)??"claude-code"}function D_(e){var r;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const t=(e==null?void 0:e.provider)??null;return((r=ha(t))==null?void 0:r.supportsSlashMenuByDefault)??!1}function R_(e){var t;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((t=e==null?void 0:e.modelOptions)!=null&&t.some(r=>{var s;return((s=r.supportedReasoningEfforts)==null?void 0:s.some(i=>k_.has(i)))??!1}))}function M_(e,t){if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const r=(e==null?void 0:e.inRunInputMode)??"none";return r==="queued_guidance"||r==="none"||r==="streaming_guidance"&&t===!1}function kP(e){return(e==null?void 0:e.supportsRunSteering)!==void 0?e.supportsRunSteering:(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function A_(e){const t=ha(e);return(t==null?void 0:t.reasoningLevelPersists)??!1}function I_(e,t){var s;return((s=ha(t??null))==null?void 0:s.foldRulesMessagesByDefault)??!1}typeof window<"u"&&yP();function E_(e,t,r,s){return _e.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:r,expectedVersion:s??void 0})})}function hf(e){return _e.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function L_(e){return _e.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function F_(e,t){const r=new URLSearchParams({workspaceId:e,path:t});return _e.request(`/api/files/download?${r.toString()}`)}function Ac(e,t,r=1,s=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(r),pageSize:String(s)});return _e.request(`/api/files/search?${i.toString()}`)}function mf(e,t){const r=new URLSearchParams({workspaceId:e,path:t});return _e.request(`/api/files/preview?${r.toString()}`)}function Su(e){var t,r;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((r=e.lastErrorDetail)!=null&&r.trim())}function Cv(e,t,r){return`${e} is-${xP(t,r)}`}function xP(e,t){t==null||t.isActive;const r=__(e);return t!=null&&t.hasSubagents?r==="error"?"error":r==="unread"?"subagent-unread":r==="running"||r==="running_inferred"?"subagent-running":"subagent":r==="running_inferred"?"running-inferred":r.replace("_","-")}function eu(e){return e.runningState==="stale"?o("conversation.runtimeStale"):e.runningState==="unknown"?o("conversation.runtimeUnknown"):null}function SP(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function __(e){return Su(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?O_(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function O_(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function B_(e){return Cu(e)!==null}function qi(e){return e.isSubagent===!0&&!B_(e)}function Cu(e){return e.forkMethod==="reconstructed_message_fork"||e.forkMethod==="reconstructed_session_fork"?"reconstructed":e.forkMethod==="native_message_fork"||e.forkSourceType==="message"?"message":e.forkMethod==="native_session_fork"||e.forkSourceType==="session"?"session":null}function jv(e){const t=Cu(e);return t==="reconstructed"?o("shell.sessionForkReconstructed"):t==="message"?o("shell.sessionForkMessage"):t==="session"?o("shell.sessionForkSession"):null}function Tv(e){return e.sessionKind==="annotation"?"annotation":null}function CP(e){return Tv(e)==="annotation"?o("conversation.actionSessionBadge"):null}const Dx=48;function W_(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function $i(e,t){const r=W_(e)||t,s=r.length>Dx?r.slice(0,Dx).trimEnd():r;return{fullTitle:r,displayTitle:s}}function Pd(e,t){return(t??"").localeCompare(e??"")}function Rx(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Dd(e){return(e==null?void 0:e.trim())??""}function Nv(e,t,r){if(r==="updatedAt"){const c=Pd(e.updatedAt,t.updatedAt);if(c!==0)return c}if(r==="title"){const c=Rx(Dd(e.title),Dd(t.title));if(c!==0)return c}else{const c=Pd(e.createdAt,t.createdAt);if(c!==0)return c}const s=Pd(e.updatedAt,t.updatedAt);if(s!==0)return s;const i=Pd(e.createdAt,t.createdAt);if(i!==0)return i;const l=Rx(Dd(e.title),Dd(t.title));return l!==0?l:e.sessionId.localeCompare(t.sessionId)}function ju(e,t){return[...e].sort((r,s)=>Nv(r,s,t))}function Pv(e,t){return Array.isArray(e)?e.map(r=>({...r,sessions:ju(r.sessions,t),children:Pv(r.children,t)})):[]}const pf=5,ff=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function jP(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function TP(e,t){const r=e.reduce((d,m)=>d+m.count,0);if(r<=0)return[];const i=e.slice(0,pf).map((d,m)=>({...d,key:d.type,ratio:d.count/r,color:ff[m]??ff[0]})),l=e.slice(pf);if(l.length===0)return i;const c=l.reduce((d,m)=>d+m.count,0);return i.push({key:"other",type:t,count:c,ratio:c/r,color:ff[pf]}),i}function U_(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((s,i)=>{const l=t,c=i===e.length-1?1:Math.min(1,t+s.ratio);return t=c,`${s.color} ${Mx(l)} ${Mx(c)}`}).join(", ")})`}function NP(e){return{"--workbench-manage-chart-background":U_(e)}}function Mx(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const H_=8,z_=12,q_=160,Ax=96;function PP(e,t,r,s={}){const i=s.gapPx??H_,l=s.viewportMarginPx??z_,c=s.defaultWidthPx??q_,d=s.estimatedHeightPx??Ax,m=s.minHeightPx??Ax,f=Math.max(0,r.width),v=Math.max(0,r.height),g=Math.max(0,v-l*2),w=Math.max(0,f-l*2),k=Rd(Math.max(t.width||c,c),0,w),y=Math.max(t.height||d,d),C=Math.max(0,f-e.x-l),T=Math.max(0,e.x-l),j=C<k&&T>C,N=Math.max(0,v-e.y-i-l),D=Math.max(0,e.y-i-l),F=N<y&&D>N,E=Rd(Math.max(F?D:N,m),0,g),I=Math.min(y,E),M=j?e.x-k:e.x,_=Math.max(l,f-l-k),L=F?e.y-i-I:e.y+i,Q=Math.max(l,v-l-I),O=Rd(M,l,_),ne=Rd(L,l,Q),Y=j||O<e.x?"right":"left";return{top:ne,left:O,width:k,maxHeight:Math.max(0,E),transformOrigin:`${F?"bottom":"top"} ${Y}`}}function Rd(e,t,r){return!Number.isFinite(e)||r<t?t:Math.min(Math.max(e,t),r)}const DP="workbench.navigation.snapshot",RP=1800*1e3,$_="workbench.navigation.snapshot.host.";function MP(e){return`${$_}${e}`}function AP(e=RP,t=En.getState().activeHostId){if(t){const r=Er(MP(t),e);if(r)return r}return Er(DP,e)}function Md(e,t=En.getState().activeHostId){As(DP,e),t&&As(MP(t),e)}function tu(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(r=>({workspace:r.workspace,sessions:ju(r.sessions,t),childWorktrees:V_(r.childWorktrees,t)}))}function V_(e,t){return Pv(e,t)}function Tu(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function hm(e){const t=new Map;for(const r of e)t.set(r.workspace.id,Tu(r.workspace)),IP(t,r.childWorktrees??[],r.workspace,r.workspace);return Object.fromEntries(t)}function ri(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function IP(e,t,r,s,i=s.name){var l;for(const c of t){const d=((l=c.meta.displayName)==null?void 0:l.trim())||c.workspace.name;e.set(c.workspace.id,{workspaceId:c.workspace.id,tone:"worktree",backgroundColor:c.workspace.backgroundColor??null,displayName:d,workspaceName:c.workspace.name,branchName:c.meta.branchName||null,depth:c.meta.depth,rootWorkspaceId:r.id,rootDisplayName:r.name,parentWorkspaceId:c.meta.parentWorkspaceId||s.id,parentDisplayName:i}),IP(e,c.children,r,c.workspace,d)}}function mm(){return _e.request("/api/butler/profile")}function G_(e){return _e.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function Ix(e){return _e.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function K_(){return _e.request("/api/butler/control-session")}function Yg(){return _e.request("/api/butler/control-sessions")}function Y_(e){return _e.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function X_(){return _e.request("/api/butler/control-session/reset",{method:"POST"})}function Q_(e={}){return _e.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function J_(e){return _e.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function Z_(){return _e.request("/api/butler/control-session/events")}function pm(){return _e.request("/api/butler/overview")}function eO(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const r=t.toString(),s=r?`/api/butler/projects?${r}`:"/api/butler/projects";return _e.request(s)}function EP(e,t={}){const r=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&r.set("enabled",String(t.enabled)),t.executionMode&&r.set("executionMode",t.executionMode);const s=r.toString(),i=s?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${s}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return _e.request(i)}function Nu(e={}){var i,l;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),(l=e.projectId)!=null&&l.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const r=t.toString(),s=r?`/api/butler/inbox?${r}`:"/api/butler/inbox";return _e.request(s)}function tO(e){return _e.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function fm(e={}){var i,l;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.projectId)!=null&&i.trim()&&t.set("projectId",e.projectId.trim()),(l=e.sessionId)!=null&&l.trim()&&t.set("sessionId",e.sessionId.trim());const r=t.toString(),s=r?`/api/butler/follow-up-tasks?${r}`:"/api/butler/follow-up-tasks";return _e.request(s)}function nO(e){return _e.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function LP(e){return _e.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function rO(e){return _e.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function Ex(e,t){return _e.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:t.projectId,itemType:t.itemType,title:t.title,content:t.content,priority:t.priority,status:t.status})})}function sO(e){return _e.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function iO(e){return _e.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function aO(e){return _e.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function oO(){return _e.request("/api/butler/notifications/archives")}function lO(e,t){return _e.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function cO(e){const t=new URLSearchParams;return t.set("sessionId",e),_e.request(`/api/butler/session-target?${t.toString()}`)}function uO(e){const t=new URLSearchParams;return t.set("sessionId",e),_e.request(`/api/butler/session-action-context?${t.toString()}`)}function dO(e){return _e.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const Dv=new Map;function FP(){Dv.clear()}function Rv({disabled:e=!1,workspaceId:t=null,pendingProvider:r=null,selectedProvider:s=null,providers:i=Wc,className:l,disabledReasons:c,statusHintByProvider:d,onSelect:m}){const f=li(),v=!!t,[g,w]=p.useState(()=>Lx(i,t)),k=i.map(y=>({provider:y}));return p.useEffect(()=>{yP()},[]),p.useEffect(()=>{if(!t){w({});return}const y=Lx(i,t);w(y);const C=i.filter(j=>!y[j]);if(C.length===0)return;let T=!1;return yv(C,t).then(j=>{mO(t,j),T||w(N=>({...N,...j}))}),()=>{T=!0}},[i,t]),n.jsx("div",{className:`session-provider-grid${l?` ${l}`:""}`,children:k.map(y=>{const C=qs(y.provider,"full"),T=r===y.provider,j=s===y.provider,N=!!g[y.provider],D=hO(g[y.provider]??null),F=(c==null?void 0:c[y.provider])??D,W=T?o("shell.startingSession"):F||((d==null?void 0:d[y.provider])??(v&&!N&&!T?o("shell.providerChecking"):null));return n.jsxs("button",{type:"button",className:"session-provider-card","data-provider":y.provider,"data-pending":T?"true":"false","data-selected":j?"true":"false","aria-label":C,disabled:e||!!F,onClick:()=>{f.trigger("action"),m(y.provider)},children:[n.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:n.jsx("img",{src:wP(y.provider),alt:"",loading:"eager",decoding:"async"})}),n.jsxs("span",{className:"session-provider-card-copy",children:[n.jsx("strong",{children:C}),W?n.jsx("span",{className:"session-provider-card-status",children:W}):null]})]},y.provider)})})}function hO(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??o("conversation.capabilityDenied")}function Lx(e,t){const r=(t==null?void 0:t.trim())??"";if(!r)return{};const s=[];for(const i of e){const l=Dv.get(_P(r,i));l&&s.push([i,l])}return Object.fromEntries(s)}function mO(e,t){const r=e.trim();if(r)for(const[s,i]of Object.entries(t))i&&Dv.set(_P(r,s),i)}function _P(e,t){return`${e}::${t}`}class zh extends Error{constructor(t,r){super(r),this.code=t,this.name="HostSwitchError"}}class pO{constructor(){ot(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const r=this.performSwitch(t).finally(()=>{this.inFlight===r&&(this.inFlight=null)});this.inFlight=r,await r}async performSwitch(t){const r=En.getState();if(r.activeHostId===t)return;const s=kT(r,t);if(!s)throw new zh("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await DN(s.baseUrl)).reachable)throw new zh("HOST_UNREACHABLE",`目标 HOST 不可达:${s.baseUrl}`);await En.update({hosts:r.hosts.map(l=>l.id===t?{...l,lastConnectedAt:new Date().toISOString(),updatedAt:new Date().toISOString()}:l),activeHostId:t})}}const OP=new pO;function BP({collapsed:e=!1}){const[t,r]=p.useState(!1),[s,i]=p.useState(!1),[l,c]=p.useState(""),[d,m]=p.useState(""),[f,v]=p.useState(null),[g,w]=p.useState(null),k=p.useRef(null),y=p.useRef(null),C=Rl(M=>M),T=gu(M=>M.session),{showToast:j}=Qn(),N=za(C),D=p.useMemo(()=>fO(C.hosts,C.activeHostId),[C.activeHostId,C.hosts]),F=p.useCallback(()=>{if(typeof window>"u")return;const M=k.current;if(!M)return;const _=M.getBoundingClientRect(),L=window.innerWidth,Q=window.innerHeight,O=16,ne=8,G=Math.min(320,Math.max(240,L-O*2)),te=Math.min(e?Math.max(O,_.right+ne):Math.max(O,_.left),Math.max(O,L-G-O)),K=s?320:240,z=e?_.top:_.bottom+ne,q=Math.min(Math.max(O,z),Math.max(O,Q-K-O));w({position:"fixed",top:q,left:te,width:G,maxWidth:L-O*2})},[e,s]);p.useEffect(()=>{if(!t){w(null);return}function M(L){var Q,O;L.target instanceof Node&&!((Q=k.current)!=null&&Q.contains(L.target))&&!((O=y.current)!=null&&O.contains(L.target))&&(r(!1),i(!1))}function _(L){L.key==="Escape"&&(r(!1),i(!1))}return window.addEventListener("pointerdown",M),window.addEventListener("keydown",_),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),F(),()=>{window.removeEventListener("pointerdown",M),window.removeEventListener("keydown",_),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[t,F]);async function W(M){if(f||M.id===C.activeHostId){r(!1);return}v(M.id);try{await OP.switchHost(M.id),r(!1),i(!1)}catch(_){j({title:wO(_,M.name),tone:"error"})}finally{v(null)}}async function E(){let M;try{M=Ci(d)}catch{j({title:o("shell.hostAddInvalidUrl"),tone:"error"});return}if(C.hosts.some(Q=>Q.baseUrl===M)){j({title:o("shell.hostAddDuplicate"),tone:"error"});return}const _=new Date().toISOString(),L={id:vO(),name:l.trim()||gO(M),baseUrl:M,kind:bO(M),createdAt:_,updatedAt:_,lastConnectedAt:null,lastUserId:null,lastUsername:null};try{await En.update({hosts:[...C.hosts,L]}),c(""),m(""),i(!1),j({title:o("shell.hostAddSuccess",{name:L.name})})}catch{j({title:o("shell.hostAddFailed"),tone:"error"})}}if(!N)return null;const I=T!=null&&T.user.username?`${N.baseUrl} · ${T.user.username}`:N.baseUrl;return n.jsxs("div",{ref:k,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[n.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":o("shell.hostSwitcherAriaLabel"),title:I,"aria-expanded":t,onClick:()=>{r(M=>!M),i(!1)},children:n.jsx(yO,{})}),t&&g&&typeof document<"u"?$n.createPortal(n.jsxs("div",{ref:y,className:"workbench-host-switcher-menu",style:g,role:"menu","aria-label":o("shell.hostSwitcherTitle"),children:[n.jsx("div",{className:"workbench-host-switcher-menu-header",children:n.jsx("strong",{children:o("shell.hostSwitcherTitle")})}),n.jsx("div",{className:"workbench-host-switcher-list",children:D.map(M=>{const _=M.id===C.activeHostId,L=_?(T==null?void 0:T.user.username)??M.lastUsername??M.baseUrl:M.lastUsername??M.baseUrl;return n.jsxs("button",{type:"button",className:"workbench-host-switcher-item","data-active":_,disabled:f!==null,onClick:()=>{W(M)},children:[n.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[n.jsxs("span",{className:"workbench-host-switcher-item-title",children:[M.name,_?n.jsx("span",{className:"workbench-host-switcher-item-badge",children:o("shell.hostSwitcherCurrentBadge")}):null]}),n.jsx("span",{className:"workbench-host-switcher-item-meta",children:L})]}),n.jsx("span",{className:"workbench-host-switcher-item-trailing",children:f===M.id?o("shell.hostSwitcherSwitching"):_?n.jsx(xO,{}):n.jsx(kO,{})})]},M.id)})}),s?n.jsxs("div",{className:"workbench-host-switcher-form",children:[n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:o("shell.hostSwitcherNameLabel")}),n.jsx("input",{value:l,onChange:M=>c(M.target.value),placeholder:o("shell.hostSwitcherNamePlaceholder")})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:o("shell.hostSwitcherUrlLabel")}),n.jsx("input",{value:d,onChange:M=>m(M.target.value),placeholder:o("shell.hostSwitcherUrlPlaceholder")})]}),n.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{i(!1),c(""),m("")},children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",onClick:()=>{E()},children:o("shell.hostSwitcherSaveAction")})]})]}):n.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0)},children:[n.jsx(SO,{}),o("shell.hostSwitcherAddAction")]})]}),document.body):null]})}function fO(e,t){return[...e].sort((r,s)=>{if(r.id===t)return-1;if(s.id===t)return 1;const i=r.lastConnectedAt??r.updatedAt??r.createdAt;return(s.lastConnectedAt??s.updatedAt??s.createdAt).localeCompare(i)})}function gO(e){try{const t=new URL(e),r=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${r}`}catch{return e}}function bO(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function vO(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function wO(e,t){return e instanceof zh?e.code==="HOST_UNREACHABLE"?o("shell.hostSwitchUnreachable",{name:t}):o("shell.hostSwitchMissing"):o("shell.hostSwitchFailed")}function yO(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function kO(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function xO(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function SO(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function CO(){return n.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true",children:n.jsx("path",{d:"M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})}function Lo({className:e,"aria-label":t,...r}){return n.jsx("button",{type:"button",className:e?`workbench-modal-close ${e}`:"workbench-modal-close","aria-label":t??o("common.close"),...r,children:n.jsx(CO,{})})}function Ln({open:e,title:t,description:r,className:s,headerActions:i,showCloseButton:l=!0,onClose:c,children:d}){return p.useEffect(()=>{if(!e)return;function m(f){f.key==="Escape"&&c()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[c,e]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:c}),n.jsxs("section",{className:`workbench-modal-card surface-card${s?` ${s}`:""}`,role:"dialog","aria-modal":"true","aria-label":t,children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:t}),n.jsx("p",{children:r})]}),i||l?n.jsxs("div",{className:"workbench-modal-header-actions",children:[i,l?n.jsx(Lo,{onClick:c}):null]}):null]}),n.jsx("div",{className:"workbench-modal-body",children:d})]})]}),document.body)}const Ad={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function WP({open:e,onClose:t,onCloned:r}){const{showToast:s}=Qn(),[i,l]=p.useState(!1),[c,d]=p.useState(Ad),[m,f]=p.useState(!1),[v,g]=p.useState(!1),[w,k]=p.useState(null),[y,C]=p.useState(""),[T,j]=p.useState(""),[N,D]=p.useState(null),[F,W]=p.useState([]),[E,I]=p.useState([]),M=i||v;p.useEffect(()=>{!e&&!i&&(d(Ad),f(!1),k(null))},[i,e]);const _=p.useCallback(async te=>{g(!0),k(null);try{const K=await aP(te);C(K.currentPath),j(K.currentPath),D(K.parentPath),W(K.roots),I(K.items),d(z=>({...z,parentPath:K.currentPath}))}catch(K){C(""),D(null),I([]),k(K instanceof Error?K.message:o("shell.importBrowserBrowseFailed"))}finally{g(!1)}},[]);function L(){i||(f(!1),k(null),d(Ad),t())}function Q(){f(!0),_(c.parentPath||void 0)}function O(){i||(f(!1),k(null))}async function ne(te){te.preventDefault(),await _(T)}function Y(){d(te=>({...te,parentPath:y})),f(!1),k(null)}async function G(te){te.preventDefault();const K=c.repositoryUrl.trim(),z=c.parentPath.trim();if(!K){s({title:o("shell.cloneRepoRequired"),tone:"error"});return}if(!z){s({title:o("shell.clonePathRequired"),tone:"error"});return}l(!0);try{const q=await BF({repositoryUrl:K,parentPath:z,directoryName:c.directoryName.trim()||void 0,name:c.name.trim()||void 0,auth:c.authMode==="none"?{mode:"none"}:c.authMode==="basic"?{mode:"basic",username:c.username.trim(),password:c.password}:{mode:"token",username:c.username.trim()||void 0,token:c.token}});await(r==null?void 0:r(q)),d(Ad),f(!1),s({title:o("shell.cloneSuccess"),description:q.path,tone:"success"}),t()}catch(q){s({title:q instanceof Error?q.message:o("shell.cloneFailed"),tone:"error"})}finally{l(!1)}}return n.jsxs(n.Fragment,{children:[n.jsx(Ln,{open:e,title:o("shell.cloneWorkspaceTitle"),description:o("shell.cloneWorkspaceHint"),onClose:L,children:n.jsxs("form",{className:"workbench-clone-form",onSubmit:te=>void G(te),children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneRepositoryLabel")}),n.jsx("input",{type:"text",value:c.repositoryUrl,placeholder:o("shell.cloneRepositoryPlaceholder"),onChange:te=>d(K=>({...K,repositoryUrl:te.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneParentPathLabel")}),n.jsxs("div",{className:"workbench-modal-inline-field",children:[n.jsx("input",{type:"text",value:c.parentPath,placeholder:o("shell.cloneParentPathPlaceholder"),onChange:te=>d(K=>({...K,parentPath:te.target.value}))}),n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:Q,children:o("shell.clonePickDirectory")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneDirectoryNameLabel")}),n.jsx("input",{type:"text",value:c.directoryName,placeholder:o("shell.cloneDirectoryNamePlaceholder"),onChange:te=>d(K=>({...K,directoryName:te.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.importNameLabel")}),n.jsx("input",{type:"text",value:c.name,placeholder:o("shell.importNamePlaceholder"),onChange:te=>d(K=>({...K,name:te.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneAuthModeLabel")}),n.jsxs("select",{value:c.authMode,onChange:te=>d(K=>({...K,authMode:te.target.value})),children:[n.jsx("option",{value:"none",children:o("shell.cloneAuthModeNone")}),n.jsx("option",{value:"basic",children:o("shell.cloneAuthModeBasic")}),n.jsx("option",{value:"token",children:o("shell.cloneAuthModeToken")})]})]}),c.authMode==="basic"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:c.username,placeholder:o("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:te=>d(K=>({...K,username:te.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.clonePasswordLabel")}),n.jsx("input",{type:"password",value:c.password,placeholder:o("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:te=>d(K=>({...K,password:te.target.value}))})]})]}):null,c.authMode==="token"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:c.username,placeholder:o("shell.cloneTokenUsernamePlaceholder"),onChange:te=>d(K=>({...K,username:te.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneTokenLabel")}),n.jsx("input",{type:"password",value:c.token,placeholder:o("shell.cloneTokenPlaceholder"),onChange:te=>d(K=>({...K,token:te.target.value}))})]})]}):null,n.jsx("p",{className:"workbench-import-hint",children:o("shell.cloneHint")}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:L,children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:o(i?"shell.cloneSubmitting":"shell.cloneSubmit")})]})]})}),n.jsxs(Ln,{open:e&&m,title:o("shell.cloneBrowserTitle"),description:o("shell.cloneBrowserDescription"),onClose:O,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ne,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:T,placeholder:o("shell.importPathPlaceholder"),onChange:te=>j(te.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:M||!N,onClick:()=>{N&&_(N)},children:o("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:M,children:o("shell.importBrowserOpenPath")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:o("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:F.map(te=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:M,onClick:()=>{_(te.path)},children:te.name},te.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:y}),w?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:w}):null,v?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:o("common.loading")}):E.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:E.map(te=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:M,onClick:()=>{_(te.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:te.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:te.path})]},te.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:o("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:O,children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:M||!y,onClick:Y,children:o("shell.cloneBrowserSubmit")})]})]})]})}const Po="butler:inbox-updated";function gf(){typeof window>"u"||window.dispatchEvent(new Event(Po))}const Fx={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function UP({active:e,preferredWorkspaceId:t,preferredSessionId:r,creationRequestId:s=0,initialDraft:i=null,compactComposer:l=!1,composerOpen:c=!0,onComposerOpenChange:d}){const{showToast:m}=Qn(),[f,v]=p.useState(!1),[g,w]=p.useState(!1),[k,y]=p.useState([]),[C,T]=p.useState([]),[j,N]=p.useState(null),[D,F]=p.useState(null),[W,E]=p.useState(Fx),[I,M]=p.useState(!1),_=p.useMemo(()=>Ox(k,t,D),[D,t,k]),L=p.useMemo(()=>I?C:C.filter(K=>K.status!=="closed"),[C,I]);p.useEffect(()=>{e&&Q()},[e,r]),p.useEffect(()=>{!e||j||E(K=>{const z=Wx({projects:_,currentProjectId:K.projectId,preferredProjectId:D,preferredWorkspaceId:t});return z===K.projectId?K:{...K,projectId:z}})},[e,j,D,t,_]),p.useEffect(()=>{!e||s<=0||(O(void 0,t,i,D),d==null||d(!0))},[e,s,i,d,D,t]);async function Q(){v(!0);try{const[K,z,q]=await Promise.all([eO(),Nu(),r?cO(r).catch(()=>null):Promise.resolve(null)]),P=(q==null?void 0:q.target.project.id)??null;F(P),y(K.items),T(z.items),j||O(K.items,t,s>0?i:null,P)}catch(K){m({title:o("shell.butlerInboxLoadFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{v(!1)}}function O(K=k,z=t,q=i,P=D){var X,R;const U=Ox(K,z,P);N(null),E({...Fx,projectId:Wx({projects:U,preferredProjectId:P,preferredWorkspaceId:z}),title:((X=q==null?void 0:q.title)==null?void 0:X.trim())??"",content:((R=q==null?void 0:q.content)==null?void 0:R.trim())??""})}function ne(K){N(K.id),E({projectId:K.projectId,itemType:K.itemType,title:K.title,content:K.content,status:K.status}),l&&(d==null||d(!0))}async function Y(K){K.preventDefault(),w(!0);try{j?(await Ex(j,{projectId:W.projectId,itemType:W.itemType,title:W.title,content:W.content,status:W.status,priority:"medium"}),m({title:o("shell.butlerInboxUpdated"),tone:"success"})):(await tO({projectId:W.projectId,itemType:W.itemType,title:W.title,content:W.content,status:W.status,priority:"medium"}),m({title:o("shell.butlerInboxCreated"),tone:"success"})),gf(),await Q(),O(),l&&(d==null||d(!1))}catch(z){m({title:o("shell.butlerInboxSaveFailed"),description:z instanceof Error?z.message:void 0,tone:"error"})}finally{w(!1)}}async function G(K){w(!0);try{await aO(K),m({title:o("shell.butlerInboxDeleted"),tone:"success"}),gf(),await Q(),j===K&&O()}catch(z){m({title:o("shell.butlerInboxDeleteFailed"),description:z instanceof Error?z.message:void 0,tone:"error"})}finally{w(!1)}}async function te(K,z){if(K.status!==z){w(!0);try{await Ex(K.id,{status:z}),m({title:o("shell.butlerInboxUpdated"),tone:"success"}),gf(),await Q(),j===K.id&&E(q=>({...q,status:z}))}catch(q){m({title:o("shell.butlerInboxSaveFailed"),description:q instanceof Error?q.message:void 0,tone:"error"})}finally{w(!1)}}}return n.jsxs("div",{className:"workspace-inbox-modal",children:[l?null:n.jsx("section",{className:"workspace-inbox-panel",children:n.jsx(_x,{selectableProjects:_,formState:W,saving:g,editingItemId:j,useMobilePicker:!1,onProjectChange:K=>{E(z=>({...z,projectId:K}))},onItemTypeChange:K=>{E(z=>({...z,itemType:K}))},onStatusChange:K=>{E(z=>({...z,status:K}))},onTitleChange:K=>{E(z=>({...z,title:K}))},onContentChange:K=>{E(z=>({...z,content:K}))},onCancel:()=>O(),onSubmit:Y})}),n.jsxs("section",{className:"workspace-inbox-panel",children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsxs("div",{children:[n.jsx("h3",{children:o("shell.butlerInboxListTitle")}),n.jsx("p",{children:o("shell.butlerInboxListDescription")})]}),n.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[n.jsx("input",{type:"checkbox",checked:I,onChange:K=>M(K.target.checked)}),n.jsx("span",{children:o("shell.butlerInboxShowClosedAction")})]})]}),f?n.jsx("p",{className:"workspace-inbox-status",children:o("shell.butlerInboxLoading")}):null,!f&&L.length===0?n.jsx("p",{className:"workspace-inbox-status",children:o("shell.butlerInboxEmpty")}):null,!f&&L.length>0?n.jsx("div",{className:"workspace-inbox-list",children:L.map(K=>n.jsxs("article",{className:"workspace-inbox-item",children:[n.jsxs("div",{className:"workspace-inbox-item-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:K.title}),n.jsx("p",{children:K.projectName})]}),n.jsxs("div",{className:"workspace-inbox-item-badges",children:[n.jsx("span",{className:"workspace-inbox-badge",children:Ux(K.status)}),n.jsx("span",{className:"workspace-inbox-badge",children:DO(K.itemType)})]})]}),n.jsx("p",{className:"workspace-inbox-item-content",children:K.content}),n.jsxs("div",{className:"workspace-inbox-item-footer",children:[n.jsx("span",{children:RO(K.updatedAt)}),n.jsxs("div",{className:"workspace-inbox-item-actions",children:[n.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":o("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(z=>{const q=K.status===z;return n.jsx("button",{type:"button",className:"secondary-button","data-active":q,disabled:g,onClick:()=>{te(K,z)},children:Ux(z)},`${K.id}:${z}`)})}),n.jsx("button",{type:"button",className:"secondary-button",disabled:g,onClick:()=>ne(K),children:o("shell.butlerInboxEditAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:g,onClick:()=>{G(K.id)},children:o("shell.butlerInboxDeleteAction")})]})]})]},K.id))}):null]}),l?n.jsx(Ln,{open:e&&c,title:o(j?"shell.butlerInboxEditingTitle":"shell.butlerInboxCreateTitle"),description:o("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{d==null||d(!1),O()},children:n.jsx("div",{className:"workspace-inbox-composer-modal-body",children:n.jsx(_x,{selectableProjects:_,formState:W,saving:g,editingItemId:j,useMobilePicker:!0,onProjectChange:K=>{E(z=>({...z,projectId:K}))},onItemTypeChange:K=>{E(z=>({...z,itemType:K}))},onStatusChange:K=>{E(z=>({...z,status:K}))},onTitleChange:K=>{E(z=>({...z,title:K}))},onContentChange:K=>{E(z=>({...z,content:K}))},onCancel:()=>{d==null||d(!1),O()},onSubmit:Y})})}):null]})}function _x(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),r=[{value:"task",label:o("shell.butlerInboxTypeTask")},{value:"bug",label:o("shell.butlerInboxTypeBug")},{value:"feature",label:o("shell.butlerInboxTypeFeature")},{value:"change",label:o("shell.butlerInboxTypeChange")}],s=[{value:"pending",label:o("shell.butlerInboxStatusPending")},{value:"in_progress",label:o("shell.butlerInboxStatusInProgress")},{value:"closed",label:o("shell.butlerInboxStatusClosed")}];return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsx("h3",{children:e.editingItemId?o("shell.butlerInboxEditingTitle"):o("shell.butlerInboxCreateTitle")}),n.jsx("p",{children:o("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?n.jsx("p",{className:"workspace-inbox-status",children:o("shell.butlerInboxProjectsEmpty")}):n.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[n.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?n.jsxs(n.Fragment,{children:[n.jsx(bf,{label:o("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),n.jsx(bf,{label:o("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:r,disabled:e.saving,onChange:e.onItemTypeChange}),n.jsx(bf,{label:o("shell.butlerInboxStatusLabel"),value:e.formState.status,options:s,disabled:e.saving,onChange:e.onStatusChange})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.butlerInboxProjectLabel")}),n.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>n.jsx("option",{value:i.id,children:i.name},i.id))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.butlerInboxTypeLabel")}),n.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[n.jsx("option",{value:"task",children:o("shell.butlerInboxTypeTask")}),n.jsx("option",{value:"bug",children:o("shell.butlerInboxTypeBug")}),n.jsx("option",{value:"feature",children:o("shell.butlerInboxTypeFeature")}),n.jsx("option",{value:"change",children:o("shell.butlerInboxTypeChange")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.butlerInboxStatusLabel")}),n.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[n.jsx("option",{value:"pending",children:o("shell.butlerInboxStatusPending")}),n.jsx("option",{value:"in_progress",children:o("shell.butlerInboxStatusInProgress")}),n.jsx("option",{value:"closed",children:o("shell.butlerInboxStatusClosed")})]})]})]})}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.butlerInboxTitleLabel")}),n.jsx("input",{value:e.formState.title,placeholder:o("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.butlerInboxContentLabel")}),n.jsx("textarea",{rows:4,value:e.formState.content,placeholder:o("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?o("shell.butlerInboxCancelEditAction"):o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?o("shell.butlerInboxUpdateAction"):o("shell.butlerInboxCreateAction")})]})]})]})}function bf({label:e,value:t,options:r,disabled:s,onChange:i}){const[l,c]=p.useState(!1),d=r.find(m=>m.value===t)??r[0]??null;return p.useEffect(()=>{if(!l)return;function m(f){f.key==="Escape"&&c(!1)}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[l]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[n.jsx("span",{children:e}),n.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":l,disabled:s||r.length===0,onClick:()=>c(!0),children:[n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(d==null?void 0:d.label)??""}),n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:n.jsx(NO,{expanded:l})})]})]}),n.jsx(jO,{open:l,title:e,options:r,selectedValue:t,onClose:()=>c(!1),onSelect:m=>{i(m),c(!1)}})]})}function jO({open:e,title:t,options:r,selectedValue:s,onClose:i,onSelect:l}){return!e||typeof document>"u"?null:$n.createPortal(n.jsx("div",{className:"ios-action-sheet-overlay workspace-inbox-picker-sheet-overlay",role:"presentation",onClick:i,children:n.jsxs("div",{className:"mobile-workspace-home-sheet workspace-inbox-picker-sheet",role:"dialog","aria-modal":"true","aria-label":t,onClick:c=>c.stopPropagation(),children:[n.jsxs("div",{className:"mobile-workspace-home-sheet-card workspace-inbox-picker-sheet-card",children:[n.jsx("div",{className:"mobile-workspace-home-sheet-header workspace-inbox-picker-sheet-header",children:n.jsx("strong",{children:t})}),n.jsx("div",{className:"mobile-workspace-home-group workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:r.map(c=>{const d=c.value===s;return n.jsxs("button",{type:"button",className:"mobile-workspace-home-row workspace-inbox-picker-option",role:"option","aria-selected":d,onClick:()=>l(c.value),children:[n.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[n.jsx("strong",{children:c.label}),c.description?n.jsx("span",{children:c.description}):null]}),n.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:d?n.jsx(PO,{}):null})]},c.value)})})]}),n.jsx("button",{type:"button",className:"ios-action-sheet-cancel",onClick:i,children:o("common.cancel")})]})}),document.body)}function Xg({open:e,preferredWorkspaceId:t,preferredSessionId:r,creationRequestId:s=0,initialDraft:i=null,onClose:l,compactComposer:c=!1}){const[d,m]=p.useState(0),[f,v]=p.useState(!c);return p.useEffect(()=>{e||v(!c)},[c,e]),n.jsx(Ln,{open:e,title:o("shell.butlerInboxModalTitle"),description:o("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!c,headerActions:c?n.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":o("shell.butlerInboxCreateAction"),title:o("shell.butlerInboxCreateAction"),onClick:()=>{m(g=>g+1),v(!0)},children:n.jsx(TO,{})}):void 0,onClose:l,children:n.jsx(UP,{active:e,preferredWorkspaceId:t,preferredSessionId:r,creationRequestId:Math.max(s,d),initialDraft:i,compactComposer:c,composerOpen:f,onComposerOpenChange:v})})}function Ox(e,t,r){return[...e].filter(s=>s.lifecycleStatus!=="archived").sort((s,i)=>{const l=Bx(s,t,r),c=Bx(i,t,r);return l!==c?c-l:s.name.localeCompare(i.name,"zh-Hans-CN")})}function Bx(e,t,r){return r&&e.id===r?2:t&&e.workspaceId===t?1:0}function Wx({projects:e,currentProjectId:t,preferredProjectId:r,preferredWorkspaceId:s}){var l;if(t&&e.some(c=>c.id===t))return t;if(r&&e.some(c=>c.id===r))return r;const i=s?e.find(c=>c.workspaceId===s):null;return(i==null?void 0:i.id)||((l=e[0])==null?void 0:l.id)||""}function TO(){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M12 5v14"}),n.jsx("path",{d:"M5 12h14"})]})}function NO({expanded:e}){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:n.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function PO(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function DO(e){switch(e){case"bug":return o("shell.butlerInboxTypeBug");case"feature":return o("shell.butlerInboxTypeFeature");case"change":return o("shell.butlerInboxTypeChange");case"task":default:return o("shell.butlerInboxTypeTask")}}function Ux(e){switch(e){case"in_progress":return o("shell.butlerInboxStatusInProgress");case"closed":return o("shell.butlerInboxStatusClosed");case"pending":default:return o("shell.butlerInboxStatusPending")}}function RO(e){return new Date(e).toLocaleString()}function HP({open:e,onClose:t,onImported:r}){const{showToast:s}=Qn(),[i,l]=p.useState(!1),[c,d]=p.useState(!1),[m,f]=p.useState(!1),[v,g]=p.useState(null),[w,k]=p.useState(""),[y,C]=p.useState(""),[T,j]=p.useState(null),[N,D]=p.useState([]),[F,W]=p.useState([]),[E,I]=p.useState(!1),[M,_]=p.useState(""),L=i||c||m,Q=p.useCallback(async z=>{l(!0),g(null);try{const q=await aP(z);k(q.currentPath),C(q.currentPath),j(q.parentPath),D(q.roots),W(q.items)}catch(q){k(""),j(null),W([]),g(q instanceof Error?q.message:o("shell.importBrowserBrowseFailed"))}finally{l(!1)}},[]);p.useEffect(()=>{if(!e){I(!1),_(""),g(null);return}Q(w||void 0)},[Q,e]);function O(){L||(I(!1),_(""),t())}async function ne(z){z.preventDefault(),await Q(y)}function Y(){!w||L||(_(""),I(!0))}function G(){c||(I(!1),_(""))}async function te(z){z==null||z.preventDefault();const q=M.trim();if(!(!w||!q||L)){d(!0),g(null);try{const P=await qF({parentPath:w,directoryName:q});s({title:o("shell.importBrowserCreateDirectorySuccess"),description:P.path,tone:"success"}),I(!1),_(""),await Q(P.path)}catch(P){const U=P instanceof Error?P.message:o("shell.importBrowserCreateDirectoryFailed");g(U),s({title:U,tone:"error"})}finally{d(!1)}}}async function K(){const z=w.trim();if(!(!z||L)){f(!0),g(null);try{const q=await OF({path:z});s({title:o("shell.importSuccess"),description:q.path,tone:"success"}),t(),Promise.resolve().then(()=>r==null?void 0:r(q)).catch(P=>{s({title:P instanceof Error?P.message:o("shell.navigationLoadFailed"),tone:"error"})})}catch(q){s({title:q instanceof Error?q.message:o("shell.importFailed"),tone:"error"})}finally{f(!1)}}}return n.jsxs(n.Fragment,{children:[n.jsxs(Ln,{open:e,title:o("shell.importBrowserTitle"),description:o("shell.importBrowserDescription"),onClose:O,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ne,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:y,placeholder:o("shell.importPathPlaceholder"),onChange:z=>C(z.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:L||!T,onClick:()=>{T&&Q(T)},children:o("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:L,children:o("shell.importBrowserOpenPath")}),n.jsx("button",{type:"button",className:"secondary-button",disabled:L||!w,onClick:Y,children:o("shell.importBrowserCreateDirectory")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:o("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:N.map(z=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:L,onClick:()=>{Q(z.path)},children:z.name},z.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:w}),v?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:v}):null,i?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:o("common.loading")}):F.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:F.map(z=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:L,onClick:()=>{Q(z.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:z.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:z.path})]},z.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:o("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:L,onClick:O,children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:L||!w,onClick:()=>{K()},children:o(m?"shell.importSubmitting":"shell.importBrowserSubmit")})]})]}),n.jsx(Ln,{open:e&&E,title:o("shell.importBrowserCreateDirectoryTitle"),description:o("shell.importBrowserCreateDirectoryDescription"),onClose:G,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:z=>void te(z),children:[n.jsx("div",{className:"workbench-directory-browser-current-path",children:w}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.importBrowserCreateDirectoryLabel")}),n.jsx("input",{type:"text",value:M,placeholder:o("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:z=>_(z.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:c,onClick:G,children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:c||!M.trim(),children:o(c?"shell.importBrowserCreatingDirectory":"shell.importBrowserCreateDirectorySubmit")})]})]})})]})}const Hx="workbench.left.width",zx="workbench.right.width",qx="workbench.left.collapsed",$x="workbench.right.collapsed",vf="workbench.last.session.path",wf="workbench.workspace.selected.id",Vx="workbench.notifications.seen_at",MO=280,AO=320,Id=208,Gx=520,Kx=560,IO=200,yf=20,vc=40,Ed=5,EO=3e4,LO=12,Yx=60*1e3,FO=4e3,Xx=220,Qx=18,_O=6,OO="workbench:focus-composer",BO=new Set(["starting","running","reconnecting","stale","unknown"]),WO=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function UO(e){return BO.has(e.runningState??"idle")||e.activityState==="running"}function HO(e){var i,l;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",r=((l=e.lastErrorDetail)==null?void 0:l.trim())??"",s=[t,r].filter(c=>c.length>0).join(" · ");return s?s.length<=Xx?s:`${s.slice(0,Xx-3)}...`:null}function zO(e,t,r){var l,c,d,m,f,v,g,w,k,y,C,T;const s=new Map(e.projects.map(j=>[j.id,j.workspaceId])),i=[];for(const j of r){const N=j.title.trim()||j.projectName;if(j.assistantState.lifecycleStage==="analyzed"&&!((l=j.assistantState.linkedSessionId)!=null&&l.trim())&&j.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${j.id}:${j.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:o("shell.globalNotificationTodoAnalyzedTitle",{title:N}),body:((c=j.assistantState.analysisSummary)==null?void 0:c.trim())||((d=j.assistantState.generatedPrompt)==null?void 0:d.trim())||j.content,routePath:Ui(j.workspaceId),workspaceId:j.workspaceId,createdAt:j.assistantState.lastAnalyzedAt});continue}j.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${j.id}:${j.updatedAt}`,kind:"todo_analyze_failed",title:o("shell.globalNotificationTodoAnalyzeFailedTitle",{title:N}),body:((m=j.assistantState.lastError)==null?void 0:m.trim())||j.content,routePath:Ui(j.workspaceId),workspaceId:j.workspaceId,createdAt:j.updatedAt})}for(const j of t){const N=((f=j.sessionTitle)==null?void 0:f.trim())||j.projectName,D=j.updatedAt||j.lastAutomationAt||j.createdAt;if(j.status==="waiting_user"){i.push({id:`follow-up-waiting:${j.id}`,kind:"follow_up_waiting_user",title:o("shell.globalNotificationFollowUpWaitingTitle",{title:N}),body:((v=j.waitingReason)==null?void 0:v.trim())||((g=j.lastAutomationSummary)==null?void 0:g.trim())||j.objective,routePath:Yn(j.workspaceId,j.sessionId),workspaceId:j.workspaceId,createdAt:D});continue}if(j.status==="completed"){i.push({id:`follow-up-completed:${j.id}`,kind:"follow_up_completed",title:o("shell.globalNotificationFollowUpCompletedTitle",{title:N}),body:((w=j.lastAutomationSummary)==null?void 0:w.trim())||j.objective,routePath:Yn(j.workspaceId,j.sessionId),workspaceId:j.workspaceId,createdAt:D});continue}j.status==="failed"&&i.push({id:`follow-up-failed:${j.id}`,kind:"follow_up_failed",title:o("shell.globalNotificationFollowUpFailedTitle",{title:N}),body:((k=j.lastAutomationSummary)==null?void 0:k.trim())||((y=j.waitingReason)==null?void 0:y.trim())||j.objective,routePath:Yn(j.workspaceId,j.sessionId),workspaceId:j.workspaceId,createdAt:D})}for(const j of e.verifications){if(j.status!=="failed")continue;const N=j.projectId?s.get(j.projectId)??null:null,D=((C=j.targetRef)==null?void 0:C.trim())||j.verificationType;i.push({id:`verification-failed:${j.id}`,kind:"verification_failed",title:o("shell.globalNotificationVerificationFailedTitle",{title:D}),body:((T=j.summary)==null?void 0:T.trim())||o("shell.globalNotificationVerificationFailedFallback"),routePath:N?Ui(N):null,workspaceId:N,createdAt:j.finishedAt||j.startedAt||j.createdAt})}return i.sort((j,N)=>{const D=Jx(j.kind)-Jx(N.kind);return D!==0?D:Wa(N.createdAt)-Wa(j.createdAt)}).slice(0,LO)}function Jx(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function qO(e){switch(e){case"follow_up_waiting_user":return o("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return o("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return o("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return o("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return o("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return o("shell.globalNotificationKindVerificationFailed");default:return o("shell.globalNotificationsPanelTitle")}}function Wa(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function $O(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function VO(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function GO(e,t){const r=new Set,s=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((d,m)=>Number(m.current)-Number(d.current)||d.name.localeCompare(m.name)).map(d=>({value:d.name,current:d.current,recommended:d.name===s})).filter(d=>!d.value||r.has(d.value)?!1:(r.add(d.value),!0)),l=((e==null?void 0:e.remote)??[]).map(d=>({value:d.name})).filter(d=>!d.value||r.has(d.value)?!1:(r.add(d.value),!0)),c=t.map(d=>({value:d.name})).filter(d=>!d.value||r.has(d.value)?!1:(r.add(d.value),!0));return{localBranches:i,remoteBranches:l,tags:c}}function KO(e){return e.getBoundingClientRect()}function YO(e,t){return t?Wa(e.createdAt)>Wa(t):!0}function XO(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Zx(e,t){var c,d;const r=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const m of r){const f=Ir(m,e),v=(c=f==null?void 0:f.params.workspaceId)==null?void 0:c.trim();if(v)return v}const s=Uc(e),i=(s==null?void 0:s.sessionId)??null;return!i||!gD(i)?null:((d=new URLSearchParams(t).get("workspaceId"))==null?void 0:d.trim())||null}function QO(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function JO(e){return e==="mobile"?Ts():"/landing"}function Uc(e){var l,c,d;const t=Ir("/workspaces/:workspaceId/sessions/:sessionId",e),r=(l=t==null?void 0:t.params.sessionId)==null?void 0:l.trim();if(r)return{sessionId:r,workspaceId:((c=t==null?void 0:t.params.workspaceId)==null?void 0:c.trim())??null};const s=Ir("/sessions/:sessionId",e),i=(d=s==null?void 0:s.params.sessionId)==null?void 0:d.trim();return i?{sessionId:i,workspaceId:null}:null}function ZO(e){return!!(Ir("/sessions",e)||Ir("/workspaces/:workspaceId/sessions",e))}function eS(e){return!!Uc(e)}function e2(e){return!!(Ir("/tools",e)||Ir("/tools/files",e)||Ir("/tools/git",e)||Ir("/tools/processes",e)||Ir("/workspaces/:workspaceId/tools",e)||Ir("/workspaces/:workspaceId/tools/files",e)||Ir("/workspaces/:workspaceId/tools/git",e)||Ir("/workspaces/:workspaceId/tools/processes",e))}function tS(e){return!!(Ir("/terminals",e)||Ir("/workspaces/:workspaceId/terminals",e))}function kf(e){return!!Ir("/workspaces/:workspaceId/butler",e)}function t2(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const n2=p.lazy(async()=>({default:(await Ml(()=>Promise.resolve().then(()=>s8),void 0)).FileContextPanel})),r2=p.lazy(async()=>({default:(await Ml(()=>Promise.resolve().then(()=>w8),void 0)).GitSidebar})),s2=p.lazy(async()=>({default:(await Ml(()=>Promise.resolve().then(()=>PG),void 0)).TerminalManagerPanel}));function i2(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function wi(e){return zi(e)}function a2(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Ic(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(i2):[]}async function zP(e,t){const r=await _l(t,e);if(r.canStartSession===!1)throw new Error(r.limitations[0]??o("conversation.capabilityDenied"))}const qP=p.createContext(null);function Qg(e){return qi(e)}function Hi(e){return e.isArchived===!0}function gm(e){var t;return((t=e.parentSessionId)==null?void 0:t.trim())||null}function Mv(e,t){return RN(e,{getId:r=>r.sessionId,getParentId:gm,compare:(r,s)=>Nv(r,s,t)})}function $P(e){return e.filter(t=>{if(Hi(t))return!1;const r=gm(t);if(!r)return!0;const s=e.find(i=>i.sessionId===r);return!s||!Hi(s)})}function o2(e){return e.flatMap(t=>{const r=a2(t);return r?[r,...MN(wi(t))]:[]})}function l2(e,t,r){const s=new Set(ii(wi(e)).sort((i,l)=>Nv(i.item,l.item,r)).slice(0,t).map(i=>i.item.sessionId));return{...e,children:VP(wi(e),s)}}function VP(e,t){return e.flatMap(r=>{const s=VP(wi(r),t);return!t.has(r.item.sessionId)&&s.length===0?[]:[{...r,children:s}]})}function Ld(e,t,r,s=-1){if(e<=0)return 0;const i=s>=0?Math.max(t,s+1):t;return Math.min(e,Math.max(r??0,i))}function nS(e,t){const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>e[i]===t[i])}function c2(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function u2(e){return Su(e)||e.syncStatus==="error"}function d2(e){var s,i;if(!u2(e))return null;const t=((s=e.lastErrorCode)==null?void 0:s.trim())??"",r=((i=e.lastErrorDetail)==null?void 0:i.replace(/\s+/g," ").trim())??"";return t&&r&&!r.includes(t)?`${t} · ${r}`:r||t||(e.syncStatus==="error"&&!Su(e)?o("conversation.syncStatusError"):o("conversation.runtimeErrorTitle"))}function h2(e,t=110){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function bm(e,t="compact"){return qs(e,t)}const m2={position:"relative",zIndex:0},p2={zIndex:1};function GP(e,t,r,s){const i=[],l=(s==null?void 0:s.trim())||t.name;r&&i.push(l);const c=c2(e);return c&&i.push(c),i.join(" · ")||l}function rS(e,t){return Cv("session-state-indicator",e,t)}function f2(e,t){return xP(e,t)}function sS(e,t){try{const r=window.localStorage.getItem(e),s=r?Number(r):Number.NaN;return Number.isFinite(s)?s:t}catch{return t}}function iS(e,t){try{const r=window.localStorage.getItem(e);return r===null?t:r==="true"}catch{return t}}function aS(e){var t;try{const r=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return r||null}catch{return null}}function mo(e,t){try{window.localStorage.setItem(e,t)}catch{}}function g2(e){try{window.localStorage.removeItem(e)}catch{}}function Fd(e,t,r){return Math.max(t,Math.min(r,e))}function b2(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function v2(){typeof window>"u"||window.dispatchEvent(new CustomEvent(OO))}function KP(e,t){const r=t==null?void 0:t.trim();if(!r)return null;for(const s of e){if(s.workspace.id===r)return s;const i=KP(s.children,r);if(i)return i}return null}function w2(e,t){const r=t==null?void 0:t.trim();if(!r)return null;for(const s of e){const i=KP(s.childWorktrees,r);if(i)return i}return null}function oS(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var r;return t.collapsed===!0&&((r=t.workspace)==null?void 0:r.id)}).map(t=>t.workspace.id)}function xf(e,t){const r=new Set(t);return{items:e.map(s=>({workspace:s.workspace,sessions:s.sessions,childWorktrees:s.childWorktrees,collapsed:r.has(s.workspace.id)}))}}function YP(e,t,r){return e.map(s=>{const i=$P(s.sessions);return{workspace:s.workspace,meta:s.meta,visibleSessions:i,archivedSessions:s.sessions.filter(l=>Hi(l)&&!gm(l)),visibleSessionTree:Mv(i,r).filter(l=>!t.has(l.item.sessionId)&&!lm(wi(l),c=>t.has(c.sessionId))),children:YP(s.children,t,r)}})}function Jg(e){return e.flatMap(t=>[t.workspace.id,...Jg(t.children)])}function Ec(e){return e.flatMap(t=>[...t.visibleSessionTree,...Ec(t.children)])}function y2(e,t){if(!t)return null;for(const r of e){if(r.workspace.id===t)return{workspace:r.workspace,visibleSessionTree:Ic(r)};const s=QP(r.childWorktrees,t);if(s)return s}return null}function XP(e,t){for(const r of e){const s=ii(r.visibleSessionTree).find(l=>l.item.sessionId===t);if(s)return s;const i=XP(r.children,t);if(i)return i}return null}function QP(e,t){for(const r of e){if(r.workspace.id===t)return{workspace:r.workspace,visibleSessionTree:r.visibleSessionTree};const s=QP(r.children,t);if(s)return s}return null}function k2(e,t){if(!t)return null;for(const r of e){if(r.workspace.id===t)return{workspace:r.workspace,archivedSessions:r.archivedSessions};const s=JP(r.childWorktrees,t);if(s)return s}return null}function lS(e,t){if(!t)return null;for(const r of e){if(r.workspace.id===t)return r.workspace;const s=ZP(r.childWorktrees,t);if(s)return s}return null}function JP(e,t){for(const r of e){if(r.workspace.id===t)return{workspace:r.workspace,archivedSessions:r.archivedSessions};const s=JP(r.children,t);if(s)return s}return null}function ZP(e,t){for(const r of e){if(r.workspace.id===t)return r.workspace;const s=ZP(r.children,t);if(s)return s}return null}function eD(e,t){for(const r of e){if(r.workspace.id===t)return[r.workspace.id];const s=eD(r.children,t);if(s.length>0)return[r.workspace.id,...s]}return[]}function cS(e){return e.flatMap(t=>[t.workspace.id,...tD(t.childWorktrees)])}function tD(e){return e.flatMap(t=>[t.workspace.id,...tD(t.children)])}function x2(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const r=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&r.push(e.parentDisplayName),r.join(" / ")}function S2(e,t,r,s){if(t===r)return e;const i=e.findIndex(f=>f.workspace.id===t),l=e.findIndex(f=>f.workspace.id===r);if(i<0||l<0)return e;const c=[...e],[d]=c.splice(i,1);if(!d)return e;const m=c.findIndex(f=>f.workspace.id===r);return m<0?e:(c.splice(s==="before"?m:m+1,0,d),c.every((f,v)=>{var g;return f.workspace.id===((g=e[v])==null?void 0:g.workspace.id)})?e:c)}function C2(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let r=!1;const s=e.items.map(i=>{let l=!1;const c=i.sessions.map(m=>{const f=t.get(m.sessionId);return f===void 0||Hi(m)===f?m:(r=!0,l=!0,{...m,isArchived:f})}),d=rD(i.childWorktrees??[],t,m=>{m&&(r=!0,l=!0)});return l?{...i,sessions:c,childWorktrees:d}:i});return r?{...e,items:s}:e}function j2(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const r of t.items){for(const s of r.sessions){const i=e.get(s.sessionId);i!==void 0&&Hi(s)===i&&e.delete(s.sessionId)}sD(e,r.childWorktrees??[])}}function T2(e,t,r){let s=!1;const i=e.map(l=>{if(l.workspace.id!==t.workspaceId){const{nodes:m,changed:f}=iD(l.childWorktrees,t,r);return f?(s=!0,{...l,childWorktrees:m}):l}const c=l.sessions.findIndex(m=>m.sessionId===t.sessionId),d=c>=0?l.sessions.map((m,f)=>f===c?t:m):[t,...l.sessions];return s=!0,{...l,sessions:ju(d,r)}});return s?i:e}function N2(e,t,r){let s=!1;const i=e.map(l=>{let c=!1;const d=l.sessions.map(f=>f.sessionId!==t?f:(s=!0,c=!0,{...f,lastSeenAt:f.lastSeenAt&&f.lastSeenAt>r?f.lastSeenAt:r,activityState:f.activityState==="completed_unread"?"idle":f.activityState})),m=vm(l.childWorktrees,f=>f.sessionId!==t?f:(s=!0,c=!0,{...f,lastSeenAt:f.lastSeenAt&&f.lastSeenAt>r?f.lastSeenAt:r,activityState:f.activityState==="completed_unread"?"idle":f.activityState}));return c?{...l,sessions:d,childWorktrees:m}:l});return s?i:e}function uS(e,t,r){let s=!1;const i=e.map(l=>{let c=!1;const d=l.sessions.map(f=>f.sessionId!==t||f.isArchived===r?f:(s=!0,c=!0,{...f,isArchived:r})),m=vm(l.childWorktrees,f=>f.sessionId!==t||f.isArchived===r?f:(s=!0,c=!0,{...f,isArchived:r}));return c?{...l,sessions:d,childWorktrees:m}:l});return s?i:e}function dS(e,t,r){let s=!1;const i=e.map(l=>{let c=!1;const d=l.sessions.map(f=>f.sessionId!==t||f.isFavorite===!0===r?f:(s=!0,c=!0,{...f,isFavorite:r})),m=vm(l.childWorktrees,f=>f.sessionId!==t||f.isFavorite===!0===r?f:(s=!0,c=!0,{...f,isFavorite:r}));return c?{...l,sessions:d,childWorktrees:m}:l});return s?i:e}function P2(e,t){return e.includes(t)?e.filter(r=>r!==t):[...e,t]}function D2(e){return e?e.slice(0,8):"--"}function hS(e,t,r){return r?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(s=>s!==t):e}function nD(e,t){const r=e.filter(s=>t.has(s));return r.length===e.length?e:r}function rD(e,t,r){return e.map(s=>{let i=!1;const l=s.sessions.map(d=>{const m=t.get(d.sessionId);return m===void 0||Hi(d)===m?d:(i=!0,{...d,isArchived:m})}),c=rD(s.children,t,d=>{d&&(i=!0)});return r(i),i?{...s,sessions:l,children:c}:s})}function sD(e,t){for(const r of t){for(const s of r.sessions){const i=e.get(s.sessionId);i!==void 0&&Hi(s)===i&&e.delete(s.sessionId)}sD(e,r.children)}}function iD(e,t,r){let s=!1;const i=e.map(l=>{if(l.workspace.id===t.workspaceId){const d=l.sessions.findIndex(f=>f.sessionId===t.sessionId),m=d>=0?l.sessions.map((f,v)=>v===d?t:f):[t,...l.sessions];return s=!0,{...l,sessions:ju(m,r)}}const c=iD(l.children,t,r);return c.changed?(s=!0,{...l,children:c.nodes}):l});return{nodes:s?i:[...e],changed:s}}function R2(e,t){return e.map(r=>({...r,sessions:ju(r.sessions,t),childWorktrees:Pv(r.childWorktrees,t)}))}function vm(e,t){let r=!1;const s=e.map(i=>{let l=!1;const c=i.sessions.map(m=>{const f=t(m);return f!==m&&(l=!0,r=!0),f}),d=vm(i.children,t);return d!==i.children&&(l=!0,r=!0),l?{...i,sessions:c,children:d}:i});return r?s:[...e]}function Zg(e){return`workspace-management.summary.${e}`}function aD(e){return`git-sidebar.snapshot.${e}`}function oD(e,t){const r=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!r,repoRoot:r,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function lD(e,t){const r=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!r,repoRoot:r}}}function cD(e,t){var i,l,c;const r=((i=t.status)==null?void 0:i.snapshot.repoRoot)??e.git.repoRoot,s=((l=t.status)==null?void 0:l.snapshot.branch)??((c=t.branches)==null?void 0:c.currentBranch)??e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:e.git.isRepository||!!r,repoRoot:r,currentBranch:s,error:null}}}function uD({count:e,className:t="workbench-skeleton-lines"}){return n.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(r,s)=>n.jsx("span",{className:"skeleton-line"},s))})}function M2(){return n.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>n.jsxs("section",{className:"workbench-skeleton-card",children:[n.jsxs("div",{className:"workbench-skeleton-heading",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx("span",{className:"skeleton-line tiny"})]}),n.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(r,s)=>n.jsxs("div",{className:"workbench-skeleton-session",children:[n.jsx("span",{className:"workbench-skeleton-dot"}),n.jsx(uD,{count:2,className:"workbench-skeleton-lines compact"})]},s))})]},t))})}function _d(){return n.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>n.jsxs("article",{className:"workbench-info-skeleton-card",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx(uD,{count:3})]},t))})}function A2({side:e,collapsed:t}){const r=e==="left"?8.5:15.5,s=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:r,y1:"4",x2:r,y2:"20"}),n.jsx("polyline",{points:s})]})}function mS({ariaLabel:e,side:t,collapsed:r,className:s="panel-icon-button",onClick:i}){return n.jsx("button",{className:s,type:"button","aria-label":e,title:e,onClick:i,children:n.jsx(A2,{side:t,collapsed:r})})}function Lc({expanded:e}){return n.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"6 9 12 15 18 9"})})}function I2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"7 10 12 15 17 10"}),n.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function E2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),n.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),n.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),n.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function L2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function dD(e){return n.jsx("div",{className:"workbench-notification-anchor",children:n.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":o("shell.globalNotificationsAction"),title:o("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[n.jsx(L2,{}),e.unreadCount>0?n.jsx("span",{className:"workbench-notification-badge","aria-label":o("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function F2(e){const[t,r]=p.useState("notifications");p.useEffect(()=>{e.open&&r("notifications")},[e.open]);const s=p.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return n.jsxs(Ln,{open:e.open,title:o("shell.globalNotificationsPanelTitle"),description:o("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[n.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":o("shell.globalNotificationsPanelTitle"),children:[n.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>r("notifications"),children:o("shell.globalNotificationsAction")}),n.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>r("inbox"),children:o("shell.butlerInboxAction")})]}),n.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?n.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":o("shell.globalNotificationsAction"),children:[n.jsx("div",{className:"workbench-notification-toolbar",children:n.jsxs("label",{className:"workbench-notification-filter",children:[n.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),n.jsx("span",{children:o("shell.globalNotificationsShowArchived")})]})}),s.length>0?n.jsx("div",{className:"workbench-notification-list",children:s.map(i=>{const l=e.archivedNotificationIds.has(i.id);return n.jsxs("article",{className:"workbench-notification-item","data-archived":l,children:[n.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[n.jsx("span",{className:"workbench-notification-item-kind",children:qO(i.kind)}),n.jsx("strong",{children:i.title}),n.jsx("p",{children:i.body})]}),n.jsxs("div",{className:"workbench-notification-item-side",children:[n.jsx("time",{children:XO(i.createdAt)}),n.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(l){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:o(l?"shell.globalNotificationsRemoveArchiveAction":"shell.globalNotificationsArchiveAction")})]})]},i.id)})}):n.jsx("p",{className:"workbench-notification-empty",children:o("shell.globalNotificationsEmpty")})]}):n.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":o("shell.butlerInboxAction"),children:n.jsx(UP,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),n.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:n.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:o("common.close")})})]})}function _2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function O2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"11",cy:"11",r:"7"}),n.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function B2(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function W2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("path",{d:"M7 9l3 3-3 3"}),n.jsx("path",{d:"M13 15h4"})]})}function U2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),n.jsx("circle",{cx:"9",cy:"11",r:"1"}),n.jsx("circle",{cx:"15",cy:"11",r:"1"}),n.jsx("path",{d:"M8 15h8"}),n.jsx("path",{d:"M12 5V3"})]})}function hD(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}function mD(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}function pD(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),n.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function H2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"18",cy:"6",r:"3"}),n.jsx("circle",{cx:"6",cy:"6",r:"3"}),n.jsx("circle",{cx:"18",cy:"18",r:"3"}),n.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),n.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function z2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function q2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),n.jsx("path",{d:"M14 16l2 2 4-4"})]})}function $2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),n.jsx("path",{d:"M10 12h8"}),n.jsx("path",{d:"M15 8l4 4-4 4"})]})}function V2({selected:e}){return e?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),n.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function fD({active:e,className:t}){return e?n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function G2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 7h18"}),n.jsx("path",{d:"M5 7l1 12h12l1-12"}),n.jsx("path",{d:"M9 11h6"}),n.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function K2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M12 20h9"}),n.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function Y2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M9 13h6"})]})}function X2(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),n.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function Q2({open:e,mode:t,keyword:r,codeWorkspaceId:s,codeResults:i,codeLoading:l,codeError:c,workspaceOptions:d,sessionResults:m,onClose:f,onModeChange:v,onKeywordChange:g,onCodeWorkspaceChange:w,onCodeSearch:k,onOpenSession:y}){const C=r.trim().length>0&&s.trim().length>0;return n.jsx(Ln,{open:e,title:o("shell.searchModalTitle"),description:o("shell.searchModalDescription"),onClose:f,children:n.jsxs("div",{className:"workbench-search-modal",children:[n.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":o("shell.searchModeLabel"),children:[n.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>v("sessions"),children:o("shell.searchModeSessions")}),n.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>v("code"),children:o("shell.searchModeCode")})]}),t==="sessions"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:r,placeholder:o("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:T=>g(T.target.value)})]}),n.jsx("div",{className:"workbench-search-results",children:r.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:o("shell.searchSessionHint")}):m.length>0?m.map(T=>{const j=$i(T.session.title,o("common.unknown"));return n.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>y(T.session.sessionId),children:[n.jsx("span",{className:"workbench-search-result-title",title:j.fullTitle,children:j.displayTitle}),n.jsxs("span",{className:"workbench-search-result-meta",children:[T.workspace.name," · ",bm(T.session.provider,"full")]})]},T.session.sessionId)}):n.jsx("p",{className:"workbench-search-empty",children:o("shell.searchSessionEmpty")})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.searchWorkspaceLabel")}),n.jsx("select",{value:s,onChange:T=>w(T.target.value),children:d.map(T=>n.jsx("option",{value:T.id,children:T.name},T.id))})]}),n.jsxs("form",{className:"workbench-search-code-form",onSubmit:T=>{T.preventDefault(),k()},children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:r,placeholder:o("shell.searchCodePlaceholder"),autoFocus:!0,onChange:T=>g(T.target.value)})]}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!C||l,children:o(l?"common.loading":"shell.searchSubmit")})]}),n.jsxs("div",{className:"workbench-search-results",children:[c?n.jsx("p",{className:"status-text","data-tone":"error",children:c}):null,!c&&r.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:o("shell.searchCodeHint")}):null,!c&&r.trim().length>0&&!l&&i.length===0?n.jsx("p",{className:"workbench-search-empty",children:o("shell.searchCodeEmpty")}):null,i.map(T=>n.jsxs("div",{className:"workbench-search-result-item static",children:[n.jsx("span",{className:"workbench-search-result-title",children:T.name}),n.jsx("span",{className:"workbench-search-result-meta",children:T.path})]},`${T.path}-${T.kind}`))]})]})]})})}function J2({menuKey:e,session:t,workspace:r,workspaceContext:s,isActive:i,isFavorite:l,menuOpen:c,menuAnchorPoint:d,showWorkspaceName:m,depth:f=0,showActions:v=!0,hasSubagents:g=!1,subagentListExpanded:w=!1,selectionMode:k=!1,selected:y=!1,onToggleSelect:C,onToggleSubagents:T,onOpen:j,onRename:N,onOpenContextMenu:D,onToggleFavorite:F,onArchive:W,onCloseMenu:E}){var U;const I=nr(),M=Qg(t)?((U=t.subagentLabel)==null?void 0:U.trim())||o("shell.subagentBadge"):null,_=$i(t.title,o("common.unknown")),L=d2(t),Q=L?h2(L):null,O=eu(t),ne=O?SP("session-activity-badge",t):null,Y=Cu(t),G=jv(t),te=p.useRef(null),[K,z]=p.useState(null);p.useLayoutEffect(()=>{if(I.isDesktop||!c||!d||typeof window>"u"){z(null);return}const X=()=>{var Se,se;const R=PP(d,{width:((Se=te.current)==null?void 0:Se.offsetWidth)??0,height:((se=te.current)==null?void 0:se.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:168});z({position:"fixed",top:`${Math.round(R.top)}px`,left:`${Math.round(R.left)}px`,width:`${Math.round(R.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(R.maxHeight)}px`,transformOrigin:R.transformOrigin})};return X(),window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[d,c,I.isDesktop]);async function q(){await bv([{id:`rename:${t.sessionId}`,label:o("shell.renameAction"),onSelect:N},{id:`favorite:${t.sessionId}`,label:o(l?"shell.unfavoriteAction":"shell.favoriteAction"),onSelect:F},{id:`archive:${t.sessionId}`,label:o("shell.archiveAction"),onSelect:W}])}const P=!I.isDesktop&&c&&typeof document<"u"?$n.createPortal(n.jsxs("div",{ref:te,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":o("shell.sessionMoreAction"),onClick:X=>X.stopPropagation(),style:K??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{N(),E()},children:[n.jsx(K2,{}),n.jsx("span",{children:o("shell.renameAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{F(),E()},children:[n.jsx(fD,{active:l}),n.jsx("span",{children:o(l?"shell.unfavoriteAction":"shell.favoriteAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{W(),E()},children:[n.jsx(G2,{}),n.jsx("span",{children:o("shell.archiveAction")})]})]}),document.body):null;return n.jsxs("article",{className:"workbench-session-card","data-active":i,"data-depth":f,"data-subagent":Qg(t),"data-workspace-tone":s.tone,"data-worktree-depth":s.depth,"data-has-subagents":g,"data-selecting":k,"data-selected":y,style:ri(s),onContextMenu:X=>{if(!(k||!v||!D)){if(X.preventDefault(),X.stopPropagation(),I.isDesktop){q();return}D({x:X.clientX,y:X.clientY})}},children:[n.jsxs("div",{className:"workbench-session-main",children:[k?n.jsx("span",{className:"workbench-session-selection-indicator","data-selected":y,"aria-hidden":"true",children:n.jsx(V2,{selected:y})}):g?n.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:p2,"data-indicator-variant":f2(t,{hasSubagents:!0,isActive:i}),"aria-label":o(w?"shell.subagentCollapse":"shell.subagentExpand"),title:o(w?"shell.subagentCollapse":"shell.subagentExpand"),"aria-expanded":w,onClick:X=>{X.stopPropagation(),T==null||T()},children:[n.jsx("span",{className:rS(t,{hasSubagents:!0,isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:n.jsx(Lc,{expanded:w})})]}):n.jsx("span",{className:rS(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("button",{type:"button",className:"workbench-session-link",style:g?m2:void 0,"data-active":i,"aria-pressed":k?y:void 0,onClick:k?C:j,onKeyDown:X=>{if(k||!v||!D||X.key!=="ContextMenu"&&!(X.shiftKey&&X.key==="F10"))return;if(X.preventDefault(),X.stopPropagation(),I.isDesktop){q();return}const R=X.currentTarget.getBoundingClientRect();D({x:R.right,y:R.bottom})},children:n.jsxs("div",{className:"workbench-session-link-copy",children:[n.jsxs("div",{className:"session-title-row",children:[n.jsx("span",{className:"session-title",title:_.fullTitle,children:_.displayTitle}),M?n.jsx("span",{className:"session-subagent-badge",children:M}):null,G&&Y?n.jsx("span",{className:`session-fork-badge ${Y}`,children:G}):null]}),n.jsxs("div",{className:"session-meta-row",children:[n.jsx("span",{className:"session-meta",children:GP(t,r,m,s.displayName)}),O&&ne?n.jsx("span",{className:ne,children:O}):null,n.jsx("span",{className:`session-provider-badge ${t.provider}`,children:bm(t.provider)})]}),Q?n.jsx("div",{className:"session-error-row",title:L??void 0,children:n.jsx("span",{className:"session-error-text",children:Q})}):null]})})]}),P]})}function pS({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:r,favoriteSessions:s,favoriteSessionIds:i,activeWorkspaceId:l,isConversationActive:c,isTerminalActive:d,isButlerActive:m,isSearchOpen:f,navigationLoading:v,navigationError:g,activeSessionId:w,onRefreshNavigation:k,onSessionUpdated:y,onNavigateConversation:C,onNavigateTerminals:T,onNavigateButler:j,onOpenSearch:N,onOpenSettings:D,onSelectWorkspace:F,onToggleWorkspaceCollapse:W,onStartWorkspaceReorder:E,onPreviewWorkspaceReorder:I,onCommitWorkspaceReorder:M,allowWorkspaceReorder:_,subscribeGitSnapshot:L,requestGitRefresh:Q,subscribeWorkspaceManagementSnapshot:O,requestWorkspaceManagementRefresh:ne,onToggleFavoriteSession:Y,onArchiveSession:G,onUnarchiveSession:te,workspaceManagementStateById:K,setWorkspaceManagementStateById:z,unreadNotificationCount:q,notificationPanelOpen:P,onToggleNotificationPanel:U,onClose:X,onToggleCollapse:R}){const Se=vr(),se=nr(),{showToast:J}=Qn(),Ne=p.useCallback(H=>{!se.isDesktop||se.ui.osFamily!=="macos"||H.button!==0||cv(H.target)&&uv()},[se.isDesktop,se.ui.osFamily]),[Ee,ie]=p.useState(!1),[xe,lt]=p.useState(!1),[Oe,bt]=p.useState(!1),[Ct,nt]=p.useState([]),[et,De]=p.useState(null),[Ue,Ye]=p.useState(null),[ye,He]=p.useState(null),[je,Fe]=p.useState(null),[Ve,kt]=p.useState(null),[me,Me]=p.useState(null),[Xe,ze]=p.useState(!1),[vt,ht]=p.useState(!1),[pe,$e]=p.useState(""),[Nt,Rt]=p.useState(""),[Ft,Wt]=p.useState(""),[Kt,un]=p.useState({localBranches:[],remoteBranches:[],tags:[]}),[ae,Be]=p.useState(!1),[It,jt]=p.useState(-1),[Cn,on]=p.useState(!1),[Wn,Rn]=p.useState(!1),[$t,dn]=p.useState(null),[gn,Z]=p.useState(null),[ce,ge]=p.useState(null),[Ce,We]=p.useState(null),[qe,Pt]=p.useState(null),[Ke,at]=p.useState(null),[ft,ct]=p.useState(yf),[oe,Re]=p.useState({}),[_t,Ut]=p.useState({}),[Qt,ln]=p.useState([]),[jn,Jn]=p.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[bn,Jt]=p.useState(null),[ur,vn]=p.useState(""),[yn,kn]=p.useState(null),[Nn,xt]=p.useState(null),[Zt,we]=p.useState([]),[Ge,St]=p.useState(!1),[Sn,_n]=p.useState({}),[Vn,zn]=p.useState(null),rr=p.useRef(null),Gn=p.useRef(null),xr=p.useRef(null),Kr=p.useRef(new Map),Yr=p.useRef(null),Xr=p.useRef(null),Lr=p.useRef(null),es=p.useMemo(()=>new Set(jn.expandedWorkspaceIds),[jn.expandedWorkspaceIds]),sr=p.useMemo(()=>new Set(jn.collapsedWorkspaceIds),[jn.collapsedWorkspaceIds]),Hr=Vn!==null,dr=_&&se.isDesktop&&se.ui.osFamily==="macos",wt=p.useCallback(()=>{Pt(null),at(null)},[]),ir=p.useCallback((H,de)=>{Pt(H),at(de)},[]),tn=lS(e,Ve)??((me==null?void 0:me.id)===Ve?me:null),hr=Ft.trim().toLowerCase(),ar=p.useMemo(()=>[{key:"localBranches",label:o("shell.createWorktreeBaseRefLocalGroup"),items:Kt.localBranches},{key:"remoteBranches",label:o("shell.createWorktreeBaseRefRemoteGroup"),items:Kt.remoteBranches},{key:"tags",label:o("shell.createWorktreeBaseRefTagGroup"),items:Kt.tags}].map(de=>({...de,items:de.items.filter(Ae=>hr?Ae.value.toLowerCase().includes(hr):!0)})).filter(de=>de.items.length>0),[hr,Kt]),ue=p.useMemo(()=>ar.flatMap(H=>H.items),[ar]),Qe=tn?`create-worktree-base-ref-listbox-${tn.id}`:"create-worktree-base-ref-listbox",yt=k2(e,Ce),Lt=yt?Vs(yt.workspace):null,fn=p.useMemo(()=>y2(e,Nn),[Nn,e]),mn=p.useMemo(()=>fn?o2(fn.visibleSessionTree):[],[fn]),nn=p.useMemo(()=>mn.map(H=>H.sessionId),[mn]),Un=p.useMemo(()=>new Set(nn),[nn]),Fr=p.useMemo(()=>new Set(Zt),[Zt]),zr=nn.length>0&&Zt.length===nn.length;p.useEffect(()=>{z(H=>{const de=cS(e),Ae=new Set(de),dt={};Object.entries(H).forEach(([zt,B])=>{Ae.has(zt)&&(dt[zt]=B)}),de.forEach(zt=>{const B=lS(e,zt);if(!B)return;const re=Er(Zg(zt),Yx),Te=Er(aD(zt),Yx),Je=dt[zt];let Dt=lD((Je==null?void 0:Je.detail)??re??oD(B),B);(Te!=null&&Te.status||Te!=null&&Te.branches)&&(Dt=cD(Dt,{status:Te.status??null,branches:Te.branches??null})),dt[zt]={detail:Dt,loading:!1,error:null}});const mt=Object.keys(H),pn=Object.keys(dt);return mt.length===pn.length&&pn.every(zt=>H[zt]===dt[zt])?H:dt})},[e]);const Xt=p.useCallback(async H=>{await k(),await se.bridge.showNotification(o("shell.importSuccess"),H.path)},[k,se.bridge]),Cr=p.useCallback(async H=>{await k(),await se.bridge.showNotification(o("shell.cloneSuccess"),H.path)},[k,se.bridge]);function V(H){if(Ct.includes(H)){nt(Ae=>Ae.filter(dt=>dt!==H));return}nt(Ae=>[...Ae,H]),L(H),Q(H),O(H),ne(H)}async function fe(H,de){if(Sn[H])return;const Ae=(de==null?void 0:de.trim().toUpperCase())??null;_n(dt=>({...dt,[H]:!0}));try{await iP(H,{backgroundColor:Ae}),await k()}catch(dt){J({title:dt instanceof Error?dt.message:o("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{_n(dt=>({...dt,[H]:!1}))}}async function ve(){if(!(!et||Ue)){Ye(et.id);try{await sP(et.id),nt(H=>H.filter(de=>de!==et.id)),z(H=>{const de={...H};return delete de[et.id],de}),De(null),await k(),J({title:o("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(H){J({title:H instanceof Error?H.message:o("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{Ye(null)}}}p.useEffect(()=>{if(!qe)return;function H(de){const Ae=de.target;Ae instanceof HTMLElement&&Ae.closest(".workbench-session-menu")||wt()}return window.addEventListener("pointerdown",H),()=>{window.removeEventListener("pointerdown",H)}},[wt,qe]),p.useEffect(()=>{if(!Nn){Zt.length>0&&we([]);return}if(!fn){xt(null),we([]);return}we(H=>nD(H,Un))},[fn,Un,Nn,Zt.length]),p.useEffect(()=>{Nn&&nn.length===0&&(xt(null),we([]))},[nn.length,Nn]),p.useEffect(()=>{const H=new Set(cS(e)),de=new Set(e.flatMap(Ae=>Jg(Ae.childWorktrees)));nt(Ae=>Ae.filter(dt=>H.has(dt))),Jn(Ae=>({expandedWorkspaceIds:Ae.expandedWorkspaceIds.filter(dt=>de.has(dt)),collapsedWorkspaceIds:Ae.collapsedWorkspaceIds.filter(dt=>de.has(dt))})),De(Ae=>Ae&&H.has(Ae.id)?Ae:null),_n(Ae=>Object.fromEntries(Object.entries(Ae).filter(([dt,mt])=>mt&&H.has(dt))))},[e]),p.useEffect(()=>{const H=s.findIndex(de=>de.session.sessionId===w);ct(de=>{const Ae=Ld(s.length,yf,de,H);return Ae===de?de:Ae})},[w,s]),p.useEffect(()=>{Re(H=>{const de={};for(const Ae of e){const dt=Ic(Ae),mt=dt.findIndex(pn=>pn.item.sessionId===w||la([pn],w??"",zt=>zt.sessionId).length>0);de[Ae.workspace.id]=Ld(dt.length,vc,H[Ae.workspace.id],mt);for(const pn of Ec(Ae.childWorktrees)){pn.item.sessionId===w||la([pn],w??"",Te=>Te.sessionId).length>0;const zt=pn.item.workspaceId;if(de[zt]!==void 0)continue;const B=Ec(Ae.childWorktrees).filter(Te=>Te.item.workspaceId===zt&&Te.depth===0),re=B.findIndex(Te=>Te.item.sessionId===w||la([Te],w??"",Je=>Je.sessionId).length>0);de[zt]=Ld(B.length,vc,H[zt],re)}}return nS(H,de)?H:de})},[w,e]),p.useEffect(()=>{Ut(H=>{const de={};for(const Ae of e)for(const dt of[...Ic(Ae),...Ec(Ae.childWorktrees)])for(const mt of ii(wi(dt))){const pn=wi(mt);if(pn.length===0)continue;const zt=ii(pn),B=zt.findIndex(re=>re.item.sessionId===w);de[mt.item.sessionId]=Ld(zt.length,Ed,H[mt.item.sessionId],B)}return nS(H,de)?H:de})},[w,e]),p.useEffect(()=>{if(!w)return;const H=e.flatMap(de=>[...la(Ic(de),w,Ae=>Ae.sessionId),...Ec(de.childWorktrees).flatMap(Ae=>la([Ae],w,dt=>dt.sessionId))]);H.length!==0&&ln(de=>{const Ae=new Set(de);let dt=!1;for(const mt of H)Ae.has(mt)||(Ae.add(mt),dt=!0);return dt?Array.from(Ae):de})},[w,e]),p.useEffect(()=>{if(!l)return;const H=[];for(const de of e){const Ae=eD(de.childWorktrees,l);Ae.length!==0&&H.push(...Ae)}H.length>0&&Jn(de=>{const Ae=new Set(de.expandedWorkspaceIds);let dt=!1;for(const mt of H)Ae.has(mt)||(Ae.add(mt),dt=!0);return dt?{expandedWorkspaceIds:Array.from(Ae),collapsedWorkspaceIds:de.collapsedWorkspaceIds}:de})},[l,e]),p.useEffect(()=>{if(!Ve){Me(null),ze(!1),ht(!1),$e(""),Rt(""),Wt(""),Be(!1),jt(-1),on(!1),un({localBranches:[],remoteBranches:[],tags:[]}),Rn(!1),dn(null);return}ze(!1),$e(""),Rt(""),Wt(""),Be(!1),jt(-1),on(!1),un({localBranches:[],remoteBranches:[],tags:[]}),Rn(!1),dn(null)},[Ve]),p.useEffect(()=>{const H=tn;if(!Xe||!H)return;let de=!1;const Ae=H.id;return Rn(!0),dn(null),Promise.all([fP(Ae),f_(Ae)]).then(([dt,mt])=>{de||un(GO(dt,mt))}).catch(()=>{de||(un({localBranches:[],remoteBranches:[],tags:[]}),dn(o("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{de||Rn(!1)}),()=>{de=!0}},[tn==null?void 0:tn.id,Xe]),p.useLayoutEffect(()=>{if(!ae||!rr.current){Z(null),ge(null);return}const H=()=>{const Ae=rr.current;if(!Ae)return;const dt=KO(Ae);Z({top:dt.bottom+8,left:dt.left,width:dt.width})};H();const de=Ae=>{var mt,pn;const dt=Ae.target;dt instanceof Node&&((mt=rr.current)!=null&&mt.contains(dt)||(pn=Gn.current)!=null&&pn.contains(dt)||(Be(!1),jt(-1)))};return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),window.addEventListener("pointerdown",de),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0),window.removeEventListener("pointerdown",de)}},[ue.length,ae]),p.useLayoutEffect(()=>{if(!ae||!Gn.current){ge(null);return}const H=Gn.current,de=()=>{const dt=Math.ceil(H.getBoundingClientRect().height);ge(mt=>mt===dt?mt:dt)};if(de(),typeof ResizeObserver>"u")return;const Ae=new ResizeObserver(()=>{de()});return Ae.observe(H),()=>{Ae.disconnect()}},[ae,ar,Wn,$t]);function it(){ie(!0)}function tt(){lt(!0)}function Tt(){ze(!1),$e(""),Rt(""),Wt(""),Be(!1),jt(-1),on(!1)}function cn(H,de){const Ae=H.getBoundingClientRect();return de<=Ae.top+Ae.height/2?"before":"after"}function In(){xr.current!==null&&(cancelAnimationFrame(xr.current),xr.current=null),zn(null)}function Hn(H){const de=(H==null?void 0:H.commit)??!1,Ae=(H==null?void 0:H.preserveClickSuppression)??!1,dt=Yr.current,mt=Xr.current;Yr.current=null,Xr.current=null,mt==null||mt(),dt!=null&&dt.dragging&&(In(),de&&M(),!Ae&&Lr.current===dt.workspaceId&&(Lr.current=null))}function ts(H){if(Lr.current===H){Lr.current=null;return}W(H)}function gs(H,de){if(de){Kr.current.set(H,de);return}Kr.current.delete(H)}function or(H,de){for(const[Ae,dt]of Kr.current){const mt=dt.getBoundingClientRect();if(H>=mt.left&&H<=mt.right&&de>=mt.top&&de<=mt.bottom)return{workspaceId:Ae,element:dt}}return null}function Ls(H,de){var B;if(!dr||H.button!==0)return;Hn();const Ae=H.currentTarget,dt={pointerId:H.pointerId,workspaceId:de,startX:H.clientX,startY:H.clientY,pointerTarget:Ae,dragging:!1};Yr.current=dt,(B=Ae.setPointerCapture)==null||B.call(Ae,H.pointerId);const mt=re=>{ns(re)},pn=re=>{mr(re.pointerId,{commit:!0,preserveClickSuppression:!0})},zt=re=>{mr(re.pointerId,{commit:!1,preserveClickSuppression:!1})};Xr.current=()=>{Ae.removeEventListener("pointermove",mt),Ae.removeEventListener("pointerup",pn),Ae.removeEventListener("pointercancel",zt),window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",pn),window.removeEventListener("pointercancel",zt)},Ae.addEventListener("pointermove",mt),Ae.addEventListener("pointerup",pn),Ae.addEventListener("pointercancel",zt),window.addEventListener("pointermove",mt,{passive:!1}),window.addEventListener("pointerup",pn),window.addEventListener("pointercancel",zt)}function ns(H){const de=Yr.current;if(!de||de.pointerId!==H.pointerId)return;if(!de.dragging){if(Math.hypot(H.clientX-de.startX,H.clientY-de.startY)<_O)return;de.dragging=!0,Lr.current=de.workspaceId,E(),zn(de.workspaceId)}H.preventDefault();const Ae=or(H.clientX,H.clientY);!Ae||Ae.workspaceId===de.workspaceId||I(de.workspaceId,Ae.workspaceId,cn(Ae.element,H.clientY))}function mr(H,de){var dt,mt;const Ae=Yr.current;!Ae||Ae.pointerId!==H||((mt=(dt=Ae.pointerTarget).releasePointerCapture)==null||mt.call(dt,H),Hn(de))}function pa(H){ns(H)}function rs(H){mr(H.pointerId,{commit:!0,preserveClickSuppression:!0})}function ji(H){mr(H.pointerId,{commit:!1,preserveClickSuppression:!1})}function Qr(H,de){H.dataTransfer.effectAllowed="move",H.dataTransfer.setData("text/plain",de),E(),xr.current!==null&&cancelAnimationFrame(xr.current),xr.current=requestAnimationFrame(()=>{xr.current=null,zn(de)})}function qr(H,de){const Ae=Vn||H.dataTransfer.getData("text/plain");!Ae||Ae===de||(H.preventDefault(),H.dataTransfer.dropEffect="move",I(Ae,de,cn(H.currentTarget,H.clientY)))}function ci(H){H.preventDefault()}function ui(){In(),M()}p.useEffect(()=>()=>{Hn()},[]);function Ti(H){return _t[H]??Ed}function _r(H){return Qt.includes(H)}function $(H){return oe[H]??vc}function be(){ct(H=>Math.min(s.length,H+yf))}function st(H,de){Re(Ae=>({...Ae,[H]:Math.min(de,(Ae[H]??vc)+vc)}))}function At(H){Ut(de=>({...de,[H]:(de[H]??Ed)+Ed}))}function en(H){ln(de=>de.includes(H)?de.filter(Ae=>Ae!==H):[...de,H])}function ds(H,de){return sr.has(H)?!1:de||es.has(H)}function Ni(H,de){const Ae=!ds(H,de);Jn(dt=>{const mt=dt.expandedWorkspaceIds.filter(zt=>zt!==H),pn=dt.collapsedWorkspaceIds.filter(zt=>zt!==H);return Ae?{expandedWorkspaceIds:[...mt,H],collapsedWorkspaceIds:pn}:{expandedWorkspaceIds:mt,collapsedWorkspaceIds:[...pn,H]}})}function Gi(H){for(const de of e){const Ae=ii(Mv(de.visibleSessions,r)).find(dt=>dt.item.sessionId===H)??XP(de.childWorktrees,H);if(Ae)return wi(Ae)}return[]}function Ki(H,de){const Ae=Vs(H);return n.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":Ae.tone,style:ri(Ae),onClick:()=>We(H.id),children:[n.jsxs("span",{className:"workbench-archive-folder-main",children:[n.jsx(Y2,{}),n.jsx("span",{children:o("shell.archiveFolderLabel")})]}),n.jsx("span",{className:"workbench-section-counter",children:de.length})]})}function Ga(){return n.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[n.jsx("span",{className:"workbench-workspace-batch-label",children:o("shell.batchSelectionMode")}),n.jsxs("span",{className:"workbench-workspace-batch-counter",children:[Zt.length,"/",nn.length]}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:$l,children:o(zr?"shell.clearSelectedSessions":"shell.selectAllSessions")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Zt.length===0||Ge,onClick:()=>{Ho()},children:o(Ge?"shell.batchArchiving":"shell.batchArchiveAction")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Oo,children:o("common.cancel")})]})}function _o(H,de="workbench-workspace-actions"){return n.jsxs("div",{className:de,children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":o("shell.switchWorkspace"),title:o("shell.switchWorkspace"),"aria-pressed":l===H,onClick:()=>{F(H),X==null||X()},children:n.jsx($2,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":o("shell.batchSelectSessions"),title:o("shell.batchSelectSessions"),onClick:()=>zl(H),children:n.jsx(q2,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":o("shell.createSession"),title:o("shell.createSession"),onClick:()=>kt(H),children:n.jsx(_2,{})})]})}function Ka(H){const de=H.visibleSessionTree,dt=new Set(Jg(H.children)).has(l??""),mt=H.workspace.id===l||dt,pn=Hr||!ds(H.workspace.id,mt),zt=Vs(H.workspace);return n.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":Nn===H.workspace.id,"data-worktree-depth":H.meta.depth,"data-workspace-tone":"worktree",style:ri(zt),children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":o(pn?"shell.worktreeExpand":"shell.worktreeCollapse"),onClick:()=>Ni(H.workspace.id,mt),children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(Lc,{expanded:!pn})}),n.jsxs("span",{children:[n.jsx("strong",{children:H.meta.displayName||H.workspace.name}),n.jsx("span",{className:"session-meta",children:H.meta.branchName})]})]}),Nn===H.workspace.id?Ga():_o(H.workspace.id)]}),pn?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list","data-workspace-tone":zt.tone,style:ri(zt),children:[de.length===0?n.jsx("p",{className:"workbench-session-empty",children:o("shell.emptyWorkspaceSessions")}):de.slice(0,$(H.workspace.id)).map(B=>Fs({node:B,workspace:H.workspace,workspaceContext:zt,menuKeyPrefix:`worktree:${H.workspace.id}`,showWorkspaceName:!1,selectionMode:Nn===H.workspace.id,favoriteEnabled:!0})),de.length>$(H.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>st(H.workspace.id,de.length),children:o("shell.sessionExpandMore")}):null]}),H.children.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:H.children.map(B=>Ka(B))}):null,Ki(H.workspace,H.archivedSessions)]})]},H.workspace.id)}function Fs(H){const{node:de,workspace:Ae,workspaceContext:dt,menuKeyPrefix:mt,showWorkspaceName:pn,selectionMode:zt,favoriteEnabled:B,ancestorExpanded:re=!1,allowToggle:Te=de.depth===0,ancestorHasNextSiblings:Je=[],hasNextSibling:Dt=!1,isFirstSibling:Mt=!1}=H,Vt=de.item,Mn=wi(de),Pn=re||_r(Vt.sessionId),Ht=Pn&&Te,jr=Ht?l2(de,Ti(Vt.sessionId),r):de,bs=Pn?wi(jr):[],ss=ii(Mn).length,_s=ii(bs).length,Pi=Ht&&_s<ss,Vl=de.depth>0?[...Je,Dt]:[...Je];return n.jsxs("div",{className:"workbench-session-tree-node",children:[n.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":de.depth},children:[de.depth>0?n.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[Je.map((Di,Qa)=>Di?n.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":Qa+1}},`${Vt.sessionId}:ancestor:${Qa}`):null),n.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":Dt,"data-first":Mt,style:{"--workbench-session-tree-level":de.depth},children:n.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,n.jsx(J2,{menuKey:`${mt}:${Vt.sessionId}`,session:Vt,workspace:Ae,workspaceContext:dt,isActive:Vt.sessionId===w,isFavorite:B&&i.has(Vt.sessionId),menuOpen:qe===`${mt}:${Vt.sessionId}`,showWorkspaceName:pn,depth:de.depth,showActions:B,hasSubagents:Te&&Mn.length>0,subagentListExpanded:Pn,selectionMode:zt,selected:Fr.has(Vt.sessionId),onToggleSelect:()=>ql(Vt.sessionId),onToggleSubagents:()=>en(Vt.sessionId),onOpen:()=>{Se(Yn(Ae.id,Vt.sessionId)),X==null||X()},onRename:()=>fa(Vt,Ae),menuAnchorPoint:qe===`${mt}:${Vt.sessionId}`?Ke:null,onOpenContextMenu:Di=>ir(`${mt}:${Vt.sessionId}`,Di),onToggleFavorite:()=>Wo(Vt.sessionId),onArchive:()=>Uo(Vt.sessionId),onCloseMenu:wt})]}),Mn.length>0&&Pn?n.jsxs("div",{className:"workbench-subsession-list",children:[bs.map((Di,Qa)=>Fs({node:Di,workspace:Ae,workspaceContext:dt,menuKeyPrefix:mt,showWorkspaceName:pn,selectionMode:zt,favoriteEnabled:B,ancestorExpanded:!0,allowToggle:!1,ancestorHasNextSiblings:Vl,hasNextSibling:Qa<bs.length-1,isFirstSibling:Qa===0})),Pi?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>At(Vt.sessionId),children:o("shell.subagentExpandMore")}):null]}):null]},Vt.sessionId)}function zl(H){wt(),xt(H),we([])}function Oo(){xt(null),we([])}function ql(H){we(de=>P2(de,H))}function $l(){we(H=>H.length===nn.length?[]:nn)}async function Bo(H,de){He(H),Fe(de);try{await zP(H,de),kt(null),Se(ON(H,de)),X==null||X()}catch(Ae){J({title:Ae instanceof Error?Ae.message:o("shell.startSessionFailed"),tone:"error"})}finally{He(null),Fe(null)}}async function Yi(H){if(H.preventDefault(),!tn||vt)return;const de=pe.trim(),Ae=Nt.trim(),dt=Ft.trim();if(!de){J({title:o("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!$O(de)){J({title:o("shell.createWorktreeBranchInvalid"),tone:"error"});return}ht(!0);try{const mt=await YF({sourceWorkspaceId:tn.id,branchName:de,displayName:Ae||void 0,baseRef:dt||void 0});Me(mt.workspace),F(mt.workspace.id),await k(),kt(mt.workspace.id),Tt(),J({title:o("shell.createWorktreeSucceeded",{name:mt.meta.displayName||mt.workspace.name}),tone:"success"})}catch(mt){J({title:mt instanceof Error?mt.message:o("shell.createWorktreeFailed"),tone:"error"})}finally{ht(!1)}}async function Wo(H){const de=i.has(H);wt();try{await Y(H),J({title:o(de?"shell.favoriteRemoved":"shell.favoriteAdded"),tone:"success"})}catch(Ae){J({title:Ae instanceof Error?Ae.message:o("shell.favoriteToggleFailed"),tone:"error"})}}async function Uo(H){wt();try{await G(H),J({title:o("shell.archiveAdded"),tone:"success"})}catch(de){J({title:de instanceof Error?de.message:o("shell.navigationLoadFailed"),tone:"error"})}}async function Ho(){if(!(Zt.length===0||Ge)){wt(),St(!0);try{const H=[...Zt],de=await Promise.allSettled(H.map(async mt=>({sessionId:mt,session:await lP(mt,!0)}))),Ae=[];let dt=0;for(const mt of de){if(mt.status==="fulfilled"){Ae.push(mt.value.sessionId),y(mt.value.session);continue}dt+=1}Ae.length>0&&(await k(),we(mt=>mt.filter(pn=>!Ae.includes(pn)))),dt>0?J({title:Ae.length>0?o("shell.batchArchivePartialFailed"):o("shell.batchArchiveFailed"),tone:"error"}):J({title:o("shell.batchArchiveSuccess"),tone:"success"})}catch(H){J({title:H instanceof Error?H.message:o("shell.batchArchiveFailed"),tone:"error"})}finally{St(!1)}}}async function zo(H){wt();try{await te(H),J({title:o("shell.archiveRestored"),tone:"success"})}catch(de){J({title:de instanceof Error?de.message:o("shell.navigationLoadFailed"),tone:"error"})}}function fa(H,de){wt(),Jt({session:H,workspace:de}),vn(H.title)}async function qo(H){if(H.preventDefault(),!bn)return;const de=ur.trim();if(de){kn(bn.session.sessionId);try{const Ae=await oP(bn.session.sessionId,de);y(Ae),Jt(null),vn(""),J({title:o("shell.renameSuccess"),tone:"success"})}catch(Ae){J({title:Ae instanceof Error?Ae.message:o("shell.renameFailed"),tone:"error"})}finally{kn(null)}}}const Ya=s.slice(0,ft),$o=Ya.length<s.length;function Vs(H){return t[H.id]??Tu(H)}function Xa(H,de,Ae,dt,mt=[]){var Pn;const pn=Ct.includes(H.id),zt=K[H.id]??{detail:null,loading:!1,error:null},B=Ue===H.id,re=Sn[H.id]===!0,Te=(Pn=zt.detail)!=null&&Pn.git.remotes.length?zt.detail.git.remotes.map(Ht=>`${Ht.name}: ${Ht.url}`).join(" · "):o("shell.manageWorkspaceNoRemote"),Je=zt.detail?TP(zt.detail.codeComposition.items,o("shell.manageWorkspaceCodeCompositionOther")):[],Dt=Je.length>0?NP(Je):void 0,Mt=Vs(H),Vt=x2(Mt,mt),Mn=[...mt,Mt.displayName];return n.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":Mt.tone,"data-worktree-node":dt,style:ri(Mt),children:[n.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":pn,onClick:()=>V(H.id),children:[n.jsxs("span",{className:"workbench-manage-item-heading",children:[n.jsx(Lc,{expanded:pn}),n.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[n.jsx("strong",{children:Mt.displayName}),n.jsx("span",{className:"workbench-manage-item-tree-path",children:Vt})]})]}),n.jsx("span",{className:"workbench-section-counter",children:de})]}),pn?n.jsxs("div",{className:"workbench-manage-item-body",children:[n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspacePathLabel")}),n.jsx("p",{className:"workbench-manage-detail-value",children:H.path})]}),dt?n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspaceColorLabel")}),n.jsxs("div",{className:"workbench-manage-color-actions",children:[n.jsx("div",{className:"workbench-manage-color-palette","aria-label":o("shell.manageWorkspaceColorLabel"),children:WO.map(Ht=>n.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":o("shell.manageWorkspaceColorSelectSwatch",{color:Ht}),"aria-pressed":H.backgroundColor===Ht,disabled:re,"data-selected":H.backgroundColor===Ht,style:{backgroundColor:Ht},onClick:()=>{fe(H.id,Ht)}},Ht))}),n.jsx("button",{type:"button",className:"ghost-button",disabled:re||!H.backgroundColor,onClick:()=>{fe(H.id,null)},children:o("shell.manageWorkspaceColorClearAction")})]})]}),n.jsx("p",{className:"workbench-manage-hint",children:H.backgroundColor??o("shell.manageWorkspaceColorUnset")})]}):null,zt.loading&&zt.detail===null?n.jsx("p",{className:"workbench-manage-status status-text",children:o("shell.manageWorkspaceLoading")}):null,zt.error?n.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:zt.error}):null,zt.detail?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-manage-detail-block",children:n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspaceGitCommitCount")}),n.jsx("strong",{className:"workbench-manage-detail-accent",children:zt.detail.git.commitCount??"--"})]})}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspaceGitInfoLabel")}),zt.detail.git.isRepository?n.jsxs("div",{className:"workbench-manage-kv-list",children:[n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.manageWorkspaceRepoRoot")}),n.jsx("span",{children:zt.detail.git.repoRoot??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.manageWorkspaceCurrentBranch")}),n.jsx("span",{children:zt.detail.git.currentBranch??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.manageWorkspaceRemoteLabel")}),n.jsx("span",{children:Te})]})]}):n.jsx("p",{className:"workbench-section-empty",children:zt.detail.git.error??o("shell.manageWorkspaceNotGit")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspaceCodeCompositionLabel")}),Je.length>0?n.jsxs("div",{className:"workbench-manage-type-chart",children:[n.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Dt,"aria-hidden":"true",children:[n.jsx("strong",{className:"workbench-manage-type-chart-total",children:zt.detail.codeComposition.scannedFileCount}),n.jsx("span",{className:"workbench-manage-type-chart-caption",children:o("shell.manageWorkspaceCodeCompositionFiles")})]}),n.jsx("div",{className:"workbench-manage-type-list",children:Je.map(Ht=>n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsxs("span",{className:"workbench-manage-type-meta",children:[n.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:Ht.color},"aria-hidden":"true"}),n.jsx("span",{className:"workbench-manage-type-name",children:Ht.type})]}),n.jsxs("span",{children:[Ht.count," · ",jP(Ht)]})]},Ht.key))})]}):n.jsx("p",{className:"workbench-section-empty",children:zt.detail.codeComposition.error??o("shell.manageWorkspaceNoCodeComposition")}),zt.detail.codeComposition.truncated?n.jsx("p",{className:"workbench-manage-hint",children:o("shell.manageWorkspaceCodeTruncated",{count:zt.detail.codeComposition.scannedFileCount})}):null]})]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{bt(!1),Se(DL(H.id))},children:o("shell.workspaceDetailDebugOpenPageAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Ue,onClick:()=>De(H),children:o(B?"shell.manageWorkspaceRemoving":"shell.manageWorkspaceRemoveAction")})]})]}):null,Ae.length>0?n.jsx("div",{className:"workbench-manage-children",children:Ae.map(Ht=>Xa(Ht.workspace,Ht.visibleSessions.length+Ht.archivedSessions.length,Ht.children,!0,Mn))}):null]},H.id)}return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header",onMouseDownCapture:Ne,children:n.jsxs("div",{className:"workbench-nav-toolbar",children:[R?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":o("shell.hideSessionSidebar"),title:o("shell.hideSessionSidebar"),onClick:R,children:n.jsx(pD,{})}):null,n.jsx(BP,{}),n.jsx(dD,{unreadCount:q,open:P,onToggle:U}),n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":o("shell.goBack"),title:o("shell.goBack"),onClick:()=>Se(-1),children:n.jsx(hD,{})}),n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":o("shell.goForward"),title:o("shell.goForward"),onClick:()=>Se(1),children:n.jsx(mD,{})})]})}),n.jsxs("div",{className:"workbench-nav-body",children:[n.jsxs("div",{className:"workbench-nav-segment",role:"tablist","aria-label":o("shell.centerTabsLabel"),children:[n.jsxs("button",{type:"button",className:c?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":c,onClick:C,children:[n.jsx(B2,{}),o("shell.conversationEntry")]}),n.jsxs("button",{type:"button",className:d?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":d,onClick:T,children:[n.jsx(W2,{}),o("shell.terminalsEntry")]}),n.jsxs("button",{type:"button",className:m?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":m,onClick:j,children:[n.jsx(U2,{}),o("shell.butlerEntry")]}),n.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":f,"aria-haspopup":"dialog","aria-expanded":f,onClick:N,children:[n.jsx(O2,{}),n.jsx("span",{children:o("shell.searchEntry")})]})]}),g?n.jsx("div",{className:"workbench-status-row",children:n.jsx("p",{className:"status-text","data-tone":"error",children:g})}):null,s.length>0?n.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsxs("div",{className:"workbench-section-heading-main",children:[n.jsx(fD,{active:!0,className:"workbench-favorite-heading-icon"}),n.jsx("span",{children:o("shell.favoriteSectionTitle")})]}),n.jsx("span",{className:"workbench-section-counter",children:s.length})]}),n.jsxs("div",{className:"workbench-session-list",children:[Ya.map(H=>{const de=Gi(H.session.sessionId);return n.jsx("div",{children:Fs({node:{item:H.session,depth:0,children:de},workspace:H.workspace,workspaceContext:Vs(H.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},H.session.sessionId)}),$o?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:be,children:o("shell.favoriteExpandMore")}):null]})]}):null,v&&e.length===0?n.jsx(M2,{}):null,!v&&!g&&e.length===0?n.jsx("div",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("shell.emptyNavigationBody")})}):null,n.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsx("div",{className:"workbench-section-heading-main",children:n.jsx("span",{children:o("shell.workspaceSectionTitle")})}),n.jsxs("div",{className:"workbench-section-actions",children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":o("shell.manageWorkspaceAction"),title:o("shell.manageWorkspaceAction"),onClick:()=>bt(!0),children:n.jsx(E2,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":o("shell.importWorkspaceTitle"),title:o("shell.importWorkspaceTitle"),onClick:it,children:n.jsx(I2,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":o("shell.cloneWorkspaceTitle"),title:o("shell.cloneWorkspaceTitle"),onClick:tt,children:n.jsx(H2,{})})]})]}),e.map(H=>{const de=Ic(H),Ae=Vn===H.workspace.id,dt=H.isCollapsed||Hr;return n.jsxs("section",{className:"workbench-workspace-group",ref:mt=>gs(H.workspace.id,mt),"data-workspace-group-id":H.workspace.id,"data-batch-active":Nn===H.workspace.id,"data-dragging":Ae,onDragOver:mt=>qr(mt,H.workspace.id),onDrop:ci,children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":o(dt?"shell.workspaceExpand":"shell.workspaceCollapse"),draggable:_&&!dr,onClick:()=>ts(H.workspace.id),onPointerDown:dr?mt=>Ls(mt,H.workspace.id):void 0,onPointerMove:dr?pa:void 0,onPointerUp:dr?rs:void 0,onPointerCancel:dr?ji:void 0,onDragStart:_&&!dr?mt=>Qr(mt,H.workspace.id):void 0,onDragEnd:_&&!dr?ui:void 0,"data-reorder-enabled":_?"true":void 0,children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(Lc,{expanded:!dt})}),n.jsx("strong",{children:H.workspace.name})]}),Nn===H.workspace.id?Ga():_o(H.workspace.id)]}),dt?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list",children:[de.length===0?n.jsx("p",{className:"workbench-session-empty",children:o("shell.emptyWorkspaceSessions")}):de.slice(0,$(H.workspace.id)).map(mt=>Fs({node:mt,workspace:H.workspace,workspaceContext:Vs(H.workspace),menuKeyPrefix:`workspace:${H.workspace.id}`,showWorkspaceName:!1,selectionMode:Nn===H.workspace.id,favoriteEnabled:!0})),de.length>$(H.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>st(H.workspace.id,de.length),children:o("shell.sessionExpandMore")}):null]}),H.childWorktrees.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:H.childWorktrees.map(mt=>Ka(mt))}):null,Ki(H.workspace,H.archivedSessions)]})]},H.workspace.id)})]})]}),n.jsx("div",{className:"workbench-nav-footer minimal",children:n.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:D,title:o("settings.title"),children:[n.jsx(z2,{}),n.jsx("span",{className:"settings-entry-label",children:o("settings.title")})]})}),n.jsx(Ln,{open:Oe,title:o("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:o("shell.manageWorkspaceDescription"),headerActions:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:it,children:o("shell.manageWorkspaceImportAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:tt,children:o("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{Ue||bt(!1)},children:e.length>0?n.jsx("div",{className:"workbench-manage-list",children:e.map(H=>Xa(H.workspace,H.visibleSessions.length+H.archivedSessions.length,H.childWorktrees,!1))}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.manageWorkspaceEmpty")})}),n.jsxs(Ln,{open:et!==null,title:o("shell.manageWorkspaceRemoveConfirmTitle"),description:o("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{Ue||De(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:et?o("shell.manageWorkspaceRemoveConfirmTarget",{name:et.name}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!Ue,onClick:()=>De(null),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Ue,onClick:()=>{ve()},children:o(Ue?"shell.manageWorkspaceRemoving":"shell.manageWorkspaceRemoveConfirmAction")})]})]}),n.jsx(WP,{open:xe,onClose:()=>lt(!1),onCloned:Cr}),n.jsx(HP,{open:Ee,onClose:()=>ie(!1),onImported:Xt}),n.jsx(Ln,{open:tn!==null,title:o("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:tn?`${o("shell.createSessionTarget")} · ${tn.name}`:o("shell.createSessionModalDescription"),headerActions:n.jsx("button",{type:"button",className:"secondary-button create-session-worktree-trigger",disabled:vt||!!ye,onClick:()=>ze(!0),children:o("shell.createWorktreeAction")}),onClose:()=>kt(null),children:n.jsxs("section",{className:"create-session-modal-section",children:[n.jsxs("div",{className:"create-session-modal-section-header",children:[n.jsx("strong",{children:o("shell.createSessionProviderLabel")}),n.jsx("span",{children:o("shell.providerOptionHint")})]}),n.jsx(Rv,{disabled:!!ye||vt,workspaceId:(tn==null?void 0:tn.id)??null,pendingProvider:ye===(tn==null?void 0:tn.id)?je??null:null,onSelect:H=>{tn&&Bo(tn.id,H)}})]})}),n.jsx(Ln,{open:tn!==null&&Xe,title:o("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:n.jsx("button",{type:"button",className:Cn?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":o("shell.createWorktreeHelpAction"),title:o("shell.createWorktreeHelpAction"),"aria-pressed":Cn,onClick:()=>on(H=>!H),children:n.jsx(X2,{})}),description:tn?`${o("shell.createWorktreeSectionDescription")} ${o("shell.createSessionTarget")} · ${tn.name}`:o("shell.createWorktreeSectionDescription"),onClose:Tt,children:n.jsxs("form",{className:"create-session-worktree-form",onSubmit:Yi,children:[Cn?n.jsxs("section",{className:"create-session-worktree-help-card","aria-label":o("shell.createWorktreeHelpTitle"),children:[n.jsx("strong",{children:o("shell.createWorktreeHelpTitle")}),n.jsxs("div",{className:"create-session-worktree-help-grid",children:[n.jsxs("article",{children:[n.jsx("h3",{children:o("shell.createWorktreeHelpBranchTitle")}),n.jsx("p",{children:o("shell.createWorktreeHelpBranchBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:o("shell.createWorktreeHelpDisplayNameTitle")}),n.jsx("p",{children:o("shell.createWorktreeHelpDisplayNameBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:o("shell.createWorktreeHelpBaseRefTitle")}),n.jsx("p",{children:o("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:o("shell.createWorktreeBranchLabel")}),n.jsx("input",{className:"settings-text-input",value:pe,placeholder:o("shell.createWorktreeBranchPlaceholder"),onChange:H=>{const de=H.target.value;VO(de)&&$e(de)}})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:o("shell.createWorktreeDisplayNameLabel")}),n.jsx("input",{className:"settings-text-input",value:Nt,placeholder:o("shell.createWorktreeDisplayNamePlaceholder"),onChange:H=>Rt(H.target.value)})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:o("shell.createWorktreeBaseRefLabel")}),n.jsx("div",{className:"create-session-worktree-combobox",ref:rr,onBlurCapture:H=>{var Ae,dt;const de=H.relatedTarget;de instanceof Node&&((Ae=rr.current)!=null&&Ae.contains(de)||(dt=Gn.current)!=null&&dt.contains(de))||(Be(!1),jt(-1))},children:n.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[n.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":ae,"aria-controls":Qe,value:Ft,placeholder:o("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{Be(!0),jt(ue.length>0?0:-1)},onChange:H=>{Wt(H.target.value),Be(!0),jt(ue.length>0?0:-1)},onKeyDown:H=>{if(H.key==="ArrowDown"){if(H.preventDefault(),!ae){Be(!0);return}ue.length>0&&jt(de=>de>=ue.length-1?0:de+1);return}if(H.key==="ArrowUp"){if(H.preventDefault(),!ae){Be(!0);return}ue.length>0&&jt(de=>de<=0?ue.length-1:de-1);return}if(H.key==="Enter"&&ae&&It>=0){H.preventDefault();const de=ue[It];de&&(Wt(de.value),Be(!1),jt(-1));return}H.key==="Escape"&&Be(!1)}}),n.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":o("shell.createWorktreeBaseRefToggle"),"aria-expanded":ae,onClick:()=>{Be(H=>!H),jt(!ae&&ue.length>0?0:-1)},children:n.jsx(Lc,{expanded:ae})})]})}),n.jsx("span",{className:"create-session-worktree-field-hint",children:Wn?o("shell.createWorktreeBaseRefLoading"):$t||o("shell.createWorktreeBaseRefHint",{localCount:Kt.localBranches.length,remoteCount:Kt.remoteBranches.length,tagCount:Kt.tags.length})})]}),ae&&gn&&typeof document<"u"?$n.createPortal(n.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[n.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${gn.top}px`,"--create-worktree-combobox-left":`${gn.left}px`,"--create-worktree-combobox-width":`${gn.width}px`,"--create-worktree-combobox-height":`${ce??0}px`}}),n.jsx("div",{ref:Gn,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${gn.top}px`,"--create-worktree-combobox-left":`${gn.left}px`,"--create-worktree-combobox-width":`${gn.width}px`},children:Wn?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:o("shell.createWorktreeBaseRefLoading")}):$t?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:$t}):ar.length>0?n.jsx("div",{id:Qe,className:"create-session-worktree-combobox-list",role:"listbox",children:ar.map(H=>n.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":H.label,children:[n.jsx("header",{className:"create-session-worktree-combobox-group-title",children:H.label}),n.jsx("div",{className:"create-session-worktree-combobox-group-options",children:H.items.map(de=>{const Ae=ue.findIndex(pn=>pn.value===de.value),dt=Ft===de.value,mt=It===Ae;return n.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":dt,"data-highlighted":mt,onMouseDown:pn=>pn.preventDefault(),onMouseEnter:()=>jt(Ae),onClick:()=>{Wt(de.value),Be(!1),jt(-1)},children:[n.jsx("span",{className:"create-session-worktree-combobox-option-label",children:de.value}),n.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[de.current?n.jsx("span",{className:"create-session-worktree-combobox-badge",children:o("shell.createWorktreeBaseRefCurrentBadge")}):null,de.recommended?n.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:o("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${H.key}:${de.value}`)})})]},H.key))}):n.jsx("p",{className:"create-session-worktree-combobox-empty",children:o("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:vt,onClick:Tt,children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:vt,children:o(vt?"shell.createWorktreeSubmitting":"shell.createWorktreeSubmit")})]})]})}),n.jsx(Ln,{open:yt!==null,title:o("shell.archiveModalTitle"),description:yt?`${yt.workspace.name} · ${o("shell.archiveModalDescription")}`:o("shell.archiveModalDescription"),onClose:()=>We(null),children:yt&&yt.archivedSessions.length>0?n.jsx("div",{className:"workbench-archive-list","data-workspace-tone":(Lt==null?void 0:Lt.tone)??"root",style:ri(Lt),children:yt.archivedSessions.map(H=>{const de=$i(H.title,o("common.unknown"));return n.jsxs("article",{className:"workbench-archive-item","data-workspace-tone":(Lt==null?void 0:Lt.tone)??"root",style:ri(Lt),children:[n.jsxs("div",{className:"workbench-archive-item-main",children:[n.jsx("strong",{title:de.fullTitle,children:de.displayTitle}),n.jsxs("p",{children:[GP(H,yt.workspace,!1)," ·"," ",bm(H.provider)]})]}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>zo(H.sessionId),children:o("shell.unarchiveAction")})]},H.sessionId)})}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.archiveEmpty")})}),n.jsx(Ln,{open:bn!==null,title:o("shell.renameModalTitle"),description:o("shell.renameModalDescription"),onClose:()=>{yn||(Jt(null),vn(""))},children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:qo,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.renameInputLabel")}),n.jsx("input",{type:"text",value:ur,placeholder:o("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:H=>vn(H.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!yn,onClick:()=>{Jt(null),vn("")},children:o("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!ur.trim()||yn===(bn==null?void 0:bn.session.sessionId),children:yn===(bn==null?void 0:bn.session.sessionId)?o("shell.renamingSession"):o("common.save")})]})]})})]})}function fS({panelReady:e,activeTab:t,fileRevealRequest:r,onTabChange:s,onToggleCollapse:i,currentSessionId:l,activeWorkspaceId:c,navigationGroups:d,workspaceContext:m,worktreeMeta:f,worktreeMergeState:v,onRefreshWorktreeMergePreview:g,onApplyWorktreeMerge:w,onCleanupWorktree:k}){var ne;const y=c??((ne=d[0])==null?void 0:ne.workspace.id)??null,C=nr(),{showToast:T}=Qn(),j=p.useRef(null),N=p.useRef(null),D=C.isDesktop&&C.bridge.supported,F=D&&!!c,W=D&&!!y,E=D&&!!y,I=typeof globalThis<"u"&&"PointerEvent"in globalThis,M=p.useCallback(async(Y,G,te)=>{if(Y==="files"){const z=await DF(C,{workspaceId:G,sessionId:te,focusOwner:"file-context-panel"});z.ok||T({title:z.detail??o("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(Y==="git"){const z=await RF(C,{workspaceId:G,focusOwner:"git-sidebar"});z.ok||T({title:z.detail??o("git.openExternalFailed"),tone:"error"});return}const K=await MF(C,{workspaceId:G,focusOwner:"terminal-manager-panel"});K.ok||T({title:K.detail??o("terminalManager.openExternalFailed"),tone:"error"})},[C,T]),_=p.useCallback((Y,G)=>{if(Y.button!==0||!D)return;const te=G==="files"?c:G==="git"||G==="terminals"?y:null;if(!te)return;const K=G==="files"?l:null;j.current={tab:G,startX:Y.clientX,startY:Y.clientY,workspaceId:te,sessionId:K,detached:!1,preview:null};const z=X=>{var J;const R=j.current;if(!R)return;const Se=Math.abs(X.clientX-R.startX),se=Math.abs(X.clientY-R.startY);!R.detached&&Math.max(Se,se)<Qx||(R.detached||(R.detached=!0,N.current=R.tab,R.preview=vx({title:R.tab==="files"?o("shell.filesEntry"):R.tab==="git"?o("shell.gitEntry"):o("shell.terminalManagerEntry"),x:X.clientX,y:X.clientY})),(J=R.preview)==null||J.updatePosition(X.clientX,X.clientY))},q=X=>{var Se;const R=(Se=j.current)==null?void 0:Se.preview;X&&(R==null||R.cancel()),window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",P),window.removeEventListener("blur",U),j.current=null},P=async()=>{var R;const X=j.current;q(!1),X!=null&&X.detached&&(await((R=X.preview)==null?void 0:R.complete()),await M(X.tab,X.workspaceId,X.sessionId))},U=()=>{q(!0)};window.addEventListener("mousemove",z),window.addEventListener("mouseup",P),window.addEventListener("blur",U)},[c,D,l,y,M]),L=p.useCallback((Y,G)=>{if(Y.button!==0||!D)return;const te=G==="files"?c:G==="git"||G==="terminals"?y:null;if(!te)return;const K=Y.currentTarget,z=Y.pointerId;K.setPointerCapture(z);const q=G==="files"?l:null;j.current={tab:G,startX:Y.clientX,startY:Y.clientY,workspaceId:te,sessionId:q,detached:!1,preview:null};const P=se=>{var ie;if(se.pointerId!==z)return;const J=j.current;if(!J)return;const Ne=Math.abs(se.clientX-J.startX),Ee=Math.abs(se.clientY-J.startY);!J.detached&&Math.max(Ne,Ee)<Qx||(J.detached||(J.detached=!0,N.current=J.tab,J.preview=vx({title:J.tab==="files"?o("shell.filesEntry"):J.tab==="git"?o("shell.gitEntry"):o("shell.terminalManagerEntry"),x:se.clientX,y:se.clientY})),(ie=J.preview)==null||ie.updatePosition(se.clientX,se.clientY))},U=se=>{var Ne;const J=(Ne=j.current)==null?void 0:Ne.preview;se&&(J==null||J.cancel()),K.removeEventListener("pointermove",P),K.removeEventListener("pointerup",X),K.removeEventListener("pointercancel",R),K.removeEventListener("lostpointercapture",R),window.removeEventListener("blur",Se),j.current=null,K.hasPointerCapture(z)&&K.releasePointerCapture(z)},X=async se=>{var Ne;if(se.pointerId!==z)return;const J=j.current;U(!1),J!=null&&J.detached&&(await((Ne=J.preview)==null?void 0:Ne.complete()),await M(J.tab,J.workspaceId,J.sessionId))},R=se=>{se.pointerId===z&&U(!0)},Se=()=>{U(!0)};K.addEventListener("pointermove",P),K.addEventListener("pointerup",X),K.addEventListener("pointercancel",R),K.addEventListener("lostpointercapture",R),window.addEventListener("blur",Se)},[c,D,l,y,M]),Q=p.useCallback(Y=>{if(N.current===Y){N.current=null;return}s(Y)},[s]),O=p.useCallback(Y=>{!C.isDesktop||C.ui.osFamily!=="macos"||Y.button!==0||cv(Y.target)&&uv()},[C.isDesktop,C.ui.osFamily]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(m==null?void 0:m.tone)??"root",style:ri(m),"data-window-drag-handle":"workbench-auxiliary-header",onMouseDownCapture:O,children:[i?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":o("shell.hideInfoSidebar"),title:o("shell.hideInfoSidebar"),onClick:i,children:n.jsx(pD,{})}):null,n.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":o("shell.infoTabsLabel"),children:[n.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:F?"拖拽标签到独立窗口":void 0,onPointerDown:Y=>L(Y,"files"),onMouseDown:I?void 0:Y=>_(Y,"files"),onClick:()=>Q("files"),children:o("shell.filesEntry")}),n.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:W?"拖拽标签到独立窗口":void 0,onPointerDown:Y=>L(Y,"git"),onMouseDown:I?void 0:Y=>_(Y,"git"),onClick:()=>Q("git"),children:o("shell.gitEntry")}),n.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:E?"拖拽标签到独立窗口":void 0,onPointerDown:Y=>L(Y,"terminals"),onMouseDown:I?void 0:Y=>_(Y,"terminals"),onClick:()=>Q("terminals"),children:o("shell.terminalManagerEntry")})]})]}),n.jsxs("div",{className:"workbench-auxiliary-body",children:[e?null:n.jsx(_d,{}),e&&t==="git"&&f?n.jsx(Z2,{meta:f,state:v,onRefresh:()=>g(f.workspaceId,!0),onApply:()=>w(f.workspaceId),onCleanup:()=>k(f)}):null,e&&t==="files"?c?n.jsx(p.Suspense,{fallback:n.jsx(_d,{}),children:n.jsx(n2,{sessionId:l,workspaceId:c,externalRevealRequest:r})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("shell.filesPanelEmpty")})}):null,e&&t==="git"?y?n.jsx(p.Suspense,{fallback:n.jsx(_d,{}),children:n.jsx(r2,{workspaceId:y})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?n.jsx(p.Suspense,{fallback:n.jsx(_d,{}),children:n.jsx(s2,{currentWorkspaceId:c,navigationGroups:d})}):null]})]})}function Z2({meta:e,state:t,onRefresh:r,onApply:s,onCleanup:i}){const[l,c]=p.useState(!1),d=(t==null?void 0:t.preview)??null,m=(t==null?void 0:t.loading)??!1,f=(t==null?void 0:t.applying)??!1,v=(t==null?void 0:t.cleaning)??!1,g=d!==null,w=(d==null?void 0:d.alreadyMerged)===!0,k=new Set((d==null?void 0:d.blockers.map(O=>O.code))??[]),y=k.size>0||!!(t!=null&&t.error),C=w&&!y,T=(d==null?void 0:d.canMerge)===!0&&!m&&!f&&!v&&!C,j=C&&!m&&!f&&!v&&!k.has("SOURCE_DIRTY")&&!k.has("HAS_ACTIVE_CHILDREN"),N=m||f||v?"loading":y?"blocked":C?"merged":d!=null&&d.canMerge?"ready":g?"blocked":"idle",D=(d==null?void 0:d.targetWorkspace.name)??o("common.unknown"),F=(d==null?void 0:d.sourceBranchName)??e.branchName,W=(d==null?void 0:d.targetBranchName)??e.baseRef??o("common.unknown"),E=tB({t:o,hasPreview:g,showMergedState:C,isMerged:w,canMerge:(d==null?void 0:d.canMerge)===!0,ahead:(d==null?void 0:d.ahead)??0,blockerCodeSet:k}),I=m?o("shell.worktreeMergePreviewLoading"):f?o("shell.worktreeMergeApplying"):v?o("shell.worktreeCleanupRunning"):C?o("shell.worktreeMergeAlreadyMerged"):d!=null&&d.canMerge?o("shell.worktreeMergeReady"):o(g?"shell.worktreeMergeBlocked":"shell.worktreeMergePreviewIdle"),M=[o("shell.worktreeMergeCurrentBranch",{branch:F}),o("shell.worktreeMergeParentBranch",{branch:W}),o("shell.worktreeMergeTargetWorkspace",{name:D}),d?o("shell.worktreeMergeAheadBehind",{ahead:d.ahead,behind:d.behind}):o("shell.worktreeMergeAheadBehindPending"),d!=null&&d.mergeBaseCommit?o("shell.worktreeMergeBaseCommit",{commit:D2(d.mergeBaseCommit)}):null].filter(O=>!!O),_=`worktree-merge-panel-details-${e.workspaceId}`,L=o(l?"shell.worktreeMergeCollapseDetails":"shell.worktreeMergeExpandDetails"),Q=eB({t:o,loading:m,applying:f,cleaning:v,hasPreview:g,canMerge:(d==null?void 0:d.canMerge)===!0,showMergedState:C,blockerCodeSet:k});return p.useEffect(()=>{c(!1)},[e.workspaceId]),n.jsxs("section",{className:"worktree-merge-panel","data-state":N,children:[n.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":L,"aria-expanded":l,"aria-controls":_,onClick:()=>{c(O=>!O)},children:[n.jsx("span",{className:"worktree-merge-panel-summary-label",children:o("shell.worktreeMergePanelLabel")}),n.jsx("span",{className:"worktree-merge-panel-summary-main",children:n.jsx("span",{className:"worktree-merge-panel-summary-tags",children:Q.map(O=>n.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":N,children:O},O))})}),n.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:L})]}),l?n.jsxs("div",{id:_,className:"worktree-merge-panel-details",children:[n.jsx("div",{className:"worktree-merge-panel-detail-head",children:n.jsx("span",{className:"worktree-merge-panel-status","data-state":N,children:I})}),n.jsx("div",{className:"worktree-merge-panel-meta",children:M.map(O=>n.jsx("span",{children:O},O))}),g?n.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":o("shell.worktreeMergeChecklistTitle"),children:E.map(O=>n.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":O.state,children:[n.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:O.state==="done"?"✓":O.state==="blocked"?"!":"·"}),n.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[n.jsx("strong",{children:O.label}),O.detail?n.jsx("span",{children:O.detail}):null]})]},O.key))}):null,t!=null&&t.error?n.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,d!=null&&d.conflictPaths.length?n.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[n.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:o("shell.worktreeMergeConflictLabel")}),n.jsx("div",{className:"worktree-merge-panel-conflict-list",children:d.conflictPaths.map(O=>n.jsx("code",{children:O},O))})]}):null,n.jsxs("div",{className:"worktree-merge-panel-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:m||f||v,onClick:r,children:o(g?"shell.worktreeMergePreviewRefresh":"shell.worktreeMergePreviewAction")}),n.jsx("button",{type:"button",className:"primary-button",disabled:!T,onClick:s,children:o(f?"shell.worktreeMergeApplying":"shell.worktreeMergeApplyAction")}),n.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!j,onClick:i,children:o(v?"shell.worktreeCleanupRunning":"shell.worktreeCleanupAction")})]})]}):null]})}function eB(e){const{t,loading:r,applying:s,cleaning:i,hasPreview:l,canMerge:c,showMergedState:d,blockerCodeSet:m}=e;if(r)return[t("shell.worktreeMergeCompactChecking")];if(s)return[t("shell.worktreeMergeCompactMerging")];if(i)return[t("shell.worktreeMergeCompactCleaning")];const f=[];return m.has("SOURCE_NOT_ACTIVE")&&f.push(t("shell.worktreeMergeCompactInactive")),m.has("SOURCE_DIRTY")&&f.push(t("shell.worktreeMergeCompactDirty")),m.has("TARGET_DIRTY")&&f.push(t("shell.worktreeMergeCompactTargetDirty")),m.has("HAS_CONFLICTS")&&f.push(t("shell.worktreeMergeCompactConflict")),m.has("HAS_ACTIVE_CHILDREN")&&f.push(t("shell.worktreeMergeCompactChildren")),f.length>0?f:c?[t("shell.worktreeMergeCompactReady")]:d?[t("shell.worktreeMergeCompactMerged")]:l?m.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function tB(e){const{t,hasPreview:r,showMergedState:s,isMerged:i,canMerge:l,ahead:c,blockerCodeSet:d}=e,m=d.has("SOURCE_NOT_ACTIVE"),f=d.has("SOURCE_DIRTY"),v=d.has("TARGET_DIRTY"),g=d.has("HAS_ACTIVE_CHILDREN"),w=d.has("HAS_CONFLICTS"),k=r&&!i&&(d.has("NO_COMMITS_TO_MERGE")||c<=0),y=s?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:l?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:r?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:r&&m?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:r?m?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:r&&f?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:r?f?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:r&&v?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:r?v?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:r&&g?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:r?g?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:k?t(i?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:k?i?"done":"blocked":r?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:w?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:w?"blocked":r?"done":"pending"},y]}function nB({shellMode:e="desktop"}){var Ho,zo,fa,qo,Ya,$o,Vs,Xa,H,de,Ae,dt,mt,pn,zt;const t=oi(),r=vr(),s=nr(),{showToast:i}=Qn(),l=ai(B=>B.sessionDisplaySortMode),c=ai(B=>B.notificationPreferences.notifyOnPermissionRequest),d=ai(B=>B.notificationPreferences.notifyOnSessionCompleted),m=ai(B=>B.notificationPreferences.notifyOnSessionFailed),f=p.useRef(AP(RP)),v=p.useRef(0),g=p.useRef((((zo=(Ho=f.current)==null?void 0:Ho.items)==null?void 0:zo.length)??0)>0),w=p.useRef(new Map),k=p.useRef(!1),y=p.useRef(null),C=p.useRef(0),T=p.useRef(null),j=p.useRef(null),N=p.useRef(new Set),D=p.useRef(new Set),F=p.useRef(new Set),W=p.useRef(new Set),E=p.useRef(null),I=p.useRef(null),M=p.useRef(null),_=p.useRef(null),L=p.useRef(null),Q=p.useRef(null),O=p.useRef(null),ne=p.useRef(null),Y=p.useRef(0),G=p.useRef(0),te=p.useRef(i),K=p.useRef(s.bridge),z=p.useRef(!1),q=p.useRef(new Map),P=p.useRef(!1),U=p.useRef(new Map),X=p.useRef([]),R=p.useRef(l),Se=p.useRef(null),[se,J]=p.useState(()=>tu(f.current,l)),Ne=p.useRef(se),[Ee,ie]=p.useState(()=>{var B,re;return(((re=(B=f.current)==null?void 0:B.items)==null?void 0:re.length)??0)===0}),[xe,lt]=p.useState(null),[Oe,bt]=p.useState(()=>Fd(sS(Hx,MO),Id,Gx)),[Ct,nt]=p.useState(()=>Fd(sS(zx,AO),Id,Kx)),[et,De]=p.useState(()=>iS(qx,!1)),[Ue,Ye]=p.useState(()=>iS($x,!1)),[ye,He]=p.useState(()=>oS(f.current)),[je,Fe]=p.useState(()=>aS(wf)),[Ve,kt]=p.useState(!1),[me,Me]=p.useState("files"),[Xe,ze]=p.useState(!1),[vt,ht]=p.useState(!1),[pe,$e]=p.useState(null),[Nt,Rt]=p.useState({}),[Ft,Wt]=p.useState(!1),[Kt,un]=p.useState("sessions"),[ae,Be]=p.useState(""),[It,jt]=p.useState(""),[Cn,on]=p.useState(!1),[Wn,Rn]=p.useState(null),[$t,dn]=p.useState([]),[gn,Z]=p.useState(null),[ce,ge]=p.useState({}),[Ce,We]=p.useState({}),[qe,Pt]=p.useState(null),[Ke,at]=p.useState(!1),[ft,ct]=p.useState([]),[oe,Re]=p.useState(()=>new Set),[_t,Ut]=p.useState(!1),[Qt,ln]=p.useState(!1),[jn,Jn]=p.useState(()=>aS(Vx));p.useEffect(()=>{te.current=i},[i]),p.useEffect(()=>{R.current=l,J(B=>R2(B,l))},[l]),p.useEffect(()=>{Ne.current=se},[se]),p.useEffect(()=>{K.current=s.bridge},[s.bridge]);const bn=p.useCallback(async()=>{const B=Y.current+1;Y.current=B;try{const re=await mm();if(B!==Y.current)return;if(!re.initialized){ct([]),Re(new Set);return}const[Te,Je,Dt,Mt]=await Promise.all([pm(),fm(),Nu(),oO()]);if(B!==Y.current)return;ct(zO(Te.overview,Je.items,Dt.items)),Re(new Set(Mt.items.map(Vt=>Vt.notificationId)))}catch{if(B!==Y.current)return;ct([]),Re(new Set)}},[]),Jt=p.useCallback(B=>{const re=B.map(Te=>Te.createdAt).sort((Te,Je)=>Wa(Je)-Wa(Te))[0]??null;re&&Jn(Te=>Te&&Wa(Te)>=Wa(re)?Te:re)},[]);p.useEffect(()=>{jn&&mo(Vx,jn)},[jn]),p.useEffect(()=>{bn();const B=window.setInterval(()=>{bn()},EO);return()=>{window.clearInterval(B)}},[bn]),p.useEffect(()=>{Ot("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),p.useEffect(()=>{var B,re;Ot("workbench.cached_snapshot_loaded",{cached:!!f.current,workspaceCount:((B=f.current)==null?void 0:B.items.length)??0,sessionCount:((re=f.current)==null?void 0:re.items.reduce((Te,Je)=>Te+Je.sessions.length,0))??0})},[]);function ur(B){var Je;if(!B||!Array.isArray(B.items))return;j2(w.current,B);const re=C2(B,w.current);Ot("workbench.apply_snapshot",{workspaceCount:re.items.length,sessionCount:re.items.reduce((Dt,Mt)=>Dt+Mt.sessions.length,0),currentSessionId:((Je=Uc(t.pathname))==null?void 0:Je.sessionId)??null});const Te=tu(re,R.current);f.current=re,Md(re),Ne.current=Te,J(Te),He(oS(re)),lt(null)}const vn=p.useCallback(async()=>{const B=v.current+1;v.current=B,ie(re=>re||!g.current),Ot("workbench.refresh_navigation.start",{requestId:B,hasNavigationData:g.current});try{const re=await rP();if(B!==v.current){Ot("workbench.refresh_navigation.stale",{requestId:B});return}ur(re)}catch(re){if(B!==v.current)return;lt(re instanceof Error?re.message:o("shell.navigationLoadFailed")),te.current({title:re instanceof Error?re.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{Ot("workbench.refresh_navigation.end",{requestId:B,success:B===v.current}),B===v.current&&ie(!1)}},[]),yn=p.useCallback(B=>{J(re=>{const Te=T2(re,B,R.current);return Ne.current=Te,Te})},[]),kn=p.useCallback(()=>{var B;(B=j.current)==null||B.requestRefresh()},[]),Nn=p.useCallback((B,re)=>{r(Yn(B,re))},[r]),xt=p.useCallback((B,re)=>{var Te;E.current={workspaceId:B,paths:re},(Te=j.current)==null||Te.subscribeFileTree(B,re)},[]),Zt=p.useCallback((B,re)=>{var Te;I.current={workspaceId:B,paths:re},(Te=j.current)==null||Te.requestFileTreeRefresh(B,re)},[]),we=p.useCallback(B=>(N.current.add(B),()=>{N.current.delete(B)}),[]),Ge=p.useCallback(B=>{var re;M.current=B,(re=j.current)==null||re.subscribeGit(B)},[]),St=p.useCallback(B=>{var re;_.current=B,(re=j.current)==null||re.requestGitRefresh(B)},[]),Sn=p.useCallback(B=>(D.current.add(B),()=>{D.current.delete(B)}),[]),_n=p.useCallback(B=>{var re;L.current=B,(re=j.current)==null||re.subscribeWorkspaceManagement(B)},[]),Vn=p.useCallback(B=>{var re;Q.current=B,ge(Te=>{var Je;return{...Te,[B]:{detail:((Je=Te[B])==null?void 0:Je.detail)??null,loading:!0,error:null}}}),(re=j.current)==null||re.requestWorkspaceManagementRefresh(B)},[]),zn=p.useCallback(B=>(F.current.add(B),()=>{F.current.delete(B)}),[]),rr=p.useCallback(async(B,re=!1)=>{const Te=B.trim();if(!Te)return;let Je=!0;if(We(Dt=>{const Mt=Dt[Te];return!re&&(Mt!=null&&Mt.loading)?(Je=!1,Dt):{...Dt,[Te]:{preview:(Mt==null?void 0:Mt.preview)??null,loading:!0,applying:(Mt==null?void 0:Mt.applying)??!1,cleaning:(Mt==null?void 0:Mt.cleaning)??!1,error:null}}}),!!Je)try{const Dt=await XF(Te);We(Mt=>{var Vt,Mn;return{...Mt,[Te]:{preview:Dt,loading:!1,applying:((Vt=Mt[Te])==null?void 0:Vt.applying)??!1,cleaning:((Mn=Mt[Te])==null?void 0:Mn.cleaning)??!1,error:null}}})}catch(Dt){We(Mt=>{var Vt,Mn,Pn;return{...Mt,[Te]:{preview:((Vt=Mt[Te])==null?void 0:Vt.preview)??null,loading:!1,applying:((Mn=Mt[Te])==null?void 0:Mn.applying)??!1,cleaning:((Pn=Mt[Te])==null?void 0:Pn.cleaning)??!1,error:Dt instanceof Error?Dt.message:o("shell.worktreeMergePreviewFailed")}}})}},[]),Gn=p.useCallback(async B=>{const re=B.trim();if(re){We(Te=>{var Je,Dt;return{...Te,[re]:{preview:((Je=Te[re])==null?void 0:Je.preview)??null,loading:!1,applying:!0,cleaning:((Dt=Te[re])==null?void 0:Dt.cleaning)??!1,error:null}}});try{const Te=await QF(re);We(Je=>{var Dt;return{...Je,[re]:{preview:Te.preview,loading:!1,applying:!1,cleaning:((Dt=Je[re])==null?void 0:Dt.cleaning)??!1,error:null}}}),kn(),vn(),rr(re,!0),St(Te.preview.targetWorkspace.id),te.current({title:Te.applied?o("shell.worktreeMergeApplySuccess"):o("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(Te){We(Je=>{var Dt,Mt;return{...Je,[re]:{preview:((Dt=Je[re])==null?void 0:Dt.preview)??null,loading:!1,applying:!1,cleaning:((Mt=Je[re])==null?void 0:Mt.cleaning)??!1,error:Te instanceof Error?Te.message:o("shell.worktreeMergeApplyFailed")}}}),te.current({title:Te instanceof Error?Te.message:o("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[rr,vn,St,kn]),xr=p.useCallback(async B=>{var Je,Dt;const re=B.workspaceId,Te=Ke&&((Dt=(Je=Ce[re])==null?void 0:Je.preview)==null?void 0:Dt.alreadyMerged)===!0;We(Mt=>{var Vt;return{...Mt,[re]:{preview:((Vt=Mt[re])==null?void 0:Vt.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const Mt=await JF(re,{deleteBranch:Te});if(We(Vt=>{var Mn;return{...Vt,[re]:{preview:((Mn=Vt[re])==null?void 0:Mn.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),at(!1),Pt(Vt=>(Vt==null?void 0:Vt.workspaceId)===re?null:Vt),kn(),await vn(),r(Ms(B.parentWorkspaceId),{replace:!0}),Mt.branchDeleted){te.current({title:o("shell.worktreeCleanupDeleteBranchSuccess",{branch:Mt.deletedBranchName||B.branchName}),tone:"success"});return}if(Mt.branchDeleteRequested){te.current({title:o("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:B.branchName}),description:Mt.branchDeleteError||void 0,tone:"warning"});return}te.current({title:o("shell.worktreeCleanupSuccess"),tone:"success"})}catch(Mt){We(Vt=>{var Mn;return{...Vt,[re]:{preview:((Mn=Vt[re])==null?void 0:Mn.preview)??null,loading:!1,applying:!1,cleaning:!1,error:Mt instanceof Error?Mt.message:o("shell.worktreeCleanupFailed")}}}),te.current({title:Mt instanceof Error?Mt.message:o("shell.worktreeCleanupFailed"),tone:"error"})}},[Ke,r,vn,kn,Ce]),Kr=p.useCallback(B=>{at(!1),Pt(B)},[]),Yr=p.useCallback(B=>{var re;O.current=B,(re=j.current)==null||re.subscribeTerminalManager(B)},[]),Xr=p.useCallback(B=>{var re;ne.current=B,(re=j.current)==null||re.requestTerminalManagerRefresh(B)},[]),Lr=p.useCallback(B=>(W.current.add(B),()=>{W.current.delete(B)}),[]),es=p.useCallback((B,re)=>{J(Te=>N2(Te,B,re??new Date().toISOString()))},[]),sr=p.useCallback(async(B,re)=>{w.current.set(B,re),J(Te=>uS(Te,B,re));try{const Te=await lP(B,re),Je=Hi(Te);Je===re?w.current.set(B,Je):w.current.delete(B),yn(Te),kn(),vn()}catch(Te){throw w.current.delete(B),J(Je=>uS(Je,B,!re)),Te}},[vn,kn,yn]),Hr=p.useCallback((B,re)=>{Ot("workbench.set_session_workspace",{sessionId:B,workspaceId:re}),Rt(Te=>{if(!re){if(!(B in Te))return Te;const Je={...Te};return delete Je[B],Je}return Te[B]===re?Te:{...Te,[B]:re}})},[]);p.useEffect(()=>{g.current=se.length>0},[se]),p.useEffect(()=>{Ot("workbench.navigation_state",{navigationLoading:Ee,workspaceCount:se.length,sessionCount:se.reduce((B,re)=>B+re.sessions.length,0)})},[se,Ee]),p.useEffect(()=>{T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{var Ht;T.current=null,!(k.current||g.current)&&(Ot("workbench.refresh_navigation.ws_fallback_triggered"),(Ht=j.current)==null||Ht.requestRefresh())},1200);const B=new $N({onConnectionChange:Ht=>{Ht==="connected"&&FP(),Ht==="reconnect_failed"&&!g.current&&(lt(o("shell.navigationLoadFailed")),te.current({id:"workbench-navigation-connection",title:o("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:Ht=>{k.current=!0,Ot("workbench.ws_snapshot_received",{workspaceCount:Ht.items.length,sessionCount:Ht.items.reduce((jr,bs)=>jr+bs.sessions.length,0)}),T.current!==null&&(window.clearTimeout(T.current),T.current=null),ur(Ht),ie(!1)},onFileTreeSnapshot:Ht=>{N.current.forEach(jr=>jr(Ht))},onGitSnapshot:Ht=>{As(aD(Ht.workspaceId),{status:Ht.status,history:Ht.history,historyTotalCount:Ht.historyTotalCount,historyNextCursor:Ht.historyNextCursor,branches:Ht.branches}),ge(jr=>{var Pi;const bs=((Pi=se.find(Vl=>Vl.workspace.id===Ht.workspaceId))==null?void 0:Pi.workspace)??null;if(!bs)return jr;const ss=jr[Ht.workspaceId],_s=cD(lD((ss==null?void 0:ss.detail)??oD(bs),bs),Ht);return As(Zg(Ht.workspaceId),_s),{...jr,[Ht.workspaceId]:{detail:_s,loading:!1,error:null}}}),D.current.forEach(jr=>jr(Ht))},onWorkspaceManagementSnapshot:Ht=>{As(Zg(Ht.workspaceId),Ht),ge(jr=>({...jr,[Ht.workspaceId]:{detail:Ht,loading:!1,error:null}})),F.current.forEach(jr=>jr(Ht))},onTerminalManagerSnapshot:Ht=>{W.current.forEach(jr=>jr(Ht))},onUnauthorized:()=>{br.clear(),r("/login",{replace:!0})}});j.current=B;const re=E.current,Te=I.current,Je=M.current,Dt=_.current,Mt=L.current,Vt=Q.current,Mn=O.current,Pn=ne.current;return re&&B.subscribeFileTree(re.workspaceId,re.paths),Je&&B.subscribeGit(Je),Mt&&B.subscribeWorkspaceManagement(Mt),Mn&&B.subscribeTerminalManager(Mn),Te&&B.requestFileTreeRefresh(Te.workspaceId,Te.paths),Dt&&B.requestGitRefresh(Dt),Vt&&B.requestWorkspaceManagementRefresh(Vt),Pn&&B.requestTerminalManagerRefresh(Pn),B.start(),()=>{T.current!==null&&(window.clearTimeout(T.current),T.current=null),j.current===B&&(j.current=null),B.close()}},[r]),p.useEffect(()=>{mo(Hx,String(Oe))},[Oe]),p.useEffect(()=>{mo(zx,String(Ct))},[Ct]),p.useEffect(()=>{mo(qx,String(et))},[et]),p.useEffect(()=>{mo($x,String(Ue))},[Ue]),p.useEffect(()=>{if(!je){g2(wf);return}mo(wf,je)},[je]),p.useEffect(()=>{if(Ve||Ue)return;const B=window.setTimeout(()=>{kt(!0)},IO);return()=>{window.clearTimeout(B)}},[Ve,Ue]);const dr=Uc(t.pathname),wt=(dr==null?void 0:dr.sessionId)??null,ir=wt?gD(wt):!1,tn=p.useMemo(()=>_N(se),[se]),hr=p.useMemo(()=>new Set(ye),[ye]),ar=p.useMemo(()=>tn.filter(B=>B.session.isFavorite===!0).map(B=>B.session.sessionId),[tn]),ue=p.useMemo(()=>new Set(ar),[ar]),Qe=p.useCallback(B=>{const re=xf(B,ye);f.current=re,Md(re),Ne.current=B,J(B)},[ye]),yt=p.useCallback(B=>{const re=!hr.has(B),Te=hS(ye,B,re),Je=xf(se,Te);f.current=Je,Md(Je),He(Te),iP(B,{collapsed:re}).catch(Dt=>{const Mt=hS(Te,B,!re),Vt=xf(se,Mt);f.current=Vt,Md(Vt),He(Mt),te.current({title:Dt instanceof Error?Dt.message:o("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[hr,ye,se]),Lt=p.useCallback(()=>{Se.current={originalGroups:Ne.current}},[]),fn=p.useCallback((B,re,Te)=>{const Je=Ne.current,Dt=S2(Je,B,re,Te);Dt!==Je&&Qe(Dt)},[Qe]),mn=p.useCallback(()=>{const B=Se.current;Se.current=null;const re=Ne.current;B&&(B.originalGroups.length===re.length&&B.originalGroups.every((Te,Je)=>{var Dt;return Te.workspace.id===((Dt=re[Je])==null?void 0:Dt.workspace.id)})||zF({workspaceIds:re.map(Te=>Te.workspace.id)}).catch(Te=>{Qe(B.originalGroups),te.current({title:Te instanceof Error?Te.message:o("shell.workspaceReorderFailed"),tone:"error"})}))},[Qe]);p.useEffect(()=>{const B=new Map;if(tn.forEach(({session:re})=>{B.set(re.sessionId,{activityState:re.activityState,completedAt:re.completedAt??null,runningState:re.runningState??null})}),!z.current){z.current=!0,q.current=B;return}tn.forEach(({session:re})=>{var Vt;if(re.sessionId===wt)return;const Te=q.current.get(re.sessionId);if(!Te)return;const Je=Te.activityState!=="completed_unread"&&re.activityState==="completed_unread",Dt=((Vt=re.title)==null?void 0:Vt.trim())||o("common.unknown");if(d&&Je){const Mn=o("conversation.backgroundCompletionToastDescription",{title:Dt});te.current({id:`workbench-session-completed-${re.sessionId}-${re.completedAt??"unknown"}`,title:o("conversation.backgroundCompletionToastTitle"),description:Mn,tone:"success",durationMs:8e3,action:{label:o("shell.contextOpenSession"),onClick:()=>Nn(re.workspaceId,re.sessionId)}}),K.current.showNotification(o("conversation.backgroundCompletionToastTitle"),Mn)}const Mt=Te.runningState!=="failed"&&(re.runningState??null)==="failed";if(m&&Mt){const Mn=HO(re)??o("conversation.runtimeFailed"),Pn=o("conversation.backgroundFailureToastDescription",{title:Dt,detail:Mn});te.current({id:`workbench-session-failed-${re.sessionId}-${re.updatedAt}`,title:o("conversation.backgroundFailureToastTitle"),description:Pn,tone:"error",durationMs:8e3,action:{label:o("shell.contextOpenSession"),onClick:()=>Nn(re.workspaceId,re.sessionId)}}),K.current.showNotification(o("conversation.backgroundFailureToastTitle"),Pn)}}),q.current=B},[wt,tn,d,m,Nn]),p.useEffect(()=>{X.current=tn.map(B=>B.session).filter(B=>B.sessionId!==wt&&UO(B)).map(B=>{var re;return{sessionId:B.sessionId,workspaceId:B.workspaceId,title:((re=B.title)==null?void 0:re.trim())||o("common.unknown")}})},[wt,tn]),p.useEffect(()=>{let B=!1,re=null;const Te=()=>{re=window.setTimeout(()=>{Je().finally(()=>{B||Te()})},FO)},Je=async()=>{var Mn;const Dt=X.current;if(Dt.length===0){P.current||(P.current=!0);return}(Mn=j.current)==null||Mn.requestRefresh();const Mt=new Set(Dt.map(Pn=>Pn.sessionId)),Vt=await Promise.all(Dt.map(async Pn=>{try{const Ht=await cP(Pn.sessionId);return{session:Pn,items:Ht.items}}catch{return{session:Pn,items:null}}}));if(!B){for(const Pn of Vt){if(!Pn.items)continue;const Ht=Pn.items.filter(ss=>ss.status==="pending"),jr=new Set(Ht.map(ss=>ss.id)),bs=U.current.get(Pn.session.sessionId)??new Set;P.current&&Ht.forEach(ss=>{if(bs.has(ss.id)||!c)return;const _s=o("conversation.backgroundPermissionToastDescription",{title:Pn.session.title,requestTitle:ss.title});te.current({id:`workbench-permission-request-${ss.id}`,title:o("conversation.permissionRequestToastTitle"),description:_s,tone:"warning",durationMs:8e3,action:{label:o("shell.contextOpenSession"),onClick:()=>Nn(Pn.session.workspaceId,Pn.session.sessionId)}}),K.current.showNotification(o("conversation.permissionRequestToastTitle"),_s)}),U.current.set(Pn.session.sessionId,jr)}for(const[Pn,Ht]of U.current.entries())!Mt.has(Pn)&&Ht.size===0&&U.current.delete(Pn);P.current=!0}};return Je().finally(()=>{B||Te()}),()=>{B=!0,re!==null&&window.clearTimeout(re)}},[c,Nn]),p.useEffect(()=>{if(Ee&&se.length===0)return;const B=new Set(se.map(re=>re.workspace.id));He(re=>nD(re,B)),Fe(re=>re&&B.has(re)?re:null)},[se,Ee]);const nn=tn.find(B=>B.session.sessionId===wt)??null,Un=(nn==null?void 0:nn.workspace.id)??(wt?Nt[wt]??null:null),Fr=Zx(t.pathname,t.search),zr=Un??Fr??je??null,Xt=zr??((fa=se[0])==null?void 0:fa.workspace.id)??null,Cr=p.useMemo(()=>ft.filter(B=>!oe.has(B.id)),[oe,ft]),V=p.useMemo(()=>Cr.filter(B=>YO(B,jn)).length,[Cr,jn]);p.useEffect(()=>{_t&&Jt(Cr)},[Cr,Jt,_t]);const fe=p.useCallback(B=>{Ut(!1),B.routePath&&r(B.routePath)},[r]),ve=p.useCallback(async(B,re)=>{const Te=G.current+1;G.current=Te;try{const Je=await lO(B,re);if(Te!==G.current)return;Re(Dt=>{const Mt=new Set(Dt);return Je.item?Mt.add(Je.item.notificationId):Mt.delete(B),Mt})}catch(Je){if(Te!==G.current)return;te.current({title:o("shell.globalNotificationsArchiveFailed"),description:Je instanceof Error?Je.message:void 0,tone:"error"})}},[]);p.useEffect(()=>{Un&&Fe(B=>B===Un?B:Un)},[Un]),p.useEffect(()=>{Ot("workbench.current_workspace_resolved",{currentSessionId:wt,sessionWorkspaceId:Un,routeWorkspaceId:Fr,currentWorkspaceId:Xt,source:Un?nn?"navigation":"sessionWorkspaceMap":Fr?"route":je?"workspaceSelection":"navigationFallback"})},[nn,wt,Xt,Fr,je,Un]),p.useEffect(()=>{Ot("workbench.info_panel_state",{infoPanelReady:Ve,rightCollapsed:Ue,currentWorkspaceId:Xt,sessionWorkspaceId:Un,currentSessionId:wt})},[wt,Xt,Ve,Ue,Un]);const it=tS(t.pathname)?"terminals":kf(t.pathname)?"butler":"conversation",tt=e==="mobile",Tt=JO(e),cn=p.useMemo(()=>se.map(B=>{const re=$P(B.sessions);return{workspace:B.workspace,visibleSessions:re,archivedSessions:B.sessions.filter(Te=>Hi(Te)&&!gm(Te)),visibleSessionTree:Mv(re,l).filter(Te=>!ue.has(Te.item.sessionId)&&!lm(wi(Te),Je=>ue.has(Je.sessionId))),childWorktrees:YP(B.childWorktrees,ue,l),isCollapsed:hr.has(B.workspace.id)}}),[hr,ue,se,l]),In=p.useMemo(()=>hm(se),[se]),Hn=p.useMemo(()=>w2(se,Xt),[Xt,se]),ts=p.useMemo(()=>Xt?(Hn==null?void 0:Hn.workspace)??se.map(B=>B.workspace).find(B=>B.id===Xt)??null:null,[Xt,Hn,se]),gs=(Hn==null?void 0:Hn.meta)??null,or=(Xt?In[Xt]??null:null)??(ts?Tu(ts):null),Ls=gs?Ce[gs.workspaceId]??null:null,ns=p.useMemo(()=>tn.filter(B=>ue.has(B.session.sessionId)&&!Hi(B.session)&&!Qg(B.session)),[ue,tn]),mr=t.pathname.startsWith("/settings")?"settings":kf(t.pathname)?"terminals":tS(t.pathname)?"butler":e2(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":ZO(t.pathname)||eS(t.pathname)?"sessions":"workspaces",pa=tt&&(mr==="sessions"&&eS(t.pathname)||kf(t.pathname)),rs=cm({isNativeMobile:s.isNativeMobile,viewportClass:s.viewportClass}),ji=xu({viewportClass:s.viewportClass,activeEntry:mr,hasNavigationPanel:tt,hasAuxiliaryPanel:tt,preferCompactLayout:rs}),Qr=tt&&HN(ji),qr=tt&&zN(ji),ci=p.useMemo(()=>se.map(B=>B.workspace),[se]),ui=p.useMemo(()=>{const B=ae.trim().toLowerCase();return B?tn.filter(re=>{const Te=(re.session.title||"").toLowerCase(),Je=re.workspace.name.toLowerCase(),Dt=bm(re.session.provider,"full").toLowerCase();return Te.includes(B)||Je.includes(B)||Dt.includes(B)}):[]},[tn,ae]);p.useEffect(()=>{var re;const B=Xt??((re=se[0])==null?void 0:re.workspace.id)??"";B&&jt(Te=>Te&&se.some(Dt=>Dt.workspace.id===Te)?Te:B)},[Xt,se]),p.useEffect(()=>{wt&&!ir&&mo(vf,`${t.pathname}${t.search}`)},[wt,ir,t.pathname,t.search]),p.useEffect(()=>{if(wt&&ir){y.current=`${t.pathname}${t.search}`;return}wt&&!ir&&(y.current=null)},[wt,ir,t.pathname,t.search]),p.useEffect(()=>{tt||(ze(!1),ht(!1))},[tt]),p.useEffect(()=>{!tt||Ee||!QO(t.pathname)||zr||(ze(!1),ht(!1),r(Tt,{replace:!0}))},[zr,tt,t.pathname,r,Ee,Tt]);function Ti(){if(tt){ze(!0);return}De(!1)}function _r(){if(st(),tt){ht(!0);return}Ye(!1)}function $(){if(tt){ze(B=>!B);return}De(B=>!B)}function be(){if(st(),tt){ht(B=>!B);return}Ye(B=>!B)}function st(){kt(!0)}function At(B){Fe(B),st(),wt&&Un!==B&&r(Tt)}const en=p.useCallback(async B=>{var Je;const re=((Je=tn.find(Dt=>Dt.session.sessionId===B))==null?void 0:Je.session)??null,Te=(re==null?void 0:re.isFavorite)!==!0;J(Dt=>dS(Dt,B,Te));try{const Dt=await KF(B,Te);yn(Dt),kn()}catch(Dt){throw J(Mt=>dS(Mt,B,!Te)),Dt}},[tn,kn,yn]),ds=p.useCallback((B,re)=>{zP(B,re).then(()=>{r(ON(B,re))}).catch(Te=>{i({title:Te instanceof Error?Te.message:o("shell.startSessionFailed"),tone:"error"})})},[r,i]),Ni=p.useCallback(B=>{var Je;const re=((Je=B.workspaceId)==null?void 0:Je.trim())||Xt,Te=t2(B.filePath);return!re||!Te?!1:(st(),Me("files"),tt?(ze(!1),ht(!0)):Ye(!1),Z({requestId:C.current+1,workspaceId:re,filePath:Te,openViewer:B.openViewer===!0}),C.current+=1,!0)},[Xt,tt]),Gi=p.useCallback(async(B,re)=>{const Te=await oP(B,re.trim());return yn(Te),Te},[yn]);function Ki(B){Wt(!0)}function Ga(){Wt(!1),un("sessions"),Be(""),Rn(null),dn([]),on(!1)}async function _o(){const B=ae.trim();if(!B||!It.trim()){dn([]),Rn(null);return}on(!0),Rn(null);try{const re=await Ac(It,B);dn(re.items)}catch(re){dn([]),Rn(re instanceof Error?re.message:o("shell.searchCodeFailed"))}finally{on(!1)}}function Ka(B,re){const Te=B==="left"?Oe:Ct;function Je(Mt){const Vt=Mt.clientX-re;if(B==="left"){bt(Fd(Te+Vt,Id,Gx));return}nt(Fd(Te-Vt,Id,Kx))}function Dt(){document.removeEventListener("mousemove",Je),document.removeEventListener("mouseup",Dt)}document.addEventListener("mousemove",Je),document.addEventListener("mouseup",Dt)}function Fs(){if(Oo())return;if(tn.length===0){r(Tt);return}const B=Yn(tn[0].workspace.id,tn[0].session.sessionId);r(B)}function zl(){if(!Oo(Xt)){if(Xt){r(Si(Xt));return}r(Tt)}}function Oo(B){if(wt)return B&&Un&&Un!==B?!1:(r(`${t.pathname}${t.search}`),!0);if(y.current){if(B){const[Te,Je=""]=y.current.split("?"),Dt=Zx(Te??y.current,Je?`?${Je}`:"");if(Dt&&Dt!==B)return!1}return r(y.current),!0}const re=typeof window>"u"?null:window.localStorage.getItem(vf);if(re){const Te=re.split("?")[0]??re,Je=Uc(Te);if(Je){const Dt=Je.sessionId,Mt=tn.find(Pn=>Pn.session.sessionId===Dt)??null,Vt=Je.workspaceId??(Mt==null?void 0:Mt.workspace.id)??null;if(Mt!==null&&(!B||Vt===B))return r(re),!0}window.localStorage.removeItem(vf)}return!1}p.useEffect(()=>{if(typeof window>"u")return;function B(re){if(!(re.metaKey||re.ctrlKey)){re.key==="Escape"&&(ze(!1),ht(!1));return}if(b2(re.target))return;const Je=re.key.toLowerCase();if(!re.shiftKey&&Je==="b"){re.preventDefault(),$();return}if(re.shiftKey&&Je==="i"){re.preventDefault(),be();return}if(!re.shiftKey&&Je===","){re.preventDefault(),r("/settings");return}if(!re.shiftKey&&Je==="1"){re.preventDefault(),Fs();return}if(!re.shiftKey&&Je==="2"){re.preventDefault(),r(Xt?xo(Xt):Ts());return}if(!re.shiftKey&&Je==="k"){re.preventDefault(),v2();return}re.shiftKey&&Je==="r"&&(re.preventDefault(),vn())}return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B)}},[r,vn,tt,Fs]);const ql=p.useMemo(()=>({shellMode:e,navigationGroups:se,navigationLoading:Ee,navigationError:xe,currentWorkspaceId:Xt,currentSessionId:wt,favoriteSessionIds:ar,favoriteSessions:ns,globalNotifications:ft,archivedNotificationIds:Array.from(oe),showArchivedNotifications:Qt,unreadNotificationCount:V,refreshNavigation:vn,requestNavigationRefresh:kn,openNotificationPanel:()=>{Ut(!0)},closeNotificationPanel:()=>{Ut(!1)},setShowArchivedNotifications:ln,archiveNotification:B=>{ve(B,!0)},unarchiveNotification:B=>{ve(B,!1)},setAuxiliaryPanel:$e,subscribeFileTree:xt,requestFileTreeRefresh:Zt,addFileTreeSnapshotListener:we,subscribeGitSnapshot:Ge,requestGitRefresh:St,addGitSnapshotListener:Sn,subscribeWorkspaceManagementSnapshot:_n,requestWorkspaceManagementRefresh:Vn,addWorkspaceManagementSnapshotListener:zn,workspaceManagementStateById:ce,subscribeTerminalManagerSnapshot:Yr,requestTerminalManagerRefresh:Xr,addTerminalManagerSnapshotListener:Lr,selectWorkspace:At,toggleFavoriteSession:en,archiveSession:B=>sr(B,!0),unarchiveSession:B=>sr(B,!1),renameSession:Gi,startDraftSession:ds,markNavigationSessionSeen:es,upsertNavigationSession:yn,setSessionWorkspace:Hr,revealWorkspaceFile:Ni}),[we,Sn,zn,Lr,sr,wt,Xt,ft,ar,ns,At,oe,es,xe,se,Ee,V,Zt,St,Vn,vn,kn,ln,$e,Xr,Gi,Qt,ce,e,ds,Hr,xt,Ge,_n,Yr,ve,en,yn,Ni]),$l={"--workbench-left-width":`${Oe}px`,"--workbench-left-current-width":et?"0px":`${Oe}px`,"--workbench-right-width":`${Ct}px`,"--workbench-right-current-width":Ue?"0px":`${Ct}px`},Bo=it==="butler"?pe:n.jsx(fS,{panelReady:Ve,activeTab:me,fileRevealRequest:gn,onTabChange:B=>{st(),Me(B)},currentSessionId:ir?null:wt,activeWorkspaceId:Xt,navigationGroups:se,workspaceContext:or,worktreeMeta:gs,worktreeMergeState:Ls,onRefreshWorktreeMergePreview:rr,onApplyWorktreeMerge:Gn,onCleanupWorktree:xr}),Yi=Bo!==null,Wo=tt?n.jsx(pS,{workspaceGroups:cn,workspaceVisualContextMap:In,sessionDisplaySortMode:l,favoriteSessions:ns,favoriteSessionIds:ue,activeWorkspaceId:Xt,isConversationActive:it==="conversation",isTerminalActive:it==="terminals",isButlerActive:it==="butler",isSearchOpen:Ft,navigationLoading:Ee,navigationError:xe,activeSessionId:wt,onRefreshNavigation:vn,onSessionUpdated:yn,onNavigateConversation:Fs,onNavigateTerminals:()=>{ze(!1),r(Xt?xo(Xt):Ts())},onNavigateButler:()=>{ze(!1),r(Xt?Ui(Xt):Ts())},onOpenSearch:()=>{ze(!1),Ki()},onOpenSettings:()=>{ze(!1),r("/settings")},onSelectWorkspace:At,onToggleWorkspaceCollapse:yt,onStartWorkspaceReorder:Lt,onPreviewWorkspaceReorder:fn,onCommitWorkspaceReorder:mn,allowWorkspaceReorder:!1,subscribeGitSnapshot:Ge,requestGitRefresh:St,subscribeWorkspaceManagementSnapshot:_n,requestWorkspaceManagementRefresh:Vn,onToggleFavoriteSession:en,onArchiveSession:B=>sr(B,!0),onUnarchiveSession:B=>sr(B,!1),workspaceManagementStateById:ce,setWorkspaceManagementStateById:ge,unreadNotificationCount:V,notificationPanelOpen:_t,onToggleNotificationPanel:()=>{Ut(B=>!B)},onClose:()=>ze(!1)}):null,Uo=tt&&Yi?Bo:null;return n.jsxs(qP.Provider,{value:ql,children:[tt?n.jsx(n.Fragment,{children:n.jsx(nF,{activeEntry:mr,presentation:pa?"conversation-focus":"default",navigationPanel:Wo,auxiliaryPanel:Uo,onOpenNavigation:()=>{ht(!1),ze(!0)},onOpenSearch:()=>{ze(!1),ht(!1),Ki()},onOpenAuxiliary:()=>{Yi&&(st(),ze(!1),ht(!0))},onNavigateWorkspaces:()=>{ze(!1),ht(!1),r(Ts())},onNavigateTerminals:()=>{ze(!1),ht(!1),r(Xt?xo(Xt):Ts())},onNavigateButler:()=>{ze(!1),ht(!1),r(Xt?Ui(Xt):Ts())},onNavigateSessions:()=>{ze(!1),ht(!1),zl()},onNavigateToolFiles:()=>{ze(!1),ht(!1),r(Xt?LN(Xt):Ts())},onNavigateToolGit:()=>{ze(!1),ht(!1),r(Xt?FN(Xt):Ts())},onNavigateToolProcesses:()=>{ze(!1),ht(!1),r(Xt?Xb(Xt):Ts())},onNavigateSettings:()=>{ze(!1),ht(!1),r("/settings")},children:n.jsx(Ug,{})})}):n.jsx("div",{className:"workbench-shell",style:$l,"data-nav-loading":Ee,"data-left-collapsed":et,"data-right-collapsed":Ue,"data-info-ready":Ve,"data-runtime-platform":s.platform,"data-os-family":s.ui.osFamily,"data-overlay-titlebar":s.ui.prefersOverlayTitlebar,children:n.jsxs("div",{className:"workbench-body-shell",children:[n.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":et,children:n.jsx(pS,{workspaceGroups:cn,workspaceVisualContextMap:In,sessionDisplaySortMode:l,favoriteSessions:ns,favoriteSessionIds:ue,activeWorkspaceId:Xt,isConversationActive:it==="conversation",isTerminalActive:it==="terminals",isButlerActive:it==="butler",isSearchOpen:Ft,navigationLoading:Ee,navigationError:xe,activeSessionId:wt,onRefreshNavigation:vn,onSessionUpdated:yn,onNavigateConversation:Fs,onNavigateTerminals:()=>r(Xt?xo(Xt):Ts()),onNavigateButler:()=>r(Xt?Ui(Xt):Ts()),onOpenSearch:()=>Ki(),onOpenSettings:()=>r("/settings"),onSelectWorkspace:At,onToggleWorkspaceCollapse:yt,onStartWorkspaceReorder:Lt,onPreviewWorkspaceReorder:fn,onCommitWorkspaceReorder:mn,allowWorkspaceReorder:!0,subscribeGitSnapshot:Ge,requestGitRefresh:St,subscribeWorkspaceManagementSnapshot:_n,requestWorkspaceManagementRefresh:Vn,onToggleFavoriteSession:en,onArchiveSession:B=>sr(B,!0),onUnarchiveSession:B=>sr(B,!1),workspaceManagementStateById:ce,setWorkspaceManagementStateById:ge,unreadNotificationCount:V,notificationPanelOpen:_t,onToggleNotificationPanel:()=>{Ut(B=>!B)},onToggleCollapse:()=>De(!0)})}),n.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":et,role:"separator","aria-label":o("shell.leftResizerLabel"),onMouseDown:et?void 0:B=>Ka("left",B.clientX)}),n.jsxs("div",{className:"workbench-main-shell",children:[n.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!et&&!Ue,children:[n.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":et,children:[n.jsx(mS,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:o("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:Ti}),n.jsx(BP,{collapsed:!0}),n.jsx(dD,{unreadCount:V,open:_t,onToggle:()=>{Ut(B=>!B)},collapsed:!0}),n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button workbench-collapsed-button","aria-label":o("shell.goBack"),title:o("shell.goBack"),onClick:()=>r(-1),children:n.jsx(hD,{})}),n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button workbench-collapsed-button","aria-label":o("shell.goForward"),title:o("shell.goForward"),onClick:()=>r(1),children:n.jsx(mD,{})})]}),Yi?n.jsx("div",{className:"workbench-collapsed-controls right","data-visible":Ue,children:n.jsx(mS,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:o("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:_r})}):null]}),n.jsx(Ug,{})]}),Yi?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Ue,role:"separator","aria-label":o("shell.rightResizerLabel"),onMouseDown:Ue?void 0:B=>Ka("right",B.clientX)}),n.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(or==null?void 0:or.tone)??"root","data-worktree-depth":(or==null?void 0:or.depth)??0,"data-collapsed":Ue,"data-custom-panel":it==="butler",style:ri(or),children:it==="butler"?n.jsx("div",{className:"workbench-auxiliary-custom-panel",children:pe}):n.jsx(fS,{panelReady:Ve,activeTab:me,fileRevealRequest:gn,onTabChange:B=>{st(),Me(B)},onToggleCollapse:()=>Ye(!0),currentSessionId:ir?null:wt,activeWorkspaceId:Xt,navigationGroups:se,workspaceContext:or,worktreeMeta:gs,worktreeMergeState:Ls,onRefreshWorktreeMergePreview:rr,onApplyWorktreeMerge:Gn,onCleanupWorktree:Kr})})]}):null]})}),n.jsx(F2,{open:_t,notifications:ft,archivedNotificationIds:oe,showArchivedNotifications:Qt,onClose:()=>Ut(!1),onToggleShowArchivedNotifications:ln,onArchiveNotification:B=>{ve(B,!0)},onUnarchiveNotification:B=>{ve(B,!1)},onSelectNotification:fe,preferredWorkspaceId:Xt,preferredSessionId:ir?null:wt}),n.jsx(Q2,{open:Ft,mode:Kt,keyword:ae,codeWorkspaceId:It,codeResults:$t,codeLoading:Cn,codeError:Wn,workspaceOptions:ci,sessionResults:ui,onClose:Ga,onModeChange:B=>{un(B),Rn(null),dn([])},onKeywordChange:B=>{Be(B),Kt==="code"&&!B.trim()&&(dn([]),Rn(null))},onCodeWorkspaceChange:B=>jt(B),onCodeSearch:()=>{_o()},onOpenSession:B=>{Ga();const re=tn.find(Te=>Te.session.sessionId===B)??null;r(re?Yn(re.workspace.id,B):Ts())}}),n.jsxs(Ln,{open:qe!==null,title:o("shell.worktreeCleanupModalTitle"),description:o("shell.worktreeCleanupModalDescription"),onClose:()=>{var B;qe&&((B=Ce[qe.workspaceId])!=null&&B.cleaning)||(at(!1),Pt(null))},children:[n.jsx("p",{className:"workbench-section-empty",children:qe?o("shell.worktreeCleanupConfirm",{name:qe.displayName||qe.branchName}):""}),qe?n.jsxs("div",{className:"worktree-cleanup-modal-options",children:[n.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[n.jsx("input",{type:"checkbox",checked:Ke,disabled:!!((qo=Ce[qe.workspaceId])!=null&&qo.cleaning)||(($o=(Ya=Ce[qe.workspaceId])==null?void 0:Ya.preview)==null?void 0:$o.alreadyMerged)!==!0,onChange:B=>at(B.target.checked)}),n.jsx("span",{children:o("shell.worktreeCleanupDeleteBranchLabel",{branch:qe.branchName})})]}),((Xa=(Vs=Ce[qe.workspaceId])==null?void 0:Vs.preview)==null?void 0:Xa.alreadyMerged)!==!0?n.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:o("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!(qe&&((H=Ce[qe.workspaceId])!=null&&H.cleaning)),onClick:()=>{at(!1),Pt(null)},children:o("common.cancel")}),n.jsx("button",{type:"button",className:Ke&&qe&&((Ae=(de=Ce[qe.workspaceId])==null?void 0:de.preview)==null?void 0:Ae.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!qe||!!(qe&&((dt=Ce[qe.workspaceId])!=null&&dt.cleaning)),onClick:()=>{qe&&xr(qe)},children:qe&&((mt=Ce[qe.workspaceId])!=null&&mt.cleaning)?o("shell.worktreeCleanupRunning"):Ke&&qe&&((zt=(pn=Ce[qe.workspaceId])==null?void 0:pn.preview)==null?void 0:zt.alreadyMerged)===!0?o("shell.worktreeCleanupDeleteBranchAction"):o("shell.worktreeCleanupAction")})]})]}),tt?n.jsxs(n.Fragment,{children:[Qr?null:n.jsx(gS,{isOpen:Xe,side:"left",onClose:()=>ze(!1),children:Wo}),qr?null:n.jsx(gS,{isOpen:vt,side:"right",onClose:()=>ht(!1),children:Uo})]}):null]})}function gS({isOpen:e,side:t,onClose:r,children:s,className:i,overlayClassName:l}){if(!e)return null;const c=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:["mobile-nav-overlay","open",l].filter(Boolean).join(" "),onClick:r,role:"button",tabIndex:0,"aria-label":o("common.back"),onKeyDown:d=>{d.key==="Escape"&&r()}}),n.jsx("div",{className:["mobile-nav-drawer",t,"open",i].filter(Boolean).join(" "),children:s})]});return typeof document>"u"?c:$n.createPortal(c,document.body)}function Pr(){return p.useContext(qP)??{navigationGroups:[],navigationLoading:!1,navigationError:null,shellMode:"desktop",currentWorkspaceId:null,currentSessionId:null,favoriteSessionIds:[],favoriteSessions:[],globalNotifications:[],archivedNotificationIds:[],showArchivedNotifications:!1,unreadNotificationCount:0,refreshNavigation:async()=>{},requestNavigationRefresh:()=>{},openNotificationPanel:()=>{},closeNotificationPanel:()=>{},setShowArchivedNotifications:()=>{},archiveNotification:()=>{},unarchiveNotification:()=>{},setAuxiliaryPanel:()=>{},subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{},subscribeWorkspaceManagementSnapshot:()=>{},requestWorkspaceManagementRefresh:()=>{},addWorkspaceManagementSnapshotListener:()=>()=>{},workspaceManagementStateById:{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{},selectWorkspace:()=>{},toggleFavoriteSession:async()=>{},archiveSession:async()=>{},unarchiveSession:async()=>{},renameSession:async()=>{throw new Error("workbench shell unavailable")},startDraftSession:()=>{},setSessionWorkspace:()=>{},upsertNavigationSession:()=>{},markNavigationSessionSeen:()=>{},revealWorkspaceFile:()=>!1}}function gD(e){return e.startsWith("draft-")}function Sf(e,t){if(!e)return{allowed:!1,hidden:!1,reason:o("conversation.capabilityDenied")};switch(t){case"send_message":return e.canSendMessage===!1?{allowed:!1,hidden:!1,reason:o("conversation.capabilitySendDisabled")}:{allowed:!0,hidden:!1,reason:null};case"attachments":return e.supportsAttachments?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:o("conversation.capabilityAttachmentDisabled")};case"interrupt":return e.supportsInterrupt?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:o("conversation.capabilityInterruptDisabled")};default:return{allowed:!1,hidden:!1,reason:o("conversation.capabilityDenied")}}}const rB=new Set(["updateplan"]),bD=new Set(["todowrite"]),eb=new Set(["todoread"]),vD=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function sB(e,t){const r=aB(e,t);return r||oB(e,t)}function wD(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function iB(e,t,r){if(!e)return null;if(tb(e.name)){const c=Tl(e);if(!c||!ym(c.value))return null;const d=yD(c.value,r);return!d||d.items.length===0?null:{provider:t,source:"plan",explanation:d.explanation,items:d.items,updatedAt:r}}const s=wm(e.name);if(!bD.has(s)&&!eb.has(s)&&!vD.has(s))return null;const i=Tl(e,(eb.has(s),"prefer-output"));if(!i)return null;if(s==="taskdelete"||s==="taskremove"){const c=kD(i.value);return c.length>0?{provider:t,source:"todo",explanation:null,items:c.map((d,m)=>({id:d,title:`Task ${m+1}`,status:"cancelled",detail:d,updatedAt:r})),updatedAt:r}:null}const l=Fc(i.value,r);return l.length===0?null:{provider:t,source:tb(e.name)?"plan":"todo",explanation:null,items:l,updatedAt:r}}function aB(e,t){let r=null;for(const s of e){const i=s.toolCall;if(!i||wm(i.name)===""||!tb(i.name))continue;const l=Tl(i);if(!l||typeof l.value!="object"||l.value===null)continue;const c=yD(l.value,s.timestamp);!c||c.items.length===0||(r={provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:s.timestamp})}return r}function oB(e,t){const r=new Map;let s=null;for(const l of e){const c=l.toolCall;if(!c)continue;const d=wm(c.name);if(bD.has(d)){const v=Tl(c),g=v?Fc(v.value,l.timestamp):[];g.length>0&&(Cf(r,g),s=l.timestamp);continue}if(eb.has(d)){const v=Tl(c,"prefer-output"),g=v?Fc(v.value,l.timestamp):[];g.length>0&&(Cf(r,g),s=l.timestamp);continue}if(!vD.has(d))continue;const m=Tl(c,"prefer-output");if(!m)continue;if(d==="tasklist"||d==="taskget"){const v=Fc(m.value,l.timestamp);v.length>0&&(Cf(r,v),s=l.timestamp);continue}if(d==="taskdelete"||d==="taskremove"){const v=kD(m.value);if(v.length>0){for(const g of v)r.delete(g);s=l.timestamp}continue}const f=Fc(m.value,l.timestamp);if(f.length!==0){for(const v of f)cB(r,v);s=l.timestamp}}const i=Array.from(r.values()).sort((l,c)=>l.updatedAt.localeCompare(c.updatedAt)).map(l=>({...l}));return i.length===0||!s?null:{provider:t,source:"todo",explanation:null,items:i,updatedAt:s}}function tb(e){return rB.has(wm(e))}function yD(e,t){const r=Array.isArray(e.plan)?e.plan:null;if(!r||r.length===0)return null;const s=r.map((i,l)=>xD(i,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${l+1}`,fallbackStatus:"pending",updatedAt:t})).filter(i=>i!==null);return s.length===0?null:{items:s,explanation:kr(e.explanation)}}function Tl(e,t="prefer-input"){const r=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const s of r){const i=lB(s.text);if(i!==null)return{value:i,source:s.source}}return null}function lB(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const r=Od(t);if(r!==null)return r;const s=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(s!=null&&s[1]){const m=Od(s[1].trim());if(m!==null)return m}const i=t.indexOf("{"),l=t.lastIndexOf("}");if(i>=0&&l>i){const m=Od(t.slice(i,l+1));if(m!==null)return m}const c=t.indexOf("["),d=t.lastIndexOf("]");return c>=0&&d>c?Od(t.slice(c,d+1)):null}function Od(e){try{return JSON.parse(e)}catch{return null}}function Fc(e,t){return Hc(e).map((s,i)=>xD(s,{fallbackIdPrefix:"task",fallbackTitle:`Task ${i+1}`,fallbackStatus:"pending",updatedAt:t})).filter(s=>s!==null)}function Hc(e){if(Array.isArray(e))return e.flatMap(r=>Hc(r));if(!ym(e))return[];if(mB(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const r of t){if(!(r in e))continue;const s=Hc(e[r]);if(s.length>0)return s}return Object.values(e).flatMap(r=>Hc(r))}function kD(e){const r=Hc(e).map(i=>nb(i)).filter(i=>i!==null);if(r.length>0)return r;if(!ym(e))return[];const s=nb(e);return s?[s]:[]}function xD(e,t){if(!ym(e))return null;const r=kr(e.step)??kr(e.title)??kr(e.content)??kr(e.task)??kr(e.text)??kr(e.name)??kr(e.subject)??kr(e.description)??t.fallbackTitle,s=nb(e)??hB(t.fallbackIdPrefix,r),i=dB(e,r);return{id:s,title:r,status:uB(e.status,t.fallbackStatus),detail:i,updatedAt:t.updatedAt}}function cB(e,t){const r=e.get(t.id);if(!r){e.set(t.id,{...t});return}e.set(t.id,{id:r.id,title:t.title||r.title,status:t.status,detail:t.detail??r.detail,updatedAt:t.updatedAt})}function Cf(e,t){e.clear();for(const r of t)e.set(r.id,{...r})}function uB(e,t){var s;const r=(s=kr(e))==null?void 0:s.toLowerCase().replace(/[\s-]+/g,"_");return r?["pending","todo","open","queued","not_started","created"].includes(r)?"pending":["in_progress","progress","active","doing","running","started"].includes(r)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(r)?"completed":["failed","error","errored"].includes(r)?"failed":["cancelled","canceled","aborted","skipped"].includes(r)?"cancelled":t:t}function dB(e,t){const r=[kr(e.detail),kr(e.details),kr(e.description),kr(e.reason),kr(e.summary),kr(e.note),kr(e.priority)].filter(s=>s!==null);for(const s of r)if(s!==t)return s;return null}function nb(e){return kr(e.id)??kr(e.taskId)??kr(e.task_id)??kr(e.uuid)??kr(e.key)}function hB(e,t){return`${e}:${t.trim().toLowerCase()}`}function mB(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>kr(t)!==null)}function wm(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function ym(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function kr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function pB(){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),n.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function fB(){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),n.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),n.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),n.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),n.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function gB(){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),n.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function bB(){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),n.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),n.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),n.jsx("path",{d:"M8.2 5h3.6"}),n.jsx("path",{d:"M10 7.2v4.6"}),n.jsx("path",{d:"M7.3 6.8l1.7 4"}),n.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function vB({expanded:e}){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("path",{d:"M4 6.5h8"}),n.jsx("path",{d:"M4 10h8"}),n.jsx("path",{d:"M4 13.5h5"}),e?n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 12.8V7.2"}),n.jsx("path",{d:"M11.8 9.4L14 7.2l2.2 2.2"})]}):n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 7.2v5.6"}),n.jsx("path",{d:"M11.8 10.6L14 12.8l2.2-2.2"})]})]})}function wB(){return n.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[n.jsx("path",{d:"M4.5 5.5h1.2"}),n.jsx("path",{d:"M8 5.5h7.5"}),n.jsx("path",{d:"M4.5 10h1.2"}),n.jsx("path",{d:"M8 10h7.5"}),n.jsx("path",{d:"M4.5 14.5h1.2"}),n.jsx("path",{d:"M8 14.5h7.5"}),n.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),n.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const bS={in_progress:0,failed:1,pending:2,completed:3,cancelled:4};function yB({provider:e,messages:t,variant:r="header"}){const[s,i]=p.useState(!1),l=p.useMemo(()=>sB(t,e),[t,e]);if(!l||l.items.length===0)return null;const c=wD(l.items),d=c.in_progress||c.pending,m=d>0?d:l.items.length,f=[...l.items].sort((g,w)=>{const k=bS[g.status]-bS[w.status];return k!==0?k:g.updatedAt.localeCompare(w.updatedAt)}),v=r==="composer"?"conversation-task-progress-button composer-task-progress-button":"conversation-header-ai-button conversation-task-progress-button";return n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:v,"data-variant":r,"aria-label":o("conversation.taskProgressButton",{count:l.items.length}),title:o("conversation.taskProgressButton",{count:l.items.length}),onClick:()=>{i(!0)},children:[n.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:n.jsx(wB,{})}),n.jsx("span",{className:"conversation-task-progress-badge",children:m})]}),n.jsx(Ln,{open:s,title:o("conversation.taskProgressModalTitle"),description:o("conversation.taskProgressModalDescription",{count:l.items.length}),className:"conversation-task-progress-modal",onClose:()=>{i(!1)},children:n.jsxs("div",{className:"conversation-task-progress-modal-body",children:[n.jsxs("div",{className:"conversation-task-progress-summary",children:[n.jsx(wc,{label:o("conversation.taskProgressSummaryTotal"),value:l.items.length}),n.jsx(wc,{label:o("conversation.taskProgressStatusInProgress"),value:c.in_progress}),n.jsx(wc,{label:o("conversation.taskProgressStatusPending"),value:c.pending}),n.jsx(wc,{label:o("conversation.taskProgressStatusCompleted"),value:c.completed}),c.failed>0?n.jsx(wc,{label:o("conversation.taskProgressStatusFailed"),value:c.failed}):null]}),l.explanation?n.jsxs("div",{className:"conversation-task-progress-explanation",children:[n.jsx("strong",{children:o("conversation.taskProgressExplanationTitle")}),n.jsx("p",{children:l.explanation})]}):null,n.jsx("ol",{className:"conversation-task-progress-list",children:f.map(g=>n.jsxs("li",{className:"conversation-task-progress-item","data-status":g.status,children:[n.jsx("span",{className:"conversation-task-progress-item-indicator","data-status":g.status,"aria-hidden":"true"}),n.jsxs("div",{className:"conversation-task-progress-item-body",children:[n.jsxs("div",{className:"conversation-task-progress-item-header",children:[n.jsx("strong",{children:g.title}),n.jsx("span",{className:"conversation-task-progress-item-status",children:kB(g.status)})]}),g.detail?n.jsx("p",{className:"conversation-task-progress-item-detail",children:g.detail}):null]})]},g.id))})]})})]})}function wc({label:e,value:t}){return n.jsxs("div",{className:"conversation-task-progress-summary-card",children:[n.jsx("span",{children:e}),n.jsx("strong",{children:t})]})}function kB(e){switch(e){case"in_progress":return o("conversation.taskProgressStatusInProgress");case"completed":return o("conversation.taskProgressStatusCompleted");case"failed":return o("conversation.taskProgressStatusFailed");case"cancelled":return o("conversation.taskProgressStatusCancelled");case"pending":default:return o("conversation.taskProgressStatusPending")}}const xB="codingns.conversation.composer-draft:",SB=1,CB=[{id:"builtin-stage-and-summarize",text:"请将本次会话变更的所有代码提交到git暂存区,然后总结一条中文的提交信息"},{id:"builtin-review-module",text:"分析本项目 模块的代码实现,并分析存在的问题"},{id:"builtin-group-commits",text:"分析当前项目中的未提交文件,按照功能模块进行分类提交,提交信息格式请参考我最近的提交记录"}];function Av(){return typeof window<"u"&&typeof window.localStorage<"u"}function jB(e){if(!e||typeof e!="object")return null;const t="id"in e?e.id:null,r="fileName"in e?e.fileName:null,s="mimeType"in e?e.mimeType:null,i="fileSize"in e?e.fileSize:null,l="lastModified"in e?e.lastModified:null,c="contentBase64"in e?e.contentBase64:null;if(typeof t!="string"||typeof r!="string"||typeof s!="string"||typeof i!="number"||typeof l!="number"||typeof c!="string")return null;const d=t.trim(),m=r.trim(),f=s.trim(),v=c.trim();return!d||!m||!f||i<0||l<0||!v?null:{id:d,fileName:m,mimeType:f,fileSize:i,lastModified:l,contentBase64:v}}function TB(e){if(!e||typeof e!="object")return null;const t="content"in e?e.content:null,r="attachments"in e?e.attachments:null;if(typeof t!="string"||!Array.isArray(r))return null;const s=r.map(i=>jB(i)).filter(i=>i!==null);return s.length!==r.length||t.length===0&&s.length===0?null:{content:t,attachments:s}}function zc(e){return`${xB}${e}`}function NB(e){var t,r;return{id:((r=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:r.call(t))??`phrase-${Date.now()}-${Math.random().toString(16).slice(2)}`,text:e.trim()}}function PB(e){if(!Av())return null;const t=e.trim();if(!t)return null;const r=window.localStorage.getItem(zc(t));if(!r)return null;try{const s=JSON.parse(r),i=s&&typeof s=="object"&&"draft"in s&&s.draft&&typeof s.draft=="object"?s.draft:s,l=TB(i);return l||(window.localStorage.removeItem(zc(t)),null)}catch{return window.localStorage.removeItem(zc(t)),null}}function DB(e,t){if(!Av())return!1;const r=e.trim();if(!r)return!1;if(t.content.length===0&&t.attachments.length===0)return SD(r),!0;try{return window.localStorage.setItem(zc(r),JSON.stringify({schemaVersion:SB,draft:t})),!0}catch{return!1}}function SD(e){if(!Av())return;const t=e.trim();t&&window.localStorage.removeItem(zc(t))}const vS="workbench:focus-composer",qc="provider-default",wS=["codex","claude-code","opencode","gemini","kimi"],RB=new Set(["codex","claude-code","opencode"]),MB=new Set(["codex","claude-code","opencode"]),yS={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function AB(e){return[{id:qc,name:o("conversation.modelUseCliDefault"),provider:e,usesProviderDefault:!0}]}function kS(e){return AB(e)}function xS(e){return e.usesProviderDefault===!0||e.id===qc}function IB(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${Date.now()}-${Math.random().toString(16).slice(2)}`}function SS(e){if(e){e.value="";try{const t=e.showPicker;if(typeof t=="function"){t.call(e);return}}catch{}e.click()}}function EB(e,t,r,s){const i=globalThis.atob(r),l=Uint8Array.from(i,c=>c.charCodeAt(0));return new File([l],e,{type:t,lastModified:s})}function LB(e){return e.trim().toLowerCase().startsWith("image/")}function $c(e){const t=e.type.trim().toLowerCase();return t.length>0?t:"application/octet-stream"}function CD(e){return LB($c(e))?"image":"file"}function jD(e,t=IB()){const r=CD(e);return{id:t,file:e,kind:r,previewUrl:r==="image"?URL.createObjectURL(e):null}}function FB(e){const t=EB(e.fileName,e.mimeType,e.contentBase64,e.lastModified);return jD(t,e.id)}function _B(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OB(e){const t=e.trim().replace(/\s+/g," ");return t.length===0?o("conversation.forkDraftEmpty"):t.length>140?`${t.slice(0,140)}…`:t}function BB(e,t){return t===e?MB.has(t)?null:o("conversation.forkProviderNativeUnsupported"):RB.has(t)?null:o("conversation.forkProviderReconstructedUnsupported")}function TD(e){return(e==null?void 0:e.canStartSession)===!1}function WB(e){return TD(e)?(e==null?void 0:e.limitations[0])??o("conversation.capabilityDenied"):null}function UB(e,t){return{id:t,kind:CD(e),fileName:e.name,mimeType:$c(e),fileSize:e.size}}function CS(e){return new Promise((t,r)=>{const s=new FileReader;s.onerror=()=>{r(s.error??new Error("FILE_READ_FAILED"))},s.onload=()=>{const i=typeof s.result=="string"?s.result:"",l=i.includes(",")?i.split(",").at(-1)??"":i;t(l)},s.readAsDataURL(e)})}function HB(e){e.forEach(t=>{t.previewUrl&&URL.revokeObjectURL(t.previewUrl)})}function zB(e,t){const r=new Set(e.map(i=>`${i.file.name}:${i.file.size}:${i.file.lastModified}`)),s=[...e];return t.forEach(i=>{const l=`${i.name}:${i.size}:${i.lastModified}`;r.has(l)||(r.add(l),s.push(jD(i)))}),s}function km({capabilities:e,placeholder:t,draftStorageId:r,forkDraft:s=null,onClearForkDraft:i,onForkDraftChange:l,panelRef:c,portalContainer:d=null,hasActiveRun:m=null,canInterrupt:f=null,contextUsage:v=null,taskProvider:g=null,taskMessages:w=[],hasPendingQueuedMessages:k=!1,isSubmitting:y,isRunning:C=!1,onInterrupt:T,onQueueSend:j,onSend:N}){const D=nr(),F=p.useId(),W=p.useId(),[E,I]=p.useState(""),[M,_]=p.useState(""),[L,Q]=p.useState("medium"),[O,ne]=p.useState([]),[Y,G]=p.useState(!1),[te,K]=p.useState(!1),[z,q]=p.useState(CB),[P,U]=p.useState(!1),[X,R]=p.useState(!1),[Se,se]=p.useState(""),[J,Ne]=p.useState(!1),[Ee,ie]=p.useState(!1),[xe,lt]=p.useState(!1),[Oe,bt]=p.useState(!1),[Ct,nt]=p.useState(null),[et,De]=p.useState(!1),[Ue,Ye]=p.useState({}),[ye,He]=p.useState(null),je=p.useRef(null),Fe=p.useRef(null),Ve=p.useRef(null),kt=p.useRef(!1),me=p.useRef(new Set),Me=p.useRef(new Map),Xe=p.useRef(0),{showToast:ze}=Qn(),vt=li(),ht=P_(e),pe=ca(ue=>nf(ht)?ue.profile.providers[ht]:null),$e=(pe==null?void 0:pe.defaultModel)??null,Nt=(pe==null?void 0:pe.defaultReasoningLevel)??null,Rt=p.useMemo(()=>Sf(e,"send_message"),[e]),Ft=p.useMemo(()=>Sf(e,"interrupt"),[e]),Wt=p.useMemo(()=>Sf(e,"attachments"),[e]),Kt=p.useMemo(()=>{var Qe;const ue=(Qe=e==null?void 0:e.modelOptions)==null?void 0:Qe.map(yt=>{var Lt;return{...yt,provider:ht,supportedReasoningEfforts:(Lt=yt.supportedReasoningEfforts)==null?void 0:Lt.filter(fn=>fn==="low"||fn==="medium"||fn==="high"||fn==="xhigh")}});return ue!=null&&ue.length?ue:kS(ht)},[e==null?void 0:e.modelOptions,ht]),un=p.useMemo(()=>Kt.find(ue=>ue.id===M)??null,[Kt,M]),ae=R_(e),Be=D_(e),It=p.useMemo(()=>[{value:"low",label:o("conversation.reasoningLow")},{value:"medium",label:o("conversation.reasoningMedium")},{value:"high",label:o("conversation.reasoningHigh")},{value:"xhigh",label:o("conversation.reasoningMaximum")}],[]),jt=p.useMemo(()=>{if(!ae)return[];const ue=un==null?void 0:un.supportedReasoningEfforts;return!ue||ue.length===0?It:It.filter(Qe=>ue.includes(Qe.value))},[ae,It,un==null?void 0:un.supportedReasoningEfforts]),Cn=p.useMemo(()=>Kt.map(ue=>({value:ue.id,label:xS(ue)?o("conversation.modelUseCliDefault"):ue.name})),[Kt]),on=p.useMemo(()=>jt.map(ue=>({value:ue.value,label:ue.label})),[jt]),Wn=p.useMemo(()=>[{command:"/plan",label:o("conversation.slashCommandPlan")},{command:"/review",label:o("conversation.slashCommandReview")},{command:"/explain",label:o("conversation.slashCommandExplain")}],[]),Rn=(e==null?void 0:e.inRunInputMode)??"none",$t=!!s,dn=(s==null?void 0:s.targetProvider)??null,gn=!!s&&(e==null?void 0:e.provider)===dn,Z=p.useMemo(()=>s?gn?e:Ct??Ba(s.targetProvider):null,[e,Ct,s,gn]),ce=p.useMemo(()=>{var Qe;if(!s)return[];const ue=(Qe=Z==null?void 0:Z.modelOptions)==null?void 0:Qe.map(yt=>{var Lt;return{...yt,provider:s.targetProvider,supportedReasoningEfforts:(Lt=yt.supportedReasoningEfforts)==null?void 0:Lt.filter(fn=>fn==="low"||fn==="medium"||fn==="high"||fn==="xhigh")}});return ue!=null&&ue.length?ue:kS(s.targetProvider)},[Z==null?void 0:Z.modelOptions,s]),ge=p.useMemo(()=>ce.map(ue=>({value:ue.id,label:xS(ue)?o("conversation.modelUseCliDefault"):ue.name})),[ce]),Ce=p.useMemo(()=>!s||!s.targetModel?qc:ce.some(ue=>ue.id===s.targetModel)?s.targetModel:qc,[ce,s]),We=p.useMemo(()=>s?wS.filter(ue=>BB(s.sourceProvider,ue)!==null?!1:!TD(Ue[ue]??null)):[],[s,Ue]),qe=p.useMemo(()=>s?We.length>0?We:[s.targetProvider]:[],[s,We]),Pt=p.useMemo(()=>qe.map(ue=>({value:ue,label:qs(ue,"full")})),[qe]),Ke=p.useMemo(()=>s?WB(Ue[s.targetProvider]??Z??null):null,[Z,s,Ue]),at=m??null,ft=C&&Rn==="streaming_guidance"&&at===!1&&!kP(e),ct=!$t&&C&&Rn==="streaming_guidance"&&!ft,oe=!$t&&C&&typeof j=="function"&&M_(e,at),Re=!$t&&C&&!ct&&!oe,_t=$t&&!!Ke,Ut=E.trim().length>0||O.length>0,Qt=f??Ft.allowed,jn=C&&Qt&&!!T&&!xe&&!Ut&&!Oe&&!y,Jn=!jn&&!Ut&&(Oe||y||C||!C&&k),bn=o(Oe||y||k?"conversation.sendingState":"conversation.runtimeRunning"),Jt=o(C?oe?"conversation.queueGuidanceButton":ct?"conversation.sendGuidanceButton":"conversation.sendButton":"conversation.sendButton"),ur=p.useCallback(ue=>{_(ue),nf(ht)&&Qc({providers:{[ht]:{defaultModel:ue}}}).catch(()=>{})},[ht]),vn=p.useCallback(ue=>{Q(ue),nf(ht)&&Qc({providers:{[ht]:{defaultReasoningLevel:ue}}}).catch(()=>{})},[ht]),yn=p.useCallback(ue=>{me.current.forEach(Qe=>{URL.revokeObjectURL(Qe)}),me.current.clear(),ue.forEach(Qe=>{Qe.previewUrl&&me.current.add(Qe.previewUrl)}),ne(ue)},[]),kn=p.useCallback(ue=>{ue.length!==0&&ne(Qe=>{const yt=zB(Qe,ue);return yt.forEach(Lt=>{Lt.previewUrl&&me.current.add(Lt.previewUrl)}),yt})},[]),Nn=p.useCallback(ue=>{Me.current.delete(ue),ne(Qe=>{const yt=Qe.find(Lt=>Lt.id===ue);return yt!=null&&yt.previewUrl&&(me.current.delete(yt.previewUrl),URL.revokeObjectURL(yt.previewUrl)),Qe.filter(Lt=>Lt.id!==ue)})},[]),xt=p.useCallback(ue=>{const Qe=Array.from(ue.target.files??[]);Qe.length>0&&kn(Qe),ue.target.value=""},[kn]),Zt=p.useCallback(ue=>{var yt;D.isMobile||!Wt.allowed||Re||!((((yt=ue.dataTransfer.files)==null?void 0:yt.length)??0)>0||Array.from(ue.dataTransfer.items??[]).some(Lt=>Lt.kind==="file"))||(ue.preventDefault(),ue.dataTransfer.dropEffect="copy",te||K(!0),ie(!1))},[Wt.allowed,te,Re,D.isMobile]),we=p.useCallback(ue=>{const Qe=ue.relatedTarget;Qe instanceof Node&&ue.currentTarget.contains(Qe)||K(!1)},[]),Ge=p.useCallback(ue=>{if(D.isMobile||!Wt.allowed||Re)return;const Qe=Array.from(ue.dataTransfer.files??[]);Qe.length!==0&&(ue.preventDefault(),K(!1),kn(Qe))},[Wt.allowed,Re,kn,D.isMobile]),St=p.useCallback(ue=>{if(!Wt.allowed||Re)return;const Qe=ue==="camera"?Ve.current:Fe.current;SS(Qe),G(!1)},[Wt.allowed,Re]),Sn=p.useCallback(()=>{if(!(!Wt.allowed||Re)){if(ie(!1),D.isNativeMobile){vt.trigger("selection"),G(!0);return}SS(Fe.current)}},[Wt.allowed,vt,Re,D.isNativeMobile]),_n=p.useCallback(()=>{ie(ue=>!ue)},[]),Vn=p.useCallback(ue=>{var Qe;I(yt=>yt.trimStart().startsWith(ue)?yt:yt.trim()?`${ue} ${yt.trim()}`:`${ue} `),ie(!1),(Qe=je.current)==null||Qe.focus()},[]),zn=p.useCallback(async ue=>{const Qe=z;Xe.current+=1,q(ue),Ne(!0);try{const yt=await t_(ue.map(Lt=>({id:Lt.id,text:Lt.text})));return q(yt.items.map(Lt=>({id:Lt.id,text:Lt.text}))),!0}catch(yt){return q(Qe),ze({title:yt instanceof Error?yt.message:o("conversation.quickPhraseSaveFailed"),tone:"error"}),!1}finally{Ne(!1)}},[z,ze]),rr=p.useCallback(async()=>{const ue=Se.trim();!ue||!await zn([...z,NB(ue)])||(se(""),R(!1))},[zn,Se,z]),Gn=p.useCallback(ue=>{zn(z.filter(Qe=>Qe.id!==ue))},[zn,z]),xr=p.useCallback((ue,Qe)=>{const yt=z.findIndex(nn=>nn.id===ue);if(yt<0)return;const Lt=yt+Qe;if(Lt<0||Lt>=z.length)return;const fn=[...z],[mn]=fn.splice(yt,1);fn.splice(Lt,0,mn),zn(fn)},[zn,z]),Kr=p.useCallback(ue=>{var Qe;I(ue),U(!1),(Qe=je.current)==null||Qe.focus()},[]),Yr=p.useCallback(ue=>{const Qe=ue?PB(ue):null,yt=(Qe==null?void 0:Qe.attachments.map(Lt=>FB(Lt)))??[];Me.current=new Map(((Qe==null?void 0:Qe.attachments)??[]).map(Lt=>[Lt.id,Lt])),yn(yt),I((Qe==null?void 0:Qe.content)??""),ie(!1)},[yn]);p.useEffect(()=>{if(!Kt.length)return;if($e&&Kt.some(Qe=>Qe.id===$e)){M!==$e&&_($e);return}if(Kt.some(Qe=>Qe.id===M))return;const ue=Kt[0].id;_(ue)},[Kt,ht,M,$e]),p.useEffect(()=>{if(!A_(ht)||jt.length===0)return;if(Nt&&jt.some(yt=>yt.value===Nt)){L!==Nt&&Q(Nt);return}const ue=e==null?void 0:e.defaultReasoningLevel;if(ue&&jt.some(yt=>yt.value===ue)){L!==ue&&Q(ue);return}if(jt.some(yt=>yt.value===L))return;const Qe=jt[0].value;Q(Qe)},[jt,e==null?void 0:e.defaultReasoningLevel,ht,L,Nt]),p.useEffect(()=>{let ue=!1;const Qe=Xe.current;return e_().then(yt=>{ue||Xe.current!==Qe||q(yt.items.map(Lt=>({id:Lt.id,text:Lt.text})))}).catch(()=>{}),()=>{ue=!0}},[]),p.useEffect(()=>{Yr(r)},[r,Yr]),p.useEffect(()=>{if(!r)return;const ue=r,Qe=new Set(O.map(fn=>fn.id));Me.current.forEach((fn,mn)=>{Qe.has(mn)||Me.current.delete(mn)});let yt=!1;async function Lt(){if(E.length===0&&O.length===0){SD(ue);return}const fn=await Promise.all(O.map(async mn=>{const nn=Me.current.get(mn.id);return nn&&nn.fileName===mn.file.name&&nn.fileSize===mn.file.size&&nn.lastModified===mn.file.lastModified&&nn.mimeType===$c(mn.file)?nn:{id:mn.id,fileName:mn.file.name,mimeType:$c(mn.file),fileSize:mn.file.size,lastModified:mn.file.lastModified,contentBase64:await CS(mn.file)}}));yt||(Me.current=new Map(fn.map(mn=>[mn.id,mn])),DB(ue,{content:E,attachments:fn}))}return Lt(),()=>{yt=!0}},[O,E,r]),p.useEffect(()=>{const ue=je.current;ue&&(ue.style.height="0px",ue.style.height=`${Math.min(ue.scrollHeight,120)}px`)},[E]),p.useEffect(()=>{Wt.allowed||(Me.current.clear(),G(!1),yn([]))},[Wt.allowed,yn]),p.useEffect(()=>{D.isMobile||G(!1)},[D.isMobile]),p.useEffect(()=>()=>{me.current.forEach(ue=>{URL.revokeObjectURL(ue)}),me.current.clear()},[]),p.useEffect(()=>{function ue(){var Qe;(Qe=je.current)==null||Qe.focus()}return window.addEventListener(vS,ue),()=>{window.removeEventListener(vS,ue)}},[]),p.useEffect(()=>{if(!s){nt(null),De(!1),Ye({}),He(null);return}if(gn){nt(null),De(!1);return}let ue=!1;return nt(Ba(s.targetProvider)),De(!0),_l(s.targetProvider,s.workspaceId).then(Qe=>{ue||nt(Qe)}).catch(()=>{ue||nt(Ba(s.targetProvider))}).finally(()=>{ue||De(!1)}),()=>{ue=!0}},[s==null?void 0:s.targetProvider,s==null?void 0:s.workspaceId,gn]),p.useEffect(()=>{if(!s){Ye({});return}let ue=!1;return yv(wS,s.workspaceId).then(Qe=>{ue||Ye(Qe)}),()=>{ue=!0}},[s==null?void 0:s.workspaceId]),p.useEffect(()=>{!s||!l||We.length!==0&&(We.includes(s.targetProvider)||l({...s,targetProvider:We[0]??s.targetProvider,targetModel:null}))},[s,l,We]),p.useEffect(()=>{!s||!s.targetModel||!l||ce.some(ue=>ue.id===s.targetModel)||l({...s,targetModel:null})},[ce,s,l]);const Xr=p.useCallback(ue=>{if(!(!s||!l||ue===s.targetProvider)){if(ue!==s.sourceProvider&&s.targetProvider===s.sourceProvider){He(ue);return}l({...s,targetProvider:ue,targetModel:null})}},[s,l]),Lr=p.useCallback(ue=>{!s||!l||l({...s,targetModel:ue===qc?null:ue})},[s,l]),es=p.useCallback(()=>{!s||!ye||!l||(l({...s,targetProvider:ye,targetModel:null}),He(null))},[s,l,ye]),sr=p.useCallback(()=>{He(null)},[]);async function Hr(ue){if(kt.current)return;const Qe=E.trim(),yt=O;if(Qe.length===0&&yt.length===0||!Rt.allowed||Re||_t){ze({title:Re?o("conversation.runtimeRunning"):Ke??Rt.reason??o("conversation.capabilityDenied"),tone:"error"});return}kt.current=!0,vt.trigger(ue==="queue"?"selection":"action"),bt(!0),I(""),ne([]),G(!1),K(!1),U(!1),R(!1),ie(!1);try{const Lt=await Promise.all(yt.map(async nn=>({kind:nn.kind,fileName:nn.file.name,mimeType:$c(nn.file),fileSize:nn.file.size,contentBase64:await CS(nn.file)}))),fn=yt.map(nn=>UB(nn.file,nn.id));await(ue==="queue"&&j?j:N)(Qe,{model:$t||un!=null&&un.usesProviderDefault?void 0:M||void 0,reasoningLevel:$t?void 0:ae&&jt.length>0?L:void 0,attachments:Lt,attachmentMeta:fn}),HB(yt),yt.forEach(nn=>{nn.previewUrl&&me.current.delete(nn.previewUrl)})}catch(Lt){I(Qe),ne(yt),ze({title:Lt instanceof Error&&Lt.message==="FILE_READ_FAILED"?o("conversation.attachmentReadFailed"):Lt instanceof Error?Lt.message:o("conversation.capabilityDenied"),tone:"error"})}finally{bt(!1),kt.current=!1}}async function dr(ue){ue.preventDefault(),await Hr(oe?"queue":"send")}async function wt(){if(!(!Qt||!T||xe))try{lt(!0),vt.trigger("action"),await T()}catch(ue){ze({title:ue instanceof Error?ue.message:o("conversation.capabilityInterruptDisabled"),tone:"error"})}finally{lt(!1)}}const ir=Oe||y||Re||_t||!Rt.allowed||!Ut,tn=Oe||y||Re||!Wt.allowed,hr=E.length===0&&!Re,ar=n.jsxs("section",{ref:c,className:"composer-panel",children:[n.jsxs("form",{className:"composer-form",onSubmit:dr,children:[n.jsx("input",{id:F,ref:Fe,type:"file",multiple:!0,tabIndex:-1,"aria-hidden":"true",style:yS,onChange:xt}),n.jsx("input",{id:W,ref:Ve,type:"file",accept:"image/*",capture:"environment",tabIndex:-1,"aria-hidden":"true",style:yS,onChange:xt}),n.jsxs("div",{className:"composer-input-container","data-drag-active":te?"true":void 0,onDragOver:Zt,onDragLeave:we,onDrop:Ge,children:[s?n.jsxs("div",{className:"composer-fork-draft",children:[n.jsxs("div",{className:"composer-fork-draft-main",children:[n.jsxs("div",{className:"composer-fork-draft-copy",children:[n.jsx("span",{className:"composer-fork-draft-label",children:o("conversation.forkDraftLabel")}),n.jsx("span",{className:"composer-fork-draft-text",children:OB(s.content)})]}),n.jsxs("div",{className:"composer-fork-config",children:[n.jsxs("div",{className:"composer-fork-config-grid",children:[n.jsxs("div",{className:"composer-fork-field",children:[n.jsx("span",{className:"composer-fork-model-label",children:o("conversation.forkTargetProviderLabel")}),n.jsx(Bd,{ariaLabel:o("conversation.forkTargetProviderLabel"),value:s.targetProvider,options:Pt,onChange:ue=>Xr(ue),compact:!0})]}),n.jsxs("div",{className:"composer-fork-field",children:[n.jsx("span",{className:"composer-fork-model-label",children:o("conversation.forkTargetModelLabel")}),n.jsx(Bd,{ariaLabel:o("conversation.forkTargetModelLabel"),value:Ce,options:ge,onChange:Lr,disabled:et||_t,compact:!0})]})]}),Ke?n.jsx("p",{className:"composer-capability-hint",children:Ke}):null]})]}),i?n.jsx("button",{type:"button",className:"composer-fork-draft-clear","aria-label":o("conversation.forkDraftClear"),title:o("conversation.forkDraftClear"),onClick:i,children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):null]}):null,O.length>0?n.jsx("div",{className:"composer-attachments",children:O.map(ue=>n.jsxs("div",{className:"composer-attachment-card",children:[ue.previewUrl?n.jsx("img",{src:ue.previewUrl,alt:o("conversation.attachmentPreviewAlt"),className:"composer-attachment-preview"}):n.jsx("div",{className:"composer-attachment-file","aria-hidden":"true",children:n.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),n.jsx("path",{d:"M14 2v5h5"}),n.jsx("path",{d:"M9 13h6"}),n.jsx("path",{d:"M9 17h6"})]})}),n.jsxs("div",{className:"composer-attachment-meta",children:[n.jsx("span",{className:"attachment-name",title:ue.file.name,children:ue.file.name}),n.jsx("span",{className:"attachment-size",children:_B(ue.file.size)})]}),n.jsx("button",{type:"button",className:"attachment-remove",onClick:()=>Nn(ue.id),"aria-label":o("conversation.removeAttachment"),children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},ue.id))}):null,te?n.jsx("div",{className:"composer-drop-hint",children:o("conversation.attachmentDropHint")}):null,n.jsxs("div",{className:"composer-input-wrapper",children:[n.jsx("textarea",{ref:je,className:"composer-input",value:E,placeholder:t??o("conversation.composerPlaceholder"),readOnly:Re,"aria-readonly":Re,onChange:ue=>I(ue.target.value),rows:1,onFocus:()=>ie(!1),onPaste:ue=>{if(Re||!Wt.allowed)return;const Qe=Array.from(ue.clipboardData.items).filter(yt=>yt.kind==="file").map(yt=>yt.getAsFile()).filter(yt=>!!yt);Qe.length!==0&&(ue.preventDefault(),kn(Qe))},onKeyDown:ue=>{ue.key==="Escape"&&ie(!1),ue.key==="Enter"&&!ue.shiftKey&&(ue.preventDefault(),ir||dr(ue))}}),hr?n.jsx("button",{type:"button",className:"composer-quick-phrase-trigger","aria-label":o("conversation.quickPhraseTrigger"),title:o("conversation.quickPhraseTrigger"),onClick:()=>{U(!0),ie(!1)},children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M7 8h10"}),n.jsx("path",{d:"M7 12h8"}),n.jsx("path",{d:"M7 16h5"}),n.jsx("path",{d:"M5 5h14v14H9l-4 4V5z"})]})}):null]}),Ee?n.jsx("div",{className:"composer-slash-menu",role:"menu","aria-label":o("conversation.slashMenuTitle"),children:Wn.map(ue=>n.jsxs("button",{type:"button",className:"composer-slash-item",onClick:()=>Vn(ue.command),children:[n.jsx("span",{className:"composer-slash-command",children:ue.command}),n.jsx("span",{className:"composer-slash-label",children:ue.label})]},ue.command))}):null,n.jsxs("div",{className:"composer-controls",children:[n.jsxs("div",{className:"composer-controls-left",children:[Wt.allowed?D.isNativeMobile?n.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":o("conversation.attachFiles"),title:o("conversation.attachFiles"),disabled:tn,onClick:Sn,children:n.jsx(jf,{})}):tn?n.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":o("conversation.attachFiles"),title:o("conversation.attachFiles"),disabled:!0,children:n.jsx(jf,{})}):n.jsx("label",{htmlFor:F,className:"composer-attach-btn","aria-label":o("conversation.attachFiles"),title:o("conversation.attachFiles"),onClick:()=>{ie(!1)},children:n.jsx(jf,{})}):null,$t?null:n.jsx(Bd,{ariaLabel:o("conversation.modelSelectorLabel"),value:M,options:Cn,onChange:ur}),!$t&&ae&&jt.length>0?n.jsx(Bd,{ariaLabel:o("conversation.reasoningSelectorLabel"),value:L,options:on,onChange:ue=>vn(ue),compact:!0}):null,Be?n.jsxs("button",{type:"button",className:"composer-slash-btn",onClick:_n,title:o("conversation.slashMenu"),children:[n.jsx("span",{className:"slash-icon",children:"/"}),n.jsx("span",{children:o("conversation.slashMenu")})]}):null,n.jsx(XB,{contextUsage:v}),n.jsx(yB,{provider:g,messages:w,variant:"composer"})]}),Jn?n.jsx("div",{className:"composer-send-group",children:n.jsx("button",{className:"composer-send composer-send-busy",type:"button",disabled:!0,"aria-label":bn,title:bn,children:n.jsxs("svg",{className:"composer-send-spinner",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeOpacity:"0.28",strokeWidth:"2.5"}),n.jsx("path",{d:"M20 12a8 8 0 0 0-8-8",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})})}):n.jsx("div",{className:"composer-send-group",children:jn?n.jsx("button",{className:"composer-send composer-send-busy",type:"button",onClick:()=>{wt()},"aria-label":o("conversation.capabilityInterrupt"),title:o("conversation.capabilityInterrupt"),children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})}):n.jsx("button",{className:"composer-send",type:"submit",disabled:ir,"aria-label":Jt,title:Jt,children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),n.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})})]})]})]}),n.jsx(Ln,{open:P,title:o("conversation.quickPhraseModalTitle"),description:o("conversation.quickPhraseModalDescription"),className:"composer-quick-phrase-modal",onClose:()=>{U(!1),R(!1)},children:n.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[n.jsxs("div",{className:"composer-quick-phrase-toolbar",children:[n.jsx("div",{className:"composer-quick-phrase-toolbar-copy",children:n.jsx("span",{children:o("conversation.quickPhraseListLabel")})}),n.jsx("button",{type:"button",className:"primary-button",disabled:J,onClick:()=>R(!0),children:o("conversation.quickPhraseOpenCreateAction")})]}),n.jsx("div",{className:"composer-quick-phrase-list",role:"list","aria-label":o("conversation.quickPhraseListLabel"),children:z.length===0?n.jsx("div",{className:"composer-quick-phrase-empty",children:o("conversation.quickPhraseEmpty")}):z.map((ue,Qe)=>n.jsxs("div",{className:"composer-quick-phrase-item",role:"listitem",children:[n.jsxs("button",{type:"button",className:"composer-quick-phrase-select",onClick:()=>Kr(ue.text),children:[n.jsx("span",{className:"composer-quick-phrase-order",children:o("conversation.quickPhraseOrderLabel",{index:Qe+1})}),n.jsx("span",{className:"composer-quick-phrase-text",children:ue.text})]}),n.jsxs("div",{className:"composer-quick-phrase-actions",children:[n.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:J||Qe===0,"aria-label":o("conversation.quickPhraseMoveUp"),title:o("conversation.quickPhraseMoveUp"),onClick:()=>xr(ue.id,-1),children:"↑"}),n.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:J||Qe===z.length-1,"aria-label":o("conversation.quickPhraseMoveDown"),title:o("conversation.quickPhraseMoveDown"),onClick:()=>xr(ue.id,1),children:"↓"}),n.jsx("button",{type:"button",className:"composer-quick-phrase-action is-danger",disabled:J,"aria-label":o("conversation.quickPhraseDelete"),title:o("conversation.quickPhraseDelete"),onClick:()=>Gn(ue.id),children:"×"})]})]},ue.id))})]})}),n.jsx(Ln,{open:X,title:o("conversation.quickPhraseCreateModalTitle"),description:o("conversation.quickPhraseCreateModalDescription"),className:"composer-quick-phrase-create-modal",onClose:()=>R(!1),children:n.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("conversation.quickPhraseCreateLabel")}),n.jsx("textarea",{className:"composer-quick-phrase-textarea",value:Se,placeholder:o("conversation.quickPhraseCreatePlaceholder"),rows:4,onChange:ue=>se(ue.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>R(!1),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:J||Se.trim().length===0,onClick:()=>{rr()},children:o("conversation.quickPhraseCreateAction")})]})]})}),n.jsx(Ln,{open:ye!==null,title:o("conversation.forkSwitchConfirmTitle"),description:o("conversation.forkSwitchConfirmDescription"),className:"composer-fork-confirm-modal",onClose:sr,children:n.jsxs("div",{className:"composer-fork-confirm-body",children:[n.jsxs("div",{className:"composer-fork-confirm-list",children:[n.jsxs("div",{className:"composer-fork-confirm-item",children:[n.jsx("span",{className:"composer-fork-confirm-icon is-keep","aria-hidden":"true",children:n.jsx(GB,{})}),n.jsxs("div",{className:"composer-fork-confirm-copy",children:[n.jsx("strong",{children:o("conversation.forkSwitchConfirmKeepTitle")}),n.jsx("p",{children:o("conversation.forkSwitchConfirmKeepBody")})]})]}),n.jsxs("div",{className:"composer-fork-confirm-item",children:[n.jsx("span",{className:"composer-fork-confirm-icon is-convert","aria-hidden":"true",children:n.jsx(KB,{})}),n.jsxs("div",{className:"composer-fork-confirm-copy",children:[n.jsx("strong",{children:o("conversation.forkSwitchConfirmConvertTitle")}),n.jsx("p",{children:o("conversation.forkSwitchConfirmConvertBody")})]})]}),n.jsxs("div",{className:"composer-fork-confirm-item",children:[n.jsx("span",{className:"composer-fork-confirm-icon is-drop","aria-hidden":"true",children:n.jsx(YB,{})}),n.jsxs("div",{className:"composer-fork-confirm-copy",children:[n.jsx("strong",{children:o("conversation.forkSwitchConfirmDropTitle")}),n.jsx("p",{children:o("conversation.forkSwitchConfirmDropBody")})]})]})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:sr,children:o("conversation.forkSwitchKeepNative")}),n.jsx("button",{type:"button",className:"primary-button",onClick:es,children:o("conversation.forkSwitchConfirmAction")})]})]})}),n.jsx(qB,{open:Y&&D.isNativeMobile,onClose:()=>G(!1),onSelectCamera:()=>St("camera"),onSelectLibrary:()=>St("library")})]});return d?$n.createPortal(ar,d):ar}function qB({open:e,onClose:t,onSelectCamera:r,onSelectLibrary:s}){return!e||typeof document>"u"?null:$n.createPortal(n.jsx("div",{className:"ios-action-sheet-overlay composer-attachment-sheet-overlay",role:"presentation",onClick:t,children:n.jsxs("div",{className:"mobile-workspace-home-sheet composer-attachment-sheet",role:"dialog","aria-modal":"true","aria-label":o("conversation.attachmentSourceSheetTitle"),onClick:i=>i.stopPropagation(),children:[n.jsxs("div",{className:"mobile-workspace-home-sheet-card composer-attachment-sheet-card",children:[n.jsxs("div",{className:"mobile-workspace-home-sheet-header",children:[n.jsx("strong",{children:o("conversation.attachmentSourceSheetTitle")}),n.jsx("span",{children:o("conversation.attachmentSourceSheetDescription")})]}),n.jsxs("div",{className:"mobile-workspace-home-group composer-attachment-sheet-actions",children:[n.jsxs("button",{type:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":o("conversation.attachmentTakePhoto"),onClick:r,children:[n.jsxs("span",{className:"composer-attachment-sheet-option-copy",children:[n.jsx("strong",{children:o("conversation.attachmentTakePhoto")}),n.jsx("span",{children:o("conversation.attachmentTakePhotoHint")})]}),n.jsx($B,{})]}),n.jsxs("button",{type:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":o("conversation.attachmentChooseFromLibrary"),onClick:s,children:[n.jsxs("span",{className:"composer-attachment-sheet-option-copy",children:[n.jsx("strong",{children:o("conversation.attachmentChooseFromLibrary")}),n.jsx("span",{children:o("conversation.attachmentChooseFromLibraryHint")})]}),n.jsx(VB,{})]})]})]}),n.jsx("button",{type:"button",className:"ios-action-sheet-cancel",onClick:t,children:o("common.cancel")})]})}),document.body)}function $B(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M4 8h3l1.5-2h7L17 8h3a1 1 0 0 1 1 1v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a1 1 0 0 1 1-1Z"}),n.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}function jf(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),n.jsx("path",{d:"M8 12h8M12 8v8"})]})}function VB(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 15 3-3 2.5 2.5 3-4L18 13.5"}),n.jsx("circle",{cx:"8.75",cy:"8.75",r:"1.25",fill:"currentColor",stroke:"none"})]})}function GB(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"M12 3 4 7v5c0 5 3.5 8 8 9 4.5-1 8-4 8-9V7l-8-4Z"}),n.jsx("path",{d:"m9.5 12 1.8 1.8L15 10.2"})]})}function KB(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"M4 7h9"}),n.jsx("path",{d:"m10 3 4 4-4 4"}),n.jsx("path",{d:"M20 17h-9"}),n.jsx("path",{d:"m14 13-4 4 4 4"})]})}function YB(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"m7 7 10 10"}),n.jsx("path",{d:"M17 7 7 17"}),n.jsx("path",{d:"M12 3v2"}),n.jsx("path",{d:"M12 19v2"})]})}function Bd({ariaLabel:e,value:t,options:r,onChange:s,disabled:i=!1,compact:l=!1}){const[c,d]=p.useState(!1),m=p.useRef(null),f=p.useRef(null),v=p.useRef(null),[g,w]=p.useState(null),k=p.useId(),y=r.find(T=>T.value===t)??r[0]??null,C=p.useCallback(()=>{const T=f.current;if(!T||typeof window>"u")return;const j=T.getBoundingClientRect(),N=window.innerWidth,D=window.innerHeight,F=12,W=10,E=Math.max(160,N-F*2),I=l?140:220,M=Math.min(E,Math.max(j.width,I)),_=Math.min(Math.max(F,j.left),Math.max(F,N-M-F)),L=j.top-F,Q=D-j.bottom-F,O=L>=180||L>=Q;w({position:"fixed",left:_,width:M,maxWidth:E,top:O?void 0:j.bottom+W,bottom:O?D-j.top+W:void 0})},[l]);return p.useEffect(()=>{if(!c)return;function T(N){var F,W;const D=N.target;!((F=m.current)!=null&&F.contains(D))&&!((W=v.current)!=null&&W.contains(D))&&d(!1)}function j(N){N.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",T),window.addEventListener("keydown",j),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),C(),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",j),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[c,C]),y?n.jsxs("div",{ref:m,className:`composer-mac-select ${l?"is-compact":""}`,"data-open":c?"true":"false",children:[n.jsxs("button",{ref:f,type:"button",className:"composer-mac-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":c,"aria-controls":k,disabled:i,onClick:()=>d(T=>!T),children:[n.jsx("span",{className:"composer-mac-select-label",children:y.label}),n.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),c&&g&&typeof document<"u"?$n.createPortal(n.jsx("div",{ref:v,className:"composer-mac-select-popover",style:g,role:"presentation",children:n.jsx("div",{id:k,className:"composer-mac-select-list",role:"listbox","aria-label":e,children:r.map(T=>{const j=T.value===t;return n.jsxs("button",{type:"button",role:"option","aria-selected":j,className:`composer-mac-select-option ${j?"is-selected":""}`,onClick:()=>{s(T.value),d(!1)},children:[n.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:j?"✓":""}),n.jsx("span",{className:"composer-mac-select-option-label",children:T.label})]},T.value)})})}),document.body):null]}):null}function XB({contextUsage:e}){const[t,r]=p.useState(!1),s=p.useRef(null),i=p.useRef(null),[l,c]=p.useState(null),d=p.useId(),m=e?Math.round(e.usageRatio*100):null,f=e?Math.max(0,Math.min(e.usageRatio,1)):0,v=QB(f),g=e?JB(e.contextWindowSource):null,w=e?`${o("conversation.contextUsageTitle")} ${m}%`:o("conversation.contextUsageUnavailable"),k=p.useCallback(()=>{const y=s.current;if(!y||typeof window>"u")return;const C=y.getBoundingClientRect(),T=window.innerWidth,j=window.innerHeight,N=12,D=10,F=Math.min(240,Math.max(188,T-N*2)),W=Math.min(Math.max(N,C.left+C.width/2-F/2),Math.max(N,T-F-N)),E=C.top-N,I=j-C.bottom-N,M=E>=140||E>=I;c({position:"fixed",left:W,width:F,maxWidth:T-N*2,top:M?void 0:C.bottom+D,bottom:M?j-C.top+D:void 0})},[]);return p.useEffect(()=>{if(!t)return;function y(T){var N,D;const j=T.target;!((N=s.current)!=null&&N.contains(j))&&!((D=i.current)!=null&&D.contains(j))&&r(!1)}function C(T){T.key==="Escape"&&r(!1)}return window.addEventListener("pointerdown",y),window.addEventListener("keydown",C),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),k(),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",C),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[t,k]),n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:s,type:"button",className:`composer-context-ring ${v}`,style:{"--context-usage-progress":`${f}`},"aria-label":w,"aria-expanded":t,"aria-describedby":t?d:void 0,onClick:()=>r(y=>!y),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:n.jsx("span",{className:"composer-context-ring-value",children:m===null?"--":n.jsxs(n.Fragment,{children:[n.jsx("span",{children:m}),n.jsx("span",{className:"composer-context-ring-suffix",children:"%"})]})})}),t&&l&&typeof document<"u"?$n.createPortal(n.jsx("div",{ref:i,id:d,className:"composer-context-tooltip",style:l,role:"tooltip",children:e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"composer-context-tooltip-title",children:o("conversation.contextUsageTitle")}),n.jsxs("div",{className:"composer-context-tooltip-line",children:[m,"% · ",Tf(e.promptTokens)," /"," ",Tf(e.contextWindow)," tokens"]}),e.cachedInputTokens>0?n.jsx("div",{className:"composer-context-tooltip-line",children:o("conversation.contextUsageCachedTokens").replace("{count}",Tf(e.cachedInputTokens))}):null,g?n.jsx("div",{className:"composer-context-tooltip-meta",children:g}):null,e.isEstimated?n.jsx("div",{className:"composer-context-tooltip-meta",children:o("conversation.contextUsageEstimated")}):null]}):n.jsx("div",{className:"composer-context-tooltip-line",children:o("conversation.contextUsageUnavailable")})}),document.body):null]})}function QB(e){return e>=.95?"is-critical":e>=.8?"is-warning":"is-normal"}function JB(e){switch(e){case"provider-log":return o("conversation.contextUsageSourceProviderLog");case"provider-runtime":return o("conversation.contextUsageSourceProviderRuntime");case"provider-config":return o("conversation.contextUsageSourceProviderConfig");case"model-map":return o("conversation.contextUsageSourceModelMap");default:return""}}function Tf(e){return new Intl.NumberFormat().format(e)}function ZB(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const eW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nW={};function jS(e,t){return(nW.jsx?tW:eW).test(e)}const rW=/[ \t\n\f\r]/g;function sW(e){return typeof e=="object"?e.type==="text"?TS(e.value):!1:TS(e)}function TS(e){return e.replace(rW,"")===""}class Pu{constructor(t,r,s){this.normal=r,this.property=t,s&&(this.space=s)}}Pu.prototype.normal={};Pu.prototype.property={};Pu.prototype.space=void 0;function ND(e,t){const r={},s={};for(const i of e)Object.assign(r,i.property),Object.assign(s,i.normal);return new Pu(r,s,t)}function rb(e){return e.toLowerCase()}class Es{constructor(t,r){this.attribute=r,this.property=t}}Es.prototype.attribute="";Es.prototype.booleanish=!1;Es.prototype.boolean=!1;Es.prototype.commaOrSpaceSeparated=!1;Es.prototype.commaSeparated=!1;Es.prototype.defined=!1;Es.prototype.mustUseProperty=!1;Es.prototype.number=!1;Es.prototype.overloadedBoolean=!1;Es.prototype.property="";Es.prototype.spaceSeparated=!1;Es.prototype.space=void 0;let iW=0;const wn=Fo(),Mr=Fo(),sb=Fo(),pt=Fo(),er=Fo(),Nl=Fo(),Us=Fo();function Fo(){return 2**++iW}const ib=Object.freeze(Object.defineProperty({__proto__:null,boolean:wn,booleanish:Mr,commaOrSpaceSeparated:Us,commaSeparated:Nl,number:pt,overloadedBoolean:sb,spaceSeparated:er},Symbol.toStringTag,{value:"Module"})),Nf=Object.keys(ib);class Iv extends Es{constructor(t,r,s,i){let l=-1;if(super(t,r),NS(this,"space",i),typeof s=="number")for(;++l<Nf.length;){const c=Nf[l];NS(this,Nf[l],(s&ib[c])===ib[c])}}}Iv.prototype.defined=!0;function NS(e,t,r){r&&(e[t]=r)}function Ol(e){const t={},r={};for(const[s,i]of Object.entries(e.properties)){const l=new Iv(s,e.transform(e.attributes||{},s),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,r[rb(s)]=s,r[rb(l.attribute)]=s}return new Pu(t,r,e.space)}const PD=Ol({properties:{ariaActiveDescendant:null,ariaAtomic:Mr,ariaAutoComplete:null,ariaBusy:Mr,ariaChecked:Mr,ariaColCount:pt,ariaColIndex:pt,ariaColSpan:pt,ariaControls:er,ariaCurrent:null,ariaDescribedBy:er,ariaDetails:null,ariaDisabled:Mr,ariaDropEffect:er,ariaErrorMessage:null,ariaExpanded:Mr,ariaFlowTo:er,ariaGrabbed:Mr,ariaHasPopup:null,ariaHidden:Mr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:er,ariaLevel:pt,ariaLive:null,ariaModal:Mr,ariaMultiLine:Mr,ariaMultiSelectable:Mr,ariaOrientation:null,ariaOwns:er,ariaPlaceholder:null,ariaPosInSet:pt,ariaPressed:Mr,ariaReadOnly:Mr,ariaRelevant:null,ariaRequired:Mr,ariaRoleDescription:er,ariaRowCount:pt,ariaRowIndex:pt,ariaRowSpan:pt,ariaSelected:Mr,ariaSetSize:pt,ariaSort:null,ariaValueMax:pt,ariaValueMin:pt,ariaValueNow:pt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function DD(e,t){return t in e?e[t]:t}function RD(e,t){return DD(e,t.toLowerCase())}const aW=Ol({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Nl,acceptCharset:er,accessKey:er,action:null,allow:null,allowFullScreen:wn,allowPaymentRequest:wn,allowUserMedia:wn,alt:null,as:null,async:wn,autoCapitalize:null,autoComplete:er,autoFocus:wn,autoPlay:wn,blocking:er,capture:null,charSet:null,checked:wn,cite:null,className:er,cols:pt,colSpan:null,content:null,contentEditable:Mr,controls:wn,controlsList:er,coords:pt|Nl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wn,defer:wn,dir:null,dirName:null,disabled:wn,download:sb,draggable:Mr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wn,formTarget:null,headers:er,height:pt,hidden:sb,high:pt,href:null,hrefLang:null,htmlFor:er,httpEquiv:er,id:null,imageSizes:null,imageSrcSet:null,inert:wn,inputMode:null,integrity:null,is:null,isMap:wn,itemId:null,itemProp:er,itemRef:er,itemScope:wn,itemType:er,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wn,low:pt,manifest:null,max:null,maxLength:pt,media:null,method:null,min:null,minLength:pt,multiple:wn,muted:wn,name:null,nonce:null,noModule:wn,noValidate:wn,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:wn,optimum:pt,pattern:null,ping:er,placeholder:null,playsInline:wn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wn,referrerPolicy:null,rel:er,required:wn,reversed:wn,rows:pt,rowSpan:pt,sandbox:er,scope:null,scoped:wn,seamless:wn,selected:wn,shadowRootClonable:wn,shadowRootDelegatesFocus:wn,shadowRootMode:null,shape:null,size:pt,sizes:null,slot:null,span:pt,spellCheck:Mr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:pt,step:null,style:null,tabIndex:pt,target:null,title:null,translate:null,type:null,typeMustMatch:wn,useMap:null,value:Mr,width:pt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:er,axis:null,background:null,bgColor:null,border:pt,borderColor:null,bottomMargin:pt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:wn,declare:wn,event:null,face:null,frame:null,frameBorder:null,hSpace:pt,leftMargin:pt,link:null,longDesc:null,lowSrc:null,marginHeight:pt,marginWidth:pt,noResize:wn,noHref:wn,noShade:wn,noWrap:wn,object:null,profile:null,prompt:null,rev:null,rightMargin:pt,rules:null,scheme:null,scrolling:Mr,standby:null,summary:null,text:null,topMargin:pt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:pt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:wn,disableRemotePlayback:wn,prefix:null,property:null,results:pt,security:null,unselectable:null},space:"html",transform:RD}),oW=Ol({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Us,accentHeight:pt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:pt,amplitude:pt,arabicForm:null,ascent:pt,attributeName:null,attributeType:null,azimuth:pt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:pt,by:null,calcMode:null,capHeight:pt,className:er,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:pt,diffuseConstant:pt,direction:null,display:null,dur:null,divisor:pt,dominantBaseline:null,download:wn,dx:null,dy:null,edgeMode:null,editable:null,elevation:pt,enableBackground:null,end:null,event:null,exponent:pt,externalResourcesRequired:null,fill:null,fillOpacity:pt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Nl,g2:Nl,glyphName:Nl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:pt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:pt,horizOriginX:pt,horizOriginY:pt,id:null,ideographic:pt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:pt,k:pt,k1:pt,k2:pt,k3:pt,k4:pt,kernelMatrix:Us,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:pt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:pt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:pt,overlineThickness:pt,paintOrder:null,panose1:null,path:null,pathLength:pt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:er,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:pt,pointsAtY:pt,pointsAtZ:pt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Us,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Us,rev:Us,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Us,requiredFeatures:Us,requiredFonts:Us,requiredFormats:Us,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:pt,specularExponent:pt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:pt,strikethroughThickness:pt,string:null,stroke:null,strokeDashArray:Us,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:pt,strokeOpacity:pt,strokeWidth:null,style:null,surfaceScale:pt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Us,tabIndex:pt,tableValues:null,target:null,targetX:pt,targetY:pt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Us,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:pt,underlineThickness:pt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:pt,values:null,vAlphabetic:pt,vMathematical:pt,vectorEffect:null,vHanging:pt,vIdeographic:pt,version:null,vertAdvY:pt,vertOriginX:pt,vertOriginY:pt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:pt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:DD}),MD=Ol({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),AD=Ol({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:RD}),ID=Ol({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),lW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},cW=/[A-Z]/g,PS=/-[a-z]/g,uW=/^data[-\w.:]+$/i;function dW(e,t){const r=rb(t);let s=t,i=Es;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&uW.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(PS,mW);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!PS.test(l)){let c=l.replace(cW,hW);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=Iv}return new i(s,t)}function hW(e){return"-"+e.toLowerCase()}function mW(e){return e.charAt(1).toUpperCase()}const pW=ND([PD,aW,MD,AD,ID],"html"),Ev=ND([PD,oW,MD,AD,ID],"svg");function fW(e){return e.join(" ").trim()}var gl={},Pf,DS;function gW(){if(DS)return Pf;DS=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,m=`
|
|
70
|
+
`,f="/",v="*",g="",w="comment",k="declaration";function y(T,j){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];j=j||{};var N=1,D=1;function F(Y){var G=Y.match(t);G&&(N+=G.length);var te=Y.lastIndexOf(m);D=~te?Y.length-te:D+Y.length}function W(){var Y={line:N,column:D};return function(G){return G.position=new E(Y),_(),G}}function E(Y){this.start=Y,this.end={line:N,column:D},this.source=j.source}E.prototype.content=T;function I(Y){var G=new Error(j.source+":"+N+":"+D+": "+Y);if(G.reason=Y,G.filename=j.source,G.line=N,G.column=D,G.source=T,!j.silent)throw G}function M(Y){var G=Y.exec(T);if(G){var te=G[0];return F(te),T=T.slice(te.length),G}}function _(){M(r)}function L(Y){var G;for(Y=Y||[];G=Q();)G!==!1&&Y.push(G);return Y}function Q(){var Y=W();if(!(f!=T.charAt(0)||v!=T.charAt(1))){for(var G=2;g!=T.charAt(G)&&(v!=T.charAt(G)||f!=T.charAt(G+1));)++G;if(G+=2,g===T.charAt(G-1))return I("End of comment missing");var te=T.slice(2,G-2);return D+=2,F(te),T=T.slice(G),D+=2,Y({type:w,comment:te})}}function O(){var Y=W(),G=M(s);if(G){if(Q(),!M(i))return I("property missing ':'");var te=M(l),K=Y({type:k,property:C(G[0].replace(e,g)),value:te?C(te[0].replace(e,g)):g});return M(c),K}}function ne(){var Y=[];L(Y);for(var G;G=O();)G!==!1&&(Y.push(G),L(Y));return Y}return _(),ne()}function C(T){return T?T.replace(d,g):g}return Pf=y,Pf}var RS;function bW(){if(RS)return gl;RS=1;var e=gl&&gl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(gl,"__esModule",{value:!0}),gl.default=r;const t=e(gW());function r(s,i){let l=null;if(!s||typeof s!="string")return l;const c=(0,t.default)(s),d=typeof i=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:v}=m;d?i(f,v,m):v&&(l=l||{},l[f]=v)}),l}return gl}var yc={},MS;function vW(){if(MS)return yc;MS=1,Object.defineProperty(yc,"__esModule",{value:!0}),yc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,l=function(f){return!f||r.test(f)||e.test(f)},c=function(f,v){return v.toUpperCase()},d=function(f,v){return"".concat(v,"-")},m=function(f,v){return v===void 0&&(v={}),l(f)?f:(f=f.toLowerCase(),v.reactCompat?f=f.replace(i,d):f=f.replace(s,d),f.replace(t,c))};return yc.camelCase=m,yc}var kc,AS;function wW(){if(AS)return kc;AS=1;var e=kc&&kc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(bW()),r=vW();function s(i,l){var c={};return!i||typeof i!="string"||(0,t.default)(i,function(d,m){d&&m&&(c[(0,r.camelCase)(d,l)]=m)}),c}return s.default=s,kc=s,kc}var yW=wW();const kW=pu(yW),ED=LD("end"),Lv=LD("start");function LD(e){return t;function t(r){const s=r&&r.position&&r.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function xW(e){const t=Lv(e),r=ED(e);if(t&&r)return{start:t,end:r}}function Vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?IS(e.position):"start"in e||"end"in e?IS(e):"line"in e||"column"in e?ab(e):""}function ab(e){return ES(e&&e.line)+":"+ES(e&&e.column)}function IS(e){return ab(e&&e.start)+"-"+ab(e&&e.end)}function ES(e){return e&&typeof e=="number"?e:1}class us extends Error{constructor(t,r,s){super(),typeof r=="string"&&(s=r,r=void 0);let i="",l={},c=!1;if(r&&("line"in r&&"column"in r?l={place:r}:"start"in r&&"end"in r?l={place:r}:"type"in r?l={ancestors:[r],place:r.position}:l={...r}),typeof t=="string"?i=t:!l.cause&&t&&(c=!0,i=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof s=="string"){const m=s.indexOf(":");m===-1?l.ruleId=s:(l.source=s.slice(0,m),l.ruleId=s.slice(m+1))}if(!l.place&&l.ancestors&&l.ancestors){const m=l.ancestors[l.ancestors.length-1];m&&(l.place=m.position)}const d=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=d?d.line:void 0,this.name=Vc(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}us.prototype.file="";us.prototype.name="";us.prototype.reason="";us.prototype.message="";us.prototype.stack="";us.prototype.column=void 0;us.prototype.line=void 0;us.prototype.ancestors=void 0;us.prototype.cause=void 0;us.prototype.fatal=void 0;us.prototype.place=void 0;us.prototype.ruleId=void 0;us.prototype.source=void 0;const Fv={}.hasOwnProperty,SW=new Map,CW=/[A-Z]/g,jW=new Set(["table","tbody","thead","tfoot","tr"]),TW=new Set(["td","th"]),FD="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function NW(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=LW(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=EW(r,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ev:pW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=_D(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function _D(e,t,r){if(t.type==="element")return PW(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return DW(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return MW(e,t,r);if(t.type==="mdxjsEsm")return RW(e,t);if(t.type==="root")return AW(e,t,r);if(t.type==="text")return IW(e,t)}function PW(e,t,r){const s=e.schema;let i=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(i=Ev,e.schema=i),e.ancestors.push(t);const l=BD(e,t.tagName,!1),c=FW(e,t);let d=Ov(e,t);return jW.has(t.tagName)&&(d=d.filter(function(m){return typeof m=="string"?!sW(m):!0})),OD(e,c,l,t),_v(c,d),e.ancestors.pop(),e.schema=s,e.create(t,l,c,r)}function DW(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}nu(e,t.position)}function RW(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nu(e,t.position)}function MW(e,t,r){const s=e.schema;let i=s;t.name==="svg"&&s.space==="html"&&(i=Ev,e.schema=i),e.ancestors.push(t);const l=t.name===null?e.Fragment:BD(e,t.name,!0),c=_W(e,t),d=Ov(e,t);return OD(e,c,l,t),_v(c,d),e.ancestors.pop(),e.schema=s,e.create(t,l,c,r)}function AW(e,t,r){const s={};return _v(s,Ov(e,t)),e.create(t,e.Fragment,s,r)}function IW(e,t){return t.value}function OD(e,t,r,s){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=s)}function _v(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function EW(e,t,r){return s;function s(i,l,c,d){const f=Array.isArray(c.children)?r:t;return d?f(l,c,d):f(l,c)}}function LW(e,t){return r;function r(s,i,l,c){const d=Array.isArray(l.children),m=Lv(s);return t(i,l,c,d,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function FW(e,t){const r={};let s,i;for(i in t.properties)if(i!=="children"&&Fv.call(t.properties,i)){const l=OW(e,i,t.properties[i]);if(l){const[c,d]=l;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&TW.has(t.tagName)?s=d:r[c]=d}}if(s){const l=r.style||(r.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return r}function _W(e,t){const r={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const l=s.data.estree.body[0];l.type;const c=l.expression;c.type;const d=c.properties[0];d.type,Object.assign(r,e.evaluater.evaluateExpression(d.argument))}else nu(e,t.position);else{const i=s.name;let l;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const d=s.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else nu(e,t.position);else l=s.value===null?!0:s.value;r[i]=l}return r}function Ov(e,t){const r=[];let s=-1;const i=e.passKeys?new Map:SW;for(;++s<t.children.length;){const l=t.children[s];let c;if(e.passKeys){const m=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(m){const f=i.get(m)||0;c=m+"-"+f,i.set(m,f+1)}}const d=_D(e,l,c);d!==void 0&&r.push(d)}return r}function OW(e,t,r){const s=dW(e.schema,t);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=s.commaSeparated?ZB(r):fW(r)),s.property==="style"){let i=typeof r=="object"?r:BW(e,String(r));return e.stylePropertyNameCase==="css"&&(i=WW(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&s.space?lW[s.property]||s.property:s.attribute,r]}}function BW(e,t){try{return kW(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const s=r,i=new us("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=FD+"#cannot-parse-style-attribute",i}}function BD(e,t,r){let s;if(!r)s={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let l=-1,c;for(;++l<i.length;){const d=jS(i[l])?{type:"Identifier",name:i[l]}:{type:"Literal",value:i[l]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}s=c}else s=jS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const i=s.value;return Fv.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(s);nu(e)}function nu(e,t){const r=new us("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=FD+"#cannot-handle-mdx-estrees-without-createevaluater",r}function WW(e){const t={};let r;for(r in e)Fv.call(e,r)&&(t[UW(r)]=e[r]);return t}function UW(e){let t=e.replace(CW,HW);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function HW(e){return"-"+e.toLowerCase()}const Df={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},zW={};function Bv(e,t){const r=zW,s=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return WD(e,s,i)}function WD(e,t,r){if(qW(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return LS(e.children,t,r)}return Array.isArray(e)?LS(e,t,r):""}function LS(e,t,r){const s=[];let i=-1;for(;++i<e.length;)s[i]=WD(e[i],t,r);return s.join("")}function qW(e){return!!(e&&typeof e=="object")}const FS=document.createElement("i");function Wv(e){const t="&"+e+";";FS.innerHTML=t;const r=FS.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}function zs(e,t,r,s){const i=e.length;let l=0,c;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,r=r>0?r:0,s.length<1e4)c=Array.from(s),c.unshift(t,r),e.splice(...c);else for(r&&e.splice(t,r);l<s.length;)c=s.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function si(e,t){return e.length>0?(zs(e,e.length,0,t),e):t}const _S={}.hasOwnProperty;function UD(e){const t={};let r=-1;for(;++r<e.length;)$W(t,e[r]);return t}function $W(e,t){let r;for(r in t){const i=(_S.call(e,r)?e[r]:void 0)||(e[r]={}),l=t[r];let c;if(l)for(c in l){_S.call(i,c)||(i[c]=[]);const d=l[c];VW(i[c],Array.isArray(d)?d:d?[d]:[])}}}function VW(e,t){let r=-1;const s=[];for(;++r<t.length;)(t[r].add==="after"?e:s).push(t[r]);zs(e,0,0,s)}function HD(e,t){const r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function ki(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const fs=Va(/[A-Za-z]/),cs=Va(/[\dA-Za-z]/),GW=Va(/[#-'*+\--9=?A-Z^-~]/);function qh(e){return e!==null&&(e<32||e===127)}const ob=Va(/\d/),KW=Va(/[\dA-Fa-f]/),YW=Va(/[!-/:-@[-`{-~]/);function an(e){return e!==null&&e<-2}function Xn(e){return e!==null&&(e<0||e===32)}function Dn(e){return e===-2||e===-1||e===32}const xm=Va(new RegExp("\\p{P}|\\p{S}","u")),Do=Va(/\s/);function Va(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function Bl(e){const t=[];let r=-1,s=0,i=0;for(;++r<e.length;){const l=e.charCodeAt(r);let c="";if(l===37&&cs(e.charCodeAt(r+1))&&cs(e.charCodeAt(r+2)))i=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(r+1);l<56320&&d>56319&&d<57344?(c=String.fromCharCode(l,d),i=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(s,r),encodeURIComponent(c)),s=r+i+1,c=""),i&&(r+=i,i=0)}return t.join("")+e.slice(s)}function Fn(e,t,r,s){const i=s?s-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(m){return Dn(m)?(e.enter(r),d(m)):t(m)}function d(m){return Dn(m)&&l++<i?(e.consume(m),d):(e.exit(r),t(m))}}const XW={tokenize:QW};function QW(e){const t=e.attempt(this.parser.constructs.contentInitial,s,i);let r;return t;function s(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Fn(e,t,"linePrefix")}function i(d){return e.enter("paragraph"),l(d)}function l(d){const m=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=m),r=m,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return an(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),c)}}const JW={tokenize:ZW},OS={tokenize:eU};function ZW(e){const t=this,r=[];let s=0,i,l,c;return d;function d(D){if(s<r.length){const F=r[s];return t.containerState=F[1],e.attempt(F[0].continuation,m,f)(D)}return f(D)}function m(D){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&N();const F=t.events.length;let W=F,E;for(;W--;)if(t.events[W][0]==="exit"&&t.events[W][1].type==="chunkFlow"){E=t.events[W][1].end;break}j(s);let I=F;for(;I<t.events.length;)t.events[I][1].end={...E},I++;return zs(t.events,W+1,0,t.events.slice(F)),t.events.length=I,f(D)}return d(D)}function f(D){if(s===r.length){if(!i)return w(D);if(i.currentConstruct&&i.currentConstruct.concrete)return y(D);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(OS,v,g)(D)}function v(D){return i&&N(),j(s),w(D)}function g(D){return t.parser.lazy[t.now().line]=s!==r.length,c=t.now().offset,y(D)}function w(D){return t.containerState={},e.attempt(OS,k,y)(D)}function k(D){return s++,r.push([t.currentConstruct,t.containerState]),w(D)}function y(D){if(D===null){i&&N(),j(0),e.consume(D);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:l}),C(D)}function C(D){if(D===null){T(e.exit("chunkFlow"),!0),j(0),e.consume(D);return}return an(D)?(e.consume(D),T(e.exit("chunkFlow")),s=0,t.interrupt=void 0,d):(e.consume(D),C)}function T(D,F){const W=t.sliceStream(D);if(F&&W.push(null),D.previous=l,l&&(l.next=D),l=D,i.defineSkip(D.start),i.write(W),t.parser.lazy[D.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<c&&(!i.events[E][1].end||i.events[E][1].end.offset>c))return;const I=t.events.length;let M=I,_,L;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(_){L=t.events[M][1].end;break}_=!0}for(j(s),E=I;E<t.events.length;)t.events[E][1].end={...L},E++;zs(t.events,M+1,0,t.events.slice(I)),t.events.length=E}}function j(D){let F=r.length;for(;F-- >D;){const W=r[F];t.containerState=W[1],W[0].exit.call(t,e)}r.length=D}function N(){i.write([null]),l=void 0,i=void 0,t.containerState._closeFlow=void 0}}function eU(e,t,r){return Fn(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Il(e){if(e===null||Xn(e)||Do(e))return 1;if(xm(e))return 2}function Sm(e,t,r){const s=[];let i=-1;for(;++i<e.length;){const l=e[i].resolveAll;l&&!s.includes(l)&&(t=l(t,r),s.push(l))}return t}const lb={name:"attention",resolveAll:tU,tokenize:nU};function tU(e,t){let r=-1,s,i,l,c,d,m,f,v;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(s=r;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[s][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;m=e[s][1].end.offset-e[s][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const g={...e[s][1].end},w={...e[r][1].start};BS(g,-m),BS(w,m),c={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},d={type:m>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:w},l={type:m>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[r][1].start}},i={type:m>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[s][1].end={...c.start},e[r][1].start={...d.end},f=[],e[s][1].end.offset-e[s][1].start.offset&&(f=si(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=si(f,[["enter",i,t],["enter",c,t],["exit",c,t],["enter",l,t]]),f=si(f,Sm(t.parser.constructs.insideSpan.null,e.slice(s+1,r),t)),f=si(f,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",i,t]]),e[r][1].end.offset-e[r][1].start.offset?(v=2,f=si(f,[["enter",e[r][1],t],["exit",e[r][1],t]])):v=0,zs(e,s-1,r-s+3,f),r=s+f.length-v-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function nU(e,t){const r=this.parser.constructs.attentionMarkers.null,s=this.previous,i=Il(s);let l;return c;function c(m){return l=m,e.enter("attentionSequence"),d(m)}function d(m){if(m===l)return e.consume(m),d;const f=e.exit("attentionSequence"),v=Il(m),g=!v||v===2&&i||r.includes(m),w=!i||i===2&&v||r.includes(s);return f._open=!!(l===42?g:g&&(i||!w)),f._close=!!(l===42?w:w&&(v||!g)),t(m)}}function BS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const rU={name:"autolink",tokenize:sU};function sU(e,t,r){let s=0;return i;function i(k){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(k),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(k){return fs(k)?(e.consume(k),c):k===64?r(k):f(k)}function c(k){return k===43||k===45||k===46||cs(k)?(s=1,d(k)):f(k)}function d(k){return k===58?(e.consume(k),s=0,m):(k===43||k===45||k===46||cs(k))&&s++<32?(e.consume(k),d):(s=0,f(k))}function m(k){return k===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(k),e.exit("autolinkMarker"),e.exit("autolink"),t):k===null||k===32||k===60||qh(k)?r(k):(e.consume(k),m)}function f(k){return k===64?(e.consume(k),v):GW(k)?(e.consume(k),f):r(k)}function v(k){return cs(k)?g(k):r(k)}function g(k){return k===46?(e.consume(k),s=0,v):k===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(k),e.exit("autolinkMarker"),e.exit("autolink"),t):w(k)}function w(k){if((k===45||cs(k))&&s++<63){const y=k===45?w:g;return e.consume(k),y}return r(k)}}const Du={partial:!0,tokenize:iU};function iU(e,t,r){return s;function s(l){return Dn(l)?Fn(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||an(l)?t(l):r(l)}}const zD={continuation:{tokenize:oU},exit:lU,name:"blockQuote",tokenize:aU};function aU(e,t,r){const s=this;return i;function i(c){if(c===62){const d=s.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return r(c)}function l(c){return Dn(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function oU(e,t,r){const s=this;return i;function i(c){return Dn(c)?Fn(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(zD,t,r)(c)}}function lU(e){e.exit("blockQuote")}const qD={name:"characterEscape",tokenize:cU};function cU(e,t,r){return s;function s(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),i}function i(l){return YW(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(l)}}const $D={name:"characterReference",tokenize:uU};function uU(e,t,r){const s=this;let i=0,l,c;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,c=cs,v(g))}function f(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=KW,v):(e.enter("characterReferenceValue"),l=7,c=ob,v(g))}function v(g){if(g===59&&i){const w=e.exit("characterReferenceValue");return c===cs&&!Wv(s.sliceSerialize(w))?r(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&i++<l?(e.consume(g),v):r(g)}}const WS={partial:!0,tokenize:hU},US={concrete:!0,name:"codeFenced",tokenize:dU};function dU(e,t,r){const s=this,i={partial:!0,tokenize:W};let l=0,c=0,d;return m;function m(E){return f(E)}function f(E){const I=s.events[s.events.length-1];return l=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,d=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),v(E)}function v(E){return E===d?(c++,e.consume(E),v):c<3?r(E):(e.exit("codeFencedFenceSequence"),Dn(E)?Fn(e,g,"whitespace")(E):g(E))}function g(E){return E===null||an(E)?(e.exit("codeFencedFence"),s.interrupt?t(E):e.check(WS,C,F)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===null||an(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(E)):Dn(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Fn(e,k,"whitespace")(E)):E===96&&E===d?r(E):(e.consume(E),w)}function k(E){return E===null||an(E)?g(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(E))}function y(E){return E===null||an(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(E)):E===96&&E===d?r(E):(e.consume(E),y)}function C(E){return e.attempt(i,F,T)(E)}function T(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),j}function j(E){return l>0&&Dn(E)?Fn(e,N,"linePrefix",l+1)(E):N(E)}function N(E){return E===null||an(E)?e.check(WS,C,F)(E):(e.enter("codeFlowValue"),D(E))}function D(E){return E===null||an(E)?(e.exit("codeFlowValue"),N(E)):(e.consume(E),D)}function F(E){return e.exit("codeFenced"),t(E)}function W(E,I,M){let _=0;return L;function L(G){return E.enter("lineEnding"),E.consume(G),E.exit("lineEnding"),Q}function Q(G){return E.enter("codeFencedFence"),Dn(G)?Fn(E,O,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):O(G)}function O(G){return G===d?(E.enter("codeFencedFenceSequence"),ne(G)):M(G)}function ne(G){return G===d?(_++,E.consume(G),ne):_>=c?(E.exit("codeFencedFenceSequence"),Dn(G)?Fn(E,Y,"whitespace")(G):Y(G)):M(G)}function Y(G){return G===null||an(G)?(E.exit("codeFencedFence"),I(G)):M(G)}}}function hU(e,t,r){const s=this;return i;function i(c){return c===null?r(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return s.parser.lazy[s.now().line]?r(c):t(c)}}const Rf={name:"codeIndented",tokenize:pU},mU={partial:!0,tokenize:fU};function pU(e,t,r){const s=this;return i;function i(f){return e.enter("codeIndented"),Fn(e,l,"linePrefix",5)(f)}function l(f){const v=s.events[s.events.length-1];return v&&v[1].type==="linePrefix"&&v[2].sliceSerialize(v[1],!0).length>=4?c(f):r(f)}function c(f){return f===null?m(f):an(f)?e.attempt(mU,c,m)(f):(e.enter("codeFlowValue"),d(f))}function d(f){return f===null||an(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),d)}function m(f){return e.exit("codeIndented"),t(f)}}function fU(e,t,r){const s=this;return i;function i(c){return s.parser.lazy[s.now().line]?r(c):an(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i):Fn(e,l,"linePrefix",5)(c)}function l(c){const d=s.events[s.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):an(c)?i(c):r(c)}}const gU={name:"codeText",previous:vU,resolve:bU,tokenize:wU};function bU(e){let t=e.length-4,r=3,s,i;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=r;++s<t;)if(e[s][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[t][1].type="codeTextPadding",r+=2,t-=2;break}}for(s=r-1,t++;++s<=t;)i===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(i=s):(s===t||e[s][1].type==="lineEnding")&&(e[i][1].type="codeTextData",s!==i+2&&(e[i][1].end=e[s-1][1].end,e.splice(i+2,s-i-2),t-=s-i-2,s=i+2),i=void 0);return e}function vU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function wU(e,t,r){let s=0,i,l;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),s++,d):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?r(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(l=e.enter("codeTextSequence"),i=0,v(g)):an(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(g))}function f(g){return g===null||g===32||g===96||an(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),f)}function v(g){return g===96?(e.consume(g),i++,v):i===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",f(g))}}class yU{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,r){const s=r??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,r,s){const i=r||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return s&&xc(this.left,s),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),xc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),xc(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const r=this.left.splice(t,Number.POSITIVE_INFINITY);xc(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);xc(this.left,r.reverse())}}}function xc(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function VD(e){const t={};let r=-1,s,i,l,c,d,m,f;const v=new yU(e);for(;++r<v.length;){for(;r in t;)r=t[r];if(s=v.get(r),r&&s[1].type==="chunkFlow"&&v.get(r-1)[1].type==="listItemPrefix"&&(m=s[1]._tokenizer.events,l=0,l<m.length&&m[l][1].type==="lineEndingBlank"&&(l+=2),l<m.length&&m[l][1].type==="content"))for(;++l<m.length&&m[l][1].type!=="content";)m[l][1].type==="chunkText"&&(m[l][1]._isInFirstContentOfListItem=!0,l++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,kU(v,r)),r=t[r],f=!0);else if(s[1]._container){for(l=r,i=void 0;l--;)if(c=v.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(i&&(v.get(i)[1].type="lineEndingBlank"),c[1].type="lineEnding",i=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;i&&(s[1].end={...v.get(i)[1].start},d=v.slice(i,r),d.unshift(s),v.splice(i,r-i+1,d))}}return zs(e,0,Number.POSITIVE_INFINITY,v.slice(0)),!f}function kU(e,t){const r=e.get(t)[1],s=e.get(t)[2];let i=t-1;const l=[];let c=r._tokenizer;c||(c=s.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,m=[],f={};let v,g,w=-1,k=r,y=0,C=0;const T=[C];for(;k;){for(;e.get(++i)[1]!==k;);l.push(i),k._tokenizer||(v=s.sliceStream(k),k.next||v.push(null),g&&c.defineSkip(k.start),k._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(v),k._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=k,k=k.next}for(k=r;++w<d.length;)d[w][0]==="exit"&&d[w-1][0]==="enter"&&d[w][1].type===d[w-1][1].type&&d[w][1].start.line!==d[w][1].end.line&&(C=w+1,T.push(C),k._tokenizer=void 0,k.previous=void 0,k=k.next);for(c.events=[],k?(k._tokenizer=void 0,k.previous=void 0):T.pop(),w=T.length;w--;){const j=d.slice(T[w],T[w+1]),N=l.pop();m.push([N,N+j.length-1]),e.splice(N,2,j)}for(m.reverse(),w=-1;++w<m.length;)f[y+m[w][0]]=y+m[w][1],y+=m[w][1]-m[w][0]-1;return f}const xU={resolve:CU,tokenize:jU},SU={partial:!0,tokenize:TU};function CU(e){return VD(e),e}function jU(e,t){let r;return s;function s(d){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),i(d)}function i(d){return d===null?l(d):an(d)?e.check(SU,c,l)(d):(e.consume(d),i)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function c(d){return e.consume(d),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function TU(e,t,r){const s=this;return i;function i(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Fn(e,l,"linePrefix")}function l(c){if(c===null||an(c))return r(c);const d=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,r,t)(c)}}function GD(e,t,r,s,i,l,c,d,m){const f=m||Number.POSITIVE_INFINITY;let v=0;return g;function g(j){return j===60?(e.enter(s),e.enter(i),e.enter(l),e.consume(j),e.exit(l),w):j===null||j===32||j===41||qh(j)?r(j):(e.enter(s),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),C(j))}function w(j){return j===62?(e.enter(l),e.consume(j),e.exit(l),e.exit(i),e.exit(s),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),k(j))}function k(j){return j===62?(e.exit("chunkString"),e.exit(d),w(j)):j===null||j===60||an(j)?r(j):(e.consume(j),j===92?y:k)}function y(j){return j===60||j===62||j===92?(e.consume(j),k):k(j)}function C(j){return!v&&(j===null||j===41||Xn(j))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(s),t(j)):v<f&&j===40?(e.consume(j),v++,C):j===41?(e.consume(j),v--,C):j===null||j===32||j===40||qh(j)?r(j):(e.consume(j),j===92?T:C)}function T(j){return j===40||j===41||j===92?(e.consume(j),C):C(j)}}function KD(e,t,r,s,i,l){const c=this;let d=0,m;return f;function f(k){return e.enter(s),e.enter(i),e.consume(k),e.exit(i),e.enter(l),v}function v(k){return d>999||k===null||k===91||k===93&&!m||k===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?r(k):k===93?(e.exit(l),e.enter(i),e.consume(k),e.exit(i),e.exit(s),t):an(k)?(e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),v):(e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||k===91||k===93||an(k)||d++>999?(e.exit("chunkString"),v(k)):(e.consume(k),m||(m=!Dn(k)),k===92?w:g)}function w(k){return k===91||k===92||k===93?(e.consume(k),d++,g):g(k)}}function YD(e,t,r,s,i,l){let c;return d;function d(w){return w===34||w===39||w===40?(e.enter(s),e.enter(i),e.consume(w),e.exit(i),c=w===40?41:w,m):r(w)}function m(w){return w===c?(e.enter(i),e.consume(w),e.exit(i),e.exit(s),t):(e.enter(l),f(w))}function f(w){return w===c?(e.exit(l),m(c)):w===null?r(w):an(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),Fn(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),v(w))}function v(w){return w===c||w===null||an(w)?(e.exit("chunkString"),f(w)):(e.consume(w),w===92?g:v)}function g(w){return w===c||w===92?(e.consume(w),v):v(w)}}function Gc(e,t){let r;return s;function s(i){return an(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),r=!0,s):Dn(i)?Fn(e,s,r?"linePrefix":"lineSuffix")(i):t(i)}}const NU={name:"definition",tokenize:DU},PU={partial:!0,tokenize:RU};function DU(e,t,r){const s=this;let i;return l;function l(k){return e.enter("definition"),c(k)}function c(k){return KD.call(s,e,d,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(k)}function d(k){return i=ki(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),m):r(k)}function m(k){return Xn(k)?Gc(e,f)(k):f(k)}function f(k){return GD(e,v,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(k)}function v(k){return e.attempt(PU,g,g)(k)}function g(k){return Dn(k)?Fn(e,w,"whitespace")(k):w(k)}function w(k){return k===null||an(k)?(e.exit("definition"),s.parser.defined.push(i),t(k)):r(k)}}function RU(e,t,r){return s;function s(d){return Xn(d)?Gc(e,i)(d):r(d)}function i(d){return YD(e,l,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return Dn(d)?Fn(e,c,"whitespace")(d):c(d)}function c(d){return d===null||an(d)?t(d):r(d)}}const MU={name:"hardBreakEscape",tokenize:AU};function AU(e,t,r){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return an(l)?(e.exit("hardBreakEscape"),t(l)):r(l)}}const IU={name:"headingAtx",resolve:EU,tokenize:LU};function EU(e,t){let r=e.length-2,s=3,i,l;return e[s][1].type==="whitespace"&&(s+=2),r-2>s&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(s===r-1||r-4>s&&e[r-2][1].type==="whitespace")&&(r-=s+1===r?2:4),r>s&&(i={type:"atxHeadingText",start:e[s][1].start,end:e[r][1].end},l={type:"chunkText",start:e[s][1].start,end:e[r][1].end,contentType:"text"},zs(e,s,r-s+1,[["enter",i,t],["enter",l,t],["exit",l,t],["exit",i,t]])),e}function LU(e,t,r){let s=0;return i;function i(v){return e.enter("atxHeading"),l(v)}function l(v){return e.enter("atxHeadingSequence"),c(v)}function c(v){return v===35&&s++<6?(e.consume(v),c):v===null||Xn(v)?(e.exit("atxHeadingSequence"),d(v)):r(v)}function d(v){return v===35?(e.enter("atxHeadingSequence"),m(v)):v===null||an(v)?(e.exit("atxHeading"),t(v)):Dn(v)?Fn(e,d,"whitespace")(v):(e.enter("atxHeadingText"),f(v))}function m(v){return v===35?(e.consume(v),m):(e.exit("atxHeadingSequence"),d(v))}function f(v){return v===null||v===35||Xn(v)?(e.exit("atxHeadingText"),d(v)):(e.consume(v),f)}}const FU=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],HS=["pre","script","style","textarea"],_U={concrete:!0,name:"htmlFlow",resolveTo:WU,tokenize:UU},OU={partial:!0,tokenize:zU},BU={partial:!0,tokenize:HU};function WU(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function UU(e,t,r){const s=this;let i,l,c,d,m;return f;function f(R){return v(R)}function v(R){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(R),g}function g(R){return R===33?(e.consume(R),w):R===47?(e.consume(R),l=!0,C):R===63?(e.consume(R),i=3,s.interrupt?t:P):fs(R)?(e.consume(R),c=String.fromCharCode(R),T):r(R)}function w(R){return R===45?(e.consume(R),i=2,k):R===91?(e.consume(R),i=5,d=0,y):fs(R)?(e.consume(R),i=4,s.interrupt?t:P):r(R)}function k(R){return R===45?(e.consume(R),s.interrupt?t:P):r(R)}function y(R){const Se="CDATA[";return R===Se.charCodeAt(d++)?(e.consume(R),d===Se.length?s.interrupt?t:O:y):r(R)}function C(R){return fs(R)?(e.consume(R),c=String.fromCharCode(R),T):r(R)}function T(R){if(R===null||R===47||R===62||Xn(R)){const Se=R===47,se=c.toLowerCase();return!Se&&!l&&HS.includes(se)?(i=1,s.interrupt?t(R):O(R)):FU.includes(c.toLowerCase())?(i=6,Se?(e.consume(R),j):s.interrupt?t(R):O(R)):(i=7,s.interrupt&&!s.parser.lazy[s.now().line]?r(R):l?N(R):D(R))}return R===45||cs(R)?(e.consume(R),c+=String.fromCharCode(R),T):r(R)}function j(R){return R===62?(e.consume(R),s.interrupt?t:O):r(R)}function N(R){return Dn(R)?(e.consume(R),N):L(R)}function D(R){return R===47?(e.consume(R),L):R===58||R===95||fs(R)?(e.consume(R),F):Dn(R)?(e.consume(R),D):L(R)}function F(R){return R===45||R===46||R===58||R===95||cs(R)?(e.consume(R),F):W(R)}function W(R){return R===61?(e.consume(R),E):Dn(R)?(e.consume(R),W):D(R)}function E(R){return R===null||R===60||R===61||R===62||R===96?r(R):R===34||R===39?(e.consume(R),m=R,I):Dn(R)?(e.consume(R),E):M(R)}function I(R){return R===m?(e.consume(R),m=null,_):R===null||an(R)?r(R):(e.consume(R),I)}function M(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||Xn(R)?W(R):(e.consume(R),M)}function _(R){return R===47||R===62||Dn(R)?D(R):r(R)}function L(R){return R===62?(e.consume(R),Q):r(R)}function Q(R){return R===null||an(R)?O(R):Dn(R)?(e.consume(R),Q):r(R)}function O(R){return R===45&&i===2?(e.consume(R),te):R===60&&i===1?(e.consume(R),K):R===62&&i===4?(e.consume(R),U):R===63&&i===3?(e.consume(R),P):R===93&&i===5?(e.consume(R),q):an(R)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(OU,X,ne)(R)):R===null||an(R)?(e.exit("htmlFlowData"),ne(R)):(e.consume(R),O)}function ne(R){return e.check(BU,Y,X)(R)}function Y(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),G}function G(R){return R===null||an(R)?ne(R):(e.enter("htmlFlowData"),O(R))}function te(R){return R===45?(e.consume(R),P):O(R)}function K(R){return R===47?(e.consume(R),c="",z):O(R)}function z(R){if(R===62){const Se=c.toLowerCase();return HS.includes(Se)?(e.consume(R),U):O(R)}return fs(R)&&c.length<8?(e.consume(R),c+=String.fromCharCode(R),z):O(R)}function q(R){return R===93?(e.consume(R),P):O(R)}function P(R){return R===62?(e.consume(R),U):R===45&&i===2?(e.consume(R),P):O(R)}function U(R){return R===null||an(R)?(e.exit("htmlFlowData"),X(R)):(e.consume(R),U)}function X(R){return e.exit("htmlFlow"),t(R)}}function HU(e,t,r){const s=this;return i;function i(c){return an(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):r(c)}function l(c){return s.parser.lazy[s.now().line]?r(c):t(c)}}function zU(e,t,r){return s;function s(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Du,t,r)}}const qU={name:"htmlText",tokenize:$U};function $U(e,t,r){const s=this;let i,l,c;return d;function d(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),m}function m(P){return P===33?(e.consume(P),f):P===47?(e.consume(P),W):P===63?(e.consume(P),D):fs(P)?(e.consume(P),M):r(P)}function f(P){return P===45?(e.consume(P),v):P===91?(e.consume(P),l=0,y):fs(P)?(e.consume(P),N):r(P)}function v(P){return P===45?(e.consume(P),k):r(P)}function g(P){return P===null?r(P):P===45?(e.consume(P),w):an(P)?(c=g,K(P)):(e.consume(P),g)}function w(P){return P===45?(e.consume(P),k):g(P)}function k(P){return P===62?te(P):P===45?w(P):g(P)}function y(P){const U="CDATA[";return P===U.charCodeAt(l++)?(e.consume(P),l===U.length?C:y):r(P)}function C(P){return P===null?r(P):P===93?(e.consume(P),T):an(P)?(c=C,K(P)):(e.consume(P),C)}function T(P){return P===93?(e.consume(P),j):C(P)}function j(P){return P===62?te(P):P===93?(e.consume(P),j):C(P)}function N(P){return P===null||P===62?te(P):an(P)?(c=N,K(P)):(e.consume(P),N)}function D(P){return P===null?r(P):P===63?(e.consume(P),F):an(P)?(c=D,K(P)):(e.consume(P),D)}function F(P){return P===62?te(P):D(P)}function W(P){return fs(P)?(e.consume(P),E):r(P)}function E(P){return P===45||cs(P)?(e.consume(P),E):I(P)}function I(P){return an(P)?(c=I,K(P)):Dn(P)?(e.consume(P),I):te(P)}function M(P){return P===45||cs(P)?(e.consume(P),M):P===47||P===62||Xn(P)?_(P):r(P)}function _(P){return P===47?(e.consume(P),te):P===58||P===95||fs(P)?(e.consume(P),L):an(P)?(c=_,K(P)):Dn(P)?(e.consume(P),_):te(P)}function L(P){return P===45||P===46||P===58||P===95||cs(P)?(e.consume(P),L):Q(P)}function Q(P){return P===61?(e.consume(P),O):an(P)?(c=Q,K(P)):Dn(P)?(e.consume(P),Q):_(P)}function O(P){return P===null||P===60||P===61||P===62||P===96?r(P):P===34||P===39?(e.consume(P),i=P,ne):an(P)?(c=O,K(P)):Dn(P)?(e.consume(P),O):(e.consume(P),Y)}function ne(P){return P===i?(e.consume(P),i=void 0,G):P===null?r(P):an(P)?(c=ne,K(P)):(e.consume(P),ne)}function Y(P){return P===null||P===34||P===39||P===60||P===61||P===96?r(P):P===47||P===62||Xn(P)?_(P):(e.consume(P),Y)}function G(P){return P===47||P===62||Xn(P)?_(P):r(P)}function te(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):r(P)}function K(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),z}function z(P){return Dn(P)?Fn(e,q,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):q(P)}function q(P){return e.enter("htmlTextData"),c(P)}}const Uv={name:"labelEnd",resolveAll:YU,resolveTo:XU,tokenize:QU},VU={tokenize:JU},GU={tokenize:ZU},KU={tokenize:eH};function YU(e){let t=-1;const r=[];for(;++t<e.length;){const s=e[t][1];if(r.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const i=s.type==="labelImage"?4:2;s.type="data",t+=i}}return e.length!==r.length&&zs(e,0,e.length,r),e}function XU(e,t){let r=e.length,s=0,i,l,c,d;for(;r--;)if(i=e[r][1],l){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(c){if(e[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(l=r,i.type!=="labelLink")){s=2;break}}else i.type==="labelEnd"&&(c=r);const m={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},v={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[c-2][1].start}};return d=[["enter",m,t],["enter",f,t]],d=si(d,e.slice(l+1,l+s+3)),d=si(d,[["enter",v,t]]),d=si(d,Sm(t.parser.constructs.insideSpan.null,e.slice(l+s+4,c-3),t)),d=si(d,[["exit",v,t],e[c-2],e[c-1],["exit",f,t]]),d=si(d,e.slice(c+1)),d=si(d,[["exit",m,t]]),zs(e,l,e.length,d),e}function QU(e,t,r){const s=this;let i=s.events.length,l,c;for(;i--;)if((s.events[i][1].type==="labelImage"||s.events[i][1].type==="labelLink")&&!s.events[i][1]._balanced){l=s.events[i][1];break}return d;function d(w){return l?l._inactive?g(w):(c=s.parser.defined.includes(ki(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(w),e.exit("labelMarker"),e.exit("labelEnd"),m):r(w)}function m(w){return w===40?e.attempt(VU,v,c?v:g)(w):w===91?e.attempt(GU,v,c?f:g)(w):c?v(w):g(w)}function f(w){return e.attempt(KU,v,g)(w)}function v(w){return t(w)}function g(w){return l._balanced=!0,r(w)}}function JU(e,t,r){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),i}function i(g){return Xn(g)?Gc(e,l)(g):l(g)}function l(g){return g===41?v(g):GD(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return Xn(g)?Gc(e,m)(g):v(g)}function d(g){return r(g)}function m(g){return g===34||g===39||g===40?YD(e,f,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):v(g)}function f(g){return Xn(g)?Gc(e,v)(g):v(g)}function v(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):r(g)}}function ZU(e,t,r){const s=this;return i;function i(d){return KD.call(s,e,l,c,"reference","referenceMarker","referenceString")(d)}function l(d){return s.parser.defined.includes(ki(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(d):r(d)}function c(d){return r(d)}}function eH(e,t,r){return s;function s(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),i}function i(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):r(l)}}const tH={name:"labelStartImage",resolveAll:Uv.resolveAll,tokenize:nH};function nH(e,t,r){const s=this;return i;function i(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),c):r(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in s.parser.constructs?r(d):t(d)}}const rH={name:"labelStartLink",resolveAll:Uv.resolveAll,tokenize:sH};function sH(e,t,r){const s=this;return i;function i(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?r(c):t(c)}}const Mf={name:"lineEnding",tokenize:iH};function iH(e,t){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Fn(e,t,"linePrefix")}}const yh={name:"thematicBreak",tokenize:aH};function aH(e,t,r){let s=0,i;return l;function l(f){return e.enter("thematicBreak"),c(f)}function c(f){return i=f,d(f)}function d(f){return f===i?(e.enter("thematicBreakSequence"),m(f)):s>=3&&(f===null||an(f))?(e.exit("thematicBreak"),t(f)):r(f)}function m(f){return f===i?(e.consume(f),s++,m):(e.exit("thematicBreakSequence"),Dn(f)?Fn(e,d,"whitespace")(f):d(f))}}const js={continuation:{tokenize:uH},exit:hH,name:"list",tokenize:cH},oH={partial:!0,tokenize:mH},lH={partial:!0,tokenize:dH};function cH(e,t,r){const s=this,i=s.events[s.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,c=0;return d;function d(k){const y=s.containerState.type||(k===42||k===43||k===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!s.containerState.marker||k===s.containerState.marker:ob(k)){if(s.containerState.type||(s.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),k===42||k===45?e.check(yh,r,f)(k):f(k);if(!s.interrupt||k===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(k)}return r(k)}function m(k){return ob(k)&&++c<10?(e.consume(k),m):(!s.interrupt||c<2)&&(s.containerState.marker?k===s.containerState.marker:k===41||k===46)?(e.exit("listItemValue"),f(k)):r(k)}function f(k){return e.enter("listItemMarker"),e.consume(k),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||k,e.check(Du,s.interrupt?r:v,e.attempt(oH,w,g))}function v(k){return s.containerState.initialBlankLine=!0,l++,w(k)}function g(k){return Dn(k)?(e.enter("listItemPrefixWhitespace"),e.consume(k),e.exit("listItemPrefixWhitespace"),w):r(k)}function w(k){return s.containerState.size=l+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(k)}}function uH(e,t,r){const s=this;return s.containerState._closeFlow=void 0,e.check(Du,i,l);function i(d){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Fn(e,t,"listItemIndent",s.containerState.size+1)(d)}function l(d){return s.containerState.furtherBlankLines||!Dn(d)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(d)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(lH,t,c)(d))}function c(d){return s.containerState._closeFlow=!0,s.interrupt=void 0,Fn(e,e.attempt(js,t,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function dH(e,t,r){const s=this;return Fn(e,i,"listItemIndent",s.containerState.size+1);function i(l){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(l):r(l)}}function hH(e){e.exit(this.containerState.type)}function mH(e,t,r){const s=this;return Fn(e,i,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const c=s.events[s.events.length-1];return!Dn(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):r(l)}}const zS={name:"setextUnderline",resolveTo:pH,tokenize:fH};function pH(e,t){let r=e.length,s,i,l;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){s=r;break}e[r][1].type==="paragraph"&&(i=r)}else e[r][1].type==="content"&&e.splice(r,1),!l&&e[r][1].type==="definition"&&(l=r);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",c,t]),e.splice(l+1,0,["exit",e[s][1],t]),e[s][1].end={...e[l][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function fH(e,t,r){const s=this;let i;return l;function l(f){let v=s.events.length,g;for(;v--;)if(s.events[v][1].type!=="lineEnding"&&s.events[v][1].type!=="linePrefix"&&s.events[v][1].type!=="content"){g=s.events[v][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),i=f,c(f)):r(f)}function c(f){return e.enter("setextHeadingLineSequence"),d(f)}function d(f){return f===i?(e.consume(f),d):(e.exit("setextHeadingLineSequence"),Dn(f)?Fn(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||an(f)?(e.exit("setextHeadingLine"),t(f)):r(f)}}const gH={tokenize:bH};function bH(e){const t=this,r=e.attempt(Du,s,e.attempt(this.parser.constructs.flowInitial,i,Fn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xU,i)),"linePrefix")));return r;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const vH={resolveAll:QD()},wH=XD("string"),yH=XD("text");function XD(e){return{resolveAll:QD(e==="text"?kH:void 0),tokenize:t};function t(r){const s=this,i=this.parser.constructs[e],l=r.attempt(i,c,d);return c;function c(v){return f(v)?l(v):d(v)}function d(v){if(v===null){r.consume(v);return}return r.enter("data"),r.consume(v),m}function m(v){return f(v)?(r.exit("data"),l(v)):(r.consume(v),m)}function f(v){if(v===null)return!0;const g=i[v];let w=-1;if(g)for(;++w<g.length;){const k=g[w];if(!k.previous||k.previous.call(s,s.previous))return!0}return!1}}}function QD(e){return t;function t(r,s){let i=-1,l;for(;++i<=r.length;)l===void 0?r[i]&&r[i][1].type==="data"&&(l=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==l+2&&(r[l][1].end=r[i-1][1].end,r.splice(l+2,i-l-2),i=l+2),l=void 0);return e?e(r,s):r}}function kH(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const s=e[r-1][1],i=t.sliceStream(s);let l=i.length,c=-1,d=0,m;for(;l--;){const f=i[l];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(f===-2)m=!0,d++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(d=0),d){const f={type:r===e.length||m||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:s.start._bufferIndex+c,_index:s.start._index+l,line:s.end.line,column:s.end.column-d,offset:s.end.offset-d},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(e.splice(r,0,["enter",f,t],["exit",f,t]),r+=2)}r++}return e}const xH={42:js,43:js,45:js,48:js,49:js,50:js,51:js,52:js,53:js,54:js,55:js,56:js,57:js,62:zD},SH={91:NU},CH={[-2]:Rf,[-1]:Rf,32:Rf},jH={35:IU,42:yh,45:[zS,yh],60:_U,61:zS,95:yh,96:US,126:US},TH={38:$D,92:qD},NH={[-5]:Mf,[-4]:Mf,[-3]:Mf,33:tH,38:$D,42:lb,60:[rU,qU],91:rH,92:[MU,qD],93:Uv,95:lb,96:gU},PH={null:[lb,vH]},DH={null:[42,95]},RH={null:[]},MH=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:DH,contentInitial:SH,disable:RH,document:xH,flow:jH,flowInitial:CH,insideSpan:PH,string:TH,text:NH},Symbol.toStringTag,{value:"Module"}));function AH(e,t,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const i={},l=[];let c=[],d=[];const m={attempt:I(W),check:I(E),consume:N,enter:D,exit:F,interrupt:I(E,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:y,parser:e,previous:null,sliceSerialize:w,sliceStream:k,write:g};let v=t.tokenize.call(f,m);return t.resolveAll&&l.push(t),f;function g(Q){return c=si(c,Q),T(),c[c.length-1]!==null?[]:(M(t,0),f.events=Sm(l,f.events,f),f.events)}function w(Q,O){return EH(k(Q),O)}function k(Q){return IH(c,Q)}function y(){const{_bufferIndex:Q,_index:O,line:ne,column:Y,offset:G}=s;return{_bufferIndex:Q,_index:O,line:ne,column:Y,offset:G}}function C(Q){i[Q.line]=Q.column,L()}function T(){let Q;for(;s._index<c.length;){const O=c[s._index];if(typeof O=="string")for(Q=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===Q&&s._bufferIndex<O.length;)j(O.charCodeAt(s._bufferIndex));else j(O)}}function j(Q){v=v(Q)}function N(Q){an(Q)?(s.line++,s.column=1,s.offset+=Q===-3?2:1,L()):Q!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=Q}function D(Q,O){const ne=O||{};return ne.type=Q,ne.start=y(),f.events.push(["enter",ne,f]),d.push(ne),ne}function F(Q){const O=d.pop();return O.end=y(),f.events.push(["exit",O,f]),O}function W(Q,O){M(Q,O.from)}function E(Q,O){O.restore()}function I(Q,O){return ne;function ne(Y,G,te){let K,z,q,P;return Array.isArray(Y)?X(Y):"tokenize"in Y?X([Y]):U(Y);function U(J){return Ne;function Ne(Ee){const ie=Ee!==null&&J[Ee],xe=Ee!==null&&J.null,lt=[...Array.isArray(ie)?ie:ie?[ie]:[],...Array.isArray(xe)?xe:xe?[xe]:[]];return X(lt)(Ee)}}function X(J){return K=J,z=0,J.length===0?te:R(J[z])}function R(J){return Ne;function Ne(Ee){return P=_(),q=J,J.partial||(f.currentConstruct=J),J.name&&f.parser.constructs.disable.null.includes(J.name)?se():J.tokenize.call(O?Object.assign(Object.create(f),O):f,m,Se,se)(Ee)}}function Se(J){return Q(q,P),G}function se(J){return P.restore(),++z<K.length?R(K[z]):te}}}function M(Q,O){Q.resolveAll&&!l.includes(Q)&&l.push(Q),Q.resolve&&zs(f.events,O,f.events.length-O,Q.resolve(f.events.slice(O),f)),Q.resolveTo&&(f.events=Q.resolveTo(f.events,f))}function _(){const Q=y(),O=f.previous,ne=f.currentConstruct,Y=f.events.length,G=Array.from(d);return{from:Y,restore:te};function te(){s=Q,f.previous=O,f.currentConstruct=ne,f.events.length=Y,d=G,L()}}function L(){s.line in i&&s.column<2&&(s.column=i[s.line],s.offset+=i[s.line]-1)}}function IH(e,t){const r=t.start._index,s=t.start._bufferIndex,i=t.end._index,l=t.end._bufferIndex;let c;if(r===i)c=[e[r].slice(s,l)];else{if(c=e.slice(r,i),s>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(s):c.shift()}l>0&&c.push(e[i].slice(0,l))}return c}function EH(e,t){let r=-1;const s=[];let i;for(;++r<e.length;){const l=e[r];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
|
|
71
|
+
`;break}case-3:{c=`\r
|
|
72
|
+
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&i)continue;c=" ";break}default:c=String.fromCharCode(l)}i=l===-2,s.push(c)}return s.join("")}function LH(e){const s={constructs:UD([MH,...(e||{}).extensions||[]]),content:i(XW),defined:[],document:i(JW),flow:i(gH),lazy:{},string:i(wH),text:i(yH)};return s;function i(l){return c;function c(d){return AH(s,l,d)}}}function FH(e){for(;!VD(e););return e}const qS=/[\0\t\n\r]/g;function _H(){let e=1,t="",r=!0,s;return i;function i(l,c,d){const m=[];let f,v,g,w,k;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),g=0,t="",r&&(l.charCodeAt(0)===65279&&g++,r=void 0);g<l.length;){if(qS.lastIndex=g,f=qS.exec(l),w=f&&f.index!==void 0?f.index:l.length,k=l.charCodeAt(w),!f){t=l.slice(g);break}if(k===10&&g===w&&s)m.push(-3),s=void 0;else switch(s&&(m.push(-5),s=void 0),g<w&&(m.push(l.slice(g,w)),e+=w-g),k){case 0:{m.push(65533),e++;break}case 9:{for(v=Math.ceil(e/4)*4,m.push(-2);e++<v;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:s=!0,e=1}g=w+1}return d&&(s&&m.push(-5),t&&m.push(t),m.push(null)),m}}const OH=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function BH(e){return e.replace(OH,WH)}function WH(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),l=i===120||i===88;return HD(r.slice(l?2:1),l?16:10)}return Wv(r)||e}const JD={}.hasOwnProperty;function UH(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),HH(r)(FH(LH(r).document().write(_H()(e,t,!0))))}function HH(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Ye),autolinkProtocol:_,autolinkEmail:_,atxHeading:l(nt),blockQuote:l(xe),characterEscape:_,characterReference:_,codeFenced:l(lt),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(lt,c),codeText:l(Oe,c),codeTextData:_,data:_,codeFlowValue:_,definition:l(bt),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(Ct),hardBreakEscape:l(et),hardBreakTrailing:l(et),htmlFlow:l(De,c),htmlFlowData:_,htmlText:l(De,c),htmlTextData:_,image:l(Ue),label:c,link:l(Ye),listItem:l(He),listItemValue:w,listOrdered:l(ye,g),listUnordered:l(ye),paragraph:l(je),reference:R,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(nt),strong:l(Fe),thematicBreak:l(kt)},exit:{atxHeading:m(),atxHeadingSequence:W,autolink:m(),autolinkEmail:ie,autolinkProtocol:Ee,blockQuote:m(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:J,characterReference:Ne,codeFenced:m(T),codeFencedFence:C,codeFencedFenceInfo:k,codeFencedFenceMeta:y,codeFlowValue:L,codeIndented:m(j),codeText:m(G),codeTextData:L,data:L,definition:m(),definitionDestinationString:F,definitionLabelString:N,definitionTitleString:D,emphasis:m(),hardBreakEscape:m(O),hardBreakTrailing:m(O),htmlFlow:m(ne),htmlFlowData:L,htmlText:m(Y),htmlTextData:L,image:m(K),label:q,labelText:z,lineEnding:Q,link:m(te),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Se,resourceDestinationString:P,resourceTitleString:U,resource:X,setextHeading:m(M),setextHeadingLineSequence:I,setextHeadingText:E,strong:m(),thematicBreak:m()}};ZD(t,(e||{}).mdastExtensions||[]);const r={};return s;function s(me){let Me={type:"root",children:[]};const Xe={stack:[Me],tokenStack:[],config:t,enter:d,exit:f,buffer:c,resume:v,data:r},ze=[];let vt=-1;for(;++vt<me.length;)if(me[vt][1].type==="listOrdered"||me[vt][1].type==="listUnordered")if(me[vt][0]==="enter")ze.push(vt);else{const ht=ze.pop();vt=i(me,ht,vt)}for(vt=-1;++vt<me.length;){const ht=t[me[vt][0]];JD.call(ht,me[vt][1].type)&&ht[me[vt][1].type].call(Object.assign({sliceSerialize:me[vt][2].sliceSerialize},Xe),me[vt][1])}if(Xe.tokenStack.length>0){const ht=Xe.tokenStack[Xe.tokenStack.length-1];(ht[1]||$S).call(Xe,void 0,ht[0])}for(Me.position={start:Ra(me.length>0?me[0][1].start:{line:1,column:1,offset:0}),end:Ra(me.length>0?me[me.length-2][1].end:{line:1,column:1,offset:0})},vt=-1;++vt<t.transforms.length;)Me=t.transforms[vt](Me)||Me;return Me}function i(me,Me,Xe){let ze=Me-1,vt=-1,ht=!1,pe,$e,Nt,Rt;for(;++ze<=Xe;){const Ft=me[ze];switch(Ft[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ft[0]==="enter"?vt++:vt--,Rt=void 0;break}case"lineEndingBlank":{Ft[0]==="enter"&&(pe&&!Rt&&!vt&&!Nt&&(Nt=ze),Rt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Rt=void 0}if(!vt&&Ft[0]==="enter"&&Ft[1].type==="listItemPrefix"||vt===-1&&Ft[0]==="exit"&&(Ft[1].type==="listUnordered"||Ft[1].type==="listOrdered")){if(pe){let Wt=ze;for($e=void 0;Wt--;){const Kt=me[Wt];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;$e&&(me[$e][1].type="lineEndingBlank",ht=!0),Kt[1].type="lineEnding",$e=Wt}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}Nt&&(!$e||Nt<$e)&&(pe._spread=!0),pe.end=Object.assign({},$e?me[$e][1].start:Ft[1].end),me.splice($e||ze,0,["exit",pe,Ft[2]]),ze++,Xe++}if(Ft[1].type==="listItemPrefix"){const Wt={type:"listItem",_spread:!1,start:Object.assign({},Ft[1].start),end:void 0};pe=Wt,me.splice(ze,0,["enter",Wt,Ft[2]]),ze++,Xe++,Nt=void 0,Rt=!0}}}return me[Me][1]._spread=ht,Xe}function l(me,Me){return Xe;function Xe(ze){d.call(this,me(ze),ze),Me&&Me.call(this,ze)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(me,Me,Xe){this.stack[this.stack.length-1].children.push(me),this.stack.push(me),this.tokenStack.push([Me,Xe||void 0]),me.position={start:Ra(Me.start),end:void 0}}function m(me){return Me;function Me(Xe){me&&me.call(this,Xe),f.call(this,Xe)}}function f(me,Me){const Xe=this.stack.pop(),ze=this.tokenStack.pop();if(ze)ze[0].type!==me.type&&(Me?Me.call(this,me,ze[0]):(ze[1]||$S).call(this,me,ze[0]));else throw new Error("Cannot close `"+me.type+"` ("+Vc({start:me.start,end:me.end})+"): it’s not open");Xe.position.end=Ra(me.end)}function v(){return Bv(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function w(me){if(this.data.expectingFirstListItemValue){const Me=this.stack[this.stack.length-2];Me.start=Number.parseInt(this.sliceSerialize(me),10),this.data.expectingFirstListItemValue=void 0}}function k(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.lang=me}function y(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.meta=me}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.value=me.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.value=me.replace(/(\r?\n|\r)$/g,"")}function N(me){const Me=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=Me,Xe.identifier=ki(this.sliceSerialize(me)).toLowerCase()}function D(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.title=me}function F(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.url=me}function W(me){const Me=this.stack[this.stack.length-1];if(!Me.depth){const Xe=this.sliceSerialize(me).length;Me.depth=Xe}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function I(me){const Me=this.stack[this.stack.length-1];Me.depth=this.sliceSerialize(me).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function _(me){const Xe=this.stack[this.stack.length-1].children;let ze=Xe[Xe.length-1];(!ze||ze.type!=="text")&&(ze=Ve(),ze.position={start:Ra(me.start),end:void 0},Xe.push(ze)),this.stack.push(ze)}function L(me){const Me=this.stack.pop();Me.value+=this.sliceSerialize(me),Me.position.end=Ra(me.end)}function Q(me){const Me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Xe=Me.children[Me.children.length-1];Xe.position.end=Ra(me.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Me.type)&&(_.call(this,me),L.call(this,me))}function O(){this.data.atHardBreak=!0}function ne(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.value=me}function Y(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.value=me}function G(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.value=me}function te(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=Me,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function K(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=Me,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function z(me){const Me=this.sliceSerialize(me),Xe=this.stack[this.stack.length-2];Xe.label=BH(Me),Xe.identifier=ki(Me).toLowerCase()}function q(){const me=this.stack[this.stack.length-1],Me=this.resume(),Xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Xe.type==="link"){const ze=me.children;Xe.children=ze}else Xe.alt=Me}function P(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.url=me}function U(){const me=this.resume(),Me=this.stack[this.stack.length-1];Me.title=me}function X(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function Se(me){const Me=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=Me,Xe.identifier=ki(this.sliceSerialize(me)).toLowerCase(),this.data.referenceType="full"}function se(me){this.data.characterReferenceType=me.type}function J(me){const Me=this.sliceSerialize(me),Xe=this.data.characterReferenceType;let ze;Xe?(ze=HD(Me,Xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ze=Wv(Me);const vt=this.stack[this.stack.length-1];vt.value+=ze}function Ne(me){const Me=this.stack.pop();Me.position.end=Ra(me.end)}function Ee(me){L.call(this,me);const Me=this.stack[this.stack.length-1];Me.url=this.sliceSerialize(me)}function ie(me){L.call(this,me);const Me=this.stack[this.stack.length-1];Me.url="mailto:"+this.sliceSerialize(me)}function xe(){return{type:"blockquote",children:[]}}function lt(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function bt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ct(){return{type:"emphasis",children:[]}}function nt(){return{type:"heading",depth:0,children:[]}}function et(){return{type:"break"}}function De(){return{type:"html",value:""}}function Ue(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function ye(me){return{type:"list",ordered:me.type==="listOrdered",start:null,spread:me._spread,children:[]}}function He(me){return{type:"listItem",spread:me._spread,checked:null,children:[]}}function je(){return{type:"paragraph",children:[]}}function Fe(){return{type:"strong",children:[]}}function Ve(){return{type:"text",value:""}}function kt(){return{type:"thematicBreak"}}}function Ra(e){return{line:e.line,column:e.column,offset:e.offset}}function ZD(e,t){let r=-1;for(;++r<t.length;){const s=t[r];Array.isArray(s)?ZD(e,s):zH(e,s)}}function zH(e,t){let r;for(r in t)if(JD.call(t,r))switch(r){case"canContainEols":{const s=t[r];s&&e[r].push(...s);break}case"transforms":{const s=t[r];s&&e[r].push(...s);break}case"enter":case"exit":{const s=t[r];s&&Object.assign(e[r],s);break}}}function $S(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Vc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Vc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Vc({start:t.start,end:t.end})+") is still open")}function qH(e){const t=this;t.parser=r;function r(s){return UH(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $H(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function VH(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
|
|
73
|
+
`}]}function GH(e,t){const r=t.value?t.value+`
|
|
74
|
+
`:"",s={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(s.className=["language-"+i[0]]);let l={type:"element",tagName:"code",properties:s,children:[{type:"text",value:r}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function KH(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function YH(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function XH(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),i=Bl(s.toLowerCase()),l=e.footnoteOrder.indexOf(s);let c,d=e.footnoteCounts.get(s);d===void 0?(d=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=l+1,d+=1,e.footnoteCounts.set(s,d);const m={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+i,id:r+"fnref-"+i+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(t,f),e.applyData(t,f)}function QH(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function JH(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function e0(e,t){const r=t.referenceType;let s="]";if(r==="collapsed"?s+="[]":r==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const i=e.all(t),l=i[0];l&&l.type==="text"?l.value="["+l.value:i.unshift({type:"text",value:"["});const c=i[i.length-1];return c&&c.type==="text"?c.value+=s:i.push({type:"text",value:s}),i}function ZH(e,t){const r=String(t.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return e0(e,t);const i={src:Bl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(i.title=s.title);const l={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,l),e.applyData(t,l)}function ez(e,t){const r={src:Bl(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,s),e.applyData(t,s)}function tz(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const s={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,s),e.applyData(t,s)}function nz(e,t){const r=String(t.identifier).toUpperCase(),s=e.definitionById.get(r);if(!s)return e0(e,t);const i={href:Bl(s.url||"")};s.title!==null&&s.title!==void 0&&(i.title=s.title);const l={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function rz(e,t){const r={href:Bl(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const s={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function sz(e,t,r){const s=e.all(t),i=r?iz(r):t0(t),l={},c=[];if(typeof t.checked=="boolean"){const v=s[0];let g;v&&v.type==="element"&&v.tagName==="p"?g=v:(g={type:"element",tagName:"p",properties:{},children:[]},s.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let d=-1;for(;++d<s.length;){const v=s[d];(i||d!==0||v.type!=="element"||v.tagName!=="p")&&c.push({type:"text",value:`
|
|
75
|
+
`}),v.type==="element"&&v.tagName==="p"&&!i?c.push(...v.children):c.push(v)}const m=s[s.length-1];m&&(i||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
|
|
76
|
+
`});const f={type:"element",tagName:"li",properties:l,children:c};return e.patch(t,f),e.applyData(t,f)}function iz(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const r=e.children;let s=-1;for(;!t&&++s<r.length;)t=t0(r[s])}return t}function t0(e){const t=e.spread;return t??e.children.length>1}function az(e,t){const r={},s=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++i<s.length;){const c=s[i];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:r,children:e.wrap(s,!0)};return e.patch(t,l),e.applyData(t,l)}function oz(e,t){const r={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function lz(e,t){const r={type:"root",children:e.wrap(e.all(t))};return e.patch(t,r),e.applyData(t,r)}function cz(e,t){const r={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function uz(e,t){const r=e.all(t),s=r.shift(),i=[];if(s){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],c),i.push(c)}if(r.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},d=Lv(t.children[1]),m=ED(t.children[t.children.length-1]);d&&m&&(c.position={start:d,end:m}),i.push(c)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,l),e.applyData(t,l)}function dz(e,t,r){const s=r?r.children:void 0,l=(s?s.indexOf(t):1)===0?"th":"td",c=r&&r.type==="table"?r.align:void 0,d=c?c.length:t.children.length;let m=-1;const f=[];for(;++m<d;){const g=t.children[m],w={},k=c?c[m]:void 0;k&&(w.align=k);let y={type:"element",tagName:l,properties:w,children:[]};g&&(y.children=e.all(g),e.patch(g,y),y=e.applyData(g,y)),f.push(y)}const v={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,v),e.applyData(t,v)}function hz(e,t){const r={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}const VS=9,GS=32;function mz(e){const t=String(e),r=/\r?\n|\r/g;let s=r.exec(t),i=0;const l=[];for(;s;)l.push(KS(t.slice(i,s.index),i>0,!0),s[0]),i=s.index+s[0].length,s=r.exec(t);return l.push(KS(t.slice(i),i>0,!1)),l.join("")}function KS(e,t,r){let s=0,i=e.length;if(t){let l=e.codePointAt(s);for(;l===VS||l===GS;)s++,l=e.codePointAt(s)}if(r){let l=e.codePointAt(i-1);for(;l===VS||l===GS;)i--,l=e.codePointAt(i-1)}return i>s?e.slice(s,i):""}function pz(e,t){const r={type:"text",value:mz(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function fz(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const gz={blockquote:$H,break:VH,code:GH,delete:KH,emphasis:YH,footnoteReference:XH,heading:QH,html:JH,imageReference:ZH,image:ez,inlineCode:tz,linkReference:nz,link:rz,listItem:sz,list:az,paragraph:oz,root:lz,strong:cz,table:uz,tableCell:hz,tableRow:dz,text:pz,thematicBreak:fz,toml:Wd,yaml:Wd,definition:Wd,footnoteDefinition:Wd};function Wd(){}const n0=-1,Cm=0,Kc=1,$h=2,Hv=3,zv=4,qv=5,$v=6,r0=7,s0=8,YS=typeof self=="object"?self:globalThis,bz=(e,t)=>{const r=(i,l)=>(e.set(l,i),i),s=i=>{if(e.has(i))return e.get(i);const[l,c]=t[i];switch(l){case Cm:case n0:return r(c,i);case Kc:{const d=r([],i);for(const m of c)d.push(s(m));return d}case $h:{const d=r({},i);for(const[m,f]of c)d[s(m)]=s(f);return d}case Hv:return r(new Date(c),i);case zv:{const{source:d,flags:m}=c;return r(new RegExp(d,m),i)}case qv:{const d=r(new Map,i);for(const[m,f]of c)d.set(s(m),s(f));return d}case $v:{const d=r(new Set,i);for(const m of c)d.add(s(m));return d}case r0:{const{name:d,message:m}=c;return r(new YS[d](m),i)}case s0:return r(BigInt(c),i);case"BigInt":return r(Object(BigInt(c)),i);case"ArrayBuffer":return r(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:d}=new Uint8Array(c);return r(new DataView(d),c)}}return r(new YS[l](c),i)};return s},XS=e=>bz(new Map,e)(0),bl="",{toString:vz}={},{keys:wz}=Object,Sc=e=>{const t=typeof e;if(t!=="object"||!e)return[Cm,t];const r=vz.call(e).slice(8,-1);switch(r){case"Array":return[Kc,bl];case"Object":return[$h,bl];case"Date":return[Hv,bl];case"RegExp":return[zv,bl];case"Map":return[qv,bl];case"Set":return[$v,bl];case"DataView":return[Kc,r]}return r.includes("Array")?[Kc,r]:r.includes("Error")?[r0,r]:[$h,r]},Ud=([e,t])=>e===Cm&&(t==="function"||t==="symbol"),yz=(e,t,r,s)=>{const i=(c,d)=>{const m=s.push(c)-1;return r.set(d,m),m},l=c=>{if(r.has(c))return r.get(c);let[d,m]=Sc(c);switch(d){case Cm:{let v=c;switch(m){case"bigint":d=s0,v=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);v=null;break;case"undefined":return i([n0],c)}return i([d,v],c)}case Kc:{if(m){let w=c;return m==="DataView"?w=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(w=new Uint8Array(c)),i([m,[...w]],c)}const v=[],g=i([d,v],c);for(const w of c)v.push(l(w));return g}case $h:{if(m)switch(m){case"BigInt":return i([m,c.toString()],c);case"Boolean":case"Number":case"String":return i([m,c.valueOf()],c)}if(t&&"toJSON"in c)return l(c.toJSON());const v=[],g=i([d,v],c);for(const w of wz(c))(e||!Ud(Sc(c[w])))&&v.push([l(w),l(c[w])]);return g}case Hv:return i([d,c.toISOString()],c);case zv:{const{source:v,flags:g}=c;return i([d,{source:v,flags:g}],c)}case qv:{const v=[],g=i([d,v],c);for(const[w,k]of c)(e||!(Ud(Sc(w))||Ud(Sc(k))))&&v.push([l(w),l(k)]);return g}case $v:{const v=[],g=i([d,v],c);for(const w of c)(e||!Ud(Sc(w)))&&v.push(l(w));return g}}const{message:f}=c;return i([d,{name:m,message:f}],c)};return l},QS=(e,{json:t,lossy:r}={})=>{const s=[];return yz(!(t||r),!!t,new Map,s)(e),s},Vh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?XS(QS(e,t)):structuredClone(e):(e,t)=>XS(QS(e,t));function kz(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function xz(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Sz(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||kz,s=e.options.footnoteBackLabel||xz,i=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const v=e.all(f),g=String(f.identifier).toUpperCase(),w=Bl(g.toLowerCase());let k=0;const y=[],C=e.footnoteCounts.get(g);for(;C!==void 0&&++k<=C;){y.length>0&&y.push({type:"text",value:" "});let N=typeof r=="string"?r:r(m,k);typeof N=="string"&&(N={type:"text",value:N}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+w+(k>1?"-"+k:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(m,k),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const T=v[v.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const N=T.children[T.children.length-1];N&&N.type==="text"?N.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...y)}else v.push(...y);const j={type:"element",tagName:"li",properties:{id:t+"fn-"+w},children:e.wrap(v,!0)};e.patch(f,j),d.push(j)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Vh(c),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
77
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
|
|
78
|
+
`}]}}const jm=(function(e){if(e==null)return Nz;if(typeof e=="function")return Tm(e);if(typeof e=="object")return Array.isArray(e)?Cz(e):jz(e);if(typeof e=="string")return Tz(e);throw new Error("Expected function, string, or object as test")});function Cz(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=jm(e[r]);return Tm(s);function s(...i){let l=-1;for(;++l<t.length;)if(t[l].apply(this,i))return!0;return!1}}function jz(e){const t=e;return Tm(r);function r(s){const i=s;let l;for(l in e)if(i[l]!==t[l])return!1;return!0}}function Tz(e){return Tm(t);function t(r){return r&&r.type===e}}function Tm(e){return t;function t(r,s,i){return!!(Pz(r)&&e.call(this,r,typeof s=="number"?s:void 0,i||void 0))}}function Nz(){return!0}function Pz(e){return e!==null&&typeof e=="object"&&"type"in e}const i0=[],Dz=!0,cb=!1,Rz="skip";function a0(e,t,r,s){let i;typeof t=="function"&&typeof r!="function"?(s=r,r=t):i=t;const l=jm(i),c=s?-1:1;d(e,void 0,[])();function d(m,f,v){const g=m&&typeof m=="object"?m:{};if(typeof g.type=="string"){const k=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(w,"name",{value:"node ("+(m.type+(k?"<"+k+">":""))+")"})}return w;function w(){let k=i0,y,C,T;if((!t||l(m,f,v[v.length-1]||void 0))&&(k=Mz(r(m,v)),k[0]===cb))return k;if("children"in m&&m.children){const j=m;if(j.children&&k[0]!==Rz)for(C=(s?j.children.length:-1)+c,T=v.concat(j);C>-1&&C<j.children.length;){const N=j.children[C];if(y=d(N,C,T)(),y[0]===cb)return y;C=typeof y[1]=="number"?y[1]:C+c}}return k}}}function Mz(e){return Array.isArray(e)?e:typeof e=="number"?[Dz,e]:e==null?i0:[e]}function Vv(e,t,r,s){let i,l,c;typeof t=="function"&&typeof r!="function"?(l=void 0,c=t,i=r):(l=t,c=r,i=s),a0(e,l,d,i);function d(m,f){const v=f[f.length-1],g=v?v.children.indexOf(m):void 0;return c(m,g,v)}}const ub={}.hasOwnProperty,Az={};function Iz(e,t){const r=t||Az,s=new Map,i=new Map,l=new Map,c={...gz,...r.handlers},d={all:f,applyData:Lz,definitionById:s,footnoteById:i,footnoteCounts:l,footnoteOrder:[],handlers:c,one:m,options:r,patch:Ez,wrap:_z};return Vv(e,function(v){if(v.type==="definition"||v.type==="footnoteDefinition"){const g=v.type==="definition"?s:i,w=String(v.identifier).toUpperCase();g.has(w)||g.set(w,v)}}),d;function m(v,g){const w=v.type,k=d.handlers[w];if(ub.call(d.handlers,w)&&k)return k(d,v,g);if(d.options.passThrough&&d.options.passThrough.includes(w)){if("children"in v){const{children:C,...T}=v,j=Vh(T);return j.children=d.all(v),j}return Vh(v)}return(d.options.unknownHandler||Fz)(d,v,g)}function f(v){const g=[];if("children"in v){const w=v.children;let k=-1;for(;++k<w.length;){const y=d.one(w[k],v);if(y){if(k&&w[k-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=JS(y.value)),!Array.isArray(y)&&y.type==="element")){const C=y.children[0];C&&C.type==="text"&&(C.value=JS(C.value))}Array.isArray(y)?g.push(...y):g.push(y)}}}return g}}function Ez(e,t){e.position&&(t.position=xW(e))}function Lz(e,t){let r=t;if(e&&e.data){const s=e.data.hName,i=e.data.hChildren,l=e.data.hProperties;if(typeof s=="string")if(r.type==="element")r.tagName=s;else{const c="children"in r?r.children:[r];r={type:"element",tagName:s,properties:{},children:c}}r.type==="element"&&l&&Object.assign(r.properties,Vh(l)),"children"in r&&r.children&&i!==null&&i!==void 0&&(r.children=i)}return r}function Fz(e,t){const r=t.data||{},s="value"in t&&!(ub.call(r,"hProperties")||ub.call(r,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function _z(e,t){const r=[];let s=-1;for(t&&r.push({type:"text",value:`
|
|
79
|
+
`});++s<e.length;)s&&r.push({type:"text",value:`
|
|
80
|
+
`}),r.push(e[s]);return t&&e.length>0&&r.push({type:"text",value:`
|
|
81
|
+
`}),r}function JS(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function ZS(e,t){const r=Iz(e,t),s=r.one(e,void 0),i=Sz(r),l=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return i&&l.children.push({type:"text",value:`
|
|
82
|
+
`},i),l}function Oz(e,t){return e&&"run"in e?async function(r,s){const i=ZS(r,{file:s,...t});await e.run(i,s)}:function(r,s){return ZS(r,{file:s,...e||t})}}function eC(e){if(e)throw e}var Af,tC;function Bz(){if(tC)return Af;tC=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},l=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var v=e.call(f,"constructor"),g=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!v&&!g)return!1;var w;for(w in f);return typeof w>"u"||e.call(f,w)},c=function(f,v){r&&v.name==="__proto__"?r(f,v.name,{enumerable:!0,configurable:!0,value:v.newValue,writable:!0}):f[v.name]=v.newValue},d=function(f,v){if(v==="__proto__")if(e.call(f,v)){if(s)return s(f,v).value}else return;return f[v]};return Af=function m(){var f,v,g,w,k,y,C=arguments[0],T=1,j=arguments.length,N=!1;for(typeof C=="boolean"&&(N=C,C=arguments[1]||{},T=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});T<j;++T)if(f=arguments[T],f!=null)for(v in f)g=d(C,v),w=d(f,v),C!==w&&(N&&w&&(l(w)||(k=i(w)))?(k?(k=!1,y=g&&i(g)?g:[]):y=g&&l(g)?g:{},c(C,{name:v,newValue:m(N,y,w)})):typeof w<"u"&&c(C,{name:v,newValue:w}));return C},Af}var Wz=Bz();const If=pu(Wz);function db(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Uz(){const e=[],t={run:r,use:s};return t;function r(...i){let l=-1;const c=i.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...i);function d(m,...f){const v=e[++l];let g=-1;if(m){c(m);return}for(;++g<i.length;)(f[g]===null||f[g]===void 0)&&(f[g]=i[g]);i=f,v?Hz(v,d)(...f):c(null,...f)}}function s(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Hz(e,t){let r;return s;function s(...c){const d=e.length>c.length;let m;d&&c.push(i);try{m=e.apply(this,c)}catch(f){const v=f;if(d&&r)throw v;return i(v)}d||(m&&m.then&&typeof m.then=="function"?m.then(l,i):m instanceof Error?i(m):l(m))}function i(c,...d){r||(r=!0,t(c,...d))}function l(c){i(null,c)}}const Oi={basename:zz,dirname:qz,extname:$z,join:Vz,sep:"/"};function zz(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ru(e);let r=0,s=-1,i=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(l){r=i+1;break}}else s<0&&(l=!0,s=i+1);return s<0?"":e.slice(r,s)}if(t===e)return"";let c=-1,d=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(l){r=i+1;break}}else c<0&&(l=!0,c=i+1),d>-1&&(e.codePointAt(i)===t.codePointAt(d--)?d<0&&(s=i):(d=-1,s=c));return r===s?s=c:s<0&&(s=e.length),e.slice(r,s)}function qz(e){if(Ru(e),e.length===0)return".";let t=-1,r=e.length,s;for(;--r;)if(e.codePointAt(r)===47){if(s){t=r;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function $z(e){Ru(e);let t=e.length,r=-1,s=0,i=-1,l=0,c;for(;t--;){const d=e.codePointAt(t);if(d===47){if(c){s=t+1;break}continue}r<0&&(c=!0,r=t+1),d===46?i<0?i=t:l!==1&&(l=1):i>-1&&(l=-1)}return i<0||r<0||l===0||l===1&&i===r-1&&i===s+1?"":e.slice(i,r)}function Vz(...e){let t=-1,r;for(;++t<e.length;)Ru(e[t]),e[t]&&(r=r===void 0?e[t]:r+"/"+e[t]);return r===void 0?".":Gz(r)}function Gz(e){Ru(e);const t=e.codePointAt(0)===47;let r=Kz(e,!t);return r.length===0&&!t&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function Kz(e,t){let r="",s=0,i=-1,l=0,c=-1,d,m;for(;++c<=e.length;){if(c<e.length)d=e.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(i===c-1||l===1))if(i!==c-1&&l===2){if(r.length<2||s!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(m=r.lastIndexOf("/"),m!==r.length-1){m<0?(r="",s=0):(r=r.slice(0,m),s=r.length-1-r.lastIndexOf("/")),i=c,l=0;continue}}else if(r.length>0){r="",s=0,i=c,l=0;continue}}t&&(r=r.length>0?r+"/..":"..",s=2)}else r.length>0?r+="/"+e.slice(i+1,c):r=e.slice(i+1,c),s=c-i-1;i=c,l=0}else d===46&&l>-1?l++:l=-1}return r}function Ru(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Yz={cwd:Xz};function Xz(){return"/"}function hb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Qz(e){if(typeof e=="string")e=new URL(e);else if(!hb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Jz(e)}function Jz(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let r=-1;for(;++r<t.length;)if(t.codePointAt(r)===37&&t.codePointAt(r+1)===50){const s=t.codePointAt(r+2);if(s===70||s===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Ef=["history","path","basename","stem","extname","dirname"];class o0{constructor(t){let r;t?hb(t)?r={path:t}:typeof t=="string"||Zz(t)?r={value:t}:r=t:r={},this.cwd="cwd"in r?"":Yz.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Ef.length;){const l=Ef[s];l in r&&r[l]!==void 0&&r[l]!==null&&(this[l]=l==="history"?[...r[l]]:r[l])}let i;for(i in r)Ef.includes(i)||(this[i]=r[i])}get basename(){return typeof this.path=="string"?Oi.basename(this.path):void 0}set basename(t){Ff(t,"basename"),Lf(t,"basename"),this.path=Oi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Oi.dirname(this.path):void 0}set dirname(t){nC(this.basename,"dirname"),this.path=Oi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Oi.extname(this.path):void 0}set extname(t){if(Lf(t,"extname"),nC(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Oi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){hb(t)&&(t=Qz(t)),Ff(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Oi.basename(this.path,this.extname):void 0}set stem(t){Ff(t,"stem"),Lf(t,"stem"),this.path=Oi.join(this.dirname||"",t+(this.extname||""))}fail(t,r,s){const i=this.message(t,r,s);throw i.fatal=!0,i}info(t,r,s){const i=this.message(t,r,s);return i.fatal=void 0,i}message(t,r,s){const i=new us(t,r,s);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Lf(e,t){if(e&&e.includes(Oi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Oi.sep+"`")}function Ff(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function nC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Zz(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const e4=(function(e){const s=this.constructor.prototype,i=s[e],l=function(){return i.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),t4={}.hasOwnProperty;class Gv extends e4{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Uz()}copy(){const t=new Gv;let r=-1;for(;++r<this.attachers.length;){const s=this.attachers[r];t.use(...s)}return t.data(If(!0,{},this.namespace)),t}data(t,r){return typeof t=="string"?arguments.length===2?(Bf("data",this.frozen),this.namespace[t]=r,this):t4.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Bf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const i=r.call(t,...s);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const r=Hd(t),s=this.parser||this.Parser;return _f("parse",s),s(String(r),r)}process(t,r){const s=this;return this.freeze(),_f("process",this.parser||this.Parser),Of("process",this.compiler||this.Compiler),r?i(void 0,r):new Promise(i);function i(l,c){const d=Hd(t),m=s.parse(d);s.run(m,d,function(v,g,w){if(v||!g||!w)return f(v);const k=g,y=s.stringify(k,w);s4(y)?w.value=y:w.result=y,f(v,w)});function f(v,g){v||!g?c(v):l?l(g):r(void 0,g)}}}processSync(t){let r=!1,s;return this.freeze(),_f("processSync",this.parser||this.Parser),Of("processSync",this.compiler||this.Compiler),this.process(t,i),sC("processSync","process",r),s;function i(l,c){r=!0,eC(l),s=c}}run(t,r,s){rC(t),this.freeze();const i=this.transformers;return!s&&typeof r=="function"&&(s=r,r=void 0),s?l(void 0,s):new Promise(l);function l(c,d){const m=Hd(r);i.run(t,m,f);function f(v,g,w){const k=g||t;v?d(v):c?c(k):s(void 0,k,w)}}}runSync(t,r){let s=!1,i;return this.run(t,r,l),sC("runSync","run",s),i;function l(c,d){eC(c),i=d,s=!0}}stringify(t,r){this.freeze();const s=Hd(r),i=this.compiler||this.Compiler;return Of("stringify",i),rC(t),i(t,s)}use(t,...r){const s=this.attachers,i=this.namespace;if(Bf("use",this.frozen),t!=null)if(typeof t=="function")m(t,r);else if(typeof t=="object")Array.isArray(t)?d(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[v,...g]=f;m(v,g)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(f.plugins),f.settings&&(i.settings=If(!0,i.settings,f.settings))}function d(f){let v=-1;if(f!=null)if(Array.isArray(f))for(;++v<f.length;){const g=f[v];l(g)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,v){let g=-1,w=-1;for(;++g<s.length;)if(s[g][0]===f){w=g;break}if(w===-1)s.push([f,...v]);else if(v.length>0){let[k,...y]=v;const C=s[w][1];db(C)&&db(k)&&(k=If(!0,C,k)),s[w]=[f,k,...y]}}}}const n4=new Gv().freeze();function _f(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Of(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Bf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function rC(e){if(!db(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function sC(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Hd(e){return r4(e)?e:new o0(e)}function r4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function s4(e){return typeof e=="string"||i4(e)}function i4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const a4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",iC=[],aC={allowDangerousHtml:!0},o4=/^(https?|ircs?|mailto|xmpp)$/i,l4=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function l0(e){const t=c4(e),r=u4(e);return d4(t.runSync(t.parse(r),r),e)}function c4(e){const t=e.rehypePlugins||iC,r=e.remarkPlugins||iC,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...aC}:aC;return n4().use(qH).use(r).use(Oz,s).use(t)}function u4(e){const t=e.children||"",r=new o0;return typeof t=="string"&&(r.value=t),r}function d4(e,t){const r=t.allowedElements,s=t.allowElement,i=t.components,l=t.disallowedElements,c=t.skipHtml,d=t.unwrapDisallowed,m=t.urlTransform||h4;for(const v of l4)Object.hasOwn(t,v.from)&&(""+v.from+(v.to?"use `"+v.to+"` instead":"remove it")+a4+v.id,void 0);return Vv(e,f),NW(e,{Fragment:n.Fragment,components:i,ignoreInvalidStyle:!0,jsx:n.jsx,jsxs:n.jsxs,passKeys:!0,passNode:!0});function f(v,g,w){if(v.type==="raw"&&w&&typeof g=="number")return c?w.children.splice(g,1):w.children[g]={type:"text",value:v.value},g;if(v.type==="element"){let k;for(k in Df)if(Object.hasOwn(Df,k)&&Object.hasOwn(v.properties,k)){const y=v.properties[k],C=Df[k];(C===null||C.includes(v.tagName))&&(v.properties[k]=m(String(y||""),k,v))}}if(v.type==="element"){let k=r?!r.includes(v.tagName):l?l.includes(v.tagName):!1;if(!k&&s&&typeof g=="number"&&(k=!s(v,g,w)),k&&w&&typeof g=="number")return d&&v.children?w.children.splice(g,1,...v.children):w.children.splice(g,1),g}}}function h4(e){const t=e.indexOf(":"),r=e.indexOf("?"),s=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||r!==-1&&t>r||s!==-1&&t>s||o4.test(e.slice(0,t))?e:""}function oC(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,i=r.indexOf(t);for(;i!==-1;)s++,i=r.indexOf(t,i+t.length);return s}function m4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function p4(e,t,r){const i=jm((r||{}).ignore||[]),l=f4(t);let c=-1;for(;++c<l.length;)a0(e,"text",d);function d(f,v){let g=-1,w;for(;++g<v.length;){const k=v[g],y=w?w.children:void 0;if(i(k,y?y.indexOf(k):void 0,w))return;w=k}if(w)return m(f,v)}function m(f,v){const g=v[v.length-1],w=l[c][0],k=l[c][1];let y=0;const T=g.children.indexOf(f);let j=!1,N=[];w.lastIndex=0;let D=w.exec(f.value);for(;D;){const F=D.index,W={index:D.index,input:D.input,stack:[...v,f]};let E=k(...D,W);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?w.lastIndex=F+1:(y!==F&&N.push({type:"text",value:f.value.slice(y,F)}),Array.isArray(E)?N.push(...E):E&&N.push(E),y=F+D[0].length,j=!0),!w.global)break;D=w.exec(f.value)}return j?(y<f.value.length&&N.push({type:"text",value:f.value.slice(y)}),g.children.splice(T,1,...N)):N=[f],T+N.length}}function f4(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s<r.length;){const i=r[s];t.push([g4(i[0]),b4(i[1])])}return t}function g4(e){return typeof e=="string"?new RegExp(m4(e),"g"):e}function b4(e){return typeof e=="function"?e:function(){return e}}const Wf="phrasing",Uf=["autolink","link","image","label"];function v4(){return{transforms:[j4],enter:{literalAutolink:y4,literalAutolinkEmail:Hf,literalAutolinkHttp:Hf,literalAutolinkWww:Hf},exit:{literalAutolink:C4,literalAutolinkEmail:S4,literalAutolinkHttp:k4,literalAutolinkWww:x4}}}function w4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Wf,notInConstruct:Uf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Wf,notInConstruct:Uf},{character:":",before:"[ps]",after:"\\/",inConstruct:Wf,notInConstruct:Uf}]}}function y4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Hf(e){this.config.enter.autolinkProtocol.call(this,e)}function k4(e){this.config.exit.autolinkProtocol.call(this,e)}function x4(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function S4(e){this.config.exit.autolinkEmail.call(this,e)}function C4(e){this.exit(e)}function j4(e){p4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,T4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),N4]],{ignore:["link","linkReference"]})}function T4(e,t,r,s,i){let l="";if(!c0(i)||(/^w/i.test(t)&&(r=t+r,t="",l="http://"),!P4(r)))return!1;const c=D4(r+s);if(!c[0])return!1;const d={type:"link",title:null,url:l+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[d,{type:"text",value:c[1]}]:d}function N4(e,t,r,s){return!c0(s,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}function P4(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function D4(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],s=r.indexOf(")");const i=oC(e,"(");let l=oC(e,")");for(;s!==-1&&i>l;)e+=r.slice(0,s+1),r=r.slice(s+1),s=r.indexOf(")"),l++;return[e,r]}function c0(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||Do(r)||xm(r))&&(!t||r!==47)}u0.peek=O4;function R4(){this.buffer()}function M4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function A4(){this.buffer()}function I4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function E4(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=ki(this.sliceSerialize(e)).toLowerCase(),r.label=t}function L4(e){this.exit(e)}function F4(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=ki(this.sliceSerialize(e)).toLowerCase(),r.label=t}function _4(e){this.exit(e)}function O4(){return"["}function u0(e,t,r,s){const i=r.createTracker(s);let l=i.move("[^");const c=r.enter("footnoteReference"),d=r.enter("reference");return l+=i.move(r.safe(r.associationId(e),{after:"]",before:l})),d(),c(),l+=i.move("]"),l}function B4(){return{enter:{gfmFootnoteCallString:R4,gfmFootnoteCall:M4,gfmFootnoteDefinitionLabelString:A4,gfmFootnoteDefinition:I4},exit:{gfmFootnoteCallString:E4,gfmFootnoteCall:L4,gfmFootnoteDefinitionLabelString:F4,gfmFootnoteDefinition:_4}}}function W4(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:u0},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(s,i,l,c){const d=l.createTracker(c);let m=d.move("[^");const f=l.enter("footnoteDefinition"),v=l.enter("label");return m+=d.move(l.safe(l.associationId(s),{before:m,after:"]"})),v(),m+=d.move("]:"),s.children&&s.children.length>0&&(d.shift(4),m+=d.move((t?`
|
|
83
|
+
`:" ")+l.indentLines(l.containerFlow(s,d.current()),t?d0:U4))),f(),m}}function U4(e,t,r){return t===0?e:d0(e,t,r)}function d0(e,t,r){return(r?"":" ")+e}const H4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];h0.peek=G4;function z4(){return{canContainEols:["delete"],enter:{strikethrough:$4},exit:{strikethrough:V4}}}function q4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:H4}],handlers:{delete:h0}}}function $4(e){this.enter({type:"delete",children:[]},e)}function V4(e){this.exit(e)}function h0(e,t,r,s){const i=r.createTracker(s),l=r.enter("strikethrough");let c=i.move("~~");return c+=r.containerPhrasing(e,{...i.current(),before:c,after:"~"}),c+=i.move("~~"),l(),c}function G4(){return"~"}function K4(e){return e.length}function Y4(e,t){const r=t||{},s=(r.align||[]).concat(),i=r.stringLength||K4,l=[],c=[],d=[],m=[];let f=0,v=-1;for(;++v<e.length;){const C=[],T=[];let j=-1;for(e[v].length>f&&(f=e[v].length);++j<e[v].length;){const N=X4(e[v][j]);if(r.alignDelimiters!==!1){const D=i(N);T[j]=D,(m[j]===void 0||D>m[j])&&(m[j]=D)}C.push(N)}c[v]=C,d[v]=T}let g=-1;if(typeof s=="object"&&"length"in s)for(;++g<f;)l[g]=lC(s[g]);else{const C=lC(s);for(;++g<f;)l[g]=C}g=-1;const w=[],k=[];for(;++g<f;){const C=l[g];let T="",j="";C===99?(T=":",j=":"):C===108?T=":":C===114&&(j=":");let N=r.alignDelimiters===!1?1:Math.max(1,m[g]-T.length-j.length);const D=T+"-".repeat(N)+j;r.alignDelimiters!==!1&&(N=T.length+N+j.length,N>m[g]&&(m[g]=N),k[g]=N),w[g]=D}c.splice(1,0,w),d.splice(1,0,k),v=-1;const y=[];for(;++v<c.length;){const C=c[v],T=d[v];g=-1;const j=[];for(;++g<f;){const N=C[g]||"";let D="",F="";if(r.alignDelimiters!==!1){const W=m[g]-(T[g]||0),E=l[g];E===114?D=" ".repeat(W):E===99?W%2?(D=" ".repeat(W/2+.5),F=" ".repeat(W/2-.5)):(D=" ".repeat(W/2),F=D):F=" ".repeat(W)}r.delimiterStart!==!1&&!g&&j.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&N==="")&&(r.delimiterStart!==!1||g)&&j.push(" "),r.alignDelimiters!==!1&&j.push(D),j.push(N),r.alignDelimiters!==!1&&j.push(F),r.padding!==!1&&j.push(" "),(r.delimiterEnd!==!1||g!==f-1)&&j.push("|")}y.push(r.delimiterEnd===!1?j.join("").replace(/ +$/,""):j.join(""))}return y.join(`
|
|
84
|
+
`)}function X4(e){return e==null?"":String(e)}function lC(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Q4(e,t,r,s){const i=r.enter("blockquote"),l=r.createTracker(s);l.move("> "),l.shift(2);const c=r.indentLines(r.containerFlow(e,l.current()),J4);return i(),c}function J4(e,t,r){return">"+(r?"":" ")+e}function Z4(e,t){return cC(e,t.inConstruct,!0)&&!cC(e,t.notInConstruct,!1)}function cC(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function uC(e,t,r,s){let i=-1;for(;++i<r.unsafe.length;)if(r.unsafe[i].character===`
|
|
85
|
+
`&&Z4(r.stack,r.unsafe[i]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
86
|
+
`}function e5(e,t){const r=String(e);let s=r.indexOf(t),i=s,l=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===i?++l>c&&(c=l):l=1,i=s+t.length,s=r.indexOf(t,i);return c}function t5(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function n5(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function r5(e,t,r,s){const i=n5(r),l=e.value||"",c=i==="`"?"GraveAccent":"Tilde";if(t5(e,r)){const g=r.enter("codeIndented"),w=r.indentLines(l,s5);return g(),w}const d=r.createTracker(s),m=i.repeat(Math.max(e5(l,i)+1,3)),f=r.enter("codeFenced");let v=d.move(m);if(e.lang){const g=r.enter(`codeFencedLang${c}`);v+=d.move(r.safe(e.lang,{before:v,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=r.enter(`codeFencedMeta${c}`);v+=d.move(" "),v+=d.move(r.safe(e.meta,{before:v,after:`
|
|
87
|
+
`,encode:["`"],...d.current()})),g()}return v+=d.move(`
|
|
88
|
+
`),l&&(v+=d.move(l+`
|
|
89
|
+
`)),v+=d.move(m),f(),v}function s5(e,t,r){return(r?"":" ")+e}function Kv(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function i5(e,t,r,s){const i=Kv(r),l=i==='"'?"Quote":"Apostrophe",c=r.enter("definition");let d=r.enter("label");const m=r.createTracker(s);let f=m.move("[");return f+=m.move(r.safe(r.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(r.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=r.enter("destinationRaw"),f+=m.move(r.safe(e.url,{before:f,after:e.title?" ":`
|
|
90
|
+
`,...m.current()}))),d(),e.title&&(d=r.enter(`title${l}`),f+=m.move(" "+i),f+=m.move(r.safe(e.title,{before:f,after:i,...m.current()})),f+=m.move(i),d()),c(),f}function a5(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function ru(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Gh(e,t,r){const s=Il(e),i=Il(t);return s===void 0?i===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}m0.peek=o5;function m0(e,t,r,s){const i=a5(r),l=r.enter("emphasis"),c=r.createTracker(s),d=c.move(i);let m=c.move(r.containerPhrasing(e,{after:i,before:d,...c.current()}));const f=m.charCodeAt(0),v=Gh(s.before.charCodeAt(s.before.length-1),f,i);v.inside&&(m=ru(f)+m.slice(1));const g=m.charCodeAt(m.length-1),w=Gh(s.after.charCodeAt(0),g,i);w.inside&&(m=m.slice(0,-1)+ru(g));const k=c.move(i);return l(),r.attentionEncodeSurroundingInfo={after:w.outside,before:v.outside},d+m+k}function o5(e,t,r){return r.options.emphasis||"*"}function l5(e,t){let r=!1;return Vv(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return r=!0,cb}),!!((!e.depth||e.depth<3)&&Bv(e)&&(t.options.setext||r))}function c5(e,t,r,s){const i=Math.max(Math.min(6,e.depth||1),1),l=r.createTracker(s);if(l5(e,r)){const v=r.enter("headingSetext"),g=r.enter("phrasing"),w=r.containerPhrasing(e,{...l.current(),before:`
|
|
91
|
+
`,after:`
|
|
92
|
+
`});return g(),v(),w+`
|
|
93
|
+
`+(i===1?"=":"-").repeat(w.length-(Math.max(w.lastIndexOf("\r"),w.lastIndexOf(`
|
|
94
|
+
`))+1))}const c="#".repeat(i),d=r.enter("headingAtx"),m=r.enter("phrasing");l.move(c+" ");let f=r.containerPhrasing(e,{before:"# ",after:`
|
|
95
|
+
`,...l.current()});return/^[\t ]/.test(f)&&(f=ru(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,r.options.closeAtx&&(f+=" "+c),m(),d(),f}p0.peek=u5;function p0(e){return e.value||""}function u5(){return"<"}f0.peek=d5;function f0(e,t,r,s){const i=Kv(r),l=i==='"'?"Quote":"Apostrophe",c=r.enter("image");let d=r.enter("label");const m=r.createTracker(s);let f=m.move("![");return f+=m.move(r.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(r.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=r.enter("destinationRaw"),f+=m.move(r.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),d(),e.title&&(d=r.enter(`title${l}`),f+=m.move(" "+i),f+=m.move(r.safe(e.title,{before:f,after:i,...m.current()})),f+=m.move(i),d()),f+=m.move(")"),c(),f}function d5(){return"!"}g0.peek=h5;function g0(e,t,r,s){const i=e.referenceType,l=r.enter("imageReference");let c=r.enter("label");const d=r.createTracker(s);let m=d.move("![");const f=r.safe(e.alt,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const v=r.stack;r.stack=[],c=r.enter("reference");const g=r.safe(r.associationId(e),{before:m,after:"]",...d.current()});return c(),r.stack=v,l(),i==="full"||!f||f!==g?m+=d.move(g+"]"):i==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function h5(){return"!"}b0.peek=m5;function b0(e,t,r){let s=e.value||"",i="`",l=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(s);)i+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++l<r.unsafe.length;){const c=r.unsafe[l],d=r.compilePattern(c);let m;if(c.atBreak)for(;m=d.exec(s);){let f=m.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(m.index+1)}}return i+s+i}function m5(){return"`"}function v0(e,t){const r=Bv(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}w0.peek=p5;function w0(e,t,r,s){const i=Kv(r),l=i==='"'?"Quote":"Apostrophe",c=r.createTracker(s);let d,m;if(v0(e,r)){const v=r.stack;r.stack=[],d=r.enter("autolink");let g=c.move("<");return g+=c.move(r.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),d(),r.stack=v,g}d=r.enter("link"),m=r.enter("label");let f=c.move("[");return f+=c.move(r.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=r.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(r.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(m=r.enter("destinationRaw"),f+=c.move(r.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=r.enter(`title${l}`),f+=c.move(" "+i),f+=c.move(r.safe(e.title,{before:f,after:i,...c.current()})),f+=c.move(i),m()),f+=c.move(")"),d(),f}function p5(e,t,r){return v0(e,r)?"<":"["}y0.peek=f5;function y0(e,t,r,s){const i=e.referenceType,l=r.enter("linkReference");let c=r.enter("label");const d=r.createTracker(s);let m=d.move("[");const f=r.containerPhrasing(e,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const v=r.stack;r.stack=[],c=r.enter("reference");const g=r.safe(r.associationId(e),{before:m,after:"]",...d.current()});return c(),r.stack=v,l(),i==="full"||!f||f!==g?m+=d.move(g+"]"):i==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function f5(){return"["}function Yv(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function g5(e){const t=Yv(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function b5(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function k0(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function v5(e,t,r,s){const i=r.enter("list"),l=r.bulletCurrent;let c=e.ordered?b5(r):Yv(r);const d=e.ordered?c==="."?")":".":g5(r);let m=t&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!e.ordered){const v=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&v&&(!v.children||!v.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(m=!0),k0(r)===c&&v){let g=-1;for(;++g<e.children.length;){const w=e.children[g];if(w&&w.type==="listItem"&&w.children&&w.children[0]&&w.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=d),r.bulletCurrent=c;const f=r.containerFlow(e,s);return r.bulletLastUsed=c,r.bulletCurrent=l,i(),f}function w5(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function y5(e,t,r,s){const i=w5(r);let l=r.bulletCurrent||Yv(r);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let c=l.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const d=r.createTracker(s);d.move(l+" ".repeat(c-l.length)),d.shift(c);const m=r.enter("listItem"),f=r.indentLines(r.containerFlow(e,d.current()),v);return m(),f;function v(g,w,k){return w?(k?"":" ".repeat(c))+g:(k?l:l+" ".repeat(c-l.length))+g}}function k5(e,t,r,s){const i=r.enter("paragraph"),l=r.enter("phrasing"),c=r.containerPhrasing(e,s);return l(),i(),c}const x5=jm(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function S5(e,t,r,s){return(e.children.some(function(c){return x5(c)})?r.containerPhrasing:r.containerFlow).call(r,e,s)}function C5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}x0.peek=j5;function x0(e,t,r,s){const i=C5(r),l=r.enter("strong"),c=r.createTracker(s),d=c.move(i+i);let m=c.move(r.containerPhrasing(e,{after:i,before:d,...c.current()}));const f=m.charCodeAt(0),v=Gh(s.before.charCodeAt(s.before.length-1),f,i);v.inside&&(m=ru(f)+m.slice(1));const g=m.charCodeAt(m.length-1),w=Gh(s.after.charCodeAt(0),g,i);w.inside&&(m=m.slice(0,-1)+ru(g));const k=c.move(i+i);return l(),r.attentionEncodeSurroundingInfo={after:w.outside,before:v.outside},d+m+k}function j5(e,t,r){return r.options.strong||"*"}function T5(e,t,r,s){return r.safe(e.value,s)}function N5(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function P5(e,t,r){const s=(k0(r)+(r.options.ruleSpaces?" ":"")).repeat(N5(r));return r.options.ruleSpaces?s.slice(0,-1):s}const S0={blockquote:Q4,break:uC,code:r5,definition:i5,emphasis:m0,hardBreak:uC,heading:c5,html:p0,image:f0,imageReference:g0,inlineCode:b0,link:w0,linkReference:y0,list:v5,listItem:y5,paragraph:k5,root:S5,strong:x0,text:T5,thematicBreak:P5};function D5(){return{enter:{table:R5,tableData:dC,tableHeader:dC,tableRow:A5},exit:{codeText:I5,table:M5,tableData:zf,tableHeader:zf,tableRow:zf}}}function R5(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function M5(e){this.exit(e),this.data.inTable=void 0}function A5(e){this.enter({type:"tableRow",children:[]},e)}function zf(e){this.exit(e)}function dC(e){this.enter({type:"tableCell",children:[]},e)}function I5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,E5));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function E5(e,t){return t==="|"?t:e}function L5(e){const t=e||{},r=t.tableCellPadding,s=t.tablePipeAlign,i=t.stringLength,l=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
96
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:w,table:c,tableCell:m,tableRow:d}};function c(k,y,C,T){return f(v(k,C,T),k.align)}function d(k,y,C,T){const j=g(k,C,T),N=f([j]);return N.slice(0,N.indexOf(`
|
|
97
|
+
`))}function m(k,y,C,T){const j=C.enter("tableCell"),N=C.enter("phrasing"),D=C.containerPhrasing(k,{...T,before:l,after:l});return N(),j(),D}function f(k,y){return Y4(k,{align:y,alignDelimiters:s,padding:r,stringLength:i})}function v(k,y,C){const T=k.children;let j=-1;const N=[],D=y.enter("table");for(;++j<T.length;)N[j]=g(T[j],y,C);return D(),N}function g(k,y,C){const T=k.children;let j=-1;const N=[],D=y.enter("tableRow");for(;++j<T.length;)N[j]=m(T[j],k,y,C);return D(),N}function w(k,y,C){let T=S0.inlineCode(k,y,C);return C.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function F5(){return{exit:{taskListCheckValueChecked:hC,taskListCheckValueUnchecked:hC,paragraph:O5}}}function _5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:B5}}}function hC(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function O5(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const s=r.children[0];if(s&&s.type==="text"){const i=t.children;let l=-1,c;for(;++l<i.length;){const d=i[l];if(d.type==="paragraph"){c=d;break}}c===r&&(s.value=s.value.slice(1),s.value.length===0?r.children.shift():r.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,r.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function B5(e,t,r,s){const i=e.children[0],l=typeof e.checked=="boolean"&&i&&i.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",d=r.createTracker(s);l&&d.move(c);let m=S0.listItem(e,t,r,{...s,...d.current()});return l&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(v){return v+c}}function W5(){return[v4(),B4(),z4(),D5(),F5()]}function U5(e){return{extensions:[w4(),W4(e),q4(),L5(e),_5()]}}const H5={tokenize:K5,partial:!0},C0={tokenize:Y5,partial:!0},j0={tokenize:X5,partial:!0},T0={tokenize:Q5,partial:!0},z5={tokenize:J5,partial:!0},N0={name:"wwwAutolink",tokenize:V5,previous:D0},P0={name:"protocolAutolink",tokenize:G5,previous:R0},ma={name:"emailAutolink",tokenize:$5,previous:M0},Vi={};function q5(){return{text:Vi}}let po=48;for(;po<123;)Vi[po]=ma,po++,po===58?po=65:po===91&&(po=97);Vi[43]=ma;Vi[45]=ma;Vi[46]=ma;Vi[95]=ma;Vi[72]=[ma,P0];Vi[104]=[ma,P0];Vi[87]=[ma,N0];Vi[119]=[ma,N0];function $5(e,t,r){const s=this;let i,l;return c;function c(g){return!mb(g)||!M0.call(s,s.previous)||Xv(s.events)?r(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(g))}function d(g){return mb(g)?(e.consume(g),d):g===64?(e.consume(g),m):r(g)}function m(g){return g===46?e.check(z5,v,f)(g):g===45||g===95||cs(g)?(l=!0,e.consume(g),m):v(g)}function f(g){return e.consume(g),i=!0,m}function v(g){return l&&i&&fs(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):r(g)}}function V5(e,t,r){const s=this;return i;function i(c){return c!==87&&c!==119||!D0.call(s,s.previous)||Xv(s.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(H5,e.attempt(C0,e.attempt(j0,l),r),r)(c))}function l(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function G5(e,t,r){const s=this;let i="",l=!1;return c;function c(g){return(g===72||g===104)&&R0.call(s,s.previous)&&!Xv(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(g),e.consume(g),d):r(g)}function d(g){if(fs(g)&&i.length<5)return i+=String.fromCodePoint(g),e.consume(g),d;if(g===58){const w=i.toLowerCase();if(w==="http"||w==="https")return e.consume(g),m}return r(g)}function m(g){return g===47?(e.consume(g),l?f:(l=!0,m)):r(g)}function f(g){return g===null||qh(g)||Xn(g)||Do(g)||xm(g)?r(g):e.attempt(C0,e.attempt(j0,v),r)(g)}function v(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function K5(e,t,r){let s=0;return i;function i(c){return(c===87||c===119)&&s<3?(s++,e.consume(c),i):c===46&&s===3?(e.consume(c),l):r(c)}function l(c){return c===null?r(c):t(c)}}function Y5(e,t,r){let s,i,l;return c;function c(f){return f===46||f===95?e.check(T0,m,d)(f):f===null||Xn(f)||Do(f)||f!==45&&xm(f)?m(f):(l=!0,e.consume(f),c)}function d(f){return f===95?s=!0:(i=s,s=void 0),e.consume(f),c}function m(f){return i||s||!l?r(f):t(f)}}function X5(e,t){let r=0,s=0;return i;function i(c){return c===40?(r++,e.consume(c),i):c===41&&s<r?l(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(T0,t,l)(c):c===null||Xn(c)||Do(c)?t(c):(e.consume(c),i)}function l(c){return c===41&&s++,e.consume(c),i}}function Q5(e,t,r){return s;function s(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),s):d===38?(e.consume(d),l):d===93?(e.consume(d),i):d===60||d===null||Xn(d)||Do(d)?t(d):r(d)}function i(d){return d===null||d===40||d===91||Xn(d)||Do(d)?t(d):s(d)}function l(d){return fs(d)?c(d):r(d)}function c(d){return d===59?(e.consume(d),s):fs(d)?(e.consume(d),c):r(d)}}function J5(e,t,r){return s;function s(l){return e.consume(l),i}function i(l){return cs(l)?r(l):t(l)}}function D0(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Xn(e)}function R0(e){return!fs(e)}function M0(e){return!(e===47||mb(e))}function mb(e){return e===43||e===45||e===46||e===95||cs(e)}function Xv(e){let t=e.length,r=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){r=!0;break}if(s._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const Z5={tokenize:o6,partial:!0};function e6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:s6,continuation:{tokenize:i6},exit:a6}},text:{91:{name:"gfmFootnoteCall",tokenize:r6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:t6,resolveTo:n6}}}}function t6(e,t,r){const s=this;let i=s.events.length;const l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;i--;){const m=s.events[i][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return d;function d(m){if(!c||!c._balanced)return r(m);const f=ki(s.sliceSerialize({start:c.end,end:s.now()}));return f.codePointAt(0)!==94||!l.includes(f.slice(1))?r(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),t(m))}}function n6(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},d=[e[r+1],e[r+2],["enter",s,t],e[r+3],e[r+4],["enter",i,t],["exit",i,t],["enter",l,t],["enter",c,t],["exit",c,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(r,e.length-r+1,...d),e}function r6(e,t,r){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l=0,c;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?r(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(g){if(l>999||g===93&&!c||g===null||g===91||Xn(g))return r(g);if(g===93){e.exit("chunkString");const w=e.exit("gfmFootnoteCallString");return i.includes(ki(s.sliceSerialize(w)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(g)}return Xn(g)||(c=!0),l++,e.consume(g),g===92?v:f}function v(g){return g===91||g===92||g===93?(e.consume(g),l++,f):f(g)}}function s6(e,t,r){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l,c=0,d;return m;function m(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",v):r(y)}function v(y){if(c>999||y===93&&!d||y===null||y===91||Xn(y))return r(y);if(y===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=ki(s.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),w}return Xn(y)||(d=!0),c++,e.consume(y),y===92?g:v}function g(y){return y===91||y===92||y===93?(e.consume(y),c++,v):v(y)}function w(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),i.includes(l)||i.push(l),Fn(e,k,"gfmFootnoteDefinitionWhitespace")):r(y)}function k(y){return t(y)}}function i6(e,t,r){return e.check(Du,t,e.attempt(Z5,t,r))}function a6(e){e.exit("gfmFootnoteDefinition")}function o6(e,t,r){const s=this;return Fn(e,i,"gfmFootnoteDefinitionIndent",5);function i(l){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(l):r(l)}}function l6(e){let r=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:l,resolveAll:i};return r==null&&(r=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function i(c,d){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let f=m;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[m][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const v={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[m][1].start)},w=[["enter",v,d],["enter",c[f][1],d],["exit",c[f][1],d],["enter",g,d]],k=d.parser.constructs.insideSpan.null;k&&zs(w,w.length,0,Sm(k,c.slice(f+1,m),d)),zs(w,w.length,0,[["exit",g,d],["enter",c[m][1],d],["exit",c[m][1],d],["exit",v,d]]),zs(c,f-1,m-f+3,w),m=f+w.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function l(c,d,m){const f=this.previous,v=this.events;let g=0;return w;function w(y){return f===126&&v[v.length-1][1].type!=="characterEscape"?m(y):(c.enter("strikethroughSequenceTemporary"),k(y))}function k(y){const C=Il(f);if(y===126)return g>1?m(y):(c.consume(y),g++,k);if(g<2&&!r)return m(y);const T=c.exit("strikethroughSequenceTemporary"),j=Il(y);return T._open=!j||j===2&&!!C,T._close=!C||C===2&&!!j,d(y)}}}class c6{constructor(){this.map=[]}add(t,r,s){u6(this,t,r,s)}consume(t){if(this.map.sort(function(l,c){return l[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const s=[];for(;r>0;)r-=1,s.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];s.push(t.slice()),t.length=0;let i=s.pop();for(;i;){for(const l of i)t.push(l);i=s.pop()}this.map.length=0}}function u6(e,t,r,s){let i=0;if(!(r===0&&s.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=r,e.map[i][2].push(...s);return}i+=1}e.map.push([t,r,s])}}function d6(e,t){let r=!1;const s=[];for(;t<e.length;){const i=e[t];if(r){if(i[0]==="enter")i[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=s.length-1;s[l]=s[l]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(r=!0);t+=1}return s}function h6(){return{flow:{null:{name:"table",tokenize:m6,resolveAll:p6}}}}function m6(e,t,r){const s=this;let i=0,l=0,c;return d;function d(L){let Q=s.events.length-1;for(;Q>-1;){const Y=s.events[Q][1].type;if(Y==="lineEnding"||Y==="linePrefix")Q--;else break}const O=Q>-1?s.events[Q][1].type:null,ne=O==="tableHead"||O==="tableRow"?E:m;return ne===E&&s.parser.lazy[s.now().line]?r(L):ne(L)}function m(L){return e.enter("tableHead"),e.enter("tableRow"),f(L)}function f(L){return L===124||(c=!0,l+=1),v(L)}function v(L){return L===null?r(L):an(L)?l>1?(l=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),k):r(L):Dn(L)?Fn(e,v,"whitespace")(L):(l+=1,c&&(c=!1,i+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,v):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||Xn(L)?(e.exit("data"),v(L)):(e.consume(L),L===92?w:g)}function w(L){return L===92||L===124?(e.consume(L),g):g(L)}function k(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?r(L):(e.enter("tableDelimiterRow"),c=!1,Dn(L)?Fn(e,y,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):y(L))}function y(L){return L===45||L===58?T(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),C):W(L)}function C(L){return Dn(L)?Fn(e,T,"whitespace")(L):T(L)}function T(L){return L===58?(l+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),j):L===45?(l+=1,j(L)):L===null||an(L)?F(L):W(L)}function j(L){return L===45?(e.enter("tableDelimiterFiller"),N(L)):W(L)}function N(L){return L===45?(e.consume(L),N):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),D):(e.exit("tableDelimiterFiller"),D(L))}function D(L){return Dn(L)?Fn(e,F,"whitespace")(L):F(L)}function F(L){return L===124?y(L):L===null||an(L)?!c||i!==l?W(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):W(L)}function W(L){return r(L)}function E(L){return e.enter("tableRow"),I(L)}function I(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),I):L===null||an(L)?(e.exit("tableRow"),t(L)):Dn(L)?Fn(e,I,"whitespace")(L):(e.enter("data"),M(L))}function M(L){return L===null||L===124||Xn(L)?(e.exit("data"),I(L)):(e.consume(L),L===92?_:M)}function _(L){return L===92||L===124?(e.consume(L),M):M(L)}}function p6(e,t){let r=-1,s=!0,i=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,m=0,f,v,g;const w=new c6;for(;++r<e.length;){const k=e[r],y=k[1];k[0]==="enter"?y.type==="tableHead"?(d=!1,m!==0&&(mC(w,t,m,f,v),v=void 0,m=0),f={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},w.add(r,0,[["enter",f,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(s=!0,g=void 0,l=[0,0,0,0],c=[0,r+1,0,0],d&&(d=!1,v={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},w.add(r,0,[["enter",v,t]])),i=y.type==="tableDelimiterRow"?2:v?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(l[1]!==0&&(c[0]=c[1],g=zd(w,t,l,i,void 0,g),l=[0,0,0,0]),c[2]=r)):y.type==="tableCellDivider"&&(s?s=!1:(l[1]!==0&&(c[0]=c[1],g=zd(w,t,l,i,void 0,g)),l=c,c=[l[1],r,0,0])):y.type==="tableHead"?(d=!0,m=r):y.type==="tableRow"||y.type==="tableDelimiterRow"?(m=r,l[1]!==0?(c[0]=c[1],g=zd(w,t,l,i,r,g)):c[1]!==0&&(g=zd(w,t,c,i,r,g)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&mC(w,t,m,f,v),w.consume(t.events),r=-1;++r<t.events.length;){const k=t.events[r];k[0]==="enter"&&k[1].type==="table"&&(k[1]._align=d6(t.events,r))}return e}function zd(e,t,r,s,i,l){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",d="tableContent";r[0]!==0&&(l.end=Object.assign({},Sl(t.events,r[0])),e.add(r[0],0,[["exit",l,t]]));const m=Sl(t.events,r[1]);if(l={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(r[1],0,[["enter",l,t]]),r[2]!==0){const f=Sl(t.events,r[2]),v=Sl(t.events,r[3]),g={type:d,start:Object.assign({},f),end:Object.assign({},v)};if(e.add(r[2],0,[["enter",g,t]]),s!==2){const w=t.events[r[2]],k=t.events[r[3]];if(w[1].end=Object.assign({},k[1].end),w[1].type="chunkText",w[1].contentType="text",r[3]>r[2]+1){const y=r[2]+1,C=r[3]-r[2]-1;e.add(y,C,[])}}e.add(r[3]+1,0,[["exit",g,t]])}return i!==void 0&&(l.end=Object.assign({},Sl(t.events,i)),e.add(i,0,[["exit",l,t]]),l=void 0),l}function mC(e,t,r,s,i){const l=[],c=Sl(t.events,r);i&&(i.end=Object.assign({},c),l.push(["exit",i,t])),s.end=Object.assign({},c),l.push(["exit",s,t]),e.add(r+1,0,l)}function Sl(e,t){const r=e[t],s=r[0]==="enter"?"start":"end";return r[1][s]}const f6={name:"tasklistCheck",tokenize:b6};function g6(){return{text:{91:f6}}}function b6(e,t,r){const s=this;return i;function i(m){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?r(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),l)}function l(m){return Xn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):r(m)}function d(m){return an(m)?t(m):Dn(m)?e.check({tokenize:v6},t,r)(m):r(m)}}function v6(e,t,r){return Fn(e,s,"whitespace");function s(i){return i===null?r(i):t(i)}}function w6(e){return UD([q5(),e6(),l6(e),h6(),g6()])}const y6={};function A0(e){const t=this,r=e||y6,s=t.data(),i=s.micromarkExtensions||(s.micromarkExtensions=[]),l=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);i.push(w6(r)),l.push(W5()),c.push(U5(r))}const Kh="*** Begin Patch",Yh="*** End Patch";function pC(e){const t=e.replace(/\r\n/g,`
|
|
98
|
+
`);if(!t.includes(Kh)||!t.includes(Yh))return null;const r=t.split(`
|
|
99
|
+
`),s=[];let i=null,l=null;for(const c of r){if(c===Kh||c===Yh)continue;if(c.startsWith("*** Update File: ")){i=qf("update",c.slice(17)),s.push(i),l=null;continue}if(c.startsWith("*** Add File: ")){i=qf("add",c.slice(14)),s.push(i),l={oldLineNumber:0,newLineNumber:1};continue}if(c.startsWith("*** Delete File: ")){i=qf("delete",c.slice(17)),s.push(i),l=null;continue}if(!i)continue;if(c.startsWith("*** Move to: ")){i.nextPath=c.slice(13),i.lines.push({kind:"meta",text:c,oldLineNumber:null,newLineNumber:null});continue}if(c.startsWith("@@")){l=C6(c)??{oldLineNumber:0,newLineNumber:0},i.lines.push({kind:"hunk",text:c,oldLineNumber:null,newLineNumber:null});continue}if(c==="*** End of File"){i.lines.push({kind:"meta",text:c,oldLineNumber:null,newLineNumber:null});continue}if(i.action==="add"&&c.startsWith("+")){i.additions+=1,i.lines.push({kind:"add",text:c,oldLineNumber:null,newLineNumber:(l==null?void 0:l.newLineNumber)??i.additions}),l&&(l.newLineNumber+=1);continue}if(!l){i.lines.push({kind:"meta",text:c,oldLineNumber:null,newLineNumber:null});continue}if(c.startsWith("+")){i.additions+=1,i.lines.push({kind:"add",text:c,oldLineNumber:null,newLineNumber:l.newLineNumber}),l.newLineNumber+=1;continue}if(c.startsWith("-")){i.deletions+=1,i.lines.push({kind:"remove",text:c,oldLineNumber:l.oldLineNumber,newLineNumber:null}),l.oldLineNumber+=1;continue}if(c.startsWith(" ")||c.length===0){i.lines.push({kind:"context",text:c,oldLineNumber:l.oldLineNumber,newLineNumber:l.newLineNumber}),l.oldLineNumber+=1,l.newLineNumber+=1;continue}i.lines.push({kind:"meta",text:c,oldLineNumber:null,newLineNumber:null})}return s.length===0?null:{files:s,totalAdditions:s.reduce((c,d)=>c+d.additions,0),totalDeletions:s.reduce((c,d)=>c+d.deletions,0)}}function k6(e,t=[]){const r=e.replace(/\r\n/g,`
|
|
100
|
+
`).trim();if(!r)return null;if(r.includes(Kh)&&r.includes(Yh))return r;const s=[...new Set(t.map(i=>i.trim()).filter(i=>i.length>0))];return s.length!==1||!j6(r)?null:[Kh,`*** Update File: ${s[0]}`,r,Yh].join(`
|
|
101
|
+
`)}function x6(e){const t=T6(e);if(!t)return[];const r=t.replace(/\r\n/g,`
|
|
102
|
+
`).split(`
|
|
103
|
+
`),s=[];let i=!1;for(const l of r){const c=l.trim();if(!i){/^Success\.\s+Updated the following files:/i.test(c)&&(i=!0);continue}if(!c){if(s.length>0)break;continue}const d=c.match(/^[A-Z?]\s+(.+)$/),m=((d==null?void 0:d[1])??c).trim();if(!m)break;s.push(m)}return[...new Set(s)]}function S6(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function qf(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,lines:[]}}function C6(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function j6(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
|
|
104
|
+
@@`)||e.startsWith("+")||e.startsWith("-")}function T6(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const r=JSON.parse(t);if(!r||typeof r!="object"||Array.isArray(r))return t;const s=r;if(typeof s.output=="string"&&s.output.trim().length>0)return s.output;if(typeof s.result=="string"&&s.result.trim().length>0)return s.result;if(typeof s.message=="string"&&s.message.trim().length>0)return s.message}catch{return t}return t}const N6=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,P6=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,D6=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,R6=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,M6=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g;function Ro(e){const t=A6(e),r=I6(t);return r||I0(t)}function A6(e){return e.replace(M6,"")}function I6(e){const t=e.trim();if(!E6(t))return null;try{const r=JSON.parse(t),s=L6(r);return s.text||s.inlineImages.length>0?s:null}catch{return null}}function E6(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function L6(e){const t=[],r=[];return kh(e,t,r),{text:L0(t.join(`
|
|
105
|
+
|
|
106
|
+
`)),inlineImages:E0(r)}}function kh(e,t,r){if(typeof e=="string"){const c=I0(e);c.text&&t.push(c.text),r.push(...c.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(c=>kh(c,t,r));return}if(typeof e!="object")return;const s=e,i=new Set,l=F6(s);l&&(r.push(l),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(c=>{c in s&&i.add(c)}));for(const c of["image_url","url","src","source"]){const d=s[c];typeof d!="string"||!F0(d)||(r.push(So(d,ti(s.alt))),i.add(c))}for(const c of["text","message","content","output","result","summary","caption"])c in s&&(i.add(c),kh(s[c],t,r));i.size>0||Object.values(s).forEach(c=>{kh(c,t,r)})}function I0(e){const t=[];let r=e;return r=r.replace(R6,(s,i,l)=>{const c=U6(i,"name"),d=W6(l);return d!=null&&d.url&&t.push(So(d.url,d.altText||c)),""}),r=r.replace(P6,(s,i,l)=>(t.push(So(l,i)),"")),r=r.replace(D6,(s,i)=>(t.push(So(i,null)),"")),r=r.replace(N6,(s,i,l)=>(t.push(So(s,null,`image/${i}`,Xh(l))),"")),{text:L0(r),inlineImages:E0(t)}}function So(e,t,r,s){const i=r??_6(e)??"image/png";return{url:e,mimeType:i,altText:su(t),estimatedBytes:s??O6(e)}}function F6(e){const t=B6(e.source);if(t){const i=ti(t.type).trim().toLowerCase(),l=gC(t.media_type??t.mime_type??t.mimeType),c=fC(t.data);if(i==="base64"&&l&&c)return So(`data:${l};base64,${c}`,su(ti(t.alt)||ti(t.name)||ti(e.alt)||ti(e.name)),l,Xh(c))}const r=gC(e.media_type??e.mime_type??e.mimeType),s=fC(e.data);return r&&s?So(`data:${r};base64,${s}`,su(ti(e.alt)||ti(e.name)),r,Xh(s)):null}function E0(e){const t=new Map;return e.forEach(r=>{t.has(r.url)||t.set(r.url,r)}),[...t.values()]}function L0(e){return e.replace(/\r\n/g,`
|
|
107
|
+
`).replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
|
|
108
|
+
`).replace(/\n{3,}/g,`
|
|
109
|
+
|
|
110
|
+
`).trim()}function F0(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function _6(e){var r;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((r=t==null?void 0:t[1])==null?void 0:r.toLowerCase())??null}function O6(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Xh(t[1]):null}function Xh(e){const t=e.trim(),r=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-r)}function su(e){const t=ti(e).trim();return t.length>0?t:null}function fC(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function gC(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function ti(e){return typeof e=="string"?e:""}function B6(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function W6(e){const t=e.trim();if(t.length===0)return null;try{const r=JSON.parse(t),s=ti(r.image_url??r.imageUrl).trim(),i=su(ti(r.name)||ti(r.alt));return{url:F0(s)?s:null,altText:i}}catch{const r=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return r?{url:r[1],altText:null}:null}}function U6(e,t){const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.match(new RegExp(`${r}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return su((s==null?void 0:s[1])??(s==null?void 0:s[2])??(s==null?void 0:s[3])??(s==null?void 0:s[4])??"")}const _0="codingns.user-app.conversation-scroll",vl=1,H6=200,z6=1e7;function O0(){return typeof window<"u"&&typeof window.localStorage<"u"}function B0(e){return e.trim()}function W0(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),z6)}function U0(e){return!e||typeof e!="object"?null:{scrollTop:W0(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function H0(){if(!O0())return{schemaVersion:vl,bySessionId:{}};const e=window.localStorage.getItem(_0);if(!e)return{schemaVersion:vl,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==vl||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:vl,bySessionId:{}};const r=Object.fromEntries(Object.entries(t.bySessionId).map(([s,i])=>{const l=U0(i);return l?[s,l]:null}).filter(s=>!!s));return{schemaVersion:vl,bySessionId:r}}catch{return{schemaVersion:vl,bySessionId:{}}}}function q6(e){if(O0())try{window.localStorage.setItem(_0,JSON.stringify(e))}catch{}}function qd(e){const t=B0(e);if(!t)return null;const r=H0().bySessionId[t],s=U0(r);return s?{scrollTop:s.scrollTop,stickToBottom:s.stickToBottom,lastMessageSignature:s.lastMessageSignature}:null}function bC(e,t){const r=B0(e);if(!r)return;const s=H0();s.bySessionId[r]={scrollTop:W0(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const i=Object.entries(s.bySessionId).sort((l,c)=>c[1].updatedAt-l[1].updatedAt).slice(0,H6);s.bySessionId=Object.fromEntries(i),q6(s)}function $6(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function V6(e){var s;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const r=((s=t[1])==null?void 0:s.trim())??"";return!r||/^previous turn aborted$/i.test(r)?{detail:null}:{detail:r}}function G6(e){return o(e==="user"?"conversation.turnAbortedUser":e==="runtime"?"conversation.turnAbortedUnexpected":"conversation.turnAbortedGeneric")}const K6=480,vC=80,wC=240,Y6=120,X6=50,Q6=3500,z0=p.createContext(!1);function pb(e){return e.replace(/\\/g,"/")}function Qh(e){return/^[a-zA-Z]:\//.test(e)}function J6(e){return e.startsWith("/")||e.startsWith("//")||Qh(e)}function Z6(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Qh(e)}function yC(e){return e.replace(/\/+$/,"")}function eq(e){const t=e.indexOf("#"),r=t>=0?e.slice(0,t):e,s=r.indexOf("?");return(s>=0?r.slice(0,s):r).replace(/:(\d+)(?::(\d+))?$/,"")}function tq(e){const t=[];for(const r of pb(e).split("/"))if(!(!r||r===".")){if(r===".."){if(t.length===0)return null;t.pop();continue}t.push(r)}return t.join("/")}function Qv(e){try{return decodeURIComponent(e)}catch{return e}}function nq(e,t){const r=Qv(e).trim();if(!r||r.startsWith("#"))return null;let s=r;if(/^file:\/\//i.test(s))try{s=decodeURIComponent(new URL(s).pathname),/^\/[a-zA-Z]:\//.test(s)&&(s=s.slice(1))}catch{return null}else if(Z6(s))return null;if(s=pb(eq(s.trim())),!s)return null;const i=yC(pb(t.trim()));if(!i)return null;if(J6(s)){const l=yC(s),c=Qh(i)?i.toLowerCase():i,d=Qh(l)?l.toLowerCase():l;if(d===c)return null;const m=`${c}/`;return d.startsWith(m)?l.slice(i.length+1):null}return tq(s)}function fb(e){return e.kind==="tool_call"||e.kind==="tool_result"}function q0(e){return e.toolCall?e.toolCall:fb(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function rq(e){return e==="shell_command"||e==="tool"?o("conversation.roleTool"):e}function $0(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function fo(e,t){const r=e[t];return typeof r=="string"?r:""}function sq(e){if(e.name==="apply_patch"){const l=pC(e.input);if(l)return l;const c=x6(e.output||e.error||""),d=k6(e.input,c);return d?pC(d):null}if(e.name!=="Write"&&e.name!=="Edit"&&e.name!=="MultiEdit")return null;const t=$0(e.input);if(!t)return null;const r=fo(t,"file_path")||fo(t,"path");if(!r)return null;if(e.name==="Write"){const l=fo(t,"content"),c=l.length>0?l.split(/\r?\n/):[];return{files:[{path:r,nextPath:null,action:"add",additions:c.length,deletions:0,lines:c.map((d,m)=>({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:m+1}))}],totalAdditions:c.length,totalDeletions:0}}if(e.name==="Edit"){const l=fo(t,"old_string").split(/\r?\n/),c=fo(t,"new_string").split(/\r?\n/);return kC(r,[{oldLines:l,newLines:c}])}const i=(Array.isArray(t.edits)?t.edits:[]).map(l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;const c=l;return{oldLines:fo(c,"old_string").split(/\r?\n/),newLines:fo(c,"new_string").split(/\r?\n/)}}).filter(l=>!!l);return i.length>0?kC(r,i):null}function kC(e,t){const r=[];let s=0,i=0;return t.forEach((l,c)=>{r.push({kind:"hunk",text:`@@ -1,${l.oldLines.length} +1,${l.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),l.oldLines.forEach((d,m)=>{d.length===0&&l.oldLines.length===1&&l.newLines.length>0||(i+=1,r.push({kind:"remove",text:`-${d}`,oldLineNumber:m+1,newLineNumber:null}))}),l.newLines.forEach((d,m)=>{d.length===0&&l.newLines.length===1&&l.oldLines.length>0||(s+=1,r.push({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:m+1}))}),c<t.length-1&&r.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:s,deletions:i,lines:r}],totalAdditions:s,totalDeletions:i}}function iq(e){const t=$0(e.input),r=t&&typeof t.command=="string"?t.command.trim():"";if(r)return`${o("conversation.toolPreviewCommand")}:${r}`;if(e.name==="read_thread_terminal")return o("conversation.toolPreviewTerminal");const s=e.input||e.error||e.output||o("conversation.toolResultEmpty");return s.length>60?`${s.slice(0,60)}...`:s}function aq(e){var l;const t=e.map(c=>({message:c,tool:q0(c)})).filter(c=>!!c.tool);if(t.length===0)return null;const r={...t[0].tool};let s=!1,i=!1;for(const{message:c,tool:d}of t)c.kind==="tool_call"&&(s=!0,!r.input&&d.input&&(r.input=d.input)),c.kind==="tool_result"&&(i=!0,r.output=d.output,r.error=d.error,r.status=d.status,!r.input&&d.input&&(r.input=d.input)),!r.name&&d.name&&(r.name=d.name);return{key:t.map(({message:c})=>c.id).join(":"),tool:r,hasRequest:s,hasResult:i,updatedAt:((l=t.at(-1))==null?void 0:l.message.timestamp)??t[0].message.timestamp}}function oq(e){const t=new Map;for(const r of e){const s=q0(r);if(!s)continue;const i=t.get(s.callId);if(i){i.messages.push(r);continue}t.set(s.callId,{messages:[r],firstSequence:r.sequence})}return Array.from(t.values()).sort((r,s)=>r.firstSequence-s.firstSequence).map(r=>aq(r.messages)).filter(r=>!!r)}function lq(e){const t=[];for(let r=0;r<e.length;r+=1){const s=e[r];if(!fb(s)){t.push({type:"message",key:s.id,message:s});continue}const i=[s];let l=r+1;for(;l<e.length;){const d=e[l];if(!fb(d))break;i.push(d),l+=1}const c=oq(i);if(c.length===0){t.push({type:"message",key:s.id,message:s}),r=l-1;continue}c.forEach(d=>{t.push({type:"tool_group",key:d.key,group:d})}),r=l-1}return t}function cq(e,t){if(!I_(null,e))return!1;const r=t.trim();return/AGENTS\.md instructions for/i.test(r)&&/<INSTRUCTIONS>/i.test(r)&&/<\/INSTRUCTIONS>/i.test(r)}function uq(e){const t=e.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return t?t.replace(/^#+\s*/,""):o("conversation.rulesMessageTitle")}function dq(e,t){const r=new Set;if(t!=="kimi")return r;for(const s of e){if(s.role==="system"&&s.kind==="text"){r.add(s.id);continue}break}return r}function iu(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(r=>iu(r)).join(""):e&&typeof e=="object"&&"props"in e?iu(((t=e.props)==null?void 0:t.children)??""):""}function hq(e){const t=Array.isArray(e)?e[0]:e;if(!p.isValidElement(t))return null;const r=t.props,s=typeof r.className=="string"?r.className:"",i=/language-([^\s]+)/.exec(s);return{content:iu(r.children).replace(/\n$/,""),codeClassName:s||void 0,language:(i==null?void 0:i[1])??null}}function mq(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function Jv(e,t){var r;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!mq(e))throw new Error(o("conversation.copyContentFailed"))}}function pq({className:e,children:t,onCopy:r}){const s=p.useContext(z0),i=iu(t).trim();if(s||!i)return n.jsx("code",{className:e||void 0,children:t});function l(c){c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),r(i))}return n.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":o("conversation.copyAction"),onClick:()=>r(i),onKeyDown:l,children:t})}function fq({href:e,children:t,className:r,onInteract:s}){const i=iu(t).trim()||(e?Qv(e).trim():"");return n.jsx(z0.Provider,{value:!0,children:n.jsx("a",{href:e,className:[r,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:l=>{l.preventDefault(),s(e,i)},children:t})})}function V0({language:e,codeClassName:t,content:r}){const{showToast:s}=Qn(),i=nr(),l=(e==null?void 0:e.trim().toLowerCase())??null,c=l==="text",d=l||"code";async function m(){try{await Jv(r,i),s({title:o("conversation.copyContentSuccess"),tone:"success"})}catch(f){s({title:f instanceof Error?f.message:o("conversation.copyContentFailed"),tone:"error"})}}return n.jsxs("div",{className:`code-block${c?" text-code-block":""}`,children:[n.jsxs("div",{className:"code-header",children:[n.jsx("span",{className:"code-header-label",children:d}),n.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void m(),children:o("conversation.copyAction")})]}),n.jsx("pre",{className:t,children:n.jsx("code",{children:r})})]})}function _c({content:e,className:t}){const{showToast:r}=Qn(),s=nr(),{navigationGroups:i,currentWorkspaceId:l,revealWorkspaceFile:c}=Pr(),d=p.useMemo(()=>{var v;return((v=i.find(g=>g.workspace.id===l))==null?void 0:v.workspace)??null},[l,i]);async function m(v){if(v.trim())try{await Jv(v,s),r({title:o("conversation.copyContentSuccess"),tone:"success"})}catch(g){r({title:g instanceof Error?g.message:o("conversation.copyContentFailed"),tone:"error"})}}function f(v,g){const w=v&&(d!=null&&d.path)?nq(v,d.path):null;w&&c({workspaceId:(d==null?void 0:d.id)??l,filePath:w,openViewer:!1})||m(g||(v?Qv(v).trim():""))}return n.jsx("div",{className:t,children:n.jsx(l0,{remarkPlugins:[A0],components:{p:({node:v,...g})=>n.jsx("p",{...g}),a(v){return n.jsx(fq,{href:typeof v.href=="string"?v.href:void 0,className:typeof v.className=="string"?v.className:void 0,onInteract:f,children:v.children})},pre(v){const g=hq(v.children);return g?n.jsx(V0,{language:g.language,codeClassName:g.codeClassName,content:g.content}):n.jsx("pre",{children:v.children})},code(v){const g=typeof v.className=="string"?v.className:"";return n.jsx(pq,{className:g||void 0,onCopy:w=>{m(w)},children:v.children})}},children:e})})}function xC(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function gq(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function $d({sessionId:e,attachmentPayloads:t=[],attachments:r=[],inlineImages:s=[]}){return n.jsx(bq,{sessionId:e,attachments:r,attachmentPayloads:t,inlineImages:s})}function bq({sessionId:e,attachmentPayloads:t=[],attachments:r=[],inlineImages:s=[]}){const[i,l]=p.useState({}),[c,d]=p.useState(null),m=p.useMemo(()=>r.map((w,k)=>{const y=xC(w,t==null?void 0:t[k]);if(y)return{id:w.id,kind:w.kind,fileName:w.fileName,fileSize:w.fileSize,url:y,status:"ready"};const C=i[w.id];return{id:w.id,kind:w.kind,fileName:w.fileName,fileSize:w.fileSize,url:(C==null?void 0:C.url)??null,status:(C==null?void 0:C.status)??(e?"loading":"error")}}),[t,r,i,e]),f=p.useMemo(()=>s.map((w,k)=>({id:`inline-image-${k}`,kind:"image",fileName:w.altText||`${o("conversation.imageAttachmentLabel")} ${k+1}`,fileSize:w.estimatedBytes,url:w.url,status:"ready"})),[s]),v=p.useMemo(()=>[...f,...m],[m,f]),g=v.find(w=>w.id===c)??null;return p.useEffect(()=>{if(!c)return;function w(k){k.key==="Escape"&&d(null)}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[c]),p.useEffect(()=>{const w=r.filter((C,T)=>!xC(C,t==null?void 0:t[T]));if(!e||w.length===0){l({});return}let k=!1;const y=[];return l(Object.fromEntries(w.map(C=>[C.id,{id:C.id,kind:C.kind,fileName:C.fileName,fileSize:C.fileSize,url:null,status:"loading"}]))),Promise.all(w.map(async C=>{try{const T=await n_(e,C.id),j=URL.createObjectURL(T);return y.push(j),{id:C.id,kind:C.kind,fileName:C.fileName,fileSize:C.fileSize,url:j,status:"ready"}}catch{return{id:C.id,kind:C.kind,fileName:C.fileName,fileSize:C.fileSize,url:null,status:"error"}}})).then(C=>{if(k){y.forEach(T=>URL.revokeObjectURL(T));return}l(Object.fromEntries(C.map(T=>[T.id,T])))}),()=>{k=!0,y.forEach(C=>URL.revokeObjectURL(C))}},[t,r,e]),v.length===0?null:n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"message-attachments",children:v.map(w=>{const k=w.kind==="image",y=w.status==="loading"?o("conversation.attachmentPreviewLoading"):w.status==="error"?o("conversation.attachmentPreviewUnavailable"):o(k?"conversation.attachmentPreviewOpen":"conversation.attachmentDownload"),C=gq(w.fileSize),T=n.jsx("div",{className:"message-attachment-card",children:k?w.url?n.jsx("img",{className:"message-attachment-thumbnail",src:w.url,alt:w.fileName||o("conversation.attachmentPreviewAlt"),loading:"lazy"}):n.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:w.status==="loading"?o("conversation.attachmentPreviewLoading"):o("conversation.attachmentPreviewUnavailable")}):n.jsxs("div",{className:"message-attachment-file-card",children:[n.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),n.jsx("path",{d:"M14 2v5h5"}),n.jsx("path",{d:"M9 13h6"}),n.jsx("path",{d:"M9 17h6"})]})}),n.jsxs("div",{className:"message-attachment-file-meta",children:[n.jsx("strong",{title:w.fileName,children:w.fileName}),n.jsx("span",{children:C??o("conversation.fileAttachmentLabel")})]})]})});return!k&&w.url?n.jsx("a",{className:"message-attachment-button",href:w.url,download:w.fileName,"aria-label":`${w.fileName} - ${y}`,title:y,children:T},w.id):n.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>k&&w.url&&d(w.id),disabled:!w.url,"aria-label":`${w.fileName} - ${y}`,title:y,children:T},w.id)})}),g!=null&&g.url?n.jsxs("div",{className:"workbench-modal-layer message-image-modal",role:"dialog","aria-modal":"true",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("conversation.attachmentPreviewClose"),onClick:()=>d(null)}),n.jsxs("div",{className:"workbench-modal-card surface-card message-image-modal-card",children:[n.jsxs("div",{className:"workbench-modal-header message-image-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("conversation.imagePreviewTitle")}),n.jsx("p",{children:g.fileName})]}),n.jsx(Lo,{"aria-label":o("conversation.attachmentPreviewClose"),onClick:()=>d(null)})]}),n.jsxs("div",{className:"message-image-modal-body",children:[n.jsx("div",{className:"message-image-modal-stage",children:n.jsx("img",{className:"message-image-modal-image",src:g.url,alt:g.fileName||o("conversation.attachmentPreviewAlt")})}),n.jsx("p",{className:"message-image-modal-hint",children:o("conversation.imagePreviewHint")})]})]})]}):null]})}function vq(){return n.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>n.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[n.jsx("div",{className:"timeline-skeleton-avatar"}),n.jsxs("div",{className:"timeline-skeleton-bubble",children:[n.jsx("span",{className:"timeline-skeleton-line long"}),n.jsx("span",{className:"timeline-skeleton-line medium"}),n.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function wq({tool:e,preview:t}){const[r,s]=p.useState(null);return p.useEffect(()=>{if(r===null)return;function i(l){l.key==="Escape"&&s(null)}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((i,l)=>n.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>s(l),children:[n.jsx("span",{className:"apply-patch-summary-label",children:SC(i.action)}),n.jsx("span",{className:"apply-patch-summary-file",title:$f(i),children:S6(i.nextPath??i.path)}),n.jsxs("span",{className:"apply-patch-summary-stats",children:[n.jsxs("span",{className:"apply-patch-summary-added",children:["+",i.additions]}),n.jsxs("span",{className:"apply-patch-summary-removed",children:["-",i.deletions]})]})]},CC(i,l)))}),r!==null&&typeof document<"u"?$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer apply-patch-modal",role:"dialog","aria-modal":"true",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:()=>s(null)}),n.jsxs("div",{className:"workbench-modal-card surface-card apply-patch-modal-card",children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("conversation.applyPatchDialogTitle")}),n.jsx("p",{children:o("conversation.applyPatchDialogDescription")})]}),n.jsx(Lo,{onClick:()=>s(null)})]}),(()=>{const i=t.files[r];return i?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"apply-patch-modal-totals",children:[n.jsxs("span",{className:"apply-patch-stat-pill positive",children:[o("conversation.applyPatchAddedStat")," +",i.additions]}),n.jsxs("span",{className:"apply-patch-stat-pill negative",children:[o("conversation.applyPatchRemovedStat")," -",i.deletions]})]}),n.jsxs("div",{className:"apply-patch-modal-body",children:[n.jsxs("section",{className:"apply-patch-file-panel",children:[n.jsxs("div",{className:"apply-patch-file-panel-header",children:[n.jsxs("div",{className:"apply-patch-file-panel-title",children:[n.jsx("span",{className:"apply-patch-summary-label",children:SC(i.action)}),n.jsx("strong",{children:$f(i)})]}),n.jsxs("div",{className:"apply-patch-summary-stats",children:[n.jsxs("span",{className:"apply-patch-summary-added",children:["+",i.additions]}),n.jsxs("span",{className:"apply-patch-summary-removed",children:["-",i.deletions]})]})]}),n.jsx("div",{className:"apply-patch-diff-view",children:n.jsx("div",{className:"apply-patch-diff-scroll",children:i.lines.map((l,c)=>n.jsxs("div",{className:`apply-patch-diff-line ${jq(l.kind)}`,children:[n.jsx("span",{className:"apply-patch-line-number",children:jC(l.oldLineNumber)}),n.jsx("span",{className:"apply-patch-line-number",children:jC(l.newLineNumber)}),n.jsx("span",{className:"apply-patch-line-content",children:l.text||" "})]},`${$f(i)}:${c}`))})})]},CC(i,r)),e.error?n.jsxs("section",{className:"apply-patch-error-panel",children:[n.jsx("div",{className:"tool-call-section-label",children:o("conversation.toolResultLabel")}),n.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]})]}):null})()]})]}),document.body):null]})}function yq({group:e}){const[t,r]=p.useState(!1),{tool:s,hasRequest:i,hasResult:l}=e,c=rq(s.name),d=p.useMemo(()=>iB(s,null,e.updatedAt),[e.updatedAt,s]),m=p.useMemo(()=>sq(s),[s.input,s.name]);if(m)return n.jsx(wq,{tool:s,preview:m});if(d)return n.jsx(kq,{tool:s,snapshot:d,expanded:t,hasRequest:i,hasResult:l,onToggleExpanded:()=>{r(g=>!g)}});const f=iq(s),v=!!(s.input||s.output||s.error);return n.jsxs("div",{className:`tool-call-item ${l?"tool-result":""}`,children:[n.jsxs("button",{type:"button",className:"tool-call-header",onClick:()=>v&&r(g=>!g),children:[n.jsxs("div",{className:"tool-call-info",children:[n.jsx("span",{className:"tool-call-name",children:c}),n.jsx("span",{className:"tool-call-input-preview",children:f})]}),n.jsx("div",{className:"tool-call-meta",children:v&&n.jsx("span",{className:`tool-call-toggle ${t?"expanded":""}`,children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]}),t&&v&&n.jsxs("div",{className:"tool-call-output",children:[i&&s.input&&n.jsxs("div",{className:"tool-call-section",children:[n.jsx("div",{className:"tool-call-section-label",children:o("conversation.toolInputLabel")}),n.jsx("pre",{children:s.input})]}),(l||s.error||s.output)&&n.jsxs("div",{className:"tool-call-section",children:[n.jsx("div",{className:"tool-call-section-label",children:o("conversation.toolResultLabel")}),n.jsx("pre",{className:s.error?"tool-call-error":void 0,children:s.error||s.output||o("conversation.toolResultEmpty")})]})]})]})}function kq({tool:e,snapshot:t,expanded:r,hasRequest:s,hasResult:i,onToggleExpanded:l}){const c=wD(t.items),d=o(r?"conversation.taskCardRawCollapse":"conversation.taskCardRawExpand");return n.jsxs("div",{className:"tool-call-item task-tool-item",children:[n.jsxs("div",{className:"task-tool-header",children:[n.jsxs("div",{className:"task-tool-heading",children:[n.jsx("span",{className:"task-tool-badge",children:t.source==="plan"?o("conversation.taskCardPlanTitle"):o("conversation.taskCardTodoTitle")}),n.jsxs("div",{className:"task-tool-heading-main",children:[n.jsx("strong",{children:xq(t,e.name)}),n.jsx("span",{className:"task-tool-summary-text",children:Sq(t.items,c)})]})]}),n.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:l,children:d})]}),n.jsx("ol",{className:"task-tool-list",children:t.items.map(m=>n.jsxs("li",{className:"task-tool-list-item","data-status":m.status,children:[n.jsx("span",{className:"task-tool-item-indicator","data-status":m.status,"aria-hidden":"true"}),n.jsx("strong",{className:"task-tool-item-title",children:m.title}),m.detail?n.jsx("span",{className:"task-tool-item-detail",children:m.detail}):null,n.jsx("span",{className:"task-tool-item-status",children:Cq(m.status)})]},m.id))}),r?n.jsxs("div",{className:"tool-call-output",children:[s&&e.input?n.jsxs("div",{className:"tool-call-section",children:[n.jsx("div",{className:"tool-call-section-label",children:o("conversation.toolInputLabel")}),n.jsx("pre",{children:e.input})]}):null,i||e.error||e.output?n.jsxs("div",{className:"tool-call-section",children:[n.jsx("div",{className:"tool-call-section-label",children:o("conversation.toolResultLabel")}),n.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||o("conversation.toolResultEmpty")})]}):null]}):null]})}function xq(e,t){if(e.source==="plan")return o("conversation.taskCardPlanUpdated");const r=t.trim().toLowerCase();return r==="taskcreate"||r==="todowrite"||r==="todoread"||r.startsWith("task"),o("conversation.taskCardTodoUpdated")}function Sq(e,t){const r=[o("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&r.push(o("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&r.push(o("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&r.push(o("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&r.push(o("conversation.taskCardSummaryFailed",{count:t.failed})),r.join(" / ")}function Cq(e){switch(e){case"in_progress":return o("conversation.taskProgressStatusInProgress");case"completed":return o("conversation.taskProgressStatusCompleted");case"failed":return o("conversation.taskProgressStatusFailed");case"cancelled":return o("conversation.taskProgressStatusCancelled");case"pending":default:return o("conversation.taskProgressStatusPending")}}function SC(e){return o(e==="add"?"conversation.applyPatchAddedLabel":e==="delete"?"conversation.applyPatchDeletedLabel":"conversation.applyPatchEditedLabel")}function $f(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function CC(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function jq(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function jC(e){return e===null||e<=0?"":String(e)}function Tq(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function G0({timestamp:e,leading:t,children:r}){return n.jsxs("div",{className:"user-message-footer",children:[n.jsx("div",{className:"user-message-footer-leading",children:t}),n.jsxs("div",{className:"user-message-footer-trailing",children:[n.jsx("time",{className:"message-time",dateTime:e,children:Tq(e)}),r]})]})}function yo({text:e,canCopy:t=!0,canFork:r=!1,compact:s=!1,onFork:i}){const{showToast:l}=Qn(),c=nr(),[d,m]=p.useState(!1),[f,v]=p.useState(!1),g=e.trim().length>0,w=t&&g;async function k(){if(!(!w||d)){m(!0);try{await Jv(e,c),l({title:o("conversation.copyContentSuccess"),tone:"success"})}catch(C){l({title:C instanceof Error?C.message:o("conversation.copyContentFailed"),tone:"error"})}finally{m(!1)}}}async function y(){if(!(!i||f)){v(!0);try{await i()}finally{v(!1)}}}return!w&&!r?null:n.jsxs("div",{className:s?"message-metadata-bar compact":"message-metadata-bar",children:[w?n.jsx("button",{type:"button",className:"message-metadata-action","aria-label":o("conversation.copyAction"),title:o("conversation.copyAction"),onClick:()=>{k()},disabled:d,children:n.jsx(pB,{})}):null,r?n.jsx("button",{type:"button",className:"message-metadata-action","aria-label":o(f?"conversation.forkingAction":"conversation.forkFromHereAction"),title:o(f?"conversation.forkingAction":"conversation.forkFromHereAction"),onClick:()=>{y()},disabled:f,children:n.jsx(fB,{})}):null]})}function Nq({message:e,kind:t,tone:r,actionState:s,onRetry:i,onForkMessage:l}){const[c,d]=p.useState(!1),m=uq(e.content),f=r==="user-message",v=o(t==="system_prompt"?"conversation.systemPromptTitle":"conversation.rulesMessageTitle"),g=o(t==="system_prompt"?"conversation.systemPromptHint":"conversation.rulesMessageHint"),w=o(c?t==="system_prompt"?"conversation.systemPromptCollapse":"conversation.rulesMessageCollapse":t==="system_prompt"?"conversation.systemPromptExpand":"conversation.rulesMessageExpand");return n.jsx("article",{className:`message-item ${r} rules-message-row`,"data-message-id":e.id,children:n.jsxs("div",{className:"message-content-wrapper",children:[n.jsxs("div",{className:"rules-message-card",children:[n.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":c,onClick:()=>d(k=>!k),children:[n.jsxs("div",{className:"rules-message-heading",children:[n.jsx("span",{className:"rules-message-badge",children:v}),n.jsx("span",{className:"rules-message-summary",children:m})]}),n.jsx("span",{className:"rules-message-action",children:w})]}),n.jsx("p",{className:"rules-message-hint",children:g}),c&&n.jsx("div",{className:"rules-message-body",children:n.jsx(_c,{content:e.content,className:"message-text message-content markdown-content"})}),f?n.jsx(G0,{timestamp:e.timestamp,children:n.jsx(yo,{text:e.content,canCopy:s.canCopy,canFork:s.canFork&&!!(l&&e.deliveryState==="sent"),compact:!0,onFork:l?()=>l(e):null})}):n.jsx(yo,{text:e.content,canCopy:s.canCopy,canFork:s.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&n.jsx("button",{className:"retry-button",type:"button",onClick:()=>i(e.clientRequestId),children:o("conversation.resendButton")})]})})}function Pq({message:e,provider:t,interruptedSource:r=null,foldedPromptKind:s=null,actionState:i,onRetry:l,onForkMessage:c,assistantAvatar:d}){const m=e.role==="user",f=e.kind==="thinking",v=e.role==="assistant"&&e.kind==="text",g=t==="codex"&&e.kind==="text"?V6(e.content):null,w=s??(cq(t,e.content)?"rules":null),k=p.useMemo(()=>Ro(e.content),[e.content]),y=k.text,C=k.inlineImages,[T,j]=p.useState(!1),[N,D]=p.useState(!1),[F,W]=p.useState(null),[E,I]=p.useState(null);if(w){const M=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return n.jsx(Nq,{message:e,kind:w,tone:M,actionState:i,onRetry:l,onForkMessage:c})}if(g){const M=G6(r),_=g.detail?`${M}
|
|
111
|
+
|
|
112
|
+
${g.detail}`:M;return n.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[n.jsx("div",{className:"message-avatar",children:d??n.jsx(Vf,{})}),n.jsxs("div",{className:"message-content-wrapper",children:[n.jsx(_c,{content:_,className:"message-text message-content markdown-content"}),n.jsx(yo,{text:_,canCopy:i.canCopy,canFork:!1,onFork:null})]})]})}if(m){const M=e.origin==="butler_proxy"||Dq(e.clientRequestId),_=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function L(){if(!_)return;const O=!T;if(j(O),!(!O||E||N)){D(!0),W(null);try{const ne=await LP(e.originRef);I(ne.task)}catch(ne){W(ne instanceof Error?ne.message:o("conversation.butlerOriginDetailLoadFailed"))}finally{D(!1)}}}const Q=M?_?n.jsxs("div",{className:"message-origin-detail-anchor",children:[n.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":T,onClick:()=>{L()},children:o("conversation.butlerProxyMessageBadge")}),T?n.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[n.jsx("strong",{children:o("conversation.butlerOriginDetailTitle")}),N?n.jsx("p",{children:o("conversation.butlerOriginDetailLoading")}):F?n.jsx("p",{children:F}):E?n.jsxs(n.Fragment,{children:[n.jsxs("p",{children:[o("conversation.butlerOriginDetailObjectiveLabel"),":",E.objective]}),n.jsxs("p",{children:[o("conversation.butlerOriginDetailStatusLabel"),":",Rq(E.status)]}),n.jsxs("p",{children:[o("conversation.butlerOriginDetailSummaryLabel"),":",E.lastAutomationSummary||o("conversation.butlerAnalysisEmpty")]}),E.waitingReason?n.jsxs("p",{children:[o("conversation.butlerOriginDetailWaitingReasonLabel"),":",E.waitingReason]}):null]}):n.jsx("p",{children:o("conversation.butlerAnalysisEmpty")})]}):null]}):n.jsx("span",{className:"message-origin-badge",children:o("conversation.butlerProxyMessageBadge")}):null;return n.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:n.jsxs("div",{className:"message-content-wrapper",children:[n.jsx($d,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:C}),y?n.jsx(_c,{content:y,className:"message-text message-content markdown-content"}):null,e.deliveryState==="failed"&&e.clientRequestId&&n.jsx("button",{className:"retry-button",type:"button",onClick:()=>l(e.clientRequestId),children:o("conversation.resendButton")}),n.jsx(G0,{timestamp:e.timestamp,leading:Q,children:n.jsx(yo,{text:y,canCopy:i.canCopy,canFork:i.canFork&&!!(c&&e.deliveryState==="sent"),compact:!0,onFork:c?()=>c(e):null})})]})})}return f?n.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[n.jsx("div",{className:"message-avatar",children:d??n.jsx(Vf,{})}),n.jsxs("div",{className:"thinking-message-content",children:[n.jsx("div",{className:"thinking-message-label",children:o("conversation.thinkingLabel")}),n.jsx($d,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:C}),y&&n.jsx(_c,{content:y,className:"message-text message-content markdown-content thinking-message-text"}),n.jsx(yo,{text:y,canCopy:i.canCopy,canFork:i.canFork&&!!(c&&e.deliveryState==="sent"),onFork:c?()=>c(e):null})]})]}):v?n.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[n.jsx("div",{className:"message-avatar",children:d??n.jsx(Vf,{})}),n.jsxs("div",{className:"message-content-wrapper",children:[n.jsx($d,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:C}),y&&n.jsx(_c,{content:y,className:"message-text message-content markdown-content"}),n.jsx(yo,{text:y,canCopy:i.canCopy,canFork:i.canFork&&!!(c&&e.deliveryState==="sent"),onFork:c?()=>c(e):null})]})]}):n.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:n.jsxs("div",{className:"message-content-wrapper",children:[n.jsx($d,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:C}),y?n.jsx("div",{className:"message-text message-content",children:n.jsx(V0,{language:"text",content:y})}):null,n.jsx(yo,{text:y,canCopy:i.canCopy,canFork:i.canFork&&!!(c&&e.deliveryState==="sent"),onFork:c?()=>c(e):null})]})})}function Vf(){return n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function Dq(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function Rq(e){switch(e){case"waiting_user":return o("shell.butlerAutomationStatusWaitingUser");case"completed":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":return o("shell.butlerAutomationStatusCancelled");case"active":default:return o("shell.butlerAutomationStatusActive")}}function Nm({sessionId:e="session",messages:t,historyState:r,loadingOlderMessages:s=!1,hasOlderMessages:i=!1,onLoadOlderMessages:l=()=>{},onRetryMessage:c,onForkMessage:d,provider:m,interruptedSource:f=null,runtimeThinkingPlaceholder:v=null,assistantAvatar:g}){var et;const{showToast:w}=Qn(),k=p.useRef(null),y=p.useRef(e),C=p.useRef(0),T=p.useRef(null),j=p.useRef(!0),N=p.useRef(null),D=p.useRef(!1),F=p.useRef(qd(e)),W=p.useRef(((et=qd(e))==null?void 0:et.lastMessageSignature)??null),E=p.useRef(qd(e)),I=p.useRef(null),M=p.useRef(null),_=p.useRef(null),L=p.useRef(0),Q=p.useRef(!1),[O,ne]=p.useState(!1),[Y,G]=p.useState(!1),te=p.useRef(!1),K=lq(t),z=p.useMemo(()=>dq(t,m),[t,m]),q=p.useMemo(()=>Mq(t),[t]),P=r==="loading"&&t.length===0;function U(De){const Ye=De.scrollHeight-De.clientHeight-De.scrollTop<=vC;return{scrollTop:De.scrollTop,stickToBottom:Ye,lastMessageSignature:te.current&&!Ye?W.current:Vd(t.at(-1)??null)}}function X(De){return E.current=U(De),E.current}function R(De){const Ue=De.scrollHeight-De.clientHeight-De.scrollTop,Ye=Ue<=vC;j.current=Ye,Ye&&te.current&&(xe(),te.current=!1,W.current=Vd(t.at(-1)??null),G(!1)),ne(t.length>0&&(Ue>wC||te.current)),X(De)}function Se(De=k.current){De&&X(De),E.current&&bC(e,E.current)}function se(De){E.current&&bC(De,E.current)}function J(){I.current!==null&&(window.clearTimeout(I.current),I.current=null)}function Ne(){J(),I.current=window.setTimeout(()=>{I.current=null,Se()},Y6)}function Ee(De){De.scrollTop=De.scrollHeight}function ie(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function xe(){ie(),Q.current=!1,_.current=null,L.current=0}function lt(De,Ue){const Ye=Math.max(0,De.scrollHeight-De.clientHeight),ye=Math.max(0,Math.min(Ue,Ye));De.scrollTop=ye,j.current=!1,ne(t.length>0&&(Ye-ye>wC||te.current))}function Oe(){ie(),Q.current&&(M.current=window.setTimeout(()=>{M.current=null;const De=k.current,Ue=_.current;if(!De||Ue===null){xe();return}if(lt(De,Ue),Date.now()<L.current){Oe();return}xe(),R(De)},X6))}function bt(De,Ue){Q.current=!0,_.current=De,L.current=Date.now()+Q6,lt(Ue,De),Oe()}function Ct(De){return D.current||!i||s||r!=="ready"||De.scrollTop>K6?!1:(D.current=!0,N.current=De.scrollHeight-De.scrollTop,l(),!0)}p.useEffect(()=>{r==="error"&&w({title:o("conversation.historyLoadFailed"),tone:"error"})},[r,w]),p.useLayoutEffect(()=>{var De,Ue;y.current!==e&&(se(y.current),y.current=e,C.current=0,T.current=null,F.current=qd(e),W.current=((De=F.current)==null?void 0:De.lastMessageSignature)??null,E.current=F.current,j.current=((Ue=F.current)==null?void 0:Ue.stickToBottom)??!0,N.current=null,xe(),te.current=!1,G(!1),ne(!1))},[e]),p.useLayoutEffect(()=>()=>{J(),xe(),se(y.current)},[e]),p.useLayoutEffect(()=>{const De=k.current,Ue=Vd(t.at(-1)??null);if(!De){C.current=t.length,T.current=Ue;return}const Ye=C.current,ye=T.current,He=F.current;if(He&&r==="ready"){const je=!He.stickToBottom&&He.lastMessageSignature!==null&&Ue!==null&&He.lastMessageSignature!==Ue;He.stickToBottom?(xe(),Ee(De)):bt(He.scrollTop,De),te.current=je,W.current=He.lastMessageSignature,G(je),F.current=null,R(De),C.current=t.length,T.current=Ue,X(De);return}if(He&&r==="error"){He.stickToBottom?(xe(),Ee(De)):bt(He.scrollTop,De),F.current=null,R(De),C.current=t.length,T.current=Ue,X(De);return}if(Q.current){lt(De,_.current??De.scrollTop),C.current=t.length,T.current=Ue,X(De);return}N.current!==null&&t.length>=Ye?(De.scrollTop=Math.max(0,De.scrollHeight-N.current),N.current=null):j.current&&(Ye===0||t.length!==Ye||Ue!==ye)&&Ee(De),R(De),C.current=t.length,T.current=Ue},[r,t,e]),p.useEffect(()=>{if(!i){D.current=!1;return}!s&&N.current===null&&(D.current=!1)},[i,s,t.length]);function nt(){const De=k.current;De&&(R(De),Ne(),Ct(De))}return n.jsxs("section",{className:"message-timeline",children:[r==="loading"&&n.jsx("div",{className:"timeline-status",children:n.jsx("span",{className:"status-text",children:o("conversation.historyLoading")})}),n.jsxs("div",{ref:k,className:"message-list",onScroll:nt,children:[P?n.jsx(vq,{}):null,s?n.jsx("div",{className:"timeline-status timeline-status-inline",children:n.jsx("span",{className:"status-text",children:o("conversation.historyLoadingOlder")})}):null,K.length===0&&r==="ready"&&n.jsx("div",{className:"timeline-empty",children:n.jsx("p",{className:"status-text",children:o("conversation.timelineEmpty")})}),K.map(De=>De.type==="tool_group"?n.jsx("article",{className:"message-item tool-message-row",children:n.jsx(yq,{group:De.group})},De.key):n.jsx(Pq,{message:De.message,provider:m,foldedPromptKind:z.has(De.message.id)?"system_prompt":null,actionState:q.get(De.message.id)??{canCopy:De.message.role==="user",canFork:!1},onRetry:c,onForkMessage:d,interruptedSource:f,assistantAvatar:g},De.key)),v?n.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:n.jsxs("span",{className:"status-text thinking-status-text","aria-label":v,children:[n.jsx("span",{children:$6(v)||v}),n.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null]}),O?n.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":Y?"true":"false","aria-label":o("conversation.scrollToBottomAction"),title:o("conversation.scrollToBottomAction"),onClick:()=>{const De=k.current;De&&(xe(),Ee(De),te.current=!1,W.current=Vd(t.at(-1)??null),G(!1),R(De),Se(De))},children:[Y?n.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,n.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:n.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function Vd(e){return e?JSON.stringify({id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function Mq(e){const t=new Map;let r=0;function s(i){let l=null;for(let c=i-1;c>=r;c-=1){const d=e[c];if(!(!d||!Aq(d))){l=d.id;break}}for(let c=r;c<i;c+=1){const d=e[c];if(d){if(d.role==="user"){t.set(d.id,{canCopy:!0,canFork:!1});continue}t.set(d.id,{canCopy:d.id===l,canFork:d.id===l})}}}for(let i=0;i<e.length;i+=1){const l=e[i];l&&l.role==="user"&&i>r&&(s(i),r=i)}return s(e.length),t}function Aq(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function K0(){return n.jsxs("section",{className:"butler-loading-panel",role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"butler-loading-orb","aria-hidden":"true",children:[n.jsx("span",{className:"butler-loading-ring butler-loading-ring-primary"}),n.jsx("span",{className:"butler-loading-ring butler-loading-ring-secondary"}),n.jsx("span",{className:"butler-loading-core"})]}),n.jsxs("div",{className:"butler-loading-copy",children:[n.jsx("h1",{children:o("shell.butlerLoadingTitle")}),n.jsx("p",{children:o("shell.butlerLoadingDescription")})]})]})}const TC="butler:records-updated";function Zv(e){if(typeof window>"u")return()=>{};const t=()=>{e()};return window.addEventListener(TC,t),()=>{window.removeEventListener(TC,t)}}class Y0{constructor(t){ot(this,"socket",null);ot(this,"disposed",!1);ot(this,"authRecoveryInFlight",!1);ot(this,"latestCursor");ot(this,"subscribed",!1);ot(this,"pendingOlderRequest",null);ot(this,"connectionManager");this.options=t,this.latestCursor=t.cursor,this.connectionManager=new qN({onReconnect:r=>{this.connect(r)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.latestCursor=t}reconnectNow(){this.connectionManager.reconnectNow()}requestOlderMessages(t,r){return!this.socket||this.socket.readyState!==WebSocket.OPEN?!1:this.subscribed?(this.sendOlderMessagesRequest(t,r),!0):(this.pendingOlderRequest={cursor:t,limit:r},!0)}close(){var t;this.disposed=!0,this.subscribed=!1,this.pendingOlderRequest=null,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var l;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const r=(l=br.getState().session)==null?void 0:l.accessToken;if(!r){this.options.onUnauthorized();return}const s=`${_T("/ws")}?access_token=${encodeURIComponent(r)}`,i=new WebSocket(s);this.subscribed=!1,this.socket=i,i.addEventListener("open",()=>{i.send(JSON.stringify({type:"session.subscribe",sessionId:this.options.sessionId,cursor:this.latestCursor,limit:this.options.limit}))}),i.addEventListener("message",c=>{const d=JSON.parse(c.data);if(d.type==="system.connected"){this.connectionManager.markConnected();return}if(d.type==="session.subscribed"){this.subscribed=!0,this.options.onSubscribed(),this.flushPendingOlderRequest();return}if(d.type==="session.error"){if(d.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(d);return}if(d.type==="session.runtime_status"){this.options.onRuntimeStatus(d);return}if(d.type==="session.activity"){this.options.onActivity(d);return}if(d.type==="session.history_older"){this.options.onOlderHistory(d);return}if(d.type==="session.runtime_message"){this.options.onRuntimeMessage(d);return}if(d.type==="session.runtime_error"){this.options.onRuntimeError(d);return}if(d.type==="session.interrupted"){this.options.onInterrupted(d);return}if(d.type==="session.permission_request"){this.options.onPermissionRequest(d);return}if(d.type==="session.permission_request_resolved"){this.options.onPermissionRequestResolved(d);return}this.latestCursor=d.cursor,this.options.onEnvelope(d)}),i.addEventListener("close",()=>{this.disposed||this.socket!==i||(this.subscribed=!1,this.connectionManager.markDisconnected())}),i.addEventListener("error",()=>{this.disposed||this.socket!==i||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0,this.subscribed=!1;const t=this.socket;this.socket=null,t==null||t.close(),br.refresh().then(r=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(r.status==="refreshed"){this.connectionManager.reconnectNow();return}if(r.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendOlderMessagesRequest(t,r){var s;(s=this.socket)==null||s.send(JSON.stringify({type:"session.load_older",sessionId:this.options.sessionId,cursor:t,limit:r}))}flushPendingOlderRequest(){if(!this.pendingOlderRequest)return;const t=this.pendingOlderRequest;this.pendingOlderRequest=null,this.sendOlderMessagesRequest(t.cursor,t.limit)}}function NC(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function Pm(e,t,r="sent",s=null){const i=t.kind??(t.role==="tool"?"tool_result":"text"),l=t.toolCall??(i==="tool_call"||i==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:i==="tool_call"?t.content:"",output:i==="tool_result"&&t.content?t.content:null,error:null,status:i==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:i,content:t.content,toolCall:l,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:r,clientRequestId:s}}function X0(e,t,r,s=[],i=[],l=Number.MAX_SAFE_INTEGER){return{id:`pending-${r}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:s,attachmentPayloads:i,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:l,rawRef:`pending://${r}`,deliveryState:"sending",clientRequestId:r}}function Cc(e,t,r){const s=new Map;for(const i of e)s.set(i.id,i);for(const i of r){const l=Pm(t,i),c=i3(s,l);if(c&&c!==l.id)continue;const d=s3(s,l);d&&d!==l.id&&s.delete(d);const m=s.get(i.messageId)??null;s.set(i.messageId,m?Uq(m,l):l)}return Q0(Array.from(s.values()))}function PC(e,t,r,s){const i=s===null?null:e.find(m=>m.clientRequestId===s)??null,l=e.filter(m=>m.clientRequestId!==s),c=Pm(t,r,"sent",s),d=Wq(c,i);return Q0([...l.filter(m=>m.id!==d.id),d])}function gb(e,t){return e.map(r=>r.clientRequestId===t?{...r,deliveryState:"failed"}:r)}function Iq(e){const t=[];for(const r of e){const s=t.at(-1);if(!s||!J0(s,r)){t.push(r);continue}t[t.length-1]=Gq(s,r)}return t}function Eq(e){const t=[];for(const r of e){if(!zq(r)){t.push(r);continue}let s=t.length-1;for(;s>=0&&qq(t[s]);)s-=1;const i=s>=0?t[s]:null;if(!i||!J0(i,r)){t.push(r);continue}t[s]=Kq(i,r)}return t}function Lq(e){const t=[];let r=null,s=!1;for(const i of e)if(!$q(r,i,s)){if(t.push(i),au(i)){r=i,s=!1;continue}r&&bb(i)&&(s=!0)}return t}function Fq(e){const t=[];for(const r of e){const s=t.at(-1);if(!s||!Z0(s,r)){t.push(r);continue}t[t.length-1]=eR(s,r)}return t}function _q(e){const t=[];for(const r of e){if(t.push(r),t.length<4)continue;const s=t[t.length-4],i=t[t.length-3],l=t[t.length-2],c=t[t.length-1];Vq(s,i,l,c)&&t.splice(t.length-3,3,eR(i,c))}return t}function Oq(e){const t=[];for(const r of e){const s=t.at(-1);if(!s||!Yq(s,r)){t.push(r);continue}t[t.length-1]=Qq(s,r)}return t}function Bq(e){const t=[];for(const r of e){const s=t.findIndex(i=>Xq(i,r));if(s===-1){t.push(r);continue}t[s]=Jq(t[s],r)}return t}function Q0(e){const t=[...e].sort((r,s)=>r.sequence!==s.sequence?r.sequence-s.sequence:r.timestamp.localeCompare(s.timestamp));return Bq(Oq(Lq(_q(Fq(Eq(Iq(t)))))))}function Wq(e,t){if(!t||!Hq(t,e))return e;const r=e.attachments??[];return{...e,sequence:t.sequence,timestamp:t.timestamp,attachments:r.length>0?r:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function Uq(e,t){if(e.id!==t.id)return t;if(e.role!==t.role||e.kind!==t.kind||e.rawRef!==t.rawRef)return ou(e,t);const r=Zq(e.toolCall,t.toolCall),s=t3(e.content,t.content,e.timestamp,t.timestamp),i=n3(e.attachments,t.attachments);return{...ou(e,t),content:s,toolCall:r,attachments:i,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,timestamp:e.timestamp.localeCompare(t.timestamp)>=0?e.timestamp:t.timestamp,sequence:Math.max(e.sequence,t.sequence)}}function Hq(e,t){return Dm(e)&&t.role==="user"&&t.kind==="text"&&e.sequence>t.sequence}function J0(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const r=Ro(e.content),s=Ro(t.content);return Wl(e.timestamp,t.timestamp,30*1e3)&&tr(r.text)===tr(s.text)&&r3(r.inlineImages,s.inlineImages)}function zq(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")&&e.toolCall===null}function qq(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.kind==="tool_call"||e.kind==="tool_result")}function $q(e,t,r){return!e||r||!au(e)||!au(t)?!1:Wl(e.timestamp,t.timestamp,120*1e3)&&tr(e.content)===tr(t.content)}function au(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function bb(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&e.kind==="text"}function Z0(e,t){return bb(e)&&bb(t)&&Wl(e.timestamp,t.timestamp,120*1e3)&&tr(e.content)===tr(t.content)}function Vq(e,t,r,s){return!e||!t||!r||!s||!au(e)||!au(r)?!1:Z0(t,s)&&Wl(e.timestamp,r.timestamp,120*1e3)&&tr(e.content)===tr(r.content)}function eR(e,t){var c,d;const r=((c=e.attachments)==null?void 0:c.length)??0,s=((d=t.attachments)==null?void 0:d.length)??0;if(r!==s)return r>s?e:t;const i=tr(e.content).length,l=tr(t.content).length;return i!==l?i>l?e:t:ou(e,t)}function Gq(e,t){var m,f;const r=((m=e.attachments)==null?void 0:m.length)??0,s=((f=t.attachments)==null?void 0:f.length)??0;if(r!==s)return r>s?e:t;const i=Ro(e.content).inlineImages.length,l=Ro(t.content).inlineImages.length;if(i!==l)return i>l?e:t;const c=e.content!==tr(e.content),d=t.content!==tr(t.content);return c!==d?c?t:e:t}function Kq(e,t){var m,f;const r=((m=e.attachments)==null?void 0:m.length)??0,s=((f=t.attachments)==null?void 0:f.length)??0;if(r!==s)return r>s?e:t;const i=Ro(e.content).inlineImages.length,l=Ro(t.content).inlineImages.length;if(i!==l)return i>l?e:t;const c=e.content!==tr(e.content),d=t.content!==tr(t.content);return c!==d&&c?t:e}function Yq(e,t){return!DC(e)||!DC(t)?!1:e.role===t.role&&Wl(e.timestamp,t.timestamp,120*1e3)&&tr(e.content)===tr(t.content)}function Xq(e,t){return!RC(e)||!RC(t)?!1:e.role===t.role&&Wl(e.timestamp,t.timestamp,120*1e3)&&tr(e.content)===tr(t.content)}function DC(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function RC(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Qq(e,t){var m,f;const r=((m=e.attachments)==null?void 0:m.length)??0,s=((f=t.attachments)==null?void 0:f.length)??0;if(r!==s)return r>s?e:t;const i=tr(e.content).length,l=tr(t.content).length;if(i!==l)return i>l?e:t;const c=e.rawRef.includes("#file="),d=t.rawRef.includes("#file=");return c!==d?c?e:t:ou(e,t)}function Jq(e,t){var m,f;const r=((m=e.attachments)==null?void 0:m.length)??0,s=((f=t.attachments)==null?void 0:f.length)??0;if(r!==s)return r>s?e:t;const i=tr(e.content).length,l=tr(t.content).length;if(i!==l)return i>l?e:t;const c=e.rawRef.includes("/context#"),d=t.rawRef.includes("/context#");return c!==d?c?e:t:ou(e,t)}function Zq(e,t){return e?t?{...e3(e,t),input:tR(e.input,t.input),output:AC(e.output,t.output),error:AC(e.error,t.error)}:e:t}function e3(e,t){const r=MC(e.status),s=MC(t.status);return s!==r?s>r?t:e:t}function MC(e){return e==="running"?0:1}function t3(e,t,r,s){const i=tr(e),l=tr(t);return i===l?e.length>=t.length?e:t:i.length>l.length&&i.includes(l)?e:l.length>i.length&&l.includes(i)||s.localeCompare(r)>=0?t:e}function n3(e,t){const r=(e==null?void 0:e.length)??0,s=(t==null?void 0:t.length)??0;return s!==r?s>r?t:e:t??e}function tR(e,t){return t.length>e.length?t:e}function AC(e,t){return e===null?t:t===null?e:tR(e,t)}function ou(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function tr(e){return e.replace(/\r\n/g,`
|
|
113
|
+
`).trimEnd()}function r3(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((r,s)=>{var i;return r.url===((i=t[s])==null?void 0:i.url)})}function s3(e,t){return rR(t)?nR(e,t,"optimistic"):null}function i3(e,t){return Dm(t)?nR(e,t,"authoritative"):null}function nR(e,t,r){const s=Jh(t.timestamp),i=tr(t.content);let l=null,c=Number.POSITIVE_INFINITY;for(const[d,m]of e.entries()){if(!(r==="optimistic"?Dm(m):rR(m))||tr(m.content)!==i)continue;const v=Jh(m.timestamp),g=Math.abs(v-s);g>300*1e3||g<c&&(l=d,c=g)}return l}function Dm(e){return e.role!=="user"||e.kind!=="text"||e.deliveryState==="failed"?!1:e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic")}function rR(e){return e.role==="user"&&e.kind==="text"&&!Dm(e)}function Jh(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function a3(e){return e.reduce((r,s)=>Number.isFinite(s.sequence)&&s.sequence>r?s.sequence:r,0)+1}function Wl(e,t,r){return Math.abs(Jh(e)-Jh(t))<=r}const IC=60,o3=400,sR="butler-diagnostic://";class iR{constructor(t){ot(this,"state");ot(this,"listeners",new Set);ot(this,"realtimeClient",null);ot(this,"realtimeSessionId",null);ot(this,"selectedControlSessionId",null);ot(this,"controlSessionReloadInFlight",!1);ot(this,"terminalSyncTimer",null);ot(this,"terminalSyncArmed",!1);ot(this,"terminalSyncCompletedControlSessionId",null);ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);this.workspaceId=t,this.state={loading:!0,sending:!1,switchingProvider:!1,initialized:!1,profile:null,activeProvider:"codex",controlSession:null,capabilities:wl("codex"),overview:null,events:[],messages:[],historyState:"idle",runtimeHasActiveRun:null,runtimeCanInterrupt:null,contextUsage:null,error:null}}async initialize(){this.patch({loading:!0,error:null});try{const t=await mm();if(!t.initialized||!t.profile){this.patch({loading:!1,initialized:!1,profile:null,activeProvider:"codex",capabilities:wl("codex"),controlSession:null,messages:[],historyState:"idle",overview:null,events:[],runtimeHasActiveRun:null,runtimeCanInterrupt:null,contextUsage:null});return}const r=t.profile;this.patch({initialized:!0,profile:r,activeProvider:r.providerId,capabilities:wl(r.providerId)}),await this.reloadForProvider(r.providerId),this.patch({loading:!1})}catch(t){this.patch({loading:!1,error:Ei(t)})}}async initializeProfile(t){this.patch({loading:!0,error:null});try{const r=await G_(t);if(!r.initialized||!r.profile)throw new Error("BUTLER_PROFILE_INIT_FAILED");this.patch({initialized:!0,profile:r.profile,activeProvider:r.profile.providerId,capabilities:wl(r.profile.providerId)}),await this.reloadForProvider(r.profile.providerId)}catch(r){throw this.patch({error:Ei(r)}),r}finally{this.patch({loading:!1})}}async switchProvider(t){if(!this.state.initialized||!this.state.profile||this.state.activeProvider===t)return;const r={activeProvider:this.state.activeProvider,profile:this.state.profile,controlSession:this.state.controlSession,capabilities:this.state.capabilities,overview:this.state.overview,events:this.state.events,messages:this.state.messages,historyState:this.state.historyState,runtimeHasActiveRun:this.state.runtimeHasActiveRun,runtimeCanInterrupt:this.state.runtimeCanInterrupt,contextUsage:this.state.contextUsage};this.patch({switchingProvider:!0,error:null,activeProvider:t,controlSession:null,messages:[],historyState:"idle",overview:null,events:[],runtimeHasActiveRun:null,runtimeCanInterrupt:null,contextUsage:null,capabilities:wl(t)});try{const s=await Ix({providerId:t});if(!s.initialized||!s.profile)throw new Error("BUTLER_PROFILE_UPDATE_FAILED");this.patch({initialized:!0,profile:s.profile,activeProvider:s.profile.providerId}),await Promise.all([this.refreshCapabilities(s.profile.providerId),this.refreshOverview(),this.refreshEvents()]),await this.startFreshSession({preserveSwitchingState:!0})}catch(s){throw this.patch({...r,error:Ei(s)}),s}finally{this.patch({switchingProvider:!1})}}async updateProfile(t){if(!(!this.state.initialized||!this.state.profile)){this.patch({loading:!0,error:null});try{const r=await Ix(t);if(!r.initialized||!r.profile)throw new Error("BUTLER_PROFILE_UPDATE_FAILED");this.patch({initialized:!0,profile:r.profile,activeProvider:r.profile.providerId})}catch(r){throw this.patch({error:Ei(r)}),r}finally{this.patch({loading:!1})}}}async sendMessage(t,r){const s=t.trim();if(!(!s||!this.state.initialized)){this.patch({sending:!0,error:null});try{const i=this.state.controlSession;if(i){const l=await J_({controlSessionId:i.id,content:s,model:(r==null?void 0:r.model)??null,reasoningLevel:(r==null?void 0:r.reasoningLevel)??null,permissionMode:(r==null?void 0:r.permissionMode)??null});this.selectedControlSessionId=l.controlSession.id,this.patch({controlSession:l.controlSession})}else{const l=await Q_({content:s,model:(r==null?void 0:r.model)??null,reasoningLevel:(r==null?void 0:r.reasoningLevel)??null,permissionMode:(r==null?void 0:r.permissionMode)??null});this.selectedControlSessionId=l.controlSession.id,this.patch({controlSession:l.controlSession})}await this.reloadControlSession(this.selectedControlSessionId),await Promise.all([this.refreshOverview(),this.refreshEvents()])}catch(i){throw this.patch({error:Ei(i)}),i}finally{this.patch({sending:!1})}}}async retryMessage(t){const r=this.state.messages.find(s=>s.clientRequestId===t);!r||!r.content.trim()||await this.sendMessage(r.content)}async interrupt(){var r;const t=((r=this.state.controlSession)==null?void 0:r.session.sessionId)??null;t&&(await dP(t),this.patch({runtimeHasActiveRun:!1,runtimeCanInterrupt:!1}))}async startFreshSession(t){if(this.state.initialized){this.teardownRealtime(),this.selectedControlSessionId=null,this.terminalSyncArmed=!1,this.terminalSyncCompletedControlSessionId=null,this.patch({sending:!1,error:null,controlSession:null,messages:[],historyState:"ready",runtimeHasActiveRun:null,runtimeCanInterrupt:null,contextUsage:null});try{await X_()}catch(r){throw this.patch({historyState:"error",error:Ei(r)}),r}this.patch({switchingProvider:t!=null&&t.preserveSwitchingState?this.state.switchingProvider:!1})}}async refreshAll(){if(this.state.initialized){this.patch({loading:!0,error:null});try{await this.reloadForProvider(this.state.activeProvider)}finally{this.patch({loading:!1})}}}async reloadEventsAndOverview(){this.state.initialized&&await Promise.all([this.refreshOverview(),this.refreshEvents()])}async reloadForProvider(t){Ot("butler.runtime.reload_for_provider.start",{workspaceId:this.workspaceId,providerId:t,selectedControlSessionId:this.selectedControlSessionId}),await Promise.all([this.refreshCapabilities(t),this.refreshOverview(),this.refreshEvents()]),await this.reloadControlSession(this.selectedControlSessionId),Ot("butler.runtime.reload_for_provider.end",{workspaceId:this.workspaceId,providerId:t,selectedControlSessionId:this.selectedControlSessionId})}async openControlSession(t){this.selectedControlSessionId=t.trim()||null,await this.reloadControlSession(this.selectedControlSessionId)}async adoptControlSession(t){this.selectedControlSessionId=t.id,this.patch({controlSession:t}),await this.reloadControlSession(t.id)}async reloadControlSession(t){var i,l,c,d;const r=((i=this.state.controlSession)==null?void 0:i.id)??null,s=this.state.historyState==="ready"&&r!==null&&(t==null||t===r);Ot("butler.runtime.reload_control_session.start",{workspaceId:this.workspaceId,requestedControlSessionId:t??null,currentControlSessionId:r,currentSessionId:((c=(l=this.state.controlSession)==null?void 0:l.session)==null?void 0:c.sessionId)??null,currentMessages:this.state.messages.length,currentHistoryState:this.state.historyState,backgroundReload:s}),s||this.patch({historyState:"loading"});try{const f=(t?await Y_(t):await K_()).controlSession;if(!f){this.selectedControlSessionId=null,this.terminalSyncArmed=!1,this.terminalSyncCompletedControlSessionId=null,this.teardownRealtime(),this.patch({controlSession:null,messages:[],historyState:"ready",runtimeHasActiveRun:null,runtimeCanInterrupt:null,contextUsage:null}),Ot("butler.runtime.reload_control_session.empty",{workspaceId:this.workspaceId,requestedControlSessionId:t??null});return}this.selectedControlSessionId=f.id;const[v,g]=await Promise.all([kv(f.session.sessionId,null,IC,"forward"),Kg(f.session.sessionId)]);((d=this.state.controlSession)==null?void 0:d.id)!==f.id&&(this.terminalSyncCompletedControlSessionId=null),this.terminalSyncArmed=g.hasActiveRun||f.status==="running",g.hasActiveRun?this.terminalSyncCompletedControlSessionId=null:this.terminalSyncArmed||(this.terminalSyncCompletedControlSessionId=f.id);const w=v.messages.map(k=>Pm(f.session.sessionId,k));this.ensureRealtimeSubscription(f.session.sessionId,v.cursor),this.patch({controlSession:f,messages:LC(w,f,{runningState:g.runningState,runtimeHasActiveRun:g.hasActiveRun,runtimeCanInterrupt:g.canInterrupt,detail:g.detail,errorDetail:g.errorDetail,updatedAt:g.updatedAt}),historyState:"ready",runtimeHasActiveRun:g.hasActiveRun,runtimeCanInterrupt:g.canInterrupt,contextUsage:g.contextUsage}),Ot("butler.runtime.reload_control_session.end",{workspaceId:this.workspaceId,controlSessionId:f.id,sessionId:f.session.sessionId,messages:w.length,historyState:"ready",hasActiveRun:g.hasActiveRun,canInterrupt:g.canInterrupt,terminalSyncArmed:this.terminalSyncArmed,terminalSyncCompletedControlSessionId:this.terminalSyncCompletedControlSessionId})}catch(m){this.patch({historyState:"error",error:Ei(m)}),Ot("butler.runtime.reload_control_session.error",{workspaceId:this.workspaceId,requestedControlSessionId:t??null,message:Ei(m)})}}async refreshCapabilities(t){try{const r=await _l(t,this.workspaceId);this.patch({capabilities:r})}catch{this.patch({capabilities:wl(t)})}}async refreshOverview(){try{const t=await pm();this.patch({overview:t.overview})}catch(t){this.patch({error:Ei(t)})}}async refreshEvents(){try{const t=await Z_();this.patch({events:t.items})}catch(t){this.patch({error:Ei(t)})}}patch(t){this.state={...this.state,...t},this.emit()}emit(){for(const t of this.listeners)t()}ensureRealtimeSubscription(t,r){if(this.realtimeClient&&this.realtimeSessionId===t){this.realtimeClient.updateCursor(r),Ot("butler.runtime.realtime.reuse",{workspaceId:this.workspaceId,sessionId:t,cursor:r});return}this.teardownRealtime(),this.realtimeSessionId=t,Ot("butler.runtime.realtime.subscribe",{workspaceId:this.workspaceId,sessionId:t,cursor:r}),this.realtimeClient=new Y0({sessionId:t,cursor:r,limit:IC,onConnectionChange:()=>{},onSubscribed:()=>{},onEnvelope:s=>{this.handleRealtimeMessages(s.sessionId,s.messages)},onOlderHistory:s=>{this.handleRealtimeMessages(s.sessionId,s.messages)},onRuntimeMessage:s=>{this.handleRealtimeRuntimeMessage(s)},onActivity:s=>{this.handleRealtimeActivity(s)},onRuntimeStatus:s=>{this.handleRealtimeStatus(s)},onRuntimeError:s=>{this.handleRealtimeRuntimeError(s)},onInterrupted:s=>{this.handleRealtimeInterrupted(s)},onPermissionRequest:()=>{},onPermissionRequestResolved:()=>{},onError:s=>{this.isActiveControlSession(s.sessionId??null)&&this.patch({error:s.detail})},onUnauthorized:()=>{this.patch({error:o("common.unauthorized")})}}),this.realtimeClient.start()}teardownRealtime(){var t;this.clearTerminalSyncTimer(),this.realtimeSessionId&&Ot("butler.runtime.realtime.teardown",{workspaceId:this.workspaceId,sessionId:this.realtimeSessionId}),(t=this.realtimeClient)==null||t.close(),this.realtimeClient=null,this.realtimeSessionId=null}clearTerminalSyncTimer(){this.terminalSyncTimer!==null&&(window.clearTimeout(this.terminalSyncTimer),this.terminalSyncTimer=null)}scheduleTerminalSessionSync(t,r){var s;this.clearTerminalSyncTimer(),Ot("butler.runtime.terminal_sync.scheduled",{workspaceId:this.workspaceId,controlSessionId:((s=this.state.controlSession)==null?void 0:s.id)??null,reason:t,...r}),this.terminalSyncTimer=window.setTimeout(()=>{var i,l,c;if(this.terminalSyncTimer=null,this.controlSessionReloadInFlight){Ot("butler.runtime.terminal_sync.skipped_inflight",{workspaceId:this.workspaceId,controlSessionId:((i=this.state.controlSession)==null?void 0:i.id)??null,reason:t,...r});return}this.controlSessionReloadInFlight=!0,this.terminalSyncCompletedControlSessionId=((l=this.state.controlSession)==null?void 0:l.id)??null,Ot("butler.runtime.terminal_sync.start",{workspaceId:this.workspaceId,controlSessionId:((c=this.state.controlSession)==null?void 0:c.id)??null,reason:t,...r}),this.reloadControlSession().finally(()=>{var d;this.controlSessionReloadInFlight=!1,Ot("butler.runtime.terminal_sync.end",{workspaceId:this.workspaceId,controlSessionId:((d=this.state.controlSession)==null?void 0:d.id)??null,reason:t,...r})})},o3)}handleRealtimeMessages(t,r){var i,l,c;if(!this.isActiveControlSession(t)){Ot("butler.runtime.realtime.messages.ignored",{workspaceId:this.workspaceId,sessionId:t,incoming:r.length,activeSessionId:((i=this.state.controlSession)==null?void 0:i.session.sessionId)??null});return}const s=l3(this.state.messages,t,r);this.patch({messages:LC(s,this.state.controlSession,{runningState:((l=this.state.controlSession)==null?void 0:l.session.runningState)??"idle",runtimeHasActiveRun:this.state.runtimeHasActiveRun??!1,runtimeCanInterrupt:this.state.runtimeCanInterrupt??!1,detail:null,errorDetail:this.state.error,updatedAt:((c=this.state.controlSession)==null?void 0:c.updatedAt)??new Date().toISOString()}),historyState:"ready"}),Ot("butler.runtime.realtime.messages",{workspaceId:this.workspaceId,sessionId:t,incoming:r.length,messages:s.length})}handleRealtimeRuntimeMessage(t){this.handleRealtimeMessages(t.sessionId,[t.message])}handleRealtimeActivity(t){var i;if(!this.isActiveControlSession(t.sessionId))return;t.hasActiveRun&&(this.terminalSyncArmed=!0,this.terminalSyncCompletedControlSessionId=null);const r=((i=this.state.controlSession)==null?void 0:i.id)??null,s=!t.hasActiveRun&&this.terminalSyncArmed&&r!==null&&this.terminalSyncCompletedControlSessionId!==r;Ot("butler.runtime.realtime.activity",{workspaceId:this.workspaceId,sessionId:t.sessionId,hasActiveRun:t.hasActiveRun,canInterrupt:t.canInterrupt,updatedAt:t.updatedAt,shouldSyncTerminalState:s,terminalSyncArmed:this.terminalSyncArmed,terminalSyncCompletedControlSessionId:this.terminalSyncCompletedControlSessionId}),this.patch({runtimeHasActiveRun:t.hasActiveRun,runtimeCanInterrupt:t.canInterrupt}),s&&this.scheduleTerminalSessionSync("activity_terminal",{sessionId:t.sessionId,updatedAt:t.updatedAt})}handleRealtimeStatus(t){var c;if(!this.isActiveControlSession(t.sessionId))return;const r=t.status==="starting"||t.status==="running";r&&(this.terminalSyncArmed=!0,this.terminalSyncCompletedControlSessionId=null);const s=t.status==="completed"||t.status==="failed"||t.status==="interrupted",i=((c=this.state.controlSession)==null?void 0:c.id)??null,l=s&&!r&&this.terminalSyncArmed&&i!==null&&this.terminalSyncCompletedControlSessionId!==i;Ot("butler.runtime.realtime.status",{workspaceId:this.workspaceId,sessionId:t.sessionId,status:t.status,timestamp:t.timestamp,shouldSyncTerminalState:l,terminalSyncArmed:this.terminalSyncArmed,terminalSyncCompletedControlSessionId:this.terminalSyncCompletedControlSessionId}),this.patch({runtimeHasActiveRun:r,runtimeCanInterrupt:r?!0:this.state.runtimeCanInterrupt}),l&&this.scheduleTerminalSessionSync("status_terminal",{sessionId:t.sessionId,status:t.status,timestamp:t.timestamp})}handleRealtimeRuntimeError(t){this.isActiveControlSession(t.sessionId)&&(Ot("butler.runtime.realtime.error",{workspaceId:this.workspaceId,sessionId:t.sessionId,detail:t.detail,errorCode:t.error_code}),this.patch({error:t.detail,runtimeHasActiveRun:!1}),this.reloadControlSession())}handleRealtimeInterrupted(t){this.isActiveControlSession(t.sessionId)&&(Ot("butler.runtime.realtime.interrupted",{workspaceId:this.workspaceId,sessionId:t.sessionId,detail:t.detail}),this.patch({runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,error:t.detail}),this.reloadControlSession())}isActiveControlSession(t){var r;return!!(t&&((r=this.state.controlSession)==null?void 0:r.session.sessionId)===t)}}function Kn(e,t){const[r,s]=p.useState(()=>t(e.getState()));return p.useEffect(()=>(s(t(e.getState())),e.subscribe(()=>{s(t(e.getState()))})),[t,e]),r}function wl(e){const t=[{id:"provider-default",name:o("conversation.modelUseCliDefault"),usesProviderDefault:!0}];return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:e==="claude-code"?"streaming_guidance":"none",supportsSubagents:!1,supportsInterrupt:!0,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:!1,supportsPermissionPrompt:!0,supportsCheckpoint:!1,supportsQueueWhileRunning:!1,supportsRunSteering:!1,supportsSlashMenu:!1,supportsReasoningSelector:!0,modelOptions:t,defaultReasoningLevel:null,limitations:[]}}function l3(e,t,r){const s=new Map;for(const i of e.filter(l=>!aR(l)))s.set(EC(i),i);for(const i of r){const l=Pm(t,i);s.set(EC(l),l)}return[...s.values()].sort((i,l)=>i.sequence!==l.sequence?i.sequence-l.sequence:i.timestamp.localeCompare(l.timestamp))}function EC(e){return e.id||e.rawRef}function LC(e,t,r){const s=e.filter(l=>!aR(l));if(s.length>0||!t)return s;const i=c3(t,r);return i?[...s,u3(t,i,r.updatedAt)]:s}function c3(e,t){var d,m,f;if(t.runtimeHasActiveRun)return null;const r=t.runningState,s=e.status==="failed"||r==="failed";if(!(s||r==="completed"||r==="interrupted"||r==="idle"&&e.status!=="running"))return null;const l=((d=e.lastSummary)==null?void 0:d.trim())||((m=t.errorDetail)==null?void 0:m.trim())||((f=t.detail)==null?void 0:f.trim())||null,c=[s?"本轮助手会话已结束,但没有收到可展示的助手消息。":"本轮助手会话已结束,但 provider 没有返回可展示的助手消息。"];return l&&(c.push(""),c.push(`诊断信息:${l}`)),c.join(`
|
|
114
|
+
`)}function u3(e,t,r){const s=Number.isFinite(e.session.messageCount)?e.session.messageCount:0;return{id:`butler-diagnostic-${e.id}`,sessionId:e.session.sessionId,role:"system",kind:"text",content:t,toolCall:null,attachments:[],attachmentPayloads:null,origin:"system",originRef:e.id,timestamp:r??e.updatedAt,sequence:s+1,rawRef:`${sR}${e.id}`,deliveryState:"sent",clientRequestId:null}}function aR(e){return e.rawRef.startsWith(sR)}function Ei(e){return e instanceof Error?e.message:String(e)}const vb={"risk-first":["risk","blocker","verification"],"blocker-first":["blocker","risk","verification"],"verification-first":["verification","risk","blocker"],"progress-first":["progress","risk","blocker"]},oR=300,d3={displayName:"",providerId:"codex",agentsMode:"inline",personaTone:"direct",personaLanguage:"zh-CN",personaSummaryStyle:"brief",focusRiskPreference:"conservative",reportPriorityPreset:"risk-first"},Gf={displayName:"",agentsMode:"inline",agentsFilePath:"",agentsContent:"",personaTone:"direct",personaLanguage:"zh-CN",personaSummaryStyle:"brief",focusRiskPreference:"conservative",reportPriorityPreset:"risk-first",summaryDebounceSeconds:oR},h3=[{value:60,labelKey:"shell.butlerSummaryDebounceOption1Minute"},{value:180,labelKey:"shell.butlerSummaryDebounceOption3Minutes"},{value:300,labelKey:"shell.butlerSummaryDebounceOption5Minutes"},{value:600,labelKey:"shell.butlerSummaryDebounceOption10Minutes"},{value:900,labelKey:"shell.butlerSummaryDebounceOption15Minutes"},{value:1800,labelKey:"shell.butlerSummaryDebounceOption30Minutes"}],ia={builder:["🧠","🤖","🦾","🛠️","⚙️","🧩","🚀","🛰️","🔧","💡"],analyst:["🦉","🧭","🔍","📚","🧪","📐","🗂️","📝","🧮","📊"],direct:["🦅","🛡️","⚡","🎯","🪓","🧱","🔨","📌","🧰","🏹"],steady:["🐢","🐘","🦬","🦫","🌲","⛰️","🪨","🧺","🧷","🕰️"],friendly:["🐼","🦊","🐻","🐶","🐱","🐹","🐰","🦄","🌼","🍀"],default:["🧠","🤖","🦉","🧩","📚","💡","🛠️","🚀","🌟","🪄","🧭","🔮"]};function m3(e){if(typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function p3(e){var t;if(typeof navigator<"u"&&((t=navigator.clipboard)!=null&&t.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!m3(e))throw new Error(o("conversation.copyContentFailed"))}function f3(){var Ke,at,ft,ct;const{workspaceId:e=""}=Eo(),t=vr(),{showToast:r}=Qn(),{requestNavigationRefresh:s,setAuxiliaryPanel:i}=Pr(),l=p.useRef(null),c=p.useRef(null),[d,m]=p.useState(d3),[f,v]=p.useState(!1),[g,w]=p.useState(Gf),[k,y]=p.useState(!1),[C,T]=p.useState(0),[j,N]=p.useState([]),[D,F]=p.useState([]),[W,E]=p.useState([]),[I,M]=p.useState([]),[_,L]=p.useState(!1),[Q,O]=p.useState(!1),[ne,Y]=p.useState(!1),[G,te]=p.useState(null),[K,z]=p.useState(null),[q,P]=p.useState(!1),[U,X]=p.useState(null),[R,Se]=p.useState({itemId:null,kind:null});(!l.current||c.current!==e)&&(l.current=new iR(e),c.current=e);const se=l.current,J=Kn(se,oe=>oe.loading),Ne=Kn(se,oe=>oe.sending),Ee=Kn(se,oe=>oe.switchingProvider),ie=Kn(se,oe=>oe.initialized),xe=Kn(se,oe=>oe.profile),lt=Kn(se,oe=>oe.activeProvider),Oe=Kn(se,oe=>oe.controlSession),bt=Kn(se,oe=>oe.capabilities),Ct=Kn(se,oe=>oe.overview),nt=Kn(se,oe=>oe.events),et=Kn(se,oe=>oe.messages),De=Kn(se,oe=>oe.historyState),Ue=Kn(se,oe=>oe.runtimeHasActiveRun),Ye=Kn(se,oe=>oe.runtimeCanInterrupt),ye=Kn(se,oe=>oe.contextUsage),He=Kn(se,oe=>oe.error),je=p.useRef(null),Fe=((Ke=xe==null?void 0:xe.displayName)==null?void 0:Ke.trim())||d.displayName.trim()||o("shell.butlerEntry"),Ve=p.useMemo(()=>H3({displayName:Fe,providerId:(xe==null?void 0:xe.providerId)??d.providerId,tone:(xe==null?void 0:xe.persona.tone)??d.personaTone}),[Fe,d.personaTone,d.providerId,xe==null?void 0:xe.persona.tone,xe==null?void 0:xe.providerId]),kt=p.useMemo(()=>D.filter(oe=>cR(oe.status)).slice(0,3),[D]),me=p.useMemo(()=>((Ct==null?void 0:Ct.projects)??[]).map(oe=>oe.id).sort(),[Ct==null?void 0:Ct.projects]),Me=p.useCallback(async()=>{if(!ie){M([]);return}try{const oe=await Yg();M(oe.items)}catch(oe){r({title:o("shell.butlerSidebarLoadFailed"),description:oe instanceof Error?oe.message:void 0,tone:"error"})}},[ie,r]),Xe=p.useCallback(()=>{O(!0)},[]),ze=p.useCallback(()=>{Y(!0),Me()},[Me]),vt=p.useCallback(oe=>{w(Re=>({...Re,...oe}))},[]),ht=p.useCallback(async oe=>{O(!1),te(oe),z(null),X(null),P(!0);try{const Re=await LP(oe);z(Re.task)}catch(Re){X(Re instanceof Error?Re.message:o("shell.butlerAutomationRoundLoadFailed"))}finally{P(!1)}},[]),pe=p.useCallback(async oe=>{Se({itemId:oe.id,kind:"analyze"});try{const Re=await sO(oe.id);N(_t=>FC(_t,Re.item)),M(_t=>I3(_t,Re.controlSession)),await se.adoptControlSession(Re.controlSession),r({title:o("shell.butlerTodoAnalyzeQueued"),tone:"success"})}catch(Re){r({title:o("shell.butlerTodoAnalyzeFailed"),description:Re instanceof Error?Re.message:void 0,tone:"error"})}finally{Se({itemId:null,kind:null})}},[r]),$e=p.useCallback(async oe=>{Se({itemId:oe.id,kind:"start"});try{const Re=await iO(oe.id);N(_t=>FC(_t,Re.item)),Re.followUpTask&&F(_t=>A3(_t,Re.followUpTask)),s(),r({title:o("shell.butlerTodoStartSessionSucceeded"),tone:"success"}),t(Yn(Re.item.workspaceId,Re.session.sessionId))}catch(Re){r({title:o("shell.butlerTodoStartSessionFailed"),description:Re instanceof Error?Re.message:void 0,tone:"error"})}finally{Se({itemId:null,kind:null})}},[t,s,r]),Nt=p.useCallback(oe=>{var _t;const Re=(_t=oe.assistantState.linkedSessionId)==null?void 0:_t.trim();Re&&t(Yn(oe.workspaceId,Re))},[t]),Rt=p.useCallback(async oe=>{var _t;const Re=(_t=oe.assistantState.generatedPrompt)==null?void 0:_t.trim();if(Re)try{await p3(Re),r({title:o("shell.butlerTodoCopyPromptSucceeded"),tone:"success"})}catch(Ut){r({title:Ut instanceof Error?Ut.message:o("conversation.copyContentFailed"),tone:"error"})}},[r]),Ft=p.useCallback(async()=>{if(xe){if(!g.displayName.trim()){r({title:o("shell.butlerInitNameRequired"),tone:"warning"});return}y(!0);try{await se.updateProfile({displayName:g.displayName.trim(),agentsMode:g.agentsMode,agentsFilePath:g.agentsMode==="file"?g.agentsFilePath:null,agentsContent:g.agentsContent,persona:{tone:g.personaTone,language:g.personaLanguage,summaryStyle:g.personaSummaryStyle},focus:{...xe.focus,riskPreference:g.focusRiskPreference,reportPriority:vb[g.reportPriorityPreset],summaryDebounceSeconds:g.summaryDebounceSeconds}}),r({title:o("shell.butlerSettingsSaved"),tone:"success"})}catch(oe){r({title:o("shell.butlerSettingsSaveFailed"),description:oe instanceof Error?oe.message:void 0,tone:"error"})}finally{y(!1)}}},[xe,g,r,se]);p.useEffect(()=>{se.initialize()},[se]),p.useEffect(()=>{var Re,_t;const oe=JSON.stringify({workspaceId:e,activeProvider:lt,controlSessionId:(Oe==null?void 0:Oe.id)??null,sessionId:((Re=Oe==null?void 0:Oe.session)==null?void 0:Re.sessionId)??null,messages:et.length,historyState:De,runtimeHasActiveRun:Ue,runtimeCanInterrupt:Ye,loading:J,sending:Ne,switchingProvider:Ee,error:He});je.current!==oe&&(je.current=oe,Ot("butler.page.timeline_state",{workspaceId:e,activeProvider:lt,controlSessionId:(Oe==null?void 0:Oe.id)??null,sessionId:((_t=Oe==null?void 0:Oe.session)==null?void 0:_t.sessionId)??null,messages:et.length,historyState:De,runtimeHasActiveRun:Ue,runtimeCanInterrupt:Ye,loading:J,sending:Ne,switchingProvider:Ee,error:He??null}))},[e,lt,Oe==null?void 0:Oe.id,(at=Oe==null?void 0:Oe.session)==null?void 0:at.sessionId,et.length,De,Ue,Ye,J,Ne,Ee,He]),p.useEffect(()=>{He&&r({title:o("shell.butlerLoadFailed"),description:He,tone:"error"})},[He,r]),p.useEffect(()=>{if(!xe){w(Gf);return}w({displayName:xe.displayName,agentsMode:xe.agentsMode,agentsFilePath:O3(xe),agentsContent:xe.agentsContent,personaTone:xe.persona.tone,personaLanguage:xe.persona.language,personaSummaryStyle:xe.persona.summaryStyle,focusRiskPreference:xe.focus.riskPreference,reportPriorityPreset:_3(xe.focus.reportPriority),summaryDebounceSeconds:xe.focus.summaryDebounceSeconds??Gf.summaryDebounceSeconds})},[xe]),p.useEffect(()=>{if(!ie){N([]),F([]),E([]),M([]);return}let oe=!1;async function Re(){try{const[Qt,ln,jn,Jn]=await Promise.all([Nu(),fm(),Yg(),Promise.all(me.map(bn=>EP(bn)))]);oe||(N(Qt.items),F(ln.items),M(jn.items),E(Jn.flatMap(bn=>bn.items)))}catch(Qt){if(oe)return;N([]),F([]),E([]),M([]),r({title:o("shell.butlerSidebarLoadFailed"),description:Qt instanceof Error?Qt.message:void 0,tone:"error"})}}Re();function _t(){Re()}const Ut=window.setInterval(()=>{Re()},15e3);return window.addEventListener(Po,_t),()=>{oe=!0,window.clearInterval(Ut),window.removeEventListener(Po,_t)}},[ie,me,r]),p.useEffect(()=>Zv(()=>{se.reloadEventsAndOverview()}),[se]);const Wt=p.useMemo(()=>[{value:"codex",label:"Codex"}],[]),Kt=p.useMemo(()=>[{value:"inline",label:o("shell.butlerAgentsModeInline")},{value:"file",label:o("shell.butlerAgentsModeFile")}],[]),un=p.useMemo(()=>[{value:"direct",label:o("shell.butlerToneDirect")},{value:"steady",label:o("shell.butlerToneSteady")},{value:"friendly",label:o("shell.butlerToneFriendly")}],[]),ae=p.useMemo(()=>[{value:"zh-CN",label:o("shell.butlerLanguageZhCn")},{value:"en-US",label:o("shell.butlerLanguageEnUs")},{value:"bilingual",label:o("shell.butlerLanguageBilingual")}],[]),Be=p.useMemo(()=>[{value:"brief",label:o("shell.butlerSummaryBrief")},{value:"structured",label:o("shell.butlerSummaryStructured")},{value:"thorough",label:o("shell.butlerSummaryThorough")}],[]),It=p.useMemo(()=>[{value:"conservative",label:o("shell.butlerRiskConservative")},{value:"balanced",label:o("shell.butlerRiskBalanced")},{value:"proactive",label:o("shell.butlerRiskProactive")}],[]),jt=p.useMemo(()=>[{value:"risk-first",label:o("shell.butlerReportRiskFirst")},{value:"blocker-first",label:o("shell.butlerReportBlockerFirst")},{value:"verification-first",label:o("shell.butlerReportVerificationFirst")},{value:"progress-first",label:o("shell.butlerReportProgressFirst")}],[]),Cn=Ma(Wt,d.providerId),on=Ma(Kt,d.agentsMode),Wn=Ma(un,d.personaTone),Rn=Ma(ae,d.personaLanguage),$t=Ma(Be,d.personaSummaryStyle),dn=Ma(It,d.focusRiskPreference),gn=Ma(jt,d.reportPriorityPreset),Z=d.agentsMode==="inline"?o("shell.butlerAgentsModeInlineDescription"):o("shell.butlerAgentsModeFileDescription"),ce=[on,Rn,dn],ge=p.useMemo(()=>n.jsx(g3,{overview:Ct,events:nt,inboxItems:j,followUpTasks:D,patrolPlans:W,settingsForm:g,savingSettings:k,onOpenFollowUpHistory:Xe,onOpenFollowUpDetail:ht,onAnalyzeTodo:pe,onStartTodoSession:$e,onOpenTodoSession:Nt,onCopyTodoPrompt:Rt,todoActionState:R,onSettingsFormChange:vt,onSaveSettings:()=>{Ft()}}),[nt,pe,Rt,Xe,D,ht,Nt,Ft,vt,$e,j,Ct,W,k,g,R]);p.useEffect(()=>{if(!ie){i(null);return}return i(ge),()=>{i(null)}},[ie,i,ge]);async function Ce(oe){oe.preventDefault();const Re=d.displayName.trim();if(!Re){r({title:o("shell.butlerInitNameRequired"),tone:"warning"});return}const _t={displayName:Re,providerId:d.providerId,agentsMode:d.agentsMode,persona:{tone:d.personaTone,language:d.personaLanguage,summaryStyle:d.personaSummaryStyle},focus:{projectIds:[],riskPreference:d.focusRiskPreference,reportPriority:vb[d.reportPriorityPreset],summaryDebounceSeconds:oR}};v(!0);try{await se.initializeProfile(_t),r({title:o("shell.butlerInitSuccess"),tone:"success"})}catch(Ut){r({title:o("shell.butlerInitFailed"),description:Ut instanceof Error?Ut.message:void 0,tone:"error"})}finally{v(!1)}}async function We(oe){if(oe!==lt)try{await se.switchProvider(oe),Pt(oe),r({title:o("shell.butlerProviderSwitched"),description:o("shell.butlerProviderSwitchedDescription",{provider:Ma(Wt,oe)}),tone:"success"})}catch(Re){r({title:o("shell.butlerProviderSwitchFailed"),description:Re instanceof Error?Re.message:void 0,tone:"error"})}}async function qe(){try{Pt(lt),await se.startFreshSession(),r({title:o("shell.butlerNewSessionStarted"),tone:"success"})}catch(oe){r({title:o("shell.butlerNewSessionFailed"),description:oe instanceof Error?oe.message:void 0,tone:"error"})}}function Pt(oe){T(Re=>Re+1),t(Ui(e),{replace:!0}),oe&&s()}return J&&!ie&&!f?n.jsx("main",{className:"workbench-page butler-page-shell butler-loading-shell",children:n.jsx(K0,{})}):ie?n.jsxs(n.Fragment,{children:[n.jsxs("main",{className:"workbench-page conversation-page-shell butler-page-shell butler-chat-workspace",children:[n.jsxs("header",{className:"workbench-auxiliary-header butler-main-header","data-window-drag-handle":"conversation-header",children:[n.jsx("div",{className:"butler-header-main",children:n.jsxs("div",{className:"butler-header-analysis-anchor",onMouseEnter:()=>{L(!0)},onMouseLeave:()=>{L(!1)},children:[n.jsx("div",{className:"butler-chat-avatar","aria-hidden":"true",children:n.jsx("span",{children:Ve})}),n.jsx("div",{className:"butler-main-heading",children:n.jsx("h1",{tabIndex:0,onFocus:()=>{L(!0)},onBlur:()=>{L(!1)},children:Fe})}),_?n.jsxs("div",{className:"butler-header-analysis-popover",role:"status","aria-live":"polite",children:[n.jsx("strong",{children:o("conversation.butlerAnalysisTitle")}),kt.length>0?kt.map(oe=>n.jsxs("div",{className:"butler-header-analysis-item",children:[n.jsxs("p",{children:[o("conversation.butlerAnalysisObjectiveLabel"),":",oe.objective]}),n.jsxs("p",{children:[o("conversation.butlerAnalysisStatusLabel"),":",Mu(oe.status)]}),n.jsxs("p",{children:[o("conversation.butlerAnalysisSummaryLabel"),":",oe.lastAutomationSummary||oe.waitingReason||o("conversation.butlerAnalysisEmpty")]})]},oe.id)):n.jsx("p",{children:o("conversation.butlerAnalysisEmpty")})]}):null]})}),n.jsxs("div",{className:"butler-toolbar-cluster",children:[n.jsx("div",{className:"butler-provider-switcher",children:n.jsx("select",{"aria-label":o("shell.butlerProviderLabel"),value:lt,disabled:Wt.length<=1||Ee||Ne,onChange:oe=>{We(oe.target.value)},children:Wt.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})}),n.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":o("shell.butlerNewSessionAction"),title:o("shell.butlerNewSessionAction"),disabled:J||Ne||Ee,onClick:()=>{qe()},children:n.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:n.jsx(q3,{})})}),n.jsx("button",{type:"button",className:"terminal-tab-control butler-header-icon-button","aria-label":o("shell.butlerHistoryAction"),title:o("shell.butlerHistoryAction"),disabled:J||Ne||Ee,onClick:()=>{ze()},children:n.jsx("span",{className:"terminal-toolbar-icon","aria-hidden":"true",children:n.jsx($3,{})})})]})]}),n.jsx("section",{className:"butler-main-column",children:n.jsxs("div",{className:"butler-conversation-shell",children:[n.jsx(Nm,{sessionId:(ft=Oe==null?void 0:Oe.session)==null?void 0:ft.sessionId,messages:et,historyState:De,loadingOlderMessages:!1,hasOlderMessages:!1,provider:lt,assistantAvatar:n.jsx("span",{className:"butler-message-avatar","aria-hidden":"true",children:Ve}),onLoadOlderMessages:()=>{},onRetryMessage:oe=>{const Re=et.find(_t=>_t.clientRequestId===oe);if(Re!=null&&Re.content.trim()){se.sendMessage(Re.content);return}se.retryMessage(oe)}}),n.jsx("div",{className:"butler-composer-shell",children:n.jsx(km,{capabilities:bt,draftStorageId:`butler:${lt}:${C}`,placeholder:o("shell.butlerComposerPlaceholder",{displayName:Fe}),hasActiveRun:Ue,canInterrupt:Ye,contextUsage:ye,isSubmitting:Ne||Ee,isRunning:Ue??!1,onInterrupt:async()=>{await se.interrupt(),s()},onSend:async(oe,Re)=>{var _t;(((_t=Re==null?void 0:Re.attachments)==null?void 0:_t.length)??0)>0&&r({title:o("shell.butlerAttachmentUnsupported"),tone:"warning"}),await se.sendMessage(oe,{model:(Re==null?void 0:Re.model)??null,reasoningLevel:(Re==null?void 0:Re.reasoningLevel)??null,permissionMode:null}),s()}})})]},`timeline:${lt}:${C}`)})]}),n.jsx(Ln,{open:Q,title:o("shell.butlerFollowUpHistoryTitle"),description:o("shell.butlerFollowUpHistoryDescription"),onClose:()=>{O(!1)},children:n.jsx(C3,{tasks:D,onOpenFollowUpDetail:ht,onClose:()=>{O(!1)}})}),n.jsx(Ln,{open:ne,title:o("shell.butlerHistoryTitle"),description:o("shell.butlerHistoryDescription"),onClose:()=>{Y(!1)},children:n.jsx(k3,{sessions:I,activeControlSessionId:(Oe==null?void 0:Oe.id)??null,onSelectSession:async oe=>{await se.openControlSession(oe.id),Y(!1)}})}),n.jsx(Ln,{open:G!==null,title:o("shell.butlerAutomationRoundDetailsTitle"),description:((ct=K==null?void 0:K.sessionTitle)==null?void 0:ct.trim())||(K==null?void 0:K.projectName)||o("shell.butlerAutomationRoundDetailsDescription"),onClose:()=>{te(null),z(null),X(null),P(!1)},children:n.jsx(R3,{task:K,loading:q,error:U})})]}):n.jsxs("main",{className:"workbench-page butler-page-shell butler-init-shell",children:[n.jsxs("div",{className:"butler-init-backdrop","aria-hidden":"true",children:[n.jsx("span",{className:"butler-init-glow butler-init-glow-primary"}),n.jsx("span",{className:"butler-init-glow butler-init-glow-secondary"})]}),n.jsxs("div",{className:"butler-init-layout",children:[n.jsxs("aside",{className:"butler-init-sidebar",children:[n.jsx("section",{className:"butler-init-hero-card",children:n.jsxs("div",{className:"butler-init-hero-copy",children:[n.jsx("h1",{children:o("shell.butlerInitTitle")}),n.jsx("p",{children:o("shell.butlerInitDescription")})]})}),n.jsxs("section",{className:"butler-init-preview-card",children:[n.jsx("header",{className:"butler-init-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.butlerInitPreviewTitle")})})}),n.jsxs("div",{className:"butler-init-preview-identity",children:[n.jsxs("div",{className:"butler-init-preview-nameplate",children:[n.jsx("div",{className:"butler-chat-avatar butler-init-preview-avatar",children:n.jsx("span",{children:Ve})}),n.jsx("strong",{children:Fe})]}),n.jsx("span",{className:"butler-init-preview-provider",children:Cn})]}),n.jsx("div",{className:"butler-init-chip-list",children:ce.map(oe=>n.jsx("span",{className:"butler-init-chip",children:oe},oe))}),n.jsxs("div",{className:"butler-init-preview-rows",children:[n.jsxs("div",{className:"butler-init-preview-row",children:[n.jsx("span",{children:o("shell.butlerPersonaToneLabel")}),n.jsx("strong",{children:Wn})]}),n.jsxs("div",{className:"butler-init-preview-row",children:[n.jsx("span",{children:o("shell.butlerInitPreviewRuleLabel")}),n.jsx("strong",{children:on})]}),n.jsxs("div",{className:"butler-init-preview-row",children:[n.jsx("span",{children:o("shell.butlerPersonaSummaryStyleLabel")}),n.jsx("strong",{children:$t})]}),n.jsxs("div",{className:"butler-init-preview-row",children:[n.jsx("span",{children:o("shell.butlerReportPriorityPresetLabel")}),n.jsx("strong",{children:gn})]})]})]})]}),n.jsxs("form",{className:"butler-init-form",onSubmit:Ce,children:[n.jsxs("section",{className:"butler-init-form-section",children:[n.jsx("header",{className:"butler-init-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.butlerInitBasicsTitle")})})}),n.jsxs("div",{className:"butler-init-basic-grid",children:[n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerDisplayNameLabel")}),n.jsx("input",{className:"butler-form-control",value:d.displayName,onChange:oe=>m(Re=>({...Re,displayName:oe.target.value})),placeholder:o("shell.butlerDisplayNamePlaceholder")}),n.jsx("small",{children:o("shell.butlerDisplayNameHint")})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerProviderLabel")}),n.jsx("select",{className:"butler-form-control",value:d.providerId,disabled:Wt.length<=1,onChange:oe=>m(Re=>({...Re,providerId:oe.target.value})),children:Wt.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),n.jsxs("label",{className:"butler-form-field butler-form-field-wide",children:[n.jsx("span",{children:o("shell.butlerAgentsModeLabel")}),n.jsx("select",{className:"butler-form-control",value:d.agentsMode,onChange:oe=>m(Re=>({...Re,agentsMode:oe.target.value})),children:Kt.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))}),n.jsx("small",{children:Z})]})]})]}),n.jsxs("section",{className:"butler-init-form-section",children:[n.jsx("header",{className:"butler-init-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.butlerInitPersonaTitle")})})}),n.jsxs("div",{className:"butler-init-persona-grid",children:[n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaToneLabel")}),n.jsx("select",{className:"butler-form-control",value:d.personaTone,onChange:oe=>m(Re=>({...Re,personaTone:oe.target.value})),children:un.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaLanguageLabel")}),n.jsx("select",{className:"butler-form-control",value:d.personaLanguage,onChange:oe=>m(Re=>({...Re,personaLanguage:oe.target.value})),children:ae.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaSummaryStyleLabel")}),n.jsx("select",{className:"butler-form-control",value:d.personaSummaryStyle,onChange:oe=>m(Re=>({...Re,personaSummaryStyle:oe.target.value})),children:Be.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]})]})]}),n.jsxs("section",{className:"butler-init-form-section",children:[n.jsx("header",{className:"butler-init-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.butlerInitPreferenceTitle")})})}),n.jsxs("div",{className:"butler-init-preferences-grid",children:[n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerFocusRiskPreferenceLabel")}),n.jsx("select",{className:"butler-form-control",value:d.focusRiskPreference,onChange:oe=>m(Re=>({...Re,focusRiskPreference:oe.target.value})),children:It.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerReportPriorityPresetLabel")}),n.jsx("select",{className:"butler-form-control",value:d.reportPriorityPreset,onChange:oe=>m(Re=>({...Re,reportPriorityPreset:oe.target.value})),children:jt.map(oe=>n.jsx("option",{value:oe.value,children:oe.label},oe.value))})]})]})]}),n.jsx("div",{className:"butler-init-actions",children:n.jsx("button",{className:"butler-init-submit",type:"submit",disabled:J||f,children:o(J||f?"shell.butlerInitSubmitting":"shell.butlerInitSubmit")})})]})]})]})}function g3(e){const[t,r]=p.useState("info"),s=[{id:"info",label:o("shell.butlerSidebarInfoTab")},{id:"automation",label:o("shell.butlerSidebarAutomationTab")},{id:"settings",label:o("shell.butlerSidebarSettingsTab")}];return n.jsxs("div",{className:"butler-side-column",children:[n.jsx("div",{className:"workbench-auxiliary-header butler-side-header",children:n.jsx("div",{className:"workbench-info-tabs butler-side-tabs",role:"tablist","aria-label":o("shell.butlerSidebarTabsLabel"),children:s.map(i=>n.jsx("button",{type:"button",role:"tab","aria-selected":t===i.id,className:t===i.id?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{r(i.id)},children:i.label},i.id))})}),t==="info"?n.jsx(b3,{overview:e.overview,inboxItems:e.inboxItems,followUpTasks:e.followUpTasks,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt,todoActionState:e.todoActionState}):t==="automation"?n.jsx(v3,{overview:e.overview,followUpTasks:e.followUpTasks,patrolPlans:e.patrolPlans}):n.jsx(N3,{settingsForm:e.settingsForm,savingSettings:e.savingSettings,onSettingsFormChange:e.onSettingsFormChange,onSaveSettings:e.onSaveSettings})]})}function b3(e){var c;const[t,r]=p.useState(!1),s=p.useMemo(()=>t?e.followUpTasks:e.followUpTasks.filter(d=>cR(d.status)),[e.followUpTasks,t]),i=p.useMemo(()=>{var d;return M3(((d=e.overview)==null?void 0:d.verifications)??[],t)},[(c=e.overview)==null?void 0:c.verifications,t]),l=p.useMemo(()=>t?e.inboxItems:e.inboxItems.filter(d=>d.status!=="closed"),[e.inboxItems,t]);return n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"butler-side-card",children:n.jsxs("label",{className:"butler-record-toggle",children:[n.jsx("input",{type:"checkbox",checked:t,onChange:d=>r(d.target.checked)}),n.jsx("span",{children:o("shell.butlerInfoShowCompletedAction")})]})}),n.jsx(S3,{tasks:s,onOpenFollowUpHistory:e.onOpenFollowUpHistory,onOpenFollowUpDetail:e.onOpenFollowUpDetail}),n.jsx(w3,{title:o("shell.butlerInfoVerificationRecordsTitle"),items:i,emptyText:o("shell.butlerInfoVerificationRecordsEmpty")}),n.jsx(y3,{title:o("shell.butlerInfoTodoRecordsTitle"),items:l,emptyText:o("shell.butlerInfoTodoRecordsEmpty"),todoActionState:e.todoActionState,onAnalyzeTodo:e.onAnalyzeTodo,onStartTodoSession:e.onStartTodoSession,onOpenTodoSession:e.onOpenTodoSession,onCopyTodoPrompt:e.onCopyTodoPrompt})]})}function v3(e){const t=p.useMemo(()=>P3(e.patrolPlans,e.followUpTasks,e.overview),[e.followUpTasks,e.overview,e.patrolPlans]),r=p.useMemo(()=>D3(e.followUpTasks,e.overview),[e.followUpTasks,e.overview]);return n.jsxs(n.Fragment,{children:[n.jsx(j3,{items:t,emptyText:o("shell.butlerAutomationTasksEmpty")}),n.jsx(T3,{items:r,emptyText:o("shell.butlerAutomationRunsEmpty")})]})}function w3(e){return n.jsxs("section",{className:"butler-side-card",children:[n.jsx("header",{children:n.jsx("h2",{children:e.title})}),e.items.length>0?n.jsx("div",{className:"butler-record-list",children:e.items.map(t=>n.jsx(x3,{title:t.title,content:t.content},`${t.title}:${t.content}`))}):n.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function y3(e){return n.jsxs("section",{className:"butler-side-card",children:[n.jsx("header",{children:n.jsx("h2",{children:e.title})}),e.items.length>0?n.jsx("div",{className:"butler-record-list",children:e.items.map(t=>{var d,m;const r=e.todoActionState.itemId===t.id?e.todoActionState.kind:null,s=!!((d=t.assistantState.generatedPrompt)!=null&&d.trim()),i=!!((m=t.assistantState.linkedSessionId)!=null&&m.trim()),l=t.assistantState.lifecycleStage==="analyzing",c=i||s&&!l&&t.status!=="closed";return n.jsxs("article",{className:"butler-todo-card",children:[n.jsxs("header",{className:"butler-todo-card-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:t.title}),n.jsx("span",{children:t.projectName})]}),n.jsxs("div",{className:"butler-todo-card-badges",children:[n.jsx("span",{className:"butler-inline-badge",children:B3(t.status)}),n.jsx("span",{className:"butler-inline-badge",children:L3(t.assistantState.lifecycleStage)})]})]}),n.jsx("p",{children:t.content}),n.jsx("p",{className:"butler-secondary-text",children:t.assistantState.lastError||t.assistantState.analysisSummary||o("shell.butlerTodoLifecycleEmpty")}),s?n.jsx("div",{className:"butler-todo-prompt-preview",children:n.jsxs("details",{className:"butler-todo-prompt-preview-details",children:[n.jsx("summary",{children:o("shell.butlerTodoPromptPreviewAction")}),n.jsx("pre",{children:t.assistantState.generatedPrompt})]})}):null,n.jsxs("div",{className:"butler-todo-card-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:r!==null||t.status==="closed"||l,onClick:()=>{e.onAnalyzeTodo(t)},children:o(r==="analyze"||l?"shell.butlerTodoAnalyzeRunning":s?"shell.butlerTodoReanalyzeAction":"shell.butlerTodoAnalyzeAction")}),n.jsx("button",{type:"button",className:"secondary-button",disabled:r!==null||!c,onClick:()=>{if(i){e.onOpenTodoSession(t);return}e.onStartTodoSession(t)},children:o(r==="start"?"shell.butlerTodoStartSessionRunning":i?"shell.butlerTodoOpenSessionAction":l?"shell.butlerTodoWaitForPromptAction":s?"shell.butlerTodoStartSessionAction":"shell.butlerTodoAnalyzeFirstAction")}),n.jsx("button",{type:"button",className:"secondary-button",disabled:!s,onClick:()=>{e.onCopyTodoPrompt(t)},children:o("shell.butlerTodoCopyPromptAction")})]})]},t.id)})}):n.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function k3(e){return e.sessions.length===0?n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerHistoryEmpty")}):n.jsx("div",{className:"butler-record-list",children:e.sessions.map(t=>{var i,l,c,d,m;const r=t.id===e.activeControlSessionId,s=((i=t.title)==null?void 0:i.trim())||((l=t.session.title)==null?void 0:l.trim())||((c=t.lastSummary)==null?void 0:c.trim())||t.sessionId;return n.jsxs("article",{className:"butler-todo-card",children:[n.jsxs("header",{className:"butler-todo-card-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:s}),n.jsx("span",{children:F3(t.updatedAt)})]}),n.jsxs("div",{className:"butler-todo-card-badges",children:[n.jsx("span",{className:"butler-inline-badge",children:t.purpose==="todo_analysis"?o("shell.butlerControlSessionKindTodoAnalysis"):o("shell.butlerControlSessionKindChat")}),n.jsx("span",{className:"butler-inline-badge",children:W3(t.status)}),r?n.jsx("span",{className:"butler-inline-badge",children:o("shell.butlerCurrentSessionBadge")}):null]})]}),n.jsx("p",{className:"butler-secondary-text",children:((d=t.lastSummary)==null?void 0:d.trim())||((m=t.session.title)==null?void 0:m.trim())||t.sessionId}),n.jsx("div",{className:"butler-todo-card-actions",children:n.jsx("button",{type:"button",className:"secondary-button",disabled:r,onClick:()=>{e.onSelectSession(t)},children:o(r?"shell.butlerCurrentSessionBadge":"shell.butlerHistoryOpenAction")})})]},t.id)})})}function x3(e){return n.jsxs("div",{className:"butler-simple-info-block",children:[n.jsx("span",{children:e.title}),n.jsx("strong",{children:e.content})]})}function S3(e){const t=p.useMemo(()=>[...e.tasks].sort((r,s)=>Nr(Mo(s))-Nr(Mo(r))).slice(0,5),[e.tasks]);return n.jsxs("section",{className:"butler-side-card",children:[n.jsxs("header",{children:[n.jsx("div",{className:"butler-card-header-copy",children:n.jsx("h2",{children:o("shell.butlerInfoFollowUpRecordsTitle")})}),n.jsx("button",{type:"button",className:"secondary-button butler-side-header-action",onClick:e.onOpenFollowUpHistory,children:o("shell.butlerFollowUpHistoryAction")})]}),t.length>0?n.jsx("div",{className:"butler-record-list",children:t.map(r=>n.jsx(lR,{task:r,onOpenFollowUpDetail:e.onOpenFollowUpDetail},r.id))}):n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerInfoFollowUpRecordsEmpty")})]})}function C3(e){const t=p.useMemo(()=>[...e.tasks].sort((r,s)=>Nr(Mo(s))-Nr(Mo(r))),[e.tasks]);return n.jsx("div",{className:"butler-follow-up-history-panel",children:t.length>0?n.jsx("div",{className:"butler-record-list",children:t.map(r=>n.jsx(lR,{task:r,onOpenFollowUpDetail:async s=>{e.onClose(),await e.onOpenFollowUpDetail(s)}},r.id))}):n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerInfoFollowUpRecordsEmpty")})})}function lR(e){var i,l,c;const{task:t}=e,r=((i=t.sessionTitle)==null?void 0:i.trim())||t.projectName,s=((l=t.waitingReason)==null?void 0:l.trim())||((c=t.lastAutomationSummary)==null?void 0:c.trim())||t.objective;return n.jsxs("article",{className:"butler-follow-up-status-card",children:[n.jsxs("header",{className:"butler-follow-up-status-header",children:[n.jsxs("div",{className:"butler-follow-up-status-title-group",children:[n.jsx("strong",{children:r}),n.jsx("span",{children:t.projectName})]}),n.jsx("span",{className:"butler-automation-status-badge","data-status":t.status,children:Mu(t.status)})]}),n.jsx("div",{className:"butler-follow-up-status-body",children:n.jsx("p",{children:s})}),n.jsxs("footer",{className:"butler-follow-up-status-footer",children:[n.jsx("span",{children:El(Mo(t))}),n.jsx("button",{type:"button",className:"secondary-button butler-follow-up-status-action",onClick:()=>{e.onOpenFollowUpDetail(t.id)},children:o("shell.butlerAutomationViewRoundsAction")})]})]})}function j3(e){return n.jsxs("section",{className:"butler-side-card",children:[n.jsx("header",{children:n.jsx("h2",{children:o("shell.butlerAutomationTasksTitle")})}),e.items.length>0?n.jsx("div",{className:"butler-record-list",children:e.items.map(t=>n.jsxs("article",{className:"butler-automation-card",children:[n.jsxs("header",{className:"butler-automation-card-header",children:[n.jsxs("div",{className:"butler-automation-card-title-group",children:[n.jsx("strong",{children:t.title}),n.jsx("span",{children:t.projectName})]}),n.jsx("span",{className:"butler-automation-status-badge","data-status":"active",children:t.statusLabel})]}),n.jsxs("div",{className:"butler-automation-card-body",children:[n.jsxs("div",{className:"butler-automation-row",children:[n.jsx("span",{children:o("shell.butlerAutomationTaskTypeLabel")}),n.jsx("strong",{children:t.taskTypeLabel})]}),n.jsxs("div",{className:"butler-automation-row",children:[n.jsx("span",{children:o("shell.butlerAutomationTaskLastRunLabel")}),n.jsx("strong",{children:El(t.lastRunAt)})]})]}),n.jsxs("footer",{className:"butler-automation-card-footer",children:[n.jsx("span",{children:o("shell.butlerAutomationTaskNextRunLabel")}),n.jsx("strong",{children:El(t.nextRunAt)})]})]},t.id))}):n.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function T3(e){return n.jsxs("section",{className:"butler-side-card",children:[n.jsx("header",{children:n.jsx("h2",{children:o("shell.butlerAutomationRunsTitle")})}),e.items.length>0?n.jsx("div",{className:"butler-record-list",children:e.items.map(t=>n.jsxs("article",{className:"butler-automation-card",children:[n.jsxs("header",{className:"butler-automation-card-header",children:[n.jsxs("div",{className:"butler-automation-card-title-group",children:[n.jsx("strong",{children:t.title}),n.jsx("span",{children:t.projectName})]}),n.jsx("span",{className:"butler-automation-status-badge","data-status":"active",children:t.statusLabel})]}),n.jsxs("div",{className:"butler-automation-card-body",children:[n.jsxs("div",{className:"butler-automation-row",children:[n.jsx("span",{children:o("shell.butlerAutomationRunSourceLabel")}),n.jsx("strong",{children:t.sourceLabel})]}),n.jsxs("div",{className:"butler-automation-row",children:[n.jsx("span",{children:o("shell.butlerAutomationRunSummaryLabel")}),n.jsx("strong",{children:t.summary})]})]}),n.jsxs("footer",{className:"butler-automation-card-footer",children:[n.jsx("span",{children:o("shell.butlerAutomationRunProcessedAtLabel")}),n.jsx("strong",{children:El(t.createdAt)})]})]},t.id))}):n.jsx("p",{className:"butler-secondary-text",children:e.emptyText})]})}function N3(e){return n.jsxs("section",{className:"butler-side-card butler-settings-panel",children:[n.jsx("header",{children:n.jsx("h2",{children:o("shell.butlerSettingsTitle")})}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerDisplayNameLabel")}),n.jsx("input",{"aria-label":o("shell.butlerDisplayNameLabel"),className:"butler-form-control",value:e.settingsForm.displayName,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({displayName:t.target.value})}})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerAgentsModeLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerAgentsModeLabel"),className:"butler-form-control",value:e.settingsForm.agentsMode,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({agentsMode:t.target.value})},children:[n.jsx("option",{value:"inline",children:o("shell.butlerAgentsModeInline")}),n.jsx("option",{value:"file",children:o("shell.butlerAgentsModeFile")})]}),n.jsx("small",{children:e.settingsForm.agentsMode==="file"?o("shell.butlerAgentsModeFileDescription"):o("shell.butlerAgentsModeInlineDescription")})]}),e.settingsForm.agentsMode==="file"?n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerAgentsFilePathLabel")}),n.jsx("input",{"aria-label":o("shell.butlerAgentsFilePathLabel"),className:"butler-form-control butler-settings-file-path",value:e.settingsForm.agentsFilePath,readOnly:!0,disabled:e.savingSettings})]}):null,n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerAgentsContentLabel")}),n.jsx("textarea",{"aria-label":o("shell.butlerAgentsContentLabel"),className:"butler-form-control butler-settings-agents-editor",rows:10,value:e.settingsForm.agentsContent,disabled:e.savingSettings,placeholder:o("shell.butlerAgentsContentPlaceholder"),onChange:t=>{e.onSettingsFormChange({agentsContent:t.target.value})}}),n.jsx("small",{children:o("shell.butlerAgentsContentHint")})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaToneLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerPersonaToneLabel"),className:"butler-form-control",value:e.settingsForm.personaTone,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({personaTone:t.target.value})},children:[n.jsx("option",{value:"direct",children:o("shell.butlerToneDirect")}),n.jsx("option",{value:"steady",children:o("shell.butlerToneSteady")}),n.jsx("option",{value:"friendly",children:o("shell.butlerToneFriendly")})]})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaLanguageLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerPersonaLanguageLabel"),className:"butler-form-control",value:e.settingsForm.personaLanguage,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({personaLanguage:t.target.value})},children:[n.jsx("option",{value:"zh-CN",children:o("shell.butlerLanguageZhCn")}),n.jsx("option",{value:"en-US",children:o("shell.butlerLanguageEnUs")}),n.jsx("option",{value:"bilingual",children:o("shell.butlerLanguageBilingual")})]})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerPersonaSummaryStyleLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerPersonaSummaryStyleLabel"),className:"butler-form-control",value:e.settingsForm.personaSummaryStyle,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({personaSummaryStyle:t.target.value})},children:[n.jsx("option",{value:"brief",children:o("shell.butlerSummaryBrief")}),n.jsx("option",{value:"structured",children:o("shell.butlerSummaryStructured")}),n.jsx("option",{value:"thorough",children:o("shell.butlerSummaryThorough")})]})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerFocusRiskPreferenceLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerFocusRiskPreferenceLabel"),className:"butler-form-control",value:e.settingsForm.focusRiskPreference,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({focusRiskPreference:t.target.value})},children:[n.jsx("option",{value:"conservative",children:o("shell.butlerRiskConservative")}),n.jsx("option",{value:"balanced",children:o("shell.butlerRiskBalanced")}),n.jsx("option",{value:"proactive",children:o("shell.butlerRiskProactive")})]})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerReportPriorityPresetLabel")}),n.jsxs("select",{"aria-label":o("shell.butlerReportPriorityPresetLabel"),className:"butler-form-control",value:e.settingsForm.reportPriorityPreset,disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({reportPriorityPreset:t.target.value})},children:[n.jsx("option",{value:"risk-first",children:o("shell.butlerReportRiskFirst")}),n.jsx("option",{value:"blocker-first",children:o("shell.butlerReportBlockerFirst")}),n.jsx("option",{value:"verification-first",children:o("shell.butlerReportVerificationFirst")}),n.jsx("option",{value:"progress-first",children:o("shell.butlerReportProgressFirst")})]})]}),n.jsxs("label",{className:"butler-form-field",children:[n.jsx("span",{children:o("shell.butlerSummaryDebounceLabel")}),n.jsx("select",{"aria-label":o("shell.butlerSummaryDebounceLabel"),className:"butler-form-control",value:String(e.settingsForm.summaryDebounceSeconds),disabled:e.savingSettings,onChange:t=>{e.onSettingsFormChange({summaryDebounceSeconds:Number(t.target.value)})},children:h3.map(t=>n.jsx("option",{value:t.value,children:o(t.labelKey)},t.value))})]}),n.jsx("div",{className:"butler-inline-actions",children:n.jsx("button",{type:"button",className:"primary-button",disabled:e.savingSettings,onClick:e.onSaveSettings,children:e.savingSettings?o("shell.butlerSettingsSaving"):o("shell.butlerSettingsSaveAction")})})]})}function El(e){if(!e)return"-";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Mo(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function P3(e,t,r){const s=new Map(((r==null?void 0:r.projects)??[]).map(c=>[c.id,c.name])),i=e.map(c=>({id:`patrol-plan:${c.id}`,title:c.name,projectName:s.get(c.projectId)??c.projectId,taskTypeLabel:OC("patrol_plan",c.triggerType),statusLabel:c.enabled?o("shell.butlerAutomationTaskEnabled"):o("shell.butlerAutomationTaskDisabled"),nextRunAt:c.nextRunAt,lastRunAt:c.lastScheduledAt})),l=t.map(c=>{var d;return{id:`follow-up:${c.id}`,title:((d=c.sessionTitle)==null?void 0:d.trim())||c.projectName,projectName:c.projectName,taskTypeLabel:OC("follow_up"),statusLabel:Mu(c.status),nextRunAt:c.nextCheckAt,lastRunAt:c.lastAutomationAt||c.lastCheckedAt||c.updatedAt}});return[...i,...l].sort((c,d)=>{const m=Nr(c.nextRunAt),f=Nr(d.nextRunAt);return m!==f?m===0?1:f===0?-1:m-f:Nr(d.lastRunAt)-Nr(c.lastRunAt)}).slice(0,10)}function D3(e,t){const r=new Map(((t==null?void 0:t.projects)??[]).map(l=>[l.id,l.name])),s=((t==null?void 0:t.patrols)??[]).map(l=>{var c;return{id:`patrol-run:${l.id}`,title:o("shell.butlerAutomationPatrolRunTitle"),projectName:r.get(l.projectId)??l.projectId,sourceLabel:BC("patrol_run"),statusLabel:l.status,summary:((c=l.summary)==null?void 0:c.trim())||o("shell.butlerAutomationRunEmptySummary"),createdAt:l.finishedAt||l.startedAt||l.createdAt}}),i=e.flatMap(l=>(l.rounds??[]).map(c=>{var d,m;return{id:`follow-up-round:${l.id}:${c.roundNumber}`,title:`${((d=l.sessionTitle)==null?void 0:d.trim())||l.projectName} · ${o("shell.butlerAutomationRoundLabel",{round:c.roundNumber})}`,projectName:l.projectName,sourceLabel:BC("follow_up_round"),statusLabel:Mu(c.status),summary:((m=c.summary)==null?void 0:m.trim())||o("shell.butlerAutomationRunEmptySummary"),createdAt:c.createdAt}}));return[...s,...i].sort((l,c)=>Nr(c.createdAt)-Nr(l.createdAt)).slice(0,12)}function R3(e){if(e.loading)return n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerAutomationRoundLoading")});if(e.error)return n.jsx("p",{className:"butler-secondary-text",children:e.error});if(!e.task)return n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerAutomationRoundEmpty")});const t=[...e.task.rounds??[]].sort((r,s)=>Nr(s.createdAt)-Nr(r.createdAt));return n.jsxs("div",{className:"butler-follow-up-rounds",children:[n.jsxs("div",{className:"butler-follow-up-round-summary",children:[n.jsx("strong",{children:e.task.objective}),n.jsx("span",{children:o("conversation.butlerCurrentFollowUpProgress",{current:e.task.autoContinueCount,max:e.task.maxAutoContinueCount??5})})]}),t.length>0?n.jsx("div",{className:"butler-follow-up-round-list",children:t.map(r=>n.jsxs("article",{className:"butler-follow-up-round-card",children:[n.jsxs("header",{className:"butler-follow-up-round-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:o("shell.butlerAutomationRoundLabel",{round:r.roundNumber})}),n.jsx("span",{children:U3(r.kind)})]}),n.jsx("span",{children:El(r.createdAt)})]}),n.jsxs("div",{className:"butler-follow-up-round-body",children:[n.jsxs("p",{children:[o("shell.butlerAutomationRoundProcessedAtLabel"),":",El(r.createdAt)]}),n.jsxs("p",{children:[o("shell.butlerAutomationRoundStatusLabel"),":",Mu(r.status)]}),r.observedRunningState?n.jsxs("p",{children:[o("shell.butlerAutomationRoundObservedStateLabel"),":",r.observedRunningState]}):null,n.jsxs("p",{children:[o("shell.butlerAutomationRoundSummaryLabel"),":",r.summary||o("conversation.butlerAnalysisEmpty")]}),r.waitingReason?n.jsxs("p",{children:[o("shell.butlerAutomationRoundWaitingReasonLabel"),":",r.waitingReason]}):null,r.continuePrompt?n.jsxs("p",{children:[o("shell.butlerAutomationRoundPromptLabel"),":",r.continuePrompt]}):null]})]},`${r.roundNumber}:${r.createdAt}`))}):n.jsx("p",{className:"butler-secondary-text",children:o("shell.butlerAutomationRoundEmpty")})]})}function M3(e,t){return[...e].filter(r=>t||E3(r.status)).sort((r,s)=>Nr(_C(s))-Nr(_C(r))).slice(0,5).map(r=>{var s,i;return{title:((s=r.targetRef)==null?void 0:s.trim())||r.verificationType,content:((i=r.summary)==null?void 0:i.trim())||o("shell.butlerInfoVerificationFallback",{status:r.status})}})}function FC(e,t){const r=e.filter(s=>s.id!==t.id);return[t,...r].sort((s,i)=>Nr(i.updatedAt)-Nr(s.updatedAt))}function A3(e,t){const r=e.filter(s=>s.id!==t.id);return[t,...r].sort((s,i)=>Nr(Mo(i))-Nr(Mo(s)))}function I3(e,t){const r=e.filter(s=>s.id!==t.id);return[t,...r].sort((s,i)=>Nr(i.updatedAt)-Nr(s.updatedAt))}function cR(e){return e==="active"||e==="waiting_user"}function E3(e){return e==="queued"||e==="running"||e==="failed"}function L3(e){switch(e){case"analyzing":return o("shell.butlerTodoLifecycleAnalyzing");case"analyzed":return o("shell.butlerTodoLifecycleAnalyzed");case"session_created":return o("shell.butlerTodoLifecycleSessionCreated");case"follow_up_active":return o("shell.butlerTodoLifecycleFollowUpActive");case"completed":return o("shell.butlerTodoLifecycleCompleted");case"failed":return o("shell.butlerTodoLifecycleFailed");case"pending":default:return o("shell.butlerTodoLifecyclePending")}}function _C(e){return e.finishedAt||e.startedAt||e.createdAt}function Nr(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function F3(e){const t=Nr(e);return t<=0?"-":new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function _3(e){for(const[t,r]of Object.entries(vb))if(r.length===e.length&&r.every((s,i)=>s===e[i]))return t;return"risk-first"}function O3(e){var s;if((s=e.agentsFilePath)!=null&&s.trim())return e.agentsFilePath.trim();const t=e.workspacePath.includes("\\")?"\\":"/";return`${e.workspacePath.replace(/[\\/]+$/,"")}${t}AGENTS.md`}function B3(e){switch(e){case"pending":return o("shell.butlerInfoTodoPending");case"in_progress":return o("shell.butlerInfoTodoInProgress");case"closed":return o("shell.butlerInfoTodoClosed");default:return o("shell.butlerInfoTodoPending")}}function W3(e){switch(e){case"running":return o("shell.butlerInfoTodoInProgress");case"failed":return o("shell.butlerTodoLifecycleFailed");case"closed":return o("shell.butlerInfoTodoClosed");case"idle":default:return o("shell.butlerInfoTodoPending")}}function Mu(e){switch(e){case"active":return o("shell.butlerAutomationStatusActive");case"waiting_user":return o("shell.butlerAutomationStatusWaitingUser");case"completed":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":return o("shell.butlerAutomationStatusCancelled");default:return o("shell.butlerAutomationStatusActive")}}function U3(e){switch(e){case"started":return o("shell.butlerAutomationRoundKindStarted");case"continue":return o("shell.butlerAutomationRoundKindContinue");case"queued":return o("shell.butlerAutomationRoundKindQueued");case"waiting_user":return o("shell.butlerAutomationRoundKindWaitingUser");case"completed":return o("shell.butlerAutomationRoundKindCompleted");case"failed":return o("shell.butlerAutomationRoundKindFailed");case"cancelled":return o("shell.butlerAutomationRoundKindCancelled");case"limit_reached":return o("shell.butlerAutomationRoundKindLimitReached");default:return e}}function OC(e,t){if(e==="follow_up")return o("shell.butlerAutomationTaskTypeFollowUp");switch(t){case"interval":return o("shell.butlerAutomationTaskTypeInterval");case"cron":return o("shell.butlerAutomationTaskTypeCron");case"manual":default:return o("shell.butlerAutomationTaskTypeManual")}}function BC(e){return o(e==="patrol_run"?"shell.butlerAutomationRunSourcePatrol":"shell.butlerAutomationRunSourceFollowUp")}function H3(e){const r=`${e.displayName.trim()}:${e.providerId}:${e.tone}`,s=z3(e);if(!r)return ia.default[0];const i=Array.from(r).reduce((l,c)=>{const d=c.codePointAt(0)??0;return l+d},0);return s[i%s.length]}function z3(e){const t=e.displayName.trim().toLowerCase();return/(bot|ai|智能|助手|助理|管家|buddy|helper)/.test(t)?ia.builder:/(书|学|知|研|析|查|review|audit|scan)/.test(t)?ia.analyst:e.tone==="friendly"?ia.friendly:e.tone==="steady"?ia.steady:e.tone==="direct"?e.providerId==="claude-code"?ia.analyst:ia.direct:e.providerId==="claude-code"?ia.analyst:ia.default}function Ma(e,t){var r;return((r=e.find(s=>s.value===t))==null?void 0:r.label)??t}function q3(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function $3(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M12 8v5l3 2"}),n.jsx("path",{d:"M5 3v4"}),n.jsx("path",{d:"M19 3v4"}),n.jsx("path",{d:"M4 7h16"}),n.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2"})]})}function Ul(e){return e.flatMap(t=>[{workspace:t.workspace,label:t.workspace.name,subtitle:t.workspace.path,depth:0,kind:"workspace",meta:null},...uR(t.childWorktrees??[])])}function ua(e,t){const r=t==null?void 0:t.trim();if(!r)return null;for(const s of e){if(s.workspace.id===r)return{workspace:s.workspace,sessions:s.sessions,childWorktrees:s.childWorktrees??[],meta:null};const i=dR(s.childWorktrees??[],r);if(i)return i}return null}function uR(e){return e.flatMap(t=>[{workspace:t.workspace,label:t.meta.displayName||t.workspace.name,subtitle:t.workspace.path,depth:t.meta.depth,kind:"worktree",meta:t.meta},...uR(t.children)])}function dR(e,t){for(const r of e){if(r.workspace.id===t)return{workspace:r.workspace,sessions:r.sessions,childWorktrees:r.children,meta:r.meta};const s=dR(r.children,t);if(s)return s}return null}const V3=10080*60*1e3;function G3(e,t){return K3(e.hosts,e.activeHostId).flatMap(r=>{const s=r.id===e.activeHostId?t:Y3(r.id);return[{kind:"host",host:r,workspaceCount:s.length},...s.map(i=>({kind:"workspace",host:r,workspace:i.workspace,option:i}))]})}function K3(e,t){return[...e].sort((r,s)=>{if(r.id===t)return-1;if(s.id===t)return 1;const i=r.lastConnectedAt??r.updatedAt??r.createdAt;return(s.lastConnectedAt??s.updatedAt??s.createdAt).localeCompare(i)})}function Y3(e){const t=AP(V3,e);return t?Ul(tu(t)):[]}function hR({children:e,className:t,frameRef:r,...s}){return n.jsx("div",{ref:r,className:["mobile-top-header-frame",t].filter(Boolean).join(" "),...s,children:e})}function Hl({currentWorkspace:e,workspaces:t,workspaceOptions:r,onSelectWorkspace:s,className:i,containerRef:l,heading:c,content:d,sheetContent:m,triggerLabel:f,triggerAriaLabel:v,onTriggerClick:g,trailing:w,gestureHandlers:k}){const[y,C]=p.useState(!1),[T,j]=p.useState(null),N=li(),D=vr(),{showToast:F}=Qn(),W=Rl(O=>O),E=za(W),I=r??t.map(O=>({workspace:{...O,repoRoot:O.path},label:O.name,subtitle:O.path,depth:0,kind:"workspace",meta:null})),M=G3(W,I),_=(e==null?void 0:e.name)??(E==null?void 0:E.name)??null,L=(e==null?void 0:e.path)??(E==null?void 0:E.baseUrl)??null;if(!_)return null;async function Q(O){const ne=O.kind==="host"?`host:${O.host.id}`:`workspace:${O.host.id}:${O.workspace.id}`;if(!T){j(ne);try{O.host.id!==W.activeHostId&&(N.trigger("selection"),await OP.switchHost(O.host.id)),O.kind==="host"?D(Ts()):(O.workspace.id!==(e==null?void 0:e.id)||O.host.id!==W.activeHostId)&&await(s==null?void 0:s(O.workspace.id)),C(!1)}catch(Y){F({title:X3(Y,O.host.name),tone:"error"})}finally{j(null)}}}return n.jsxs(n.Fragment,{children:[n.jsx(hR,{className:i,frameRef:l,...k,children:n.jsxs("section",{className:"mobile-workspace-home-header",children:[n.jsx("h1",{className:"mobile-workspace-switcher-heading",children:c??_}),n.jsxs("div",{className:"mobile-workspace-home-toolbar-top",children:[n.jsxs("button",{type:"button",className:"mobile-workspace-home-switcher","aria-label":v??o("shell.workspaceHomeSwitcherLabel"),onClick:()=>{if(g){g();return}N.trigger("selection"),C(!0)},children:[n.jsx("span",{className:"mobile-workspace-home-switcher-label",children:f??_}),n.jsx(e$,{})]}),n.jsx("div",{className:"mobile-workspace-home-toolbar-actions",children:w})]}),L?n.jsx("p",{className:"mobile-workspace-home-path",children:L}):null,d]})}),y&&!g?J3(n.jsxs(Z3,{title:o("shell.hostWorkspaceSwitcherTitle"),onClose:()=>C(!1),children:[n.jsx("div",{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:M.map(O=>n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row","data-host-entry-kind":O.kind,"data-host-active":O.host.id===W.activeHostId,"data-worktree-kind":O.kind==="workspace"?O.option.kind:void 0,"data-worktree-depth":O.kind==="workspace"?O.option.depth+1:0,disabled:T!==null,onClick:()=>{Q(O)},children:[n.jsxs("div",{className:O.kind==="host"?"mobile-workspace-home-session-main mobile-host-workspace-switcher-host-main":"mobile-workspace-home-session-main",style:{"--mobile-workspace-tree-depth":String(O.kind==="host"?0:O.option.depth+1)},children:[n.jsxs("span",{className:"mobile-workspace-home-session-title",children:[O.kind==="host"?n.jsx("span",{className:"mobile-host-workspace-switcher-host-badge",children:o("shell.hostSwitcherNodeBadge")}):null,O.kind==="workspace"&&O.option.kind==="worktree"?n.jsx("span",{className:"mobile-workspace-home-worktree-badge",children:o("shell.mobileWorktreeBadge")}):null,O.kind==="host"?O.host.name:O.option.label]}),n.jsx("span",{className:"mobile-workspace-home-session-meta",children:O.kind==="host"?Q3(O.host,O.workspaceCount):O.option.subtitle})]}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:O.kind==="host"&&O.host.id===W.activeHostId?n.jsx(WC,{}):O.kind==="workspace"&&O.workspace.id===(e==null?void 0:e.id)&&O.host.id===W.activeHostId?n.jsx(WC,{}):n.jsx(t$,{})})]},O.kind==="host"?`host-${O.host.id}`:`workspace-${O.host.id}-${O.workspace.id}`))}),m?m(()=>C(!1)):null]})):null]})}function X3(e,t){return e instanceof zh?e.code==="HOST_UNREACHABLE"?o("shell.hostSwitchUnreachable",{name:t}):o("shell.hostSwitchMissing"):o("shell.hostSwitchFailed")}function Q3(e,t){return e?e.lastUsername?o("shell.hostSwitcherWorkspaceCountWithUser",{username:e.lastUsername,count:t}):t>0?o("shell.hostSwitcherWorkspaceCount",{count:t}):e.baseUrl:""}function J3(e){return typeof document>"u"?null:$n.createPortal(e,document.body)}function Z3({title:e,onClose:t,children:r}){return n.jsx("div",{className:"ios-action-sheet-overlay",role:"presentation",onClick:t,children:n.jsxs("div",{className:"mobile-workspace-home-sheet",role:"dialog","aria-modal":"true","aria-label":e,onClick:s=>s.stopPropagation(),children:[n.jsxs("div",{className:"mobile-workspace-home-sheet-card",children:[n.jsx("div",{className:"mobile-workspace-home-sheet-header",children:n.jsx("strong",{children:e})}),r]}),n.jsx("button",{type:"button",className:"ios-action-sheet-cancel",onClick:t,children:o("common.cancel")})]})})}function e$(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function t$(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function WC(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}const mR="mobile.butler.active-tab",xh=["info","automation","settings"],n$=15e3,ew=56,tw=1.2,UC=360;function r$(){if(typeof window>"u")return"info";try{const e=window.localStorage.getItem(mR);return e==="automation"||e==="settings"?e:"info"}catch{return"info"}}function s$(e,t){return e==="settings"?"settings":e==="automation"?"automation":e==="info"?"info":t}function i$(e,t,r){if(!t)return{closeSidebar:!1,nextTab:e};const s=r.x-t.x,i=r.y-t.y;if(Math.abs(s)<ew)return{closeSidebar:!1,nextTab:e};if(Math.abs(s)<Math.abs(i)*tw)return{closeSidebar:!1,nextTab:e};const l=xh.indexOf(e);if(s>0&&l===0)return{closeSidebar:!0,nextTab:e};const c=s<0?Math.min(xh.length-1,l+1):Math.max(0,l-1);return{closeSidebar:!1,nextTab:xh[c]??e}}function a$(e,t){if(!e)return null;const r=t.x-e.x,s=t.y-e.y;return Math.abs(r)<ew||Math.abs(r)<Math.abs(s)*tw?null:r>0?"list":"sidebar"}function Kf(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-mobile-butler-gesture='ignore']"):!1}function o$(){var Ve,kt,me,Me,Xe,ze,vt,ht;const{workspaceId:e=""}=Eo(),t=oi(),r=vr(),{showToast:s}=Qn(),{navigationGroups:i,requestNavigationRefresh:l,selectWorkspace:c}=Pr(),d=((Ve=i.find(pe=>pe.workspace.id===e))==null?void 0:Ve.workspace)??null,m=new URLSearchParams(t.search).get("tab"),f=p.useRef(r$()),v=s$(m,f.current),g=p.useRef(null),w=p.useRef(null),k=p.useRef(null),y=p.useRef(null),C=p.useRef(null),[T,j]=p.useState(null),[N,D]=p.useState(null),[F,W]=p.useState({loading:!0,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[]});(!y.current||C.current!==e)&&(y.current=new iR(e),C.current=e);const E=y.current,I=Kn(E,pe=>pe.loading),M=Kn(E,pe=>pe.initialized),_=Kn(E,pe=>pe.profile),L=Kn(E,pe=>pe.activeProvider),Q=Kn(E,pe=>pe.controlSession),O=Kn(E,pe=>pe.capabilities),ne=Kn(E,pe=>pe.messages),Y=Kn(E,pe=>pe.historyState),G=Kn(E,pe=>pe.runtimeHasActiveRun),te=Kn(E,pe=>pe.runtimeCanInterrupt),K=Kn(E,pe=>pe.contextUsage),{composerPortalTarget:z}=tv(),q=p.useRef(null);p.useEffect(()=>{if(f.current=v,!(typeof window>"u"))try{window.localStorage.setItem(mR,v)}catch{}},[v]),p.useEffect(()=>{if(m===v)return;const pe=new URLSearchParams(t.search);pe.set("tab",v),r({pathname:t.pathname,search:`?${pe.toString()}`},{replace:!0})},[v,t.pathname,t.search,r,m]),p.useEffect(()=>{e&&c(e)},[c,e]),p.useEffect(()=>{e&&E.initialize()},[E,e]),p.useEffect(()=>{if(!e){W({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[]});return}let pe=!1;async function $e(Wt){W(Kt=>({...Kt,loading:!0}));try{const Kt=await mm();if(!Kt.initialized||!Kt.profile){pe||W({loading:!1,initialized:!1,profile:null,overview:null,followUpTasks:[],inboxItems:[],patrolPlans:[],controlSessions:[]});return}const[un,ae,Be,It]=await Promise.all([pm(),fm(),Nu({workspaceId:e}),Yg()]),jt=un.overview.projects.filter(on=>on.workspaceId===e).map(on=>on.id),Cn=await Promise.all(jt.map(on=>EP(on)));if(pe)return;W({loading:!1,initialized:!0,profile:Kt.profile,overview:un.overview,followUpTasks:ae.items.filter(on=>on.workspaceId===e),inboxItems:Be.items.filter(on=>on.status!=="closed"),patrolPlans:Cn.flatMap(on=>on.items),controlSessions:It.items})}catch(Kt){if(pe)return;W(un=>({...un,loading:!1})),Wt&&s({title:o("shell.butlerLoadFailed"),description:Kt instanceof Error?Kt.message:void 0,tone:"error"})}}$e(!0);const Nt=window.setInterval(()=>{$e(!1)},n$),Rt=Zv(()=>{$e(!1)}),Ft=()=>{$e(!1)};return window.addEventListener(Po,Ft),()=>{pe=!0,window.clearInterval(Nt),Rt(),window.removeEventListener(Po,Ft)}},[s,e]);const P=p.useMemo(()=>{var pe;return new Set((((pe=F.overview)==null?void 0:pe.projects)??[]).filter($e=>$e.workspaceId===e).map($e=>$e.id))},[(kt=F.overview)==null?void 0:kt.projects,e]),U=p.useMemo(()=>F.followUpTasks.filter(pe=>h$(pe.status)),[F.followUpTasks]),X=p.useMemo(()=>{var pe;return(((pe=F.overview)==null?void 0:pe.verifications)??[]).filter($e=>$e.projectId?P.has($e.projectId):!1)},[(me=F.overview)==null?void 0:me.verifications,P]),R=p.useMemo(()=>[...U].sort((pe,$e)=>Wi(Qf($e))-Wi(Qf(pe))).slice(0,4),[U]),Se=p.useMemo(()=>u$(X),[X]),se=p.useMemo(()=>d$(F.inboxItems.filter(pe=>pe.status!=="closed")).slice(0,4),[F.inboxItems]),J=p.useMemo(()=>p$(F.patrolPlans,F.followUpTasks,F.overview,P),[F.followUpTasks,F.overview,F.patrolPlans,P]),Ne=p.useMemo(()=>f$(F.followUpTasks,F.overview,P),[F.followUpTasks,F.overview,P]),Ee=F.loading||I,ie=!Ee&&(!F.initialized||!M||!F.profile),xe=((Me=_==null?void 0:_.displayName)==null?void 0:Me.trim())||((ze=(Xe=F.profile)==null?void 0:Xe.displayName)==null?void 0:ze.trim())||o("shell.butlerEntry"),lt=!Q&&ne.length===0,Oe=!ie&&T===null,bt=v==="info"?n.jsxs(n.Fragment,{children:[n.jsx(Xf,{title:o("shell.butlerInfoFollowUpRecordsTitle"),emptyText:o("shell.butlerInfoFollowUpRecordsEmpty"),actionLabel:o("shell.butlerFollowUpHistoryAction"),onAction:()=>j("list"),items:R.map(pe=>{var $e,Nt,Rt;return{id:pe.id,title:(($e=pe.sessionTitle)==null?void 0:$e.trim())||pe.projectName,content:((Nt=pe.waitingReason)==null?void 0:Nt.trim())||((Rt=pe.lastAutomationSummary)==null?void 0:Rt.trim())||pe.objective||o("shell.butlerInfoFollowUpFallback",{updatedAt:Sh(Qf(pe))})}})}),n.jsx(Xf,{title:o("shell.butlerInfoVerificationRecordsTitle"),emptyText:o("shell.butlerInfoVerificationRecordsEmpty"),items:Se.map((pe,$e)=>({id:`${pe.title}:${$e}`,title:pe.title,content:pe.content}))}),n.jsx(Xf,{title:o("shell.butlerInfoTodoRecordsTitle"),emptyText:o("shell.butlerInfoTodoRecordsEmpty"),items:se.map((pe,$e)=>({id:`${pe.title}:${$e}`,title:pe.title,content:pe.content}))})]}):v==="automation"?n.jsxs(n.Fragment,{children:[n.jsx(HC,{title:o("shell.butlerAutomationTasksTitle"),emptyText:o("shell.butlerAutomationTasksEmpty"),items:J.map(pe=>({id:pe.id,title:pe.title,subtitle:pe.projectName,status:pe.statusLabel,content:`${o("shell.butlerAutomationTaskTypeLabel")} · ${pe.taskTypeLabel}`,meta:`${o("shell.butlerAutomationTaskNextRunLabel")} · ${Sh(pe.nextRunAt)}`}))}),n.jsx(HC,{title:o("shell.butlerAutomationRunsTitle"),emptyText:o("shell.butlerAutomationRunsEmpty"),items:Ne.map(pe=>({id:pe.id,title:pe.title,subtitle:pe.projectName,status:pe.statusLabel,content:`${pe.sourceLabel} · ${pe.summary}`,meta:Sh(pe.createdAt)}))})]}):n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[n.jsx("div",{className:"mobile-feature-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.butlerSidebarSettingsTab")})})}),n.jsxs("div",{className:"mobile-butler-settings-summary",children:[n.jsx(Yf,{label:o("shell.butlerDisplayNameLabel"),value:xe}),n.jsx(Yf,{label:o("shell.butlerProviderLabel"),value:VC(L)}),n.jsx(Yf,{label:o("shell.mobileButlerAssistantWorkspaceLabel"),value:((vt=F.profile)==null?void 0:vt.workspacePath)??(d==null?void 0:d.path)??"-"})]})]});c$(q,N,Oe,`${e}:${T??"none"}`);function Ct(pe){pe!==v&&r(Ui(e,pe),{replace:!0})}function nt(pe){if(pe.changedTouches.length!==1){g.current=null;return}if(Kf(pe.target)){g.current=null;return}const $e=pe.changedTouches[0];g.current={x:$e.clientX,y:$e.clientY}}function et(pe){if(pe.changedTouches.length!==1)return;const $e=g.current;g.current=null;const Nt=pe.changedTouches[0],Rt=a$($e,{x:Nt.clientX,y:Nt.clientY});Rt&&j(Rt)}function De(pe){if(pe.changedTouches.length!==1){w.current=null;return}if(Kf(pe.target)){w.current=null;return}const $e=pe.changedTouches[0];w.current={x:$e.clientX,y:$e.clientY}}function Ue(pe){const $e=w.current;if(w.current=null,!$e||pe.changedTouches.length!==1)return;const Nt=pe.changedTouches[0],Rt=Nt.clientX-$e.x,Ft=Nt.clientY-$e.y;Rt>-ew||Math.abs(Rt)<Math.abs(Ft)*tw||j(null)}function Ye(pe){if(pe.changedTouches.length!==1){k.current=null;return}if(Kf(pe.target)){k.current=null;return}const $e=pe.changedTouches[0];k.current={x:$e.clientX,y:$e.clientY}}function ye(pe){const $e=k.current;if(k.current=null,pe.changedTouches.length!==1)return;const Nt=pe.changedTouches[0],Rt=i$(v,$e,{x:Nt.clientX,y:Nt.clientY});if(Rt.closeSidebar){j(null);return}Rt.nextTab!==v&&Ct(Rt.nextTab)}async function He(pe){await E.openControlSession(pe),j(null)}async function je(){await E.startFreshSession(),j(null),l()}async function Fe(pe,$e){var Nt;(((Nt=$e==null?void 0:$e.attachments)==null?void 0:Nt.length)??0)>0&&s({title:o("shell.butlerAttachmentUnsupported"),tone:"warning"}),await E.sendMessage(pe,{model:($e==null?void 0:$e.model)??null,reasoningLevel:($e==null?void 0:$e.reasoningLevel)??null,permissionMode:null}),l()}return d?n.jsxs("main",{ref:q,className:"mobile-feature-page mobile-page-fixed-root mobile-butler-page mobile-butler-page-shell","data-mobile-butler-drawer":T??"none",children:[n.jsx(Hl,{currentWorkspace:d,workspaces:i.map(pe=>pe.workspace),heading:o("shell.mobileButlerEntry"),triggerLabel:d.name,onSelectWorkspace:pe=>{c(pe),r(Ui(pe,v))},trailing:n.jsxs("div",{className:"mobile-butler-header-trailing","data-mobile-butler-gesture":"ignore",children:[n.jsxs("div",{className:"mobile-butler-hero-top mobile-butler-toolbar-identity",children:[n.jsx("div",{className:"mobile-butler-hero-badge",children:"AI"}),n.jsxs("div",{className:"mobile-butler-hero-copy",children:[n.jsx("strong",{children:xe}),n.jsx("span",{children:VC(L)})]})]}),n.jsxs("div",{className:"mobile-butler-toolbar-actions",children:[n.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":o("shell.butlerHistoryAction"),title:o("shell.butlerHistoryAction"),onClick:()=>j("list"),children:"≡"}),n.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":o("shell.butlerSidebarTabsLabel"),title:o("shell.butlerSidebarTabsLabel"),onClick:()=>j("sidebar"),children:"ⓘ"})]})]})}),n.jsxs("div",{className:"mobile-butler-stage-shell",children:[T?n.jsx("button",{type:"button",className:"mobile-butler-drawer-scrim","aria-label":o("common.close"),onClick:()=>j(null)}):null,n.jsxs("aside",{className:"mobile-butler-drawer mobile-butler-drawer-list",style:{width:`min(88vw, ${UC}px)`},onTouchStart:De,onTouchEnd:Ue,children:[n.jsxs("div",{className:"mobile-butler-drawer-header",children:[n.jsxs("div",{children:[n.jsx("h2",{children:o("shell.butlerHistoryTitle")}),n.jsx("p",{children:o("shell.butlerHistoryDescription")})]}),n.jsx("button",{type:"button",className:"mobile-butler-toolbar-button","aria-label":o("shell.butlerNewSessionAction"),onClick:()=>{je()},children:"+"})]}),n.jsx("div",{className:"mobile-butler-list-body",children:n.jsx(l$,{activeControlSessionId:(Q==null?void 0:Q.id)??null,sessions:F.controlSessions,onSelectSession:pe=>{He(pe)}})})]}),n.jsx("div",{className:"mobile-butler-main-stage",onTouchStart:nt,onTouchEnd:et,children:Ee?n.jsx("section",{className:"mobile-butler-loading-shell",children:n.jsx(K0,{})}):ie?n.jsxs("section",{className:"mobile-butler-empty-panel",children:[n.jsx("h2",{children:o("shell.mobileButlerEmptyTitle")}),n.jsx("p",{children:o("shell.mobileButlerEmptyBody")})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-butler-chat-body",children:lt?n.jsxs("section",{className:"mobile-butler-empty-panel",children:[n.jsx("h2",{children:o("shell.butlerConversationTitle")}),n.jsx("p",{children:o("shell.butlerProjectSyncEmptyState")})]}):n.jsx("div",{className:"conversation-timeline-shell mobile-butler-timeline-shell",children:n.jsx(Nm,{sessionId:(ht=Q==null?void 0:Q.session)==null?void 0:ht.sessionId,messages:ne,historyState:Y,loadingOlderMessages:!1,hasOlderMessages:!1,provider:L,onLoadOlderMessages:()=>{},onRetryMessage:pe=>{E.retryMessage(pe)}})})}),Oe?n.jsx("div",{className:"mobile-butler-chat-composer","data-mobile-butler-gesture":"ignore",children:n.jsx(km,{capabilities:O,draftStorageId:`mobile-butler:${e}:${L}`,panelRef:D,portalContainer:z,placeholder:o("shell.butlerComposerPlaceholder",{displayName:xe}),hasActiveRun:G??!1,canInterrupt:te??!1,contextUsage:K,isSubmitting:I,isRunning:G??!1,onInterrupt:async()=>{await E.interrupt(),l()},onSend:async(pe,$e)=>{await Fe(pe,$e)}})}):null]})}),n.jsxs("aside",{className:"mobile-butler-drawer mobile-butler-drawer-sidebar",style:{width:`min(88vw, ${UC}px)`},onTouchStart:Ye,onTouchEnd:ye,children:[n.jsx("div",{className:"mobile-butler-segmented-shell","data-mobile-butler-gesture":"ignore",children:n.jsx("div",{className:"mobile-butler-segmented-control",role:"tablist","aria-label":o("shell.butlerSidebarTabsLabel"),children:xh.map(pe=>{const $e=v===pe,Nt=o(pe==="info"?"shell.butlerSidebarInfoTab":pe==="automation"?"shell.butlerSidebarAutomationTab":"shell.butlerSidebarSettingsTab");return n.jsx("button",{type:"button",role:"tab",className:"mobile-butler-segmented-button","aria-selected":$e,onClick:()=>{Ct(pe)},children:Nt},pe)})})}),n.jsx("div",{className:"mobile-page-top-body mobile-butler-body mobile-butler-sidebar-body",children:bt})]})]})]}):n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.workspaceDetailMissingTitle")}),n.jsx("p",{children:o("shell.workspaceDetailMissingBody")})]})})}function Yf({label:e,value:t}){return n.jsxs("div",{className:"mobile-butler-info-metric",children:[n.jsx("span",{children:e}),n.jsx("strong",{title:t,children:t})]})}function HC(e){return n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:e.title})}),n.jsx("span",{className:"mobile-feature-counter",children:e.items.length})]}),e.items.length>0?n.jsx("div",{className:"mobile-butler-record-list",children:e.items.map(t=>n.jsxs("article",{className:"mobile-butler-record-card",children:[n.jsxs("header",{className:"mobile-butler-record-header",children:[n.jsxs("div",{className:"mobile-butler-record-copy",children:[n.jsx("strong",{children:t.title}),t.subtitle?n.jsx("span",{children:t.subtitle}):null]}),t.status?n.jsx("span",{className:"mobile-butler-record-badge",children:t.status}):null]}),n.jsx("p",{children:t.content}),t.meta?n.jsx("footer",{children:t.meta}):null]},t.id))}):n.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function Xf(e){return n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-butler-record-section mobile-butler-record-section-compact",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:e.title})}),e.actionLabel&&e.onAction?n.jsx("button",{type:"button",className:"mobile-butler-section-action",onClick:e.onAction,children:e.actionLabel}):null]}),e.items.length>0?n.jsx("div",{className:"mobile-butler-record-list mobile-butler-record-list-compact",children:e.items.map(t=>n.jsxs("article",{className:"mobile-butler-compact-record",children:[n.jsx("span",{children:t.title}),n.jsx("strong",{children:t.content})]},t.id))}):n.jsx("p",{className:"mobile-butler-empty-text",children:e.emptyText})]})}function l$(e){return e.sessions.length===0?n.jsx("p",{className:"mobile-butler-empty-text",children:o("shell.butlerHistoryEmpty")}):n.jsx("div",{className:"mobile-butler-record-list",children:e.sessions.map(t=>{var i,l,c,d,m;const r=t.id===e.activeControlSessionId,s=((i=t.title)==null?void 0:i.trim())||((l=t.session.title)==null?void 0:l.trim())||((c=t.lastSummary)==null?void 0:c.trim())||t.sessionId;return n.jsxs("article",{className:"mobile-butler-record-card mobile-butler-history-card","data-active":r,children:[n.jsxs("header",{className:"mobile-butler-record-header",children:[n.jsxs("div",{className:"mobile-butler-record-copy",children:[n.jsx("strong",{children:s}),n.jsx("span",{children:Sh(t.updatedAt)})]}),r?n.jsx("span",{className:"mobile-butler-record-badge",children:o("shell.butlerCurrentSessionBadge")}):null]}),n.jsx("p",{children:((d=t.lastSummary)==null?void 0:d.trim())||((m=t.session.title)==null?void 0:m.trim())||t.sessionId}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{e.onSelectSession(t.id)},children:o(r?"shell.butlerCurrentSessionBadge":"shell.butlerHistoryOpenAction")})]},t.id)})})}function c$(e,t,r,s){p.useEffect(()=>{const i=e.current;if(!r||!i){i&&i.style.removeProperty("--mobile-conversation-composer-height");return}if(!t){i.style.removeProperty("--mobile-conversation-composer-height");return}const l=i,c=t;function d(){!e.current||!c.isConnected||l.style.setProperty("--mobile-conversation-composer-height",`${c.offsetHeight}px`)}d();const m=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return m==null||m.observe(c),window.addEventListener("resize",d),()=>{m==null||m.disconnect(),window.removeEventListener("resize",d),i.style.removeProperty("--mobile-conversation-composer-height")}},[t,r,s,e])}function u$(e){return[...e].filter(t=>m$(t.status)).sort((t,r)=>Wi($C(r))-Wi($C(t))).slice(0,4).map(t=>{var r,s;return{title:((r=t.targetRef)==null?void 0:r.trim())||t.verificationType,content:((s=t.summary)==null?void 0:s.trim())||o("shell.butlerInfoVerificationFallback",{status:t.status})}})}function d$(e){return e.map(t=>({title:t.title,content:`${t.projectName} · ${g$(t.status)}`}))}function h$(e){return e==="active"||e==="waiting_user"}function m$(e){return e==="queued"||e==="running"||e==="failed"}function p$(e,t,r,s){const i=new Map(((r==null?void 0:r.projects)??[]).filter(d=>s.has(d.id)).map(d=>[d.id,d.name])),l=e.filter(d=>s.has(d.projectId)).map(d=>({id:`patrol-plan:${d.id}`,title:d.name,projectName:i.get(d.projectId)??d.projectId,taskTypeLabel:zC("patrol_plan",d.triggerType),statusLabel:d.enabled?o("shell.butlerAutomationTaskEnabled"):o("shell.butlerAutomationTaskDisabled"),nextRunAt:d.nextRunAt,lastRunAt:d.lastScheduledAt})),c=t.map(d=>{var m;return{id:`follow-up:${d.id}`,title:((m=d.sessionTitle)==null?void 0:m.trim())||d.projectName,projectName:d.projectName,taskTypeLabel:zC("follow_up"),statusLabel:pR(d.status),nextRunAt:d.nextCheckAt,lastRunAt:d.lastAutomationAt||d.lastCheckedAt||d.updatedAt}});return[...l,...c].sort((d,m)=>{const f=Wi(d.nextRunAt),v=Wi(m.nextRunAt);return f!==v?f===0?1:v===0?-1:f-v:Wi(m.lastRunAt)-Wi(d.lastRunAt)}).slice(0,8)}function f$(e,t,r){const s=new Map(((t==null?void 0:t.projects)??[]).filter(c=>r.has(c.id)).map(c=>[c.id,c.name])),i=((t==null?void 0:t.patrols)??[]).filter(c=>r.has(c.projectId)).map(c=>{var d;return{id:`patrol-run:${c.id}`,title:o("shell.butlerAutomationPatrolRunTitle"),projectName:s.get(c.projectId)??c.projectId,sourceLabel:qC("patrol_run"),statusLabel:c.status,summary:((d=c.summary)==null?void 0:d.trim())||o("shell.butlerAutomationRunEmptySummary"),createdAt:c.finishedAt||c.startedAt||c.createdAt}}),l=e.flatMap(c=>(c.rounds??[]).map(d=>{var m,f;return{id:`follow-up-round:${c.id}:${d.roundNumber}`,title:`${((m=c.sessionTitle)==null?void 0:m.trim())||c.projectName} · ${o("shell.butlerAutomationRoundLabel",{round:d.roundNumber})}`,projectName:c.projectName,sourceLabel:qC("follow_up_round"),statusLabel:pR(d.status),summary:((f=d.summary)==null?void 0:f.trim())||o("shell.butlerAutomationRunEmptySummary"),createdAt:d.createdAt}}));return[...i,...l].sort((c,d)=>Wi(d.createdAt)-Wi(c.createdAt)).slice(0,10)}function g$(e){switch(e){case"pending":return o("shell.butlerInfoTodoPending");case"in_progress":return o("shell.butlerInfoTodoInProgress");case"closed":return o("shell.butlerInfoTodoClosed");default:return o("shell.butlerInfoTodoPending")}}function Qf(e){return e.updatedAt||e.lastAutomationAt||e.lastCheckedAt||e.createdAt}function pR(e){switch(e){case"active":return o("shell.butlerAutomationStatusActive");case"waiting_user":return o("shell.butlerAutomationStatusWaitingUser");case"completed":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":return o("shell.butlerAutomationStatusCancelled");default:return o("shell.butlerAutomationStatusActive")}}function zC(e,t){if(e==="follow_up")return o("shell.butlerAutomationTaskTypeFollowUp");switch(t){case"interval":return o("shell.butlerAutomationTaskTypeInterval");case"cron":return o("shell.butlerAutomationTaskTypeCron");case"manual":default:return o("shell.butlerAutomationTaskTypeManual")}}function qC(e){return o(e==="patrol_run"?"shell.butlerAutomationRunSourcePatrol":"shell.butlerAutomationRunSourceFollowUp")}function $C(e){return e.finishedAt||e.startedAt||e.createdAt}function Wi(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function Sh(e){if(!e)return"-";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function VC(e){switch(e){case"claude-code":return"Claude Code";case"codex":default:return"Codex"}}function b$(){const{shellMode:e}=Pr();return e==="mobile"?n.jsx(o$,{}):n.jsx(f3,{})}function fR({connectionState:e,onReconnect:t}){const{showToast:r,dismissToast:s}=Qn();return p.useEffect(()=>{if(e==="connected"||e==="closed"){s("conversation-connection-state");return}if(e==="reconnect_failed"){r({id:"conversation-connection-state",title:o("conversation.connectionReconnectFailed"),description:o("conversation.reconnectFailedExplain"),tone:"warning",durationMs:null,action:{label:o("conversation.reconnectButton"),onClick:t}});return}r({id:"conversation-connection-state",title:o("conversation.connectionReconnecting"),description:o("conversation.reconnectExplain"),tone:"info",durationMs:3200})},[e,s,t,r]),null}const Gd="provider-default",v$=420,w$=520,y$=32,k$=48;function x$(e){if(typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function S$(e,t){var r;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!x$(e))throw new Error(o("conversation.copyContentFailed"))}}function Kd(e,t,r){return Math.min(Math.max(e,t),r)}function Jf(e){return e&&Wc.includes(e)?e:"codex"}function wb(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function GC(e){var r,s;const t=wb(e);return((s=(r=t==null?void 0:t.closest("[data-message-id]"))==null?void 0:r.getAttribute("data-message-id"))==null?void 0:s.trim())||null}function C$(e,t){return[t.trim()||o("conversation.selectionActionDefaultPrompt"),"",o("conversation.selectionActionQuotedLabel"),"```text",e.trim(),"```"].join(`
|
|
115
|
+
`)}function Zf(e){if(typeof window>"u")return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const r=t.getRangeAt(0),s=wb(r.startContainer),i=wb(r.endContainer);if(!s||!i||!e.contains(s)||!e.contains(i))return null;const l=t.toString().trim();if(!l)return null;const c=r.getBoundingClientRect();if(!c.width&&!c.height)return null;const d=GC(r.startContainer),m=GC(r.endContainer);return{text:l,sourceMessageId:d&&d===m?d:null,rect:{left:c.left,top:c.top,right:c.right,bottom:c.bottom,width:c.width,height:c.height}}}function j$({containerRef:e,session:t,currentCapabilities:r}){const s=vr(),i=nr(),{showToast:l}=Qn(),{shellMode:c,requestNavigationRefresh:d,selectWorkspace:m,upsertNavigationSession:f}=Pr(),v=ca(ye=>ye.profile.providers),[g,w]=p.useState(null),[k,y]=p.useState(!1),[C,T]=p.useState(""),[j,N]=p.useState(!1),[D,F]=p.useState(Jf(t==null?void 0:t.provider)),[W,E]=p.useState(Gd),[I,M]=p.useState(null),[_,L]=p.useState({}),[Q,O]=p.useState(!1),[ne,Y]=p.useState(!1),[G,te]=p.useState(!1),[K,z]=p.useState(0),[q,P]=p.useState(null),[U,X]=p.useState(()=>({width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight})),R=p.useRef(!1),Se=p.useRef(!1),se=p.useRef(null),J=p.useRef(null),Ne=c==="mobile"||i.isMobile,Ee=p.useMemo(()=>ye=>{var He,je;return((je=(He=v[ye])==null?void 0:He.defaultModel)==null?void 0:je.trim())||Gd},[v]),ie=p.useMemo(()=>D===(t==null?void 0:t.provider)&&r?r:I??Ba(D),[r,I,D,t==null?void 0:t.provider]),xe=p.useMemo(()=>{var He;const ye=Ba(D).modelOptions??[];return(He=ie.modelOptions)!=null&&He.length?ie.modelOptions:ye},[ie.modelOptions,D]),lt=p.useMemo(()=>xe.find(ye=>ye.id===W)??xe[0]??null,[xe,W]),Oe=p.useMemo(()=>{const ye=_[D]??(D===(t==null?void 0:t.provider)?r:I);return!ye||ye.canStartSession!==!1?null:ye.limitations[0]??o("conversation.capabilityDenied")},[r,I,_,D,t==null?void 0:t.provider]),bt=p.useMemo(()=>{var me;if(!g||typeof window>"u")return null;const ye=(me=e.current)==null?void 0:me.getBoundingClientRect(),He=ye?Math.max(80,ye.left+80):96,je=ye?Math.min(U.width-80,ye.right-80):U.width-96,Fe=ye?Math.max(12,ye.top+12):12,Ve=ye?Math.max(Fe,ye.bottom-48):Math.max(12,U.height-48),kt=g.rect.left+g.rect.width/2;return{left:Kd(kt,He,Math.max(He,je)),top:Kd(g.rect.top-48,Fe,Ve)}},[e,g,U.height,U.width]),Ct=p.useMemo(()=>{var Nt;if(!g||typeof window>"u")return null;const ye=(Nt=e.current)==null?void 0:Nt.getBoundingClientRect(),He=(ye==null?void 0:ye.left)??0,je=(ye==null?void 0:ye.right)??U.width,Fe=(ye==null?void 0:ye.top)??0,Ve=(ye==null?void 0:ye.bottom)??U.height;if(Ne)return{left:U.width/2,top:U.height/2,width:Math.min(420,Math.max(280,U.width-24)),maxHeight:Math.max(260,U.height-y$),transform:"translate(-50%, -50%)"};const kt=Math.max(280,Math.min(U.width-24,je-He-24)),me=Math.min(420,kt),Me=g.rect.left+g.rect.width/2,Xe=Math.max(12,He+12),ze=Math.max(Xe,Math.min(U.width-me-12,je-me-12)),vt=Math.min(w$,Math.max(280,Ve-Fe-24),Math.max(280,U.height-24)),ht=Math.max(12,Fe+12),pe=Math.max(ht,Math.min(U.height-vt-12,Ve-vt-12)),$e=g.rect.top-v$-18;return{left:Kd(Me-me/2,Xe,ze),top:Kd($e,ht,pe),width:me,maxHeight:vt}},[e,Ne,g,U.height,U.width]);p.useEffect(()=>{if(typeof window>"u")return;const ye=()=>{X({width:window.innerWidth,height:window.innerHeight})};return ye(),window.addEventListener("resize",ye),()=>{window.removeEventListener("resize",ye)}},[]),p.useEffect(()=>{if(!t){J.current!==null&&typeof window<"u"&&(window.clearTimeout(J.current),J.current=null),se.current=null,Se.current=!1,w(null),y(!1);return}const ye=Jf(t.provider);F(ye),E(Ee(ye))},[Ee,t]),p.useEffect(()=>{if(!t||!e.current||typeof window>"u"){J.current!==null&&(window.clearTimeout(J.current),J.current=null),se.current=null,Se.current=!1,w(null);return}const ye=e.current,He=Xe=>{R.current||(se.current=Xe,w(Xe),Xe||y(!1))},je=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},Fe=(Xe,ze)=>{if(se.current=Xe,je(),ze!=null&&ze.immediate){He(Xe);return}J.current=window.setTimeout(()=>{J.current=null,He(se.current)},k$)},Ve=()=>{const Xe=Zf(ye);if(Se.current){se.current=Xe;return}Fe(Xe)},kt=()=>{const Xe=Zf(ye);if(Se.current){se.current=Xe;return}Fe(Xe,{immediate:!0})},me=Xe=>{!(Xe.target instanceof Node)||!ye.contains(Xe.target)||(Se.current=!0,je())},Me=()=>{Se.current&&(Se.current=!1,Fe(Zf(ye)))};return document.addEventListener("pointerdown",me),document.addEventListener("selectionchange",Ve),window.addEventListener("pointerup",Me),window.addEventListener("pointercancel",Me),window.addEventListener("mouseup",Me),window.addEventListener("touchend",Me),window.addEventListener("resize",kt),window.addEventListener("scroll",kt,!0),()=>{je(),document.removeEventListener("pointerdown",me),document.removeEventListener("selectionchange",Ve),window.removeEventListener("pointerup",Me),window.removeEventListener("pointercancel",Me),window.removeEventListener("mouseup",Me),window.removeEventListener("touchend",Me),window.removeEventListener("resize",kt),window.removeEventListener("scroll",kt,!0)}},[e,t]),p.useEffect(()=>{(!k||!(g!=null&&g.sourceMessageId))&&N(!1)},[k,g==null?void 0:g.sourceMessageId]),p.useEffect(()=>{if(!k||!t)return;let ye=!1;return D===t.provider&&r?(O(!1),M(r),()=>{ye=!0}):(O(!0),M(Ba(D)),_l(D,t.workspaceId).then(He=>{ye||M(He)}).catch(()=>{ye||M(Ba(D))}).finally(()=>{ye||O(!1)}),()=>{ye=!0})},[k,r,D,t]),p.useEffect(()=>{if(!k||!t){L({});return}let ye=!1;return yv(Wc,t.workspaceId).then(He=>{ye||L(He)}),()=>{ye=!0}},[k,t]),p.useEffect(()=>{if(!k||!t)return;const ye=Wc.filter(je=>{const Fe=_[je];return!Fe||Fe.canStartSession!==!1});if(ye.length===0||ye.includes(D))return;const He=ye[0];F(He),E(Ee(He))},[k,Ee,_,D,t]),p.useEffect(()=>{var He;const ye=Ee(D);if(!xe.some(je=>je.id===W)){if(xe.some(je=>je.id===ye)){E(ye);return}E(((He=xe[0])==null?void 0:He.id)??Gd)}},[xe,Ee,W,D]),p.useEffect(()=>{if(!k){R.current=!1;return}R.current=!0},[k]),p.useEffect(()=>{if(typeof window>"u")return;const ye=He=>{He.key==="Escape"&&(y(!1),w(null),R.current=!1)};return window.addEventListener("keydown",ye),()=>{window.removeEventListener("keydown",ye)}},[]);async function nt(){if(g)try{await S$(g.text,i),l({title:o("conversation.copyContentSuccess"),tone:"success"})}catch(ye){l({title:ye instanceof Error?ye.message:o("conversation.copyContentFailed"),tone:"error"})}}function et(){g&&(P({title:"",content:g.text}),z(ye=>ye+1),te(!0),y(!1),w(null),R.current=!1)}function De(){if(!g||!t)return;const ye=Jf(t.provider);F(ye),E(Ee(ye)),T(""),N(!1),y(!0)}async function Ue(){var ye,He,je,Fe;if(!(!g||!t)){if(Oe){l({title:Oe,tone:"error"});return}Y(!0);try{const Ve=C$(g.text,C),kt=(lt==null?void 0:lt.id)===Gd?null:(lt==null?void 0:lt.id)??null;let me=null;if(j&&g.sourceMessageId)me=await uP(t.sessionId,{sourceType:"message",sourceMessageId:g.sourceMessageId,strategy:"auto",targetProvider:D,sessionKind:"annotation",annotationSourceMessageId:g.sourceMessageId,annotationSourceText:g.text}),f(me),await Sv(me.sessionId,{content:Ve,clientRequestId:((He=(ye=globalThis.crypto)==null?void 0:ye.randomUUID)==null?void 0:He.call(ye))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:kt});else{const Me=await xv({workspaceId:t.workspaceId,provider:D,content:Ve,clientRequestId:((Fe=(je=globalThis.crypto)==null?void 0:je.randomUUID)==null?void 0:Fe.call(je))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:kt,parentSessionId:t.sessionId,sessionKind:"annotation",annotationSourceMessageId:g.sourceMessageId??null,annotationSourceText:g.text});me=Me.session??await wv(Me.sessionId)}f(me),d(),m(me.workspaceId),s(Yn(me.workspaceId,me.sessionId)),y(!1),w(null),R.current=!1}catch(Ve){l({title:Ve instanceof Error?Ve.message:o("conversation.selectionActionFailed"),tone:"error"})}finally{Y(!1)}}}function Ye(ye=!1){y(!1),R.current=!1,ye&&w(null)}return!t||!g||!bt||typeof document>"u"?n.jsx(Xg,{open:G,preferredWorkspaceId:(t==null?void 0:t.workspaceId)??null,preferredSessionId:(t==null?void 0:t.sessionId)??null,creationRequestId:K,initialDraft:q,onClose:()=>te(!1)}):n.jsxs(n.Fragment,{children:[$n.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"conversation-selection-toolbar",style:bt,onMouseDown:ye=>ye.preventDefault(),children:[n.jsx("button",{type:"button",className:"conversation-selection-action",onClick:()=>void nt(),children:o("conversation.copyAction")}),n.jsx("button",{type:"button",className:"conversation-selection-action",onClick:et,children:o("conversation.selectionTodoAction")}),n.jsx("button",{type:"button",className:"conversation-selection-action is-primary",onClick:De,children:o("conversation.selectionActionButton")})]}),k&&Ct?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`conversation-selection-dialog-backdrop${Ne?" is-mobile":""}`,onMouseDown:()=>Ye(!1)}),n.jsxs("div",{className:`conversation-selection-action-dialog${Ne?" is-centered":""}`,style:Ct,role:"dialog","aria-modal":"true","aria-label":o("conversation.selectionActionButton"),onMouseDown:ye=>ye.stopPropagation(),children:[n.jsxs("div",{className:"conversation-selection-action-dialog-header",children:[n.jsx("strong",{children:o("conversation.selectionActionButton")}),n.jsx("button",{type:"button",className:"conversation-selection-action-dialog-close","aria-label":o("common.close"),onClick:()=>Ye(!1),children:"×"})]}),n.jsx("p",{className:"conversation-selection-action-dialog-quote",children:g.text}),n.jsxs("label",{className:"conversation-selection-field",children:[n.jsx("span",{children:o("conversation.selectionActionPromptLabel")}),n.jsx("textarea",{value:C,rows:4,placeholder:o("conversation.selectionActionPromptPlaceholder"),onChange:ye=>T(ye.target.value)})]}),n.jsxs("label",{className:"conversation-selection-checkbox",children:[n.jsx("input",{type:"checkbox",checked:j,disabled:!g.sourceMessageId,onChange:ye=>N(ye.target.checked)}),n.jsx("span",{children:o("conversation.selectionActionIncludeContext")})]}),g.sourceMessageId?null:n.jsx("p",{className:"conversation-selection-hint",children:o("conversation.selectionActionContextUnavailable")}),Oe?n.jsx("p",{className:"conversation-selection-hint",children:Oe}):null,n.jsxs("div",{className:"conversation-selection-grid",children:[n.jsxs("label",{className:"conversation-selection-field",children:[n.jsx("span",{children:o("conversation.forkTargetProviderLabel")}),n.jsx("select",{value:D,onChange:ye=>{const He=ye.target.value;F(He),E(Ee(He))},children:Wc.map(ye=>{var He;return n.jsx("option",{value:ye,disabled:((He=_[ye])==null?void 0:He.canStartSession)===!1,children:qs(ye,"full")},ye)})})]}),n.jsxs("label",{className:"conversation-selection-field",children:[n.jsx("span",{children:o("conversation.forkTargetModelLabel")}),n.jsx("select",{value:W,disabled:Q||!!Oe,onChange:ye=>E(ye.target.value),children:xe.map(ye=>n.jsx("option",{value:ye.id,children:ye.name},ye.id))})]})]}),n.jsxs("div",{className:"conversation-selection-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Ye(!1),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:ne||!!Oe,onClick:()=>void Ue(),children:o(ne?"conversation.sendingState":"conversation.selectionActionSubmit")})]})]})]}):null]}),document.body),n.jsx(Xg,{open:G,preferredWorkspaceId:t.workspaceId,preferredSessionId:t.sessionId,creationRequestId:K,initialDraft:q,onClose:()=>te(!1)})]})}const T$=new Set(["abstract","as","async","await","break","case","catch","class","const","continue","default","delete","do","else","enum","export","extends","false","finally","for","from","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","readonly","return","static","super","switch","this","throw","true","try","type","typeof","undefined","var","void","while","with","yield"]),N$=new Set(["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","False","finally","for","from","global","if","import","in","is","lambda","None","nonlocal","not","or","pass","raise","return","True","try","while","with","yield"]),P$=new Set(["case","do","done","elif","else","esac","export","fi","for","function","if","in","local","readonly","return","then","until","while"]),D$=new Set(["add","alter","and","as","asc","between","by","create","delete","desc","drop","from","group","having","insert","into","join","left","like","limit","not","null","offset","on","or","order","right","select","set","table","union","update","values","where"]),R$=new Set(["add","arg","cmd","copy","entrypoint","env","expose","from","healthcheck","label","maintainer","onbuild","run","shell","stopsignal","user","volume","workdir","as"]),M$=new Set(["trace","debug","info","warn","warning","error","fatal"]);function gR({workspaceId:e,filePath:t,open:r,onClose:s,onSaved:i,diffContent:l}){const[c,d]=p.useState(null),[m,f]=p.useState(""),[v,g]=p.useState(!1),[w,k]=p.useState(!1),[y,C]=p.useState("preview"),[T,j]=p.useState("default"),[N,D]=p.useState(0),[F,W]=p.useState("fit"),[E,I]=p.useState(1),[M,_]=p.useState(1),[L,Q]=p.useState(110),[O,ne]=p.useState(!0),{showToast:Y}=Qn(),G=nr(),te=p.useRef(s),K=p.useRef(Y),z=p.useMemo(()=>rw(t),[t]),q=p.useMemo(()=>aV(l),[l]),P=(c==null?void 0:c.kind)??null,U=!!(c!=null&&c.capabilities.canEdit),X=!!(c!=null&&c.capabilities.canRefresh),R=L$(P,z),Se=p.useMemo(()=>F$(c,G.isDesktop),[G.isDesktop,c]),se=p.useMemo(()=>kb(Se,N),[Se,N]),J=p.useMemo(()=>_$(Se,N,M,L,O),[Se,N,M,L,O]),Ne=p.useMemo(()=>kb(Se,N),[Se,N]),Ee=(c==null?void 0:c.content)??"",ie=U&&m!==Ee,xe=wR(P),lt=yb(P);if(p.useEffect(()=>{te.current=s},[s]),p.useEffect(()=>{K.current=Y},[Y]),p.useEffect(()=>{if(!r){d(null),f(""),g(!1),k(!1),C(bR(t,null)),vR({setResourceRefreshVersion:D,setImageScale:I,setImageScaleMode:W,setPdfPage:_,setPdfScale:Q,setPdfFitWidth:ne}),j("default");return}if(!e||!t)return;const Ye=e,ye=t;let He=!1;async function je(){g(!0);try{const Fe=await mf(Ye,ye);He||eg(Fe,ye,{preserveMode:!1,setPreview:d,setEditorContent:f,setMode:C,setResourceRefreshVersion:D,setImageScale:I,setImageScaleMode:W,setPdfPage:_,setPdfScale:Q,setPdfFitWidth:ne})}catch(Fe){He||(K.current({title:tg(Fe,o("conversation.filePanelOpenFailed")),tone:"error"}),te.current())}finally{He||g(!1)}}return je(),()=>{He=!0}},[t,r,e]),p.useEffect(()=>{if(!r)return;function Ye(ye){ye.key==="Escape"&&s()}return window.addEventListener("keydown",Ye),()=>{window.removeEventListener("keydown",Ye)}},[s,r]),!r||!t||typeof document>"u")return null;const Oe=t,bt=e;async function Ct(){if(!(!bt||!(c!=null&&c.version)||!U)){k(!0);try{await E_(bt,Oe,m,c.version);const Ye=await mf(bt,Oe);eg(Ye,Oe,{preserveMode:!1,setPreview:d,setEditorContent:f,setMode:C,setResourceRefreshVersion:D,setImageScale:I,setImageScaleMode:W,setPdfPage:_,setPdfScale:Q,setPdfFitWidth:ne}),await i(Oe),Y({title:o("conversation.filePanelSaveSuccess"),tone:"success"})}catch(Ye){Y({title:tg(Ye,o("conversation.filePanelSaveFailed")),tone:"error"})}finally{k(!1)}}}async function nt(){if(!(!bt||!X||ie)){g(!0);try{const Ye=await mf(bt,Oe);eg(Ye,Oe,{preserveMode:!0,setPreview:d,setEditorContent:f,setMode:C,setResourceRefreshVersion:D,setImageScale:I,setImageScaleMode:W,setPdfPage:_,setPdfScale:Q,setPdfFitWidth:ne}),D(ye=>ye+1)}catch(Ye){Y({title:tg(Ye,o("conversation.fileViewerRefreshFailed")),tone:"error"})}finally{g(!1)}}}async function et(){if(!Se)return;const Ye=await G.bridge.openExternal(Se);Ye.ok||Y({title:Ye.detail??o("conversation.fileViewerOpenExternalFailed"),tone:"error"})}const De=I$({canShowPreviewTab:xe,canShowCodeTab:lt,canEdit:U}),Ue=E$({preview:c,isDirty:ie,handleRefreshPreview:nt,handleOpenExternal:et,imageScaleMode:F,imageScale:E,setImageScale:I,setImageScaleMode:W,pdfPage:M,setPdfPage:_,pdfScale:L,setPdfScale:Q,pdfFitWidth:O,setPdfFitWidth:ne});return $n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:s}),n.jsxs("section",{className:"workbench-modal-card surface-card file-viewer-modal","data-size":T,"data-resizable":G.isDesktop&&T!=="full"?"true":void 0,role:"dialog","aria-modal":"true","aria-label":t,children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:t}),n.jsx("p",{children:o("conversation.fileViewerHint").replace("{language}",R)})]}),n.jsx(Lo,{onClick:s})]}),n.jsxs("div",{className:"file-viewer-toolbar",children:[n.jsxs("div",{className:"file-viewer-toolbar-start",children:[n.jsxs("div",{className:"file-viewer-tabs",role:"tablist","aria-label":o("conversation.fileViewerModeLabel"),children:[De.includes("preview")?n.jsx("button",{type:"button",className:"file-viewer-tab","data-active":y==="preview",role:"tab","aria-selected":y==="preview",onClick:()=>C("preview"),children:o("conversation.fileViewerPreview")}):null,De.includes("code")?n.jsx("button",{type:"button",className:"file-viewer-tab","data-active":y==="code",role:"tab","aria-selected":y==="code",onClick:()=>C("code"),children:o("conversation.fileViewerCode")}):null,De.includes("edit")?n.jsx("button",{type:"button",className:"file-viewer-tab","data-active":y==="edit",role:"tab","aria-selected":y==="edit",onClick:()=>C("edit"),disabled:!U,children:o("conversation.fileViewerEdit")}):null]}),n.jsx("span",{className:"file-viewer-language",children:R})]}),n.jsxs("div",{className:"file-viewer-toolbar-end",children:[n.jsxs("div",{className:"file-viewer-size-group",role:"group","aria-label":o("conversation.fileViewerSizeLabel"),children:[n.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":T==="default",onClick:()=>j("default"),children:o("conversation.fileViewerSizeDefault")}),n.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":T==="wide",onClick:()=>j("wide"),children:o("conversation.fileViewerSizeWide")}),n.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":T==="full",onClick:()=>j("full"),children:o("conversation.fileViewerSizeFull")})]}),n.jsx("div",{className:"file-viewer-actions",children:Ue.map(Ye=>n.jsx("button",{type:"button",className:"secondary-button file-viewer-action-button","data-active":Ye.active?"true":void 0,onClick:()=>void Ye.onClick(),disabled:Ye.disabled,children:Ye.label},Ye.id))}),U?n.jsx("button",{type:"button",className:"primary-button",onClick:()=>void Ct(),disabled:!ie||w,children:o(w?"conversation.filePanelSaving":"conversation.filePanelSave")}):null]})]}),n.jsx("div",{className:"workbench-modal-body file-viewer-body",children:v?n.jsx("p",{className:"status-text",children:o("common.loading")}):(c==null?void 0:c.supported)===!1?n.jsx("p",{className:"status-text",children:c.reason??o("conversation.filePanelUnsupported")}):y==="edit"?n.jsx("textarea",{className:"file-viewer-editor","data-testid":"file-viewer-editor",value:m,onChange:Ye=>f(Ye.target.value),spellCheck:!1}):y==="preview"&&P==="html"?n.jsx(O$,{src:Ne,filePath:t}):y==="preview"&&P==="image"?n.jsx(B$,{src:se,filePath:t,scale:E,scaleMode:F}):y==="preview"&&P==="pdf"?n.jsx(W$,{src:J,filePath:t}):y==="preview"&&P==="markdown"?n.jsx(U$,{content:m}):n.jsx(yR,{content:m,language:z,overviewMarkers:q})})]})]}),document.body)}function bR(e,t){return t==="markdown"||t==="html"||t==="image"||t==="pdf"||rV(e??"")||sV(e??"")?"preview":"code"}function eg(e,t,r){r.setPreview(e),r.setEditorContent(e.content??""),r.setMode(s=>r.preserveMode&&A$(s,e.kind)?s:bR(t,e.kind)),vR(r)}function vR(e){e.setResourceRefreshVersion(0),e.setImageScale(1),e.setImageScaleMode("fit"),e.setPdfPage(1),e.setPdfScale(110),e.setPdfFitWidth(!0)}function wR(e){return e==="markdown"||e==="html"||e==="image"||e==="pdf"}function yb(e){return e==="text"||e==="markdown"||e==="html"}function A$(e,t){return e==="preview"?wR(t):yb(t)}function I$(e){const t=[];return e.canShowPreviewTab&&t.push("preview"),e.canShowCodeTab?(t.push("code"),t.push("edit")):e.canEdit&&t.push("edit"),t}function E$(e){var s;if(!((s=e.preview)!=null&&s.supported))return[];const t=[],r=!e.preview.capabilities.canRefresh||e.isDirty;return e.preview.kind==="image"&&t.push({id:"image-zoom-out",label:o("conversation.fileViewerZoomOut"),onClick:()=>{e.setImageScaleMode("custom"),e.setImageScale(i=>Math.max(.25,KC(i-.25)))}},{id:"image-zoom-in",label:o("conversation.fileViewerZoomIn"),onClick:()=>{e.setImageScaleMode("custom"),e.setImageScale(i=>Math.min(4,KC(i+.25)))}},{id:"image-fit",label:o("conversation.fileViewerFit"),active:e.imageScaleMode==="fit",onClick:()=>{e.setImageScaleMode("fit"),e.setImageScale(1)}},{id:"image-actual",label:o("conversation.fileViewerActualSize"),active:e.imageScaleMode==="actual",onClick:()=>{e.setImageScaleMode("actual"),e.setImageScale(1)}},{id:"image-refresh",label:o("conversation.fileViewerRefreshPreview"),disabled:r,onClick:e.handleRefreshPreview}),e.preview.kind==="pdf"&&t.push({id:"pdf-prev-page",label:o("conversation.fileViewerPreviousPage"),disabled:e.pdfPage<=1,onClick:()=>e.setPdfPage(i=>Math.max(1,i-1))},{id:"pdf-page-indicator",label:o("conversation.fileViewerPageIndicator").replace("{page}",String(e.pdfPage)),disabled:!0,onClick:()=>{}},{id:"pdf-next-page",label:o("conversation.fileViewerNextPage"),onClick:()=>e.setPdfPage(i=>i+1)},{id:"pdf-zoom-out",label:o("conversation.fileViewerZoomOut"),onClick:()=>{e.setPdfFitWidth(!1),e.setPdfScale(i=>Math.max(50,Math.round(i-10)))}},{id:"pdf-zoom-in",label:o("conversation.fileViewerZoomIn"),onClick:()=>{e.setPdfFitWidth(!1),e.setPdfScale(i=>Math.min(300,Math.round(i+10)))}},{id:"pdf-fit-width",label:o("conversation.fileViewerFitWidth"),active:e.pdfFitWidth,onClick:()=>e.setPdfFitWidth(!0)},{id:"pdf-refresh",label:o("conversation.fileViewerRefreshPreview"),disabled:r,onClick:e.handleRefreshPreview}),(e.preview.kind==="html"||e.preview.kind==="markdown"||e.preview.kind==="text")&&t.push({id:"text-refresh",label:o("conversation.fileViewerRefreshPreview"),disabled:r,onClick:e.handleRefreshPreview}),e.preview.previewUrl&&t.push({id:"open-external",label:o("conversation.fileViewerOpenExternal"),onClick:e.handleOpenExternal}),t}function L$(e,t){switch(e){case"image":return o("conversation.fileViewerImage");case"pdf":return o("conversation.fileViewerPdf");case"html":return"HTML";case"markdown":return"Markdown";default:return xR(t)}}function kb(e,t){if(!e)return null;const r=new URL(e,window.location.origin);return r.searchParams.set("_preview",String(t)),r.hash="",r.toString()}function F$(e,t){var r;return e?!t&&e.previewPath&&typeof window<"u"&&((r=window.location)!=null&&r.origin)?new URL(e.previewPath,window.location.origin).toString():e.previewUrl??null:null}function _$(e,t,r,s,i){const l=kb(e,t);if(!l)return null;const c=new URL(l,window.location.origin),d=new URLSearchParams;return d.set("page",String(r)),d.set("zoom",i?"page-width":String(s)),c.hash=d.toString(),c.toString()}function KC(e){return Math.round(e*100)/100}function O$({src:e,filePath:t}){return e?n.jsx("div",{className:"file-viewer-html-frame-shell",children:n.jsx("iframe",{className:"file-viewer-html-frame","data-testid":"file-viewer-html-preview",title:t,src:e,sandbox:"allow-forms allow-modals allow-scripts"},e)}):n.jsx("p",{className:"status-text",children:o("conversation.fileViewerHtmlPreviewUnavailable")})}function B$({src:e,filePath:t,scale:r,scaleMode:s}){return e?n.jsx("div",{className:"file-viewer-media-shell","data-mode":s,children:n.jsx("div",{className:"file-viewer-image-stage",children:n.jsx("img",{className:"file-viewer-image","data-testid":"file-viewer-image-preview","data-mode":s,src:e,alt:t,style:s==="fit"?void 0:{transform:`scale(${r})`}})})}):n.jsx("p",{className:"status-text",children:o("conversation.fileViewerImageUnavailable")})}function W$({src:e,filePath:t}){return e?n.jsx("div",{className:"file-viewer-pdf-shell",children:n.jsx("iframe",{className:"file-viewer-pdf-frame","data-testid":"file-viewer-pdf-preview",title:t,src:e},e)}):n.jsx("p",{className:"status-text",children:o("conversation.fileViewerPdfUnavailable")})}function U$({content:e}){return n.jsx("div",{className:"markdown-content file-viewer-markdown",children:n.jsx(l0,{remarkPlugins:[A0],components:{code(t){const r=typeof t.className=="string"?t.className:"",s=/language-([\w-]+)/.exec(r);return s?n.jsx(yR,{content:String(t.children).replace(/\n$/,""),language:sw(s[1]??"plain")}):n.jsx("code",{className:r||void 0,children:t.children})}},children:e})})}function yR({content:e,language:t,overviewMarkers:r=[]}){const s=e.split(/\r?\n/),i=p.useRef(null),l=p.useMemo(()=>{const c=new Map;for(const d of r)for(let m=0;m<d.span;m++)c.set(d.line+m,d.kind);return c},[r]);return n.jsxs("div",{className:"file-viewer-code-block",children:[n.jsx("div",{className:"file-viewer-code-header",children:xR(t)}),n.jsxs("div",{className:"file-viewer-scroll-shell",children:[n.jsx("div",{className:"file-viewer-code-body",ref:i,children:s.map((c,d)=>{const m=H$(c,t),f=d+1,v=l.get(f);return n.jsxs("div",{className:`file-viewer-code-line${v?` diff-line-${v}`:""}`,children:[n.jsx("span",{className:"file-viewer-code-gutter",children:f}),n.jsx("code",{className:"file-viewer-code-content",children:m.length?m.map((g,w)=>n.jsx("span",{className:`code-token ${g.kind}`,children:g.text},`${d}-${w}-${g.text}`)):n.jsx("span",{className:"code-token plain",children:" "})})]},`${d}-${c}`)})}),n.jsx(lV,{markers:r,totalLines:s.length,scrollContainerRef:i})]})]})}function H$(e,t){const r=sw(t);return r==="json"?z$(e):r==="yaml"?G$(e):r==="toml"?K$(e):r==="ini"?kR(e):r==="env"?Y$(e):r==="properties"?X$(e):r==="conf"?Q$(e):r==="editorconfig"?J$(e):r==="dockerfile"?Z$(e):r==="gitignore"?eV(e):r==="log"?tV(e):r==="python"?Yc(e,N$,"#"):r==="shell"?Yc(e,P$,"#"):r==="sql"?V$(e):r==="html"||r==="xml"?q$(e):r==="css"?$$(e):r==="markdown"?[{text:e,kind:"plain"}]:Yc(e,T$,"//")}function Yc(e,t,r){const s=[];let i=0;for(;i<e.length;){const l=e.slice(i);if(l.startsWith(r)){s.push({text:l,kind:"comment"});break}const c=/^(?:'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"|`[^`\\]*(?:\\.[^`\\]*)*`)/.exec(l);if(c){s.push({text:c[0],kind:"string"}),i+=c[0].length;continue}const d=/^(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/.exec(l);if(d){s.push({text:d[0],kind:"number"}),i+=d[0].length;continue}const m=/^[A-Za-z_][\w$-]*/.exec(l);if(m){const v=m[0],g=v.toLowerCase();v==="true"||v==="false"||g==="true"||g==="false"?s.push({text:v,kind:"boolean"}):v==="null"||v==="None"||g==="none"?s.push({text:v,kind:"null"}):t.has(v)||t.has(g)?s.push({text:v,kind:"keyword"}):s.push({text:v,kind:"plain"}),i+=v.length;continue}const f=/^(?:===|!==|==|!=|<=|>=|=>|&&|\|\||[+\-*/%=<>!?:|&^~]+)/.exec(l);if(f){s.push({text:f[0],kind:"operator"}),i+=f[0].length;continue}s.push({text:l[0]??"",kind:"plain"}),i+=1}return s}function z$(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r),i=/^"(?:[^"\\]|\\.)*"/.exec(s);if(i){const m=e.slice(r+i[0].length).trimStart()[0];t.push({text:i[0],kind:m===":"?"attr":"string"}),r+=i[0].length;continue}const l=/^(?:-?\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i.exec(s);if(l){t.push({text:l[0],kind:"number"}),r+=l[0].length;continue}const c=/^(?:true|false|null)\b/.exec(s);if(c){const m=c[0]==="null"?"null":"boolean";t.push({text:c[0],kind:m}),r+=c[0].length;continue}const d=/^(?::|,|\{|\}|\[|\])/.exec(s);if(d){t.push({text:d[0],kind:"operator"}),r+=d[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function q$(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r);if(s.startsWith("<!--")){t.push({text:s,kind:"comment"});break}const i=/^(<\/?[\w:-]+)/.exec(s);if(i){t.push({text:i[0],kind:"tag"}),r+=i[0].length;continue}const l=/^([\w:-]+)(=)/.exec(s);if(l){t.push({text:l[1]??"",kind:"attr"}),t.push({text:l[2]??"",kind:"operator"}),r+=l[0].length;continue}const c=/^(?:'[^']*'|"[^"]*")/.exec(s);if(c){t.push({text:c[0],kind:"string"}),r+=c[0].length;continue}const d=/^(?:\/?>)/.exec(s);if(d){t.push({text:d[0],kind:"operator"}),r+=d[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function $$(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r);if(s.startsWith("/*")){t.push({text:s,kind:"comment"});break}const i=/^(?:'[^']*'|"[^"]*")/.exec(s);if(i){t.push({text:i[0],kind:"string"}),r+=i[0].length;continue}const l=/^([A-Za-z-]+)(\s*:)/.exec(s);if(l){t.push({text:l[1]??"",kind:"attr"}),t.push({text:l[2]??"",kind:"operator"}),r+=l[0].length;continue}const c=/^(?:#(?:[\da-fA-F]{3,8})|\d+(?:\.\d+)?(?:px|rem|em|vh|vw|%)?)/.exec(s);if(c){t.push({text:c[0],kind:"number"}),r+=c[0].length;continue}const d=/^(?:@media|@supports|@import|@keyframes)\b/.exec(s);if(d){t.push({text:d[0],kind:"keyword"}),r+=d[0].length;continue}const m=/^(?:[{}:;(),.>])/.exec(s);if(m){t.push({text:m[0],kind:"operator"}),r+=m[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function V$(e){return Yc(e,D$,"--")}function G$(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r);if(s.startsWith("#")){t.push({text:s,kind:"comment"});break}const i=/^([A-Za-z0-9_.-]+)(\s*:)/.exec(s);if(i){t.push({text:i[1]??"",kind:"attr"}),t.push({text:i[2]??"",kind:"operator"}),r+=i[0].length;continue}const l=/^(?:'[^']*'|"[^"]*")/.exec(s);if(l){t.push({text:l[0],kind:"string"}),r+=l[0].length;continue}const c=/^(?:-?\d+(?:\.\d+)?)/.exec(s);if(c){t.push({text:c[0],kind:"number"}),r+=c[0].length;continue}const d=/^(?:true|false|yes|no|null|~)\b/i.exec(s);if(d){const f=d[0].toLowerCase(),v=f==="null"||f==="~"?"null":"boolean";t.push({text:d[0],kind:v}),r+=d[0].length;continue}const m=/^(?:[-?:,[\]{}|>])/.exec(s);if(m){t.push({text:m[0],kind:"operator"}),r+=m[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function K$(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r);if(s.startsWith("#")){t.push({text:s,kind:"comment"});break}const i=/^(\[\[?[^\]]+\]?\])/.exec(s);if(i){t.push({text:i[0],kind:"tag"}),r+=i[0].length;continue}const l=/^([A-Za-z0-9_.-]+)(\s*=)/.exec(s);if(l){t.push({text:l[1]??"",kind:"attr"}),t.push({text:l[2]??"",kind:"operator"}),r+=l[0].length;continue}const c=Rm(s,{trueValues:["true"],falseValues:["false"],nullValues:[]});if(c){t.push(...c.tokens),r+=c.length;continue}const d=/^(?:[,[\]{}])/.exec(s);if(d){t.push({text:d[0],kind:"operator"}),r+=d[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function kR(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r),i=s.trimStart();if(i.startsWith(";")||i.startsWith("#")){t.push({text:s,kind:"comment"});break}const l=/^(\[[^\]]+\])/.exec(s);if(l){t.push({text:l[0],kind:"tag"}),r+=l[0].length;continue}const c=/^([A-Za-z0-9_.-]+)(\s*[=:])/.exec(s);if(c){t.push({text:c[1]??"",kind:"attr"}),t.push({text:c[2]??"",kind:"operator"}),r+=c[0].length;continue}const d=Rm(s,{trueValues:["true","yes","on"],falseValues:["false","no","off"],nullValues:["null"]});if(d){t.push(...d.tokens),r+=d.length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function Y$(e){if(e.trimStart().startsWith("#"))return[{text:e,kind:"comment"}];const r=/^(\s*)(export)(\s+)/.exec(e),s=r?r[0].length:0,i=[];r&&(i.push({text:r[1]??"",kind:"plain"}),i.push({text:r[2]??"",kind:"keyword"}),i.push({text:r[3]??"",kind:"plain"}));const l=e.slice(s),c=/^([A-Za-z_][A-Za-z0-9_]*)(=)/.exec(l);if(!c)return kR(e);i.push({text:c[1]??"",kind:"attr"}),i.push({text:c[2]??"",kind:"operator"});const d=l.slice(c[0].length),m=Rm(d,{trueValues:["true"],falseValues:["false"],nullValues:["null"]});return m?(i.push(...m.tokens),i):(i.push({text:d,kind:"plain"}),i)}function X$(e){return nw(e,{commentPrefixes:["#","!"],allowSection:!1,delimiters:["=",":"]})}function Q$(e){return nw(e,{commentPrefixes:["#",";"],allowSection:!0,delimiters:["=",":"]})}function J$(e){return nw(e,{commentPrefixes:["#",";"],allowSection:!0,delimiters:["="]})}function Z$(e){return Yc(e,R$,"#")}function eV(e){const t=e.trimStart();if(!t)return[];if(t.startsWith("#"))return[{text:e,kind:"comment"}];if(t.startsWith("!")){const r=e.length-t.length,s=e.slice(0,r),i=t.slice(1);return[{text:s,kind:"plain"},{text:"!",kind:"operator"},{text:i,kind:"string"}]}return[{text:e,kind:"string"}]}function tV(e){const t=[];let r=0;for(;r<e.length;){const s=e.slice(r);if(s.startsWith("#")){t.push({text:s,kind:"comment"});break}const i=/^(?:\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:[.,]\d{3,6})?(?:Z|[+-]\d{2}:\d{2})?)/.exec(s);if(i){t.push({text:i[0],kind:"tag"}),r+=i[0].length;continue}const l=/^(?:\[(TRACE|DEBUG|INFO|WARN|WARNING|ERROR|FATAL)\])/.exec(s);if(l){t.push({text:s.slice(0,l[0].length),kind:"keyword"}),r+=l[0].length;continue}const c=/^[A-Za-z_][\w-]*/.exec(s);if(c){const m=c[0];M$.has(m.toLowerCase())?t.push({text:m,kind:"keyword"}):t.push({text:m,kind:"plain"}),r+=m.length;continue}const d=/^(?:\d+(?:\.\d+)?)/.exec(s);if(d){t.push({text:d[0],kind:"number"}),r+=d[0].length;continue}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function nw(e,t){const r=e.trimStart();if(t.commentPrefixes.some(m=>r.startsWith(m)))return[{text:e,kind:"comment"}];if(t.allowSection){const m=/^(\[[^\]]+\])/.exec(e);if(m)return[{text:m[0],kind:"tag"}]}const s=/^([A-Za-z0-9_.\-*?]+)(\s*(?:=|:))/.exec(e);if(!s)return[{text:e,kind:"plain"}];const i=(s[2]??"").trim();if(!t.delimiters.includes(i))return[{text:e,kind:"plain"}];const l=[{text:s[1]??"",kind:"attr"},{text:s[2]??"",kind:"operator"}],c=e.slice(s[0].length),d=nV(c);return d.length&&l.push(...d),l}function nV(e){if(!e)return[];const t=[];let r=0;for(;r<e.length;){const s=e.slice(r),i=Rm(s,{trueValues:["true","yes","on"],falseValues:["false","no","off"],nullValues:["null"]});if(i){t.push(...i.tokens),r+=i.length;continue}if(s.startsWith("#")||s.startsWith(";")){t.push({text:s,kind:"comment"});break}t.push({text:s[0]??"",kind:"plain"}),r+=1}return t}function Rm(e,t){const r=/^(?:'[^']*'|"[^"]*")/.exec(e);if(r)return{tokens:[{text:r[0],kind:"string"}],length:r[0].length};const s=/^(?:-?\d+(?:\.\d+)?)/.exec(e);if(s)return{tokens:[{text:s[0],kind:"number"}],length:s[0].length};const i=/^[A-Za-z0-9_.:+/-]+/.exec(e);if(!i)return null;const l=i[0],c=l.toLowerCase();return t.trueValues.includes(c)?{tokens:[{text:l,kind:"boolean"}],length:l.length}:t.falseValues.includes(c)?{tokens:[{text:l,kind:"boolean"}],length:l.length}:t.nullValues.includes(c)?{tokens:[{text:l,kind:"null"}],length:l.length}:{tokens:[{text:l,kind:"plain"}],length:l.length}}function rw(e){var s,i;if(!e)return"plain";const t=((s=e.split(/[\\/]/).pop())==null?void 0:s.toLowerCase())??"";if(t===".env"||t.startsWith(".env."))return"env";if(t===".editorconfig")return"editorconfig";if(t==="dockerfile"||t.endsWith(".dockerfile"))return"dockerfile";if(t===".gitignore")return"gitignore";switch(((i=e.split(".").pop())==null?void 0:i.toLowerCase())??""){case"md":case"markdown":return"markdown";case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"log":return"log";case"properties":return"properties";case"toml":return"toml";case"ini":return"ini";case"conf":return"conf";case"dockerfile":return"dockerfile";case"css":case"scss":case"less":return"css";case"html":case"htm":return"html";case"xml":case"svg":return"xml";case"py":return"python";case"sh":case"bash":case"zsh":return"shell";case"sql":return"sql";case"yml":case"yaml":return"yaml";case"rs":return"rust";case"go":return"go";case"java":return"java";case"c":case"h":case"cpp":case"cc":case"hpp":return"cpp";default:return"plain"}}function sw(e){const t=e.toLowerCase();switch(t){case"ts":case"tsx":case"typescript":return"typescript";case"js":case"jsx":case"javascript":return"javascript";case"bash":case"shell":case"sh":case"zsh":return"shell";case"md":case"markdown":return"markdown";case"properties":return"properties";case"toml":return"toml";case"ini":return"ini";case"env":return"env";case"conf":return"conf";case"editorconfig":return"editorconfig";case"dockerfile":return"dockerfile";case"gitignore":return"gitignore";case"log":return"log";default:return t}}function xR(e){switch(sw(e)){case"typescript":return"TypeScript";case"javascript":return"JavaScript";case"markdown":return"Markdown";case"json":return"JSON";case"properties":return"Properties";case"toml":return"TOML";case"ini":return"INI";case"env":return"ENV";case"conf":return"CONF";case"editorconfig":return"EditorConfig";case"dockerfile":return"Dockerfile";case"gitignore":return"GitIgnore";case"log":return"Log";case"css":return"CSS";case"html":return"HTML";case"xml":return"XML";case"python":return"Python";case"shell":return"Shell";case"sql":return"SQL";case"yaml":return"YAML";case"rust":return"Rust";case"go":return"Go";case"java":return"Java";case"cpp":return"C/C++";default:return o("conversation.fileViewerPlainText")}}function rV(e){return rw(e)==="markdown"}function sV(e){return rw(e)==="html"}function tg(e,t){return e instanceof Ur?e.message:t}function iV(e){const t=[],r=e.replace(/\r\n/g,`
|
|
116
|
+
`).split(`
|
|
117
|
+
`);let s=0,i=0;for(const l of r){if(l.startsWith("diff --git")||l.startsWith("index ")||l.startsWith("--- ")||l.startsWith("+++ ")){t.push({kind:"meta",text:l,oldLineNo:null,newLineNo:null});continue}const c=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(l);if(c){s=parseInt(c[1],10),i=parseInt(c[2],10),t.push({kind:"hunk",text:l,oldLineNo:null,newLineNo:null});continue}if(l.startsWith(" ")||l===""){t.push({kind:"context",text:l.slice(1),oldLineNo:s,newLineNo:i}),s++,i++;continue}if(l.startsWith("+")){t.push({kind:"add",text:l.slice(1),oldLineNo:null,newLineNo:i}),i++;continue}if(l.startsWith("-")){t.push({kind:"remove",text:l.slice(1),oldLineNo:s,newLineNo:null}),s++;continue}t.push({kind:"meta",text:l,oldLineNo:null,newLineNo:null})}return t}function aV(e){if(!(e!=null&&e.trim()))return[];const t=iV(e),r=[];let s=0,i=[];function l(){if(i.length===0){s=0;return}const c=s>0?"modify":"add";oV(r,i,c),s=0,i=[]}for(const c of t){if(c.kind==="remove"){s+=1;continue}if(c.kind==="add"){c.newLineNo!==null&&i.push(c.newLineNo);continue}l()}return l(),r}function oV(e,t,r){const s=t.filter(c=>c>0);if(s.length===0)return;let i=s[0]??1,l=i;for(let c=1;c<s.length;c+=1){const d=s[c]??l;if(d===l+1){l=d;continue}e.push({line:i,span:l-i+1,kind:r}),i=d,l=d}e.push({line:i,span:l-i+1,kind:r})}function lV({markers:e,totalLines:t,scrollContainerRef:r}){const[s,i]=p.useState({top:0,height:0});if(p.useEffect(()=>{const c=r.current;if(!c){i({top:0,height:0});return}const d=c;function m(){const{clientHeight:f,scrollHeight:v,scrollTop:g}=d;if(v<=0||f<=0||v<=f){i({top:0,height:0});return}const w=f/v,k=Math.min(100,Math.max(12,w*100)),y=v-f,C=Math.max(0,100-k),T=y<=0?0:g/y*C;i({top:T,height:k})}return m(),d.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",m),()=>{d.removeEventListener("scroll",m),window.removeEventListener("resize",m)}},[r]),e.length===0&&s.height===0)return null;const l=Math.max(t,1);return n.jsxs("div",{className:"file-overview-ruler","data-testid":"file-overview-ruler","aria-hidden":"true",children:[e.map(c=>{const d=(c.line-1)/l*100,m=Math.max(2,c.span/l*100);return n.jsx("div",{className:`file-overview-marker is-${c.kind}`,"data-kind":c.kind,style:{top:`${d}%`,height:`${m}%`}},`${c.kind}-${c.line}-${c.span}`)}),s.height>0?n.jsx("div",{className:"file-overview-viewport",style:{top:`${s.top}%`,height:`${s.height}%`}}):null]})}function Ao(e){const t=e.toLowerCase();if(t===".env"||t.startsWith(".env."))return"ENV";if(t.endsWith(".d.ts"))return"DTS";switch(t.includes(".")?t.slice(t.lastIndexOf(".")+1):""){case"ts":return"TS";case"tsx":return"TSX";case"js":return"JS";case"jsx":return"JSX";case"json":return"{}";case"md":return"MD";case"css":return"CSS";case"scss":return"SASS";case"html":return"HTML";case"yml":case"yaml":return"YAML";case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return"IMG";case"txt":return"TXT";default:return"FILE"}}function Io(e){const t=e.toLowerCase();return t===".env"||t.startsWith(".env.")?"env":t.endsWith(".md")?"md":t.endsWith(".css")||t.endsWith(".scss")?"style":t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".gif")||t.endsWith(".svg")||t.endsWith(".webp")?"image":t.endsWith(".ts")||t.endsWith(".tsx")||t.endsWith(".js")||t.endsWith(".jsx")?"code":t.endsWith(".json")||t.endsWith(".yml")||t.endsWith(".yaml")?"data":"default"}const cV=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),uV=["._"];function ng(e){return e.split(/[/\\]/).filter(Boolean).pop()??e}function dV(e){const t=e.trim().toLowerCase();return t?cV.has(t)||uV.some(r=>t.startsWith(r)):!1}function iw(e,t,r){return r?[...e]:e.filter(s=>!dV(t(s)))}function Ch(e,t){return iw(e,r=>r.name,t)}function hV(e,t){return t?e:Object.entries(e).reduce((r,[s,i])=>(r[s]=Ch(i,!1),r),{})}async function rg(e,t){const[r,s]=await Promise.all([hP(t),VF(e)]);return mV(r.changes,s.items)}function mV(e,t){const r=new Set(t.map(s=>Th(s.path)));return e.filter(s=>r.has(Th(s.path))||s.oldPath!==null&&r.has(Th(s.oldPath)))}function pV(e){const t=YC("","");for(const r of e){const s=Th(r.path),i=s.split("/").filter(Boolean);let l=t;i.forEach((c,d)=>{const m=i.slice(0,d+1).join("/");if(d===i.length-1){l.children.set(`file:${m}`,{kind:"file",name:c,path:s,change:r});return}const f=`directory:${m}`,v=l.children.get(f);if(v&&v.kind==="directory"){l=v;return}const g=YC(c,m);l.children.set(f,g),l=g})}return jR(CR([...t.children.values()]))}function SR(e,t){const r=e.oldPath?`${e.oldPath} -> ${e.path}`:e.path;return aw(e)?`${r} ${t}`:r}function aw(e){return e.status==="D"||e.stagedStatus==="D"||e.worktreeStatus==="D"}function jh(e){return e.split("/").filter(Boolean).pop()??e}function Th(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function YC(e,t){return{kind:"directory",name:e,path:t,children:new Map}}function CR(e){return[...e].sort((t,r)=>t.kind!==r.kind?t.kind==="directory"?-1:1:t.name.localeCompare(r.name,"zh-CN")).map(t=>t.kind==="directory"?{kind:"directory",name:t.name,path:t.path,children:CR([...t.children.values()])}:t)}function jR(e){return e.map(t=>{var c;if(t.kind!=="directory")return t;const r=jR(t.children);let s=t.name,i=t.path,l=r;for(;l.length===1&&((c=l[0])==null?void 0:c.kind)==="directory";){const d=l[0];s=`${s}/${d.name}`,i=d.path,l=d.children}return{kind:"directory",name:s,path:i,children:l}})}const fV=450,gV=60*1e3,XC=20,QC=16;function bV({sessionId:e,workspaceId:t,showSystemFiles:r,selectedPath:s,refreshVersion:i,onCountChange:l,onSelectFile:c,onOpenFile:d}){const[m,f]=p.useState("tree"),[v,g]=p.useState([]),[w,k]=p.useState(!0),[y,C]=p.useState(!1),[T,j]=p.useState([]),N=p.useRef(null),{showToast:D}=Qn();p.useEffect(()=>{const ne=Er(Yd(t,e),gV);f("tree"),g(ne??[]),k(ne===null),C(!1),j([]),N.current=null},[e,t]),p.useEffect(()=>{let ne=!1;async function Y(){k(!0);try{const G=await rg(e,t);ne||(g(G),As(Yd(t,e),G))}catch(G){ne||D({title:sg(G,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{ne||k(!1)}}return Y(),()=>{ne=!0}},[i,e,D,t]);async function F(){k(!0);try{const ne=await rg(e,t);g(ne),As(Yd(t,e),ne)}catch(ne){D({title:sg(ne,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{k(!1)}}async function W(){if(L.length!==0){C(!0);try{await pP(t,L.map(Y=>Y.path));const ne=await rg(e,t);g(ne),As(Yd(t,e),ne),D({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(ne){D({title:sg(ne,o("git.stageFailed")),tone:"error"})}finally{C(!1)}}}function E(ne){j(Y=>Y.includes(ne)?Y.filter(G=>G!==ne):[...Y,ne])}function I(ne){const Y=Date.now(),G=N.current;return N.current={filePath:ne,timestamp:Y},(G==null?void 0:G.filePath)===ne&&Y-G.timestamp<=fV}async function M(ne,Y){if(Y&&I(ne)){await d(ne),N.current=null;return}Y||(N.current=null),await c(ne)}const _=p.useMemo(()=>iw(v,ne=>jh(ne.path),r),[v,r]),L=_.filter(ne=>!ne.staged),Q=pV(_),O=new Set(T);return p.useEffect(()=>{l==null||l(_.length)},[l,_.length]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"file-panel-session-toolbar",children:[n.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[n.jsx("button",{className:m==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":m==="tree",onClick:()=>f("tree"),children:o("conversation.filePanelSessionTreeView")}),n.jsx("button",{className:m==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":m==="list",onClick:()=>f("list"),children:o("conversation.filePanelSessionListView")})]}),n.jsxs("div",{className:"file-panel-session-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void F(),disabled:w||y,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"primary-button",type:"button",onClick:()=>void W(),disabled:y||L.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),n.jsxs("div",{className:"file-panel-session-summary",children:[n.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${_.length}`}),n.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${L.length}`})]}),n.jsx("div",{className:"file-tree",children:w?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):_.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):m==="tree"?TR({nodes:Q,depth:0,collapsedPathSet:O,selectedPath:s,onToggleTreePath:E,onFileClick:M}):vV({items:_,selectedPath:s,onFileClick:M})})]})}function TR({nodes:e,depth:t,collapsedPathSet:r,selectedPath:s,onToggleTreePath:i,onFileClick:l}){return e.map(c=>{if(c.kind==="directory"){const d=!r.has(c.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":d,style:{paddingInlineStart:`${XC+t*QC}px`},onClick:()=>i(c.path),children:[n.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:d?"v":">"}),n.jsx("span",{className:"file-tree-label",children:c.name})]}),d?n.jsx("div",{className:"file-tree-children",children:TR({nodes:c.children,depth:t+1,collapsedPathSet:r,selectedPath:s,onToggleTreePath:i,onFileClick:l})}):null]},`session-directory:${c.path}`)}return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===c.change.path,"data-kind":"file",style:{paddingInlineStart:`${XC+t*QC}px`},onClick:()=>void l(c.change.path,!aw(c.change)),children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(c.name),"aria-hidden":"true",children:Ao(c.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:c.name}),n.jsx("span",{className:"file-tree-path",children:SR(c.change,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":c.change.status,children:c.change.status}),n.jsx("span",{className:"file-session-badge subtle",children:c.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${c.path}`)})}function vV({items:e,selectedPath:t,onFileClick:r}){return e.map(s=>n.jsx("div",{className:"file-session-list-item",children:n.jsxs("button",{className:"file-session-list-button",type:"button","data-active":t===s.path,onClick:()=>void r(s.path,!aw(s)),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(jh(s.path)),"aria-hidden":"true",children:Ao(jh(s.path))}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:jh(s.path)}),n.jsx("span",{className:"file-tree-path",children:SR(s,o("conversation.filePanelSessionDeleted"))})]}),n.jsxs("span",{className:"file-session-item-meta",children:[n.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),n.jsx("span",{className:"file-session-badge subtle",children:s.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Yd(e,t){return`file-panel.session-changes.${e}.${t}`}function sg(e,t){return e instanceof Ur?e.message:typeof e=="object"&&e&&"message"in e?String(e.message??t):t}const fr="",wV=450,Li=8,Xd=4,yV=176,kV=120,xV=300*1e3,SV=60*1e3,JC=1600,CV=20,jV=16;function ow({className:e,sessionId:t,workspaceId:r,hideHeading:s=!1,externalRevealRequest:i=null,externalWindowMode:l=!1,workbenchShellOverrides:c}){var Xt,Cr;const d=Pr(),{navigationGroups:m,subscribeFileTree:f,requestFileTreeRefresh:v,addFileTreeSnapshotListener:g,subscribeGitSnapshot:w,requestGitRefresh:k,addGitSnapshotListener:y}={...d,...c},[C,T]=p.useState({}),[j,N]=p.useState([]),[D,F]=p.useState([]),[W,E]=p.useState(fr),[I,M]=p.useState([]),[_,L]=p.useState(null),[Q,O]=p.useState(!1),[ne,Y]=p.useState(!1),[G,te]=p.useState(!1),[K,z]=p.useState(!1),[q,P]=p.useState(""),[U,X]=p.useState(null),[R,Se]=p.useState(!1),[se,J]=p.useState(null),[Ne,Ee]=p.useState("workspace"),[ie,xe]=p.useState(0),[lt,Oe]=p.useState(0),[bt,Ct]=p.useState(!1),[nt,et]=p.useState(!1),[De,Ue]=p.useState(null),[Ye,ye]=p.useState(null),[He,je]=p.useState(null),[Fe,Ve]=p.useState(null),[kt,me]=p.useState([]),[Me,Xe]=p.useState(!1),[ze,vt]=p.useState(null),ht=p.useRef({}),pe=p.useRef([]),$e=p.useRef(fr),Nt=p.useRef(!1),Rt=p.useRef(null),Ft=p.useRef(null),Wt=p.useRef(null),Kt=p.useRef(null),un=p.useRef(null),ae=p.useRef(null),Be=p.useRef(0),It=p.useRef(new Map),{showToast:jt}=Qn(),Cn=nr(),on=ai(V=>V.showSystemFiles),Wn=!!(t!=null&&t.trim()),Rn=s&&Cn.isMobile;p.useEffect(()=>{Ot("file_panel.props",{sessionId:t,workspaceId:r,externalWindowMode:l})},[l,t,r]),p.useEffect(()=>{$e.current=W},[W]);function $t(V){T(fe=>{const ve=typeof V=="function"?V(fe):V;return ht.current=ve,ve})}function dn(V){N(fe=>{const ve=typeof V=="function"?V(fe):V;return pe.current=ve,ve})}p.useEffect(()=>{var tt,Tt;if(Nn(),!r){Nn(),Nt.current=!1,ht.current={},pe.current=[],$e.current=fr,$t({}),dn([]),F([]),E(fr),z(!1),P(""),X(null),Se(!1),O(!1),Xe(!1),vt(null),M([]),L(null),Ue(null),ye(null),je(null);return}Nt.current=!0;const V=Er(rj(r),xV);Ot("file_panel.workspace_snapshot",{workspaceId:r,cached:!!V,cachedRootItems:((Tt=(tt=V==null?void 0:V.treeCache)==null?void 0:tt[fr])==null?void 0:Tt.length)??0,cachedDirectoryCount:Object.keys((V==null?void 0:V.treeCache)??{}).length});const fe=UV((V==null?void 0:V.activeDirectoryPath)??fr,(V==null?void 0:V.treeCache)??{}),ve=nj((V==null?void 0:V.expandedDirectories)??[],fe),it=Zd((V==null?void 0:V.treeCache)??{},fe,ve);ht.current=it,pe.current=ve,$e.current=fe,$t(it),dn(ve),F([]),E(fe),O(!1),Y(!1),z(!1),P(""),X(null),Se(!1),queueMicrotask(()=>{Nt.current=!1})},[r]),p.useEffect(()=>{if(!i||i.workspaceId!==r)return;const V=()=>{if(ae.current===i.requestId)return;ae.current=i.requestId,Ee("workspace"),(i.openViewer?zn(i.filePath):Vn(i.filePath)).catch(ve=>{jt({title:Fi(ve,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(Nt.current){queueMicrotask(V);return}V()},[i,zn,Vn,jt,r]),p.useEffect(()=>{if(r)return g(V=>{V.workspaceId===r&&($t(fe=>({...fe,[V.path]:V.items})),V.path===fr&&O(!1),F(fe=>fe.filter(ve=>ve!==V.path)),yn(V.path,V.items))})},[g,r]),p.useEffect(()=>()=>{Nn()},[]),p.useEffect(()=>{r&&f(r,ag(pe.current,$e.current))},[W,j,f,r]),p.useEffect(()=>{M([]),L(null),J(null),vt(null),xe(0),Ct(!1),et(!1),Ue(null),ye(null),je(null),Rt.current=null,Be.current+=1},[t]),p.useEffect(()=>{!Wn&&Ne==="session"&&Ee("workspace")},[Ne,Wn]),p.useEffect(()=>{if(!bt&&!nt&&!De)return;function V(ve){var cn,In,Hn;if(!(ve.target instanceof Node))return;const it=((cn=Ft.current)==null?void 0:cn.contains(ve.target))??!1,tt=((In=Wt.current)==null?void 0:In.contains(ve.target))??!1,Tt=((Hn=Kt.current)==null?void 0:Hn.contains(ve.target))??!1;!it&&!tt&&!Tt&&(Ct(!1),et(!1),Ue(null),ye(null))}function fe(ve){ve.key==="Escape"&&(Ct(!1),et(!1),Ue(null),ye(null))}return document.addEventListener("pointerdown",V),document.addEventListener("keydown",fe),()=>{document.removeEventListener("pointerdown",V),document.removeEventListener("keydown",fe)}},[bt,nt,De]),p.useLayoutEffect(()=>{if(!De||typeof window>"u"){ye(null);return}const V=De;function fe(){const it=Kt.current;if(!it)return;const tt=it.getBoundingClientRect();ye(IV({x:V.positionX,y:V.positionY},{width:tt.width||yV,height:tt.height||it.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}fe();const ve=window.requestAnimationFrame(fe);return window.addEventListener("resize",fe),window.addEventListener("scroll",fe,!0),()=>{window.cancelAnimationFrame(ve),window.removeEventListener("resize",fe),window.removeEventListener("scroll",fe,!0)}},[De]),p.useEffect(()=>{if(!r)return;const V=nj(j,W),fe=Zd(C,W,V);As(rj(r),{treeCache:fe,expandedDirectories:V,activeDirectoryPath:W})},[W,j,C,r]),p.useEffect(()=>{if(Nt.current)return;const V=Zd(C,W,j);zV(C,V)||$t(V)},[W,j,C]),p.useEffect(()=>{let V=!1;const fe=(r==null?void 0:r.trim())??null;async function ve(tt){if(!fe)return;const Tt=Ch(ht.current[fr]??[],on),cn=(tt==null?void 0:tt.silent)!==!0&&Tt.length===0;cn&&O(!0),Ot("file_panel.load_root_tree.start",{sessionId:t,workspaceId:fe,silent:(tt==null?void 0:tt.silent)===!0,cachedRootItems:Tt.length});try{const In=await ur(fr,{force:!0});V||(Ot("file_panel.load_root_tree.end",{sessionId:t,workspaceId:fe,itemCount:In.length}),$t(Hn=>({...Zd(Hn,$e.current,pe.current),[fr]:In})))}catch(In){!V&&!sj(In)&&jt({title:Fi(In,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!V&&cn&&O(!1)}}if(Ch(ht.current[fr]??[],on).length>0){const tt=window.setTimeout(()=>{fe&&(f(fe,ag(pe.current,$e.current)),ve({silent:!0}))},1500);return()=>{V=!0,window.clearTimeout(tt)}}return ve(),()=>{V=!0}},[t,on,jt,r]),p.useEffect(()=>{if(!r||!t){Oe(0);return}const V=Er(qV(r,t),SV);Ot("file_panel.session_change_count.snapshot",{sessionId:t,workspaceId:r,cached:V!==null,cachedCount:V}),Oe(V??0)},[t,ie,r]),p.useEffect(()=>{if(!r){me([]);return}const V=r.trim();w(V),k(V)},[r,w,k]),p.useEffect(()=>{if(!r)return;const V=r.trim();return y(fe=>{var ve;fe.workspaceId===V&&me(((ve=fe.status)==null?void 0:ve.changes)??[])})},[y,r]);const gn=p.useMemo(()=>iw(kt,V=>ng(V.path),on),[kt,on]),Z=p.useMemo(()=>{const V=new Map,fe=new Set;for(const ve of gn){const it=ve.path.replace(/\\/g,"/"),tt=ve.worktreeStatus??ve.stagedStatus??ve.status;V.set(it,tt);const Tt=it.split("/");for(let cn=1;cn<Tt.length;cn++)fe.add(Tt.slice(0,cn).join("/"))}return{statusByPath:V,changedDirs:fe}},[gn]),ce=p.useMemo(()=>hV(C,on),[on,C]),ge=p.useMemo(()=>U===null?null:Ch(U,on),[U,on]),Ce=ce[fr]??[],We=K&&ge!==null,qe=p.useMemo(()=>Me?xb(Ce,ce,Z.statusByPath,Z.changedDirs):Ce,[Z.changedDirs,Z.statusByPath,Ce,Me,ce]),Pt=p.useMemo(()=>We?(ge??[]).map(V=>bi(V.path,V.kind)):NR(qe,ce,j,Me,Z.statusByPath,Z.changedDirs),[j,Z.changedDirs,Z.statusByPath,We,Me,ge,ce,qe]),Ke=((Xt=m.find(V=>V.workspace.id===r))==null?void 0:Xt.workspace)??null,at=tj(I),ft=(at==null?void 0:at.path)??null,ct=(at==null?void 0:at.kind)==="file"?at.path:null,oe=p.useMemo(()=>new Set(I.map(V=>V.path)),[I]),Re=p.useMemo(()=>Jd(I),[I]),_t=!!(Ke!=null&&Ke.path&&I.length===1&&ft),Ut=I.length===1&&(at==null?void 0:at.kind)==="file",Qt=Re.length>0,ln=Re.length>0,jn=!!(Fe!=null&&Fe.items.length&&r),Jn=!!((ct?aa(ct):W)&&j.length);async function bn(V,fe=!1){if(!r)return[];if(!fe){const ve=ht.current[V];if(ve)return ve}V===fr?O(!0):F(ve=>Ph(ve,V));try{const ve=await ur(V,{force:fe});return $t(it=>({...it,[V]:ve})),ve}catch(ve){throw sj(ve)||jt({title:Fi(ve,o("conversation.filePanelLoadFailed")),tone:"error"}),ve}finally{V===fr?O(!1):F(ve=>ve.filter(it=>it!==V))}}async function Jt(V){if(!r)return;const fe=(V==null?void 0:V.activeDirectoryPath)??$e.current,ve=(V==null?void 0:V.expandedDirectories)??pe.current,it=HV(ht.current,fe,ve);Ot("file_panel.refresh_tree_cache.start",{sessionId:t,workspaceId:r,targetDirectories:it});const Tt=(await Promise.all(it.map(async cn=>{const In=await ur(cn,{force:!0});return[cn,In]}))).reduce((cn,[In,Hn])=>(cn[In]=Hn,cn),{});Ot("file_panel.refresh_tree_cache.end",{sessionId:t,workspaceId:r,targetDirectories:it,directoryCount:Object.keys(Tt).length}),$t(Tt)}async function ur(V,fe){if(!r)return[];if(!(fe!=null&&fe.force)){const it=ht.current[V];if(it)return it}const ve=ag(Ph(pe.current,V),V||$e.current);return f(r,ve),v(r,[V]),vn(V,JC,{allowCached:(fe==null?void 0:fe.force)!==!0})}function vn(V,fe=JC,ve){const it=ht.current[V];return(ve==null?void 0:ve.allowCached)!==!1&&it?Promise.resolve(it):new Promise((tt,Tt)=>{const cn=window.setTimeout(()=>{kn(V,cn),Tt(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${V}`))},fe),In=It.current.get(V)??[];It.current.set(V,[...In,{resolve:tt,reject:Tt,timerId:cn}])})}function yn(V,fe){const ve=It.current.get(V)??[];ve.length!==0&&(It.current.delete(V),ve.forEach(it=>{window.clearTimeout(it.timerId),it.resolve(fe)}))}function kn(V,fe){const it=(It.current.get(V)??[]).filter(tt=>tt.timerId!==fe);if(it.length===0){It.current.delete(V);return}It.current.set(V,it)}function Nn(){for(const[V,fe]of It.current.entries())fe.forEach(ve=>{window.clearTimeout(ve.timerId),ve.reject(new Error(`FILE_TREE_ABORTED:${V}`))});It.current.clear()}function xt(V){M([V]),L(V.path)}function Zt(V){E(V.kind==="directory"?V.path:aa(V.path))}function we(V){const fe=PV(Pt,_,V);M(fe),L(V.path),Zt(V)}function Ge(V){const fe=NV(I,V),ve=tj(fe);M(fe),L(V.path),ve&&Zt(ve)}function St(V){xt(V),Zt(V)}function Sn(V,fe){if(fe!=null&&fe.shiftKey){we(V);return}if(Qd(fe)){Ge(V);return}St(V)}async function _n(V,fe=!1){const ve=lu(V,fe);if(!ve.length){E(fr);return}dn(it=>RR(it,ve)),E(ve[ve.length-1]??fr);for(const it of ve)try{await bn(it)}catch{return}}async function Vn(V){const fe=bi(V,"file");xt(fe),Zt(fe),await _n(V)}async function zn(V){J(V),vt(null),Rt.current=null,Be.current+=1,Vn(V);const fe=Be.current,ve=V.replace(/\\/g,"/"),it=Z.statusByPath.get(ve);if(r&&it&&it!=="?"&&it!=="D")try{const tt=await mP(r,V,!1);Be.current===fe&&vt(tt.content||null)}catch{Be.current===fe&&vt(null)}}function rr(V){const fe=Date.now(),ve=Rt.current;return Rt.current={filePath:V,timestamp:fe},(ve==null?void 0:ve.filePath)===V&&fe-ve.timestamp<=wV}function Gn(){Rt.current=null}async function xr(V,fe){const ve=bi(V,"file");if(fe!=null&&fe.shiftKey||Qd(fe)){Gn(),Sn(ve,fe);return}if(rr(V)){await zn(V);return}Sn(ve,fe),await _n(V)}function Kr(){z(!1),P(""),X(null),Gn()}async function Yr(V,fe){const ve=bi(V.path,V.kind);if(fe!=null&&fe.shiftKey||Qd(fe)){Gn(),Sn(ve,fe);return}if(V.kind==="directory"){Kr(),Sn(ve,fe),await Xr(V.path);return}if(rr(V.path)){Kr(),await zn(V.path);return}await Vn(V.path)}async function Xr(V){if(xt(bi(V,"directory")),E(V),!pe.current.includes(V))try{await bn(V),dn(fe=>Ph(fe,V))}catch{}}async function Lr(V){if(xt(bi(V,"directory")),E(V),pe.current.includes(V)){es(V);return}await Xr(V)}function es(V){dn(fe=>fe.filter(ve=>ve!==V&&!ve.startsWith(`${V}/`))),E(aa(V)),M([]),L(null)}async function sr(){if(!r)return;const V=r;try{if(k(V),await Jt(),ct&&await _n(ct),We&&q.trim()){const fe=await Ac(V,q.trim());X(fe.items)}}catch(fe){jt({title:Fi(fe,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function Hr(V){if(V==null||V.preventDefault(),!r||!q.trim()){X(null);return}Se(!0);try{const fe=await Ac(r,q.trim());X(fe.items)}catch(fe){jt({title:Fi(fe,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{Se(!1)}}function dr(){if(K){z(!1),P(""),X(null);return}z(!0)}function wt(V){et(!1),V()}function ir(){var V;(V=un.current)==null||V.click()}async function tn(V){var Tt;const fe=((Tt=V.target.files)==null?void 0:Tt[0])??null;if(V.target.value="",!fe||!r)return;const ve=TV(fe.name);if(!ve){jt({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const it=ZC(W,at),tt=ej(it,ve);te(!0);try{const cn=await FV(fe);await L_({workspaceId:r,path:tt,contentBase64:cn}),await Jt(),await Vn(tt),jt({title:o("conversation.filePanelUploadSuccess",{name:ve}),tone:"success"})}catch(cn){jt({title:Fi(cn,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{te(!1)}}async function hr(V=ct){if(!(!r||!V)){te(!0);try{const fe=await F_(r,V),ve=_V(fe.contentBase64);OV(fe.fileName,new Blob([ve],{type:"application/octet-stream"})),jt({title:o("conversation.filePanelDownloadSuccess",{name:fe.fileName}),tone:"success"})}catch(fe){jt({title:Fi(fe,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{te(!1)}}}function ar(){const V=ct?aa(ct):W;!V||!pe.current.includes(V)||es(V)}async function ue(V,fe=ZC(W,at)){if(!r)return;const ve=fe,it=ve?`${ve}/`:"",tt=window.prompt(o(V==="create_file"?"conversation.filePanelCreateFilePrompt":"conversation.filePanelCreateDirectoryPrompt"),it);if(!(tt!=null&&tt.trim()))return;const Tt=tt.trim();Y(!0);try{await hf({workspaceId:r,opType:V,dstPath:Tt,content:V==="create_file"?"":void 0}),await Jt(),V==="create_directory"?(await _n(Tt,!0),xt(bi(Tt,"directory")),E(Tt)):await Vn(Tt)}catch(cn){jt({title:Fi(cn,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{Y(!1)}}function Qe(V,fe=Re){var it;if(fe.length===0)return;const ve=Jd(fe);Ve({mode:V,items:ve}),M(ve),L(((it=ve[ve.length-1])==null?void 0:it.path)??null),jt({title:V==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:ve.length}):o("conversation.filePanelCutSelectionSuccess",{count:ve.length}),tone:"success"}),Ue(null)}async function yt(V=MV(at,W)){if(!r||!Fe||!Fe.items.length)return;const fe=V??fr,ve=Fe.items.map(it=>({source:it,destinationPath:ej(fe,ng(it.path)||it.path)}));Y(!0);try{for(const Tt of ve)Fe.mode==="cut"&&Nh(Tt.source.path)===Nh(Tt.destinationPath)||await hf({workspaceId:r,opType:Fe.mode==="copy"?"copy":"move",srcPath:Tt.source.path,dstPath:Tt.destinationPath});const it=ve.map(Tt=>bi(Tt.destinationPath,Tt.source.kind)),tt=it[it.length-1]??null;if(Fe.mode==="cut"&&Ve(null),M(it),L((tt==null?void 0:tt.path)??null),tt&&Zt(tt),Gn(),await Jt({activeDirectoryPath:(tt==null?void 0:tt.kind)==="directory"?tt.path:tt?aa(tt.path):$e.current,expandedDirectories:pe.current}),We&&q.trim()){const Tt=await Ac(r,q.trim());X(Tt.items)}xe(Tt=>Tt+1),jt({title:o("conversation.filePanelPasteSuccess",{count:it.length}),tone:"success"}),Ue(null)}catch(it){await Jt().catch(()=>{}),jt({title:Fi(it,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{Y(!1)}}function Lt(V=Re){!V.length||ne||(je(Jd(V)),Ue(null))}async function fn(){var fe,ve;if(!r||!(He!=null&&He.length))return;const V=Jd(He);Y(!0);try{for(const Tt of V)await hf({workspaceId:r,opType:"delete",srcPath:Tt.path});const it=AV(W,V),tt=pe.current.filter(Tt=>!V.some(cn=>cn.kind==="directory"&&Zh(cn.path,Tt)));if(se&&V.some(Tt=>Zh(Tt.path,se))&&(Be.current+=1,J(null),vt(null)),je(null),M([]),L(null),$e.current=it,pe.current=tt,E(it),dn(tt),Gn(),await Jt({activeDirectoryPath:it,expandedDirectories:tt}),We&&q.trim()){const Tt=await Ac(r,q.trim());X(Tt.items)}xe(Tt=>Tt+1),jt({title:V.length===1?o("conversation.filePanelDeleteSuccess",{name:ng(((fe=V[0])==null?void 0:fe.path)??"")||((ve=V[0])==null?void 0:ve.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:V.length}),tone:"success"})}catch(it){jt({title:Fi(it,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{Y(!1)}}async function mn(V,fe=at){const ve=(Ke==null?void 0:Ke.path)??"",it=(fe==null?void 0:fe.path)??null;if(it===null||!ve){Ct(!1);return}try{const tt=LV(ve),Tt=V==="absolute"?EV(ve,it,tt):Nh(it,tt);await BV(Tt,Cn),jt({title:o(V==="absolute"?"conversation.filePanelCopyAbsolutePathSuccess":"conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(tt){jt({title:tt instanceof Error?tt.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Ct(!1),Ue(null)}}function nn(V,fe,ve){return[{id:`open-${V.path}`,label:V.kind==="directory"?j.includes(V.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(V.kind==="directory"){Lr(V.path);return}zn(V.path)}},{id:`download-${V.path}`,label:o("conversation.filePanelDownload"),disabled:V.kind!=="file"||G,onSelect:()=>{hr(V.kind==="file"?V.path:null)}},{id:`create-file-${V.path}`,label:o("conversation.filePanelNewFile"),disabled:!r||ne||G,onSelect:()=>{ue("create_file",ve)}},{id:`create-directory-${V.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!r||ne||G,onSelect:()=>{ue("create_directory",ve)}},{id:`copy-${V.path}`,label:o("conversation.filePanelCopy"),disabled:fe.length===0,onSelect:()=>Qe("copy",fe)},{id:`cut-${V.path}`,label:o("conversation.filePanelCut"),disabled:fe.length===0,onSelect:()=>Qe("cut",fe)},{id:`paste-${V.path}`,label:o("conversation.filePanelPaste"),disabled:!jn,onSelect:()=>{yt(ve)}},{id:`copy-relative-${V.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{mn("relative",V)}},{id:`copy-absolute-${V.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{mn("absolute",V)}},{id:`delete-${V.path}`,label:o("conversation.filePanelDelete"),disabled:fe.length===0||ne||G,onSelect:()=>Lt(fe)}]}async function Un(V,fe){if(Cn.isMobile)return;V.preventDefault();const ve=bi(fe.path,fe.kind),it=oe.has(ve.path)?Re:[ve],tt=ve.kind==="directory"?ve.path:aa(ve.path);oe.has(ve.path)||St(ve);const Tt=nn(ve,it,tt);if(Cn.isDesktop){await bv(Tt);return}Cn.isWeb&&(Ct(!1),et(!1),Ue({positionX:V.clientX,positionY:V.clientY,items:Tt}))}p.useEffect(()=>{if(Ne!=="workspace")return;function V(fe){if(!DV(fe)||fe.altKey||fe.shiftKey||RV(fe.target))return;const ve=fe.key.toLowerCase();if(ve==="c"&&ln){fe.preventDefault(),Qe("copy");return}if(ve==="x"&&ln){fe.preventDefault(),Qe("cut");return}ve==="v"&&jn&&(fe.preventDefault(),yt())}return document.addEventListener("keydown",V),()=>{document.removeEventListener("keydown",V)}},[Ne,ln,jn,Qe,yt]);function Fr(V,fe){return n.jsx(n.Fragment,{children:V.map(ve=>{const it=bi(ve.path,ve.kind),tt=ve.kind==="directory",Tt=tt&&j.includes(ve.path),cn=tt&&D.includes(ve.path),In=ce[ve.path]??[],Hn=Me?xb(In,ce,Z.statusByPath,Z.changedDirs):In,ts=oe.has(ve.path),gs=ft===ve.path,or=Z.statusByPath.get(ve.path.replace(/\\/g,"/")),Ls=tt&&Z.changedDirs.has(ve.path.replace(/\\/g,"/")),ns=(Fe==null?void 0:Fe.mode)==="cut"&&Fe.items.some(mr=>mr.path===ve.path);return n.jsxs("div",{className:"file-tree-node",children:[n.jsxs("button",{className:"file-tree-item",type:"button","data-active":gs,"data-selected":ts,"data-cut-pending":ns||void 0,"data-kind":ve.kind,"aria-expanded":tt?Tt:void 0,style:{paddingInlineStart:`${CV+fe*jV}px`},onClick:mr=>{if(tt){if(mr.shiftKey||Qd(mr)){Gn(),Sn(it,mr);return}Gn(),Sn(it,mr),Lr(ve.path);return}xr(ve.path,mr)},onContextMenu:mr=>{Un(mr,ve)},children:[n.jsx("span",{className:`file-tree-chevron${tt?"":" is-hidden"}`,"aria-hidden":"true",children:Tt?"v":">"}),tt?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(ve.name),"aria-hidden":"true",children:Ao(ve.name)}),n.jsx("span",{className:"file-tree-label","data-status":or??void 0,"data-has-changes":Ls||void 0,children:ve.name}),!tt&&or?n.jsx("span",{className:"git-status-badge","data-status":or,"aria-label":or,children:or}):null,tt&&Ls?n.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,cn?n.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),tt&&Tt?n.jsx("div",{className:"file-tree-children",children:cn&&!In.length?n.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):Hn.length?Fr(Hn,fe+1):n.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${ve.kind}-${ve.path}`)})})}function zr(V){return n.jsx(n.Fragment,{children:V.map(fe=>{const ve=fe.kind==="directory",it=oe.has(fe.path),tt=ft===fe.path;return n.jsx("div",{className:"file-tree-node",children:n.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":tt,"data-selected":it,"data-kind":fe.kind,onClick:Tt=>{Yr(fe,Tt)},onContextMenu:Tt=>{Un(Tt,fe)},children:[n.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),ve?null:n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(fe.name),"aria-hidden":"true",children:Ao(fe.name)}),n.jsxs("span",{className:"file-tree-label",children:[n.jsx("span",{className:"file-tree-name",children:fe.name}),n.jsx("span",{className:"file-tree-path",children:fe.path})]})]})},`search-${fe.kind}-${fe.path}`)})})}return n.jsx("section",{className:["conversation-panel","surface-card","file-panel",e].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:r?n.jsxs(n.Fragment,{children:[n.jsx(gR,{workspaceId:r,filePath:se,open:se!==null,onClose:()=>{Be.current+=1,J(null),vt(null)},onSaved:async V=>{await Jt(),await Vn(V),xe(fe=>fe+1)},diffContent:ze}),s?null:n.jsx("div",{className:"file-panel-heading-row",children:n.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),n.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:Ne==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":Ne==="workspace",onClick:()=>Ee("workspace"),children:o("conversation.filePanelWorkspaceTab")}),n.jsxs("button",{className:Ne==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":Ne==="session",onClick:()=>{Wn&&Ee("session")},disabled:!Wn,children:[o("conversation.filePanelSessionTab"),n.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${lt}`,children:lt})]})]}),Ne==="workspace"?n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:un,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:V=>void tn(V)}),Rn?n.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:n.jsxs("div",{className:"file-mobile-action-shell",ref:Wt,children:[n.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":nt,"data-active":nt,onClick:()=>{Ct(!1),et(V=>!V)},children:[n.jsx("span",{children:o("conversation.filePanelActionsMenu")}),n.jsx(n8,{})]}),nt?n.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>Qe("copy")),disabled:!ln,children:o("conversation.filePanelCopy")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>Qe("cut")),disabled:!ln,children:o("conversation.filePanelCut")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>yt()),disabled:!jn||ne||G,children:o("conversation.filePanelPaste")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{et(!1),dr()},children:o(K?"conversation.filePanelHideSearch":"conversation.filePanelShowSearch")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{et(!1),Xe(V=>!V)},disabled:gn.length===0,children:o(Me?"conversation.filePanelShowAll":"conversation.filePanelFilterChanges")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(sr),disabled:Q||ne||R,children:o("conversation.filePanelRefresh")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{et(!1),ar()},disabled:!Jn,children:o("conversation.filePanelCollapseCurrent")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{et(!1),ir()},disabled:ne||G,children:o("conversation.filePanelUpload")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(hr),disabled:!Ut||G,children:o("conversation.filePanelDownload")}),n.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>wt(Lt),disabled:!Qt||ne||G,children:o("conversation.filePanelDelete")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>ue("create_file")),disabled:ne||G,children:o("conversation.filePanelNewFile")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>ue("create_directory")),disabled:ne||G,children:o("conversation.filePanelNewDirectory")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>mn("absolute")),disabled:!_t,children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>wt(()=>mn("relative")),disabled:!_t,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):n.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>Qe("copy"),disabled:!ln,children:n.jsx(KV,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>Qe("cut"),disabled:!ln,children:n.jsx(YV,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void yt(),disabled:!jn||ne||G,children:n.jsx(XV,{})}),n.jsxs("div",{className:"file-toolbar-menu-shell",ref:Ft,children:[n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":bt,"data-active":bt,onClick:()=>{et(!1),Ct(V=>!V)},disabled:!_t,children:n.jsx(GV,{})}),bt?n.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void mn("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),n.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void mn("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:ar,disabled:!Jn,children:n.jsx($V,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void sr(),disabled:Q||ne||R,children:n.jsx(VV,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":K,onClick:dr,disabled:Q,children:n.jsx(ij,{})}),gn.length>0?n.jsx("button",{className:"file-toolbar-button",type:"button",title:o(Me?"conversation.filePanelShowAll":"conversation.filePanelFilterChanges"),"aria-label":o(Me?"conversation.filePanelShowAll":"conversation.filePanelFilterChanges"),"data-active":Me,onClick:()=>Xe(V=>!V),children:n.jsx(r8,{})}):null,n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:ir,disabled:ne||G,children:n.jsx(JV,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void hr(),disabled:!Ut||G,children:n.jsx(ZV,{})}),n.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>Lt(),disabled:!Qt||ne||G,children:n.jsx(e8,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void ue("create_file"),disabled:ne||G,children:n.jsx(QV,{})}),n.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void ue("create_directory"),disabled:ne||G,children:n.jsx(t8,{})})]}),De&&typeof document<"u"?$n.createPortal(n.jsx("div",{className:"file-web-context-menu",ref:Kt,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(Ye==null?void 0:Ye.left)??Math.max(8,De.positionX)}px`,top:`${(Ye==null?void 0:Ye.top)??Math.max(8,De.positionY)}px`,maxHeight:Ye?`${Ye.maxHeight}px`:void 0},children:De.items.map(V=>n.jsx("button",{className:["file-web-context-menu-item",V.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:V.disabled,onClick:()=>{Ue(null),V.onSelect()},children:V.label},V.id))}),document.body):null,K?n.jsxs("form",{className:"file-toolbar-search",onSubmit:V=>void Hr(V),children:[n.jsx("input",{value:q,onChange:V=>P(V.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),Rn?n.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:R,children:o("conversation.filePanelSearchButton")}):n.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:R,children:n.jsx(ij,{})})]}):null,n.jsx("div",{className:"file-tree","data-search-mode":We,children:Q&&Ce.length===0?n.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):We?ge!=null&&ge.length?zr(ge):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):Me?qe.length?Fr(qe,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Ce.length?Fr(Ce,0):n.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),n.jsxs(Ln,{open:He!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{ne||je(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:He!=null&&He.length?He.length===1?((Cr=He[0])==null?void 0:Cr.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:He[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:He[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:He.length}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:ne,onClick:()=>je(null),children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:ne,onClick:()=>{fn()},children:o(ne?"conversation.filePanelDeleting":"conversation.filePanelDelete")})]})]})]}):Wn&&t?n.jsx(bV,{sessionId:t,workspaceId:r,showSystemFiles:on,selectedPath:ct,refreshVersion:ie,onCountChange:Oe,onSelectFile:Vn,onOpenFile:zn}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):n.jsx("section",{className:"file-panel-section",children:n.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function aa(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):fr}function lu(e,t=!1){const r=e.split("/").filter(Boolean),s=t?r.length:r.length-1,i=[];for(let l=0;l<s;l+=1)i.push(r.slice(0,l+1).join("/"));return i}function ZC(e,t){return e||((t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?aa(t.path):fr)}function ej(e,t){return e?`${e}/${t}`:t}function TV(e){var t;return((t=e.split(/[/\\]/).pop())==null?void 0:t.trim())??""}function bi(e,t){return{path:e,kind:t}}function tj(e){return e[e.length-1]??null}function NV(e,t){return e.findIndex(s=>s.path===t.path)>=0?e.filter(s=>s.path!==t.path):[...e,t]}function PV(e,t,r){const s=e.findIndex(d=>d.path===r.path);if(s<0)return[r];const i=t?e.findIndex(d=>d.path===t):s;if(i<0)return[r];const l=Math.min(i,s),c=Math.max(i,s);return e.slice(l,c+1)}function Qd(e){return!!(e!=null&&e.ctrlKey||e!=null&&e.metaKey)}function DV(e){return e.ctrlKey||e.metaKey}function RV(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"||e.isContentEditable}function Jd(e){const t=[...new Map(e.map(s=>[s.path,s])).values()].sort((s,i)=>s.path.localeCompare(i.path)),r=[];for(const s of t)r.some(i=>i.kind==="directory"&&Zh(i.path,s.path))||r.push(s);return r}function MV(e,t){return(e==null?void 0:e.kind)==="directory"?e.path:e!=null&&e.path?aa(e.path):t}function AV(e,t){let r=e;for(;r&&t.some(s=>s.kind==="directory"&&Zh(s.path,r));)r=aa(r);return r}function NR(e,t,r,s,i,l){const c=[];for(const d of e){if(c.push(bi(d.path,d.kind)),d.kind!=="directory"||!r.includes(d.path))continue;const m=t[d.path]??[],f=s?xb(m,t,i,l):m;c.push(...NR(f,t,r,s,i,l))}return c}function IV(e,t,r){const s=Math.max(0,r.width),i=Math.max(0,r.height),l=Math.max(0,i-Li*2),c=Math.max(0,s-Li*2),d=Math.min(Math.max(t.width,0),c),m=Math.max(0,i-e.y-Xd-Li),f=Math.max(0,e.y-Xd-Li),v=m<t.height&&f>m,w=ig(Math.max(v?f:m,kV),0,l),k=Math.min(Math.max(t.height,0),w),y=v?e.y-Xd-k:e.y+Xd,C=Math.max(Li,i-Li-k),T=Math.max(Li,s-Li-d);return{top:ig(y,Li,C),left:ig(e.x,Li,T),maxHeight:Math.max(0,w)}}function ig(e,t,r){return!Number.isFinite(e)||r<t?t:Math.min(Math.max(e,t),r)}function Nh(e,t="posix"){return e?PR(e,t):"."}function EV(e,t,r){const s=PR(e,r),i=Nh(t,r).replace(/^\.[/\\]?/,"");if(!i)return s;const l=DR(r),c=i.replace(/^[/\\]+/,"");return c?s.endsWith("/")||s.endsWith("\\")?`${s}${c}`:`${s}${l}${c}`:s}function LV(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.includes("\\")?"windows":"posix"}function PR(e,t){return e&&(DR(t)==="\\"?e.replace(/\//g,"\\"):e.replace(/\\/g,"/"))}function DR(e){return e==="windows"?"\\":"/"}function Zh(e,t){return t===e||t.startsWith(`${e}/`)}async function FV(e){const t=await e.arrayBuffer(),r=new Uint8Array(t),s=32768;let i="";for(let l=0;l<r.length;l+=s){const c=r.subarray(l,l+s);i+=String.fromCharCode(...c)}return btoa(i)}function _V(e){const t=atob(e),r=new Uint8Array(t.length);for(let s=0;s<t.length;s+=1)r[s]=t.charCodeAt(s);return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}function OV(e,t){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const r=window.URL.createObjectURL(t),s=document.createElement("a");s.href=r,s.download=e,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(r)}async function BV(e,t){var r;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((r=navigator.clipboard)!=null&&r.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!WV(e))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function WV(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}function UV(e,t){return e&&lu(e,!0).every(i=>i in t)?e:fr}function nj(e,t){if(!t)return[];const r=lu(t,!0);return e.filter(s=>r.includes(s))}function Zd(e,t,r){const s=lw(t,r);return Object.entries(e).reduce((i,[l,c])=>(s.has(l)&&(i[l]=c),i),{})}function HV(e,t,r){const i=[...lw(t,r)].filter(l=>l===fr||l in e);return i.length?i:[fr]}function lw(e,t){const r=new Set([fr]),s=RR(t,lu(e,!0));for(const i of s){r.add(i);for(const l of lu(i,!0))r.add(l)}return r}function zV(e,t){const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>e[i]===t[i])}function Ph(e,t){return e.includes(t)?e:[...e,t]}function RR(e,t){return t.reduce((r,s)=>Ph(r,s),e)}function rj(e){return`file-panel.workspace-tree.${e}`}function qV(e,t){return`file-panel.session-change-count.${e}.${t}`}function ag(e,t){return[...lw(t,e)]}function Fi(e,t){return e instanceof Ur?e.message:t}function sj(e){return e instanceof Error&&(e.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||e.message.startsWith("FILE_TREE_ABORTED:"))}function $V(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function VV(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function ij(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function GV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function KV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function YV(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function XV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function QV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function JV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ZV(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function e8(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function t8(){return n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function n8(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function r8(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function xb(e,t,r,s){const i=[];for(const l of e){const c=l.path.replace(/\\/g,"/");l.kind==="file"?r.has(c)&&i.push(l):MR(c,t,r,s)&&i.push(l)}return i}function MR(e,t,r,s,i){const l=i??new Set;if(l.has(e))return!1;l.add(e);const c=t[e];if(!c)return s.has(e);for(const d of c){const m=d.path.replace(/\\/g,"/");if(d.kind==="file"){if(r.has(m))return!0}else if(MR(m,t,r,s,l))return!0}return!1}const s8=Object.freeze(Object.defineProperty({__proto__:null,FileContextPanel:ow},Symbol.toStringTag,{value:"Module"})),og=56,aj=28,lg=72,eh=8,oj=960,lj=60*1e3,cj=20,uj=9,dj=9,cg=68,Ds=12,th=8,Sb=260,i8=120,ug=6e4,em={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function cw({className:e,workspaceId:t,panelActive:r=!0,externalWindowMode:s=!1,workbenchShellOverrides:i}){const l=vr(),c=nr(),d=Pr(),{subscribeGitSnapshot:m,requestGitRefresh:f,addGitSnapshotListener:v,requestNavigationRefresh:g,selectWorkspace:w,upsertNavigationSession:k}={...d,...i},[y,C]=p.useState(null),[T,j]=p.useState([]),[N,D]=p.useState(0),[F,W]=p.useState(null),[E,I]=p.useState(!1),[M,_]=p.useState(null),[L,Q]=p.useState(null),[O,ne]=p.useState(""),[Y,G]=p.useState(!1),[te,K]=p.useState(!1),[z,q]=p.useState([]),[P,U]=p.useState(!0),[X,R]=p.useState(!1),[Se,se]=p.useState(()=>typeof window<"u"?window.innerWidth<=oj:!1),[J,Ne]=p.useState([]),[Ee,ie]=p.useState(null),[xe,lt]=p.useState("unstaged"),[Oe,bt]=p.useState(null),[Ct,nt]=p.useState(null),[et,De]=p.useState(!1),[Ue,Ye]=p.useState(null),[ye,He]=p.useState(!1),[je,Fe]=p.useState(null),[Ve,kt]=p.useState(null),[me,Me]=p.useState(null),[Xe,ze]=p.useState(!1),[vt,ht]=p.useState(null),[pe,$e]=p.useState(!1),[Nt,Rt]=p.useState(!1),[Ft,Wt]=p.useState([]),[Kt,un]=p.useState(!1),[ae,Be]=p.useState(new Set),[It,jt]=p.useState(new Map),[Cn,on]=p.useState(null),[Wn,Rn]=p.useState(!1),[$t,dn]=p.useState(em),[gn,Z]=p.useState("generic"),[ce,ge]=p.useState(null),[Ce,We]=p.useState(null),[qe,Pt]=p.useState(null),[Ke,at]=p.useState(og),[ft,ct]=p.useState(!1),[oe,Re]=p.useState(null),[_t,Ut]=p.useState(null),Qt=p.useRef(null),ln=p.useRef(null),jn=p.useRef(null),Jn=p.useRef(null),bn=p.useRef(null),Jt=p.useRef(null),ur=p.useRef(null),vn=p.useRef(new Map),yn=p.useRef(new Map),kn=p.useRef(0),Nn=p.useRef(r),{showToast:xt}=Qn(),Zt=c.isDesktop&&!Se;p.useEffect(()=>{Ot("git_sidebar.props",{workspaceId:t,externalWindowMode:s})},[s,t]),p.useEffect(()=>{q([]),U(!0),D(0),W(null),I(!1),Q(null),ne(""),R(!1),Ne([]),ie(null),lt("unstaged"),bt(null),nt(null),De(!1),Ye(null),He(!1),Fe(null),kt(null),Me(null),ze(!1),ht(null),$e(!1),Rt(!1),Wt([]),Be(new Set),jt(new Map),on(null),Rn(!1),dn(em),Z("generic"),ge(null),We(null),Pt(null),ct(!1),at(og),Re(null),Ut(null),yn.current.clear(),vn.current.clear()},[t]),p.useEffect(()=>{function $(){se(window.innerWidth<=oj)}return $(),window.addEventListener("resize",$),()=>{window.removeEventListener("resize",$)}},[]),p.useEffect(()=>{if(!ft)return;const $=document.body.style.cursor,be=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function st(en){Fr(en.clientY)}function At(){ct(!1)}return window.addEventListener("pointermove",st),window.addEventListener("pointerup",At),()=>{document.body.style.cursor=$,document.body.style.userSelect=be,window.removeEventListener("pointermove",st),window.removeEventListener("pointerup",At)}},[ft]),p.useEffect(()=>{var st,At;if(!(t!=null&&t.trim())){C(null),j([]),D(0),W(null),_(null),G(!1);return}const $=t.trim(),be=Er(hg($),lj);if(Ot("git_sidebar.snapshot",{workspaceId:$,cached:!!be,cachedHistoryCount:((st=be==null?void 0:be.history)==null?void 0:st.length)??0,cachedChangedCount:((At=be==null?void 0:be.status)==null?void 0:At.changes.length)??0}),be){Ge(be),G(!1);return}C(null),j([]),D(0),W(null),_(null),G(!0)},[t]),p.useEffect(()=>{if(t!=null&&t.trim())return v($=>{var be,st,At;$.workspaceId===t.trim()&&(Ot("git_sidebar.snapshot_received",{workspaceId:$.workspaceId,changedCount:((be=$.status)==null?void 0:be.changes.length)??0,historyCount:$.history.length,branchCount:(((st=$.branches)==null?void 0:st.local.length)??0)+(((At=$.branches)==null?void 0:At.remote.length)??0)}),Ge($),G(!1))})},[v,t]),p.useEffect(()=>{if(!(t!=null&&t.trim()))return;const $=t.trim(),be=Er(hg($),lj)!==null;if(m($),be){f($);return}St()},[f,m,t]),p.useEffect(()=>{const $=Nn.current;Nn.current=r,t!=null&&t.trim()&&!$&&r&&f(t.trim())},[r,f,t]),p.useEffect(()=>{t&&As(hg(t),{status:y,history:T,historyTotalCount:N,historyNextCursor:F,branches:M})},[M,T,F,N,y,t]),p.useEffect(()=>{if(!y||!L)return;y.changes.find(be=>be.path===L)||Q(null)},[L,y]),p.useEffect(()=>{d8(Jn.current)},[O]),p.useEffect(()=>{Se||(Ne([]),ie(null),bt(null),ge(null))},[Se]),p.useEffect(()=>{if(!y){Ne([]);return}const $=new Set(y.changes.map(be=>be.path));Ne(be=>be.filter(st=>$.has(st)))},[y]);function we(){const $=jn.current;if(!$)return;$.querySelectorAll(".git-tree-shell").forEach(st=>{st.scrollTop=0})}function Ge($){C($.status),j(Array.isArray($.history)?$.history:[]),D(typeof $.historyTotalCount=="number"?$.historyTotalCount:0),W(typeof $.historyNextCursor=="string"?$.historyNextCursor:null),_($.branches??null)}function St($){t!=null&&t.trim()&&(G(!0),Ot("git_sidebar.refresh_requested",{workspaceId:t.trim(),resetTreeScroll:!1}),f(t.trim()))}async function Sn($){if(!(t!=null&&t.trim()))return;const be=t.trim();G(!0);try{const[st,At,en]=await Promise.all([hP(be),jx(be,cj,null),fP(be)]);Ge({status:st,history:At.items,historyTotalCount:At.totalCount,historyNextCursor:At.nextCursor,branches:en}),f(be),$!=null&&$.resetTreeScroll&&requestAnimationFrame(()=>{we()})}catch(st){xt({title:Cs(st,o("git.panelLoadFailed")),tone:"error"})}finally{G(!1)}}async function _n(){if(!(!t||!F||E)){I(!0);try{const $=await jx(t,cj,F);j(be=>{const st=new Set(be.map(en=>en.commitHash)),At=$.items.filter(en=>!st.has(en.commitHash));return[...be,...At]}),D($.totalCount),W($.nextCursor)}catch($){xt({title:Cs($,o("git.panelLoadFailed")),tone:"error"})}finally{I(!1)}}}function Vn($){if(!P||E||!F)return;const be=$.currentTarget;be.scrollHeight-be.scrollTop-be.clientHeight<=40&&_n()}async function zn(){if(t){K(!0);try{const $=await d_(t,"ai");ne($.validation.normalizedDraft.subject||$.draft.subject)}catch($){xt({title:Cs($,o("git.draftFailed")),tone:"error"})}finally{K(!1)}}}async function rr($,be){if(t&&$.length){K(!0);try{const st=be?await c_(t,$):await pP(t,$);C(st),Q($[$.length-1]??null),Ne(At=>At.filter(en=>!$.includes(en))),ie(null),St()}catch(st){G(!1),xt({title:Cs(st,o("git.stageFailed")),tone:"error"})}finally{K(!1)}}}async function Gn($){if(t&&$.length){K(!0);try{const be=await u_(t,$);C(be),$.includes(L??"")&&Q(null),Ne(st=>st.filter(At=>!$.includes(At))),ie(null),St()}catch(be){G(!1),xt({title:Cs(be,o("git.discardFailed")),tone:"error"})}finally{K(!1)}}}async function xr(){if(!(!t||!O.trim())){K(!0);try{await h_(t,c8(O)),xt({title:o("git.commitSuccess"),tone:"success"}),ne(""),Q(null),St()}catch($){xt({title:Cs($,o("git.commitFailed")),tone:"error"})}finally{K(!1)}}}function Kr($){dn(p8(Cn)),Rn(!0),Yr($)}async function Yr($){const be=t==null?void 0:t.trim();if(!be){Z("generic");return}try{const st=await Nx(be);if((t==null?void 0:t.trim())!==be)return;Z(g8(st,$))}catch{if((t==null?void 0:t.trim())!==be)return;Z("generic")}}function Xr(){const $=f8($t),be=o(gn==="github"?"git.remoteAuthGithubPatPlaceholder":"shell.clonePasswordPlaceholder");if($t.authMode==="basic"){if(!$t.username.trim()){xt({title:o("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!$t.password){xt({title:be,tone:"error"});return}}if($t.authMode==="token"&&!$t.token){xt({title:o("shell.cloneTokenPlaceholder"),tone:"error"});return}on($),Rn(!1),xt({title:o($?"git.remoteAuthSaved":"git.remoteAuthCleared"),description:$&&$t.rememberOnHost?o("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function Lr(){if(t){un(!0);try{const $=await Nx(t);if($.length===0){xt({title:o("git.noRemotes"),tone:"error"});return}if($.length===1){es([$[0].name]);return}Wt($),Be(new Set),jt(new Map),Rt(!0)}catch($){xt({title:Cs($,o("git.remoteFailed")),tone:"error"})}finally{un(!1)}}}async function es($){if(!t||$.length===0)return;K(!0),jt(new Map);const be=new Map;let st=!1;try{for(const At of $)try{const en=await Tx(t,"push",At,Cn,$t.rememberOnHost);be.set(At,{ok:!0,summary:en.summary})}catch(en){if(st=!0,be.set(At,{ok:!1,summary:Cs(en,o("git.remoteFailed"))}),jt(new Map(be)),wj(en)){Kr(At);return}}jt(be),St(),st||(xt({title:o("git.pushAllSuccess",{count:String($.length)}),tone:"success"}),Rt(!1))}finally{K(!1)}}async function sr($){if(t){if($==="push"){R(!1),Lr();return}K(!0);try{const be=await Tx(t,$,void 0,Cn,$t.rememberOnHost);xt({title:be.summary,tone:"success"}),R(!1),St()}catch(be){if(wj(be)){Kr();return}xt({title:Cs(be,o("git.remoteFailed")),tone:"error"})}finally{K(!1)}}}async function Hr(){if(t){K(!0);try{const $=await m_(t);ne($.commitSubject??""),xt({title:$.summary||o("git.undoLastCommitSuccess"),tone:"success"}),R(!1),St()}catch($){xt({title:Cs($,o("git.undoLastCommitFailed")),tone:"error"})}finally{K(!1)}}}async function dr($){if(t){K(!0);try{const be=await g_(t,$,!1);_(be),R(!1),St()}catch(be){xt({title:Cs(be,o("git.branchFailed")),tone:"error"})}finally{K(!1)}}}async function wt($){const be=t==null?void 0:t.trim();if(!be)throw new Error(o("git.panelLoadFailed"));const st=yn.current.get($);if(st)return st;const At=await p_(be,$);return yn.current.set($,At),At}async function ir($){nt(null),bt(null),Ye($),Fe(null);const be=yn.current.get($)??null;if(kt(be),He(!be),be)return;const st=kn.current+1;kn.current=st;try{const At=await wt($);if(kn.current!==st)return;kt(At)}catch(At){if(kn.current!==st)return;Fe(Cs(At,o("git.commitDetailLoadFailed"))),kt(null)}finally{kn.current===st&&He(!1)}}function tn(){Ye(null),He(!1),Fe(null),kt(null)}async function hr($){try{const be=await wt($);await qr(be.versionLabel,o("git.copyCommitVersionSuccess"))}catch(be){xt({title:Cs(be,o("git.commitDetailLoadFailed")),tone:"error"})}}function ar($){nt(null),bt(null),Me($),ht(null),ze(!0)}function ue($){var st;const be=((st=T[0])==null?void 0:st.commitHash)===$.commitHash&&$.commitKind==="local";return[{id:`view-changes:${$.commitHash}`,label:o("git.viewCommitChanges"),onSelect:()=>void ir($.commitHash)},{id:`copy-hash:${$.commitHash}`,label:o("git.copyCommitHash"),onSelect:()=>void qr($.commitHash,o("git.copyCommitHashSuccess"))},{id:`copy-message:${$.commitHash}`,label:o("git.copyCommitMessage"),onSelect:()=>void qr(yl($),o("git.copyCommitMessageSuccess"))},{id:`copy-version:${$.commitHash}`,label:o("git.copyCommitVersion"),onSelect:()=>void hr($.commitHash)},{id:`explain:${$.commitHash}`,label:o("git.explainCommitAction"),onSelect:()=>ar($.commitHash)},...be?[{id:`undo:${$.commitHash}`,label:o("git.undoLastCommit"),disabled:te,onSelect:()=>void Hr()}]:[]]}async function Qe($){nt(null),bt(null),await bv(ue($))}async function yt(){var $,be;if(!(!t||!me||!vt||pe)){$e(!0);try{const st=await wt(me),At=await xv({workspaceId:t,provider:vt,content:u8(st),clientRequestId:((be=($=globalThis.crypto)==null?void 0:$.randomUUID)==null?void 0:be.call($))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`}),en=At.session??await wv(At.sessionId);k(en),g(),w(en.workspaceId),l(Yn(en.workspaceId,en.sessionId)),ze(!1),Me(null),ht(null),xt({title:o("git.explainCommitStarted"),tone:"success"})}catch(st){xt({title:Cs(st,o("git.explainCommitFailed")),tone:"error"})}finally{$e(!1)}}}function Lt($){q(be=>be.includes($)?be.filter(st=>st!==$):[...be,$])}const fn=450;function mn($){const be=Date.now(),st=Qt.current;return Qt.current={filePath:$,timestamp:be},(st==null?void 0:st.filePath)===$&&be-st.timestamp<=fn}async function nn($,be){if(be.binary){xt({title:o("git.binaryDiff"),tone:"info"});return}if(be.status==="A"||be.status==="?")Ut(null),Re($);else if(t)try{const st=await mP(t,$,be.staged);Ut(st.content),Re($)}catch{Ut(null),Re($)}}function Un($){Q($),ie(null),Ne(be=>be.includes($)?be.filter(st=>st!==$):[...be,$])}function Fr($){const be=ln.current;if(!be||!Number.isFinite($))return;const st=be.getBoundingClientRect(),At=st.height-eh;if(!Number.isFinite(st.top)||!Number.isFinite(st.height)||At<=0)return;const en=($-st.top-eh/2)/At*100;if(!Number.isFinite(en))return;const ds=Math.max(aj,Math.min(lg,Math.round(en)));at(ds)}function zr($){$.preventDefault(),Fr($.clientY),ct(!0)}const Xt=(y==null?void 0:y.changes)??[],Cr=Xt.filter($=>Cb($,"staged")),V=Xt.filter($=>Cb($,"unstaged")),fe=bj(Cr,"staged"),ve=bj(V,"unstaged"),it=new Set(z),tt=new Set(J),Tt=vj(J,Xt,"staged"),cn=vj(J,Xt,"unstaged"),In=Xt.length===0&&((y==null?void 0:y.snapshot.ahead)??0)>0,Hn=Cr.length>0&&O.trim().length>0,ts=(M==null?void 0:M.currentBranch)??(y==null?void 0:y.snapshot.branch)??o("common.unknown"),gs=Cn!==null,or=gn==="github",Ls=o(or?"git.remoteAuthDescriptionGithub":"git.remoteAuthDescription"),ns=o(or?"git.remoteAuthGithubPatLabel":"shell.clonePasswordLabel"),mr=o(or?"git.remoteAuthGithubPatPlaceholder":"shell.clonePasswordPlaceholder"),pa=o(or?"git.remoteAuthGithubUsernamePlaceholder":"shell.cloneUsernamePlaceholder"),rs=Number.isFinite(Ke)?Ke:og,ji=P?`minmax(120px, ${rs}fr) ${eh}px minmax(140px, ${100-rs}fr)`:`minmax(120px, 1fr) ${eh}px auto`;p.useEffect(()=>{Ee==="staged"&&Tt.length===0&&ie(null),Ee==="unstaged"&&cn.length===0&&ie(null)},[Ee,Tt.length,cn.length]),p.useEffect(()=>{if(!Se)return;const $=V.length>0?"unstaged":Cr.length>0?"staged":"history";lt(be=>be==="unstaged"&&V.length>0||be==="staged"&&Cr.length>0?be:$)},[Se,Cr.length,V.length]),p.useEffect(()=>{Oe&&(T.some($=>$.commitHash===Oe)||bt(null))},[T,Oe]),p.useEffect(()=>{Ct&&(T.some($=>$.commitHash===Ct)||nt(null))},[Ct,T]),p.useEffect(()=>{Se&&xe!=="history"&&X&&R(!1)},[Se,X,xe]),p.useLayoutEffect(()=>{if(Se||!X){We(null);return}function $(){const st=bn.current,At=Jt.current;!st||!At||typeof window>"u"||We(jb(st.getBoundingClientRect(),{width:At.getBoundingClientRect().width||Sb,height:At.getBoundingClientRect().height||At.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}$();const be=window.requestAnimationFrame($);return window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.cancelAnimationFrame(be),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[te,M==null?void 0:M.local.length,ts,Se,X,gs]);const Qr=Oe??Ct;p.useLayoutEffect(()=>{if(!Qr){Pt(null);return}const $=Qr;function be(){const At=vn.current.get($)??null,en=ur.current;!At||!en||typeof window>"u"||Pt(jb(At.getBoundingClientRect(),{width:en.getBoundingClientRect().width||Sb,height:en.getBoundingClientRect().height||en.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}be();const st=window.requestAnimationFrame(be);return window.addEventListener("resize",be),window.addEventListener("scroll",be,!0),()=>{window.cancelAnimationFrame(st),window.removeEventListener("resize",be),window.removeEventListener("scroll",be,!0)}},[Qr,T.length]),p.useEffect(()=>{if(!Qr||typeof document>"u")return;const $=Qr;function be(st){const At=st.target;if(!(At instanceof Node))return;const en=vn.current.get($)??null,ds=ur.current;en!=null&&en.contains(At)||ds!=null&&ds.contains(At)||(bt(null),nt(null))}return document.addEventListener("pointerdown",be),()=>{document.removeEventListener("pointerdown",be)}},[Qr]);async function qr($,be){var st;try{if(typeof navigator>"u"||!((st=navigator.clipboard)!=null&&st.writeText))throw new Error("clipboard unavailable");await navigator.clipboard.writeText($),xt({title:be,tone:"success"})}catch{xt({title:o("common.copyContentFailed"),tone:"error"})}}async function ci($,be){typeof window<"u"&&!window.confirm(o("git.discardConfirm",{path:be}))||await Gn($)}function ui($){const be=($==null?void 0:$.desktopFloating)===!0&&!Se,st=be?{top:(Ce==null?void 0:Ce.top)??Ds,left:(Ce==null?void 0:Ce.left)??Ds,maxHeight:Ce==null?void 0:Ce.maxHeight,transformOrigin:(Ce==null?void 0:Ce.transformOrigin)??"top right"}:void 0,At=n.jsxs("div",{ref:be?Jt:void 0,className:"git-operations-menu","data-floating":be?"true":"false",style:st,children:[n.jsxs("div",{className:"git-menu-section",children:[n.jsx("span",{className:"git-menu-caption",children:o("git.currentBranch")}),n.jsx("strong",{className:"git-menu-branch",children:ts})]}),n.jsxs("div",{className:"git-menu-section",children:[n.jsx("span",{className:"git-menu-caption",children:o("git.remoteAuthStatusLabel")}),n.jsxs("div",{className:"git-menu-branch-list",children:[n.jsx("strong",{className:"git-menu-branch",children:o(gs?"git.remoteAuthConfigured":"git.remoteAuthNotConfigured")}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>Kr(),children:n.jsx("span",{children:o("git.remoteAuthAction")})})]})]}),n.jsxs("div",{className:"git-menu-section",children:[n.jsx("span",{className:"git-menu-caption",children:o("git.branchTitle")}),n.jsx("div",{className:"git-menu-branch-list",children:M==null?void 0:M.local.map(en=>n.jsx("button",{className:"git-menu-item",type:"button",disabled:te||en.current,onClick:()=>void dr(en.name),children:n.jsx("span",{children:en.current?`${o("git.switchBranch")} ${en.name}`:`${o("git.switchBranchTo")} ${en.name}`})},en.name))})]}),n.jsxs("div",{className:"git-menu-section",children:[n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>{R(!1),De(!0)},children:n.jsx("span",{children:o("git.viewAllVersions")})}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>void sr("fetch"),children:n.jsx("span",{children:o("git.fetch")})}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>void sr("pull"),children:n.jsx("span",{children:o("git.pull")})}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>void sr("push"),children:n.jsx("span",{children:o("git.push")})}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te,onClick:()=>void Hr(),children:n.jsx("span",{children:o("git.undoLastCommit")})}),n.jsx("button",{className:"git-menu-item",type:"button",disabled:te||Y,onClick:()=>void Sn({resetTreeScroll:!0}),children:n.jsx("span",{children:o("git.refresh")})})]})]});return be?typeof document>"u"?null:$n.createPortal(At,document.body):At}function Ti($,be){if(be){vn.current.set($,be);return}vn.current.delete($)}function _r(){var st;if(!Qr||typeof document>"u")return null;const $=T.find(At=>At.commitHash===Qr);if(!$)return null;const be=((st=T[0])==null?void 0:st.commitHash)===$.commitHash&&$.commitKind==="local";return $n.createPortal(n.jsx("div",{ref:ur,className:"git-history-entry-menu","data-floating":"true",style:{top:(qe==null?void 0:qe.top)??Ds,left:(qe==null?void 0:qe.left)??Ds,maxHeight:qe==null?void 0:qe.maxHeight,transformOrigin:(qe==null?void 0:qe.transformOrigin)??"top right"},children:n.jsx(o8,{item:$,canUndo:be,actioning:te,onViewCommitChanges:At=>void ir(At),onCopyCommitHash:At=>void qr(At,o("git.copyCommitHashSuccess")),onCopyCommitMessage:At=>void qr(yl(At),o("git.copyCommitMessageSuccess")),onCopyCommitVersion:At=>void hr(At),onExplainCommitChange:At=>void ar(At),onUndoLastCommit:()=>void Hr()})}),document.body)}return n.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",e].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[n.jsxs("section",{className:"git-card git-scaffold-section",children:[n.jsxs("div",{className:"git-editor-row",children:[n.jsx("textarea",{ref:Jn,rows:1,value:O,onChange:$=>ne(FR($.target.value)),onKeyDown:$=>{$.key==="Enter"&&$.preventDefault()},placeholder:o("git.commitSubjectPlaceholder")}),n.jsx("button",{className:"git-icon-button",type:"button","aria-label":o("git.generateDraft"),title:o("git.generateDraft"),onClick:()=>void zn(),disabled:te||Y,children:n.jsx(v8,{})})]}),n.jsxs("div",{className:"git-primary-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Sn({resetTreeScroll:!0}),disabled:te||Y||!t,children:o("git.refreshNow")}),n.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(In){Lr();return}xr()},disabled:te||!In&&!Hn,children:o(In?"git.pushNow":"git.commitNow")})]})]}),Se?n.jsxs("div",{className:"git-mobile-sections",children:[n.jsx(dg,{title:o("git.stagedChangesTitle"),count:Cr.length,expanded:xe==="staged",onToggle:()=>lt("staged"),children:n.jsx(mj,{title:o("git.stagedChangesTitle"),nodes:fe,collapsedTreePathSet:it,onToggleTreePath:Lt,onToggleMobileSelection:Un,selectedMobilePathSet:tt,selectedTargets:Tt,actioning:te,variant:"staged",swipeRowState:ce,onSwipeRowChange:ge,onStageToggle:rr,onDiscardWithConfirm:ci,onClearSelectedTargets:()=>Ne($=>$.filter(be=>!Tt.includes(be))),onPreviewFile:nn})}),n.jsx(dg,{title:o("git.changesTitle"),count:V.length,expanded:xe==="unstaged",onToggle:()=>lt("unstaged"),children:n.jsx(mj,{title:o("git.changesTitle"),nodes:ve,collapsedTreePathSet:it,onToggleTreePath:Lt,onToggleMobileSelection:Un,selectedMobilePathSet:tt,selectedTargets:cn,actioning:te,variant:"unstaged",swipeRowState:ce,onSwipeRowChange:ge,onStageToggle:rr,onDiscardWithConfirm:ci,onClearSelectedTargets:()=>Ne($=>$.filter(be=>!cn.includes(be))),onPreviewFile:nn})}),n.jsxs(dg,{title:o("git.recentVersionsTitle"),count:N,expanded:xe==="history",onToggle:()=>lt("history"),trailingContent:n.jsx("span",{className:"badge",children:ts}),headerAction:n.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":o("git.operationMenu"),title:o("git.operationMenu"),"aria-expanded":X,onClick:()=>{lt("history"),R($=>!$)},disabled:te,children:n.jsx(cu,{})}),children:[X?n.jsx("div",{className:"git-mobile-operations-shell",children:ui()}):null,n.jsx(a8,{history:T,historyLoadingMore:E,hasMore:!!F,actioning:te,openCommitHash:Oe,onMenuTriggerRef:Ti,onToggleMenu:$=>bt(be=>be===$?null:$),onViewCommitChanges:$=>void ir($),onCopyCommitHash:$=>void qr($,o("git.copyCommitHashSuccess")),onCopyCommitMessage:$=>void qr(yl($),o("git.copyCommitMessageSuccess")),onCopyCommitVersion:$=>void hr($),onExplainCommitChange:$=>void ar($),onUndoLastCommit:()=>void Hr(),onLoadMore:()=>void _n()})]})]}):n.jsxs("div",{ref:ln,className:"git-content-split",style:{gridTemplateRows:ji},children:[n.jsx("section",{className:"git-card git-tree-panel",children:n.jsxs("div",{ref:jn,className:"git-tree-panel-body",children:[Cr.length>0?n.jsx(hj,{title:o("git.stagedChangesTitle"),count:Cr.length,nodes:fe,selectedPath:L,collapsedTreePathSet:it,onToggleTreePath:Lt,onSelectFile:Q,onPreviewFile:($,be)=>{mn($)&&nn($,be)},onToggleMobileSelection:Un,onStageToggle:rr,onDiscard:Gn,actioning:te,variant:"staged",isMobileViewport:Se,selectedMobilePathSet:tt,selectedTargets:Tt,mobileActionMenuOpen:Ee==="staged",onToggleMobileActionMenu:()=>ie($=>$==="staged"?null:"staged"),onClearSelectedTargets:()=>Ne($=>$.filter(be=>!Tt.includes(be)))}):null,n.jsx(hj,{title:o("git.changesTitle"),count:V.length,nodes:ve,selectedPath:L,collapsedTreePathSet:it,onToggleTreePath:Lt,onSelectFile:Q,onPreviewFile:($,be)=>{mn($)&&nn($,be)},onToggleMobileSelection:Un,onStageToggle:rr,onDiscard:Gn,actioning:te,variant:"unstaged",isMobileViewport:Se,selectedMobilePathSet:tt,selectedTargets:cn,mobileActionMenuOpen:Ee==="unstaged",onToggleMobileActionMenu:()=>ie($=>$==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>Ne($=>$.filter(be=>!cn.includes(be)))})]})}),n.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":o("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":aj,"aria-valuemax":lg,"aria-valuenow":P?rs:lg,"data-dragging":ft,onPointerDown:zr,children:n.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),n.jsxs("section",{className:"git-card git-history-section",children:[n.jsxs("div",{className:"git-history-topbar",children:[n.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,"aria-label":o(P?"git.collapseRecentVersions":"git.expandRecentVersions"),onClick:()=>U($=>!$),children:[n.jsxs("span",{className:"git-section-toggle-main",children:[n.jsx(Mm,{expanded:P}),n.jsx("span",{children:o("git.recentVersionsTitle")})]}),n.jsx("span",{className:"workbench-section-counter",children:N})]}),n.jsxs("div",{className:"git-history-actions",children:[n.jsx("span",{className:"badge",children:ts}),n.jsx("button",{className:"git-icon-button",type:"button",ref:bn,"aria-label":o("git.operationMenu"),title:o("git.operationMenu"),onClick:()=>R($=>!$),disabled:te,children:n.jsx(cu,{})}),X?ui({desktopFloating:!0}):null]})]}),P?n.jsx(fj,{history:T,historyLoadingMore:E,hasMore:!!F,actioning:te,openCommitHash:Ct,useNativeContextMenu:Zt,onMenuTriggerRef:Ti,onScroll:Vn,onToggleMenu:$=>{if(Zt){const be=T.find(st=>st.commitHash===$);be&&Qe(be);return}nt(be=>be===$?null:$)},onOpenContextMenu:$=>void Qe($),onViewCommitChanges:$=>void ir($),onCopyCommitHash:$=>void qr($,o("git.copyCommitHashSuccess")),onCopyCommitMessage:$=>void qr(yl($),o("git.copyCommitMessageSuccess")),onCopyCommitVersion:$=>void hr($),onExplainCommitChange:$=>void ar($),onUndoLastCommit:()=>void Hr(),onLoadMore:()=>void _n()}):null]})]}),n.jsxs(Ln,{open:Nt,title:o("git.selectRemoteTitle"),description:o("git.selectRemoteDesc"),onClose:()=>{te||Rt(!1)},children:[n.jsxs("div",{className:"git-remote-auth-banner",children:[n.jsxs("div",{className:"git-remote-auth-banner-copy",children:[n.jsx("strong",{children:o("git.remoteAuthStatusLabel")}),n.jsx("span",{children:o(gs?"git.remoteAuthConfigured":"git.remoteAuthNotConfigured")})]}),n.jsx("button",{className:"secondary-button",type:"button",disabled:te,onClick:()=>Kr(),children:o("git.remoteAuthAction")})]}),n.jsx("div",{className:"git-remote-select-list",children:Ft.map($=>{const be=ae.has($.name),st=It.get($.name);return n.jsxs("label",{className:"git-remote-item",children:[n.jsx("input",{type:"checkbox",checked:be,disabled:te,onChange:()=>{Be(At=>{const en=new Set(At);return en.has($.name)?en.delete($.name):en.add($.name),en})}}),n.jsxs("span",{className:"git-remote-item-body",children:[n.jsx("span",{className:"git-remote-name",children:$.name}),n.jsx("span",{className:"git-remote-url",children:$.pushUrl}),st&&n.jsx("span",{className:`git-remote-result ${st.ok?"ok":"err"}`,children:st.summary})]})]},$.name)})}),n.jsxs("div",{className:"git-remote-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:te,onClick:()=>Rt(!1),children:o("common.close")}),n.jsx("button",{className:"primary-button",type:"button",disabled:te||ae.size===0,onClick:()=>void es(Array.from(ae)),children:te?o("git.pushing"):o("git.pushSelected",{count:String(ae.size)})})]})]}),n.jsxs(Ln,{open:Wn,title:o("git.remoteAuthTitle"),description:Ls,onClose:()=>{te||Rn(!1)},children:[n.jsxs("div",{className:"workbench-clone-form",children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneAuthModeLabel")}),n.jsxs("select",{value:$t.authMode,disabled:te,onChange:$=>dn(be=>({...be,authMode:$.target.value})),children:[n.jsx("option",{value:"none",children:o("shell.cloneAuthModeNone")}),n.jsx("option",{value:"basic",children:o("shell.cloneAuthModeBasic")}),n.jsx("option",{value:"token",children:o("shell.cloneAuthModeToken")})]})]}),$t.authMode==="basic"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:$t.username,placeholder:pa,autoComplete:"username",onChange:$=>dn(be=>({...be,username:$.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:ns}),n.jsx("input",{type:"password",value:$t.password,placeholder:mr,autoComplete:"current-password",onChange:$=>dn(be=>({...be,password:$.target.value}))})]})]}):null,$t.authMode==="token"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:$t.username,placeholder:o("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:$=>dn(be=>({...be,username:$.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("shell.cloneTokenLabel")}),n.jsx("input",{type:"password",value:$t.token,placeholder:o("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:$=>dn(be=>({...be,token:$.target.value}))})]})]}):null,or?n.jsx("p",{className:"git-remote-auth-hint",children:o("git.remoteAuthGithubPatHint")}):null,$t.authMode!=="none"?n.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[n.jsx("input",{type:"checkbox",checked:$t.rememberOnHost,onChange:$=>dn(be=>({...be,rememberOnHost:$.target.checked}))}),n.jsx("span",{children:o("git.remoteAuthRemember")})]}):null,n.jsx("p",{className:"git-remote-auth-hint",children:o("git.remoteAuthSessionHint")})]}),n.jsxs("div",{className:"git-remote-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:te,onClick:()=>Rn(!1),children:o("common.close")}),n.jsx("button",{className:"primary-button",type:"button",disabled:te,onClick:Xr,children:o("git.remoteAuthSave")})]})]}),n.jsx(Ln,{open:et,title:o("git.viewAllVersions"),description:o("git.viewAllVersionsDescription",{count:String(N)}),onClose:()=>De(!1),children:n.jsx(fj,{history:T,historyLoadingMore:E,hasMore:!!F,actioning:te,openCommitHash:Ct,className:"git-history-modal-list",onMenuTriggerRef:Ti,onToggleMenu:$=>nt(be=>be===$?null:$),onViewCommitChanges:$=>void ir($),onCopyCommitHash:$=>void qr($,o("git.copyCommitHashSuccess")),onCopyCommitMessage:$=>void qr(yl($),o("git.copyCommitMessageSuccess")),onCopyCommitVersion:$=>void hr($),onExplainCommitChange:$=>void ar($),onUndoLastCommit:()=>void Hr(),onLoadMore:()=>void _n()})}),n.jsx(Ln,{open:Ue!==null,className:"git-commit-detail-modal",title:(Ve==null?void 0:Ve.subject)||o("git.commitDetailTitle"),description:Ve?o("git.commitDetailDescription",{hash:Ve.shortHash}):o("git.commitDetailLoading"),onClose:tn,children:ye?n.jsx("div",{className:"git-commit-detail-state",children:n.jsx("p",{children:o("git.commitDetailLoading")})}):je?n.jsx("div",{className:"git-commit-detail-state is-error",children:n.jsx("p",{children:je})}):Ve?n.jsxs("div",{className:"git-commit-detail-shell",children:[n.jsxs("div",{className:"git-commit-detail-meta-grid",children:[n.jsxs("div",{className:"git-commit-detail-meta-card",children:[n.jsx("span",{children:o("git.commitVersionLabel")}),n.jsx("strong",{children:Ve.versionLabel})]}),n.jsxs("div",{className:"git-commit-detail-meta-card",children:[n.jsx("span",{children:o("git.commitHashLabel")}),n.jsx("strong",{children:Ve.commitHash})]}),n.jsxs("div",{className:"git-commit-detail-meta-card",children:[n.jsx("span",{children:o("git.commitAuthorLabel")}),n.jsx("strong",{children:Ve.authorName})]}),n.jsxs("div",{className:"git-commit-detail-meta-card",children:[n.jsx("span",{children:o("git.commitTimeLabel")}),n.jsx("strong",{children:h8(Ve.authoredAt)})]})]}),n.jsxs("section",{className:"git-commit-detail-section",children:[n.jsx("div",{className:"git-commit-detail-section-header",children:n.jsx("h3",{children:o("git.commitMessageLabel")})}),n.jsx("pre",{className:"git-commit-detail-message",children:yl(Ve)})]}),n.jsxs("section",{className:"git-commit-detail-section",children:[n.jsxs("div",{className:"git-commit-detail-section-header",children:[n.jsx("h3",{children:o("git.changedFilesTitle")}),n.jsx("span",{className:"workbench-section-counter",children:Ve.changedFiles.length})]}),n.jsx("div",{className:"git-commit-detail-file-list",children:Ve.changedFiles.map($=>n.jsxs("div",{className:"git-commit-detail-file-item",children:[n.jsx("span",{className:"git-commit-detail-file-status","data-status":$.status,children:$.status}),n.jsxs("div",{className:"git-commit-detail-file-copy",children:[n.jsx("strong",{children:$.path}),$.oldPath?n.jsx("span",{children:o("git.renamedFromLabel",{path:$.oldPath})}):null]})]},`${$.status}:${$.oldPath??""}:${$.path}`))})]}),n.jsxs("section",{className:"git-commit-detail-section",children:[n.jsxs("div",{className:"git-commit-detail-section-header",children:[n.jsx("h3",{children:o("git.commitDiffLabel")}),Ve.diffTruncated?n.jsx("span",{className:"git-commit-detail-truncated",children:o("git.diffTruncated")}):null]}),n.jsx("pre",{className:"git-commit-detail-diff",children:Ve.diffContent||o("git.emptyDiff")})]})]}):n.jsx("div",{className:"git-commit-detail-state",children:n.jsx("p",{children:o("git.commitDetailEmpty")})})}),n.jsx(Ln,{open:Xe,className:"git-explain-provider-modal",title:o("git.explainCommitTitle"),description:o("git.explainCommitDescription"),onClose:()=>{pe||(ze(!1),Me(null),ht(null))},children:n.jsxs("div",{className:"git-explain-provider-shell",children:[n.jsx(Rv,{workspaceId:t,selectedProvider:vt,pendingProvider:pe?vt:null,disabled:pe,onSelect:$=>ht($)}),n.jsxs("div",{className:"git-explain-provider-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:pe,onClick:()=>{ze(!1),Me(null),ht(null)},children:o("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:!vt||pe,onClick:()=>void yt(),children:o(pe?"conversation.sendingState":"git.startExplainCommit")})]})]})}),n.jsx(gR,{workspaceId:t,filePath:oe,open:oe!==null,onClose:()=>{Re(null),Ut(null)},onSaved:async()=>{await Sn({resetTreeScroll:!0})},diffContent:_t}),_r()]})}function hj({title:e,count:t,nodes:r,selectedPath:s,collapsedTreePathSet:i,onToggleTreePath:l,onSelectFile:c,onPreviewFile:d,onToggleMobileSelection:m,onStageToggle:f,onDiscard:v,actioning:g,variant:w,isMobileViewport:k,selectedMobilePathSet:y,selectedTargets:C,mobileActionMenuOpen:T,onToggleMobileActionMenu:j,onClearSelectedTargets:N}){const D=uw(r),F=o(w==="staged"?"git.unstageAll":"git.stageAll");return n.jsxs("section",{className:"git-tree-group","data-variant":w,children:[n.jsxs("div",{className:"git-section-header git-tree-group-header",children:[n.jsx("h3",{children:e}),n.jsxs("div",{className:"git-tree-group-actions",children:[n.jsx("span",{className:"workbench-section-counter",children:t}),!k&&D.length>0?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"git-icon-button",type:"button","aria-label":F,title:F,onClick:()=>void f(D,w==="staged"),disabled:g,children:n.jsx(Tb,{staged:w==="staged"})}),w==="unstaged"?n.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":o("git.discardAll"),title:o("git.discardAll"),onClick:()=>void v(D),disabled:g,children:n.jsx(Nb,{})}):null]}):null,k&&C.length>0?n.jsx("button",{className:"git-icon-button",type:"button","aria-label":o("git.operationMenu"),title:o("git.operationMenu"),onClick:j,disabled:g,children:n.jsx(cu,{})}):null]}),k&&T?n.jsxs("div",{className:"git-selection-menu",children:[n.jsxs("div",{className:"git-menu-section",children:[n.jsx("span",{className:"git-menu-caption",children:o("git.selectedFiles")}),n.jsx("strong",{className:"git-menu-branch",children:C.length})]}),n.jsxs("div",{className:"git-menu-section",children:[n.jsx("button",{className:"git-menu-item",type:"button",disabled:g,onClick:()=>void f(C,w==="staged"),children:n.jsx("span",{children:o(w==="staged"?"git.unstage":"git.stage")})}),w==="unstaged"?n.jsx("button",{className:"git-menu-item",type:"button",disabled:g,onClick:()=>void v(C),children:n.jsx("span",{children:o("git.discard")})}):null,n.jsx("button",{className:"git-menu-item",type:"button",disabled:g,onClick:N,children:n.jsx("span",{children:o("git.clearSelection")})})]})]}):null]}),n.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":e,children:r.length?IR({nodes:r,depth:0,collapsedTreePathSet:i,selectedPath:s,onToggleTreePath:l,onSelectFile:c,onPreviewFile:d,onToggleMobileSelection:m,onStageToggle:f,onDiscard:v,actioning:g,variant:w,isMobileViewport:k,selectedMobilePathSet:y}):n.jsx("p",{className:"git-tree-status",children:o("git.noChanges")})})]})}function dg({title:e,count:t,expanded:r,onToggle:s,trailingContent:i,headerAction:l,children:c}){return n.jsxs("section",{className:"git-mobile-section","data-expanded":r,children:[n.jsxs("div",{className:"git-mobile-section-header",children:[n.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":r,onClick:s,children:[n.jsxs("span",{className:"git-mobile-section-toggle-main",children:[n.jsx(Mm,{expanded:r}),n.jsx("h3",{children:e})]}),n.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[i,n.jsx("span",{className:"workbench-section-counter",children:t})]})]}),l?n.jsx("div",{className:"git-mobile-section-header-action",children:l}):null]}),r?n.jsx("div",{className:"git-mobile-section-body",children:c}):null]})}function mj({title:e,nodes:t,collapsedTreePathSet:r,onToggleTreePath:s,onToggleMobileSelection:i,selectedMobilePathSet:l,selectedTargets:c,actioning:d,variant:m,swipeRowState:f,onSwipeRowChange:v,onStageToggle:g,onDiscardWithConfirm:w,onClearSelectedTargets:k,onPreviewFile:y}){return n.jsxs("div",{className:"git-mobile-record-shell",children:[c.length>0?n.jsxs("div",{className:"git-mobile-selection-toolbar",children:[n.jsxs("span",{className:"git-mobile-selection-count",children:[o("git.selectedFiles")," ",c.length]}),n.jsxs("div",{className:"git-mobile-selection-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:d,onClick:()=>void g(c,m==="staged"),children:o(m==="staged"?"git.unstage":"git.stage")}),m==="unstaged"?n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:d,onClick:()=>void w(c,`${c.length}`),children:o("git.discard")}):null,n.jsx("button",{type:"button",className:"secondary-button",disabled:d,onClick:k,children:o("git.clearSelection")})]})]}):null,n.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":e,children:t.length?AR({nodes:t,depth:0,collapsedTreePathSet:r,onToggleTreePath:s,onToggleMobileSelection:i,selectedMobilePathSet:l,actioning:d,variant:m,swipeRowState:f,onSwipeRowChange:v,onStageToggle:g,onDiscardWithConfirm:w,onPreviewFile:y}):n.jsx("p",{className:"git-tree-status",children:o("git.noChanges")})})]})}function AR({nodes:e,depth:t,collapsedTreePathSet:r,onToggleTreePath:s,onToggleMobileSelection:i,selectedMobilePathSet:l,actioning:c,variant:d,swipeRowState:m,onSwipeRowChange:f,onStageToggle:v,onDiscardWithConfirm:g,onPreviewFile:w}){return e.map(k=>{if(k.kind==="directory"){const T=!r.has(k.path),j=uw(k.children),N=`directory:${k.path}`;return n.jsxs("div",{className:"git-mobile-record-branch",children:[n.jsx(pj,{rowKey:N,openState:(m==null?void 0:m.path)===N?m.direction:null,onOpenStateChange:D=>f(D?{path:N,direction:D}:null),trailingActions:j.length>0?[{label:o(d==="staged"?"git.unstage":"git.stage"),tone:"accent",onPress:()=>void v(j,d==="staged")},...d==="unstaged"?[{label:o("git.discard"),tone:"danger",onPress:()=>void g(j,k.path)}]:[]]:null,children:n.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${uj+t*dj}px`},onClick:()=>s(k.path),children:[n.jsxs("span",{className:"git-mobile-record-leading",children:[n.jsx("span",{className:"git-tree-chevron","data-expanded":T,children:n.jsx(Mm,{expanded:T})}),n.jsx("span",{className:"git-mobile-record-title",children:k.name})]}),n.jsx("span",{className:"git-mobile-record-meta",children:j.length})]})}),T?n.jsx("div",{className:"git-mobile-record-children",role:"group",children:AR({nodes:k.children,depth:t+1,collapsedTreePathSet:r,onToggleTreePath:s,onToggleMobileSelection:i,selectedMobilePathSet:l,actioning:c,variant:d,swipeRowState:m,onSwipeRowChange:f,onStageToggle:v,onDiscardWithConfirm:g,onPreviewFile:w})}):null]},N)}const y=`file:${k.path}`,C=l.has(k.path);return n.jsx(pj,{rowKey:y,openState:(m==null?void 0:m.path)===y?m.direction:null,onOpenStateChange:T=>f(T?{path:y,direction:T}:null),trailingActions:[{label:o("git.preview"),tone:"neutral",onPress:()=>w(k.change.path,k.change)},{label:o(d==="staged"?"git.unstage":"git.stage"),tone:"accent",onPress:()=>void v([k.change.path],d==="staged")},...d==="unstaged"?[{label:o("git.discard"),tone:"danger",onPress:()=>void g([k.change.path],k.path)}]:[]],children:n.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":C,style:{paddingInlineStart:`${uj+t*dj}px`},children:[n.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:C,"aria-label":`${o("git.selectFile")} ${k.name}`,onChange:()=>i(k.change.path)}),n.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>i(k.change.path),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(k.name),"aria-hidden":"true",children:Ao(k.name)}),n.jsxs("span",{className:"git-mobile-record-copy",children:[n.jsx("span",{className:"git-mobile-record-title",children:k.name}),n.jsx("span",{className:"git-mobile-record-path",children:k.path})]}),n.jsx("span",{className:"git-status-badge","data-status":k.status,children:k.status})]})]})},y)})}function pj({rowKey:e,openState:t,onOpenStateChange:r,trailingActions:s,children:i}){const l=li(),c=p.useRef(null),[d,m]=p.useState(0),f=((s==null?void 0:s.length)??0)*cg;p.useEffect(()=>{t||m(0)},[t,e]);const v=d!==0?d:t==="trailing"?-f:0;function g(C){var T,j;C.button===0&&(c.current={pointerId:C.pointerId,startX:C.clientX},(j=(T=C.currentTarget).setPointerCapture)==null||j.call(T,C.pointerId))}function w(C){const T=c.current;if(!T||T.pointerId!==C.pointerId)return;const j=f>0?f+10:0,N=Math.max(-j,Math.min(0,C.clientX-T.startX));m(N)}function k(C){var j,N;const T=c.current;if(!(!T||T.pointerId!==C.pointerId)){if((N=(j=C.currentTarget).releasePointerCapture)==null||N.call(j,C.pointerId),c.current=null,d<=-44&&(s!=null&&s.length)){l.trigger("gesture"),r("trailing"),m(0);return}r(null),m(0)}}function y(C){var j,N;const T=c.current;!T||T.pointerId!==C.pointerId||((N=(j=C.currentTarget).releasePointerCapture)==null||N.call(j,C.pointerId),c.current=null,m(0))}return n.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":t??"closed","data-dragging":d!==0,children:[s==null?void 0:s.map((C,T)=>n.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":C.tone,style:{right:T*cg,width:cg},onClick:()=>{l.trigger(C.tone==="danger"?"warning":"action"),r(null),C.onPress()},children:C.label},`trailing-${T}`)),n.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${v}px)`},onPointerDown:g,onPointerMove:w,onPointerUp:k,onPointerCancel:y,children:i})]})}function a8({history:e,historyLoadingMore:t,hasMore:r,actioning:s,openCommitHash:i,onMenuTriggerRef:l,onToggleMenu:c,onViewCommitChanges:d,onCopyCommitHash:m,onCopyCommitMessage:f,onCopyCommitVersion:v,onExplainCommitChange:g,onUndoLastCommit:w,onLoadMore:k}){return e.length?n.jsxs("div",{className:"git-mobile-history-list",children:[e.map(y=>n.jsx("article",{className:"git-mobile-history-entry","data-kind":y.commitKind,children:n.jsxs("div",{className:"git-mobile-history-entry-main",children:[n.jsx("span",{className:"git-history-marker","data-kind":y.commitKind,"aria-hidden":"true"}),n.jsxs("div",{className:"git-mobile-history-copy",children:[n.jsxs("div",{className:"git-history-title-row",children:[n.jsx("strong",{title:y.subject,children:y.subject}),n.jsx("span",{className:"git-history-kind-badge","data-kind":y.commitKind,children:_R(y.commitKind)})]}),y.refs.length>0?n.jsx("div",{className:"git-history-ref-list",children:y.refs.map(C=>n.jsx("span",{className:"git-history-ref-pill","data-kind":C.kind,"data-remote-index":String(OR(C.remoteName)),children:C.name},`${y.commitHash}:${C.kind}:${C.name}`))}):null,n.jsxs("div",{className:"git-history-meta",children:[n.jsx("span",{className:"git-history-hash",children:y.commitHash.slice(0,8)}),n.jsx("span",{children:y.authorName}),n.jsx("time",{dateTime:y.authoredAt,children:BR(y.authoredAt)})]})]}),n.jsx("button",{type:"button",className:"git-icon-button",ref:C=>l(y.commitHash,C),"aria-label":o("git.historyItemMenu"),onClick:()=>c(y.commitHash),children:n.jsx(cu,{})})]})},y.commitHash)),r?n.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:t,onClick:k,children:t?`${o("git.refreshNow")}...`:o("common.loadMore")}):null]}):n.jsx("p",{className:"git-tree-status",children:o("git.noHistory")})}function fj({history:e,historyLoadingMore:t,hasMore:r,actioning:s,openCommitHash:i,className:l,useNativeContextMenu:c=!1,onMenuTriggerRef:d,onScroll:m,onToggleMenu:f,onOpenContextMenu:v,onViewCommitChanges:g,onCopyCommitHash:w,onCopyCommitMessage:k,onCopyCommitVersion:y,onExplainCommitChange:C,onUndoLastCommit:T,onLoadMore:j}){return e.length?n.jsxs("div",{className:["git-history-list",l].filter(Boolean).join(" "),onScroll:m,children:[e.map(N=>{const D=i===N.commitHash;return n.jsxs("article",{className:"git-history-entry","data-kind":N.commitKind,"data-menu-open":D?"true":"false",onContextMenu:F=>{!c||!v||(F.preventDefault(),F.stopPropagation(),v(N))},children:[n.jsx("span",{className:"git-history-marker","data-kind":N.commitKind,"aria-hidden":"true"}),n.jsxs("div",{className:"git-history-body",children:[n.jsxs("div",{className:"git-history-title-row",children:[n.jsx("strong",{title:N.subject,children:N.subject}),n.jsxs("div",{className:"git-history-title-actions",children:[n.jsx("span",{className:"git-history-kind-badge","data-kind":N.commitKind,children:_R(N.commitKind)}),c?null:n.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:F=>d(N.commitHash,F),"aria-label":o("git.historyItemMenu"),onClick:()=>{f(N.commitHash)},children:n.jsx(cu,{})})]})]}),N.refs.length>0?n.jsx("div",{className:"git-history-ref-list",children:N.refs.map(F=>n.jsx("span",{className:"git-history-ref-pill","data-kind":F.kind,"data-remote-index":String(OR(F.remoteName)),children:F.name},`${N.commitHash}:${F.kind}:${F.name}`))}):null,n.jsxs("div",{className:"git-history-meta",children:[n.jsx("span",{className:"git-history-hash",children:N.commitHash.slice(0,8)}),n.jsx("span",{children:N.authorName}),n.jsx("time",{dateTime:N.authoredAt,children:BR(N.authoredAt)})]})]})]},N.commitHash)}),t?n.jsxs("p",{className:"git-history-loading",children:[o("git.refreshNow"),"..."]}):null,r?n.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:t,onClick:j,children:t?`${o("git.refreshNow")}...`:o("common.loadMore")}):null]}):n.jsx("p",{className:"status-text",children:o("git.noHistory")})}function o8({item:e,canUndo:t,actioning:r,onViewCommitChanges:s,onCopyCommitHash:i,onCopyCommitMessage:l,onCopyCommitVersion:c,onExplainCommitChange:d,onUndoLastCommit:m}){return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>s(e.commitHash),children:n.jsx("span",{children:o("git.viewCommitChanges")})}),n.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>i(e.commitHash),children:n.jsx("span",{children:o("git.copyCommitHash")})}),n.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>l(e),children:n.jsx("span",{children:o("git.copyCommitMessage")})}),n.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>c(e.commitHash),children:n.jsx("span",{children:o("git.copyCommitVersion")})}),n.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>d(e.commitHash),children:n.jsx("span",{children:o("git.explainCommitAction")})}),t?n.jsx("button",{type:"button",className:"git-menu-item",disabled:r,onClick:m,children:n.jsx("span",{children:o("git.undoLastCommit")})}):null]})}function IR({nodes:e,depth:t,collapsedTreePathSet:r,selectedPath:s,onToggleTreePath:i,onSelectFile:l,onPreviewFile:c,onToggleMobileSelection:d,onStageToggle:m,onDiscard:f,actioning:v,variant:g,isMobileViewport:w,selectedMobilePathSet:k}){return e.map(y=>{if(y.kind==="directory"){const j=!r.has(y.path),N=uw(y.children),D=`${o(g==="staged"?"git.unstage":"git.stage")} ${y.path}`,F=`${o("git.discard")} ${y.path}`;return n.jsxs("div",{className:"git-tree-node",children:[n.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":j,children:[n.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+t*8}px`},onClick:()=>i(y.path),children:[n.jsx("span",{className:"git-tree-chevron","data-expanded":j,children:n.jsx(Mm,{expanded:j})}),n.jsx("span",{className:"git-tree-label git-tree-label-directory",children:y.name})]}),!w&&N.length>0?n.jsxs("div",{className:"git-row-actions",children:[n.jsx("button",{className:"git-icon-button",type:"button","aria-label":D,title:D,onClick:()=>void m(N,g==="staged"),disabled:v,children:n.jsx(Tb,{staged:g==="staged"})}),g==="unstaged"?n.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":F,title:F,onClick:()=>void f(N),disabled:v,children:n.jsx(Nb,{})}):null]}):null]}),j?n.jsx("div",{className:"git-tree-children",role:"group",children:IR({nodes:y.children,depth:t+1,collapsedTreePathSet:r,selectedPath:s,onToggleTreePath:i,onSelectFile:l,onPreviewFile:c,onToggleMobileSelection:d,onStageToggle:m,onDiscard:f,actioning:v,variant:g,isMobileViewport:w,selectedMobilePathSet:k})}):null]},`directory:${y.path}`)}const C=k.has(y.path),T=w?C:s===y.path;return w?n.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":T,"data-mobile":"true",children:[n.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:C,"aria-label":`${o("git.selectFile")} ${y.name}`,onChange:()=>d(y.change.path)}),n.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":T,"data-mobile":"true",style:{paddingInlineStart:`${18+t*8}px`},onClick:()=>d(y.change.path),children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(y.name),"aria-hidden":"true",children:Ao(y.name)}),n.jsx("span",{className:"git-tree-label-wrap",children:n.jsx("span",{className:"git-tree-label",children:y.name})}),n.jsx("span",{className:"git-tree-file-meta",children:n.jsx("span",{className:"git-status-badge","data-status":y.status,children:y.status})})]})]},`file:${y.path}`):n.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":T,children:[n.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":T,style:{paddingInlineStart:`${18+t*8}px`},onClick:()=>{l(y.change.path),c&&c(y.change.path,y.change)},children:[n.jsx("span",{className:"git-tree-file-icon","data-kind":Io(y.name),"aria-hidden":"true",children:Ao(y.name)}),n.jsx("span",{className:"git-tree-label-wrap",children:n.jsx("span",{className:"git-tree-label",children:y.name})}),n.jsx("span",{className:"git-tree-file-meta",children:n.jsx("span",{className:"git-status-badge","data-status":y.status,children:y.status})})]}),n.jsxs("div",{className:"git-row-actions",children:[n.jsx("button",{className:"git-icon-button",type:"button","aria-label":y.variant==="staged"?o("git.unstage"):o("git.stage"),title:y.variant==="staged"?o("git.unstage"):o("git.stage"),onClick:()=>void m([y.change.path],y.variant==="staged"),disabled:v,children:n.jsx(Tb,{staged:y.variant==="staged"})}),g==="unstaged"?n.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":o("git.discard"),title:o("git.discard"),onClick:()=>void f([y.change.path]),disabled:v,children:n.jsx(Nb,{})}):null]})]},`file:${y.path}`)})}function gj(e,t){return{kind:"directory",name:e,path:t,children:new Map}}function bj(e,t){const r=gj("","");for(const s of e){const i=s.path.replace(/\\/g,"/"),l=i.split("/").filter(Boolean);let c=r;l.forEach((d,m)=>{const f=l.slice(0,m+1).join("/");if(m===l.length-1){c.children.set(`file:${f}`,{kind:"file",name:d,path:i,change:s,status:l8(s,t),variant:t});return}const v=`directory:${f}`,g=c.children.get(v);if(g&&g.kind==="directory"){c=g;return}const w=gj(d,f);c.children.set(v,w),c=w})}return LR(ER([...r.children.values()]))}function ER(e){return[...e].sort((t,r)=>t.kind!==r.kind?t.kind==="directory"?-1:1:t.name.localeCompare(r.name,"zh-CN")).map(t=>t.kind==="directory"?{kind:"directory",name:t.name,path:t.path,children:ER([...t.children.values()])}:t)}function LR(e){return e.map(t=>{var c;if(t.kind!=="directory")return t;const r=LR(t.children);let s=t.name,i=t.path,l=r;for(;l.length===1&&((c=l[0])==null?void 0:c.kind)==="directory";){const d=l[0];s=`${s}/${d.name}`,i=d.path,l=d.children}return{kind:"directory",name:s,path:i,children:l}})}function vj(e,t,r){const s=new Set(e);return t.filter(i=>Cb(i,r)&&s.has(i.path)).map(i=>i.path)}function uw(e){const t=[],r=new Set;function s(i){if(i.kind==="file"){r.has(i.path)||(r.add(i.path),t.push(i.path));return}i.children.forEach(s)}return e.forEach(s),t}function Cb(e,t){return t==="staged"?!!e.stagedStatus:!!e.worktreeStatus}function l8(e,t){return t==="staged"?e.stagedStatus??e.status:e.worktreeStatus??e.status}function c8(e){return{subject:FR(e).trim(),body:null,footer:null,source:"manual"}}function FR(e){return e.replace(/[\r\n]+/g," ")}function yl(e){const t=e.subject.trim(),r=e.body.trim();return r?`${t}
|
|
118
|
+
|
|
119
|
+
${r}`:t}function u8(e){const t=e.changedFiles.map(i=>`- [${i.status}] ${i.path}${i.oldPath?` (from ${i.oldPath})`:""}`).join(`
|
|
120
|
+
`),r=e.diffContent.length>ug?e.diffContent.slice(0,ug):e.diffContent,s=e.diffContent.length>ug||e.diffTruncated?`
|
|
121
|
+
注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${e.versionLabel}`,`Commit Hash:${e.commitHash}`,`提交标题:${e.subject}`,`提交作者:${e.authorName} <${e.authorEmail}>`,`提交时间:${e.authoredAt}`,"","变更文件:",t||"- 无",s,"","Diff:",r||"(empty diff)"].join(`
|
|
122
|
+
`)}function d8(e){if(!e)return;e.style.height="0px";const t=Math.min(Math.max(e.scrollHeight,34),120);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>120?"auto":"hidden"}function _R(e){switch(e){case"local":return o("git.historyKindLocal");case"remote":return o("git.historyKindRemote");default:return o("git.historyKindShared")}}function OR(e){if(!e)return 0;let t=0;for(const r of e)t=t*33+r.charCodeAt(0)>>>0;return t%6}function h8(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}function Cs(e,t){return e instanceof Ur?m8(e)??e.message:typeof e=="object"&&e&&"message"in e?e.message:t}function hg(e){return`git-sidebar.snapshot.${e}`}function m8(e){switch(e.errorCode){case"UNAUTHORIZED":return o("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return o("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return o("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return o("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return o("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return o("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return o("git.errors.invalidTarget");case"NOT_STAGED":return o("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return o("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return o("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return o("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return o("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return o("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return o("git.errors.pushFailed");case"GIT_PULL_FAILED":return o("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return o("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return o("git.errors.commandTimeout");case"GIT_DISCARD_FAILED":return o("git.discardFailed");case"GIT_UNDO_FAILED":return o("git.undoLastCommitFailed");default:return null}}function wj(e){return e instanceof Ur&&e.errorCode==="GIT_REMOTE_AUTH_FAILED"}function p8(e){return!e||!e.mode||e.mode==="none"?em:e.mode==="basic"?{authMode:"basic",username:e.username??"",password:e.password??"",token:"",rememberOnHost:!1}:e.mode==="token"?{authMode:"token",username:e.username??"",password:"",token:e.token??"",rememberOnHost:!1}:em}function f8(e){return e.authMode==="none"?null:e.authMode==="basic"?{mode:"basic",username:e.username.trim(),password:e.password}:{mode:"token",username:e.username.trim()||void 0,token:e.token}}function g8(e,t){const r=e.find(i=>i.name===t)??e.find(i=>i.name==="origin")??e[0];if(!r)return"generic";const s=r.pushUrl||r.fetchUrl;return b8(s)?"github":"generic"}function b8(e){const t=(e==null?void 0:e.trim().toLowerCase())??"";return t.startsWith("https://github.com/")||t.startsWith("http://github.com/")||t.startsWith("ssh://git@github.com/")||t.startsWith("git@github.com:")}function jb(e,t,r){const s=Math.max(0,r.width),i=Math.max(0,r.height),l=Math.max(0,i-Ds*2),c=Math.max(0,s-Ds*2),d=Math.min(Math.max(t.width||Sb,0),c),m=Math.max(0,i-e.bottom-th-Ds),f=Math.max(0,e.top-th-Ds),v=m<t.height&&f>m,w=mg(Math.max(v?f:m,i8),0,l),k=Math.min(Math.max(t.height,0),w),y=v?e.top-th-k:e.bottom+th,C=Math.max(Ds,i-Ds-k),T=Math.max(Ds,s-Ds-d);return{top:mg(y,Ds,C),left:mg(e.right-d,Ds,T),maxHeight:Math.max(0,w),transformOrigin:`${v?"bottom":"top"} right`}}function mg(e,t,r){return!Number.isFinite(e)||r<t?t:Math.min(Math.max(e,t),r)}function Mm({expanded:e}){return n.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:e?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:n.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Tb({staged:e}){return e?n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:n.jsx("path",{d:"M5 12h14"})}):n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("path",{d:"M12 5v14"}),n.jsx("path",{d:"M5 12h14"})]})}function Nb(){return n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function v8(){return n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:n.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function cu(){return n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function BR(e){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(e))}catch{return e}}const w8=Object.freeze(Object.defineProperty({__proto__:null,GitSidebar:cw,resolveGitOperationsMenuPosition:jb},Symbol.toStringTag,{value:"Module"})),jc=5;function WR({session:e}){const{showToast:t}=Qn(),{requestNavigationRefresh:r}=Pr(),[s,i]=p.useState(!1),[l,c]=p.useState(!1),[d,m]=p.useState(null),[f,v]=p.useState(null),[g,w]=p.useState(null),[k,y]=p.useState(""),[C,T]=p.useState(""),[j,N]=p.useState(jc),[D,F]=p.useState(!1),[W,E]=p.useState(0),I=p.useMemo(()=>{var G;return((G=e==null?void 0:e.title)==null?void 0:G.trim())||null},[e==null?void 0:e.title]),M=p.useMemo(()=>d?{workspaceId:d.workspaceId,project:d.project,session:d.session}:null,[d]),_=(d==null?void 0:d.latestFollowUpTask)??null;if(p.useEffect(()=>{i(!1),F(!1),v(null),m(null),y(""),T(""),N(jc)},[e==null?void 0:e.sessionId]),p.useEffect(()=>{if(!(e!=null&&e.sessionId)){c(!1);return}let G=!1;return c(!0),v(null),uO(e.sessionId).then(te=>{G||m(te.context)}).catch(te=>{G||(m(null),v(te instanceof Error?te.message:o("conversation.butlerActionLoadFailed")))}).finally(()=>{G||c(!1)}),()=>{G=!0}},[W,e==null?void 0:e.sessionId]),!(e!=null&&e.sessionId))return null;function L(){l||E(G=>G+1)}function Q(){!d&&!l&&L()}async function O(){if(!M){Q();return}const G=k.trim();if(!G){t({title:o("conversation.butlerFollowUpObjectiveRequired"),tone:"warning"});return}w("follow-up");try{const te=await nO({projectId:M.project.id,butlerSessionId:M.session.id,objective:G,completionCriteria:C.trim()||void 0,maxAutoContinueCount:j});m(K=>K&&{...K,latestFollowUpTask:te.task}),r(),t({title:o("conversation.butlerFollowUpStarted"),description:o("conversation.butlerFollowUpStartedDescription",{projectName:M.project.name}),tone:"success"}),y(""),T(""),N(jc),i(!1)}catch(te){t({title:o("conversation.butlerFollowUpFailed"),description:te instanceof Error?te.message:void 0,tone:"error"})}finally{w(null)}}async function ne(){if(_){w("follow-up");try{const G=await rO(_.id);m(te=>te&&{...te,latestFollowUpTask:G.task}),r(),t({title:o("conversation.butlerFollowUpStopped"),description:o("conversation.butlerFollowUpStoppedDescription"),tone:"success"}),i(!1)}catch(G){t({title:o("conversation.butlerFollowUpStopFailed"),description:G instanceof Error?G.message:void 0,tone:"error"})}finally{w(null)}}}async function Y(){if(!M){Q();return}w("verification");try{await dO({projectId:M.project.id,butlerSessionId:M.session.id,verificationType:"browser",targetRef:I||M.session.title||M.project.name}),r(),t({title:o("conversation.butlerVerificationStarted"),description:o("conversation.butlerVerificationStartedDescription",{projectName:M.project.name}),tone:"success"}),i(!1)}catch(G){t({title:o("conversation.butlerVerificationFailed"),description:G instanceof Error?G.message:void 0,tone:"error"})}finally{w(null)}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"conversation-butler-entry",onMouseEnter:()=>{F(!0),Q()},onMouseLeave:()=>{F(!1)},children:[n.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":o("conversation.butlerActionButton"),title:o("conversation.butlerActionButton"),onFocus:()=>{F(!0),Q()},onBlur:()=>{F(!1)},onClick:()=>{i(!0),Q()},children:n.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:n.jsx(gB,{})})}),D?n.jsxs("div",{className:"conversation-butler-analysis-popover",role:"status","aria-live":"polite",children:[n.jsx("strong",{children:o("conversation.butlerAnalysisTitle")}),l?n.jsx("p",{children:o("conversation.butlerActionLoading")}):f?n.jsx("p",{children:f}):_?n.jsxs(n.Fragment,{children:[n.jsxs("p",{children:[o("conversation.butlerAnalysisObjectiveLabel"),":",_.objective]}),n.jsxs("p",{children:[o("conversation.butlerAnalysisStatusLabel"),":",yj(_.status)]}),n.jsxs("p",{children:[o("conversation.butlerAnalysisSummaryLabel"),":",_.lastAutomationSummary||_.waitingReason||o("conversation.butlerAnalysisEmpty")]}),_.waitingReason?n.jsxs("p",{children:[o("conversation.butlerAnalysisWaitingReasonLabel"),":",_.waitingReason]}):null]}):n.jsx("p",{children:o("conversation.butlerAnalysisEmpty")})]}):null]}),n.jsx(Ln,{open:s,title:o("conversation.butlerActionModalTitle"),description:o("conversation.butlerActionModalDescription"),onClose:()=>{g||i(!1)},children:n.jsxs("div",{className:"conversation-butler-modal",children:[l?n.jsx("p",{className:"conversation-butler-modal-hint",children:o("conversation.butlerActionLoading")}):null,!l&&f?n.jsx("p",{className:"conversation-butler-modal-error",children:f}):null,!l&&!f&&M?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"conversation-butler-target-card",children:[n.jsx("span",{children:o("conversation.butlerActionProjectLabel")}),n.jsx("strong",{children:M.project.name})]}),n.jsxs("div",{className:"conversation-butler-target-card",children:[n.jsx("span",{children:o("conversation.butlerActionSessionLabel")}),n.jsx("strong",{children:M.session.title||I||M.session.sessionId})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("conversation.butlerFollowUpObjectiveLabel")}),n.jsx("textarea",{rows:4,value:k,placeholder:o("conversation.butlerFollowUpObjectivePlaceholder"),disabled:g!==null,onChange:G=>{y(G.target.value)}})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("conversation.butlerFollowUpCompletionCriteriaLabel")}),n.jsx("textarea",{rows:3,value:C,placeholder:o("conversation.butlerFollowUpCompletionCriteriaPlaceholder"),disabled:g!==null,onChange:G=>{T(G.target.value)}})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:o("conversation.butlerFollowUpRoundLimitLabel")}),n.jsx("input",{type:"number",min:1,max:20,value:j,disabled:g!==null,onChange:G=>{const te=Number.parseInt(G.target.value,10);N(Number.isFinite(te)?te:jc)}}),n.jsx("small",{children:o("conversation.butlerFollowUpRoundLimitHint")})]}),_&&(_.status==="active"||_.status==="waiting_user")?n.jsxs("div",{className:"conversation-butler-target-card",children:[n.jsx("span",{children:o("conversation.butlerCurrentFollowUpLabel")}),n.jsx("strong",{children:yj(_.status)}),n.jsx("small",{children:o("conversation.butlerCurrentFollowUpProgress",{current:_.autoContinueCount,max:_.maxAutoContinueCount??jc})}),n.jsx("button",{type:"button",className:"workbench-secondary-button",disabled:g!==null,onClick:()=>{ne()},children:o("conversation.butlerStopFollowUpAction")})]}):null,n.jsxs("div",{className:"conversation-butler-action-grid",children:[n.jsxs("button",{type:"button",className:"conversation-butler-action-card",disabled:g!==null,onClick:()=>{O()},children:[n.jsx("strong",{children:o("conversation.butlerFollowUpAction")}),n.jsx("span",{children:o("conversation.butlerFollowUpActionDescription")})]}),n.jsxs("button",{type:"button",className:"conversation-butler-action-card",disabled:g!==null,onClick:()=>{Y()},children:[n.jsx("strong",{children:o("conversation.butlerVerificationAction")}),n.jsx("span",{children:o("conversation.butlerVerificationActionDescription")})]})]})]}):null]})})]})}function yj(e){switch(e){case"waiting_user":return o("shell.butlerAutomationStatusWaitingUser");case"completed":return o("shell.butlerAutomationStatusCompleted");case"failed":return o("shell.butlerAutomationStatusFailed");case"cancelled":return o("shell.butlerAutomationStatusCancelled");case"active":default:return o("shell.butlerAutomationStatusActive")}}function y8({session:e}){return e?n.jsx(n.Fragment,{children:n.jsx(WR,{session:e})}):null}function k8({requests:e,replyingRequestId:t,onReply:r}){const[s,i]=p.useState({}),l=p.useMemo(()=>e.filter(c=>c.status==="pending"),[e]);return l.length===0?null:n.jsxs("section",{className:"permission-request-list",children:[n.jsxs("div",{className:"permission-request-list-header",children:[n.jsx("div",{children:n.jsx("strong",{children:o("conversation.permissionRequestSectionTitle")})}),n.jsx("span",{className:"permission-request-count",children:l.length})]}),n.jsx("div",{className:"permission-request-stack",children:l.map(c=>{var w,k;const d=s[c.id]??{},m=c.paths.filter(Boolean),f=c.kind==="command"&&!!((w=c.command)!=null&&w.trim()),v=c.questions.length===0&&m.length===0&&!f&&!!((k=c.summary)!=null&&k.trim()),g=c.kind==="user_input"&&c.questions.some(y=>{var C;return(((C=d[y.id])==null?void 0:C.filter(Boolean).length)??0)===0});return n.jsxs("article",{className:"permission-request-card",children:[n.jsxs("header",{className:"permission-request-card-header",children:[n.jsxs("div",{className:"permission-request-provider",children:[n.jsx("span",{className:"permission-request-provider-icon","aria-hidden":"true",children:n.jsx("img",{src:wP(c.provider),alt:"",loading:"lazy"})}),n.jsxs("div",{className:"permission-request-provider-copy",children:[n.jsx("strong",{children:c.title}),n.jsx("span",{children:qs(c.provider,"full")})]})]}),n.jsx("span",{className:"permission-request-kind",children:x8(c.kind)})]}),n.jsxs("div",{className:"permission-request-card-body",children:[m.length>0?n.jsx("div",{className:"permission-request-block",children:n.jsx("ul",{className:"permission-request-target-list",children:m.map(y=>n.jsxs("li",{className:"permission-request-target-item",children:[n.jsx("strong",{children:S8(y)}),n.jsx("span",{children:y})]},`${c.id}:${y}`))})}):null,f?n.jsxs("div",{className:"permission-request-block",children:[n.jsx("div",{className:"permission-request-block-label",children:o("conversation.permissionRequestCommandLabel")}),n.jsx("pre",{children:c.command})]}):null,v?n.jsx("p",{className:"permission-request-summary",children:c.summary}):null,c.questions.length>0?n.jsxs("div",{className:"permission-request-block",children:[n.jsx("div",{className:"permission-request-block-label",children:o("conversation.permissionRequestQuestionsLabel")}),n.jsx("div",{className:"permission-request-question-list",children:c.questions.map(y=>n.jsxs("div",{className:"permission-request-question",children:[n.jsx("div",{className:"permission-request-question-header",children:y.header}),n.jsx("p",{children:y.question}),n.jsx("div",{className:"permission-request-question-options",children:y.options.map(C=>{var j;const T=((j=d[y.id])==null?void 0:j.includes(C.label))??!1;return n.jsxs("label",{className:"permission-request-question-option",children:[n.jsx("input",{type:"radio",name:`${c.id}:${y.id}`,checked:T,onChange:()=>{i(N=>({...N,[c.id]:{...N[c.id]??{},[y.id]:[C.label]}}))}}),n.jsxs("span",{children:[n.jsx("strong",{children:C.label}),C.description?n.jsx("small",{children:C.description}):null]})]},`${y.id}:${C.label}`)})})]},y.id))})]}):null]}),n.jsx("footer",{className:"permission-request-card-footer",children:c.actions.map(y=>n.jsx("button",{type:"button",className:`permission-request-action permission-request-action-${y.tone}`,disabled:t===c.id||y.value==="submit"&&g,onClick:()=>void r(c.id,{action:y.value,answers:c.kind==="user_input"?d:void 0}),children:t===c.id?o("conversation.permissionRequestSubmitting"):y.label},`${c.id}:${y.value}`))})]},c.id)})})]})}function x8(e){return o(e==="command"?"conversation.permissionRequestKindCommand":e==="file_change"?"conversation.permissionRequestKindFileChange":e==="permissions"?"conversation.permissionRequestKindPermissions":e==="user_input"?"conversation.permissionRequestKindUserInput":"conversation.permissionRequestKindToolCall")}function S8(e){return e.split(/[/\\]+/).filter(Boolean).at(-1)??e}function C8({items:e,deletingQueueItemId:t=null,steeringQueueItemId:r=null,canSteer:s=!1,onDelete:i,onSteer:l}){return e.length===0?null:n.jsxs("section",{className:"queued-message-list","aria-label":o("conversation.queueTitle"),children:[n.jsx("div",{className:"queued-message-list__header",children:n.jsx("h2",{children:`${o("conversation.queueTitle")} · ${e.length}`})}),n.jsx("div",{className:"queued-message-list__items",children:e.map((c,d)=>{const m=c.status==="queued"||c.status==="failed",f=s&&typeof l=="function"&&c.status==="queued";return n.jsxs("article",{className:"queued-message-item",children:[n.jsxs("div",{className:"queued-message-item__main",children:[n.jsx("span",{className:"queued-message-item__order","aria-hidden":"true",children:d+1}),n.jsx("p",{className:"queued-message-item__content",title:c.content||o("conversation.queueImageOnly"),children:c.content||o("conversation.queueImageOnly")}),n.jsx("span",{className:`queued-message-item__status queued-message-item__status--${c.status}`,children:c.status==="failed"?o("conversation.queueStatusFailed"):o("conversation.queueStatusQueued")}),n.jsxs("div",{className:"queued-message-item__actions",children:[f?n.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--steer",onClick:()=>void l(c.id),disabled:r===c.id,"aria-label":o("conversation.queueSteer"),title:o("conversation.queueSteer"),children:r===c.id?o("conversation.queueSteering"):o("conversation.queueSteer")}):null,m?n.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--delete",onClick:()=>void i(c.id),disabled:t===c.id,"aria-label":o("conversation.queueDelete"),title:o("conversation.queueDelete"),children:t===c.id?"…":"×"}):null]})]}),c.errorDetail?n.jsx("p",{className:"queued-message-item__error",children:c.errorDetail}):null]},c.id)})})]})}const Pl=196,Co=82,kj=28,xj=24,UR=34,Pb=18,j8=332,nh=360,tm=840,T8=520,Sj=18,N8=.22,P8=2.4,D8=6;function R8(e,t){return(t.lastMessageAt??t.updatedAt).localeCompare(e.lastMessageAt??e.updatedAt)}function HR(e,t,r){var k,y;if(!t)return null;const s=e.find(C=>C.workspace.id===t);if(!s)return null;const i=new Map(s.sessions.map(C=>[C.sessionId,C])),l=i.get(r)??null;if(!l)return null;const c=new Map;for(const C of s.sessions){const T=((k=C.parentSessionId)==null?void 0:k.trim())||null;if(!T)continue;const j=c.get(T)??[];c.set(T,[...j,C.sessionId])}const d=new Set,m=new Set;let f=l,v=l.sessionId;for(;f&&!m.has(f.sessionId);){d.add(f.sessionId),m.add(f.sessionId),v=f.sessionId;const C=((y=f.parentSessionId)==null?void 0:y.trim())||null;f=C?i.get(C)??null:null}const g=zR(v,0,i,c,new Set),w=A8(g);return{root:g,current:l,currentPathIds:d,relatedSessionIds:w,sessionsById:i}}function M8(e){return((e==null?void 0:e.relatedSessionIds.size)??0)>1}function zR(e,t,r,s,i){const l=r.get(e);if(!l)throw new Error(`Session ${e} not found`);const c=new Set(i);c.add(e);const d=[...s.get(e)??[]].filter(m=>!c.has(m)).sort((m,f)=>{const v=r.get(m),g=r.get(f);return!v||!g?0:R8(v,g)});return{session:l,depth:t,children:d.map(m=>zR(m,t+1,r,s,c))}}function A8(e){const t=new Set;function r(s){t.add(s.session.sessionId),s.children.forEach(r)}return r(e),t}function qR(e){const t=eu(e),r=e.lastMessageAt??e.updatedAt,s=r?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(r)):null;return[qs(e.provider),s,t].filter(Boolean).join(" · ")}function $R(e){return e.isArchived===!0}function I8(e){return[...e].sort((t,r)=>t.sequence-r.sequence).filter(t=>t.content.trim().length>0||t.kind==="tool_call"||t.kind==="tool_result")}function E8(e,t){return e<=0||t<=0?1:Math.min(1,e/t)}function Db(e,t,r){return Math.min(r,Math.max(t,e))}function L8(e,t,r,s){if(e<=0||t<=0||r<=0||s<=0)return 1;const i=Math.max(1,e-Sj*2),l=Math.max(1,t-Sj*2);return Math.min(1,i/r,l/s)}function nm(e,t,r,s,i){const l=s*e.scale,c=i*e.scale,d=(t-l)/2,m=(r-c)/2,f=l<=t?d:Db(e.offsetX,t-l,0),v=c<=r?m:Db(e.offsetY,r-c,0);return{scale:e.scale,offsetX:f,offsetY:v}}function rh(e,t,r,s){const i=L8(e,t,r,s);return nm({scale:i,offsetX:(e-r*i)/2,offsetY:(t-s*i)/2},e,t,r,s)}function F8(e,t,r,s,i,l,c,d){const m=(r-e.offsetX)/e.scale,f=(s-e.offsetY)/e.scale;return nm({scale:t,offsetX:r-m*t,offsetY:s-f*t},i,l,c,d)}function _8(e){var r;const t=e.content.trim();if(t.length>0){const s=t.replace(/\s+/g," ").trim();return s.length<=160?s:`${s.slice(0,157)}...`}return(r=e.toolCall)!=null&&r.name?`${e.toolCall.name} ${o("conversation.branchTreeToolMessageFallback")}`:o("conversation.branchTreeMessageEmpty")}function O8(e){switch(e.role){case"assistant":return o("conversation.roleAssistant");case"system":return o("conversation.roleSystem");case"tool":return o("conversation.roleTool");case"user":default:return o("conversation.roleUser")}}function Rb(e,t){const r=t.get(e.session.sessionId);if(r!==void 0)return r;if(e.children.length===0)return t.set(e.session.sessionId,Pl),Pl;const s=e.children.reduce((l,c,d)=>{const m=l+Rb(c,t);return d===0?m:m+Pb},0),i=Math.max(Pl,s);return t.set(e.session.sessionId,i),i}function B8(e){const t=new Map,r=[],s=new Map;function i(d,m,f){const v=Rb(d,t),g=m+v/2,w=xj+f*(Co+UR),k=g-Pl/2,y=d.children.reduce((N,D,F)=>{const W=N+Rb(D,t);return F===0?W:W+Pb},0);let C=m+Math.max(0,(v-y)/2);const T=d.children.map(N=>{const D=i(N,C,f+1);return C+=D.subtreeWidth+Pb,D}),j={node:d,children:T,x:k,y:w,centerX:g,centerY:w+Co/2,subtreeWidth:v};return r.push(j),s.set(d.session.sessionId,j),j}const l=i(e,kj,0),c=r.reduce((d,m)=>Math.max(d,m.y+Co),0);return{root:l,nodes:r,bySessionId:s,width:l.subtreeWidth+kj*2,height:c+xj}}function W8(e){return Math.max(0,Math.min(255,Number.parseFloat(e)))}function U8(e){const t=e.trim();if(t.startsWith("#")){const s=t.slice(1);if(s.length===3){const[i,l,c]=s.split("").map(d=>Number.parseInt(d.repeat(2),16));return{r:i,g:l,b:c}}if(s.length>=6)return{r:Number.parseInt(s.slice(0,2),16),g:Number.parseInt(s.slice(2,4),16),b:Number.parseInt(s.slice(4,6),16)}}const r=t.match(/rgba?\(([^)]+)\)/i);if(r){const[s,i,l]=r[1].split(",").map(c=>W8(c));return{r:s,g:i,b:l}}return null}function sa(e,t,r){const s=U8(e);return s?`rgba(${s.r}, ${s.g}, ${s.b}, ${t})`:r}function H8(e,t,r,s,i,l){const c=e.getContext("2d");if(!c)return;const d=c,m=window.devicePixelRatio||1;e.width=Math.max(1,Math.floor(t.width*m)),e.height=Math.max(1,Math.floor(t.height*m)),e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,d.setTransform(m,0,0,m,0,0),d.clearRect(0,0,t.width,t.height);const f=window.getComputedStyle(e),v=f.getPropertyValue("--accent").trim()||"#3b82f6",g=f.getPropertyValue("--border-primary").trim()||"#d4d8df",w=f.getPropertyValue("--bg-surface").trim()||"#ffffff";if(!l){const y=d.createLinearGradient(0,0,t.width,t.height);y.addColorStop(0,sa(w,.38,"rgba(255, 255, 255, 0.38)")),y.addColorStop(1,sa(v,.05,"rgba(59, 130, 246, 0.05)")),d.fillStyle=y,d.fillRect(0,0,t.width,t.height)}function k(y){for(const C of y.children){const T=s.has(y.node.session.sessionId)&&s.has(C.node.session.sessionId),j=y.node.session.sessionId===i||C.node.session.sessionId===i;d.beginPath(),d.moveTo(y.centerX,y.y+Co-10);const N=y.y+Co+UR*.52;d.bezierCurveTo(y.centerX,N,C.centerX,N,C.centerX,C.y+10),d.lineWidth=j?3:T?2.5:1.5,d.strokeStyle=j?sa(v,.52,"rgba(59, 130, 246, 0.52)"):T?sa(v,.32,"rgba(59, 130, 246, 0.32)"):sa(g,.72,"rgba(148, 163, 184, 0.72)"),d.stroke(),d.beginPath(),d.arc(C.centerX,C.y,j?4.5:3.5,0,Math.PI*2),d.fillStyle=j?sa(v,.9,"rgba(59, 130, 246, 0.9)"):sa(g,.78,"rgba(148, 163, 184, 0.78)"),d.fill(),k(C)}}k(t.root);for(const y of t.nodes){const C=y.node.session.sessionId===r,T=y.node.session.sessionId===i,j=s.has(y.node.session.sessionId);if(!C&&!T&&!j)continue;const N=d.createRadialGradient(y.centerX,y.centerY,10,y.centerX,y.centerY,T?90:64);N.addColorStop(0,sa(v,T?.22:.14,"rgba(59, 130, 246, 0.22)")),N.addColorStop(1,"rgba(59, 130, 246, 0)"),d.fillStyle=N,d.beginPath(),d.ellipse(y.centerX,y.centerY,Pl*.72,Co*.9,0,0,Math.PI*2),d.fill(),(T||C)&&(d.beginPath(),d.arc(y.centerX,y.y+12,T?6:5,0,Math.PI*2),d.fillStyle=sa(v,.94,"rgba(59, 130, 246, 0.94)"),d.fill())}}function z8(e,t,r){const s=Math.min(j8,t-24),i=e.left+e.width/2-s/2,l=Math.max(12,Math.min(t-s-12,i)),m=r-e.bottom-12<220&&e.top>nh?Math.max(12,e.top-nh-12):Math.max(12,Math.min(r-nh-12,e.bottom+12));return{width:s,left:l,top:m,maxHeight:Math.min(nh,r-24)}}function q8({model:e,selectedSession:t,selectedTreeNode:r,previewEntry:s,onClose:i,onOpenSession:l}){const c=$i(t.title,o("common.unknown")),d=t.sessionId===e.current.sessionId,m=$R(t),f=Cu(r.session),v=jv(r.session),g=Tv(r.session),w=CP(r.session);return n.jsxs("div",{className:"conversation-branch-preview-popover",role:"dialog","aria-label":`${o("conversation.branchTreePreviewTitle")} ${c.fullTitle}`,children:[n.jsxs("div",{className:"conversation-branch-preview-popover-header",children:[n.jsxs("div",{className:"conversation-branch-preview-card-title-row",children:[n.jsx("strong",{title:c.fullTitle,children:c.displayTitle}),d?n.jsx("span",{className:"conversation-branch-current-badge",children:o("conversation.branchTreeCurrentBadge")}):null,m?n.jsx("span",{className:"conversation-branch-archived-badge",children:o("conversation.branchTreeArchivedBadge")}):null]}),n.jsx("button",{type:"button",className:"conversation-branch-preview-close","aria-label":o("common.close"),onClick:i,children:"x"})]}),n.jsx("p",{className:"conversation-branch-preview-popover-meta",children:qR(t)}),v&&f||w&&g?n.jsxs("div",{className:"conversation-branch-badge-row",children:[w&&g?n.jsx("span",{className:`session-fork-badge ${g}`,children:w}):null,v&&f?n.jsx("span",{className:`session-fork-badge ${f}`,children:v}):null]}):null,n.jsx("div",{className:"conversation-branch-preview-messages",children:s.status==="loading"?n.jsx("p",{className:"conversation-branch-empty",children:o("conversation.branchTreePreviewLoading")}):s.status==="error"?n.jsx("p",{className:"conversation-branch-empty",children:s.error||o("conversation.branchTreePreviewFailed")}):s.messages.length>0?s.messages.map(k=>n.jsxs("article",{className:"conversation-branch-preview-message",children:[n.jsxs("div",{className:"conversation-branch-preview-message-meta",children:[n.jsx("span",{children:O8(k)}),n.jsx("span",{children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(k.timestamp))})]}),n.jsx("p",{children:_8(k)})]},`${t.sessionId}:${k.messageId}`)):n.jsx("p",{className:"conversation-branch-empty",children:o("conversation.branchTreePreviewEmpty")})}),n.jsx("div",{className:"conversation-branch-preview-actions",children:n.jsx("button",{type:"button",className:"secondary-button",disabled:d,onClick:()=>l(t),children:o(d?"conversation.branchTreeCurrentAction":"conversation.branchTreeSwitchAction")})})]})}function $8({layout:e,model:t,selectedSessionId:r,onSelectSession:s,onBackgroundClick:i,stageScale:l,transform:c,isMobileViewport:d,viewportRef:m,onRegisterNodeElement:f,onViewportTouchStart:v,onViewportTouchMove:g,onViewportTouchEnd:w}){const k=p.useRef(null);return p.useEffect(()=>{const y=k.current;y&&H8(y,e,t.current.sessionId,t.currentPathIds,r,d)},[d,e,t.current.sessionId,t.currentPathIds,r]),n.jsx("div",{ref:m,className:"conversation-branch-canvas-viewport","data-scaled":l<.999,"data-mobile":d,onClick:y=>{y.target===y.currentTarget&&(i==null||i())},onTouchStart:v,onTouchMove:g,onTouchEnd:w,onTouchCancel:w,children:n.jsx("div",{className:"conversation-branch-canvas-stage-shell",style:{width:d?"100%":e.width*l,height:d?"100%":e.height*l},onClick:y=>{y.target===y.currentTarget&&(i==null||i())},children:n.jsxs("div",{className:"conversation-branch-canvas-stage",style:{width:e.width,height:e.height,transform:c?`translate(${c.offsetX}px, ${c.offsetY}px) scale(${c.scale})`:`scale(${l})`,transformOrigin:"top left"},onClick:()=>{if(i){i();return}s(null)},children:[n.jsx("canvas",{ref:k,className:"conversation-branch-canvas",width:e.width,height:e.height,"aria-hidden":"true"}),e.nodes.map(y=>{const C=$i(y.node.session.title,o("common.unknown")),T=Cu(y.node.session),j=jv(y.node.session),N=Tv(y.node.session),D=CP(y.node.session),F=y.node.session.sessionId===t.current.sessionId,W=y.node.session.sessionId===r,E=t.currentPathIds.has(y.node.session.sessionId),I=$R(y.node.session);return n.jsx("button",{ref:M=>f(y.node.session.sessionId,M),type:"button",className:"conversation-branch-smart-card conversation-branch-canvas-node","data-current":F,"data-selected":W,"data-current-path":E,"data-archived":I,style:{left:y.x,top:y.y,width:Pl,minHeight:Co},"aria-pressed":W,onClick:M=>{M.stopPropagation(),s(y.node.session.sessionId)},children:n.jsxs("div",{className:"conversation-branch-smart-card-main",children:[n.jsxs("div",{className:"conversation-branch-smart-card-title-row",children:[n.jsx("strong",{title:C.fullTitle,children:C.displayTitle}),F?n.jsx("span",{className:"conversation-branch-current-badge",children:o("conversation.branchTreeCurrentBadge")}):null,I?n.jsx("span",{className:"conversation-branch-archived-badge",children:o("conversation.branchTreeArchivedBadge")}):null]}),n.jsx("p",{children:qR(y.node.session)}),j&&T||D&&N?n.jsxs("div",{className:"conversation-branch-badge-row",children:[D&&N?n.jsx("span",{className:`session-fork-badge ${N}`,children:D}):null,j&&T?n.jsx("span",{className:`session-fork-badge ${T}`,children:j}):null]}):null]})},y.node.session.sessionId)})]})})})}function V8({model:e,onOpenSession:t,onClose:r,dialogLabel:s,dialogStyle:i,showResizeHandle:l,onBeginResize:c}){const d=p.useMemo(()=>B8(e.root),[e.root]),m=p.useRef(null),f=p.useRef(new Map),[v,g]=p.useState(null),[w,k]=p.useState(0),[y,C]=p.useState(0),[T,j]=p.useState(null),[N,D]=p.useState({}),F=p.useRef(new Set),[W,E]=p.useState(typeof window<"u"?window.innerWidth<=tm:!1),[I,M]=p.useState(null),_=p.useRef({mode:"idle",startDistance:0,startScale:1,startOffsetX:0,startOffsetY:0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1});p.useEffect(()=>{const q=m.current;if(!q)return;const P=q;function U(){k(P.clientWidth),C(P.clientHeight),E(window.innerWidth<=tm)}if(U(),typeof ResizeObserver>"u")return window.addEventListener("resize",U),()=>window.removeEventListener("resize",U);const X=new ResizeObserver(U);return X.observe(q),()=>X.disconnect()},[]),p.useEffect(()=>{g(null)},[e.current.sessionId,e.root.session.sessionId]);const L=p.useMemo(()=>E8(w,d.width),[w,d.width]);p.useEffect(()=>{if(!W||w<=0||y<=0){M(null);return}M(q=>q?nm(q,w,y,d.width,d.height):rh(w,y,d.width,d.height))},[y,w,W,d.height,d.width]);const Q=v?e.sessionsById.get(v)??null:null,O=Q?d.bySessionId.get(Q.sessionId)??null:null,ne=Q?N[Q.sessionId]??{status:"idle",messages:[],error:null}:null,Y=W&&!!r;p.useEffect(()=>{if(!v){j(null);return}const q=v;function P(){const U=f.current.get(q);if(!U){j(null);return}j(U.getBoundingClientRect())}return P(),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[v,L]),p.useEffect(()=>{if(!W)return;const q=v;if(!q)return;const P=window.requestAnimationFrame(()=>{const U=f.current.get(q);U&&j(U.getBoundingClientRect())});return()=>window.cancelAnimationFrame(P)},[W,I,v]),p.useEffect(()=>{if(!(Q!=null&&Q.sessionId)||(ne==null?void 0:ne.status)==="ready"||F.current.has(Q.sessionId))return;let q=!1;return F.current.add(Q.sessionId),D(P=>{var U;return{...P,[Q.sessionId]:{status:"loading",messages:((U=P[Q.sessionId])==null?void 0:U.messages)??[],error:null}}}),kv(Q.sessionId,null,6,"backward").then(P=>{F.current.delete(Q.sessionId),!q&&D(U=>({...U,[Q.sessionId]:{status:"ready",messages:I8(P.messages),error:null}}))}).catch(P=>{F.current.delete(Q.sessionId),!q&&D(U=>{var X;return{...U,[Q.sessionId]:{status:"error",messages:((X=U[Q.sessionId])==null?void 0:X.messages)??[],error:P instanceof Error?P.message:o("conversation.branchTreePreviewFailed")}}})}),()=>{q=!0}},[Q==null?void 0:Q.sessionId]);function G(q){!W||w<=0||y<=0||M(P=>{const U=P??rh(w,y,d.width,d.height);return nm(q(U),w,y,d.width,d.height)})}function te(q){if(!W)return;const P=q.currentTarget.getBoundingClientRect();if(q.touches.length>=2){const R=q.touches[0],Se=q.touches[1],se=Math.hypot(Se.clientX-R.clientX,Se.clientY-R.clientY),J=(R.clientX+Se.clientX)/2-P.left,Ne=(R.clientY+Se.clientY)/2-P.top,Ee=I??rh(w,y,d.width,d.height);_.current={mode:"pinch",startDistance:se,startScale:Ee.scale,startOffsetX:Ee.offsetX,startOffsetY:Ee.offsetY,startTouchX:J,startTouchY:Ne,anchorX:J,anchorY:Ne,moved:!1};return}const U=q.touches[0],X=I??rh(w,y,d.width,d.height);_.current={mode:"pan",startDistance:0,startScale:X.scale,startOffsetX:X.offsetX,startOffsetY:X.offsetY,startTouchX:U.clientX,startTouchY:U.clientY,anchorX:0,anchorY:0,moved:!1}}function K(q){if(!W)return;const P=_.current;if(q.touches.length>=2){const se=q.currentTarget.getBoundingClientRect(),J=q.touches[0],Ne=q.touches[1],Ee=Math.hypot(Ne.clientX-J.clientX,Ne.clientY-J.clientY);if(Ee<=0||P.startDistance<=0)return;q.preventDefault();const ie=(J.clientX+Ne.clientX)/2-se.left,xe=(J.clientY+Ne.clientY)/2-se.top,lt=Db(P.startScale*(Ee/P.startDistance),N8,P8);_.current={...P,mode:"pinch",moved:!0,anchorX:ie,anchorY:xe},G(Oe=>F8({...Oe,scale:P.startScale,offsetX:P.startOffsetX,offsetY:P.startOffsetY},lt,ie,xe,w,y,d.width,d.height));return}if(P.mode!=="pan"||q.touches.length!==1)return;const U=q.touches[0],X=U.clientX-P.startTouchX,R=U.clientY-P.startTouchY;(P.moved||Math.hypot(X,R)>=D8)&&(q.preventDefault(),_.current={...P,moved:!0},G(se=>({...se,offsetX:P.startOffsetX+X,offsetY:P.startOffsetY+R})))}function z(){_.current={mode:"idle",startDistance:0,startScale:(I==null?void 0:I.scale)??1,startOffsetX:(I==null?void 0:I.offsetX)??0,startOffsetY:(I==null?void 0:I.offsetY)??0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1}}return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:`conversation-branch-tree-pane${r?" conversation-branch-dialog":""}${Y?" conversation-branch-dialog-mobile-bare":""}`,role:r?"dialog":void 0,"aria-modal":r?"true":void 0,"aria-label":s,style:i,children:[Y?null:n.jsx("div",{className:"conversation-branch-tree-pane-header",children:n.jsxs("div",{className:"conversation-branch-tree-pane-topbar",children:[n.jsxs("div",{className:"conversation-branch-tree-pane-heading",children:[n.jsx("h3",{children:o("conversation.branchTreeMapTitle")}),n.jsx("p",{children:o("conversation.branchTreeMapDescription")})]}),r?n.jsx("button",{type:"button",className:"conversation-branch-pane-close","aria-label":o("common.close"),onClick:r,children:"x"}):null]})}),n.jsxs("div",{className:"conversation-branch-canvas-shell",children:[Y?n.jsx("button",{type:"button",className:"conversation-branch-pane-close conversation-branch-mobile-floating-close","aria-label":o("common.close"),onClick:r,children:"x"}):null,Y?null:n.jsx("div",{className:"conversation-branch-canvas-tip",children:o("conversation.branchTreePreviewDescription")}),n.jsx($8,{layout:d,model:e,selectedSessionId:v,onSelectSession:g,onBackgroundClick:Y?r:void 0,stageScale:L,transform:W?I:null,isMobileViewport:W,viewportRef:m,onRegisterNodeElement:(q,P)=>{if(P){f.current.set(q,P);return}f.current.delete(q)},onViewportTouchStart:te,onViewportTouchMove:K,onViewportTouchEnd:z})]}),l?n.jsx("div",{className:"conversation-branch-dialog-resizer",role:"separator","aria-orientation":"vertical","aria-label":o("conversation.branchTreeResizeHandle"),onMouseDown:q=>c==null?void 0:c(q.clientX)}):null]}),Q&&O&&ne&&T&&typeof document<"u"?$n.createPortal(n.jsx("div",{className:"conversation-branch-preview-floating",style:z8(T,window.innerWidth,window.innerHeight),children:n.jsx(q8,{model:e,selectedSession:Q,selectedTreeNode:O.node,previewEntry:ne,onClose:()=>g(null),onOpenSession:t})}),document.body):null]})}function G8({open:e,navigationGroups:t,workspaceId:r,sessionId:s,onClose:i,onOpenSession:l}){const c=p.useMemo(()=>HR(t,r,s),[t,s,r]),[d,m]=p.useState(null),[f,v]=p.useState(typeof window<"u"?window.innerWidth>tm:!0);function g(C){const T=Math.max(420,C-32),j=Math.min(T8,T),N=Math.min(Math.max(C*.5,j),T);return{minWidth:j,maxWidth:T,defaultWidth:N}}p.useEffect(()=>{if(!e)return;function C(T){T.key==="Escape"&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i,e]),p.useEffect(()=>{if(typeof window>"u")return;function C(){const T=window.innerWidth>tm;if(v(T),!T){m(null);return}const j=g(window.innerWidth);m(N=>N===null?j.defaultWidth:Math.min(j.maxWidth,Math.max(j.minWidth,N)))}return C(),window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[]);function w(C){if(typeof window>"u"||!f)return;const T=g(window.innerWidth),j=d??T.defaultWidth;function N(F){const W=F.clientX-C;m(Math.min(T.maxWidth,Math.max(T.minWidth,j+W)))}function D(){document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",D)}document.addEventListener("mousemove",N),document.addEventListener("mouseup",D)}if(!e||!c||typeof document>"u")return null;const k=g(window.innerWidth),y=f?d??k.defaultWidth:void 0;return $n.createPortal(n.jsxs("div",{className:"workbench-modal-layer conversation-branch-panel-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:i}),n.jsx(V8,{model:c,onOpenSession:l,onClose:i,dialogLabel:o("conversation.branchTreeTitle"),dialogStyle:y?{width:y,maxWidth:k.maxWidth,minWidth:k.minWidth}:void 0,showResizeHandle:f,onBeginResize:w})]}),document.body)}function K8(e){const t=e.trim().length;return t<=16?"xl":t<=26?"lg":t<=38?"md":"sm"}function VR({session:e,actions:t,workspaceContext:r=null}){const s=nr(),i=p.useCallback(d=>{!s.isDesktop||s.ui.osFamily!=="macos"||d.button!==0||cv(d.target)&&uv()},[s.isDesktop,s.ui.osFamily]);if(!e)return n.jsxs("header",{className:"conversation-header conversation-header-skeleton","aria-hidden":"true","data-window-drag-handle":"conversation-header",onMouseDownCapture:i,children:[n.jsxs("div",{className:"conversation-header-main",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx("span",{className:"skeleton-line long"})]}),t?n.jsx("div",{className:"conversation-header-actions",children:t}):null]});const l=$i(e.title,o("conversation.titleFallback")),c=K8(l.displayTitle);return n.jsxs("header",{className:"conversation-header","data-workspace-tone":(r==null?void 0:r.tone)??"root",style:ri(r),"data-window-drag-handle":"conversation-header",onMouseDownCapture:i,children:[n.jsx("div",{className:"conversation-header-main",children:n.jsx("h1",{className:`conversation-title is-${c}`,title:l.fullTitle,children:l.displayTitle})}),t?n.jsx("div",{className:"conversation-header-actions",children:t}):null]})}const Cj=30,GR=40,jj=300*1e3,Y8=600,X8=5e3,Q8=1e4;function pg(){const e=xi.getState().profile.defaultPermissionMode;return e==="default"?null:e}class J8{constructor(t,r={}){ot(this,"state");ot(this,"listeners",new Set);ot(this,"realtimeClient",null);ot(this,"historyBootstrapFallbackTimer",null);ot(this,"historyBootstrapEnvelopeReceived",!1);ot(this,"markSeenTimer",null);ot(this,"markSeenInFlight",!1);ot(this,"lastMarkSeenRequestAt",0);ot(this,"seenWatermark",null);ot(this,"runtimeRefreshTimer",null);ot(this,"runtimeRefreshMode",null);ot(this,"replaceSnapshotSeedOnBackfill",!1);ot(this,"pendingReplyDebugTraces",[]);ot(this,"hasAuthoritativeBootstrapMessages");ot(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ot(this,"getState",()=>this.state);var c;this.sessionId=t,this.options=r;const s=Er(vg(t),jj);this.hasAuthoritativeBootstrapMessages=(((c=r.bootstrapMessages)==null?void 0:c.length)??0)>0;const i=sh(r.initialSession??null,(s==null?void 0:s.session)??null),l=Cc((s==null?void 0:s.messages)??[],this.sessionId,r.bootstrapMessages??[]);this.replaceSnapshotSeedOnBackfill=!this.hasAuthoritativeBootstrapMessages&&((s==null?void 0:s.messages.length)??0)>0&&((s==null?void 0:s.pagesLoaded)??0)<=1,this.state=NC({session:i,capabilities:(s==null?void 0:s.capabilities)??null,runtimeHasActiveRun:(s==null?void 0:s.runtimeHasActiveRun)??null,runtimeCanInterrupt:(s==null?void 0:s.runtimeCanInterrupt)??null,contextUsage:(s==null?void 0:s.contextUsage)??null,messages:l,permissionRequests:(s==null?void 0:s.permissionRequests)??[],queuedMessages:(s==null?void 0:s.queuedMessages)??[],olderCursor:(s==null?void 0:s.olderCursor)??null,hasOlderMessages:(s==null?void 0:s.hasOlderMessages)??!1,lastCursor:(s==null?void 0:s.lastCursor)??null,interruptSource:(s==null?void 0:s.interruptSource)??null,pagesLoaded:(s==null?void 0:s.pagesLoaded)??0}),this.seenWatermark=(i==null?void 0:i.lastSeenAt)??null}async initialize(){this.historyBootstrapEnvelopeReceived=!1,this.clearHistoryBootstrapFallbackTimer();const t=this.options.bootstrapMessages??[],r=Cc(this.state.messages,this.sessionId,t),s=this.hasAuthoritativeBootstrapMessages;this.patch({messages:r,historyState:eG(this.state.session,s?r.length:0),loadingOlderMessages:!1,olderCursor:s?null:this.state.olderCursor,hasOlderMessages:kl({session:this.state.session,loadedMessageCount:r.length,olderCursor:s?null:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:s?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.shouldRefreshSessionDetail()&&this.refreshSessionMetadata(),this.shouldRefreshRuntimeSnapshot()&&this.refreshRuntimeSnapshot("bootstrap"),this.refreshPermissionRequests(),this.refreshQueue();try{this.startRealtime(),s&&this.scheduleMarkSeen()}catch(i){this.handleError(i)}}async reload(){var r,s;this.clearHistoryBootstrapFallbackTimer(),this.historyBootstrapEnvelopeReceived=!1,(r=this.realtimeClient)==null||r.close(),this.realtimeClient=null;const t=Er(vg(this.sessionId),jj);this.state=NC({session:sh(this.options.initialSession??null,(t==null?void 0:t.session)??null),capabilities:(t==null?void 0:t.capabilities)??null,runtimeHasActiveRun:(t==null?void 0:t.runtimeHasActiveRun)??null,runtimeCanInterrupt:(t==null?void 0:t.runtimeCanInterrupt)??null,contextUsage:(t==null?void 0:t.contextUsage)??null,messages:Cc((t==null?void 0:t.messages)??[],this.sessionId,this.options.bootstrapMessages??[]),permissionRequests:(t==null?void 0:t.permissionRequests)??[],queuedMessages:(t==null?void 0:t.queuedMessages)??[],olderCursor:(t==null?void 0:t.olderCursor)??null,hasOlderMessages:(t==null?void 0:t.hasOlderMessages)??!1,lastCursor:(t==null?void 0:t.lastCursor)??null,pagesLoaded:(t==null?void 0:t.pagesLoaded)??0}),this.seenWatermark=((s=this.state.session)==null?void 0:s.lastSeenAt)??null,this.replaceSnapshotSeedOnBackfill=!this.hasAuthoritativeBootstrapMessages&&((t==null?void 0:t.messages.length)??0)>0&&((t==null?void 0:t.pagesLoaded)??0)<=1,this.emit(),await this.initialize()}applyNavigationSession(t){if(!t||t.sessionId!==this.sessionId)return;const r=sh(this.state.session,t);r!==this.state.session&&this.patch({session:r,hasOlderMessages:kl({session:r,loadedMessageCount:this.state.messages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})})}async sendMessage(t,r){const s=Rj();this.beginPendingReplyDebugTrace("send_live",s,t.length);const i=X0(this.sessionId,t,s,(r==null?void 0:r.attachmentMeta)??[],(r==null?void 0:r.attachments)??[],a3(this.state.messages));this.patch({messages:[...this.state.messages,i],session:_i(this.state.session,"running"),runtimeHasActiveRun:Mj(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:Aj(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt});try{const l=await this.sendMessageWithFallback(t,s,r);this.markPendingReplyDebugTraceResponseReady(s,{returnedMessageId:l.message.messageId,returnedProviderSessionId:l.message.providerSessionId}),this.patch({messages:PC(this.state.messages,this.sessionId,l.message,s)})}catch(l){throw this.failPendingReplyDebugTrace(s,l),this.patch({messages:gb(this.state.messages,s),session:_i(this.state.session,"failed"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1}),l}}async retryMessage(t){const r=this.state.messages.find(s=>s.clientRequestId===t);if(r){this.patch({messages:this.state.messages.map(s=>s.clientRequestId===t?{...s,deliveryState:"sending"}:s),runtimeHasActiveRun:Mj(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:Aj(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt}),this.beginPendingReplyDebugTrace("retry_live",t,r.content.length);try{const s=await this.sendMessageWithFallback(r.content,t,{attachments:r.attachmentPayloads??[],attachmentMeta:r.attachments});this.markPendingReplyDebugTraceResponseReady(t,{returnedMessageId:s.message.messageId,returnedProviderSessionId:s.message.providerSessionId}),this.patch({messages:PC(this.state.messages,this.sessionId,s.message,t)})}catch(s){throw this.failPendingReplyDebugTrace(t,s),this.patch({messages:gb(this.state.messages,t),session:_i(this.state.session,"failed")}),s}}}async enqueueMessage(t,r){const s=Rj();try{const i=await i_(this.sessionId,{content:t,clientRequestId:s,model:(r==null?void 0:r.model)??null,reasoningLevel:(r==null?void 0:r.reasoningLevel)??null,permissionMode:pg(),attachments:(r==null?void 0:r.attachments)??[]});this.patch({queuedMessages:iG(this.state.queuedMessages,i)}),await this.refreshQueue()}catch(i){throw i}}async deleteQueuedMessage(t){await a_(this.sessionId,t),await this.refreshQueue()}async steerQueuedMessage(t){await o_(this.sessionId,t),await this.refreshRuntimeSnapshot("queue_steer")}async interrupt(){await dP(this.sessionId),this.patch({session:_i(this.state.session,"interrupted"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:"user",errorCode:null,errorDetail:null})}async replyPermissionRequest(t,r){if(!(this.state.permissionRequests.find(l=>l.id===t)??null))return;const i=await l_(this.sessionId,t,r);this.patch({permissionRequests:wg(this.state.permissionRequests,i)})}reconnect(){var t;(t=this.realtimeClient)==null||t.reconnectNow()}async loadOlderMessages(){var t;if(!(this.state.historyState!=="ready"||this.state.loadingOlderMessages||!this.state.olderCursor)){this.patch({loadingOlderMessages:!0,errorCode:null,errorDetail:null});try{if(!((t=this.realtimeClient)==null?void 0:t.requestOlderMessages(this.state.olderCursor,Cj)))throw new Error("REALTIME_NOT_CONNECTED")}catch(r){const s=r instanceof Error?r.message:"unknown";this.patch({loadingOlderMessages:!1,errorCode:"HISTORY_LOAD_MORE_FAILED",errorDetail:s})}}}destroy(){var t;this.clearHistoryBootstrapFallbackTimer(),(t=this.realtimeClient)==null||t.close(),this.realtimeClient=null,this.pendingReplyDebugTraces.length=0,this.markSeenTimer!==null&&(window.clearTimeout(this.markSeenTimer),this.markSeenTimer=null),this.runtimeRefreshTimer!==null&&(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null),this.runtimeRefreshMode=null}startRealtime(){var r;if(!((r=br.getState().session)==null?void 0:r.accessToken)){br.clear();return}this.realtimeClient=new Y0({sessionId:this.sessionId,cursor:this.state.lastCursor,limit:GR,onSubscribed:()=>{Ot("session_send.realtime_subscribed",{sessionId:this.sessionId,lastCursor:this.state.lastCursor}),this.patch({connectionState:"connected",hasOlderMessages:kl({session:this.state.session,loadedMessageCount:this.state.messages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})}),this.scheduleHistoryBootstrapFallback()},onConnectionChange:s=>{var l;const i=this.state.connectionState;if(this.patch({connectionState:s,session:s==="reconnecting"&&oa((l=this.state.session)==null?void 0:l.runningState)?_i(this.state.session,"reconnecting"):this.state.session}),s==="connected"){this.clearRuntimeRefreshTimer("poll"),i!=="closed"&&i!=="connected"&&this.patch({errorCode:null,errorDetail:null});return}this.scheduleRuntimeRefresh("poll","connection_state_change")},onEnvelope:s=>{var c,d;this.historyBootstrapEnvelopeReceived=!0,this.clearHistoryBootstrapFallbackTimer();const i=s.type==="session.backfill"&&this.replaceSnapshotSeedOnBackfill,l=this.mergeHistoryMessages(s.messages,s.type==="session.backfill");this.patch({messages:l,lastCursor:s.cursor,historyState:"ready",olderCursor:s.type==="session.backfill"&&!i&&this.state.pagesLoaded>1?this.state.olderCursor:s.olderCursor??this.state.olderCursor,hasOlderMessages:s.type==="session.backfill"?!i&&this.state.pagesLoaded>1?this.state.hasOlderMessages:!!s.olderCursor:kl({session:this.state.session,loadedMessageCount:l.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:s.type==="session.backfill"?!i&&this.state.pagesLoaded>1?this.state.pagesLoaded:Math.max(this.state.pagesLoaded,l.length>0?1:0):this.state.pagesLoaded,session:_i(this.state.session,Dj(s.type,(c=this.state.session)==null?void 0:c.runningState))}),(d=this.realtimeClient)==null||d.updateCursor(s.cursor),this.scheduleMarkSeen(),this.state.queuedMessages.length>0&&this.refreshQueue()},onOlderHistory:s=>{const i=this.mergeHistoryMessages(s.messages,!1);this.patch({messages:i,historyState:"ready",loadingOlderMessages:!1,olderCursor:s.olderCursor,hasOlderMessages:!!s.olderCursor,pagesLoaded:this.state.pagesLoaded+1,errorCode:null,errorDetail:null})},onRuntimeMessage:s=>{this.handleRuntimeMessage(s)},onActivity:s=>{this.handleActivity(s)},onRuntimeStatus:s=>{this.handleRuntimeStatus(s)},onRuntimeError:s=>{this.handleRuntimeError(s)},onInterrupted:s=>{this.handleInterrupted(s)},onPermissionRequest:s=>{this.handlePermissionRequest(s)},onPermissionRequestResolved:s=>{this.handlePermissionRequestResolved(s)},onError:s=>{this.patch({loadingOlderMessages:!1,errorCode:s.error_code,errorDetail:s.detail})},onUnauthorized:()=>{br.clear()}}),this.realtimeClient.start()}patch(t){let r=t;Object.prototype.hasOwnProperty.call(t,"session")&&(this.syncSeenWatermark(t.session??null),r={...t,session:this.applySeenWatermark(t.session??null)}),this.state={...this.state,...r},(Object.prototype.hasOwnProperty.call(r,"session")||Object.prototype.hasOwnProperty.call(r,"capabilities")||Object.prototype.hasOwnProperty.call(r,"contextUsage")||Object.prototype.hasOwnProperty.call(r,"messages")||Object.prototype.hasOwnProperty.call(r,"permissionRequests")||Object.prototype.hasOwnProperty.call(r,"queuedMessages"))&&this.persistSnapshot(),this.emit()}mergeHistoryMessages(t,r){const s=r&&this.replaceSnapshotSeedOnBackfill?this.state.messages.filter(l=>l.deliveryState!=="sent"):this.state.messages,i=Cc(s,this.sessionId,t);return r&&(this.replaceSnapshotSeedOnBackfill=!1),i}handleError(t){this.clearHistoryBootstrapFallbackTimer();const r=t instanceof Error?t.message:"unknown";this.patch({historyState:"error",errorCode:"RUNTIME_INIT_FAILED",errorDetail:r})}scheduleMarkSeen(){if(this.markSeenTimer!==null)return;const t=this.getTargetSeenAt();if(this.markSeenInFlight||t===null)return;const r=this.getMarkSeenThrottleDelayMs(),s=Math.max(Y8,r);this.markSeenTimer=window.setTimeout(()=>{this.markSeenTimer=null;const i=this.getTargetSeenAt();i!==null&&(Ot("session_seen.start",{sessionId:this.sessionId,targetSeenAt:i,seenWatermark:this.seenWatermark}),this.markSeenInFlight=!0,this.lastMarkSeenRequestAt=Date.now(),GF(this.sessionId).then(()=>{var l,c;this.bumpSeenWatermark(i),this.patch({session:Tj(this.state.session,i)}),(c=(l=this.options).onSeen)==null||c.call(l,this.sessionId,i),Ot("session_seen.end",{sessionId:this.sessionId,seenWatermark:this.seenWatermark})}).catch(()=>{Ot("session_seen.error",{sessionId:this.sessionId,targetSeenAt:i})}).finally(()=>{this.markSeenInFlight=!1,this.shouldMarkSeen()&&this.scheduleMarkSeen()}))},s)}clearRuntimeRefreshTimer(t){this.runtimeRefreshTimer!==null&&(t&&this.runtimeRefreshMode!==t||(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null))}scheduleHistoryBootstrapFallback(){this.historyBootstrapEnvelopeReceived||this.historyBootstrapFallbackTimer!==null||(this.historyBootstrapFallbackTimer=window.setTimeout(()=>{this.historyBootstrapFallbackTimer=null,!this.historyBootstrapEnvelopeReceived&&this.resolveHistoryBootstrapFallback()},350))}clearHistoryBootstrapFallbackTimer(){this.historyBootstrapFallbackTimer!==null&&(window.clearTimeout(this.historyBootstrapFallbackTimer),this.historyBootstrapFallbackTimer=null)}async resolveHistoryBootstrapFallback(){try{const t=await kv(this.sessionId,null,Cj,"backward");if(this.historyBootstrapEnvelopeReceived)return;this.historyBootstrapEnvelopeReceived=!0;const r=this.mergeHistoryMessages(t.messages,!0),s=this.replaceSnapshotSeedOnBackfill;this.patch({messages:r,historyState:"ready",olderCursor:!s&&this.state.pagesLoaded>1?this.state.olderCursor:t.nextCursor,hasOlderMessages:!s&&this.state.pagesLoaded>1?this.state.hasOlderMessages:kl({session:this.state.session,loadedMessageCount:r.length,olderCursor:t.nextCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),lastCursor:t.cursor??this.state.lastCursor,pagesLoaded:!s&&this.state.pagesLoaded>1?this.state.pagesLoaded:r.length>0?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.scheduleMarkSeen()}catch{}}scheduleRuntimeRefresh(t,r){var s,i;if(!oa((s=this.state.session)==null?void 0:s.runningState)){this.clearRuntimeRefreshTimer();return}t==="poll"&&this.state.connectionState==="connected"||(this.clearRuntimeRefreshTimer(),this.runtimeRefreshMode=t,Ot("session_runtime.refresh.schedule",{sessionId:this.sessionId,mode:t,reason:r,connectionState:this.state.connectionState,runningState:((i=this.state.session)==null?void 0:i.runningState)??null}),this.runtimeRefreshTimer=window.setTimeout(()=>{const l=this.runtimeRefreshMode??t;this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null,this.refreshRuntimeState(l,r)},t==="poll"?Q8:1200))}async refreshRuntimeState(t,r){var s,i,l,c,d;Ot("session_runtime.refresh.start",{sessionId:this.sessionId,mode:t,reason:r,connectionState:this.state.connectionState,runningState:((s=this.state.session)==null?void 0:s.runningState)??null});try{const m=await Kg(this.sessionId);this.patch({session:Nj(this.state.session,m),runtimeHasActiveRun:m.hasActiveRun,runtimeCanInterrupt:m.canInterrupt,contextUsage:m.contextUsage,...gg(m,this.state.interruptSource)}),await this.refreshQueue();const f=t==="poll"&&this.state.connectionState!=="connected"&&oa((i=this.state.session)==null?void 0:i.runningState);Ot("session_runtime.refresh.end",{sessionId:this.sessionId,mode:t,reason:r,connectionState:this.state.connectionState,runningState:((l=this.state.session)==null?void 0:l.runningState)??null,continuePolling:f}),f&&this.scheduleRuntimeRefresh("poll","connection_poll")}catch(m){Ot("session_runtime.refresh.error",{sessionId:this.sessionId,mode:t,reason:r,connectionState:this.state.connectionState,runningState:((c=this.state.session)==null?void 0:c.runningState)??null,message:m instanceof Error?m.message:"unknown"}),t==="poll"&&this.state.connectionState!=="connected"&&oa((d=this.state.session)==null?void 0:d.runningState)&&this.scheduleRuntimeRefresh("poll","connection_poll_retry")}}async refreshSessionMetadata(){const t=[];this.state.session===null&&t.push(wv(this.sessionId).then(r=>{this.patch({session:sh(r,this.state.session)})}).catch(()=>{})),Pj(this.state.capabilities)&&t.push(ZF(this.sessionId).then(r=>{this.patch({capabilities:r})}).catch(()=>{})),t.length!==0&&await Promise.allSettled(t)}async refreshPermissionRequests(){try{const t=await cP(this.sessionId);this.patch({permissionRequests:t.items})}catch{return}}shouldRefreshSessionDetail(){return this.state.session===null||Pj(this.state.capabilities)||this.state.session.runningState===null}shouldRefreshRuntimeSnapshot(){return this.state.contextUsage===null}async refreshRuntimeSnapshot(t){Ot("session_runtime.snapshot.start",{sessionId:this.sessionId,reason:t});try{const r=await Kg(this.sessionId);this.patch({session:Nj(this.state.session,r),runtimeHasActiveRun:r.hasActiveRun,runtimeCanInterrupt:r.canInterrupt,contextUsage:r.contextUsage,...gg(r,this.state.interruptSource)}),await this.refreshQueue(),Ot("session_runtime.snapshot.end",{sessionId:this.sessionId,reason:t,hasContextUsage:r.contextUsage!==null})}catch(r){Ot("session_runtime.snapshot.error",{sessionId:this.sessionId,reason:t,message:r instanceof Error?r.message:"unknown"})}}async refreshQueue(){try{const t=await s_(this.sessionId);this.patch({queuedMessages:t.items})}catch{return}}async sendMessageWithFallback(t,r,s){var i;try{return await Sv(this.sessionId,{content:t,clientRequestId:r,model:(s==null?void 0:s.model)??null,reasoningLevel:(s==null?void 0:s.reasoningLevel)??null,permissionMode:pg(),attachments:(s==null?void 0:s.attachments)??[]})}catch(l){if(!(l instanceof Ur)||l.status!==404&&l.status!==405||(((i=s==null?void 0:s.attachments)==null?void 0:i.length)??0)>0)throw l;return Ot("session_send.live_fallback",{sessionId:this.sessionId,clientRequestId:r,reason:l.message}),r_(this.sessionId,{content:t,clientRequestId:r,permissionMode:pg()})}}handleRuntimeStatus(t){var s;const r=fg((s=this.state.session)==null?void 0:s.runningState,t.status);this.patch({session:_i(this.state.session,r),runtimeHasActiveRun:oa(r)?this.state.runtimeHasActiveRun??!0:!1,runtimeCanInterrupt:oa(r)?this.state.runtimeCanInterrupt:!1,interruptSource:r==="interrupted"?t.interruptSource??this.state.interruptSource:r==="completed"||r==="failed"?null:this.state.interruptSource,errorCode:null,errorDetail:r===t.status?t.detail:this.state.errorDetail}),rm(r)&&(this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_terminal_before_message",{status:t.status,detail:t.detail}),this.clearRuntimeRefreshTimer(),this.refreshQueue(),this.refreshRuntimeSnapshot("runtime_terminal"))}handleActivity(t){if(this.patch({session:nG(this.state.session,t),runtimeHasActiveRun:t.hasActiveRun,runtimeCanInterrupt:t.canInterrupt,...gg(t,this.state.interruptSource)}),rm(t.runningState)){this.clearRuntimeRefreshTimer(),this.refreshQueue();return}(t.runningState==="stale"||t.runningState==="unknown")&&this.scheduleRuntimeRefresh("tail","activity_watchdog")}handleRuntimeMessage(t){var s;t.message.role==="assistant"&&this.completePendingReplyDebugTrace(t);const r=Cc(this.state.messages,this.sessionId,[t.message]);this.patch({messages:r,historyState:"ready",hasOlderMessages:kl({session:this.state.session,loadedMessageCount:r.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),session:_i(this.state.session,Dj("session.delta",(s=this.state.session)==null?void 0:s.runningState))}),this.scheduleMarkSeen(),this.state.queuedMessages.length>0&&this.refreshQueue()}handleRuntimeError(t){var s;const r=fg((s=this.state.session)==null?void 0:s.runningState,"failed");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_runtime_error",{errorCode:t.error_code,detail:t.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:_i(this.state.session,r),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:null,errorCode:r==="failed"?t.error_code:this.state.errorCode,errorDetail:r==="failed"?t.detail:this.state.errorDetail}),this.refreshQueue()}handleInterrupted(t){var s;const r=fg((s=this.state.session)==null?void 0:s.runningState,"interrupted");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_interrupted",{detail:t.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:_i(this.state.session,r),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:r==="interrupted"?t.interruptSource??this.state.interruptSource:this.state.interruptSource,errorCode:r==="interrupted"?null:this.state.errorCode,errorDetail:r==="interrupted"?t.detail:this.state.errorDetail}),this.refreshQueue()}handlePermissionRequest(t){this.patch({permissionRequests:wg(this.state.permissionRequests,t.request)})}handlePermissionRequestResolved(t){this.patch({permissionRequests:wg(this.state.permissionRequests,t.request)})}shouldMarkSeen(){return this.getTargetSeenAt()!==null}getTargetSeenAt(){const t=[...this.state.messages].reverse().find(s=>s.role!=="user");if(!t)return null;const r=this.seenWatermark;return r?t.timestamp>r?t.timestamp:null:t.timestamp}syncSeenWatermark(t){t!=null&&t.lastSeenAt&&this.bumpSeenWatermark(t.lastSeenAt)}bumpSeenWatermark(t){this.seenWatermark&&this.seenWatermark>=t||(this.seenWatermark=t)}getMarkSeenThrottleDelayMs(){return this.lastMarkSeenRequestAt<=0?0:Math.max(0,X8-(Date.now()-this.lastMarkSeenRequestAt))}applySeenWatermark(t){return!t||!this.seenWatermark?t:Tj(t,this.seenWatermark)}emit(){for(const t of this.listeners)t()}persistSnapshot(){As(vg(this.sessionId),{session:this.state.session,capabilities:this.state.capabilities,runtimeHasActiveRun:this.state.runtimeHasActiveRun,runtimeCanInterrupt:this.state.runtimeCanInterrupt,contextUsage:this.state.contextUsage,messages:sG(this.state.messages),permissionRequests:this.state.permissionRequests,queuedMessages:this.state.queuedMessages,olderCursor:this.state.olderCursor,hasOlderMessages:this.state.hasOlderMessages,lastCursor:this.state.lastCursor,pagesLoaded:this.state.pagesLoaded,interruptSource:this.state.interruptSource})}beginPendingReplyDebugTrace(t,r,s){const i={mode:t,clientRequestId:r,startedAtMs:performance.now(),responseReadyAtMs:null,contentLength:s};this.pendingReplyDebugTraces.push(i),Ot(`session_send.${t}.client_start`,{sessionId:this.sessionId,clientRequestId:r,contentLength:s})}markPendingReplyDebugTraceResponseReady(t,r={}){const s=this.pendingReplyDebugTraces.find(i=>i.clientRequestId===t);!s||s.responseReadyAtMs!==null||(s.responseReadyAtMs=performance.now(),Ot(`session_send.${s.mode}.client_response`,{sessionId:this.sessionId,clientRequestId:t,durationMs:Math.round(s.responseReadyAtMs-s.startedAtMs),...r}))}failPendingReplyDebugTrace(t,r){const s=this.pendingReplyDebugTraces.find(i=>i.clientRequestId===t);s&&(Ot(`session_send.${s.mode}.client_error`,{sessionId:this.sessionId,clientRequestId:t,durationMs:Math.round(performance.now()-s.startedAtMs),error:r instanceof Error?r.message:String(r)}),this.removePendingReplyDebugTrace(s.clientRequestId))}completePendingReplyDebugTrace(t){const r=this.pendingReplyDebugTraces[0];if(!r)return;const s=performance.now();Ot(`session_send.${r.mode}.first_assistant_message`,{sessionId:this.sessionId,clientRequestId:r.clientRequestId,durationMs:Math.round(s-r.startedAtMs),responseToAssistantMs:r.responseReadyAtMs===null?null:Math.round(s-r.responseReadyAtMs),messageId:t.message.messageId,kind:t.message.kind,contentLength:t.message.content.length}),this.removePendingReplyDebugTrace(r.clientRequestId)}completePendingReplyDebugTraceWithoutAssistant(t,r={}){const s=this.pendingReplyDebugTraces[0];s&&(Ot(t,{sessionId:this.sessionId,clientRequestId:s.clientRequestId,durationMs:Math.round(performance.now()-s.startedAtMs),responseReady:s.responseReadyAtMs!==null,...r}),this.removePendingReplyDebugTrace(s.clientRequestId))}removePendingReplyDebugTrace(t){const r=this.pendingReplyDebugTraces.findIndex(s=>s.clientRequestId===t);r<0||this.pendingReplyDebugTraces.splice(r,1)}}function ps(e,t){const[r,s]=p.useState(()=>t(e.getState()));return p.useEffect(()=>(s(t(e.getState())),e.subscribe(()=>{s(t(e.getState()))})),[t,e]),r}function Z8(e){const t=e==null?void 0:e.messageCount;return typeof t=="number"&&Number.isFinite(t)?t:null}function eG(e,t){return t>0?"ready":"loading"}function tG(e,t){const r=Z8(e);return r!==null?r>t:t>=GR}function kl(e){return e.olderCursor?!0:e.pagesLoaded>1?e.currentHasOlderMessages:tG(e.session,e.loadedMessageCount)}function _i(e,t){return e&&{...e,runningState:t,activityState:YR(e,t,e.completedAt??null,oa(t))}}function Tj(e,t){return!e||e.lastSeenAt&&e.lastSeenAt>=t?e:{...e,lastSeenAt:t,activityState:e.activityState==="completed_unread"?"idle":e.activityState}}function Nj(e,t){return KR(e,{runningState:t.runningState,activityResolutionSource:t.activityResolutionSource,activityConfidence:t.activityConfidence,runId:t.runId,detail:t.detail,interruptSource:t.interruptSource,errorCode:t.errorCode,errorDetail:t.errorDetail,hasActiveRun:t.hasActiveRun,updatedAt:t.updatedAt,watchdogTriggeredAt:t.watchdogTriggeredAt})}function nG(e,t){return KR(e,t)}function KR(e,t){if(!e)return e;const r=rG(t.activityResolutionSource),s=rm(t.runningState)?bg(e.completedAt,t.updatedAt):null,i=t.runningState==="completed"||t.runningState==="interrupted"||t.runningState==="failed"?bg(e.lastEventAt,t.updatedAt):t.updatedAt;return{...e,runningState:t.runningState,activitySource:r,activityResolutionSource:t.activityResolutionSource,activityConfidence:t.activityConfidence,runId:t.runId,lastEventAt:i,completedAt:s,lastErrorCode:t.runningState==="failed"?t.errorCode??e.lastErrorCode:null,lastErrorDetail:t.runningState==="failed"?t.errorDetail??t.detail??e.lastErrorDetail:null,watchdogTriggeredAt:t.watchdogTriggeredAt,updatedAt:bg(e.updatedAt,t.updatedAt)??t.updatedAt,activityState:YR(e,t.runningState,s,t.hasActiveRun)}}function YR(e,t,r,s){return s||oa(t)?"running":r&&(!e.lastSeenAt||r>e.lastSeenAt)?"completed_unread":e.activityState==="running"||e.activityState==="completed_unread"?"idle":e.activityState??"idle"}function oa(e){return e==="starting"||e==="running"||e==="reconnecting"}function rm(e){return e==="completed"||e==="interrupted"||e==="failed"}function Pj(e){if(e===null)return!0;const t=e.modelOptions??[];return t.length===0?!0:t.every(r=>r.usesProviderDefault===!0)}function Dj(e,t){return e==="session.backfill"?t??"idle":t==="completed"||t==="interrupted"||t==="failed"?t:"running"}function fg(e,t){return rm(e)?e:t}function gg(e,t){return e.runningState==="failed"?{interruptSource:null,errorCode:e.errorCode,errorDetail:e.errorDetail??e.detail}:e.runningState==="interrupted"?{interruptSource:e.interruptSource??null,errorCode:null,errorDetail:e.detail}:e.runningState==="completed"?{interruptSource:null,errorCode:null,errorDetail:e.detail}:{interruptSource:t,errorCode:null,errorDetail:null}}function rG(e){return e==="authoritative_runtime"||e==="authoritative_provider_event"?"runtime":e==="inferred_log"?"inferred":"none"}function bg(e,t){return e?t?e>=t?e:t:e:t??null}function Rj(){var e,t;if(typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function")return globalThis.crypto.randomUUID();if(typeof((t=globalThis.crypto)==null?void 0:t.getRandomValues)=="function"){const r=new Uint8Array(16);globalThis.crypto.getRandomValues(r),r[6]=r[6]&15|64,r[8]=r[8]&63|128;const s=Array.from(r,i=>i.toString(16).padStart(2,"0")).join("");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}return`fallback-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function Mj(e,t){return e?t&&e.provider===t.provider?!!t.canSendMessage:vP(e.provider):!1}function Aj(e,t){return e?t&&e.provider===t.provider?!(!t.supportsInterrupt||e.provider==="claude-code"&&e.activitySource==="inferred"):e.provider==="codex"||e.provider==="opencode"?!0:e.provider==="claude-code"&&e.activitySource!=="inferred":!1}function vg(e){return`session-runtime.snapshot.${e}`}function sG(e){return e.filter(t=>t.deliveryState==="sent").slice(-600)}function iG(e,t){const r=e.filter(s=>s.id!==t.id);return r.push(t),r.sort((s,i)=>s.orderIndex-i.orderIndex),r}function wg(e,t){const r=e.filter(s=>s.id!==t.id);return r.push(t),r.sort((s,i)=>s.status!==i.status?s.status==="pending"?-1:1:i.createdAt.localeCompare(s.createdAt)),r}function sh(e,t){if(!e)return t;if(!t||Ij(e,t))return e;if(Ij(t,e))return t;const r=Date.parse(e.updatedAt||e.lastMessageAt||e.createdAt),s=Date.parse(t.updatedAt||t.lastMessageAt||t.createdAt);return!Number.isFinite(r)||!Number.isFinite(s)?t:r>=s?e:t}function Ij(e,t){return Ej(e)&&!Ej(t)&&e.lastEventAt===t.lastEventAt&&e.lastMessageAt===t.lastMessageAt&&e.completedAt===t.completedAt}function Ej(e){return e.activityState==="running"||oa(e.runningState)}function z7(){return _e.request("/api/terminals/shells")}function q7(e){return _e.request(`/api/terminals?workspaceId=${encodeURIComponent(e)}`)}function aG(e){return _e.request(`/api/terminals/templates/${encodeURIComponent(e)}/stop`,{method:"POST"})}function $7(e){return _e.request("/api/terminals",{method:"POST",body:JSON.stringify(e)})}function V7(e){return _e.request(`/api/terminals/${encodeURIComponent(e)}`,{method:"DELETE"})}function G7(e){return _e.request(`/api/terminals/${encodeURIComponent(e)}/record`,{method:"DELETE"})}function K7(e,t={}){const r=new URLSearchParams;typeof t.beforeSeq=="number"&&r.set("beforeSeq",String(t.beforeSeq)),typeof t.limit=="number"&&r.set("limit",String(t.limit));const s=r.toString();return _e.request(`/api/terminals/${encodeURIComponent(e)}/history${s?`?${s}`:""}`)}function oG(e){return _e.request("/api/terminals/templates",{method:"POST",body:JSON.stringify(e)})}function lG(e,t){return _e.request(`/api/terminals/templates/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}function cG(e){return _e.request(`/api/terminals/templates/${encodeURIComponent(e)}`,{method:"DELETE"})}function Lj(e,t){return _e.request(`/api/terminals/templates/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t)})}function uG(e){return[{value:"",label:o("terminal.runtimeAutoOption"),description:o("terminal.runtimeAutoDescription")},{value:"tmux",label:e==="windows"?o("terminal.runtimePersistentLabel"):"tmux",description:o(e==="windows"?"terminal.runtimeWindowsPersistentDescription":"terminal.runtimeTmuxDescription")},{value:"embedded-pty",label:"embedded-pty",description:o("terminal.runtimeEmbeddedDescription")}]}function Fj(e,t){return e?e==="conpty-powershell"?o("terminal.runtimeConptyPowerShellLabel"):e==="conpty-cmd"?o("terminal.runtimeConptyCmdLabel"):e==="conpty-git-bash"?o("terminal.runtimeConptyGitBashLabel"):e==="tmux"&&t==="windows"?o("terminal.runtimePersistentLabel"):e:o("terminal.runtimeAutoOption")}function Y7(e,t){return e?e==="embedded-pty"?"pty":e==="conpty-powershell"||e==="conpty-cmd"||e==="conpty-git-bash"||e==="tmux"&&t==="windows"?o("terminal.runtimePersistentShortLabel"):e:o("terminal.runtimeAutoShortLabel")}function dG(e){return e instanceof Ur?e.errorCode==="RUNTIME_DEPENDENCY_MISSING"||e.message.includes("当前系统未安装 tmux"):!1}function hG({open:e,busy:t=!1,onClose:r,onConfirmFallback:s}){return p.useEffect(()=>{if(!e)return;function i(l){l.key==="Escape"&&!t&&r()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,r,e]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:()=>{t||r()}}),n.jsxs("section",{className:"workbench-modal-card surface-card terminal-runtime-fallback-modal",role:"dialog","aria-modal":"true","aria-label":o("terminal.runtimeMissingDialogTitle"),children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("terminal.runtimeMissingDialogTitle")}),n.jsx("p",{children:o("terminal.runtimeMissingDialogDescription")})]}),n.jsx(Lo,{onClick:()=>{t||r()}})]}),n.jsxs("div",{className:"workbench-modal-body terminal-runtime-fallback-body",children:[n.jsxs("section",{className:"terminal-runtime-fallback-section",children:[n.jsx("span",{className:"badge","data-tone":"error",children:"tmux"}),n.jsx("p",{className:"status-text",children:o("terminal.runtimeMissingInstallDescription")}),n.jsxs("ul",{className:"terminal-runtime-fallback-list",children:[n.jsx("li",{children:o("terminal.runtimeMissingInstallMacArm")}),n.jsx("li",{children:o("terminal.runtimeMissingInstallMacIntel")}),n.jsx("li",{children:o("terminal.runtimeMissingInstallDebian")}),n.jsx("li",{children:o("terminal.runtimeMissingInstallFedora")})]})]}),n.jsxs("section",{className:"terminal-runtime-fallback-section",children:[n.jsx("span",{className:"badge",children:"embedded-pty"}),n.jsx("p",{className:"status-text",children:o("terminal.runtimeMissingFallbackDescription")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:r,children:o("terminal.runtimeMissingKeepAction")}),n.jsx("button",{type:"button",className:"primary-button",disabled:t,onClick:s,children:o(t?"terminal.runtimeMissingFallbackPending":"terminal.runtimeMissingFallbackAction")})]})]})]})]}),document.body)}const ih={mode:"command",name:"",cwd:"",target:"",args:"",port:"",proxyEnabled:!1},_j=60*1e3;function mG(e){return e?new Date(e).toLocaleString():o("common.unknown")}function pG(e){return e.split(" ").map(t=>t.trim()).filter(Boolean)}function fG(e){var t,r,s;return((t=e.find(i=>i.id==="cmd"&&i.available))==null?void 0:t.id)??((r=e.find(i=>i.available))==null?void 0:r.id)??((s=e[0])==null?void 0:s.id)??""}function gG(e){const t=e.name.trim();if(t)return t;const r=e.target.trim(),s=e.args.trim();return r?s?`${r} ${s}`:r:e.mode==="script"?o("terminalManager.defaultScriptName"):o("terminalManager.defaultCommandName")}function bG(e){const t=e.args.join(" ");return t?`${e.command} ${t}`:e.command}function vG(e){return{mode:XR(e),name:e.name,cwd:e.cwd,target:e.command,args:e.args.join(" "),port:e.port===null?"":String(e.port),proxyEnabled:e.proxyEnabled}}function wG(e){return Wb(`/proxy/${encodeURIComponent(e)}`)}function XR(e){const t=e.command.toLowerCase();return t.endsWith(".ps1")||t.endsWith(".bat")||t.endsWith(".cmd")||t.endsWith(".sh")?"script":"command"}function yG(e){const t=e.trim();if(!t)return null;const r=Number(t);return Number.isInteger(r)?r:Number.NaN}function Oj(e,t){return e.get(t)??null}function kG(e,t){return e.port===null?{tone:"untracked",title:o("terminalManager.portUnset"),summary:o("terminalManager.portUnsetDescription"),badgeLabel:o("terminalManager.portUnset")}:t!=null&&t.occupied?{tone:"running",title:o("terminalManager.portOccupied"),summary:t.processName||o("terminalManager.processCommandFallback"),badgeLabel:t.processId?`PID ${t.processId}`:o("terminalManager.statusRunning"),badgeTone:"success"}:{tone:"idle",title:o("terminalManager.portAvailable"),summary:o("terminalManager.portAvailableDescription"),badgeLabel:o("terminalManager.statusStopped")}}function xG(e){return e!=null&&e.terminationScope?e.terminationScope==="process_group"?o("terminalManager.terminationScopeProcessGroup"):o("terminalManager.terminationScopeProcess"):null}function SG({open:e,title:t,description:r,onClose:s,children:i,className:l}){return p.useEffect(()=>{if(!e)return;function c(d){d.key==="Escape"&&s()}return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c)}},[s,e]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),onClick:s}),n.jsxs("section",{className:["workbench-modal-card","surface-card","terminal-manager-modal-card",l].filter(Boolean).join(" "),role:"dialog","aria-modal":"true","aria-label":t,children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:t}),n.jsx("p",{children:r})]}),n.jsx(Lo,{onClick:s})]}),n.jsx("div",{className:"workbench-modal-body",children:i})]})]}),document.body)}function CG({open:e,busy:t,title:r,description:s,confirmLabel:i,onClose:l,onConfirm:c,className:d}){return p.useEffect(()=>{if(!e)return;function m(f){f.key==="Escape"&&!t&&l()}return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[t,l,e]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),disabled:t,onClick:l}),n.jsxs("section",{className:["workbench-modal-card","surface-card",d].filter(Boolean).join(" "),role:"dialog","aria-modal":"true","aria-label":r,children:[n.jsx("div",{className:"workbench-modal-header",children:n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:r}),n.jsx("p",{children:s})]})}),n.jsx("div",{className:"workbench-modal-body",children:n.jsxs("div",{className:"workbench-modal-actions terminal-manager-confirm-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:l,children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:t,onClick:()=>{c()},children:t?o("terminalManager.templateRemoving"):i})]})})]})]}),document.body)}function Bj({label:e,value:t,options:r,open:s,onToggle:i,onChange:l}){const c=r.find(d=>d.value===t)??r[0]??null;return n.jsxs("div",{className:"field-group terminal-manager-mobile-picker",children:[n.jsx("span",{children:e}),n.jsxs("button",{type:"button",className:"terminal-manager-mobile-picker-trigger","aria-label":`${e} ${(c==null?void 0:c.label)??""}`.trim(),"aria-expanded":s?"true":"false",onClick:i,children:[n.jsxs("span",{className:"terminal-manager-mobile-picker-copy",children:[n.jsx("strong",{children:(c==null?void 0:c.label)??o("common.unknown")}),c!=null&&c.description?n.jsx("span",{children:c.description}):null]}),n.jsx(jG,{expanded:s})]}),s?n.jsx("div",{className:"terminal-manager-mobile-picker-list",role:"listbox","aria-label":e,children:r.map(d=>{const m=d.value===t;return n.jsxs("button",{type:"button",role:"option",className:"terminal-manager-mobile-picker-option","aria-selected":m,disabled:d.disabled,onClick:()=>{l(d.value)},children:[n.jsxs("span",{className:"terminal-manager-mobile-picker-option-copy",children:[n.jsx("strong",{children:d.label}),d.description?n.jsx("span",{children:d.description}):null]}),n.jsx("span",{className:"terminal-manager-mobile-picker-option-indicator","aria-hidden":"true",children:m?n.jsx(NG,{}):n.jsx(TG,{})})]},d.value||"__empty__")})}):null]})}function jG({expanded:e}){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"terminal-manager-mobile-picker-chevron","data-expanded":e?"true":"false",children:n.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7"})})}function TG(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function NG(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function dw({className:e,currentWorkspaceId:t,navigationGroups:r,externalWindowMode:s=!1,workbenchShellOverrides:i}){var Ft,Wt,Kt,un;const l=nr(),c=Pr(),{subscribeTerminalManagerSnapshot:d,requestTerminalManagerRefresh:m,addTerminalManagerSnapshotListener:f}={...c,...i},v=(t==null?void 0:t.trim())||null,[g,w]=p.useState([]),[k,y]=p.useState([]),[C,T]=p.useState([]),[j,N]=p.useState([]),[D,F]=p.useState(""),[W,E]=p.useState(""),[I,M]=p.useState(ih),[_,L]=p.useState(null),[Q,O]=p.useState(null),[ne,Y]=p.useState([]),[G,te]=p.useState(!1),[K,z]=p.useState(!1),[q,P]=p.useState(null),[U,X]=p.useState(null),[R,Se]=p.useState(null),[se,J]=p.useState(null),[Ne,Ee]=p.useState(null),[ie,xe]=p.useState(!1),[lt,Oe]=p.useState(null),{showToast:bt}=Qn(),Ct=(e==null?void 0:e.includes("mobile-tool-process-panel"))??!1,nt=_!==null,et=_==="edit"?k.find(ae=>ae.id===Q)??null:null,De=_==="edit";p.useEffect(()=>{Ot("terminal_manager.props",{currentWorkspaceId:t,workspaceCount:r.length,externalWindowMode:s})},[t,s,r.length]);const Ue=p.useMemo(()=>j.find(ae=>ae.id===D)??null,[D,j]),Ye=p.useMemo(()=>uG(l.ui.osFamily),[l.ui.osFamily]),ye=p.useMemo(()=>new Map(C.map(ae=>[ae.templateId,ae])),[C]),He=p.useMemo(()=>C.filter(ae=>ae.occupied).length,[C]),je=p.useMemo(()=>k.filter(ae=>ae.port!==null).length,[k]),Fe=(Ue==null?void 0:Ue.available)===!1&&j.length>0;p.useEffect(()=>{F(ae=>j.length?ae&&j.some(Be=>Be.id===ae)?ae:fG(j):"")},[j]),p.useEffect(()=>{!nt||!v||j.length>0||kt(v)},[v,j.length,nt]),p.useEffect(()=>{nt||Oe(null)},[nt]),p.useEffect(()=>{_==="edit"&&Q&&!et&&(L(null),O(null),M(ih),E(""),Oe(null))},[et,Q,_]),p.useEffect(()=>{!se||R===se.templateId||k.some(ae=>ae.id===se.templateId)||J(null)},[se,R,k]),p.useEffect(()=>{if(!v){w([]),y([]),T([]),te(!1);return}const ae=Er(yg(v),_j);Ot("terminal_manager.snapshot",{workspaceId:v,cached:!!ae,cachedTemplateCount:(ae==null?void 0:ae.templates.length)??0,cachedStatusCount:(ae==null?void 0:ae.templateStatuses.length)??0}),ae?(w(ae.terminals),y(ae.templates),T(ae.templateStatuses),N(ae.shellOptions??[]),te(!1)):(w([]),y([]),T([]),N([]),te(!0))},[v]),p.useEffect(()=>{if(v)return f(ae=>{ae.workspaceId===v&&(Ot("terminal_manager.snapshot_received",{workspaceId:ae.workspaceId,terminalCount:ae.terminals.length,templateCount:ae.templates.length,statusCount:ae.templateStatuses.length}),Ve(ae),te(!1))})},[v,f]),p.useEffect(()=>{if(!v)return;const ae=Er(yg(v),_j)!==null;if(d(v),ae){const Be=window.setTimeout(()=>{kt(v)},1500);return()=>{window.clearTimeout(Be)}}kt(v)},[v,m,d]),p.useEffect(()=>{v&&As(yg(v),{terminals:g,templates:k,templateStatuses:C,shellOptions:j})},[v,j,C,k,g]);function Ve(ae){w(ae.terminals),y(ae.templates),T(ae.templateStatuses),N(ae.shellOptions??[])}function kt(ae){Ot("terminal_manager.refresh_requested",{workspaceId:ae}),m(ae)}function me(){L(null),O(null),M(ih),E(""),Oe(null)}function Me(){O(null),M(ih),E(""),L("create")}function Xe(ae){O(ae.id),M(vG(ae)),E(ae.runtimeType??""),L("edit")}async function ze(ae){if(v){X(ae);try{await aG(ae),kt(v),bt({title:o("terminalManager.stopProcessSuccess"),tone:"success"})}catch(Be){bt({title:Be instanceof Error?Be.message:o("terminalManager.stopProcessFailed"),tone:"error"})}finally{X(null)}}}async function vt(){if(!v||!I.target.trim())return;const ae=yG(I.port);if(Number.isNaN(ae)){bt({title:o("terminalManager.invalidPort"),tone:"error"});return}if(I.proxyEnabled&&ae===null){bt({title:o("terminalManager.proxyPortRequired"),tone:"error"});return}z(!0);try{const Be={workspaceId:v,name:gG(I),cwd:I.cwd.trim()||void 0,command:I.target.trim(),args:pG(I.args),port:ae,proxyEnabled:I.proxyEnabled,runtimeType:W||null};if(De&&Q){const It=await lG(Q,Be);y(jt=>jt.map(Cn=>Cn.id===It.id?It:Cn))}else await oG(Be);me(),kt(v),bt({title:o(De?"terminalManager.templateUpdateSuccess":"terminalManager.templateSaveSuccess"),tone:"success"})}catch(Be){bt({title:Be instanceof Error?Be.message:o(De?"terminalManager.templateUpdateFailed":"terminalManager.templateSaveFailed"),tone:"error"})}finally{z(!1)}}async function ht(ae){const Be=await l.bridge.openExternal(ae);Be.ok||bt({title:Be.detail||o("terminalManager.openProxyUrlFailed"),tone:"error"})}async function pe(ae,Be){if(v){Se(ae.id);try{await cG(ae.id),y(It=>It.filter(jt=>jt.id!==ae.id)),T(It=>It.filter(jt=>jt.templateId!==ae.id)),Y(It=>It.filter(jt=>jt!==ae.id)),J(It=>(It==null?void 0:It.templateId)===ae.id?null:It),Q===ae.id&&me(),kt(v),bt({title:o("terminalManager.templateDeleteSuccess"),tone:"success"})}catch(It){bt({title:It instanceof Error?It.message:o("terminalManager.templateDeleteFailed"),tone:"error"})}finally{Se(null)}}}async function $e(ae){if(!v)return;const Be=Ue!=null&&Ue.available?Ue.shell:void 0;P(ae);try{await Lj(ae,{shell:Be}),kt(v),bt({title:o("terminalManager.templateRunSuccess"),tone:"success"})}catch(It){if(dG(It)){Ee({templateId:ae,shell:Be});return}bt({title:It instanceof Error?It.message:o("terminalManager.templateRunFailed"),tone:"error"})}finally{P(null)}}async function Nt(){if(!(!v||!Ne)){xe(!0);try{await Lj(Ne.templateId,{shell:Ne.shell,runtimeType:"embedded-pty"}),Ee(null),kt(v),bt({title:o("terminalManager.templateRunSuccess"),tone:"success"})}catch(ae){bt({title:ae instanceof Error?ae.message:o("terminalManager.templateRunFailed"),tone:"error"})}finally{xe(!1)}}}function Rt(ae){Y(Be=>Be.includes(ae)?Be.filter(It=>It!==ae):[...Be,ae])}return r.length?v?n.jsxs("section",{className:["conversation-panel","surface-card","terminal-manager-panel",e].filter(Boolean).join(" "),children:[n.jsx(hG,{open:Ne!==null,busy:ie,onClose:()=>{ie||Ee(null)},onConfirmFallback:()=>{Nt()}}),n.jsxs("div",{className:"terminal-manager-header terminal-manager-desktop-header",children:[n.jsxs("div",{className:"terminal-manager-panel-heading",children:[n.jsx("span",{className:"terminal-manager-panel-eyebrow",children:o("terminalManager.quickLaunchTitle")}),n.jsxs("div",{children:[n.jsx("h2",{children:o("terminalManager.templateSectionTitle")}),n.jsx("p",{className:"status-text",children:o("terminalManager.desktopPanelDescription")})]})]}),n.jsxs("div",{className:"terminal-manager-overview",children:[n.jsxs("article",{className:"terminal-manager-overview-card",children:[n.jsx("span",{children:o("terminalManager.runningCountLabel")}),n.jsx("strong",{children:He})]}),n.jsxs("article",{className:"terminal-manager-overview-card",children:[n.jsx("span",{children:o("terminalManager.portWatchCountLabel")}),n.jsx("strong",{children:je})]}),n.jsxs("article",{className:"terminal-manager-overview-card",children:[n.jsx("span",{children:o("terminalManager.terminalCountLabel")}),n.jsx("strong",{children:g.length})]})]}),n.jsxs("div",{className:"terminal-manager-toolbar terminal-manager-toolbar-header",children:[n.jsx("button",{className:"ghost-button",type:"button",disabled:!v||G,onClick:()=>{v&&kt(v)},children:o("terminalManager.refresh")}),n.jsx("button",{className:"primary-button",type:"button",disabled:!v,onClick:()=>{Me()},children:o("terminalManager.openCreateModalAction")})]})]}),n.jsxs("section",{className:"terminal-manager-section",children:[n.jsxs("div",{className:"terminal-manager-section-header",children:[n.jsxs("div",{children:[n.jsx("h3",{children:o("terminalManager.templateSectionTitle")}),n.jsx("p",{className:"status-text",children:o("terminalManager.templateSectionDescription")})]}),n.jsx("span",{className:"workbench-section-counter",children:k.length})]}),G&&!k.length?n.jsx("p",{className:"status-text",children:o("common.loading")}):null,k.length?n.jsx("div",{className:"terminal-manager-list",children:k.map(ae=>{const Be=Oj(ye,ae.id),It=kG(ae,Be),jt=xG(Be),Cn=ne.includes(ae.id),on=o(Cn?"terminalManager.hideDetailsAction":"terminalManager.showDetailsAction"),Wn=ae.proxyEnabled&&ae.proxySlug?wG(ae.proxySlug):null;return n.jsxs("article",{className:"terminal-manager-card terminal-manager-desktop-card","data-tone":It.tone,"data-expanded":Cn?"true":"false",children:[n.jsxs("div",{className:"terminal-manager-card-header",children:[n.jsxs("div",{className:"terminal-manager-card-title",children:[n.jsx("span",{className:"terminal-manager-card-indicator","aria-hidden":"true"}),n.jsx("strong",{children:ae.name})]}),n.jsxs("div",{className:"terminal-manager-card-tools",children:[n.jsx("span",{className:"badge terminal-runtime-badge",children:Fj(ae.runtimeType,l.ui.osFamily)}),n.jsx("span",{className:"badge",children:XR(ae)==="script"?o("terminalManager.scriptMode"):o("terminalManager.commandMode")}),n.jsx("button",{className:"terminal-manager-detail-toggle",type:"button","aria-label":on,"aria-expanded":Cn,onClick:()=>{Rt(ae.id)},children:"i"})]})]}),n.jsxs("div",{className:"terminal-manager-status-panel",children:[n.jsxs("div",{className:"terminal-manager-status-copy",children:[n.jsx("p",{className:"terminal-manager-status-title",children:It.title}),n.jsx("p",{className:"status-text",children:It.summary})]}),n.jsxs("div",{className:"terminal-manager-status-badges",children:[n.jsx("span",{className:"terminal-manager-stat-pill",children:ae.port===null?o("terminalManager.portUnset"):`${o("terminalManager.portLabel")} ${ae.port}`}),n.jsx("span",{className:"badge","data-tone":It.badgeTone,children:It.badgeLabel}),Be!=null&&Be.occupied&&Be.processGroupId?n.jsx("span",{className:"badge",children:`PGID ${Be.processGroupId}`}):null,ae.proxyEnabled?n.jsx("span",{className:"badge",children:o("terminalManager.proxyEnabled")}):null]})]}),n.jsxs("div",{className:"terminal-manager-actions",children:[Be!=null&&Be.occupied?n.jsx("button",{className:"secondary-button",type:"button",disabled:U===ae.id,onClick:()=>{ze(ae.id)},children:U===ae.id?o("terminalManager.stoppingProcess"):o("terminalManager.stopProcessAction")}):null,n.jsx("button",{className:"secondary-button",type:"button",disabled:q===ae.id||Fe,onClick:()=>{$e(ae.id)},children:q===ae.id?o("terminalManager.runningTemplate"):o("terminalManager.runTemplateAction")})]}),Cn?n.jsxs("section",{className:"terminal-manager-details","aria-label":o("terminalManager.detailsSectionTitle"),children:[n.jsxs("div",{className:"terminal-manager-detail-grid",children:[n.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[n.jsx("span",{children:o("terminalManager.commandPreviewLabel")}),n.jsx("strong",{children:bG(ae)})]}),n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.cwdLabel")}),n.jsx("strong",{children:ae.cwd})]}),n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminal.runtimeField")}),n.jsx("strong",{children:Fj(ae.runtimeType,l.ui.osFamily)})]}),n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.updatedAt")}),n.jsx("strong",{children:mG(ae.updatedAt)})]}),n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.portLabel")}),n.jsx("strong",{children:ae.port===null?o("terminalManager.portUnset"):ae.port})]}),n.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[n.jsx("span",{children:o("terminalManager.proxyField")}),n.jsx("strong",{children:Wn??o("terminalManager.proxyDisabledDescription")})]}),Be!=null&&Be.processId?n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.processIdLabel")}),n.jsx("strong",{children:Be.processId})]}):null,Be!=null&&Be.processGroupId?n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.processGroupIdLabel")}),n.jsx("strong",{children:Be.processGroupId})]}):null,jt?n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.terminationScopeLabel")}),n.jsx("strong",{children:jt})]}):null,Be!=null&&Be.parentProcessId?n.jsxs("div",{className:"terminal-manager-detail-item",children:[n.jsx("span",{children:o("terminalManager.parentProcessIdLabel")}),n.jsx("strong",{children:Be.parentProcessId})]}):null,Be!=null&&Be.processCommandLine?n.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[n.jsx("span",{children:o("terminalManager.processCommandLabel")}),n.jsx("strong",{children:Be.processCommandLine})]}):null,Be!=null&&Be.parentProcessCommandLine?n.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[n.jsx("span",{children:o("terminalManager.parentProcessCommandLabel")}),n.jsx("strong",{children:Be.parentProcessCommandLine})]}):null]}),n.jsxs("div",{className:"terminal-manager-actions terminal-manager-detail-actions",children:[Wn?n.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{ht(Wn)},children:o("terminalManager.openProxyUrlAction")}):null,n.jsx("button",{className:"secondary-button",type:"button",disabled:K||R===ae.id,onClick:()=>{Xe(ae)},children:o("terminalManager.editAction")}),n.jsx("button",{className:"secondary-button workbench-danger-button",type:"button",disabled:R===ae.id,onClick:()=>{J({templateId:ae.id,name:ae.name,occupied:!!(Be!=null&&Be.occupied)})},children:R===ae.id?o("terminalManager.templateRemoving"):o("terminalManager.removeAction")})]})]}):null]},ae.id)})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("terminalManager.emptyTemplateBody")})})]}),n.jsx(SG,{open:nt,title:o(De?"terminalManager.editModalTitle":"terminalManager.createModalTitle"),description:o(De?"terminalManager.editModalDescription":"terminalManager.createModalDescription"),className:Ct?"terminal-manager-mobile-modal":void 0,onClose:me,children:n.jsxs("section",{className:"terminal-manager-modal-form",children:[Ct?n.jsxs(n.Fragment,{children:[n.jsx(Bj,{label:o("terminalManager.shellField"),value:D,open:lt==="shell",options:j.map(ae=>({value:ae.id,label:ae.label,description:ae.available?null:ae.unavailableReason??o("terminalManager.shellUnavailable"),disabled:!ae.available})),onToggle:()=>{Oe(ae=>ae==="shell"?null:"shell")},onChange:ae=>{F(ae),Oe(null)}}),(Ue==null?void 0:Ue.available)===!1&&Ue.unavailableReason?n.jsx("p",{className:"status-text",children:Ue.unavailableReason}):null,n.jsx(Bj,{label:o("terminal.runtimeField"),value:W,open:lt==="runtime",options:Ye.map(ae=>({value:ae.value,label:ae.label,description:ae.description})),onToggle:()=>{Oe(ae=>ae==="runtime"?null:"runtime")},onChange:ae=>{E(ae),Oe(null)}}),n.jsx("p",{className:"status-text",children:((Ft=Ye.find(ae=>ae.value===W))==null?void 0:Ft.description)??((Wt=Ye[0])==null?void 0:Wt.description)})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminalManager.shellField")}),n.jsx("select",{value:D,onChange:ae=>{F(ae.target.value)},children:j.map(ae=>n.jsx("option",{value:ae.id,disabled:!ae.available,children:ae.available?ae.label:`${ae.label} - ${o("terminalManager.shellUnavailable")}`},ae.id))}),(Ue==null?void 0:Ue.available)===!1&&Ue.unavailableReason?n.jsx("p",{className:"status-text",children:Ue.unavailableReason}):null]}),n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminal.runtimeField")}),n.jsx("select",{value:W,onChange:ae=>{E(ae.target.value)},children:Ye.map(ae=>n.jsx("option",{value:ae.value,children:ae.label},ae.value||"auto"))}),n.jsx("p",{className:"status-text",children:((Kt=Ye.find(ae=>ae.value===W))==null?void 0:Kt.description)??((un=Ye[0])==null?void 0:un.description)})]})]}),n.jsxs("div",{className:"terminal-manager-mode-row",role:"tablist","aria-label":o("terminalManager.modeField"),children:[n.jsx("button",{type:"button",className:I.mode==="command"?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{M(ae=>({...ae,mode:"command"}))},children:o("terminalManager.commandMode")}),n.jsx("button",{type:"button",className:I.mode==="script"?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{M(ae=>({...ae,mode:"script"}))},children:o("terminalManager.scriptMode")})]}),n.jsxs("div",{className:"terminal-manager-grid",children:[n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminalManager.templateNameField")}),n.jsx("input",{value:I.name,placeholder:o("terminalManager.templateNamePlaceholder"),onChange:ae=>{M(Be=>({...Be,name:ae.target.value}))}})]}),n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminalManager.cwdField")}),n.jsx("input",{value:I.cwd,placeholder:o("terminalManager.cwdPlaceholder"),onChange:ae=>{M(Be=>({...Be,cwd:ae.target.value}))}})]})]}),n.jsxs("div",{className:"terminal-manager-grid",children:[n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:I.mode==="script"?o("terminalManager.scriptPathField"):o("terminalManager.commandField")}),n.jsx("input",{value:I.target,placeholder:I.mode==="script"?o("terminalManager.scriptPathPlaceholder"):o("terminalManager.commandPlaceholder"),onChange:ae=>{M(Be=>({...Be,target:ae.target.value}))}})]}),n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminalManager.argsField")}),n.jsx("input",{value:I.args,placeholder:o("terminalManager.argsPlaceholder"),onChange:ae=>{M(Be=>({...Be,args:ae.target.value}))}})]})]}),n.jsxs("div",{className:"terminal-manager-grid",children:[n.jsxs("div",{className:"field-group",children:[n.jsx("span",{children:o("terminalManager.portField")}),n.jsx("input",{value:I.port,placeholder:o("terminalManager.portPlaceholder"),onChange:ae=>{M(Be=>({...Be,port:ae.target.value}))}})]}),n.jsxs("div",{className:"field-group terminal-manager-proxy-field",children:[n.jsx("span",{children:o("terminalManager.proxyField")}),n.jsxs("div",{className:"terminal-manager-proxy-control",children:[n.jsx("span",{children:o("terminalManager.proxyToggleLabel")}),n.jsxs("label",{className:"terminal-manager-proxy-switch",children:[n.jsx("input",{type:"checkbox",role:"switch","aria-label":o("terminalManager.proxyField"),checked:I.proxyEnabled,onChange:ae=>{M(Be=>({...Be,proxyEnabled:ae.target.checked}))}}),n.jsx("span",{className:"terminal-manager-proxy-track","aria-hidden":"true",children:n.jsx("span",{className:"terminal-manager-proxy-thumb"})})]})]})]})]}),n.jsxs("div",{className:"terminal-manager-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",onClick:me,children:o("common.close")}),n.jsx("button",{className:"primary-button",type:"button",disabled:!v||K||!I.target.trim(),onClick:()=>{vt()},children:o(K?De?"terminalManager.templateUpdating":"terminalManager.templateSaving":De?"terminalManager.saveTemplateChangesAction":"terminalManager.saveLaunchAction")})]})]})}),n.jsx(CG,{open:se!==null,busy:se!==null&&R===se.templateId,title:o("terminalManager.removeConfirmTitle"),description:se?o(se.occupied?"terminalManager.removeRunningConfirmTarget":"terminalManager.removeConfirmTarget",{name:se.name}):"",confirmLabel:o("terminalManager.removeConfirmAction"),className:Ct?"terminal-manager-mobile-modal":"terminal-manager-confirm-modal",onClose:()=>{R||J(null)},onConfirm:()=>{if(!se)return;const ae=k.find(Be=>Be.id===se.templateId);if(!ae){J(null);return}Oj(ye,ae.id),pe(ae)}})]}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("terminalManager.noCurrentWorkspaceBody")})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:o("terminalManager.emptyWorkspaceBody")})})}function yg(e){return`terminal-manager.snapshot.${e}`}const PG=Object.freeze(Object.defineProperty({__proto__:null,TerminalManagerPanel:dw},Symbol.toStringTag,{value:"Module"})),QR="mobile.conversation.preview.mode",JR="mobile.conversation.tool.panel";function kg(){if(typeof window>"u")return"preview";try{return window.localStorage.getItem(QR)==="immersive"?"immersive":"preview"}catch{return"preview"}}function jo(e){if(!(typeof window>"u"))try{window.localStorage.setItem(QR,e)}catch{}}function Wj(){if(typeof window>"u")return"files";try{const e=window.localStorage.getItem(JR);return e==="git"||e==="processes"?e:"files"}catch{return"files"}}function Uj(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JR,e)}catch{}}function DG(e,t,r){if(!t)return null;const s=e.find(c=>c.workspace.id===t);if(!s)return null;const i=_N([s]).filter(c=>!c.session.isArchived&&!qi(c.session)),l=i.findIndex(c=>c.session.sessionId===r);return l<0?null:i[l+1]??null}const RG=15e3,Hj=.6,xg=.6,zj=8,MG=36,AG=48,IG=96,EG=320,LG="workbench:focus-composer";function FG(){const{sessionId:e="",workspaceId:t}=Eo(),r=oi(),s=vr(),i=p.useMemo(()=>new URLSearchParams(r.search),[r.search]),l=qG(i.get("toolPanel")),c=(t==null?void 0:t.trim())||null,d=p.useMemo(()=>UG(e,c,i),[c,i,e]),m=p.useMemo(()=>i9(e,r.state),[r.state,e]);return d?n.jsx(WG,{draft:d,navigate:s,initialToolPanel:l}):n.jsx(_G,{sessionId:e,bootstrapMessages:m,initialToolPanel:l})}function _G({sessionId:e,bootstrapMessages:t,initialToolPanel:r}){var kn,Nn,xt,Zt;const{shellMode:s,navigationGroups:i,requestNavigationRefresh:l,selectWorkspace:c,setSessionWorkspace:d,markNavigationSessionSeen:m,favoriteSessions:f,archiveSession:v,unarchiveSession:g,startDraftSession:w,upsertNavigationSession:k}=Pr(),y=vr(),C=p.useRef(null),T=p.useRef(null),[j,N]=p.useState(!1),[D,F]=p.useState(null),[W,E]=p.useState(!1),[I,M]=p.useState(!1),[_,L]=p.useState(null),[Q,O]=p.useState(!1),[ne,Y]=p.useState(!1),[G,te]=p.useState(null),K=p.useMemo(()=>i.flatMap(we=>we.sessions).find(we=>we.sessionId===e)??null,[i,e]);(!C.current||T.current!==e)&&((kn=C.current)==null||kn.destroy(),C.current=new J8(e,{initialSession:K,bootstrapMessages:t,onSeen:(we,Ge)=>{m(we,Ge)}}),T.current=e);const z=C.current,{showToast:q,dismissToast:P}=Qn(),U=ai(we=>we.notificationPreferences.notifyOnPermissionRequest),X=nr(),R=li(),Se=p.useRef(null),se=p.useRef(null),J=p.useRef(null),Ne=p.useRef((K==null?void 0:K.runningState)??null),Ee=p.useRef(new Set),ie=ps(z,we=>we.session),xe=ps(z,we=>we.capabilities),lt=ps(z,we=>we.runtimeHasActiveRun),Oe=ps(z,we=>we.runtimeCanInterrupt),bt=ps(z,we=>we.messages),Ct=ps(z,we=>we.permissionRequests),nt=ps(z,we=>we.queuedMessages),et=ps(z,we=>we.contextUsage),De=ps(z,we=>we.historyState),Ue=ps(z,we=>we.errorCode),Ye=ps(z,we=>we.errorDetail),ye=ps(z,we=>we.interruptSource),He=ps(z,we=>we.loadingOlderMessages),je=ps(z,we=>we.hasOlderMessages),Fe=ps(z,we=>we.connectionState),[Ve,kt]=p.useState(!1),[me,Me]=p.useState(null),[Xe,ze]=p.useState(null),vt=JG(ie),ht=vt&&kP(xe)&&(ie==null?void 0:ie.provider)===(xe==null?void 0:xe.provider),pe=nt.some(we=>we.status==="queued"||we.status==="dispatching"),$e=ZG({sessionId:e,provider:(ie==null?void 0:ie.provider)??null,runningState:(ie==null?void 0:ie.runningState)??null,activityState:(ie==null?void 0:ie.activityState)??null,runtimeHasActiveRun:lt,messages:bt})?o("conversation.runtimeThinkingPlaceholder",{provider:o("conversation.providerCodex")}):null,Nt=s!=="mobile",Rt=lM(!Nt),Ft=(ie==null?void 0:ie.workspaceId)??(K==null?void 0:K.workspaceId)??null,Wt=aM({enabled:!Nt,initialPanel:r,workspaceId:Ft,suspendMainGesture:!Nt&&Rt.isVisible}),Kt=p.useMemo(()=>new Set(f.map(we=>we.session.sessionId)),[f]),un=p.useMemo(()=>i.map(we=>we.workspace),[i]),ae=p.useMemo(()=>Ul(i),[i]),Be=p.useMemo(()=>hm(i),[i]),It=p.useMemo(()=>eM(i,(ie==null?void 0:ie.workspaceId)??(K==null?void 0:K.workspaceId)??null,Kt),[Kt,i,K==null?void 0:K.workspaceId,ie==null?void 0:ie.workspaceId]),jt=p.useMemo(()=>tM(f,i),[f,i]),[Cn,on]=p.useState([]),Wn=p.useMemo(()=>[...jt,...It],[jt,It]),Rn=p.useMemo(()=>Ft?un.find(we=>we.id===Ft)??null:null,[Ft,un]),$t=(Ft?Be[Ft]??null:null)??(Rn?Tu(Rn):null),dn=p.useMemo(()=>ua(i,Ft),[Ft,i]),gn=ae.find(we=>we.workspace.id===Ft)??(dn?{workspace:dn.workspace,label:dn.workspace.name,subtitle:dn.workspace.path}:null),Z=p.useMemo(()=>DG(i,Ft,e),[Ft,i,e]),ce=(ie==null?void 0:ie.provider)??(K==null?void 0:K.provider)??null,ge=p.useMemo(()=>{var we;return $i(((we=ie??K)==null?void 0:we.title)??null,o("conversation.titleFallback"))},[K,ie]),Ce=ie??K??null,We=Nt?null:iM(Rt.mainGestureHandlers,Wt.mainGestureHandlers),qe=p.useMemo(()=>new Map(i.flatMap(we=>we.sessions.map(Ge=>[Ge.sessionId,Ge]))),[i]);p.useEffect(()=>{const we=la(Wn,e,Ge=>Ge.session.sessionId);we.length!==0&&on(Ge=>{const St=new Set(Ge);let Sn=!1;for(const _n of we)St.has(_n)||(St.add(_n),Sn=!0);return Sn?Array.from(St):Ge})},[Wn,e]);const Pt=p.useMemo(()=>c9(Ce,bt),[Ce,bt]),Ke=p.useMemo(()=>l9(Ce,Pt),[Ce,Pt]),at=Ke!=null&&Ke.parentSessionId&&((xt=(Nn=qe.get(Ke.parentSessionId))==null?void 0:Nn.title)==null?void 0:xt.trim())||o("conversation.inheritedContextParentFallback"),ft=p.useMemo(()=>!Ke||Ke.hiddenMessageCount<=0?Pt:Ve?Ke.sourceType!=="selection"?Pt:[{id:`annotation-selection-${e}`,sessionId:e,role:"system",kind:"text",content:Ke.hiddenSelectionText,toolCall:null,attachments:[],attachmentPayloads:null,origin:"system",originRef:Ke.sourceMessageId??null,timestamp:(Ce==null?void 0:Ce.createdAt)??new Date(0).toISOString(),sequence:Ke.hiddenSequenceBoundary,rawRef:`annotation-selection://${e}`,deliveryState:"sent",clientRequestId:null},...Pt]:Pt.filter(Ge=>Ge.sequence>Ke.hiddenSequenceBoundary),[Ce==null?void 0:Ce.createdAt,Ve,Ke,Pt,e]),ct=(Ce==null?void 0:Ce.workspaceId)??(K==null?void 0:K.workspaceId)??null,oe=p.useMemo(()=>HR(i,ct,e),[ct,i,e]),Re=M8(oe),_t=!!(Ce&&ct&&Re),Ut=p.useMemo(()=>(dn==null?void 0:dn.sessions.filter(we=>we.isArchived===!0&&!qi(we)))??[],[dn]),Qt=p.useRef(null),ln=p.useRef(null),jn=p.useRef(null),Jn=p.useRef(null),[bn,Jt]=p.useState(null),{composerPortalTarget:ur}=tv();p.useEffect(()=>{z.applyNavigationSession(K)},[K,z]),p.useEffect(()=>(z.initialize(),()=>{z.destroy()}),[z]),p.useEffect(()=>(d(e,(ie==null?void 0:ie.workspaceId)??null),()=>{d(e,null)}),[ie==null?void 0:ie.workspaceId,e,d]),p.useEffect(()=>{Y(!1),te(null),kt(!1)},[e]),p.useEffect(()=>()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},[]),p.useEffect(()=>{if(!Ue||!Ye){J.current!==null&&(window.clearTimeout(J.current),J.current=null),se.current=null,Se.current=null,P("conversation-runtime-error");return}const we=`${Ue}:${Ye}`;if(!(Se.current===we||se.current===we)){if(J.current!==null&&(window.clearTimeout(J.current),J.current=null),OG((ie==null?void 0:ie.provider)??null,Ue,Ye)){se.current=we,J.current=window.setTimeout(()=>{se.current=null,J.current=null,Se.current=we,q({id:"conversation-runtime-error",title:o("conversation.runtimeErrorTitle"),description:Ye,tone:"error",durationMs:null})},RG);return}se.current=null,Se.current=we,q({id:"conversation-runtime-error",title:o("conversation.runtimeErrorTitle"),description:Ye,tone:"error",durationMs:null})}},[P,Ue,Ye,ie==null?void 0:ie.provider,q]),p.useEffect(()=>{const we=Ne.current,Ge=(ie==null?void 0:ie.runningState)??null;(we==="starting"||we==="running"||we==="reconnecting")&&Ge==="completed"&&R.trigger("success"),Ne.current=Ge},[R,ie==null?void 0:ie.runningState]),p.useEffect(()=>{const we=Ct.filter(St=>St.status==="pending"),Ge=(ie==null?void 0:ie.workspaceId)??(K==null?void 0:K.workspaceId)??null;for(const St of we)Ee.current.has(St.id)||(Ee.current.add(St.id),U&&(q({id:`permission-request-${St.id}`,title:o("conversation.permissionRequestToastTitle"),description:St.title,tone:"warning",durationMs:8e3,action:Ge?{label:o("shell.contextOpenSession"),onClick:()=>{y(Yn(Ge,e))}}:void 0}),X.bridge.showNotification(o("conversation.permissionRequestToastTitle"),St.title)))},[K==null?void 0:K.workspaceId,y,U,Ct,X.bridge,ie==null?void 0:ie.workspaceId,e,q]),rM(jn,bn,!Nt,e),sM(jn,Jn,!Nt,e);async function vn(we,Ge){var _n,Vn;const St=G;if(!St){await z.sendMessage(we,{model:Ge==null?void 0:Ge.model,reasoningLevel:Ge==null?void 0:Ge.reasoningLevel,attachments:Ge==null?void 0:Ge.attachments,attachmentMeta:Ge==null?void 0:Ge.attachmentMeta}),l();return}let Sn=null;try{Sn=await uP(e,{sourceType:"message",sourceMessageId:St.sourceMessageId,sourceMessageSnapshot:St.sourceMessageSnapshot,strategy:"auto",targetProvider:St.targetProvider}),k(Sn),await Sv(Sn.sessionId,{content:we,clientRequestId:((Vn=(_n=globalThis.crypto)==null?void 0:_n.randomUUID)==null?void 0:Vn.call(_n))??`fork-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:St.targetModel,reasoningLevel:(Ge==null?void 0:Ge.reasoningLevel)??null,attachments:(Ge==null?void 0:Ge.attachments)??[]}),te(null),l(),c(Sn.workspaceId),jo("preview"),y(Yn(Sn.workspaceId,Sn.sessionId)),q({title:o("conversation.forkMessageSucceeded"),tone:"success"})}catch(zn){throw Sn&&(k(Sn),l()),zn}}function yn(we){c(we),y(Si(we))}return n.jsxs(n.Fragment,{children:[n.jsxs("main",{ref:jn,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!Nt,"data-preview-mode":Nt?void 0:Rt.displayMode,"data-preview-dragging":Nt?void 0:Rt.isDragging,"data-workspace-tone":($t==null?void 0:$t.tone)??"root","data-worktree-depth":($t==null?void 0:$t.depth)??0,"data-tool-panel-open":Nt?void 0:Wt.isOpen,style:{...Nt?{}:Rt.pageStyle,...ri($t)??{}},children:[Nt?n.jsx(VR,{session:ie??K,workspaceContext:$t,actions:n.jsx(WR,{session:ie??K})}):null,Nt?null:n.jsx(Hl,{containerRef:Jn,className:"mobile-conversation-page-header",gestureHandlers:We??void 0,currentWorkspace:gn?{id:gn.workspace.id,name:gn.label,path:gn.subtitle}:un[0]??null,workspaces:un,workspaceOptions:ae,onSelectWorkspace:yn,heading:ge.fullTitle,trailing:n.jsxs("div",{className:"mobile-conversation-toolbar-main",children:[n.jsx("span",{className:"mobile-conversation-toolbar-title",title:ge.fullTitle,children:ge.displayTitle}),n.jsx(y8,{session:ie??K})]})}),Nt?null:n.jsx(cM,{visible:!Wt.isOpen&&Rt.isVisible,widthPx:Rt.previewWidthPx,isDragging:Rt.isDragging,gestureHandlers:Rt.railGestureHandlers,activeSessionId:e,createSessionActionLabel:Ft&&ce?o("shell.createSession"):void 0,favoriteItems:jt,items:It,expandedRootIds:Cn,workspaceSectionLabel:(gn==null?void 0:gn.label)??o("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:Ft&&ce?()=>{w(Ft,ce)}:void 0,archiveCurrentActionLabel:o("shell.archiveCurrentSessionAction"),archiveFolderActionLabel:Ut.length>0?o("shell.archiveFolderLabel"):void 0,onArchiveActiveSession:()=>{E(!0)},onOpenArchiveFolder:Ut.length>0?()=>{M(!0)}:void 0,onToggleSubsessions:we=>{on(Ge=>Ge.includes(we)?Ge.filter(St=>St!==we):[...Ge,we])},onActivate:we=>{Rt.closePreview(),c(we.workspace.id),y(Yn(we.workspace.id,we.session.sessionId))}}),n.jsx("div",{className:"mobile-conversation-stage",...We??{},children:n.jsxs("div",{ref:Qt,className:"mobile-conversation-main",children:[n.jsx(fR,{connectionState:Fe,onReconnect:()=>z.reconnect()}),n.jsx(k8,{requests:Ct,replyingRequestId:D,onReply:async(we,Ge)=>{F(we);try{await z.replyPermissionRequest(we,Ge)}catch(St){q({title:o("conversation.permissionRequestReplyFailed"),description:St instanceof Error?St.message:void 0,tone:"error"})}finally{F(null)}}}),Ke&&Ke.hiddenMessageCount>0?n.jsx(QG,{expanded:Ve,hiddenMessageCount:Ke.hiddenMessageCount,parentTitle:at,sourceType:Ke.sourceType,onToggle:()=>{kt(we=>!we)},onOpenBranchTree:_t?()=>Y(!0):void 0}):null,n.jsx("div",{ref:ln,className:"conversation-timeline-shell",children:n.jsx(Nm,{sessionId:e,messages:ft,historyState:De,loadingOlderMessages:He,hasOlderMessages:je,provider:(ie==null?void 0:ie.provider)??null,interruptedSource:ye,runtimeThinkingPlaceholder:$e,onLoadOlderMessages:()=>{z.loadOlderMessages()},onRetryMessage:we=>{z.retryMessage(we)},onForkMessage:we=>{ie&&(te({sourceMessageId:we.id,sourceMessageSnapshot:{role:we.role,kind:we.kind??(we.role==="tool"?"tool_result":"text"),content:we.content},content:we.content,sourceProvider:ie.provider,workspaceId:ie.workspaceId,targetProvider:ie.provider,targetModel:null}),BG())}})}),n.jsx(j$,{containerRef:ln,session:ie??K??null,currentCapabilities:xe}),n.jsx(C8,{items:nt,deletingQueueItemId:me,steeringQueueItemId:Xe,canSteer:ht,onDelete:async we=>{Me(we);try{await z.deleteQueuedMessage(we)}finally{Me(null)}},onSteer:async we=>{ze(we);try{await z.steerQueuedMessage(we),l()}finally{ze(null)}}}),Wt.isOpen?null:n.jsx(km,{capabilities:xe,draftStorageId:e,forkDraft:G,onClearForkDraft:()=>te(null),onForkDraftChange:we=>te(we),panelRef:Nt?void 0:Jt,portalContainer:Nt?null:ur,hasActiveRun:lt,contextUsage:et,taskProvider:((Zt=ie??K)==null?void 0:Zt.provider)??null,taskMessages:bt,hasPendingQueuedMessages:pe,canInterrupt:Oe,isSubmitting:j,isRunning:vt,onInterrupt:async()=>{await z.interrupt(),l()},onSend:async(we,Ge)=>{N(!0);try{await vn(we,{model:Ge==null?void 0:Ge.model,reasoningLevel:Ge==null?void 0:Ge.reasoningLevel,attachments:Ge==null?void 0:Ge.attachments,attachmentMeta:Ge==null?void 0:Ge.attachmentMeta})}finally{N(!1)}},onQueueSend:async(we,Ge)=>{N(!0);try{G?await vn(we,{model:Ge==null?void 0:Ge.model,reasoningLevel:Ge==null?void 0:Ge.reasoningLevel,attachments:Ge==null?void 0:Ge.attachments,attachmentMeta:Ge==null?void 0:Ge.attachmentMeta}):await z.enqueueMessage(we,{model:Ge==null?void 0:Ge.model,reasoningLevel:Ge==null?void 0:Ge.reasoningLevel,attachments:Ge==null?void 0:Ge.attachments,attachmentMeta:Ge==null?void 0:Ge.attachmentMeta})}finally{N(!1)}}})]})}),!Nt&&Ft?n.jsx(oM,{activePanel:Wt.activePanel,open:Wt.isOpen,sessionId:e,workspaceId:Ft,navigationGroups:i,onClose:()=>{Wt.closePanel()},onSelectPanel:we=>{Wt.selectPanel(we)},onSelectPanelBySwipe:we=>{if(we===null){Wt.closePanel();return}Wt.selectPanel(we)}}):null]}),n.jsx(G8,{open:ne,navigationGroups:i,workspaceId:ct,sessionId:e,onClose:()=>Y(!1),onOpenSession:we=>{Y(!1),c(we.workspaceId),jo("preview"),y(Yn(we.workspaceId,we.sessionId))}}),n.jsx(XG,{open:W,busy:Q,onClose:()=>{Q||E(!1)},onConfirm:async()=>{if(!Q){O(!0);try{if(await v(e),E(!1),q({title:o("shell.archiveAdded"),tone:"success"}),Ft){if(c(Ft),jo("preview"),Z){y(Yn(Z.workspace.id,Z.session.sessionId));return}y(Si(Ft));return}y("/workspaces")}catch(we){q({title:we instanceof Error?we.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{O(!1)}}}}),n.jsx(dM,{open:I,workspaceName:(dn==null?void 0:dn.workspace.name)??null,sessions:Ut,restoringSessionId:_,onClose:()=>{_||M(!1)},onRestore:async we=>{L(we);try{await g(we),q({title:o("shell.archiveRestored"),tone:"success"})}catch(Ge){q({title:Ge instanceof Error?Ge.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{L(null)}}})]})}function OG(e,t,r){return e!=="opencode"?!1:t==="OPENCODE_REQUEST_TIMEOUT"||t==="PROVIDER_RUNTIME_TIMEOUT"||/\bSERVER_TIMEOUT\b/i.test(r)||/timeout/i.test(r)||/超时/.test(r)}function BG(){typeof window>"u"||window.dispatchEvent(new CustomEvent(LG))}function WG({draft:e,navigate:t,initialToolPanel:r}){const{shellMode:s,navigationGroups:i,requestNavigationRefresh:l,selectWorkspace:c,setSessionWorkspace:d,upsertNavigationSession:m,favoriteSessions:f,unarchiveSession:v,startDraftSession:g}=Pr(),[w,k]=p.useState(!1),[y,C]=p.useState([]),T=p.useMemo(()=>Ba(e.provider),[e.provider]),[j,N]=p.useState(T),D=s!=="mobile",{showToast:F}=Qn(),W=p.useMemo(()=>HG(e),[e]),E=lM(!D),I=aM({enabled:!D,initialPanel:r,sessionId:e.sessionId,workspaceId:e.workspaceId,suspendMainGesture:!D&&E.isVisible}),M=p.useMemo(()=>new Set(f.map(nt=>nt.session.sessionId)),[f]),_=p.useMemo(()=>i.map(nt=>nt.workspace),[i]),L=p.useMemo(()=>Ul(i),[i]),Q=p.useMemo(()=>hm(i),[i]),O=p.useMemo(()=>_.find(nt=>nt.id===e.workspaceId)??null,[e.workspaceId,_]),ne=Q[e.workspaceId]??(O?Tu(O):null),Y=p.useMemo(()=>$i(W.title??null,o("conversation.titleFallback")),[W]),G=p.useMemo(()=>eM(i,e.workspaceId,M),[e.workspaceId,M,i]),te=p.useMemo(()=>tM(f,i),[f,i]),[K,z]=p.useState([]),q=p.useMemo(()=>[...te,...G],[te,G]),P=p.useMemo(()=>ua(i,e.workspaceId),[e.workspaceId,i]),U=p.useMemo(()=>(P==null?void 0:P.sessions.filter(nt=>nt.isArchived===!0&&!qi(nt)))??[],[P]),X=L.find(nt=>nt.workspace.id===e.workspaceId)??(P?{workspace:P.workspace,label:P.workspace.name,subtitle:P.workspace.path}:null),R=D?null:iM(E.mainGestureHandlers,I.mainGestureHandlers),[Se,se]=p.useState(!1),[J,Ne]=p.useState(null),Ee=p.useRef(null),ie=p.useRef(null),xe=p.useRef(null),[lt,Oe]=p.useState(null),{composerPortalTarget:bt}=tv();p.useEffect(()=>{const nt=la(q,e.sessionId,et=>et.session.sessionId);nt.length!==0&&z(et=>{const De=new Set(et);let Ue=!1;for(const Ye of nt)De.has(Ye)||(De.add(Ye),Ue=!0);return Ue?Array.from(De):et})},[e.sessionId,q]),p.useEffect(()=>(d(e.sessionId,e.workspaceId),()=>{d(e.sessionId,null)}),[e.sessionId,e.workspaceId,d]),p.useEffect(()=>{let nt=!1;return N(T),_l(e.provider,e.workspaceId).then(et=>{nt||N(et)}).catch(()=>{}),()=>{nt=!0}},[e.provider,e.workspaceId,T]),rM(ie,lt,!D,e.sessionId),sM(ie,xe,!D,e.sessionId);function Ct(nt){c(nt),t(Si(nt))}return n.jsx(n.Fragment,{children:n.jsxs("main",{ref:ie,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!D,"data-preview-mode":D?void 0:E.displayMode,"data-preview-dragging":D?void 0:E.isDragging,"data-workspace-tone":(ne==null?void 0:ne.tone)??"root","data-worktree-depth":(ne==null?void 0:ne.depth)??0,"data-tool-panel-open":D?void 0:I.isOpen,style:{...D?{}:E.pageStyle,...ri(ne)??{}},children:[D?n.jsx(VR,{session:W,workspaceContext:ne}):null,D?null:n.jsx(Hl,{containerRef:xe,className:"mobile-conversation-page-header",gestureHandlers:R??void 0,currentWorkspace:X?{id:X.workspace.id,name:X.label,path:X.subtitle}:_[0]??null,workspaces:_,workspaceOptions:L,onSelectWorkspace:Ct,heading:Y.fullTitle,trailing:n.jsx("span",{className:"mobile-conversation-toolbar-title",title:Y.fullTitle,children:Y.displayTitle})}),D?null:n.jsx(cM,{visible:!I.isOpen&&E.isVisible,widthPx:E.previewWidthPx,isDragging:E.isDragging,gestureHandlers:E.railGestureHandlers,activeSessionId:e.sessionId,createSessionActionLabel:o("shell.createSession"),favoriteItems:te,items:G,expandedRootIds:K,workspaceSectionLabel:(X==null?void 0:X.label)??o("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:()=>{g(e.workspaceId,e.provider)},archiveFolderActionLabel:U.length>0?o("shell.archiveFolderLabel"):void 0,onOpenArchiveFolder:U.length>0?()=>{se(!0)}:void 0,onToggleSubsessions:nt=>{z(et=>et.includes(nt)?et.filter(De=>De!==nt):[...et,nt])},onActivate:nt=>{E.closePreview(),c(nt.workspace.id),t(Yn(nt.workspace.id,nt.session.sessionId))}}),n.jsx("div",{className:"mobile-conversation-stage",...R??{},children:n.jsxs("div",{ref:Ee,className:"mobile-conversation-main",children:[n.jsx(fR,{connectionState:"closed",onReconnect:()=>{}}),n.jsx("div",{className:"conversation-timeline-shell",children:n.jsx(Nm,{sessionId:e.sessionId,messages:y,historyState:"ready",loadingOlderMessages:!1,hasOlderMessages:!1,provider:e.provider,runtimeThinkingPlaceholder:null,onLoadOlderMessages:()=>{},onRetryMessage:()=>{}})}),I.isOpen?null:n.jsx(km,{capabilities:j,draftStorageId:e.sessionId,panelRef:D?void 0:Oe,portalContainer:D?null:bt,contextUsage:null,taskProvider:e.provider,taskMessages:y,isSubmitting:w,isRunning:!1,onSend:async(nt,et)=>{var Ye,ye,He,je;const De=o9();C(Fe=>[...Fe,X0(e.sessionId,nt,De,(et==null?void 0:et.attachmentMeta)??[],(et==null?void 0:et.attachments)??[])]),k(!0);const Ue=performance.now();Ot("session_send.start_live.client_start",{draftSessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,clientRequestId:De,contentLength:nt.length});try{const Fe=xi.getState().profile.defaultPermissionMode,Ve=await xv({workspaceId:e.workspaceId,provider:e.provider,content:nt,clientRequestId:De,model:(et==null?void 0:et.model)??null,reasoningLevel:(et==null?void 0:et.reasoningLevel)??null,permissionMode:Fe==="default"?null:Fe,attachments:(et==null?void 0:et.attachments)??[]});Ot("session_send.start_live.client_response",{draftSessionId:e.sessionId,sessionId:Ve.sessionId,workspaceId:((Ye=Ve.session)==null?void 0:Ye.workspaceId)??e.workspaceId,provider:Ve.provider,clientRequestId:De,durationMs:Math.round(performance.now()-Ue),returnedMessageId:((ye=Ve.message)==null?void 0:ye.messageId)??null}),Ve.session&&m(Ve.session);const kt=((je=(He=Ve.session)==null?void 0:He.workspaceId)==null?void 0:je.trim())||e.workspaceId;d(Ve.sessionId,kt),jo("preview"),t(Yn(kt,Ve.sessionId),{replace:!0,state:Ve.message?{bootstrap:{sessionId:Ve.sessionId,messages:[Ve.message]}}:null}),l()}catch(Fe){throw Ot("session_send.start_live.client_error",{draftSessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,clientRequestId:De,durationMs:Math.round(performance.now()-Ue),error:Fe instanceof Error?Fe.message:String(Fe)}),C(Ve=>gb(Ve,De)),Fe}finally{k(!1)}}})]})}),D?null:n.jsx(oM,{activePanel:I.activePanel,open:I.isOpen,sessionId:e.sessionId,workspaceId:e.workspaceId,navigationGroups:i,onClose:()=>{I.closePanel()},onSelectPanel:nt=>{I.selectPanel(nt)},onSelectPanelBySwipe:nt=>{if(nt===null){I.closePanel();return}I.selectPanel(nt)}}),n.jsx(dM,{open:Se,workspaceName:(P==null?void 0:P.workspace.name)??null,sessions:U,restoringSessionId:J,onClose:()=>{J||se(!1)},onRestore:async nt=>{Ne(nt);try{await v(nt),F({title:o("shell.archiveRestored"),tone:"success"})}catch(et){F({title:et instanceof Error?et.message:o("shell.navigationLoadFailed"),tone:"error"})}finally{Ne(null)}}})]})})}function UG(e,t,r,s=null){var c,d;if(!s9(e))return null;const i=t??((c=r.get("workspaceId"))==null?void 0:c.trim())??null,l=((d=r.get("provider"))==null?void 0:d.trim())??s??null;return!i||!vP(l)?null:{sessionId:e,workspaceId:i,provider:l}}function HG(e){const t=new Date().toISOString();return{sessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,providerSessionId:`draft://${e.sessionId}`,rawStoreRef:`draft://${e.sessionId}`,parentSessionId:null,isSubagent:!1,subagentLabel:null,isArchived:!1,title:N_(e.provider),messageCount:0,lastMessageAt:null,createdAt:t,updatedAt:t,syncStatus:"idle",syncCursor:null,lastSyncAt:null,lastErrorCode:null,lastErrorDetail:null,resumedAt:null,runningState:"idle",activitySource:"none",lastEventAt:null,completedAt:null,lastSeenAt:null,activityState:"idle"}}function zG(e){var t;return((t=e.parentSessionId)==null?void 0:t.trim())||null}function ZR(e){const t=new Map(e.map(i=>[i.sessionId,i])),r=new Map,s=i=>{const l=r.get(i.sessionId);if(typeof l=="boolean")return l;if(i.isArchived)return r.set(i.sessionId,!1),!1;const c=zG(i);if(!c)return r.set(i.sessionId,!0),!0;const d=t.get(c);if(!d)return r.set(i.sessionId,!0),!0;const m=s(d);return r.set(i.sessionId,m),m};return e.filter(i=>s(i))}function eM(e,t,r){if(!t)return[];const s=ua(e,t);if(!s)return[];const i=ZR(s.sessions).map(c=>({session:c,workspace:s.workspace}));return Wh(i).filter(c=>!r.has(c.item.session.sessionId)&&!lm(c.children,d=>r.has(d.session.sessionId)))}function tM(e,t){return e.filter(r=>!qi(r.session)).flatMap(r=>{const s=ua(t,r.workspace.id);if(!s)return[];const i=Wh(ZR(s.sessions).map(c=>({session:c,workspace:s.workspace}))),l=nM(i,r.session.sessionId);return l?[l]:[]})}function nM(e,t){for(const r of e){if(r.item.session.sessionId===t)return r;const s=nM(r.children,t);if(s)return s}return null}function rM(e,t,r,s){p.useEffect(()=>{const i=e.current;if(!r||!i){i&&i.style.removeProperty("--mobile-conversation-composer-height");return}if(!t){i.style.removeProperty("--mobile-conversation-composer-height");return}const l=i,c=t;function d(){!e.current||!c.isConnected||l.style.setProperty("--mobile-conversation-composer-height",`${c.offsetHeight}px`)}d();const m=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return m==null||m.observe(c),window.addEventListener("resize",d),()=>{m==null||m.disconnect(),window.removeEventListener("resize",d),i.style.removeProperty("--mobile-conversation-composer-height")}},[t,r,s,e])}function sM(e,t,r,s){p.useEffect(()=>{const i=e.current,l=t.current;if(!r||!i){i&&i.style.removeProperty("--mobile-conversation-page-header-height");return}if(!l){i.style.removeProperty("--mobile-conversation-page-header-height");return}const c=i,d=l;function m(){!e.current||!d.isConnected||c.style.setProperty("--mobile-conversation-page-header-height",`${d.offsetHeight}px`)}m();const f=typeof ResizeObserver<"u"?new ResizeObserver(m):null;return f==null||f.observe(d),window.addEventListener("resize",m),()=>{f==null||f.disconnect(),window.removeEventListener("resize",m),i.style.removeProperty("--mobile-conversation-page-header-height")}},[r,t,s,e])}function qG(e){return e==="files"||e==="git"||e==="processes"?e:null}function iM(...e){const t=e.filter(Boolean);return{onTouchStart(r){t.forEach(s=>s.onTouchStart(r))},onTouchMove(r){t.forEach(s=>s.onTouchMove(r))},onTouchEnd(r){t.forEach(s=>s.onTouchEnd(r))},onTouchCancel(r){t.forEach(s=>s.onTouchCancel(r))}}}function aM(e){const t=oi(),r=vr(),s=li(),i=p.useRef(null),[l,c]=p.useState(()=>e.initialPanel??Wj()),d=e.initialPanel??l,m=e.enabled&&e.workspaceId!==null&&e.initialPanel!==null;p.useEffect(()=>{if(!e.enabled){i.current=null;return}const N=e.initialPanel??Wj();c(N),Uj(N)},[e.enabled,e.initialPanel]);function f(N,D){const F=new URLSearchParams(t.search);N?(F.set("toolPanel",N),c(N),Uj(N)):F.delete("toolPanel");const W=F.toString();r({pathname:t.pathname,search:W?`?${W}`:""},{replace:(D==null?void 0:D.replace)??!1})}function v(N){s.trigger("selection"),f(N,{replace:m})}function g(){m&&(s.trigger("gesture"),f(null,{replace:!0}))}function w(N){if(!e.enabled||!e.workspaceId)return;const D=N??d;s.trigger("gesture"),f(D)}function k(N){if(!e.enabled||N.changedTouches.length!==1){i.current=null;return}if($G(N.target)){i.current=null;return}const D=N.changedTouches[0];i.current={x:D.clientX,y:D.clientY}}function y(N){const D=i.current;if(i.current=null,!D||N.changedTouches.length!==1||m||e.suspendMainGesture)return;const F=N.changedTouches[0],W=F.clientX-D.x,E=F.clientY-D.y;W>-56||Math.abs(W)<=Math.abs(E)*1.15||w()}function C(N){const D=i.current;if(i.current=null,!D||N.changedTouches.length!==1||!m)return;const F=N.changedTouches[0],W=F.clientX-D.x,E=F.clientY-D.y;W<56||Math.abs(W)<=Math.abs(E)*1.15||g()}return{activePanel:d,closePanel:g,isOpen:m,mainGestureHandlers:{onTouchStart:k,onTouchMove:()=>{},onTouchEnd:y,onTouchCancel:()=>{i.current=null}},openPanel:w,panelGestureHandlers:{onTouchStart:k,onTouchMove:()=>{},onTouchEnd:C,onTouchCancel:()=>{i.current=null}},selectPanel:v}}function oM(e){const t=p.useRef(null);if(!e.open)return null;function r(i){if(i.changedTouches.length!==1){t.current=null;return}if(VG(i.target)){t.current=null;return}const l=i.changedTouches[0];t.current={x:l.clientX,y:l.clientY}}function s(i){const l=t.current;if(t.current=null,!l||i.changedTouches.length!==1)return;const c=i.changedTouches[0],d=c.clientX-l.x,m=c.clientY-l.y;if(Math.abs(d)<56||Math.abs(d)<=Math.abs(m)*1.15)return;const f=["files","git","processes"],v=f.indexOf(e.activePanel);if(d<0){e.onSelectPanelBySwipe(f[Math.min(f.length-1,v+1)]??e.activePanel);return}if(v===0){e.onSelectPanelBySwipe(null);return}e.onSelectPanelBySwipe(f[Math.max(0,v-1)]??e.activePanel)}return n.jsxs("section",{className:"mobile-conversation-tool-panel","data-panel":e.activePanel,onTouchStart:r,onTouchEnd:s,onTouchCancel:()=>{t.current=null},children:[n.jsxs("header",{className:"mobile-conversation-tool-panel-header","data-preview-gesture":"ignore",children:[n.jsx("button",{type:"button",className:"mobile-conversation-tool-panel-back","aria-label":o("shell.mobileConversationToolCloseAction"),title:o("shell.mobileConversationToolCloseAction"),onClick:e.onClose,children:n.jsx("span",{"aria-hidden":"true",children:"‹"})}),n.jsx("div",{className:"mobile-conversation-tool-panel-tabs",role:"tablist","aria-label":o("shell.mobileConversationToolTabsLabel"),children:["files","git","processes"].map(i=>n.jsx("button",{type:"button",role:"tab","aria-selected":e.activePanel===i,className:"mobile-conversation-tool-panel-tab",onClick:()=>{e.onSelectPanel(i)},children:o(i==="files"?"shell.filesEntry":i==="git"?"shell.gitEntry":"shell.mobileConversationToolProcessesTab")},i))})]}),n.jsx("div",{className:"mobile-conversation-tool-panel-body",children:e.activePanel==="files"?n.jsx(ow,{className:"mobile-conversation-tool-surface",hideHeading:!0,sessionId:e.sessionId,workspaceId:e.workspaceId}):e.activePanel==="git"?n.jsx(cw,{className:"mobile-conversation-tool-surface",panelActive:!0,workspaceId:e.workspaceId}):n.jsx(dw,{className:"mobile-conversation-tool-surface mobile-tool-native-panel mobile-tool-process-panel",currentWorkspaceId:e.workspaceId,navigationGroups:e.navigationGroups})})]})}function $G(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function VG(e){return e instanceof Element?!!e.closest("input, textarea, select, option, [contenteditable='true']"):!1}function lM(e){const t=li(),[r,s]=p.useState(()=>e?kg():"immersive"),[i,l]=p.useState(()=>qj()),[c,d]=p.useState(()=>e&&kg()==="preview"?"default":"closed"),m=p.useRef(c),f=p.useRef(null);p.useEffect(()=>{m.current=c},[c]),p.useEffect(()=>{if(!e){f.current=null,m.current="closed",d("closed"),s("immersive");return}const M=kg();s(M),d(M==="preview"?"default":"closed")},[e]),p.useEffect(()=>{e&&jo(r)},[e,r]),p.useEffect(()=>{if(typeof window>"u")return;function M(){l(qj())}return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[]);function v(M){m.current=M,d(M)}function g(M="default"){v(M),s("preview")}function w(){v("closed"),s("immersive")}function k(){v("expanded"),s("preview")}function y(){if(m.current!=="closed"){t.trigger("gesture"),w();return}t.trigger("gesture"),g()}function C(M,_){const L=_.touches[0]??_.changedTouches[0];if(!e||!L){f.current=null;return}if(KG(_.target)){f.current=null;return}if(M==="main"){if(m.current==="closed"&&L.clientX>IG){f.current=null;return}}else if(m.current==="closed"){f.current=null;return}f.current={source:M,intent:M==="rail"?"rail":m.current==="closed"?"open":"close",startX:L.clientX,startY:L.clientY,lastX:L.clientX,lastY:L.clientY,horizontalLocked:!1}}function T(M){const _=f.current,L=M.touches[0];if(!e||!_||!L)return;const Q=L.clientX-_.startX,O=L.clientY-_.startY;if(_.lastX=L.clientX,_.lastY=L.clientY,!_.horizontalLocked){if(Math.abs(Q)<zj&&Math.abs(O)<zj)return;if(Math.abs(Q)<=Math.abs(O)){f.current=null;return}if(_.intent==="open"&&Q<=0){f.current=null;return}if(_.intent==="close"&&Q>=0){f.current=null;return}_.horizontalLocked=!0}}function j(M){var O;const _=f.current;if(f.current=null,!(_!=null&&_.horizontalLocked))return;const L=(O=M==null?void 0:M.changedTouches)==null?void 0:O[0];L&&(_.lastX=L.clientX,_.lastY=L.clientY);const Q=_.lastX-_.startX;if(_.intent==="open"){Q>=MG&&(t.trigger("gesture"),g("default"));return}if(_.intent==="close"){Q<=-34&&(t.trigger("gesture"),w());return}if(Q<=-34){t.trigger("gesture"),w();return}Q>=AG&&m.current==="default"&&(t.trigger("gesture"),k())}const N=c==="expanded"?xg:c==="default"?Hj:0,D=Math.round(i*N*100)/100,F=N===0?0:N/xg,W={"--mobile-conversation-preview-default-width":`${Math.round(i*Hj*100)/100}px`,"--mobile-conversation-preview-max-width":`${Math.round(i*xg*100)/100}px`,"--mobile-conversation-preview-width":`${D}px`,"--mobile-conversation-preview-progress":F.toFixed(4)};return{closePreview:w,displayMode:c==="closed"?"immersive":"preview",isDragging:!1,isVisible:c!=="closed",mainGestureHandlers:{onTouchStart:M=>C("main",M),onTouchMove:T,onTouchEnd:j,onTouchCancel:j},pageStyle:W,previewWidthPx:D,railGestureHandlers:{onTouchStart:M=>C("rail",M),onTouchMove:T,onTouchEnd:j,onTouchCancel:j},togglePreview:y}}function cM({visible:e,widthPx:t,isDragging:r,gestureHandlers:s,activeSessionId:i,createSessionActionLabel:l,favoriteItems:c,items:d,expandedRootIds:m,workspaceSectionLabel:f,onCreateSession:v,archiveCurrentActionLabel:g,archiveFolderActionLabel:w,onArchiveActiveSession:k,onOpenArchiveFolder:y,onToggleSubsessions:C,onActivate:T}){if(!e)return null;function j(N,D){const{workspaceName:F,ancestorExpanded:W=!1,ancestorHasNextSiblings:E=[],hasNextSibling:I=!1,isFirstSibling:M=!1}=D??{},_=N.item.session.sessionId,L=N.children,Q=N.depth===0&&L.length>0,O=W||Q&&m.includes(_),ne=N.depth>0?[...E,I]:[...E];return n.jsxs("div",{className:"mobile-conversation-preview-tree-node",children:[n.jsxs("div",{className:"mobile-conversation-preview-tree-row",style:{"--mobile-preview-tree-depth":N.depth},children:[N.depth>0?n.jsxs("div",{className:"mobile-conversation-preview-guides","aria-hidden":"true",children:[E.map((Y,G)=>Y?n.jsx("span",{className:"mobile-conversation-preview-guide-column",style:{"--mobile-preview-tree-level":G+1}},`${_}:ancestor:${G}`):null),n.jsx("span",{className:"mobile-conversation-preview-guide-branch","data-continue":I,"data-first":M,style:{"--mobile-preview-tree-level":N.depth},children:n.jsx("span",{className:"mobile-conversation-preview-guide-branch-horizontal"})})]}):null,n.jsx(GG,{entry:N.item,activeSessionId:i,hasSubsessions:Q,subsessionsExpanded:O,workspaceName:F,onToggleSubsessions:Q?()=>{C(_)}:void 0,onActivate:T})]}),L.length>0&&O?n.jsx("div",{className:"mobile-conversation-preview-children",children:L.map((Y,G)=>j(Y,{workspaceName:F,ancestorExpanded:!0,ancestorHasNextSiblings:ne,hasNextSibling:G<L.length-1,isFirstSibling:G===0}))}):null]},`${N.item.workspace.id}:${_}`)}return n.jsxs("aside",{className:"mobile-conversation-preview-rail terminal-mobile-list-rail surface-card","data-dragging":r,style:{width:`${t}px`,maxWidth:`${t}px`},...s,children:[l&&v?n.jsx("div",{className:"mobile-conversation-preview-topbar terminal-mobile-list-footer",children:n.jsxs("button",{type:"button",className:"mobile-conversation-preview-create-button workbench-import-toggle terminal-mobile-list-create",onClick:v,children:[n.jsx("span",{className:"workbench-import-toggle-symbol","aria-hidden":"true",children:"+"}),n.jsx("span",{className:"workbench-import-toggle-label",children:l})]})}):null,n.jsxs("div",{className:"mobile-conversation-preview-body terminal-mobile-list-body",children:[c.length>0?n.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-list-favorites terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[n.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[n.jsx("span",{children:o("shell.favoriteSectionTitle")}),n.jsx("span",{className:"workbench-section-counter",children:c.length})]}),n.jsx("div",{className:"mobile-conversation-preview-list mobile-conversation-preview-list-static terminal-mobile-session-list",children:c.map(N=>n.jsx("div",{children:j(N,{workspaceName:N.item.workspace.name})},`favorite:${N.item.workspace.id}:${N.item.session.sessionId}`))})]}):null,n.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-group-workspace terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[n.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[n.jsx("span",{children:f}),n.jsx("span",{className:"workbench-section-counter",children:d.length})]}),d.length===0?n.jsx("div",{className:"workbench-session-empty",children:o("shell.emptyWorkspaceSessions")}):n.jsx("div",{className:"mobile-conversation-preview-list terminal-mobile-session-list","data-preview-gesture":"ignore",children:d.map(N=>j(N))})]})]}),g&&k||w&&y?n.jsxs("div",{className:"mobile-conversation-preview-actions terminal-mobile-list-footer",children:[g&&k?n.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:()=>{k()},children:g}):null,w&&y?n.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:y,children:w}):null]}):null]})}function GG({entry:e,activeSessionId:t,hasSubsessions:r=!1,subsessionsExpanded:s=!1,onActivate:i,onToggleSubsessions:l,workspaceName:c}){const d=e.session.sessionId===t;return n.jsxs("article",{className:"mobile-conversation-preview-entry terminal-mobile-session-card","data-active":d,children:[r?n.jsx("button",{type:"button",className:"mobile-conversation-preview-toggle","aria-label":o(s?"shell.subagentCollapse":"shell.subagentExpand"),title:o(s?"shell.subagentCollapse":"shell.subagentExpand"),"aria-expanded":s,onClick:m=>{m.stopPropagation(),l==null||l()},children:n.jsx("span",{className:$j(e.session,{isActive:d,hasSubsessions:r}),"aria-hidden":"true"})}):n.jsx("span",{className:$j(e.session,{isActive:d,hasSubsessions:r}),"aria-hidden":"true"}),n.jsx("button",{type:"button",className:"mobile-conversation-preview-item terminal-mobile-session-primary","data-active":d,onClick:()=>i(e),children:n.jsxs("div",{className:"mobile-conversation-preview-item-body",children:[n.jsx("span",{className:"mobile-conversation-preview-item-title",children:e.session.title||o("common.unknown")}),n.jsx("span",{className:"mobile-conversation-preview-item-meta",children:uM(e.session,c)})]})})]})}function qj(){return typeof window>"u"?390:Math.max(window.innerWidth||390,320)}function KG(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function $j(e,t){const r=Cv("mobile-conversation-preview-indicator",e,{hasSubagents:t.hasSubsessions});return r.endsWith(" is-idle")&&t.isActive?"mobile-conversation-preview-indicator is-active":r}function uM(e,t){const r=eu(e);return[t??null,qs(e.provider),YG(e.lastMessageAt??e.updatedAt),r].filter(Boolean).join(" · ")}function YG(e){return e?new Date(e).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):o("common.unknown")}function XG({open:e,busy:t,onClose:r,onConfirm:s}){return p.useEffect(()=>{if(!e)return;function i(l){l.key==="Escape"&&!t&&r()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[t,r,e]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),disabled:t,onClick:r}),n.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":o("shell.archiveConfirmTitle"),children:[n.jsx("div",{className:"workbench-modal-header",children:n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("shell.archiveConfirmTitle")}),n.jsx("p",{children:o("shell.archiveConfirmDescription")})]})}),n.jsx("div",{className:"workbench-modal-body",children:n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:r,children:o("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:t,onClick:()=>{s()},children:o("shell.archiveAction")})]})})]})]}),document.body)}function dM({open:e,workspaceName:t,sessions:r,restoringSessionId:s,onClose:i,onRestore:l}){return p.useEffect(()=>{if(!e)return;function c(d){d.key==="Escape"&&!s&&i()}return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c)}},[i,e,s]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),disabled:!!s,onClick:i}),n.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":o("shell.archiveModalTitle"),children:[n.jsx("div",{className:"workbench-modal-header",children:n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("shell.archiveModalTitle")}),n.jsx("p",{children:t?`${t} · ${o("shell.archiveModalDescription")}`:o("shell.archiveModalDescription")})]})}),n.jsx("div",{className:"workbench-modal-body",children:r.length>0?n.jsx("div",{className:"workbench-archive-list",children:r.map(c=>{const d=$i(c.title,o("common.unknown"));return n.jsxs("article",{className:"workbench-archive-item",children:[n.jsxs("div",{className:"workbench-archive-item-main",children:[n.jsx("strong",{title:d.fullTitle,children:d.displayTitle}),n.jsx("p",{children:uM(c)})]}),n.jsx("button",{type:"button",className:"secondary-button",disabled:s===c.sessionId,onClick:()=>{l(c.sessionId)},children:o("shell.unarchiveAction")})]},c.sessionId)})}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.archiveEmpty")})})]})]}),document.body)}function QG(e){const t=e.sourceType==="selection"?o("conversation.actionInheritedSelectionSummary",{parentTitle:e.parentTitle}):o("conversation.inheritedContextSummary",{count:e.hiddenMessageCount,parentTitle:e.parentTitle});return n.jsxs("section",{className:"conversation-inherited-context-banner",children:[n.jsx("div",{className:"conversation-inherited-context-copy",children:n.jsx("p",{title:t,children:t})}),n.jsxs("div",{className:"conversation-inherited-context-actions",children:[e.hiddenMessageCount>0?n.jsx("button",{type:"button",className:"conversation-inherited-context-icon-button","aria-label":e.expanded?o("conversation.inheritedContextCollapse"):o("conversation.inheritedContextExpand"),title:e.expanded?o("conversation.inheritedContextCollapse"):o("conversation.inheritedContextExpand"),onClick:e.onToggle,children:n.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:n.jsx(vB,{expanded:e.expanded})})}):null,e.onOpenBranchTree?n.jsx("button",{type:"button",className:"conversation-inherited-context-icon-button","aria-label":o("conversation.branchTreeAction"),title:o("conversation.branchTreeAction"),onClick:e.onOpenBranchTree,children:n.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:n.jsx(bB,{})})}):null]})]})}function JG(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function ZG(e){const t=e9(e),[r,s]=p.useState(t==="show"),i=p.useRef(null);return p.useEffect(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),s(t==="show")},[e.sessionId]),p.useEffect(()=>{if(t==="show"){i.current!==null&&(window.clearTimeout(i.current),i.current=null),s(!0);return}if(t==="hide_immediately"){i.current!==null&&(window.clearTimeout(i.current),i.current=null),s(!1);return}!r||i.current!==null||(i.current=window.setTimeout(()=>{i.current=null,s(!1)},EG))},[t,r]),p.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),r}function e9(e){const{provider:t,runningState:r,activityState:s,runtimeHasActiveRun:i,messages:l}=e;if(t!=="codex")return"hide_immediately";const c=r9(l);return c<0||n9(l,c)?"hide_immediately":t9(r,s,i)?"show":"hide_deferred"}function t9(e,t,r){return r===!0||t==="running"||e==="starting"||e==="running"||e==="reconnecting"}function n9(e,t){return e.slice(t+1).some(r=>r.role==="assistant"&&(r.kind==="text"||r.kind==="thinking"))}function r9(e){let t=-1;for(let r=e.length-1;r>=0;r-=1){const s=e[r];if(s.role==="user"&&s.kind==="text"){t=r;break}}return t}function s9(e){return e.startsWith("draft-")}function i9(e,t){if(!t||typeof t!="object")return[];const r=t.bootstrap;if(!r||typeof r!="object")return[];const s=r.sessionId,i=r.messages;return s!==e||!Array.isArray(i)?[]:i.filter(a9)}function a9(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.messageId=="string"&&typeof t.provider=="string"&&typeof t.providerSessionId=="string"&&typeof t.role=="string"&&typeof t.content=="string"&&typeof t.timestamp=="string"&&typeof t.sequence=="number"&&typeof t.rawRef=="string"}function o9(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}function l9(e,t){var c,d,m;if(!e)return null;const r=((c=e.parentSessionId)==null?void 0:c.trim())||null;if(!r||qi(e))return null;if(e.sessionKind==="annotation"&&typeof e.annotationSourceText=="string"&&e.annotationSourceText.trim().length>0)return{parentSessionId:r,sourceType:"selection",hiddenMessageCount:1,hiddenSequenceBoundary:0,hiddenSelectionText:e.annotationSourceText,sourceMessageId:((d=e.annotationSourceMessageId)==null?void 0:d.trim())||null};const s=e.forkSourceType==="message"||e.forkSourceType==="session"?e.forkSourceType:e.forkSourceMessageId?"message":"session",i=Math.max(0,e.inheritedPrefixMessageCount??0),l=t.filter(f=>f.sequence<=i).length;return l<=0?null:{parentSessionId:r,sourceType:s,hiddenMessageCount:l,hiddenSequenceBoundary:i,hiddenSelectionText:"",sourceMessageId:((m=e.forkSourceMessageId)==null?void 0:m.trim())||null}}function c9(e,t){var i;if(!e||e.forkSourceType!=="message"||typeof e.inheritedPrefixMessageCount!="number"||e.inheritedPrefixMessageCount<0)return t;const r=((i=e.createdAt)==null?void 0:i.trim())||"";if(r.length===0)return t;const s=Math.max(0,e.inheritedPrefixMessageCount);return t.filter(l=>l.sequence<=s?!0:l.timestamp>=r)}function u9(){return p.useEffect(()=>{const e=document.documentElement.style.background,t=document.body.style.background;return document.documentElement.style.background="transparent",document.body.style.background="transparent",()=>{document.documentElement.style.background=e,document.body.style.background=t}},[]),n.jsx("main",{className:"desktop-detach-preview-page","aria-hidden":"true",children:n.jsxs("section",{className:"desktop-detach-preview-card",children:[n.jsx("header",{className:"desktop-detach-preview-bar",children:n.jsx("strong",{className:"desktop-detach-preview-title",children:"小窗口"})}),n.jsx("div",{className:"desktop-detach-preview-body",children:n.jsx("span",{className:"desktop-detach-preview-badge"})})]})})}function d9(e){return{navigationGroups:e,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function h9(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function m9(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function p9(e){return e.kind==="files"?o("shell.filesEntry"):e.kind==="git"?o("shell.gitEntry"):e.kind==="processes"?o("shell.terminalManagerEntry"):e.kind}function f9(){const{windowId:e}=Eo(),t=vr(),r=nr(),s=ai(N=>N.sessionDisplaySortMode),[i,l]=p.useState(null),[c,d]=p.useState(!0),[m,f]=p.useState(null),[v,g]=p.useState([]),[w,k]=p.useState(null);p.useEffect(()=>{let N=!1;async function D(){if(!e){l(null),d(!1),f(o("desktopWindow.invalidWindowId"));return}d(!0),f(null);const F=await r.bridge.getWindowDescriptor(e),W=F.ok?F.value??null:r.windows.getDescriptor(e);if(!N){if(!W){l(null),d(!1),f(F.detail??o("desktopWindow.loadDescriptorFailed"));return}r.windows.registerDescriptor(W),r.windows.markWindowOpen(W.windowId),l(W),d(!1)}}return D(),()=>{N=!0}},[r,e]),p.useEffect(()=>{if(!(i!=null&&i.workspaceId)){g([]);return}let N=!1;async function D(){try{const F=await rP();if(N)return;g(tu(F,s))}catch{if(N)return;g([])}}return D(),()=>{N=!0}},[i==null?void 0:i.workspaceId,s]),p.useEffect(()=>{if(!i){k(null);return}const N=new $N({onConnectionChange:()=>{},onSnapshot:D=>{g(tu(D,s))},onUnauthorized:()=>{br.clear(),t(`/login?returnTo=${encodeURIComponent(`/desktop-window/${i.windowId}`)}`,{replace:!0})}});return k(N),N.start(),()=>{N.close(),k(null)}},[i,t,s]);const y=p.useMemo(()=>w?{navigationGroups:v,subscribeFileTree:w.subscribeFileTree.bind(w),requestFileTreeRefresh:w.requestFileTreeRefresh.bind(w),addFileTreeSnapshotListener:w.addFileTreeSnapshotListener.bind(w),subscribeGitSnapshot:w.subscribeGit.bind(w),requestGitRefresh:w.requestGitRefresh.bind(w),addGitSnapshotListener:w.addGitSnapshotListener.bind(w)}:d9(v),[v,w]),C=p.useMemo(()=>w?{subscribeGitSnapshot:w.subscribeGit.bind(w),requestGitRefresh:w.requestGitRefresh.bind(w),addGitSnapshotListener:w.addGitSnapshotListener.bind(w)}:h9(),[w]),T=p.useMemo(()=>w?{subscribeTerminalManagerSnapshot:w.subscribeTerminalManager.bind(w),requestTerminalManagerRefresh:w.requestTerminalManagerRefresh.bind(w),addTerminalManagerSnapshotListener:w.addTerminalManagerSnapshotListener.bind(w)}:m9(),[w]);if(!r.isDesktop)return n.jsx($a,{to:"/",replace:!0});if(c)return n.jsx("main",{className:"desktop-window-page",children:n.jsx("p",{className:"status-text",children:o("common.loading")})});if(m)return n.jsx("main",{className:"desktop-window-page",children:n.jsx("p",{className:"status-text",children:m})});if(!i)return n.jsx("main",{className:"desktop-window-page",children:n.jsx("p",{className:"status-text",children:o("desktopWindow.loadDescriptorFailed")})});let j=null;return i.kind==="files"?j=n.jsx(ow,{sessionId:i.sessionId,workspaceId:i.workspaceId,externalWindowMode:!0,workbenchShellOverrides:y}):i.kind==="git"?j=n.jsx(cw,{workspaceId:i.workspaceId,externalWindowMode:!0,workbenchShellOverrides:C}):i.kind==="processes"&&(j=n.jsx(dw,{currentWorkspaceId:i.workspaceId,navigationGroups:v,externalWindowMode:!0,workbenchShellOverrides:T})),j?n.jsx("main",{className:"desktop-window-page",children:n.jsx("div",{className:"desktop-window-body","data-window-kind":i.kind,"aria-label":p9(i),children:j})}):n.jsx("main",{className:"desktop-window-page",children:n.jsx("p",{className:"status-text",children:o("desktopWindow.unsupportedKind",{kind:i.kind})})})}function hw({open:e,workspaces:t,workspaceOptions:r,initialWorkspaceId:s,onClose:i,onSelect:l}){const[c,d]=p.useState(""),[m,f]=p.useState(!1),v=li(),g=p.useMemo(()=>r??t.map(y=>({workspace:y,label:y.name,subtitle:y.path,depth:0,kind:"workspace",meta:null})),[r,t]),w=p.useMemo(()=>g.map(y=>y.workspace.id).join("|"),[g]);if(p.useEffect(()=>{e&&(d(g9(g,s)),f(!1))},[s,e,w]),!e||typeof document>"u")return null;const k=g.find(y=>y.workspace.id===c)??g[0]??null;return $n.createPortal(n.jsx("div",{className:"ios-action-sheet-overlay",role:"presentation",onClick:i,children:n.jsxs("div",{className:"mobile-workspace-home-sheet",role:"dialog","aria-modal":"true","aria-label":o("shell.createSessionModalTitle"),onClick:y=>y.stopPropagation(),children:[n.jsxs("div",{className:"mobile-workspace-home-sheet-card",children:[n.jsx("div",{className:"mobile-workspace-home-sheet-header",children:n.jsx("strong",{children:o("shell.createSessionModalTitle")})}),n.jsxs("div",{className:"mobile-feature-form mobile-workspace-home-form mobile-create-session-form",children:[n.jsx("p",{className:"mobile-create-session-description",children:o("shell.createSessionModalDescription")}),n.jsxs("div",{className:"mobile-feature-field",children:[n.jsx("span",{children:o("shell.createSessionWorkspaceLabel")}),n.jsxs("button",{type:"button",className:"mobile-create-session-workspace-trigger","aria-label":`${o("shell.createSessionWorkspaceLabel")} ${(k==null?void 0:k.label)??""}`.trim(),"aria-expanded":m?"true":"false",disabled:g.length===0,onClick:()=>{v.trigger("selection"),f(y=>!y)},children:[n.jsxs("span",{className:"mobile-create-session-workspace-copy",children:[n.jsx("strong",{children:(k==null?void 0:k.label)??o("common.unknown")}),n.jsx("span",{children:(k==null?void 0:k.subtitle)??o("common.unknown")})]}),n.jsx(b9,{expanded:m})]}),m?n.jsx("div",{className:"mobile-workspace-home-group mobile-create-session-workspace-list",role:"list",children:g.map(y=>n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-create-session-workspace-row","data-worktree-kind":y.kind,"data-worktree-depth":y.depth,onClick:()=>{y.workspace.id!==c&&v.trigger("selection"),d(y.workspace.id),f(!1)},children:[n.jsxs("span",{className:"mobile-create-session-workspace-option-copy",style:{"--mobile-workspace-tree-depth":String(y.depth)},children:[n.jsxs("strong",{children:[y.kind==="worktree"?n.jsx("span",{className:"mobile-workspace-home-worktree-badge",children:o("shell.mobileWorktreeBadge")}):null,y.label]}),n.jsx("span",{children:y.subtitle})]}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:y.workspace.id===c?n.jsx(w9,{}):n.jsx(v9,{})})]},y.workspace.id))}):null]}),n.jsxs("div",{className:"mobile-create-session-provider-block",children:[n.jsxs("div",{className:"mobile-create-session-provider-header",children:[n.jsx("span",{className:"mobile-create-session-provider-label",children:o("shell.createSessionProviderLabel")}),n.jsx("span",{className:"mobile-create-session-provider-hint",children:o("shell.providerOptionHint")})]}),n.jsx(Rv,{disabled:!c,workspaceId:c||null,onSelect:y=>{c&&l(c,y)}})]})]})]}),n.jsx("button",{type:"button",className:"ios-action-sheet-cancel",onClick:i,children:o("common.cancel")})]})}),document.body)}function g9(e,t){var r;return t&&e.some(s=>s.workspace.id===t)?t:((r=e[0])==null?void 0:r.workspace.id)??""}function b9({expanded:e}){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"mobile-create-session-workspace-chevron","data-expanded":e?"true":"false",children:n.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function v9(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function w9(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}const y9=420,k9=156;function x9({entry:e,isFavorite:t,isActive:r=!1,depth:s=0,variant:i="default",workspaceTone:l="root",hasSubsessions:c=!1,subsessionsExpanded:d=!1,showActions:m=!0,onActivate:f,onToggleSubsessions:v,onToggleFavorite:g,onArchive:w,onUnarchive:k,onRename:y}){const[C,T]=p.useState(!1),[j,N]=p.useState(null),[D,F]=p.useState(null),W=p.useRef(null),E=p.useRef(!1),I=p.useRef(null),M=li(),{session:_,workspace:L}=e,Q=_.title??_.sessionId,O=qs(_.provider),ne=[O,S9(_.lastMessageAt??_.updatedAt??null),eu(_)].filter(Boolean).join(" · "),Y=j9(_),G=Y?T9(Y):null,te=i==="mobile"?null:eu(_),K=te?SP("session-list-activity-badge",_):null;p.useEffect(()=>()=>{P()},[]),p.useLayoutEffect(()=>{if(!C||!D||typeof window>"u"){N(null);return}const ie=()=>{var bt,Ct;const Oe=PP(D,{width:((bt=I.current)==null?void 0:bt.offsetWidth)??0,height:((Ct=I.current)==null?void 0:Ct.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:k9});N({position:"fixed",left:`${Math.round(Oe.left)}px`,top:`${Math.round(Oe.top)}px`,width:`${Math.round(Oe.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(Oe.maxHeight)}px`,transformOrigin:Oe.transformOrigin})},xe=Oe=>{var Ct;const bt=Oe.target;bt&&!((Ct=I.current)!=null&&Ct.contains(bt))&&q()},lt=Oe=>{Oe.key==="Escape"&&q()};return ie(),window.addEventListener("pointerdown",xe),window.addEventListener("keydown",lt),window.addEventListener("resize",ie),window.addEventListener("scroll",ie,!0),()=>{window.removeEventListener("pointerdown",xe),window.removeEventListener("keydown",lt),window.removeEventListener("resize",ie),window.removeEventListener("scroll",ie,!0)}},[D,C]);function z(ie){F(ie),T(!0)}function q(){T(!1),F(null)}function P(){W.current!==null&&(window.clearTimeout(W.current),W.current=null)}function U(ie){if(!m||ie.pointerType==="mouse")return;const xe={x:ie.clientX,y:ie.clientY};P(),W.current=window.setTimeout(()=>{E.current=!0,M.trigger("gesture"),z(xe)},y9)}function X(){P()}function R(){if(E.current){E.current=!1;return}M.trigger("selection"),f(_.sessionId)}const Se=async()=>{const ie=window.prompt(o("shell.renameModalDescription"),Q);ie&&(await y(_.sessionId,ie.trim()),q())},se=async()=>{if(_.isArchived){await k(_.sessionId),q();return}await w(_.sessionId),q()},J=()=>{g(_.sessionId),q()},Ne=ie=>{if(ie.key!=="ContextMenu"&&!(ie.shiftKey&&ie.key==="F10"))return;ie.preventDefault(),ie.stopPropagation();const xe=ie.currentTarget.getBoundingClientRect();z({x:xe.right,y:xe.bottom})},Ee=C&&typeof document<"u"?$n.createPortal(n.jsxs("div",{ref:I,className:"session-action-menu surface-card",role:"menu","aria-label":o("shell.sessionMoreAction"),style:j??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:ie=>ie.stopPropagation(),children:[n.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:J,children:o(t?"shell.unfavoriteAction":"shell.favoriteAction")}),n.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void se(),children:_.isArchived?o("shell.unarchiveAction"):o("shell.archiveAction")}),n.jsx("button",{type:"button",className:"session-action-menu-item",role:"menuitem",onClick:()=>void Se(),children:o("shell.renameAction")})]}),document.body):null;return n.jsxs("article",{className:"session-list-item","data-depth":s,"data-active":r,"data-workspace-tone":l,"data-has-subsessions":c,"data-variant":i,onContextMenu:ie=>{m&&(ie.preventDefault(),ie.stopPropagation(),z({x:ie.clientX,y:ie.clientY}))},children:[c?n.jsx("button",{type:"button",className:"session-list-subsession-toggle","aria-label":o(d?"shell.subagentCollapse":"shell.subagentExpand"),title:o(d?"shell.subagentCollapse":"shell.subagentExpand"),"aria-expanded":d,onClick:ie=>{ie.stopPropagation(),M.trigger("selection"),v==null||v()},children:n.jsx("span",{className:Vj(_,{isActive:r,hasSubsessions:c}),"aria-hidden":"true"})}):n.jsx("span",{className:Vj(_,{isActive:r,hasSubsessions:c}),"aria-hidden":"true"}),n.jsx("button",{type:"button",className:"session-list-link",onClick:R,onPointerDown:U,onPointerUp:X,onPointerCancel:X,onPointerLeave:X,onKeyDown:Ne,children:n.jsxs("div",{className:"session-list-copy",children:[n.jsx("div",{className:"session-list-title",children:Q||o("shell.searchEntry")}),n.jsx("div",{className:"session-list-meta",children:i==="mobile"?n.jsx("span",{children:ne}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:L.name}),te&&K?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:K,children:te})]}):null,n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{children:O})]})}),G?n.jsx("div",{className:"session-list-error",title:Y??void 0,children:G}):null]})}),Ee]})}function Vj(e,t){return Cv("session-list-indicator",e,{isActive:t.isActive,hasSubagents:t.hasSubsessions})}function S9(e){return e?new Date(e).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):o("common.unknown")}function C9(e){return Su(e)||e.syncStatus==="error"}function j9(e){var s,i;if(!C9(e))return null;const t=((s=e.lastErrorCode)==null?void 0:s.trim())??"",r=((i=e.lastErrorDetail)==null?void 0:i.replace(/\s+/g," ").trim())??"";return t&&r&&!r.includes(t)?`${t} · ${r}`:r||t||(e.syncStatus==="error"&&!Su(e)?o("conversation.syncStatusError"):o("conversation.runtimeErrorTitle"))}function T9(e,t=96){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const ah=5;function N9(){var se;const e=vr(),{navigationGroups:t,favoriteSessionIds:r,currentWorkspaceId:s,currentSessionId:i,navigationLoading:l,selectWorkspace:c,toggleFavoriteSession:d,archiveSession:m,unarchiveSession:f,renameSession:v,startDraftSession:g}=Pr(),w=Ul(t),k=p.useMemo(()=>hm(t),[t]),y=ua(t,s)??ua(t,((se=t[0])==null?void 0:se.workspace.id)??null),C=w.find(J=>J.workspace.id===(y==null?void 0:y.workspace.id))??(y?{workspace:y.workspace,label:y.workspace.name,subtitle:y.workspace.path}:null),T=p.useMemo(()=>new Set(r),[r]),j=p.useMemo(()=>y?y.sessions.filter(J=>{var ie;if(J.isArchived)return!1;const Ne=((ie=J.parentSessionId)==null?void 0:ie.trim())||null;if(!Ne)return!0;const Ee=y.sessions.find(xe=>xe.sessionId===Ne);return!Ee||!Ee.isArchived}).map(J=>({session:J,workspace:y.workspace})):[],[y]),N=p.useMemo(()=>j.filter(J=>T.has(J.session.sessionId)),[j,T]),D=p.useMemo(()=>Wh(j),[j]),F=p.useMemo(()=>Wh(N),[N]),W=p.useMemo(()=>y?y.sessions.filter(J=>J.isArchived===!0&&!qi(J)):[],[y]),E=(y==null?void 0:y.workspace.id)??"",I=!!E,[M,_]=p.useState([]),[L,Q]=p.useState({}),[O,ne]=p.useState(!1),[Y,G]=p.useState(!1),[te,K]=p.useState(null);p.useEffect(()=>{Q(J=>{const Ne={};for(const Ee of D){const ie=ii(zi(Ee));if(ie.length===0)continue;const xe=ie.findIndex(lt=>lt.item.session.sessionId===i);Ne[Ee.item.session.sessionId]=A9(ie.length,ah,J[Ee.item.session.sessionId],xe)}return I9(J,Ne)?J:Ne})},[i,D]),p.useEffect(()=>{if(!i)return;const J=la(D,i,Ne=>Ne.session.sessionId);J.length!==0&&_(Ne=>{const Ee=new Set(Ne);let ie=!1;for(const xe of J)Ee.has(xe)||(Ee.add(xe),ie=!0);return ie?Array.from(Ee):Ne})},[i,D]);function z(J){_(Ne=>Ne.includes(J)?Ne.filter(Ee=>Ee!==J):[...Ne,J])}function q(J){return L[J]??ah}function P(J){Q(Ne=>({...Ne,[J]:(Ne[J]??ah)+ah}))}function U(J,Ne){jo("immersive"),e(Yn(J,Ne))}function X(J,Ne){ne(!1),jo("immersive"),g(J,Ne)}async function R(J){K(J);try{await f(J)}finally{K(Ne=>Ne===J?null:Ne)}}function Se(J,Ne=!1,Ee=[],ie=!1,xe=!1){var je;const lt=J.item.session.sessionId,Oe=J.children,bt=J.depth===0&&Oe.length>0,Ct=Ne||bt&&M.includes(lt),nt=Ct&&bt,et=nt?M9(J,q(lt)):J,De=Ct?et.children:[],Ue=ii(Oe).length,Ye=ii(De).length,ye=nt&&Ye<Ue,He=J.depth>0?[...Ee,ie]:[...Ee];return n.jsxs("div",{className:"session-list-tree-node",children:[n.jsxs("div",{className:"session-list-tree-row",style:{"--session-tree-depth":J.depth},children:[J.depth>0?n.jsxs("div",{className:"session-tree-guides","aria-hidden":"true",style:{"--session-tree-depth":J.depth},children:[Ee.map((Fe,Ve)=>Fe?n.jsx("span",{className:"session-tree-guide-column",style:{"--session-tree-level":Ve+1}},`${lt}:ancestor:${Ve}`):null),n.jsx("span",{className:"session-tree-guide-branch","data-continue":ie,"data-first":xe,style:{"--session-tree-level":J.depth},children:n.jsx("span",{className:"session-tree-guide-branch-horizontal"})})]}):null,n.jsx(x9,{entry:J.item,isFavorite:T.has(lt),isActive:i===lt,depth:J.depth,variant:"mobile",workspaceTone:((je=k[J.item.workspace.id])==null?void 0:je.tone)??"root",hasSubsessions:bt,subsessionsExpanded:Ct,onActivate:Fe=>U(J.item.workspace.id,Fe),onToggleSubsessions:bt?()=>z(lt):void 0,onToggleFavorite:Fe=>{d(Fe)},onArchive:Fe=>m(Fe),onUnarchive:Fe=>f(Fe),onRename:(Fe,Ve)=>v(Fe,Ve)})]}),Ct&&De.length>0?n.jsx("div",{className:"session-list-children",children:De.map((Fe,Ve)=>Se(Fe,!0,He,Ve<De.length-1,Ve===0))}):null,ye?n.jsx("div",{className:"session-list-children",children:n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>P(lt),children:o("shell.subagentExpandMore")})}):null]},`${J.item.workspace.id}:${lt}`)}return n.jsxs("main",{className:"session-index-page mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header",children:[n.jsx(Hl,{currentWorkspace:C?{id:C.workspace.id,name:C.label,path:C.subtitle}:null,workspaces:t.map(J=>J.workspace),workspaceOptions:w,onSelectWorkspace:J=>{c(J),e(Si(J))},content:n.jsx("button",{type:"button",className:"primary-button mobile-session-index-create-button",disabled:l||!I,onClick:()=>ne(!0),children:o("shell.createSession")})}),n.jsxs("div",{className:"mobile-page-top-body",children:[n.jsx("div",{className:"session-index-archive-actions",children:n.jsxs("button",{type:"button",className:"primary-button mobile-session-index-create-button session-index-archive-button",disabled:l||!y,onClick:()=>G(!0),children:[n.jsx("span",{children:o("shell.archiveViewAction")}),n.jsx("span",{className:"session-index-archive-count",children:W.length})]})}),F.length>0?n.jsxs("section",{className:"session-section session-section-sheet",children:[n.jsxs("header",{className:"session-section-heading",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.favoriteSectionTitle")})}),n.jsx("span",{className:"session-section-count",children:N.length})]}),n.jsx("div",{className:"session-current-workspace-list",children:F.map(J=>Se(J))})]}):null,n.jsxs("section",{className:"session-section session-section-sheet",children:[n.jsxs("header",{className:"session-section-heading",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.mobileConversationCurrentWorkspaceSection")})}),n.jsx("span",{className:"session-section-count",children:D.length})]}),D.length===0?n.jsx("p",{className:"session-section-empty",children:o(l?"shell.searchSessionHint":"shell.emptyWorkspaceSessions")}):n.jsx("div",{className:"session-current-workspace-list",children:D.map(J=>Se(J))})]})]}),n.jsx(hw,{open:O,workspaces:t.map(J=>J.workspace),workspaceOptions:w,initialWorkspaceId:s??E,onClose:()=>ne(!1),onSelect:X}),n.jsx(P9,{open:Y,workspaceName:(C==null?void 0:C.label)??(y==null?void 0:y.workspace.name)??null,sessions:W,restoringSessionId:te,onClose:()=>{te||G(!1)},onRestore:J=>void R(J)})]})}function P9({open:e,workspaceName:t,sessions:r,restoringSessionId:s,onClose:i,onRestore:l}){return p.useEffect(()=>{if(!e)return;function c(d){d.key==="Escape"&&!s&&i()}return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c)}},[i,e,s]),!e||typeof document>"u"?null:$n.createPortal(n.jsxs("div",{className:"workbench-modal-layer",children:[n.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":o("common.close"),disabled:!!s,onClick:i}),n.jsxs("section",{className:"workbench-modal-card surface-card",role:"dialog","aria-modal":"true","aria-label":o("shell.archiveModalTitle"),children:[n.jsx("div",{className:"workbench-modal-header",children:n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{children:o("shell.archiveModalTitle")}),n.jsx("p",{children:t?`${t} · ${o("shell.archiveModalDescription")}`:o("shell.archiveModalDescription")})]})}),n.jsx("div",{className:"workbench-modal-body",children:r.length>0?n.jsx("div",{className:"workbench-archive-list",children:r.map(c=>n.jsxs("article",{className:"workbench-archive-item",children:[n.jsxs("div",{className:"workbench-archive-item-main",children:[n.jsx("strong",{title:c.title??c.sessionId,children:c.title??c.sessionId}),n.jsx("p",{children:D9(c)})]}),n.jsx("button",{type:"button",className:"secondary-button",disabled:s===c.sessionId,onClick:()=>{l(c.sessionId)},children:o("shell.unarchiveAction")})]},c.sessionId))}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.archiveEmpty")})})]})]}),document.body)}function D9(e){const t=qs(e.provider),r=R9(e.lastMessageAt??e.updatedAt??null);return[t,r].filter(Boolean).join(" · ")}function R9(e){if(!e)return null;const t=Date.parse(e);return Number.isNaN(t)?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}function M9(e,t){const r=new Set(ii(zi(e)).sort((s,i)=>(i.item.session.lastMessageAt??i.item.session.updatedAt).localeCompare(s.item.session.lastMessageAt??s.item.session.updatedAt)).slice(0,t).map(s=>s.item.session.sessionId));return{...e,children:hM(zi(e),r)}}function hM(e,t){return e.flatMap(r=>{const s=hM(zi(r),t);return!t.has(r.item.session.sessionId)&&s.length===0?[]:[{...r,children:s}]})}function A9(e,t,r,s=-1){if(e<=0)return 0;const i=s>=0?Math.max(t,s+1):t;return Math.min(e,Math.max(r??0,i))}function I9(e,t){const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(i=>e[i]===t[i])}function E9(){const{currentWorkspaceId:e,currentSessionId:t,navigationGroups:r}=Pr();if(!e)return n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.filesEntry")}),n.jsx("p",{children:o("shell.toolsWorkspaceRequiredBody")})]})});const s=r.flatMap(l=>l.sessions).find(l=>l.sessionId===t&&l.workspaceId===e),i=s?Yn(e,s.sessionId):Si(e);return n.jsx($a,{to:`${i}?toolPanel=files`,replace:!0})}function L9(){const{currentWorkspaceId:e,currentSessionId:t,navigationGroups:r}=Pr();if(!e)return n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.gitEntry")}),n.jsx("p",{children:o("shell.toolsWorkspaceRequiredBody")})]})});const s=r.flatMap(l=>l.sessions).find(l=>l.sessionId===t&&l.workspaceId===e),i=s?Yn(e,s.sessionId):Si(e);return n.jsx($a,{to:`${i}?toolPanel=git`,replace:!0})}function F9(){const{currentWorkspaceId:e,currentSessionId:t,navigationGroups:r}=Pr();if(!e)return n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.terminalManagerEntry")}),n.jsx("p",{children:o("shell.toolsWorkspaceRequiredBody")})]})});const s=r.flatMap(l=>l.sessions).find(l=>l.sessionId===t&&l.workspaceId===e),i=s?Yn(e,s.sessionId):Si(e);return n.jsx($a,{to:`${i}?toolPanel=processes`,replace:!0})}function _9(){var c,d;const{navigationGroups:e,currentWorkspaceId:t,currentSessionId:r}=Pr(),s=((c=e.find(m=>m.workspace.id===t))==null?void 0:c.workspace)??((d=e[0])==null?void 0:d.workspace)??null;if(!s)return n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.mobileSessionsEntry")}),n.jsx("p",{children:o("shell.emptyNavigationBody")})]})});const i=e.flatMap(m=>m.sessions).find(m=>m.sessionId===r&&m.workspaceId===s.id),l=i?Yn(s.id,i.sessionId):Si(s.id);return n.jsx($a,{to:l,replace:!0})}function O9(e){return e.status==="active"}function B9(e){return e.status==="queued"||e.status==="running"}function W9(e,t){return e.filter(O9).length+t.filter(B9).length}function U9(e){const t=p.useMemo(()=>e.notifications.filter(r=>e.showArchivedNotifications||!e.archivedNotificationIds.has(r.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return n.jsx(Ln,{open:e.open,title:o("shell.globalNotificationsPanelTitle"),description:o("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card mobile-notification-modal-card",onClose:e.onClose,children:n.jsxs("div",{className:"workbench-notification-pane mobile-notification-pane",role:"tabpanel","aria-label":o("shell.globalNotificationsAction"),children:[n.jsx("div",{className:"workbench-notification-toolbar",children:n.jsxs("label",{className:"workbench-notification-filter",children:[n.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:r=>e.onToggleShowArchivedNotifications(r.target.checked)}),n.jsx("span",{children:o("shell.globalNotificationsShowArchived")})]})}),t.length>0?n.jsx("div",{className:"workbench-notification-list",children:t.map(r=>{const s=e.archivedNotificationIds.has(r.id);return n.jsxs("article",{className:"workbench-notification-item","data-archived":s,children:[n.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(r)},children:[n.jsx("span",{className:"workbench-notification-item-kind",children:H9(r.kind)}),n.jsx("strong",{children:r.title}),n.jsx("p",{children:r.body})]}),n.jsxs("div",{className:"workbench-notification-item-side",children:[n.jsx("time",{children:z9(r.createdAt)}),n.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(s){e.onUnarchiveNotification(r.id);return}e.onArchiveNotification(r.id)},children:o(s?"shell.globalNotificationsRemoveArchiveAction":"shell.globalNotificationsArchiveAction")})]})]},r.id)})}):n.jsx("p",{className:"workbench-notification-empty",children:o("shell.globalNotificationsEmpty")})]})})}function H9(e){switch(e){case"follow_up_waiting_user":return o("shell.globalNotificationKindWaitingUser");case"follow_up_completed":return o("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return o("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return o("shell.globalNotificationKindVerificationFailed");default:return o("shell.globalNotificationsPanelTitle")}}function z9(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function q9(e){return e.isArchived!==!0&&!qi(e)}function mM(e){return e.activityState==="running"||e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting"}function $9(e){return e.activityState==="idle"&&mM(e)===!1}function Gj(e){return e==="creating"||e==="running"}function Kj(e){return e.lastEventAt??e.lastMessageAt??e.updatedAt??e.createdAt}function Yj(e){return e?new Date(e).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):o("common.unknown")}function go(e){return e!==null&&e>0}const oh=60*1e3,V9=15e3;function G9(){var He;const e=vr(),{showToast:t}=Qn(),r=Pr(),{navigationGroups:s,currentWorkspaceId:i,refreshNavigation:l,selectWorkspace:c,startDraftSession:d,subscribeGitSnapshot:m,requestGitRefresh:f,addGitSnapshotListener:v,subscribeTerminalManagerSnapshot:g,requestTerminalManagerRefresh:w,addTerminalManagerSnapshotListener:k}=r,y=r.globalNotifications??[],C=new Set(r.archivedNotificationIds??[]),T=r.showArchivedNotifications??!1,j=r.unreadNotificationCount??0,N=r.setShowArchivedNotifications??(()=>{}),D=r.archiveNotification??(()=>{}),F=r.unarchiveNotification??(()=>{}),[W,E]=p.useState(null),[I,M]=p.useState(!1),[_,L]=p.useState(!1),[Q,O]=p.useState(!1),[ne,Y]=p.useState({gitLoading:!1,terminalLoading:!1,branch:null,activeTerminalCount:null,changedFileCount:null,quickLaunchRunning:null}),[G,te]=p.useState({loading:!0,activeTaskCount:0,pendingInboxCount:0}),K=Ul(s),z=ua(s,i)??ua(s,((He=s[0])==null?void 0:He.workspace.id)??null),q=(z==null?void 0:z.workspace)??null,P=K.find(je=>je.workspace.id===(q==null?void 0:q.id))??(q?{workspace:q,label:q.name,subtitle:q.path}:null),U=[...(z==null?void 0:z.sessions)??[]].filter(q9),X=U.filter(mM),R=U.filter($9),Se=U.filter(je=>je.isFavorite===!0),se=X.slice(0,6),J=Se.slice(0,6),Ne=ne.quickLaunchRunning===null?"…":ne.quickLaunchRunning?o("shell.workspaceHomeQuickLaunchRunning"):o("shell.workspaceHomeQuickLaunchStopped");p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je){Y({gitLoading:!1,terminalLoading:!1,branch:null,activeTerminalCount:null,changedFileCount:null,quickLaunchRunning:null});return}const Fe=Er(Sg(je),oh);Y(Ve=>{var kt,me;return{...Ve,gitLoading:Fe===null,branch:((kt=Fe==null?void 0:Fe.status)==null?void 0:kt.snapshot.branch)??null,changedFileCount:((me=Fe==null?void 0:Fe.status)==null?void 0:me.changes.length)??null}})},[q==null?void 0:q.id]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(je)return v(Fe=>{Fe.workspaceId===je&&(As(Sg(je),Fe),Y(Ve=>{var kt,me,Me;return{...Ve,gitLoading:!1,branch:((kt=Fe.status)==null?void 0:kt.snapshot.branch)??((me=Fe.branches)==null?void 0:me.currentBranch)??null,changedFileCount:((Me=Fe.status)==null?void 0:Me.changes.length)??null}}))})},[v,q==null?void 0:q.id]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je){Y(Ve=>({...Ve,gitLoading:!1,branch:null,changedFileCount:null}));return}const Fe=Er(Cg(je),oh);Y(Ve=>({...Ve,terminalLoading:Fe===null,activeTerminalCount:Fe?Fe.terminals.filter(kt=>Gj(kt.status)).length:null,quickLaunchRunning:Fe?Fe.templateStatuses.some(kt=>kt.occupied):null}))},[q==null?void 0:q.id]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je){Y(Fe=>({...Fe,terminalLoading:!1,activeTerminalCount:null,quickLaunchRunning:null}));return}return k(Fe=>{Fe.workspaceId===je&&(As(Cg(je),{terminals:Fe.terminals,templates:Fe.templates,templateStatuses:Fe.templateStatuses}),Y(Ve=>({...Ve,terminalLoading:!1,activeTerminalCount:Fe.terminals.filter(kt=>Gj(kt.status)).length,quickLaunchRunning:Fe.templateStatuses.some(kt=>kt.occupied)})))})},[k,q==null?void 0:q.id]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je)return;const Fe=Er(Sg(je),oh)!==null;m(je),!Fe&&f(je)},[q==null?void 0:q.id,f,m]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je)return;const Fe=Er(Cg(je),oh)!==null;g(je),!Fe&&w(je)},[q==null?void 0:q.id,w,g]),p.useEffect(()=>{const je=(q==null?void 0:q.id)??null;if(!je){te({loading:!1,activeTaskCount:0,pendingInboxCount:0});return}let Fe=!1;async function Ve(Xe){te(ze=>({...ze,loading:!0}));try{const ze=await mm();if(!ze.initialized||!ze.profile){Fe||te({loading:!1,activeTaskCount:0,pendingInboxCount:0});return}const[vt,ht,pe]=await Promise.all([pm(),fm(),Nu({workspaceId:je})]);if(Fe)return;const $e=new Set(vt.overview.projects.filter(Rt=>Rt.workspaceId===je).map(Rt=>Rt.id)),Nt=vt.overview.verifications.filter(Rt=>Rt.projectId?$e.has(Rt.projectId):!1);te({loading:!1,activeTaskCount:W9(ht.items.filter(Rt=>Rt.workspaceId===je),Nt),pendingInboxCount:pe.items.filter(Rt=>Rt.status!=="closed").length})}catch(ze){if(Fe)return;te(vt=>({...vt,loading:!1})),Xe&&t({title:o("shell.butlerLoadFailed"),description:ze instanceof Error?ze.message:void 0,tone:"error"})}}Ve(!0);const kt=window.setInterval(()=>{Ve(!1)},V9),me=Zv(()=>{Ve(!1)}),Me=()=>{Ve(!1)};return window.addEventListener(Po,Me),()=>{Fe=!0,window.clearInterval(kt),me(),window.removeEventListener(Po,Me)}},[q==null?void 0:q.id,t]);async function Ee(je){await l(),c(je.id),E(null),e(Ms(je.id))}async function ie(je){await l(),c(je.id),E(null),e(Ms(je.id))}function xe(){q&&(c(q.id),e(EN(q.id,"git")))}function lt(){q&&(c(q.id),e(xo(q.id)))}function Oe(){q&&(c(q.id),e(Xb(q.id)))}function bt(){q&&(c(q.id),e(Ui(q.id)))}function Ct(){q&&e(Si(q.id))}function nt(){q&&M(!0)}function et(je,Fe){M(!1),d(je,Fe)}function De(){q&&(c(q.id),e(Ms(q.id)))}function Ue(je){c(je)}const Ye=[{label:o("shell.workspaceHomeMetricActive"),value:X.length,accent:go(X.length),onClick:U.length>0?Ct:void 0},{label:o("shell.workspaceHomeMetricUnread"),value:j,accent:go(j),onClick:()=>O(!0)},{label:o("shell.workspaceHomeMetricTerminal"),value:ne.terminalLoading?"…":ne.activeTerminalCount??"—",accent:ne.terminalLoading===!1&&go(ne.activeTerminalCount),onClick:q?lt:void 0},{label:o("shell.workspaceHomeMetricChanges"),value:ne.gitLoading?"…":ne.changedFileCount??"—",accent:ne.gitLoading===!1&&go(ne.changedFileCount),onClick:q?xe:void 0}],ye=[{label:o("shell.workspaceHomeWaitingInputLabel"),value:R.length,accent:go(R.length),onClick:U.length>0?Ct:void 0},{label:o("shell.workspaceHomeButlerLabel"),value:G.loading?"…":G.activeTaskCount,accent:G.loading===!1&&go(G.activeTaskCount),onClick:q?bt:void 0},{label:o("shell.workspaceHomeQuickLaunchStatusLabel"),value:Ne,accent:ne.quickLaunchRunning===!0,onClick:q?Oe:void 0},{label:o("shell.butlerInboxAction"),value:G.loading?"…":G.pendingInboxCount,accent:G.loading===!1&&go(G.pendingInboxCount),onClick:q?()=>L(!0):void 0}];return n.jsxs("main",{className:"mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header mobile-workspace-home-page",children:[n.jsx(Hl,{currentWorkspace:P?{id:P.workspace.id,name:P.label,path:P.subtitle}:null,workspaces:s.map(je=>je.workspace),workspaceOptions:K,onSelectWorkspace:Ue,sheetContent:je=>n.jsxs("div",{className:"mobile-workspace-home-group mobile-workspace-home-sheet-group",children:[n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row",onClick:()=>{je(),E("import")},children:[n.jsx("span",{className:"mobile-workspace-home-row-label",children:o("shell.importWorkspaceTitle")}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]}),n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-sheet-row",onClick:()=>{je(),E("clone")},children:[n.jsx("span",{className:"mobile-workspace-home-row-label",children:o("shell.cloneWorkspaceTitle")}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]})]})}),q?n.jsx(n.Fragment,{children:n.jsxs("div",{className:"mobile-page-top-body mobile-workspace-home-body",children:[n.jsx("section",{className:"mobile-workspace-home-section",children:n.jsx("div",{className:"mobile-workspace-home-metrics-card","aria-label":o("shell.workspaceHomeStatusSectionTitle"),children:n.jsx("div",{className:"mobile-workspace-home-toolbar-summary",children:Ye.map(je=>je.onClick?n.jsxs("button",{type:"button",className:"mobile-workspace-home-toolbar-metric","data-accent":je.accent?"true":void 0,onClick:je.onClick,children:[n.jsx("strong",{className:"mobile-workspace-home-toolbar-metric-value",children:je.value}),n.jsx("span",{className:"mobile-workspace-home-toolbar-metric-label",children:je.label})]},je.label):n.jsxs("div",{className:"mobile-workspace-home-toolbar-metric","data-accent":je.accent?"true":void 0,role:"listitem",children:[n.jsx("strong",{className:"mobile-workspace-home-toolbar-metric-value",children:je.value}),n.jsx("span",{className:"mobile-workspace-home-toolbar-metric-label",children:je.label})]},je.label))})})}),n.jsx("section",{className:"mobile-workspace-home-section",children:n.jsxs("div",{className:"mobile-workspace-home-primary-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:De,children:o("shell.workspaceDetailTitle")}),n.jsx("button",{type:"button",className:"primary-button",onClick:nt,children:o("shell.createSession")})]})}),n.jsx("section",{className:"mobile-workspace-home-section",children:n.jsx("div",{className:"mobile-workspace-home-group",children:ye.map(je=>n.jsxs("button",{type:"button",className:"mobile-workspace-home-row","data-accent":je.accent?"true":void 0,onClick:je.onClick,children:[n.jsx("span",{className:"mobile-workspace-home-row-label",children:je.label}),n.jsxs("span",{className:"mobile-workspace-home-row-trailing",children:[n.jsx("strong",{children:je.value}),n.jsx(Aa,{})]})]},je.label))})}),n.jsxs("section",{className:"mobile-workspace-home-section",children:[n.jsxs("div",{className:"mobile-workspace-home-section-header",children:[n.jsx("p",{className:"mobile-workspace-home-section-title",children:o("shell.workspaceHomeActiveSessionsSectionTitle")}),q?n.jsx("button",{type:"button",className:"mobile-workspace-home-link-button",onClick:Ct,children:o("shell.workspaceHomeViewAllAction")}):null]}),n.jsx("div",{className:"mobile-workspace-home-group",children:se.length===0?n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-empty-row",onClick:nt,children:[n.jsxs("div",{className:"mobile-workspace-home-session-main",children:[n.jsx("span",{className:"mobile-workspace-home-session-title",children:o("shell.createSession")}),n.jsx("span",{className:"mobile-workspace-home-session-meta",children:q.name})]}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]}):se.map(je=>n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-session-row",onClick:()=>e(Yn(q.id,je.sessionId)),children:[n.jsxs("div",{className:"mobile-workspace-home-session-main",children:[n.jsx("span",{className:"mobile-workspace-home-session-title",children:je.title||o("common.unknown")}),n.jsxs("span",{className:"mobile-workspace-home-session-meta",children:[qs(je.provider,"full")," · ",Yj(Kj(je))]})]}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]},je.sessionId))})]}),J.length>0?n.jsxs("section",{className:"mobile-workspace-home-section",children:[n.jsx("div",{className:"mobile-workspace-home-section-header",children:n.jsx("p",{className:"mobile-workspace-home-section-title",children:o("shell.favoriteSectionTitle")})}),n.jsx("div",{className:"mobile-workspace-home-group",children:J.map(je=>n.jsxs("button",{type:"button",className:"mobile-workspace-home-row mobile-workspace-home-session-row",onClick:()=>e(Yn(q.id,je.sessionId)),children:[n.jsxs("div",{className:"mobile-workspace-home-session-main",children:[n.jsx("span",{className:"mobile-workspace-home-session-title",children:je.title||o("common.unknown")}),n.jsxs("span",{className:"mobile-workspace-home-session-meta",children:[qs(je.provider,"full")," · ",Yj(Kj(je))]})]}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]},je.sessionId))})]}):null]})}):n.jsx("div",{className:"mobile-page-top-body mobile-workspace-home-body",children:n.jsxs("section",{className:"mobile-workspace-home-section mobile-workspace-home-empty",children:[n.jsx("p",{className:"mobile-workspace-home-section-title",children:o("shell.workspaceHomeSwitcherTitle")}),n.jsxs("div",{className:"mobile-workspace-home-group",children:[n.jsxs("button",{type:"button",className:"mobile-workspace-home-row",onClick:()=>E("import"),children:[n.jsx("span",{className:"mobile-workspace-home-row-label",children:o("shell.importWorkspaceTitle")}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]}),n.jsxs("button",{type:"button",className:"mobile-workspace-home-row",onClick:()=>E("clone"),children:[n.jsx("span",{className:"mobile-workspace-home-row-label",children:o("shell.cloneWorkspaceTitle")}),n.jsx("span",{className:"mobile-workspace-home-row-trailing",children:n.jsx(Aa,{})})]})]})]})}),n.jsx(HP,{open:W==="import",onClose:()=>E(null),onImported:Ee}),n.jsx(WP,{open:W==="clone",onClose:()=>E(null),onCloned:ie}),n.jsx(hw,{open:I,workspaces:s.map(je=>je.workspace),workspaceOptions:K,initialWorkspaceId:(q==null?void 0:q.id)??i??null,onClose:()=>M(!1),onSelect:et}),n.jsx(Xg,{open:_,preferredWorkspaceId:(q==null?void 0:q.id)??null,compactComposer:!0,onClose:()=>L(!1)}),n.jsx(U9,{open:Q,notifications:y,archivedNotificationIds:C,showArchivedNotifications:T,onClose:()=>O(!1),onToggleShowArchivedNotifications:N,onArchiveNotification:D,onUnarchiveNotification:F,onSelectNotification:je=>{O(!1),je.routePath&&e(je.routePath)}})]})}function Sg(e){return`git-sidebar.snapshot.${e}`}function Cg(e){return`terminal-manager.snapshot.${e}`}function Aa(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function pM({workspace:e,state:t,variant:r,actions:s,matrixLimit:i}){return e?r==="mobile"?n.jsx(K9,{workspace:e,state:t,actions:s,matrixLimit:i}):r==="desktop-modal"?n.jsx(Y9,{workspace:e,state:t,actions:s,matrixLimit:i}):n.jsx(X9,{workspace:e,state:t,actions:s,matrixLimit:i}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.workspaceDetailMissingBody")})}function K9({workspace:e,state:t,actions:r,matrixLimit:s}){var g,w,k;const i=t.primaryAnalysis,l=((g=t.runtime)==null?void 0:g.runtimeSession)??null,c=s?t.matrixItems.slice(0,s):t.matrixItems,d=pw(t),m=mw(t),[f,v]=p.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-workspace-composition-panel",children:[n.jsx("div",{className:"mobile-feature-section-header",children:n.jsx("div",{children:n.jsx("h2",{children:o("shell.workspaceDetailDebugTitle")})})}),t.loading&&i===null?n.jsx("p",{children:o("common.loading")}):null,t.error?n.jsx("p",{className:"status-text","data-tone":"error",children:t.error}):null,i?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mobile-detail-grid mobile-workspace-detail-grid",children:[n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugOverallStatusLabel")}),n.jsx("strong",{children:fw(d)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFrameworkLabel")}),n.jsx("strong",{children:i.primaryFramework??o("common.unknown")})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugConfidenceLabel")}),n.jsx("strong",{children:gM(i.confidence)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugSummaryServiceCountLabel")}),n.jsx("strong",{children:d.totalServices})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugCompatibilityLabel")}),n.jsx("strong",{children:To(i.compatibilityLevel)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugInjectionLabel")}),n.jsx("strong",{children:uu(i.recommendedInjectionMode??"none")})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeStatusLabel")}),n.jsx("strong",{children:Xc((l==null?void 0:l.status)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFailureStageLabel")}),n.jsx("strong",{children:du((l==null?void 0:l.failureStage)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceDiscoveryLabel")}),n.jsx("strong",{children:Dl(i.requiresServiceDiscoveryHandling)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugHmrLabel")}),n.jsx("strong",{children:Dl(i.requiresHmrHandling)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugCallbackLabel")}),n.jsx("strong",{children:Dl(i.requiresCallbackHandling)})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugAiFallbackLabel")}),n.jsx("strong",{children:bw(i.aiFallbackPolicy)})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.manageWorkspacePathLabel")}),n.jsx("strong",{children:e.path})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFrameworkNoteLabel")}),n.jsx("strong",{children:((w=t.currentCompatibilityItem)==null?void 0:w.notes)??o("shell.workspaceDetailDebugFrameworkNoteEmpty")})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugOverallSummaryLabel")}),n.jsx("strong",{children:gw(d)})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugReasonsLabel")}),n.jsx("strong",{children:im(i.reasons,"shell.workspaceDetailDebugEmptyReasons")})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFilesLabel")}),n.jsx("strong",{children:im(i.detectedFiles,"shell.workspaceDetailDebugEmptyFiles")})]})]}),t.runtime===null?n.jsx("p",{className:"status-text",children:o("shell.workspaceDetailDebugRuntimeEmpty")}):null,r?n.jsx("div",{className:"workbench-modal-actions",children:r}):null]}):null]}),m.length>0?n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-workspace-composition-panel",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.workspaceDetailDebugDetectedServicesTitle")})}),n.jsx("span",{className:"mobile-feature-counter",children:m.length})]}),n.jsx("div",{className:"mobile-feature-stack mobile-debug-service-stack",children:m.map(y=>{var C,T,j;return n.jsxs("article",{className:"surface-card mobile-debug-service-card",children:[n.jsxs("div",{className:"mobile-debug-service-card-primary-row",children:[n.jsx("h3",{children:y.service.name}),n.jsxs("div",{className:"mobile-debug-service-card-inline-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceFrameworkLabel")}),n.jsx("strong",{children:((C=y.analysis)==null?void 0:C.primaryFramework)??o("common.unknown")})]})]}),n.jsxs("div",{className:"mobile-debug-service-card-meta-row",children:[n.jsx("p",{title:y.service.cwd,children:mu(y.service.cwd,e.path)}),n.jsx("span",{className:"mobile-debug-service-card-category","data-tone":bM(y.category),children:hu(y.category)})]}),n.jsxs("div",{className:"mobile-debug-service-card-secondary-row",children:[n.jsxs("div",{className:"mobile-debug-service-card-inline-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceCommandLabel")}),n.jsx("strong",{children:vw(y.service)})]}),n.jsxs("div",{className:"mobile-debug-service-card-inline-metric","data-tone":vM(((T=y.analysis)==null?void 0:T.compatibilityLevel)??"unknown"),children:[n.jsx("span",{children:o("shell.workspaceDetailDebugCompatibilityLabel")}),n.jsx("strong",{children:To(((j=y.analysis)==null?void 0:j.compatibilityLevel)??"unknown")})]})]})]},y.service.id)})})]}):null,(k=t.runtime)!=null&&k.services.length?n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-workspace-composition-panel",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.workspaceDetailDebugRuntimeServicesTitle")})}),n.jsx("span",{className:"mobile-feature-counter",children:t.runtime.services.length})]}),n.jsx("div",{className:"mobile-feature-stack",children:t.runtime.services.map(y=>{var C,T,j,N,D;return n.jsxs("article",{className:"surface-card mobile-session-row",children:[n.jsxs("div",{className:"mobile-session-row-primary mobile-session-row-primary-static",children:[n.jsx("span",{className:"mobile-session-row-title",children:y.service.name}),n.jsx("span",{className:"mobile-session-row-provider",children:hu(sm(y.service,y.analysis))})]}),n.jsxs("div",{className:"mobile-detail-grid mobile-workspace-detail-grid",children:[n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServicePathLabel")}),n.jsx("strong",{title:y.service.cwd,children:mu(y.service.cwd,e.path)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeServicePortLabel")}),n.jsx("strong",{children:wM(((C=y.binding)==null?void 0:C.leasedPort)??((T=y.portLease)==null?void 0:T.port)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeServiceBindingLabel")}),n.jsx("strong",{children:yM(((j=y.binding)==null?void 0:j.status)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeServiceProcessLabel")}),n.jsx("strong",{children:kM(((N=y.processInstance)==null?void 0:N.status)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeServiceFailureLabel")}),n.jsx("strong",{children:du(((D=y.processInstance)==null?void 0:D.failureStage)??(l==null?void 0:l.failureStage)??null)})]}),n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeServiceAiLabel")}),n.jsx("strong",{children:fK(y.aiFallbackEdits.map(F=>F.status))})]})]})]},y.service.id)})})]}):null,c.length>0?n.jsx("section",{className:"mobile-feature-panel surface-card mobile-workspace-composition-panel",children:n.jsx(fM,{items:c,layout:"mobile",open:f,onOpen:()=>v(!0),onClose:()=>v(!1)})}):null]})}function Y9({workspace:e,state:t,actions:r,matrixLimit:s}){var m,f,v;const i=t.primaryAnalysis,l=((m=t.runtime)==null?void 0:m.runtimeSession)??null,c=s?t.matrixItems.slice(0,s):t.matrixItems,d=pw(t);return n.jsxs("div",{className:"workbench-manage-list",children:[t.loading&&i===null?n.jsx("p",{className:"workbench-manage-status status-text",children:o("common.loading")}):null,t.error?n.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:t.error}):null,i?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugOverallStatusLabel")}),n.jsx("p",{className:"workbench-manage-detail-value",children:fw(d)}),n.jsx("p",{className:"workbench-manage-hint",children:gw(d)})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.manageWorkspacePathLabel")}),n.jsx("p",{className:"workbench-manage-detail-value",children:e.path})]}),n.jsx("div",{className:"workbench-manage-detail-block",children:n.jsxs("div",{className:"workbench-manage-kv-list",children:[n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFrameworkLabel")}),n.jsx("span",{children:i.primaryFramework??o("common.unknown")})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugConfidenceLabel")}),n.jsx("span",{children:gM(i.confidence)})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugCompatibilityLabel")}),n.jsx("span",{children:To(i.compatibilityLevel)})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugInjectionLabel")}),n.jsx("span",{children:uu(i.recommendedInjectionMode??"none")})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeStatusLabel")}),n.jsx("span",{children:Xc((l==null?void 0:l.status)??null)})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugFailureStageLabel")}),n.jsx("span",{children:du((l==null?void 0:l.failureStage)??null)})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugAiFallbackLabel")}),n.jsx("span",{children:bw(i.aiFallbackPolicy)})]})]})}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugDetectedServicesTitle")}),t.services.length>0?n.jsx("div",{className:"workbench-manage-type-list",children:t.services.map(g=>{const w=t.analyses.find(k=>k.serviceId===g.id)??null;return n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsx("span",{className:"workbench-manage-type-meta",children:n.jsxs("span",{className:"workbench-manage-type-name",children:[g.name," · ",hu(sm(g,w))]})}),n.jsxs("span",{title:g.cwd,children:[mu(g.cwd,e.path)," · ",(w==null?void 0:w.primaryFramework)??o("common.unknown")," · ",To((w==null?void 0:w.compatibilityLevel)??"unknown")," · ",vw(g)]})]},g.id)})}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.workspaceDetailDebugRuntimeEmpty")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugFrameworkNoteLabel")}),n.jsx("p",{className:"workbench-manage-hint",children:((f=t.currentCompatibilityItem)==null?void 0:f.notes)??o("shell.workspaceDetailDebugFrameworkNoteEmpty")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugReasonsLabel")}),n.jsx("p",{className:"workbench-manage-hint",children:im(i.reasons,"shell.workspaceDetailDebugEmptyReasons")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugFilesLabel")}),n.jsx("p",{className:"workbench-manage-hint",children:im(i.detectedFiles,"shell.workspaceDetailDebugEmptyFiles")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugRuntimeServicesTitle")}),(v=t.runtime)!=null&&v.services.length?n.jsx("div",{className:"workbench-manage-type-list",children:t.runtime.services.map(g=>{var w,k,y,C;return n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsx("span",{className:"workbench-manage-type-meta",children:n.jsxs("span",{className:"workbench-manage-type-name",children:[g.service.name," · ",hu(sm(g.service,g.analysis))]})}),n.jsxs("span",{title:g.service.cwd,children:[mu(g.service.cwd,e.path)," · ",o("shell.workspaceDetailDebugRuntimeServicePortLabel")," ",wM(((w=g.binding)==null?void 0:w.leasedPort)??((k=g.portLease)==null?void 0:k.port)??null)," · ",o("shell.workspaceDetailDebugRuntimeServiceBindingLabel")," ",yM(((y=g.binding)==null?void 0:y.status)??null)," · ",o("shell.workspaceDetailDebugRuntimeServiceProcessLabel")," ",kM(((C=g.processInstance)==null?void 0:C.status)??null)]})]},g.service.id)})}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.workspaceDetailDebugRuntimeEmpty")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:o("shell.workspaceDetailDebugMatrixTitle")}),n.jsx("div",{className:"workbench-manage-type-list",children:c.map(g=>n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsx("span",{className:"workbench-manage-type-meta",children:n.jsx("span",{className:"workbench-manage-type-name",children:g.framework})}),n.jsxs("span",{children:[To(g.compatibilityLevel)," · ",uu(g.recommendedInjectionMode)]})]},g.framework))})]}),r?n.jsx("div",{className:"workbench-modal-actions",children:r}):null]}):null]})}function X9({workspace:e,state:t,actions:r,matrixLimit:s}){var w,k;const i=t.primaryAnalysis,l=((w=t.runtime)==null?void 0:w.runtimeSession)??null,c=s?t.matrixItems.slice(0,s):t.matrixItems,d=pw(t),m=mw(t),f=((k=t.analyses[0])==null?void 0:k.createdAt)??null,[v,g]=p.useState(!1);return n.jsxs("div",{className:"debug-readiness-page",children:[t.loading&&i===null?n.jsx("p",{className:"workbench-manage-status status-text",children:o("common.loading")}):null,t.error?n.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:t.error}):null,i?n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"debug-readiness-hero surface-card",children:[n.jsxs("div",{className:"debug-readiness-hero-header",children:[n.jsxs("div",{className:"debug-readiness-hero-copy",children:[n.jsx("span",{className:"debug-readiness-eyebrow",children:e.name??o("shell.workspaceDetailDebugPageHeroEyebrow")}),n.jsx("h2",{children:o("shell.workspaceDetailDebugPageTitle")}),n.jsx("p",{children:gw(d)})]}),r?n.jsx("div",{className:"debug-readiness-hero-actions",children:r}):null]}),n.jsxs("div",{className:"debug-readiness-summary-grid",children:[n.jsxs("article",{className:"debug-readiness-summary-card","data-tone":d.overallTone,children:[n.jsx("span",{children:o("shell.workspaceDetailDebugOverallStatusLabel")}),n.jsx("strong",{children:fw(d)}),n.jsx("small",{children:d.autoInjectionEligible?o("shell.workspaceDetailDebugAutoInjectionEligible"):o("shell.workspaceDetailDebugAutoInjectionBlocked")})]}),n.jsxs("article",{className:"debug-readiness-summary-card",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugSummaryServiceCountLabel")}),n.jsx("strong",{children:d.totalServices}),n.jsx("small",{children:o("shell.workspaceDetailDebugDetectedServicesTitle")})]}),n.jsxs("article",{className:"debug-readiness-summary-card",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugSummaryWebCountLabel")}),n.jsx("strong",{children:d.webServiceCount}),n.jsx("small",{children:Z9(d)})]}),n.jsxs("article",{className:"debug-readiness-summary-card",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugSummaryDesktopShellCountLabel")}),n.jsx("strong",{children:d.desktopShellCount}),n.jsx("small",{children:o("shell.workspaceDetailDebugDesktopShellSummaryHint")})]}),n.jsxs("article",{className:"debug-readiness-summary-card",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeStatusLabel")}),n.jsx("strong",{children:Xc((l==null?void 0:l.status)??null)}),n.jsx("small",{children:du((l==null?void 0:l.failureStage)??null)})]}),n.jsxs("article",{className:"debug-readiness-summary-card",children:[n.jsx("span",{children:o("shell.workspaceDetailDebugLastAnalyzedAtLabel")}),n.jsx("strong",{children:Xj(f)}),n.jsx("small",{children:eK(t.targetSourceType)})]})]}),n.jsx("div",{className:"debug-readiness-chip-row",children:d.categoryChips.map(y=>n.jsx("span",{className:"debug-readiness-chip","data-tone":y.tone,children:y.label},y.key))}),n.jsxs("div",{className:"debug-readiness-hero-meta",children:[n.jsx("span",{children:o("shell.manageWorkspacePathLabel")}),n.jsx("strong",{children:e.path})]})]}),n.jsxs("div",{className:"debug-readiness-layout",children:[n.jsxs("section",{className:"debug-readiness-section surface-card",children:[n.jsx("div",{className:"debug-readiness-section-header",children:n.jsxs("div",{children:[n.jsx("h3",{children:o("shell.workspaceDetailDebugDetectedServicesTitle")}),n.jsx("p",{children:o("shell.workspaceDetailDebugServiceSectionDescription")})]})}),n.jsx("div",{className:"debug-readiness-service-grid",children:m.map(y=>{var C,T,j;return n.jsxs("article",{className:"debug-readiness-service-card",children:[n.jsxs("div",{className:"debug-readiness-service-card-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:y.service.name}),n.jsx("p",{children:mu(y.service.cwd,e.path)})]}),n.jsx("span",{className:"debug-readiness-chip","data-tone":bM(y.category),children:hu(y.category)})]}),n.jsxs("div",{className:"debug-readiness-service-card-grid",children:[n.jsxs("div",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceFrameworkLabel")}),n.jsx("strong",{children:((C=y.analysis)==null?void 0:C.primaryFramework)??o("common.unknown")})]}),n.jsxs("div",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugCompatibilityLabel")}),n.jsx("strong",{children:To(((T=y.analysis)==null?void 0:T.compatibilityLevel)??"unknown")})]}),n.jsxs("div",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugInjectionLabel")}),n.jsx("strong",{children:uu(((j=y.analysis)==null?void 0:j.recommendedInjectionMode)??"none")})]}),n.jsxs("div",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugRuntimeStatusLabel")}),n.jsx("strong",{children:Xc(tK(y))})]})]}),n.jsxs("div",{className:"debug-readiness-service-card-list",children:[n.jsxs("p",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceCommandLabel")}),n.jsx("strong",{children:vw(y.service)})]}),n.jsxs("p",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceRequirementsLabel")}),n.jsx("strong",{children:nK(y.analysis)})]}),n.jsxs("p",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugServiceActionLabel")}),n.jsx("strong",{children:sK(y)})]}),n.jsxs("p",{children:[n.jsx("span",{children:o("shell.workspaceDetailDebugReasonsLabel")}),n.jsx("strong",{children:rK(y)})]})]})]},y.service.id)})})]}),n.jsxs("aside",{className:"debug-readiness-sidebar",children:[n.jsxs("section",{className:"debug-readiness-section surface-card",children:[n.jsx("div",{className:"debug-readiness-section-header",children:n.jsxs("div",{children:[n.jsx("h3",{children:o("shell.workspaceDetailDebugRuntimeHistoryTitle")}),n.jsx("p",{children:o("shell.workspaceDetailDebugRuntimeSectionDescription")})]})}),t.runtimeHistory.length>0?n.jsx("div",{className:"debug-readiness-runtime-list",children:t.runtimeHistory.map(y=>n.jsxs("article",{className:"debug-readiness-runtime-item",children:[n.jsxs("div",{className:"debug-readiness-runtime-item-header",children:[n.jsx("strong",{children:iK(y)}),n.jsx("span",{children:Xc(y.runtimeSession.status)})]}),n.jsx("p",{children:aK(y)}),n.jsxs("div",{className:"debug-readiness-runtime-item-grid",children:[n.jsxs("span",{children:[o("shell.workspaceDetailDebugRuntimeHistoryTimeLabel")," ",Xj(y.runtimeSession.startedAt??y.runtimeSession.createdAt)]}),n.jsxs("span",{children:[o("shell.workspaceDetailDebugRuntimeHistoryServiceLabel")," ",oK(y)]}),n.jsxs("span",{children:[o("shell.workspaceDetailDebugRuntimeServiceFailureLabel")," ",du(y.runtimeSession.failureStage??null)]}),n.jsxs("span",{children:[o("shell.workspaceDetailDebugRuntimeHistoryResultLabel")," ",lK(y)]})]})]},y.runtimeSession.id))}):n.jsx("p",{className:"workbench-section-empty",children:o("shell.workspaceDetailDebugRuntimeEmpty")})]}),n.jsx("section",{className:"debug-readiness-section surface-card",children:n.jsx(fM,{items:c,layout:"desktop",open:v,onOpen:()=>g(!0),onClose:()=>g(!1)})})]})]})]}):null]})}function fM({items:e,layout:t,open:r,onOpen:s,onClose:i}){const l=J9(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:t==="mobile"?void 0:"debug-readiness-section-body",children:[n.jsxs("div",{className:t==="mobile"?"mobile-feature-section-header":"debug-readiness-section-header",children:[n.jsxs("div",{children:[t==="mobile"?n.jsx("h2",{children:o("shell.workspaceDetailDebugMatrixTitle")}):null,t==="desktop"?n.jsx("h3",{children:o("shell.workspaceDetailDebugMatrixTitle")}):null,n.jsx("p",{children:o("shell.workspaceDetailDebugMatrixSectionDescription")})]}),n.jsx("span",{className:t==="mobile"?"mobile-feature-counter":"debug-readiness-matrix-counter",children:e.length})]}),n.jsxs("div",{className:`debug-readiness-matrix-entry${t==="mobile"?" debug-readiness-matrix-entry-mobile":""}`,children:[n.jsxs("div",{className:"debug-readiness-matrix-summary-row",children:[n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"success",children:[o("shell.workspaceDetailDebugCompatibilitySupported"),n.jsx("strong",{children:l.supportedCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"warn",children:[o("shell.workspaceDetailDebugCompatibilityConditional"),n.jsx("strong",{children:l.conditionalCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"danger",children:[o("shell.workspaceDetailDebugCompatibilityUnsupported"),n.jsx("strong",{children:l.unsupportedCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"neutral",children:[o("shell.workspaceDetailDebugCompatibilityUnknown"),n.jsx("strong",{children:l.unknownCount})]})]}),n.jsx("button",{type:"button",className:"secondary-button debug-readiness-matrix-open-button",onClick:s,children:o("shell.workspaceDetailDebugMatrixOpenAction")})]})]}),n.jsx(Ln,{open:r,title:o("shell.workspaceDetailDebugMatrixTitle"),description:o("shell.workspaceDetailDebugMatrixModalDescription"),className:`debug-readiness-matrix-modal-card${t==="mobile"?" debug-readiness-matrix-modal-card-mobile":""}`,onClose:i,children:n.jsxs("div",{className:"debug-readiness-matrix-modal",children:[n.jsxs("div",{className:"debug-readiness-matrix-summary-row debug-readiness-matrix-summary-row-modal",children:[n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"success",children:[o("shell.workspaceDetailDebugCompatibilitySupported"),n.jsx("strong",{children:l.supportedCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"warn",children:[o("shell.workspaceDetailDebugCompatibilityConditional"),n.jsx("strong",{children:l.conditionalCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"danger",children:[o("shell.workspaceDetailDebugCompatibilityUnsupported"),n.jsx("strong",{children:l.unsupportedCount})]}),n.jsxs("span",{className:"debug-readiness-matrix-summary-pill","data-tone":"neutral",children:[o("shell.workspaceDetailDebugCompatibilityUnknown"),n.jsx("strong",{children:l.unknownCount})]})]}),n.jsx("div",{className:"debug-readiness-matrix-table-wrap",children:n.jsxs("table",{className:"debug-readiness-matrix-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixFrameworkHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixCompatibilityHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixInjectionHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixDiscoveryHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixHmrHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixCallbackHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixAiHeader")}),n.jsx("th",{scope:"col",children:o("shell.workspaceDetailDebugMatrixNotesHeader")})]})}),n.jsx("tbody",{children:e.map(c=>{const d=vM(c.compatibilityLevel);return n.jsxs("tr",{children:[n.jsx("th",{scope:"row",className:"debug-readiness-matrix-framework-cell",children:c.framework}),n.jsx("td",{children:n.jsx(Tc,{className:"debug-readiness-matrix-badge",tone:d,icon:uK(c.compatibilityLevel),label:cK(c.compatibilityLevel),title:To(c.compatibilityLevel)})}),n.jsx("td",{children:n.jsx("span",{className:"debug-readiness-matrix-badge debug-readiness-matrix-badge-subtle","data-tone":"neutral",title:uu(c.recommendedInjectionMode),children:dK(c.recommendedInjectionMode)})}),n.jsx("td",{children:n.jsx(Tc,{className:"debug-readiness-matrix-flag",tone:c.requiresServiceDiscoveryHandling?"warn":"success",icon:c.requiresServiceDiscoveryHandling?"warn":"check",label:jg(c.requiresServiceDiscoveryHandling),title:Dl(c.requiresServiceDiscoveryHandling)})}),n.jsx("td",{children:n.jsx(Tc,{className:"debug-readiness-matrix-flag",tone:c.requiresHmrHandling?"warn":"success",icon:c.requiresHmrHandling?"warn":"check",label:jg(c.requiresHmrHandling),title:Dl(c.requiresHmrHandling)})}),n.jsx("td",{children:n.jsx(Tc,{className:"debug-readiness-matrix-flag",tone:c.requiresCallbackHandling?"warn":"success",icon:c.requiresCallbackHandling?"warn":"check",label:jg(c.requiresCallbackHandling),title:Dl(c.requiresCallbackHandling)})}),n.jsx("td",{children:n.jsx(Tc,{className:"debug-readiness-matrix-badge debug-readiness-matrix-badge-subtle",tone:mK(c.aiFallbackPolicy),icon:pK(c.aiFallbackPolicy),label:hK(c.aiFallbackPolicy),title:bw(c.aiFallbackPolicy)})}),n.jsx("td",{className:"debug-readiness-matrix-note-cell",children:c.notes})]},c.framework)})})]})}),n.jsxs("div",{className:"debug-readiness-matrix-legend",children:[n.jsx("p",{children:o("shell.workspaceDetailDebugMatrixLegendSummary")}),n.jsxs("div",{className:"debug-readiness-matrix-legend-grid",children:[n.jsxs("div",{children:[n.jsx("strong",{children:o("shell.workspaceDetailDebugMatrixDiscoveryHeader")}),n.jsx("span",{children:o("shell.workspaceDetailDebugMatrixDiscoveryNote")})]}),n.jsxs("div",{children:[n.jsx("strong",{children:o("shell.workspaceDetailDebugMatrixHmrHeader")}),n.jsx("span",{children:o("shell.workspaceDetailDebugMatrixHmrNote")})]}),n.jsxs("div",{children:[n.jsx("strong",{children:o("shell.workspaceDetailDebugMatrixCallbackHeader")}),n.jsx("span",{children:o("shell.workspaceDetailDebugMatrixCallbackNote")})]}),n.jsxs("div",{children:[n.jsx("strong",{children:o("shell.workspaceDetailDebugMatrixAiHeader")}),n.jsx("span",{children:o("shell.workspaceDetailDebugMatrixAiNote")})]})]})]})]})})]})}function Tc({tone:e,icon:t,label:r,title:s,className:i}){return n.jsxs("span",{className:i,"data-tone":e,title:s,children:[n.jsx(Q9,{kind:t}),n.jsx("span",{children:r})]})}function Q9({kind:e}){return e==="check"?n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.2 8.3L6.4 11.5L12.8 4.8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.9"})}):e==="cross"?n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M4.4 4.4L11.6 11.6M11.6 4.4L4.4 11.6",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.9"})}):e==="warn"?n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("path",{d:"M8 2.2L14 13.4H2L8 2.2Z",fill:"currentColor",opacity:"0.18"}),n.jsx("path",{d:"M8 5.3V8.8M8 11.3H8.01",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7"}),n.jsx("path",{d:"M8 2.2L14 13.4H2L8 2.2Z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"1.2"})]}):n.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),n.jsx("path",{d:"M8 5.1V8.4M8 11H8.01",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.7"})]})}function gM(e){switch(e){case"high":return o("shell.workspaceDetailDebugConfidenceHigh");case"medium":return o("shell.workspaceDetailDebugConfidenceMedium");case"low":return o("shell.workspaceDetailDebugConfidenceLow");default:return e}}function mw(e){return e.services.map(t=>{var i;const r=e.analyses.find(l=>l.serviceId===t.id)??null,s=((i=e.runtime)==null?void 0:i.services.find(l=>l.service.id===t.id))??null;return{service:t,analysis:r,runtimeItem:s,category:sm(t,r)}})}function pw(e){const t=mw(e),r=t.filter(y=>y.category!=="desktop_shell"),s=r.map(y=>y.analysis).filter(y=>y!==null),i=s.length>0?s:e.analyses,l=i.filter(y=>y.compatibilityLevel==="supported").length,c=i.filter(y=>y.compatibilityLevel==="conditional").length,d=i.filter(y=>y.compatibilityLevel==="unsupported").length,m=i.filter(y=>y.compatibilityLevel==="unknown").length,f=t.filter(y=>y.category==="desktop_shell").length,v=t.length,g=r.length,w=d>0?"danger":c>0?"warn":l>0?"success":"neutral",k=[g>0?{key:"web",label:o("shell.workspaceDetailDebugSummaryWebServicesChip",{count:g}),tone:g===l&&c===0?"success":"warn"}:null,f>0?{key:"desktop-shell",label:o("shell.workspaceDetailDebugSummaryDesktopShellChip",{count:f}),tone:"neutral"}:null,d>0?{key:"unsupported",label:o("shell.workspaceDetailDebugSummaryUnsupportedChip",{count:d}),tone:"danger"}:null].filter(y=>y!==null);return{totalServices:v,webServiceCount:g,desktopShellCount:f,supportedCount:l,conditionalCount:c,unsupportedCount:d,unknownCount:m,autoInjectionEligible:e.autoInjectionEligible,overallTone:w,categoryChips:k}}function J9(e){return{supportedCount:e.filter(t=>t.compatibilityLevel==="supported").length,conditionalCount:e.filter(t=>t.compatibilityLevel==="conditional").length,unsupportedCount:e.filter(t=>t.compatibilityLevel==="unsupported").length,unknownCount:e.filter(t=>t.compatibilityLevel==="unknown").length}}function sm(e,t){if((t==null?void 0:t.primaryFramework)==="tauri"||(t==null?void 0:t.primaryFramework)==="electron")return"desktop_shell";switch(e.role){case"frontend":return"frontend";case"backend":return"backend";case"worker":return"worker";case"mock":return"mock";default:return"custom"}}function bM(e){switch(e){case"frontend":return"success";case"backend":return"warn";case"desktop_shell":return"neutral";case"worker":case"mock":case"custom":default:return"neutral"}}function fw(e){return e.unsupportedCount>0?o("shell.workspaceDetailDebugOverallStatusBlocked"):e.conditionalCount>0?o("shell.workspaceDetailDebugOverallStatusConditional"):e.supportedCount>0?o("shell.workspaceDetailDebugOverallStatusSupported"):o("shell.workspaceDetailDebugCompatibilityUnknown")}function gw(e){return e.totalServices===0?o("shell.workspaceDetailDebugOverallSummaryEmpty"):e.desktopShellCount>0&&e.webServiceCount>0?o("shell.workspaceDetailDebugOverallSummaryMixed",{webCount:e.webServiceCount,desktopCount:e.desktopShellCount}):e.desktopShellCount>0&&e.webServiceCount===0?o("shell.workspaceDetailDebugOverallSummaryDesktopOnly",{count:e.desktopShellCount}):o("shell.workspaceDetailDebugOverallSummaryWebOnly",{count:e.webServiceCount})}function Z9(e){return o("shell.workspaceDetailDebugCompatibilityBreakdown",{supported:e.supportedCount,conditional:e.conditionalCount,unsupported:e.unsupportedCount})}function eK(e){switch(e){case"repo":return o("shell.workspaceDetailDebugTargetSourceRepo");case"worktree":return o("shell.workspaceDetailDebugTargetSourceWorktree");default:return o("common.unknown")}}function tK(e){var t,r,s,i,l;return((r=(t=e.runtimeItem)==null?void 0:t.processInstance)==null?void 0:r.status)==="running"?"RUNNING":((i=(s=e.runtimeItem)==null?void 0:s.processInstance)==null?void 0:i.status)==="error"?"FAILED":e.runtimeItem&&((l=e.runtimeItem.binding)==null?void 0:l.status)==="RELEASED"?"STOPPED":null}function nK(e){if(!e)return o("shell.workspaceDetailDebugEmptyReasons");const t=[e.requiresServiceDiscoveryHandling?o("shell.workspaceDetailDebugFailureStageServiceDiscovery"):null,e.requiresHmrHandling?o("shell.workspaceDetailDebugFailureStageHmr"):null,e.requiresCallbackHandling?o("shell.workspaceDetailDebugFailureStageCallback"):null].filter(r=>r!==null);return t.length>0?t.join(" / "):o("shell.workspaceDetailDebugRequirementsNone")}function rK(e){var t;if(e.category==="desktop_shell")return o("shell.workspaceDetailDebugServiceOverviewDesktopShell");switch((t=e.analysis)==null?void 0:t.compatibilityLevel){case"supported":return o("shell.workspaceDetailDebugServiceOverviewSupported");case"conditional":return o("shell.workspaceDetailDebugServiceOverviewConditional");case"unsupported":return o("shell.workspaceDetailDebugServiceOverviewUnsupported");default:return o("shell.workspaceDetailDebugServiceOverviewUnknown")}}function sK(e){var t;if(e.category==="desktop_shell")return o("shell.workspaceDetailDebugServiceActionDesktopShell");switch((t=e.analysis)==null?void 0:t.compatibilityLevel){case"supported":return o("shell.workspaceDetailDebugServiceActionSupported");case"conditional":return o("shell.workspaceDetailDebugServiceActionConditional");case"unsupported":return o("shell.workspaceDetailDebugServiceActionUnsupported");default:return o("shell.workspaceDetailDebugServiceActionUnknown")}}function iK(e){return o("shell.workspaceDetailDebugRuntimeHistoryTitleWithIndex",{id:e.runtimeSession.id.slice(0,8)})}function aK(e){const t=e.services.filter(r=>{var s,i;return((s=r.processInstance)==null?void 0:s.status)==="error"||((i=r.binding)==null?void 0:i.status)==="FAILED"}).map(r=>r.service.name);return t.length>0?o("shell.workspaceDetailDebugRuntimeHistoryFailedSummary",{services:t.join("、")}):o("shell.workspaceDetailDebugRuntimeHistoryGenericSummary")}function oK(e){return e.services.length===0?o("shell.workspaceDetailDebugRuntimeHistoryNoServices"):e.services.map(t=>t.service.name).join("、")}function lK(e){const t=e.services.some(r=>{var s;return((s=r.processInstance)==null?void 0:s.status)==="running"});return e.runtimeSession.status==="RUNNING"||t?o("shell.workspaceDetailDebugRuntimeHistoryResultRunning"):e.runtimeSession.status==="FAILED"?o("shell.workspaceDetailDebugRuntimeHistoryResultFailed"):e.runtimeSession.status==="STOPPED"?o("shell.workspaceDetailDebugRuntimeHistoryResultStopped"):o("shell.workspaceDetailDebugRuntimeHistoryResultPreparing")}function Xj(e){if(!e)return o("shell.workspaceDetailDebugFailureStageEmpty");const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function To(e){switch(e){case"supported":return o("shell.workspaceDetailDebugCompatibilitySupported");case"conditional":return o("shell.workspaceDetailDebugCompatibilityConditional");case"unsupported":return o("shell.workspaceDetailDebugCompatibilityUnsupported");default:return o("shell.workspaceDetailDebugCompatibilityUnknown")}}function cK(e){switch(e){case"supported":return o("shell.workspaceDetailDebugMatrixCompatibilitySupportedShort");case"conditional":return o("shell.workspaceDetailDebugMatrixCompatibilityConditionalShort");case"unsupported":return o("shell.workspaceDetailDebugMatrixCompatibilityUnsupportedShort");default:return o("shell.workspaceDetailDebugMatrixCompatibilityUnknownShort")}}function uK(e){switch(e){case"supported":return"check";case"conditional":return"warn";case"unsupported":return"cross";default:return"neutral"}}function vM(e){switch(e){case"supported":return"success";case"conditional":return"warn";case"unsupported":return"danger";default:return"neutral"}}function uu(e){switch(e){case"cli":return o("shell.workspaceDetailDebugInjectionCli");case"env":return o("shell.workspaceDetailDebugInjectionEnv");case"override":return o("shell.workspaceDetailDebugInjectionOverride");case"ai_fallback":return o("shell.workspaceDetailDebugInjectionAiFallback");default:return o("shell.workspaceDetailDebugInjectionNone")}}function dK(e){switch(e){case"cli":return o("shell.workspaceDetailDebugMatrixInjectionCliShort");case"env":return o("shell.workspaceDetailDebugMatrixInjectionEnvShort");case"override":return o("shell.workspaceDetailDebugMatrixInjectionOverrideShort");case"ai_fallback":return o("shell.workspaceDetailDebugMatrixInjectionAiFallbackShort");default:return o("shell.workspaceDetailDebugMatrixInjectionNoneShort")}}function Xc(e){switch(e){case"PREPARING":return o("shell.workspaceDetailDebugRuntimePreparing");case"RUNNING":return o("shell.workspaceDetailDebugRuntimeRunning");case"FAILED":return o("shell.workspaceDetailDebugRuntimeFailed");case"STOPPED":return o("shell.workspaceDetailDebugRuntimeStopped");default:return o("shell.workspaceDetailDebugRuntimeNotStarted")}}function du(e){switch(e){case null:case"":return o("shell.workspaceDetailDebugFailureStageEmpty");case"service_discovery":return o("shell.workspaceDetailDebugFailureStageServiceDiscovery");case"hmr":return o("shell.workspaceDetailDebugFailureStageHmr");case"callback":return o("shell.workspaceDetailDebugFailureStageCallback");case"ai_fallback_required":return o("shell.workspaceDetailDebugFailureStageAiFallbackRequired");case"adapter_selection":return o("shell.workspaceDetailDebugFailureStageAdapterSelection");case"launch_requirements":return o("shell.workspaceDetailDebugFailureStageLaunchRequirements");case"command_execution":return o("shell.workspaceDetailDebugFailureStageCommandExecution");case"process_exit":return o("shell.workspaceDetailDebugFailureStageProcessExit");case"process_runtime_error":return o("shell.workspaceDetailDebugFailureStageProcessRuntimeError");case"stale_runtime_binding":return o("shell.workspaceDetailDebugFailureStageStaleRuntimeBinding");default:return o("shell.workspaceDetailDebugFailureStageUnknown",{code:e})}}function Dl(e){return o(e?"shell.workspaceDetailDebugRequirementRequired":"shell.workspaceDetailDebugRequirementNotRequired")}function jg(e){return o(e?"shell.workspaceDetailDebugMatrixRequirementRequiredShort":"shell.workspaceDetailDebugMatrixRequirementNotRequiredShort")}function bw(e){switch(e){case"never":return o("shell.workspaceDetailDebugAiPolicyNever");case"conditional":return o("shell.workspaceDetailDebugAiPolicyConditional");default:return o("shell.workspaceDetailDebugAiPolicyAllowed")}}function hK(e){switch(e){case"never":return o("shell.workspaceDetailDebugMatrixAiNeverShort");case"conditional":return o("shell.workspaceDetailDebugMatrixAiConditionalShort");default:return o("shell.workspaceDetailDebugMatrixAiAllowedShort")}}function mK(e){switch(e){case"never":return"danger";case"conditional":return"warn";default:return"success"}}function pK(e){switch(e){case"never":return"cross";case"conditional":return"warn";default:return"check"}}function im(e,t){return e.length>0?e.join(", "):o(t)}function hu(e){switch(e){case"frontend":return o("shell.workspaceDetailDebugRoleFrontend");case"backend":return o("shell.workspaceDetailDebugRoleBackend");case"worker":return o("shell.workspaceDetailDebugRoleWorker");case"mock":return o("shell.workspaceDetailDebugRoleMock");case"desktop_shell":return o("shell.workspaceDetailDebugRoleDesktopShell");default:return o("shell.workspaceDetailDebugRoleCustom")}}function wM(e){return e===null?o("shell.workspaceDetailDebugPortEmpty"):String(e)}function yM(e){switch(e){case"ALLOCATED":return o("shell.workspaceDetailDebugBindingAllocated");case"LISTENING":return o("shell.workspaceDetailDebugBindingListening");case"FAILED":return o("shell.workspaceDetailDebugBindingFailed");case"RELEASED":return o("shell.workspaceDetailDebugBindingReleased");default:return o("shell.workspaceDetailDebugBindingUnknown")}}function kM(e){switch(e){case"creating":return o("shell.workspaceDetailDebugProcessCreating");case"running":return o("shell.workspaceDetailDebugProcessRunning");case"closed":return o("shell.workspaceDetailDebugProcessClosed");case"error":return o("shell.workspaceDetailDebugProcessError");default:return o("shell.workspaceDetailDebugProcessUnknown")}}function fK(e){return e.length===0?o("shell.workspaceDetailDebugAiEditEmpty"):e.map(t=>gK(t)).join(", ")}function gK(e){switch(e){case"PENDING":return o("shell.workspaceDetailDebugAiEditPending");case"APPLIED":return o("shell.workspaceDetailDebugAiEditApplied");case"ROLLED_BACK":return o("shell.workspaceDetailDebugAiEditRolledBack");case"REJECTED":return o("shell.workspaceDetailDebugAiEditRejected");default:return e}}function mu(e,t){const r=Qj(t),s=Qj(e);return s===r?".":s.startsWith(`${r}/`)?s.slice(r.length+1):s}function vw(e){return[e.command,...e.args].filter(Boolean).join(" ")}function Qj(e){return e.replace(/\\/g,"/").replace(/\/+$/g,"")}function xM(e){const[t,r]=p.useState({loading:!1,error:null,targetId:null,targetSourceType:null,autoInjectionEligible:!1,services:[],analyses:[],runtime:null,runtimeHistory:[],matrixItems:[]});p.useEffect(()=>{if(!(e!=null&&e.id)||!e.path){r({loading:!1,error:null,targetId:null,targetSourceType:null,autoInjectionEligible:!1,services:[],analyses:[],runtime:null,runtimeHistory:[],matrixItems:[]});return}let l=!1;return r(c=>({...c,loading:!0,error:null})),(async()=>{try{const c=await WF({workspaceId:e.id,rootPath:e.path}),[d,m]=await Promise.all([UF(c.target.id,5),HF()]),f=bK(d);if(l)return;r({loading:!1,error:null,targetId:c.target.id,targetSourceType:c.target.sourceType,autoInjectionEligible:c.autoInjectionEligible,services:c.services,analyses:c.analyses,runtime:f,runtimeHistory:d.items,matrixItems:m.items})}catch(c){if(l)return;r({loading:!1,error:c instanceof Error?c.message:o("shell.workspaceDetailDebugAnalyzeFailed"),targetId:null,targetSourceType:null,autoInjectionEligible:!1,services:[],analyses:[],runtime:null,runtimeHistory:[],matrixItems:[]})}})(),()=>{l=!0}},[e==null?void 0:e.id,e==null?void 0:e.path]);const s=p.useMemo(()=>vK(t.services,t.analyses),[t.analyses,t.services]),i=p.useMemo(()=>t.matrixItems.find(l=>l.framework===((s==null?void 0:s.primaryFramework)??"unknown"))??null,[s==null?void 0:s.primaryFramework,t.matrixItems]);return{...t,primaryAnalysis:s,currentCompatibilityItem:i}}function bK(e){return e.items[0]??null}function vK(e,t){if(t.length===0)return null;const r=new Map(t.filter(i=>i.serviceId).map(i=>[i.serviceId,i]));return[...e].sort((i,l)=>wK(i,l)).map(i=>r.get(i.id)??null).find(i=>i!==null)??t[0]??null}function wK(e,t){const r=Jj(e.role)-Jj(t.role);return r!==0?r:e.name.localeCompare(t.name)}function Jj(e){switch(e){case"frontend":return 0;case"backend":return 1;case"worker":return 2;case"mock":return 3;default:return 4}}function yK(e){return e.isArchived!==!0&&!qi(e)}function kK(e){return e.isArchived===!0&&!qi(e)}const Tg=60*1e3,Ng=10;function xK(){var q;const{workspaceId:e=""}=Eo(),t=vr(),{showToast:r}=Qn(),{navigationGroups:s,currentWorkspaceId:i,favoriteSessionIds:l,workspaceManagementStateById:c,selectWorkspace:d,subscribeGitSnapshot:m,requestGitRefresh:f,subscribeWorkspaceManagementSnapshot:v,requestWorkspaceManagementRefresh:g,toggleFavoriteSession:w,archiveSession:k,unarchiveSession:y,startDraftSession:C}=Pr(),[T,j]=p.useState(!1),[N,D]=p.useState(!1),[F,W]=p.useState(Ng),E=Ul(s),I=ua(s,e),M=(I==null?void 0:I.workspace)??null,_=E.find(P=>P.workspace.id===(M==null?void 0:M.id))??(M?{workspace:M,label:M.name,subtitle:M.path}:null),L=p.useMemo(()=>[...(I==null?void 0:I.sessions)??[]].filter(yK),[I]),Q=p.useMemo(()=>[...(I==null?void 0:I.sessions)??[]].filter(kK),[I]);p.useEffect(()=>{e&&d(e)},[d,e]),p.useEffect(()=>{if(!e)return;m(e),v(e);const P=Er(jK(e),Tg)!==null,U=Er(Zj(e),Tg)!==null;P||f(e),U||g(e)},[f,g,m,v,e]),p.useEffect(()=>{W(Ng)},[e]);const O=p.useMemo(()=>{if(!e)return{loading:!1,error:null,hasMeaningfulSummary:!1,summary:null};const P=Er(Zj(e),Tg),U=c[e]??null,X=(U==null?void 0:U.detail)??(M?TK(M,P):P??null);return{loading:(U==null?void 0:U.loading)??!1,error:(U==null?void 0:U.error)??null,hasMeaningfulSummary:NK(X),summary:X}},[M,e,c]),ne=p.useMemo(()=>O.summary?TP(O.summary.codeComposition.items,o("shell.manageWorkspaceCodeCompositionOther")):[],[O.summary]),Y=p.useMemo(()=>ne.length>0?NP(ne):void 0,[ne]),G=p.useMemo(()=>Q.slice(0,F),[Q,F]),te=xM(M?{id:M.id,path:M.path,name:M.name}:null);async function K(){if(!(!M||!(typeof window>"u"||window.confirm(o("shell.manageWorkspaceRemoveConfirmTarget",{name:M.name}))))){j(!0);try{await sP(M.id),r({title:o("shell.manageWorkspaceRemoveSuccess"),tone:"success"}),t("/workspaces",{replace:!0})}catch(U){r({title:U instanceof Error?U.message:o("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{j(!1)}}}function z(P,U){D(!1),C(P,U)}return M?n.jsxs("main",{className:"mobile-feature-page mobile-page-scroll-root mobile-page-with-top-header mobile-workspace-detail-page",children:[n.jsx(Hl,{currentWorkspace:_?{id:_.workspace.id,name:_.label,path:_.subtitle}:null,workspaces:s.map(P=>P.workspace),workspaceOptions:E,heading:o("shell.workspaceDetailTitle"),triggerLabel:(_==null?void 0:_.label)??M.name,onSelectWorkspace:P=>{d(P),t(Ms(P))},content:n.jsxs("div",{className:"mobile-workspace-detail-header-actions",children:[n.jsx("button",{type:"button",className:"primary-button",onClick:()=>D(!0),children:o("shell.createSession")}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{d(M.id),t(LN(M.id))},children:o("shell.filesEntry")}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{d(M.id),t(xo(M.id))},children:o("shell.terminalsEntry")})]})}),n.jsxs("div",{className:"mobile-page-top-body mobile-workspace-detail-body",children:[n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-workspace-detail-summary-panel",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.workspaceDetailSummaryTitle")})}),i!==M.id?n.jsx("button",{type:"button",className:"secondary-button mobile-workspace-detail-switch-button",onClick:()=>d(M.id),children:o("shell.switchWorkspace")}):null]}),O.loading&&O.summary===null?n.jsx("p",{children:o("common.loading")}):null,O.error?n.jsx("p",{className:"status-text","data-tone":"error",children:O.error}):null,O.summary?n.jsxs("div",{className:"mobile-detail-grid mobile-workspace-detail-grid",children:[n.jsxs("div",{className:"mobile-detail-metric mobile-detail-metric-wide",children:[n.jsx("span",{children:o("shell.manageWorkspacePathLabel")}),n.jsx("strong",{title:O.summary.path,children:O.summary.path})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.manageWorkspaceCurrentBranch")}),n.jsx("strong",{title:O.summary.git.currentBranch??o("common.unknown"),children:O.summary.git.currentBranch??o("common.unknown")})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.manageWorkspaceGitCommitCount")}),n.jsx("strong",{children:O.hasMeaningfulSummary?O.summary.git.commitCount??0:"—"})]}),n.jsxs("div",{className:"mobile-detail-metric",children:[n.jsx("span",{children:o("shell.manageWorkspaceCodeCompositionFiles")}),n.jsx("strong",{children:O.hasMeaningfulSummary?O.summary.codeComposition.scannedFileCount:"—"})]})]}):null,n.jsxs("div",{className:"mobile-feature-inline-actions mobile-workspace-detail-summary-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{d(M.id),t(FN(M.id))},children:o("shell.gitEntry")}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{d(M.id),t(Xb(M.id))},children:o("shell.terminalManagerEntry")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:T,onClick:()=>{K()},children:o(T?"shell.manageWorkspaceRemoving":"shell.manageWorkspaceRemoveAction")})]})]}),n.jsx(pM,{workspace:M?{id:M.id,path:M.path,name:M.name}:null,state:te,variant:"mobile"}),n.jsxs("section",{className:"mobile-feature-panel surface-card mobile-workspace-composition-panel",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.manageWorkspaceCodeCompositionLabel")})}),O.summary?n.jsx("span",{className:"mobile-feature-counter",children:O.summary.codeComposition.scannedFileCount}):null]}),O.loading&&O.summary===null?n.jsx("p",{children:o("common.loading")}):null,O.summary?ne.length>0?n.jsxs("div",{className:"workbench-manage-type-chart",children:[n.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Y,"aria-hidden":"true",children:[n.jsx("strong",{className:"workbench-manage-type-chart-total",children:O.summary.codeComposition.scannedFileCount}),n.jsx("span",{className:"workbench-manage-type-chart-caption",children:o("shell.manageWorkspaceCodeCompositionFiles")})]}),n.jsx("div",{className:"workbench-manage-type-list",children:ne.map(P=>n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsxs("span",{className:"workbench-manage-type-meta",children:[n.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:P.color},"aria-hidden":"true"}),n.jsx("span",{className:"workbench-manage-type-name",children:P.type})]}),n.jsxs("span",{children:[P.count," · ",jP(P)]})]},P.key))})]}):n.jsx("p",{children:O.summary.codeComposition.error??o("shell.manageWorkspaceNoCodeComposition")}):null,(q=O.summary)!=null&&q.codeComposition.truncated?n.jsx("p",{className:"mobile-workspace-composition-note",children:o("shell.manageWorkspaceCodeTruncated",{count:O.summary.codeComposition.scannedFileCount})}):null]}),n.jsxs("section",{className:"mobile-feature-section",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.recentSessionsSectionTitle")})}),n.jsx("span",{className:"mobile-feature-counter",children:L.length})]}),n.jsx("div",{className:"mobile-feature-stack",children:L.length===0?n.jsx("article",{className:"mobile-feature-empty surface-card",children:n.jsx("p",{children:o("shell.emptyWorkspaceSessions")})}):L.map(P=>{const U=$i(P.title,o("common.unknown")),X=l.includes(P.sessionId);return n.jsxs("article",{className:"mobile-session-row surface-card",children:[n.jsxs("button",{type:"button",className:"mobile-session-row-primary",onClick:()=>t(Yn(M.id,P.sessionId)),children:[n.jsx("span",{className:"mobile-session-row-title",title:U.fullTitle,children:U.displayTitle}),n.jsx("span",{className:"mobile-session-row-provider",children:qs(P.provider)})]}),n.jsxs("div",{className:"mobile-session-row-actions",children:[n.jsx("span",{className:"mobile-feature-badge mobile-session-row-count",children:P.messageCount}),n.jsx("button",{type:"button",className:"mobile-session-row-action","aria-label":o(X?"shell.unfavoriteAction":"shell.favoriteAction"),title:o(X?"shell.unfavoriteAction":"shell.favoriteAction"),onClick:()=>{w(P.sessionId)},children:n.jsx(SK,{active:X})}),n.jsx("button",{type:"button",className:"mobile-session-row-action","aria-label":o("shell.archiveAction"),title:o("shell.archiveAction"),onClick:()=>{k(P.sessionId)},children:n.jsx(CK,{})})]})]},P.sessionId)})})]}),Q.length>0?n.jsxs("section",{className:"mobile-feature-section",children:[n.jsxs("div",{className:"mobile-feature-section-header",children:[n.jsx("div",{children:n.jsx("h2",{children:o("shell.archiveModalTitle")})}),n.jsx("span",{className:"mobile-feature-counter",children:Q.length})]}),n.jsx("div",{className:"mobile-feature-stack",children:G.map(P=>n.jsxs("article",{className:"mobile-session-row surface-card",children:[n.jsxs("div",{className:"mobile-session-row-primary mobile-session-row-primary-static",children:[n.jsx("span",{className:"mobile-session-row-title",title:P.title,children:P.title}),n.jsx("span",{className:"mobile-session-row-provider",children:qs(P.provider)})]}),n.jsx("div",{className:"mobile-session-row-actions",children:n.jsx("button",{type:"button",className:"secondary-button mobile-session-row-restore",onClick:()=>{y(P.sessionId)},children:o("shell.unarchiveAction")})})]},P.sessionId))}),G.length<Q.length?n.jsx("button",{type:"button",className:"secondary-button mobile-workspace-detail-expand-button",onClick:()=>{W(P=>P+Ng)},children:o("shell.archiveExpandMore")}):null]}):null]}),n.jsx(hw,{open:N,workspaces:s.map(P=>P.workspace),workspaceOptions:E,initialWorkspaceId:i??M.id,onClose:()=>D(!1),onSelect:z})]}):n.jsx("main",{className:"mobile-feature-page mobile-page-scroll-root",children:n.jsxs("article",{className:"mobile-feature-empty surface-card",children:[n.jsx("h1",{children:o("shell.workspaceDetailMissingTitle")}),n.jsx("p",{children:o("shell.workspaceDetailMissingBody")}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t("/workspaces"),children:o("shell.mobileWorkspacesEntry")})]})})}function SK({active:e}){return n.jsx("svg",{viewBox:"0 0 24 24",fill:e?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.8",children:n.jsx("path",{d:"m12 3.6 2.6 5.2 5.7.8-4.1 4 1 5.7L12 16.5 6.8 19.3l1-5.7-4.1-4 5.7-.8Z"})})}function CK(){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M4 7.5h16"}),n.jsx("path",{d:"M6.4 7.5h11.2l-.9 10.2a2 2 0 0 1-2 1.8H9.3a2 2 0 0 1-2-1.8Z"}),n.jsx("path",{d:"M8 4.5h8a1.5 1.5 0 0 1 1.5 1.5v1.5h-11V6A1.5 1.5 0 0 1 8 4.5Z"}),n.jsx("path",{d:"M10 11.5h4"})]})}function Zj(e){return`workspace-management.summary.${e}`}function jK(e){return`git-sidebar.snapshot.${e}`}function TK(e,t){const r=(t==null?void 0:t.git.repoRoot)??e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:(t==null?void 0:t.git.isRepository)??!!r,repoRoot:r,currentBranch:(t==null?void 0:t.git.currentBranch)??null,commitCount:(t==null?void 0:t.git.commitCount)??null,remotes:(t==null?void 0:t.git.remotes)??[],error:(t==null?void 0:t.git.error)??null},codeComposition:(t==null?void 0:t.codeComposition)??{scannedFileCount:0,truncated:!1,items:[],error:null}}}function NK(e){return e?e.git.isRepository||e.git.repoRoot!==null||e.git.currentBranch!==null||e.git.commitCount!==null||e.git.remotes.length>0||e.codeComposition.scannedFileCount>0||e.codeComposition.items.length>0||e.codeComposition.error!==null:!1}function PK(){var d;const{workspaceId:e=""}=Eo(),t=vr(),{navigationGroups:r,selectWorkspace:s}=Pr(),i=((d=r.find(m=>m.workspace.id===e))==null?void 0:d.workspace)??null;p.useEffect(()=>{e&&s(e)},[s,e]);const l=p.useMemo(()=>i?{id:i.id,path:i.path,name:i.name}:null,[i]),c=xM(l);return i?n.jsx("main",{className:"workbench-page conversation-page-shell debug-readiness-page-shell",children:n.jsx(pM,{workspace:l,state:c,variant:"desktop-page",actions:n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>t(Ms(i.id)),children:o("shell.goBack")})})}):n.jsx("main",{className:"workbench-page conversation-page-shell debug-readiness-page-shell",children:n.jsxs("div",{className:"workbench-empty-guide surface-card",children:[n.jsx("h1",{children:o("shell.workspaceDetailMissingTitle")}),n.jsx("p",{children:o("shell.workspaceDetailMissingBody")})]})})}function DK({isDesktop:e,viewportClass:t}){return e||t==="expanded"?"desktop":"mobile"}function RK(){const e=nr(),t=DK(e);return n.jsx(nB,{shellMode:t})}const MK=[{titleKey:"workbench.emptyResumeTitle",bodyKey:"workbench.emptyResumeBody"},{titleKey:"workbench.emptyNewTitle",bodyKey:"workbench.emptyNewBody"},{titleKey:"workbench.emptyCompanionTitle",bodyKey:"workbench.emptyCompanionBody"}];function AK(){return n.jsx("main",{className:"workbench-page conversation-page-shell",children:n.jsx("section",{className:"workbench-center-placeholder",children:n.jsxs("div",{className:"workbench-empty-guide surface-card",children:[n.jsx("p",{className:"workbench-empty-eyebrow",children:o("workbench.emptyEyebrow")}),n.jsx("div",{className:"workbench-empty-main",children:n.jsxs("div",{className:"workbench-empty-copy",children:[n.jsx("h1",{children:o("workbench.emptyTitle")}),n.jsx("p",{className:"workbench-empty-body",children:o("workbench.emptyBody")})]})}),n.jsx("ol",{className:"workbench-empty-steps",children:MK.map((e,t)=>n.jsxs("li",{className:"workbench-empty-step",children:[n.jsx("span",{className:"workbench-empty-step-index",children:t+1}),n.jsxs("div",{className:"workbench-empty-step-copy",children:[n.jsx("h2",{children:o(e.titleKey)}),n.jsx("p",{children:o(e.bodyKey)})]})]},e.titleKey))}),n.jsx("p",{className:"workbench-empty-tip",children:o("workbench.emptyTip")})]})})})}function IK(){const{shellMode:e}=Pr();return e==="mobile"?n.jsx($a,{to:"/workspaces",replace:!0}):n.jsx(AK,{})}const eT=2e4,EK=1e3,LK=5e3;function FK({isOpen:e,onClose:t}){const[r,s]=p.useState(null),[i,l]=p.useState(null),[c,d]=p.useState(!1),[m,f]=p.useState(!1),[v,g]=p.useState(null),w=p.useRef(null);if(p.useEffect(()=>{if(!e)return;let T=!1;async function j(){d(!0),g(null),l(null);try{const N=await _e.request("/api/observability/runtime/session",{method:"POST",body:JSON.stringify({ttlMs:eT})});if(T){await Pg(N.sessionId);return}w.current=N.sessionId,s(N);const D=await tT(N.sessionId);if(T){await Pg(N.sessionId);return}l(D)}catch(N){T||g(Dg(N))}finally{T||d(!1)}}return j(),()=>{T=!0;const N=w.current;w.current=null,s(null),l(null),d(!1),f(!1),g(null),N&&Pg(N)}},[e]),p.useEffect(()=>{const T=(r==null?void 0:r.sessionId)??null;if(!e||!T)return;const j=T;let N=!1;async function D(){f(!0);try{const W=await tT(j);N||(l(W),g(null))}catch(W){N||g(Dg(W))}finally{N||f(!1)}}const F=window.setInterval(()=>{D()},EK);return()=>{N=!0,window.clearInterval(F)}},[e,r==null?void 0:r.sessionId]),p.useEffect(()=>{const T=(r==null?void 0:r.sessionId)??null;if(!e||!T)return;const j=T;let N=!1;async function D(){try{const W=await _e.request(`/api/observability/runtime/session/${j}/heartbeat`,{method:"POST",body:JSON.stringify({ttlMs:eT})});N||s(W)}catch(W){N||g(Dg(W))}}const F=window.setInterval(()=>{D()},LK);return()=>{N=!0,window.clearInterval(F)}},[e,r==null?void 0:r.sessionId]),!e)return null;const k=Object.entries((i==null?void 0:i.backgroundTasks.taskTypes)??{}),y=Object.entries((i==null?void 0:i.schedulers.schedulers)??{}),C=Object.entries((i==null?void 0:i.backgroundTasks.totals)??{});return n.jsxs("div",{className:"workbench-modal-layer","aria-hidden":!e,children:[n.jsx("div",{className:"workbench-modal-backdrop",onClick:t,"aria-hidden":"true"}),n.jsxs("div",{className:"workbench-modal-card surface-card parallel-task-debug-modal-card",role:"dialog","aria-modal":"true","aria-labelledby":"parallel-task-debug-title",children:[n.jsxs("div",{className:"workbench-modal-header",children:[n.jsxs("div",{className:"workbench-modal-title-wrap",children:[n.jsx("h2",{id:"parallel-task-debug-title",children:o("settings.parallelTaskDebugModalTitle")}),n.jsx("p",{children:o("settings.parallelTaskDebugModalDescription")})]}),n.jsxs("div",{className:"workbench-modal-header-actions",children:[n.jsx("span",{className:"parallel-task-debug-status-chip","data-tone":v?"error":"active",children:o(v?"settings.parallelTaskDebugStatusError":"settings.parallelTaskDebugStatusActive")}),n.jsx(Lo,{onClick:t,"aria-label":o("settings.parallelTaskDebugClose")})]})]}),n.jsxs("div",{className:"workbench-modal-body parallel-task-debug-body",children:[n.jsxs("div",{className:"parallel-task-debug-meta-grid",children:[n.jsxs("div",{className:"parallel-task-debug-meta-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugObservedAt")}),n.jsx("strong",{children:Rg(i==null?void 0:i.observedAt)})]}),n.jsxs("div",{className:"parallel-task-debug-meta-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugSessionExpireAt")}),n.jsx("strong",{children:Rg(r==null?void 0:r.expiresAt)})]}),n.jsxs("div",{className:"parallel-task-debug-meta-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugSessionTtl")}),n.jsx("strong",{children:_K((r==null?void 0:r.ttlMs)??null)})]}),n.jsxs("div",{className:"parallel-task-debug-meta-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugCollectorState")}),n.jsx("strong",{children:i!=null&&i.eventLoop.enabled?o("settings.parallelTaskDebugCollectorEnabled"):o("settings.parallelTaskDebugCollectorDisabled")})]})]}),c?n.jsx("div",{className:"parallel-task-debug-empty",children:o("settings.parallelTaskDebugLoading")}):null,!c&&v?n.jsx("div",{className:"parallel-task-debug-error",children:v}):null,!c&&!v&&i?n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"parallel-task-debug-section",children:[n.jsxs("div",{className:"parallel-task-debug-section-header",children:[n.jsx("h3",{children:o("settings.parallelTaskDebugCountersTitle")}),n.jsx("span",{children:o(m?"common.loading":"settings.parallelTaskDebugAutoRefresh")})]}),n.jsx("div",{className:"parallel-task-debug-counter-grid",children:C.map(([T,j])=>n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:OK(T)}),n.jsx("strong",{children:j})]},T))})]}),n.jsxs("section",{className:"parallel-task-debug-section",children:[n.jsxs("div",{className:"parallel-task-debug-section-header",children:[n.jsx("h3",{children:o("settings.parallelTaskDebugTaskMetricsTitle")}),n.jsx("span",{children:k.length})]}),k.length>0?n.jsx("div",{className:"parallel-task-debug-grid",children:k.map(([T,j])=>n.jsxs("article",{className:"parallel-task-debug-panel",children:[n.jsxs("div",{className:"parallel-task-debug-panel-header",children:[n.jsx("strong",{children:T}),n.jsx("span",{children:nT(j.executionLane)})]}),n.jsxs("div",{className:"parallel-task-debug-panel-body",children:[n.jsxs("span",{children:[o("settings.parallelTaskDebugWaitAvg"),": ",ei(j.waitMs.avg)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugRunAvg"),": ",ei(j.runMs.avg)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugRunMax"),": ",ei(j.runMs.max)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugStartedCount"),": ",j.counters.started??0]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugFinishedCount"),": ",j.counters.finished??0]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugFailedCount"),": ",j.counters.failed??0]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugCacheHitCount"),": ",j.counters.cache_hit??0]})]})]},T))}):n.jsx("div",{className:"parallel-task-debug-empty",children:o("settings.parallelTaskDebugEmpty")})]}),n.jsxs("section",{className:"parallel-task-debug-section",children:[n.jsxs("div",{className:"parallel-task-debug-section-header",children:[n.jsx("h3",{children:o("settings.parallelTaskDebugSchedulerTitle")}),n.jsx("span",{children:y.length})]}),y.length>0?n.jsx("div",{className:"parallel-task-debug-grid",children:y.map(([T,j])=>n.jsxs("article",{className:"parallel-task-debug-panel",children:[n.jsxs("div",{className:"parallel-task-debug-panel-header",children:[n.jsx("strong",{children:T}),n.jsx("span",{children:j.lastIdle?o("settings.parallelTaskDebugIdle"):o("settings.parallelTaskDebugBusy")})]}),n.jsxs("div",{className:"parallel-task-debug-panel-body",children:[n.jsxs("span",{children:[o("settings.parallelTaskDebugTickTotal"),": ",j.tickTotal]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugIdleTickTotal"),": ",j.idleTickTotal]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugTaskCountTotal"),": ",j.taskCountTotal]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugSchedulerErrorTotal"),": ",j.errorTotal]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugLastDuration"),": ",ei(j.lastDurationMs)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugNextDelay"),": ",ei(j.nextDelayMs)]})]})]},T))}):n.jsx("div",{className:"parallel-task-debug-empty",children:o("settings.parallelTaskDebugEmpty")})]}),n.jsxs("section",{className:"parallel-task-debug-section",children:[n.jsxs("div",{className:"parallel-task-debug-section-header",children:[n.jsx("h3",{children:o("settings.parallelTaskDebugEventLoopTitle")}),n.jsx("span",{children:i.eventLoop.enabled?o("settings.parallelTaskDebugCollectorEnabled"):o("settings.parallelTaskDebugCollectorDisabled")})]}),n.jsxs("div",{className:"parallel-task-debug-counter-grid",children:[n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugEventLoopResolution")}),n.jsx("strong",{children:ei(i.eventLoop.resolutionMs)})]}),n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugEventLoopMean")}),n.jsx("strong",{children:ei(i.eventLoop.meanMs)})]}),n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugEventLoopP95")}),n.jsx("strong",{children:ei(i.eventLoop.p95Ms)})]}),n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugEventLoopP99")}),n.jsx("strong",{children:ei(i.eventLoop.p99Ms)})]}),n.jsxs("div",{className:"parallel-task-debug-counter-card",children:[n.jsx("span",{children:o("settings.parallelTaskDebugEventLoopMax")}),n.jsx("strong",{children:ei(i.eventLoop.maxMs)})]})]})]}),n.jsxs("section",{className:"parallel-task-debug-section",children:[n.jsxs("div",{className:"parallel-task-debug-section-header",children:[n.jsx("h3",{children:o("settings.parallelTaskDebugRecentActivitiesTitle")}),n.jsx("span",{children:i.recentTaskActivities.length})]}),i.recentTaskActivities.length>0?n.jsx("div",{className:"parallel-task-debug-activity-list",children:i.recentTaskActivities.map(T=>n.jsxs("article",{className:"parallel-task-debug-activity-item",children:[n.jsxs("div",{className:"parallel-task-debug-activity-main",children:[n.jsxs("div",{className:"parallel-task-debug-activity-title-row",children:[n.jsx("strong",{children:T.taskType}),n.jsx("span",{children:BK(T.eventType)}),n.jsx("span",{children:nT(T.executionLane)})]}),n.jsxs("p",{children:[o("settings.parallelTaskDebugTaskKey"),": ",T.key]}),n.jsxs("p",{children:[o("settings.parallelTaskDebugStatus"),": ",T.status?WK(T.status):"-"]})]}),n.jsxs("div",{className:"parallel-task-debug-activity-meta",children:[n.jsx("span",{children:Rg(T.recordedAt)}),n.jsxs("span",{children:[o("settings.parallelTaskDebugAttempt"),": ",T.attempt??"-"]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugWaitMs"),": ",ei(T.waitMs)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugRunMs"),": ",ei(T.runMs)]}),n.jsxs("span",{children:[o("settings.parallelTaskDebugSource"),": ",T.source??"-"]}),T.errorMessage?n.jsxs("span",{children:[o("settings.parallelTaskDebugError"),": ",T.errorMessage]}):null]})]},T.eventId))}):n.jsx("div",{className:"parallel-task-debug-empty",children:o("settings.parallelTaskDebugEmpty")})]})]}):null]})]})]})}async function tT(e){return await _e.request(`/api/observability/runtime?sessionId=${encodeURIComponent(e)}`)}async function Pg(e){try{await _e.request(`/api/observability/runtime/session/${e}`,{method:"DELETE"})}catch{}}function Dg(e){return e instanceof Error&&e.message?e.message:o("settings.parallelTaskDebugLoadFailed")}function Rg(e){if(!e)return"-";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function ei(e){return e==null||Number.isNaN(e)?"-":`${Math.round(e*100)/100} ms`}function _K(e){return e===null||Number.isNaN(e)?"-":`${Math.round(e/1e3)} s`}function OK(e){switch(e){case"enqueue":return o("settings.parallelTaskDebugMetricEnqueue");case"dedupe":return o("settings.parallelTaskDebugMetricDedupe");case"started":return o("settings.parallelTaskDebugMetricStarted");case"finished":return o("settings.parallelTaskDebugMetricFinished");case"failed":return o("settings.parallelTaskDebugMetricFailed");case"cancelled":return o("settings.parallelTaskDebugMetricCancelled");case"timeout":return o("settings.parallelTaskDebugMetricTimeout");case"cache_hit":return o("settings.parallelTaskDebugMetricCacheHit");default:return e}}function nT(e){switch(e){case"host_background":return o("settings.parallelTaskDebugLaneHostBackground");case"helper_process":return o("settings.parallelTaskDebugLaneHelperProcess");case"external_process":return o("settings.parallelTaskDebugLaneExternalProcess");default:return o("settings.parallelTaskDebugLaneRequestMainThread")}}function BK(e){switch(e){case"enqueued":return o("settings.parallelTaskDebugEventEnqueued");case"deduped":return o("settings.parallelTaskDebugEventDeduped");case"started":return o("settings.parallelTaskDebugEventStarted");case"finished":return o("settings.parallelTaskDebugEventFinished");case"failed":return o("settings.parallelTaskDebugEventFailed");case"cancelled":return o("settings.parallelTaskDebugEventCancelled");case"timeout":return o("settings.parallelTaskDebugEventTimeout");case"cache_hit":return o("settings.parallelTaskDebugEventCacheHit");default:return e}}function WK(e){switch(e){case"queued":return o("settings.parallelTaskDebugTaskStatusQueued");case"running":return o("settings.parallelTaskDebugTaskStatusRunning");case"succeeded":return o("settings.parallelTaskDebugTaskStatusSucceeded");case"failed":return o("settings.parallelTaskDebugTaskStatusFailed");case"cancelled":return o("settings.parallelTaskDebugTaskStatusCancelled");case"timeout":return o("settings.parallelTaskDebugTaskStatusTimeout");default:return e}}async function rT(){const e=$s(),t=En.getState(),r=await e.bridge.getAndroidRuntimeInfo();if(!r.ok||!r.value)throw new Error(r.detail??"读取 Android 运行时信息失败。");const s=await _e.request(`/api/client/release-manifest?channel=${encodeURIComponent(t.releaseChannel)}&platform=android-apk`),i=s.versionCode>r.value.versionCode;return{checkedAt:new Date().toISOString(),currentVersion:r.value.version,currentVersionCode:r.value.versionCode,hasUpdate:i,manifest:s,runtimeInfo:r.value}}async function UK(e){return $s().bridge.installAndroidUpdate(e)}function HK(){const[e,t]=p.useState(!1),[r,s]=p.useState(!1),[i,l]=p.useState(null),[c,d]=p.useState(null),[m,f]=p.useState(null),[v,g]=p.useState(!1),[w,k]=p.useState(null),y=p.useRef(!1);p.useEffect(()=>{if(w===null){y.current=!1;return}const j=w;async function N(){if(!y.current){y.current=!0;try{const W=await rT();if(f(W.manifest),d(W.currentVersion),g(W.hasUpdate),!W.hasUpdate||W.currentVersionCode>=j){l(o("settings.androidInstallSucceeded"));return}l(o("settings.androidInstallCancelled"))}catch(W){l(W instanceof Error?W.message:o("settings.releaseCheckFailed"))}finally{k(null)}}}function D(){N()}function F(){document.visibilityState==="visible"&&N()}return window.addEventListener("focus",D),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("focus",D),document.removeEventListener("visibilitychange",F)}},[w]);async function C(){t(!0),l(null),k(null);try{const j=await rT();f(j.manifest),d(j.currentVersion),g(j.hasUpdate),l(j.hasUpdate?o("settings.releaseUpdateReady"):o("settings.releaseUpToDate"))}catch(j){l(j instanceof Error?j.message:o("settings.releaseCheckFailed"))}finally{t(!1)}}async function T(){if(m){s(!0),l(null),k(null);try{const j=await UK(m);if(j.status==="installer_started"){l(o("settings.androidInstallerStarted")),k(m.versionCode);return}if(j.status==="permission_required"){l(j.detail??o("settings.androidInstallPermissionRequired")),k(null);return}if(j.status==="already_up_to_date"){l(o("settings.releaseUpToDate")),g(!1),k(null);return}l(j.detail??o("settings.releaseInstallFailed")),k(null)}catch(j){l(j instanceof Error?j.message:o("settings.releaseInstallFailed")),k(null)}finally{s(!1)}}}return n.jsxs("div",{className:"settings-update-card",children:[n.jsxs("div",{className:"settings-update-summary",children:[n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.releaseCurrentVersion")}),n.jsx("strong",{className:"settings-update-value",children:c??o("settings.releaseUnknownVersion")})]}),n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.releaseTargetVersion")}),n.jsx("strong",{className:"settings-update-value",children:(m==null?void 0:m.version)??"-"})]})]}),i?n.jsx("p",{className:"settings-update-status","data-tone":v?"warning":"success",children:i}):null,n.jsxs("div",{className:"settings-update-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:e||r,onClick:C,children:o(e?"common.loading":"settings.releaseCheckNow")}),n.jsx("button",{className:"primary-button",type:"button",disabled:!m||!v||r,onClick:T,children:o(r?"common.loading":"settings.releaseInstallNow")})]})]})}function zK(){const e=$s(),t=e.isDesktop,[r,s]=p.useState(!1),[i,l]=p.useState(!1),[c,d]=p.useState(!1),[m,f]=p.useState(null),[v,g]=p.useState(null),[w,k]=p.useState(null),[y,C]=p.useState(!1);async function T(){var W;s(!0),f(null);try{const E=await xN();k(E.manifest),g(E.currentVersion),C(E.hasUpdate),f(qK(E.manifest,E.hasUpdate)),E.hasUpdate&&await e.bridge.showNotification(o("settings.releaseUpdateReady"),((W=E.manifest)==null?void 0:W.version)??"-")}catch(E){f(E instanceof Error?E.message:o("settings.releaseCheckFailed"))}finally{s(!1)}}async function j(){if(!(!w||!y)){l(!0),f(null);try{const W=await lL();if(!W.ok){f(W.detail??o("settings.releaseInstallFailed"));return}f(o("settings.releaseInstallStarted")),await e.bridge.showNotification(o("settings.releaseInstallStarted"),w.version)}catch(W){f(W instanceof Error?W.message:o("settings.releaseInstallFailed"))}finally{l(!1)}}}async function N(){if(w!=null&&w.htmlUrl){d(!0);try{const W=await e.bridge.openExternal(w.htmlUrl);W.ok||f(W.detail??o("settings.releasePageOpenFailed"))}catch(W){f(W instanceof Error?W.message:o("settings.releasePageOpenFailed"))}finally{d(!1)}}}const D=!!(t&&w&&y),F=m??(t?null:o("settings.clientUpdateUnsupported"));return n.jsxs("div",{className:"settings-update-card",children:[n.jsxs("div",{className:"settings-update-summary",children:[n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.releaseCurrentVersion")}),n.jsx("strong",{className:"settings-update-value",children:v??o("settings.releaseUnknownVersion")})]}),n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.releaseTargetVersion")}),n.jsx("strong",{className:"settings-update-value",children:(w==null?void 0:w.version)??"-"})]})]}),F?n.jsx("p",{className:"settings-update-status","data-tone":$K(w,y,F),children:F}):null,n.jsxs("div",{className:"settings-update-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:!t||r||i,onClick:T,children:o(r?"common.loading":"settings.releaseCheckNow")}),n.jsx("button",{className:"primary-button",type:"button",disabled:!D||i,onClick:j,children:o(i?"common.loading":"settings.releaseInstallNow")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:!(w!=null&&w.htmlUrl)||r||i||c,onClick:N,children:o(c?"common.loading":"settings.releaseOpenPage")})]})]})}function qK(e,t){return o(t?"settings.releaseUpdateReady":"settings.releaseUpToDate")}function $K(e,t,r){return r===o("settings.clientUpdateUnsupported")?"neutral":t?"warning":"success"}function SM(){const e=$s();return e.platform==="desktop"?n.jsx(zK,{}):e.platform==="android"?n.jsx(HK,{}):n.jsx("div",{className:"settings-update-card",children:n.jsx("p",{className:"settings-update-status","data-tone":"neutral",children:o("settings.clientUpdateUnsupported")})})}async function sT(){return await _e.request("/api/system/model-switch")}async function VK(e){return await _e.request("/api/system/model-switch",{method:"POST",body:JSON.stringify(e)})}function CM(){const e=gu(F=>{var W;return((W=F.session)==null?void 0:W.accessToken)??null}),[t,r]=p.useState(null),[s,i]=p.useState(!0),[l,c]=p.useState(null),[d,m]=p.useState(null),[f,v]=p.useState(null),[g,w]=p.useState(!1),[k,y]=p.useState("codex");p.useEffect(()=>{let F=!0;if(!e){r(null),m(null),v(null),i(!1);return}return(async()=>{i(!0);try{const E=await sT();if(!F)return;r(E),m(null),y(I=>aT(E,I))}catch(E){if(!F)return;m(Mg(E))}finally{F&&i(!1)}})(),()=>{F=!1}},[e]);async function C(){const F=await sT();r(F),m(null),y(W=>aT(F,W))}async function T(){if(e){c("refresh"),m(null),v(null);try{await C(),v(o("settings.modelManagementRefreshSuccess"))}catch(F){m(Mg(F))}finally{c(null)}}}async function j(F,W){if(!e||W.isCurrent)return;const E=iT(F,W.id);c(E),m(null),v(null);try{const I=await VK({app:F,presetId:W.id});FP(),r(M=>GK(M,I)),v(o("settings.modelManagementSwitchSuccess",{app:I.displayName,preset:I.currentPresetName??W.name}))}catch(I){m(Mg(I))}finally{c(null)}}const N=(t==null?void 0:t.items)??[],D=N.find(F=>F.app===k)??N[0]??null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"settings-model-panel",children:n.jsxs("div",{className:"settings-release-card",children:[f?n.jsx("p",{className:"settings-release-status",children:f}):null,d?n.jsx("p",{className:"settings-release-status",children:d}):null,N.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"settings-model-grid",children:N.map(F=>n.jsx("section",{className:"settings-model-card",children:n.jsxs("div",{className:"settings-model-card-main",children:[n.jsxs("div",{className:"settings-model-card-copy",children:[n.jsx("strong",{className:"settings-model-card-title",children:F.displayName}),n.jsx("span",{className:"settings-model-card-status","data-status":F.status,children:KK(F.status)})]}),n.jsxs("div",{className:"settings-model-value-line",children:[n.jsx("strong",{className:"settings-model-preset-value",children:F.currentPresetName??o("settings.modelManagementPresetMissing")}),n.jsx("strong",{className:"settings-model-current-value",children:F.currentModel??o("settings.modelManagementModelUnknown")})]})]})},F.app))}),n.jsx("div",{className:"settings-model-panel-actions",children:n.jsx("button",{className:"secondary-button settings-model-open-action",type:"button",disabled:!e||s,onClick:()=>{w(!0)},children:o("settings.modelManagementOpenSwitcher")})})]}):n.jsx("div",{className:"settings-model-empty",children:o("settings.modelManagementOptionsEmpty")})]})}),n.jsxs(Ln,{open:g,title:o("settings.modelManagementModalTitle"),description:o("settings.modelManagementModalDescription"),className:"settings-model-modal",headerActions:n.jsx("button",{className:"secondary-button",type:"button",disabled:!e||s||l!==null,onClick:()=>{T()},children:o(l==="refresh"?"common.loading":"settings.modelManagementRefresh")}),onClose:()=>w(!1),children:[n.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":o("settings.modelManagementTabsLabel"),children:N.map(F=>{const W=(D==null?void 0:D.app)===F.app;return n.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":W,"data-active":W?"true":"false",onClick:()=>y(F.app),children:F.displayName},F.app)})}),D?n.jsxs("section",{className:"settings-model-modal-panel",children:[n.jsxs("div",{className:"settings-model-modal-summary",children:[n.jsxs("div",{className:"settings-model-modal-summary-row",children:[n.jsx("span",{children:o("settings.modelManagementCurrentProfile")}),n.jsx("strong",{children:D.currentPresetName??o("settings.modelManagementPresetMissing")})]}),n.jsxs("div",{className:"settings-model-modal-summary-row",children:[n.jsx("span",{children:o("settings.modelManagementCurrentModel")}),n.jsx("strong",{children:D.currentModel??o("settings.modelManagementModelUnknown")})]})]}),D.statusText?n.jsx("p",{className:"settings-model-modal-note",children:D.statusText}):null,D.options.length>0?n.jsx("div",{className:"settings-model-switcher-list",children:D.options.map(F=>{const W=iT(D.app,F.id);return n.jsxs("div",{className:"settings-model-switcher-item","data-current":F.isCurrent?"true":"false",children:[n.jsxs("div",{className:"settings-model-switcher-item-main",children:[n.jsx("strong",{children:F.name}),n.jsx("span",{children:F.model??o("settings.modelManagementModelUnknown")})]}),n.jsx("div",{className:"settings-model-switcher-item-actions",children:F.isCurrent?n.jsx("span",{className:"settings-model-card-status","data-status":"ready",children:o("settings.modelManagementCurrentTag")}):n.jsx("button",{className:"secondary-button settings-model-option-action",type:"button",disabled:s||l!==null||D.status!=="ready",onClick:()=>{j(D.app,F)},children:o(l===W?"common.loading":"settings.modelManagementSwitchAction")})})]},`${D.app}:${F.id}`)})}):n.jsx("div",{className:"settings-model-empty",children:D.statusText??o("settings.modelManagementOptionsEmpty")})]}):n.jsx("div",{className:"settings-model-empty",children:o("settings.modelManagementOptionsEmpty")})]})]})}function iT(e,t){return`switch:${e}:${t}`}function GK(e,t){return e&&{...e,scannedAt:new Date().toISOString(),items:e.items.map(r=>r.app===t.app?t:r)}}function aT(e,t){var s;return e.items.some(i=>i.app===t)?t:((s=e.items[0])==null?void 0:s.app)??"codex"}function KK(e){switch(e){case"unconfigured":return o("settings.modelManagementStatusUnconfigured");case"unavailable":return o("settings.modelManagementStatusUnavailable");case"error":return o("settings.modelManagementStatusError");default:return o("settings.modelManagementStatusReady")}}function Mg(e){return e instanceof Ur?e.message||o("settings.modelManagementLoadFailed"):e instanceof Error?e.message:o("settings.modelManagementLoadFailed")}async function oT(){const e=En.getState();return _e.request(`/api/client/service-update?channel=${encodeURIComponent(e.releaseChannel)}`)}async function YK(e){const t=En.getState();return _e.request("/api/client/service-update/install",{method:"POST",body:JSON.stringify({packageName:e,channel:t.releaseChannel})})}async function XK(e){return _e.request(`/api/client/service-update/tasks/${encodeURIComponent(e)}`)}const QK=1500;function jM(){const e=$s(),[t,r]=p.useState(!1),[s,i]=p.useState(!1),[l,c]=p.useState(null),[d,m]=p.useState(null),[f,v]=p.useState(null),g=(d==null?void 0:d.packages[0])??null;p.useEffect(()=>{if(!f||!Ag(f.status))return;let C=!1;const T=window.setTimeout(async()=>{var j;try{const N=await XK(f.taskId);if(C)return;if(v(N),c(Mb(N)),!Ag(N.status)){i(!1);const D=await oT();if(C)return;m(D),v(((j=D.packages[0])==null?void 0:j.installTask)??N),c(lT(D.packages[0]??null,N)),N.restartRequired&&await e.bridge.showNotification(o("settings.serverRestartRequired"),N.targetVersion??"-")}}catch(N){if(C)return;i(!1),c(N instanceof Error?N.message:o("settings.serverInstallFailed"))}},QK);return()=>{C=!0,window.clearTimeout(T)}},[e.bridge,f]);async function w(){r(!0),c(null);try{const C=await oT(),T=C.packages[0]??null;m(C),v((T==null?void 0:T.installTask)??null),c(lT(T,(T==null?void 0:T.installTask)??null)),T!=null&&T.hasUpdate&&await e.bridge.showNotification(o("settings.serverUpdateReady"),`${o("settings.serverTargetVersion")}: ${T.latestVersion??"-"}`)}catch(C){c(C instanceof Error?C.message:o("settings.serverCheckFailed"))}finally{r(!1)}}async function k(){if(g!=null&&g.packageName){i(!0),c(null);try{const C=await YK(g.packageName);v(C),c(Mb(C))}catch(C){i(!1),c(C instanceof Error?C.message:o("settings.serverInstallFailed"))}}}const y=!!(g&&g.checkStatus!=="check_failed"&&g.hasUpdate&&!g.restartRequired&&!Ag(f==null?void 0:f.status));return n.jsxs("div",{className:"settings-update-card",children:[n.jsxs("div",{className:"settings-update-summary",children:[n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.serverCurrentVersion")}),n.jsx("strong",{className:"settings-update-value",children:(g==null?void 0:g.currentVersion)??"-"})]}),n.jsxs("div",{className:"settings-update-field",children:[n.jsx("span",{className:"settings-update-label",children:o("settings.serverTargetVersion")}),n.jsx("strong",{className:"settings-update-value",children:(g==null?void 0:g.latestVersion)??"-"})]})]}),l?n.jsx("p",{className:"settings-update-status","data-tone":JK(g,f),children:l}):null,n.jsxs("div",{className:"settings-update-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:t||s,onClick:w,children:o(t?"common.loading":"settings.serverCheckNow")}),n.jsx("button",{className:"primary-button",type:"button",disabled:!y||t||s,onClick:k,children:o(s?"common.loading":"settings.serverInstallNow")})]})]})}function lT(e,t){return t?Mb(t):e?e.restartRequired?o("settings.serverRestartRequired"):e.checkStatus==="check_failed"?e.checkError??o("settings.serverCheckFailed"):e.latestVersion?e.hasUpdate?o("settings.serverUpdateReady"):o("settings.serverUpToDate"):o("settings.serverLatestUnknown"):o("settings.serverCheckNow")}function Mb(e){switch(e.status){case"queued":return o("settings.serverInstallQueued");case"running":return o("settings.serverInstalling");case"succeeded":return e.restartRequired?o("settings.serverRestartRequired"):o("settings.serverInstallSucceeded");case"cancelled":return o("settings.serverInstallCancelled");case"timeout":return o("settings.serverInstallTimeout");case"failed":return e.errorMessage??o("settings.serverInstallFailed");default:return e.errorMessage??o("settings.serverInstallFailed")}}function JK(e,t){if(t)switch(t.status){case"queued":case"running":return"warning";case"succeeded":return t.restartRequired?"warning":"success";case"failed":case"cancelled":case"timeout":return"danger";default:return"neutral"}return e?e.checkStatus==="check_failed"?"danger":e.restartRequired||e.hasUpdate?"warning":"success":"neutral"}function Ag(e){return e==="queued"||e==="running"}async function cT(){return await _e.request("/api/skills/overview")}async function ZK(e){await _e.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function e7(e){await _e.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function TM(){const e=gu(N=>{var D;return((D=N.session)==null?void 0:D.accessToken)??null}),[t,r]=p.useState(null),[s,i]=p.useState(!0),[l,c]=p.useState(null),[d,m]=p.useState(null),[f,v]=p.useState(null),[g,w]=p.useState(!1);p.useEffect(()=>{let N=!0;if(!e){r(null),m(null),v(null),i(!1);return}return(async()=>{i(!0);try{const F=await cT();if(!N)return;r(F),m(null)}catch(F){if(!N)return;m(ch(F))}finally{N&&i(!1)}})(),()=>{N=!1}},[e]);async function k(){const N=await cT();r(N),m(null)}async function y(){if(e){c("refresh"),m(null),v(null);try{await k(),v(o("settings.skillRefreshSuccess"))}catch(N){m(ch(N))}finally{c(null)}}}async function C(N){if(e){c(uT(N)),m(null),v(null);try{await ZK({targetCli:N.targetCli,directoryPath:N.directoryPath,expectedContentHash:N.contentHash}),await k(),v(o("settings.skillImportSuccess",{name:N.name,target:Pc(N.targetCli)}))}catch(D){m(ch(D))}finally{c(null)}}}async function T(N){if(!e)return;const D=N.bindings.filter(F=>F.enabled).map(F=>F.targetCli);if(D.length===0){m(o("settings.skillSyncTargetMissing"));return}c(dT(N.skill.id)),m(null),v(null);try{await e7({skillId:N.skill.id,targetCli:D}),await k(),v(o("settings.skillSyncSuccess",{name:N.skill.name}))}catch(F){m(ch(F))}finally{c(null)}}const j=(t==null?void 0:t.summary)??{managedSkillCount:0,managedEntryCount:0,unmanagedEntryCount:0,conflictedEntryCount:0,diagnosticCount:0};return n.jsxs("div",{className:"settings-skill-panel",children:[n.jsxs("div",{className:"settings-release-card",children:[n.jsxs("div",{className:"settings-skill-summary-grid",children:[n.jsx(Nc,{label:o("settings.skillSummaryManagedSkills"),value:String(j.managedSkillCount)}),n.jsx(Nc,{label:o("settings.skillSummaryManagedEntries"),value:String(j.managedEntryCount)}),n.jsx(Nc,{label:o("settings.skillSummaryUnmanagedEntries"),value:String(j.unmanagedEntryCount)}),n.jsx(Nc,{label:o("settings.skillSummaryConflictedEntries"),value:String(j.conflictedEntryCount)}),n.jsx(Nc,{label:o("settings.skillSummaryDiagnostics"),value:String(j.diagnosticCount)})]}),n.jsx("div",{className:"settings-release-actions settings-skill-panel-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:!e,onClick:()=>{w(!0)},children:o("settings.skillManageAction")})})]}),n.jsxs(Ln,{open:g,title:o("settings.skillConfigModalTitle"),description:o("settings.skillConfigModalDescription"),className:"settings-skill-modal",headerActions:n.jsx("button",{className:"secondary-button",type:"button",disabled:!e||s||l!==null,onClick:()=>{y()},children:o(l==="refresh"?"common.loading":"settings.skillRefresh")}),onClose:()=>w(!1),children:[n.jsx("div",{className:"settings-release-meta",children:n.jsxs("span",{children:[o("settings.skillScannedAt"),": ",s?o("common.loading"):n7(t==null?void 0:t.scannedAt)]})}),f?n.jsx("p",{className:"settings-release-status",children:f}):null,d?n.jsx("p",{className:"settings-release-status",children:d}):null,n.jsx(lh,{title:o("settings.skillManagedListTitle"),emptyText:o("settings.skillManagedEmpty"),items:(t==null?void 0:t.managedSkills)??[],renderItem:N=>{const D=dT(N.skill.id);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:N.skill.name}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillDirectoryName"),": ",N.skill.directoryName]}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillSsotPath"),": ",n.jsx("span",{className:"settings-skill-path",children:N.ssotPath})]}),n.jsx("div",{className:"settings-skill-tags",children:N.bindings.map(F=>n.jsxs("span",{className:"settings-skill-tag","data-status":F.syncStatus,children:[Pc(F.targetCli)," · ",t7(F.syncStatus)]},`${N.skill.id}-${F.targetCli}`))})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:s||l!==null,onClick:()=>{T(N)},children:o(l===D?"common.loading":"settings.skillSyncAction")})})]},N.skill.id)}}),n.jsx(lh,{title:o("settings.skillUnmanagedListTitle"),emptyText:o("settings.skillUnmanagedEmpty"),items:(t==null?void 0:t.unmanagedEntries)??[],renderItem:N=>{const D=uT(N);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:N.name}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillSourceCli"),": ",Pc(N.targetCli)]}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillDirectoryPath"),": ",n.jsx("span",{className:"settings-skill-path",children:N.directoryPath})]})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:s||l!==null,onClick:()=>{C(N)},children:o(l===D?"common.loading":"settings.skillImportAction")})})]},`${N.targetCli}:${N.directoryPath}`)}}),n.jsx(lh,{title:o("settings.skillConflictedListTitle"),emptyText:o("settings.skillConflictedEmpty"),items:(t==null?void 0:t.conflictedEntries)??[],renderItem:N=>n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:N.name}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillSourceCli"),": ",Pc(N.targetCli)]}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillDirectoryPath"),": ",n.jsx("span",{className:"settings-skill-path",children:N.directoryPath})]})]})},`${N.targetCli}:${N.directoryPath}`)}),n.jsx(lh,{title:o("settings.skillDiagnosticsTitle"),emptyText:o("settings.skillDiagnosticsEmpty"),items:(t==null?void 0:t.diagnostics)??[],renderItem:N=>n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsxs("strong",{className:"settings-skill-entry-title",children:[Pc(N.targetCli)," · ",N.code]}),n.jsx("p",{className:"settings-skill-entry-meta",children:N.detail}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[o("settings.skillDirectoryPath"),":"," ",n.jsx("span",{className:"settings-skill-path",children:N.directoryPath??N.rootDir})]})]})},`${N.targetCli}:${N.code}:${N.directoryPath??N.rootDir}`)})]})]})}function lh({title:e,emptyText:t,items:r,renderItem:s}){return n.jsxs("section",{className:"settings-skill-section",children:[n.jsx("h3",{className:"settings-skill-section-title",children:e}),r.length>0?n.jsx("div",{className:"settings-skill-entry-list",children:r.map(i=>s(i))}):n.jsx("div",{className:"settings-skill-empty",children:t})]})}function Nc({label:e,value:t}){return n.jsxs("div",{className:"settings-skill-summary-card",children:[n.jsx("span",{children:e}),n.jsx("strong",{children:t})]})}function uT(e){return`import:${e.targetCli}:${e.directoryPath}`}function dT(e){return`sync:${e}`}function ch(e){return e instanceof Ur?e.message||o("settings.skillLoadFailed"):e instanceof Error?e.message:o("settings.skillLoadFailed")}function Pc(e){switch(e){case"claude-code":return o("settings.skillTargetClaudeCode");case"gemini":return o("settings.skillTargetGemini");case"opencode":return o("settings.skillTargetOpenCode");default:return o("settings.skillTargetCodex")}}function t7(e){switch(e){case"conflicted":return o("settings.skillBindingConflicted");case"failed":return o("settings.skillBindingFailed");case"pending":return o("settings.skillBindingPending");default:return o("settings.skillBindingSynced")}}function n7(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}async function hT(){return await _e.request("/api/system/tailscale/status")}async function r7(e){return await _e.request("/api/system/tailscale/config",{method:"PUT",body:JSON.stringify(e)})}async function s7(){return await _e.request("/api/system/tailscale/enable",{method:"POST"})}async function i7(){return await _e.request("/api/system/tailscale/disable",{method:"POST"})}async function a7(){return await _e.request("/api/system/tailscale/login",{method:"POST"})}async function o7(){return await _e.request("/api/system/tailscale/logout",{method:"POST"})}function NM(){const e=nr(),[t,r]=p.useState(null),[s,i]=p.useState(""),[l,c]=p.useState(""),[d,m]=p.useState(!0),[f,v]=p.useState(null),[g,w]=p.useState(null),[k,y]=p.useState(!1),[C,T]=p.useState(!1),j=p.useRef(!0),N=p.useRef(!1),D=p.useRef(async()=>{});N.current=C;function F(Y){r(Y),i(Y.controlServerUrl??""),c(Y.hostname??""),w(null),N.current&&!pT(Y.lastError)&&T(!1)}D.current=async Y=>{Y||m(!0);try{const G=await hT();if(!j.current)return;F(G)}catch(G){if(!j.current)return;w(dh(G))}finally{j.current&&!Y&&m(!1)}},p.useEffect(()=>{j.current=!0,D.current(!1);const Y=window.setInterval(()=>{D.current(!0)},5e3);return()=>{j.current=!1,window.clearInterval(Y)}},[]),p.useEffect(()=>{if(!C)return;function Y(){D.current(!0)}function G(){document.visibilityState==="visible"&&D.current(!0)}return window.addEventListener("focus",Y),document.addEventListener("visibilitychange",G),()=>{window.removeEventListener("focus",Y),document.removeEventListener("visibilitychange",G)}},[C]);const W=((t==null?void 0:t.controlServerUrl)??"")!==s.trim()||((t==null?void 0:t.hostname)??"")!==l.trim(),E=pT(t==null?void 0:t.lastError),I=u7(e.ui.osFamily)&&E;async function M(){const Y=await r7({controlServerUrl:mT(s),hostname:mT(l)});return F(Y),Y}async function _(Y){v(Y),w(null);try{W&&Y!=="disable"&&Y!=="logout"&&await M();const G=Y==="enable"?await s7():Y==="disable"?await i7():Y==="login"?await a7():await o7();r(G),i(G.controlServerUrl??""),c(G.hostname??"")}catch(G){w(dh(G))}finally{v(null)}}async function L(){v("save"),w(null);try{const Y=await M();r(Y),y(!1)}catch(Y){w(dh(Y))}finally{v(null)}}async function Q(){v("refresh"),w(null);try{const Y=await hT();F(Y)}catch(Y){w(dh(Y))}finally{v(null),m(!1)}}async function O(){const Y=d7(e.ui.osFamily);if(Y){v("install"),w(null);try{const G=await e.bridge.openExternal(Y);if(!G.ok){w(G.detail??o("settings.tailscaleInstallOpenFailed"));return}T(!0)}catch(G){w(G instanceof Error?G.message:o("settings.tailscaleInstallOpenFailed"))}finally{v(null)}}}function ne(){f!=="save"&&y(!1)}return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"settings-tailscale-panel",children:n.jsxs("div",{className:"settings-release-card",children:[n.jsxs("div",{className:"settings-tailscale-summary",children:[n.jsx(uh,{label:o("settings.tailscaleStatusIndicator"),value:n.jsxs("span",{className:"settings-tailscale-status-indicator","data-tone":h7((t==null?void 0:t.phase)??"disabled"),children:[n.jsx("span",{className:"settings-tailscale-status-dot","aria-hidden":"true"}),c7((t==null?void 0:t.phase)??"disabled")]})}),n.jsx(uh,{label:o("settings.tailscaleServerAddress"),value:(t==null?void 0:t.reachableBaseUrl)??o("settings.tailscaleUnavailable"),href:(t==null?void 0:t.reachableBaseUrl)??void 0}),n.jsx(uh,{label:o("settings.tailscaleAccountName"),value:(t==null?void 0:t.accountName)??o("settings.tailscaleUnavailable")}),n.jsx(uh,{label:o("settings.tailscaleIpAddress"),value:l7(t)})]}),(t==null?void 0:t.phase)==="needs_login"&&t.loginUrl?n.jsx("div",{className:"settings-release-notes",children:n.jsx("p",{className:"settings-tailscale-login-url",children:n.jsx("a",{className:"settings-tailscale-link",href:t.loginUrl,rel:"noreferrer",target:"_blank",children:t.loginUrl})})}):null,t!=null&&t.lastError||g?n.jsx("p",{className:"settings-release-status",children:g??(t==null?void 0:t.lastError)}):null,n.jsxs("div",{className:"settings-release-actions settings-tailscale-panel-actions",children:[I?n.jsx("button",{className:"settings-button",type:"button",disabled:d||f!==null,onClick:()=>{O()},children:o(f==="install"?"common.loading":"settings.tailscaleInstallAction")}):null,n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null,onClick:()=>y(!0),children:o("settings.tailscaleConfigure")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null,onClick:()=>{Q()},children:o(f==="refresh"?"common.loading":"settings.tailscaleRefresh")}),t!=null&&t.enabled?n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null||E,onClick:()=>{_("disable")},children:o(f==="disable"?"common.loading":"settings.tailscaleDisable")}):n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null||E,onClick:()=>{_("enable")},children:o(f==="enable"?"common.loading":"settings.tailscaleEnable")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null||!(t!=null&&t.enabled)||E,onClick:()=>{_("login")},children:o(f==="login"?"common.loading":"settings.tailscaleLogin")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:d||f!==null||!(t!=null&&t.enabled)||E,onClick:()=>{_("logout")},children:o(f==="logout"?"common.loading":"settings.tailscaleLogout")})]})]})}),n.jsx(Ln,{open:k,title:o("settings.tailscaleConfigModalTitle"),description:o("settings.tailscaleConfigModalDescription"),className:"settings-tailscale-modal",onClose:ne,children:n.jsxs("div",{className:"settings-tailscale-modal-body",children:[n.jsxs("div",{className:"settings-tailscale-form",children:[n.jsxs("label",{className:"settings-tailscale-field",children:[n.jsx("span",{className:"settings-tailscale-field-label",children:o("settings.tailscaleControlServer")}),n.jsx("input",{"aria-label":o("settings.tailscaleControlServer"),className:"settings-text-input",placeholder:o("settings.tailscaleControlServerPlaceholder"),value:s,onChange:Y=>i(Y.target.value)})]}),n.jsxs("label",{className:"settings-tailscale-field",children:[n.jsx("span",{className:"settings-tailscale-field-label",children:o("settings.tailscaleHostname")}),n.jsx("input",{"aria-label":o("settings.tailscaleHostname"),className:"settings-text-input",placeholder:o("settings.tailscaleHostnamePlaceholder"),value:l,onChange:Y=>c(Y.target.value)})]})]}),n.jsxs("div",{className:"settings-tailscale-modal-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:f==="save",onClick:ne,children:o("common.cancel")}),n.jsx("button",{className:"settings-button",type:"button",disabled:f!==null||!W,onClick:()=>{L()},children:o(f==="save"?"common.loading":"common.save")})]})]})})]})}function uh({label:e,value:t,href:r}){return n.jsx("section",{className:"settings-model-card settings-tailscale-summary-card",children:n.jsxs("div",{className:"settings-model-card-main settings-tailscale-summary-card-main",children:[n.jsx("div",{className:"settings-model-card-copy",children:n.jsx("strong",{className:"settings-model-card-title",children:e})}),n.jsx("div",{className:"settings-tailscale-summary-value",children:r&&typeof t=="string"?n.jsx("a",{className:"settings-tailscale-link",href:r,target:"_blank",rel:"noreferrer",children:t}):t})]})})}function mT(e){const t=e.trim();return t.length>0?t:null}function dh(e){return e instanceof Ur||e instanceof Error?e.message:o("settings.tailscaleLoadFailed")}function l7(e){if(!e)return o("settings.tailscaleUnavailable");const t=[e.tailnetIpv4,e.tailnetIpv6].filter(r=>!!r);return t.length>0?t.join(" / "):o("settings.tailscaleUnavailable")}function c7(e){switch(e){case"blocked_uninitialized":return o("settings.tailscalePhaseBlockedUninitialized");case"starting":return o("settings.tailscalePhaseStarting");case"needs_login":return o("settings.tailscalePhaseNeedsLogin");case"running":return o("settings.tailscalePhaseRunning");case"stopping":return o("settings.tailscalePhaseStopping");case"error":return o("settings.tailscalePhaseError");case"disabled":default:return o("settings.tailscalePhaseDisabled")}}function pT(e){return e?e.includes("Tailscale CLI"):!1}function u7(e){return e==="macos"||e==="windows"}function d7(e){switch(e){case"macos":return"https://tailscale.com/download/mac";case"windows":return"https://tailscale.com/download/windows";default:return null}}function h7(e){switch(e){case"running":return"green";case"starting":case"needs_login":case"error":return"yellow";case"disabled":case"blocked_uninitialized":case"stopping":default:return"gray"}}function fT({title:e,description:t,actions:r,content:s,className:i}){return n.jsx(hR,{className:i,children:n.jsxs("section",{className:"mobile-workspace-home-header mobile-page-header",children:[n.jsx("h1",{className:"mobile-workspace-switcher-heading",children:e}),n.jsxs("div",{className:"mobile-workspace-home-toolbar-top mobile-page-header-main",children:[n.jsx("div",{className:"mobile-page-header-copy",children:n.jsx("div",{className:"mobile-workspace-home-switcher mobile-page-header-static-title",children:n.jsx("span",{className:"mobile-workspace-home-switcher-label",children:e})})}),r?n.jsx("div",{className:"mobile-workspace-home-toolbar-actions mobile-page-header-actions",children:r}):null]}),t?n.jsx("p",{className:"mobile-workspace-home-path mobile-page-header-description",children:t}):null,s?n.jsx("div",{className:"mobile-page-header-content",children:s}):null]})})}function m7(e){return e==="appearance"||e==="model-management"||e==="server-connection"||e==="remote-access"||e==="skills"||e==="security-privacy"||e==="software-update"}function p7(e){return o(e==="en-US"?"locale.enUS":"locale.zhCN")}function f7(e){return o(e==="beta"?"settings.releaseBeta":"settings.releaseStable")}function g7(e){switch(e){case"acceptEdits":return o("settings.permissionModeAcceptEdits");case"bypassPermissions":return o("settings.permissionModeBypassPermissions");default:return o("settings.permissionModeDefault")}}function b7(){const e=vr(),{theme:t,selectedTheme:r,autoTheme:s,setTheme:i,setAutoTheme:l}=vN(),c=Rl(R=>R),d=_g(R=>R.profile.language),m=_g(R=>R.profile.defaultPermissionMode),f=ai(R=>R.sessionDisplaySortMode),v=ai(R=>R.showSystemFiles),g=ai(R=>R.notificationPreferences.notifyOnPermissionRequest),w=ai(R=>R.notificationPreferences.notifyOnSessionCompleted),k=ai(R=>R.notificationPreferences.notifyOnSessionFailed),y={language:d,defaultPermissionMode:m},C=nr(),T=_b(c.platform),j=T,N=Eb(c)??"",[D,F]=p.useState(N);p.useEffect(()=>{F(N)},[N]);function W(){br.clear(),xi.resetToLocalFallback(),e("/login",{replace:!0})}function E(R){i(R)}function I(R){l(R)}function M(R){try{return Ci(R)}catch{return null}}const _=M(D),L=_!==null&&_!==N;function Q(R){R.preventDefault(),_&&En.update({hosts:c.hosts.map(Se=>Se.id===c.activeHostId?{...Se,baseUrl:_,updatedAt:new Date().toISOString()}:Se)})}const O=[{value:"default",label:o("settings.permissionModeDefault")},{value:"acceptEdits",label:o("settings.permissionModeAcceptEdits")},{value:"bypassPermissions",label:o("settings.permissionModeBypassPermissions")}],ne=[{value:"createdAt",label:o("settings.sessionSortModeCreatedAt")},{value:"updatedAt",label:o("settings.sessionSortModeUpdatedAt")},{value:"title",label:o("settings.sessionSortModeTitle")}];function Y(R){En.update({releaseChannel:R==="beta"?"beta":"stable"})}function G(R){En.update({autoReconnect:R})}function te(R){En.update({autoCheckUpdate:R})}function K(R){const Se=R==="acceptEdits"||R==="bypassPermissions"?R:"default";xi.updateProfile({defaultPermissionMode:Se}).catch(()=>{})}function z(R){const Se=R==="updatedAt"||R==="title"?R:"createdAt";wo.setSessionDisplaySortMode(Se)}function q(R){wo.setShowSystemFiles(R)}function P(R){wo.setNotificationPreferences({notifyOnPermissionRequest:R})}function U(R){wo.setNotificationPreferences({notifyOnSessionCompleted:R})}function X(R){wo.setNotificationPreferences({notifyOnSessionFailed:R})}return{platform:C,theme:t,selectedTheme:r,autoTheme:s,applyTheme:E,applyAutoTheme:I,runtimeConfig:c,accountPreferences:y,sessionDisplaySortMode:f,showSystemFiles:v,notifyOnPermissionRequest:g,notifyOnSessionCompleted:w,notifyOnSessionFailed:k,showServerSettings:j,canConfigureServerAddress:T,hostBaseUrlDraft:D,setHostBaseUrlDraft:F,canSaveHostBaseUrl:L,permissionModeOptions:O,sessionDisplaySortModeOptions:ne,handleHostBaseUrlSubmit:Q,handleLogout:W,updateReleaseChannel:Y,updateAutoReconnect:G,updateAutoCheckUpdate:te,updateDefaultPermissionMode:K,updateSessionDisplaySortMode:z,updateShowSystemFiles:q,updateNotifyOnPermissionRequest:P,updateNotifyOnSessionCompleted:U,updateNotifyOnSessionFailed:X}}function gT(){const e=b7(),t=kN();return e.platform.isMobile?n.jsx(w7,{model:e,appVersion:t}):n.jsx(v7,{model:e,appVersion:t})}function v7({model:e,appVersion:t}){const[r,s]=p.useState(!1),{theme:i,selectedTheme:l,autoTheme:c,applyTheme:d,applyAutoTheme:m,runtimeConfig:f,accountPreferences:v,sessionDisplaySortMode:g,showSystemFiles:w,notifyOnPermissionRequest:k,notifyOnSessionCompleted:y,notifyOnSessionFailed:C,showServerSettings:T,hostBaseUrlDraft:j,setHostBaseUrlDraft:N,canSaveHostBaseUrl:D,permissionModeOptions:F,sessionDisplaySortModeOptions:W,platform:E,handleHostBaseUrlSubmit:I,handleLogout:M,updateReleaseChannel:_,updateAutoReconnect:L,updateAutoCheckUpdate:Q,updateDefaultPermissionMode:O,updateSessionDisplaySortMode:ne,updateShowSystemFiles:Y,updateNotifyOnPermissionRequest:G,updateNotifyOnSessionCompleted:te,updateNotifyOnSessionFailed:K}=e;return n.jsxs("div",{className:"settings-page",children:[n.jsxs("div",{className:"settings-container",children:[n.jsx("h1",{className:"settings-title",children:o("settings.title")}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.appearance")}),n.jsxs("div",{className:"settings-card",children:[n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.language")}),n.jsx("span",{className:"settings-row-description",children:o("settings.languageDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Yb,{})})]}),n.jsxs("div",{className:"settings-row settings-row-theme",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.theme")}),n.jsx("span",{className:"settings-row-description",children:o("settings.themeDescription")})]}),n.jsxs("div",{className:"settings-row-control settings-row-control-stretch",children:[n.jsxs("div",{className:"settings-theme-panel",children:[n.jsxs("div",{className:"settings-theme-toggle-row",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.autoTheme")}),n.jsx(Rs,{checked:c,label:o("settings.autoTheme"),onChange:m})]}),n.jsx("span",{className:"settings-theme-note",children:o("settings.autoThemeDescription")})]}),n.jsx("div",{className:"theme-selector",children:pN.map(z=>n.jsxs("button",{type:"button",className:`theme-card ${l===z.id&&!c?"active":""}`,"aria-pressed":l===z.id&&!c,disabled:c,onClick:()=>d(z.id),children:[n.jsx("span",{className:"theme-preview",style:{background:z.color}}),n.jsx("span",{className:"theme-label",children:fN(z)}),l===z.id&&!c?n.jsx("span",{className:"theme-check",children:"✓"}):null]},z.id))})]})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.workspaceSessionSortMode")}),n.jsx("span",{className:"settings-row-description",children:o("settings.workspaceSessionSortModeDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx("select",{"aria-label":o("settings.workspaceSessionSortMode"),className:"settings-select",value:g,onChange:z=>ne(z.target.value),children:W.map(z=>n.jsx("option",{value:z.value,children:z.label},z.value))})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.showSystemFiles")}),n.jsx("span",{className:"settings-row-description",children:o("settings.showSystemFilesDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:w,label:o("settings.showSystemFiles"),onChange:Y})})]})]})]}),T?n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.serverConnection")}),n.jsxs("div",{className:"settings-card",children:[n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.serverAddress")}),n.jsx("span",{className:"settings-row-description",children:o("settings.serverDescription")})]}),n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsxs("form",{className:"settings-inline-form",onSubmit:I,children:[n.jsx("input",{"aria-label":o("settings.serverAddress"),className:"settings-text-input",value:j,onChange:z=>N(z.target.value)}),n.jsx("button",{className:"settings-button",disabled:!D,type:"submit",children:o("common.save")})]})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.autoReconnect")}),n.jsx("span",{className:"settings-row-description",children:o("settings.autoReconnectDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:f.autoReconnect,label:o("settings.autoReconnect"),onChange:L})})]})]})]}):null,n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.modelManagement")}),n.jsx("div",{className:"settings-card",children:n.jsx("div",{className:"settings-row",children:n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsx(CM,{})})})})]}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.remoteAccess")}),n.jsx("div",{className:"settings-card",children:n.jsx("div",{className:"settings-row",children:n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsx(NM,{})})})})]}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.skills")}),n.jsx("div",{className:"settings-card",children:n.jsx("div",{className:"settings-row",children:n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsx(TM,{})})})})]}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.securityPrivacy")}),n.jsxs("div",{className:"settings-card",children:[n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.defaultPermissionMode")}),n.jsx("span",{className:"settings-row-description",children:o("settings.defaultPermissionModeDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx("select",{"aria-label":o("settings.defaultPermissionMode"),className:"settings-select",value:v.defaultPermissionMode,onChange:z=>O(z.target.value),children:F.map(z=>n.jsx("option",{value:z.value,children:z.label},z.value))})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.notifyOnPermissionRequest")}),n.jsx("span",{className:"settings-row-description",children:o("settings.notifyOnPermissionRequestDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:k,label:o("settings.notifyOnPermissionRequest"),onChange:G})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.notifyOnSessionCompleted")}),n.jsx("span",{className:"settings-row-description",children:o("settings.notifyOnSessionCompletedDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:y,label:o("settings.notifyOnSessionCompleted"),onChange:te})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.notifyOnSessionFailed")}),n.jsx("span",{className:"settings-row-description",children:o("settings.notifyOnSessionFailedDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:C,label:o("settings.notifyOnSessionFailed"),onChange:K})})]})]})]}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.softwareUpdate")}),n.jsxs("div",{className:"settings-card",children:[n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.releaseChannel")}),n.jsx("span",{className:"settings-row-description",children:o("settings.releaseChannelDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsxs("select",{"aria-label":o("settings.releaseChannel"),className:"settings-select",value:f.releaseChannel,onChange:z=>_(z.target.value),children:[n.jsx("option",{value:"stable",children:o("settings.releaseStable")}),n.jsx("option",{value:"beta",children:o("settings.releaseBeta")})]})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsx("div",{className:"settings-row-label",children:n.jsx("span",{className:"settings-row-title",children:o("settings.serverUpdate")})}),n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsx(jM,{})})]}),E.isWeb?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"settings-row",children:[n.jsx("div",{className:"settings-row-label",children:n.jsx("span",{className:"settings-row-title",children:o("settings.autoCheckUpdate")})}),n.jsx("div",{className:"settings-row-control",children:n.jsx(Rs,{checked:f.autoCheckUpdate,label:o("settings.autoCheckUpdate"),onChange:Q})})]}),n.jsxs("div",{className:"settings-row",children:[n.jsx("div",{className:"settings-row-label",children:n.jsx("span",{className:"settings-row-title",children:o("settings.clientUpdate")})}),n.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:n.jsx(SM,{})})]})]})]})]}),n.jsxs("section",{className:"settings-section",children:[n.jsx("h2",{className:"settings-section-title",children:o("settings.advancedSettings")}),n.jsx("div",{className:"settings-card",children:n.jsxs("div",{className:"settings-row",children:[n.jsxs("div",{className:"settings-row-label",children:[n.jsx("span",{className:"settings-row-title",children:o("settings.parallelTaskDebug")}),n.jsx("span",{className:"settings-row-description",children:o("settings.parallelTaskDebugDescription")})]}),n.jsx("div",{className:"settings-row-control",children:n.jsx("button",{className:"settings-button",type:"button",onClick:()=>s(!0),children:o("settings.parallelTaskDebugAction")})})]})})]}),n.jsxs("div",{className:"settings-footer settings-footer-with-logout",children:[n.jsxs("span",{className:"settings-version",children:["CodingNS v",t]}),n.jsx("button",{className:"settings-button settings-button-danger settings-button-sticky",onClick:M,type:"button",children:o("common.logout")})]})]}),n.jsx(FK,{isOpen:r,onClose:()=>s(!1)})]})}function w7({model:e,appVersion:t}){const r=vr(),{section:s}=Eo(),i=m7(s)?s:null,l=[{id:"appearance",title:o("settings.appearance"),description:o("settings.appearanceSectionSummary"),value:p7(e.accountPreferences.language),icon:n.jsx(N7,{})}];return e.showServerSettings&&l.push({id:"server-connection",title:o("settings.serverConnection"),description:o("settings.serverConnectionSectionSummary"),value:Eb(e.runtimeConfig)??"",icon:n.jsx(P7,{})}),l.push({id:"model-management",title:o("settings.modelManagement"),description:o("settings.modelManagementSectionSummary"),value:o("settings.modelManagementNavValue"),icon:n.jsx(A7,{})},{id:"remote-access",title:o("settings.remoteAccess"),description:o("settings.remoteAccessSectionSummary"),value:o("settings.tailscaleBrand"),icon:n.jsx(R7,{})},{id:"skills",title:o("settings.skills"),description:o("settings.skillsSectionSummary"),value:o("settings.skillsNavValue"),icon:n.jsx(M7,{})},{id:"security-privacy",title:o("settings.securityPrivacy"),description:o("settings.securityPrivacySectionSummary"),value:g7(e.accountPreferences.defaultPermissionMode),icon:n.jsx(I7,{})},{id:"software-update",title:o("settings.softwareUpdate"),description:o("settings.softwareUpdateSectionSummary"),value:f7(e.runtimeConfig.releaseChannel),icon:n.jsx(D7,{})}),(i?l.find(d=>d.id===i)??null:null)?n.jsxs("div",{className:"settings-page settings-page-mobile mobile-page-scroll-root mobile-page-with-top-header",children:[n.jsx(fT,{title:o("settings.title")}),n.jsxs("div",{className:"settings-mobile-container",children:[i==="appearance"?n.jsx(y7,{model:e}):null,i==="model-management"?n.jsx(C7,{}):null,i==="server-connection"&&e.showServerSettings?n.jsx(k7,{model:e}):null,i==="remote-access"?n.jsx(S7,{}):null,i==="skills"?n.jsx(j7,{}):null,i==="security-privacy"?n.jsx(x7,{model:e}):null,i==="software-update"?n.jsx(T7,{model:e}):null]}),n.jsx(bT,{onLogout:e.handleLogout})]}):n.jsxs("div",{className:"settings-page settings-page-mobile mobile-page-scroll-root mobile-page-with-top-header",children:[n.jsx(fT,{title:o("settings.title")}),n.jsxs("div",{className:"settings-mobile-container",children:[n.jsx("section",{className:"settings-mobile-group-section",children:n.jsx("div",{className:"settings-mobile-list",children:l.map(d=>n.jsxs("button",{type:"button",className:"settings-mobile-nav-row",onClick:()=>r(`/settings/${d.id}`),children:[n.jsx("span",{className:"settings-mobile-nav-icon",children:d.icon}),n.jsxs("span",{className:"settings-mobile-nav-copy",children:[n.jsx("span",{className:"settings-mobile-nav-title",children:d.title}),n.jsx("span",{className:"settings-mobile-nav-description",children:d.description})]}),n.jsxs("span",{className:"settings-mobile-nav-trailing",children:[d.value?n.jsx("span",{className:"settings-mobile-nav-value",children:d.value}):null,n.jsx(E7,{})]})]},d.id))})}),n.jsx("div",{className:"settings-footer settings-footer-mobile",children:n.jsxs("span",{className:"settings-version",children:["CodingNS v",t]})})]}),n.jsx(bT,{onLogout:e.handleLogout})]})}function y7({model:e}){return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.language")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.languageDescription")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsx("div",{className:"settings-mobile-row-copy",children:n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.language")})}),n.jsx(Yb,{variant:"compact",className:"settings-mobile-language-switcher"})]})})]}),n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.theme")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.themeDescription")}),n.jsxs("div",{className:"settings-mobile-list",children:[n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.autoTheme")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.autoThemeDescription")})]}),n.jsx(Rs,{checked:e.autoTheme,label:o("settings.autoTheme"),onChange:e.applyAutoTheme})]}),pN.map(t=>{const r=e.selectedTheme===t.id&&!e.autoTheme;return n.jsxs("button",{type:"button",className:`settings-mobile-choice-row${r?" active":""}`,"aria-pressed":r,disabled:e.autoTheme,onClick:()=>e.applyTheme(t.id),children:[n.jsxs("span",{className:"settings-mobile-choice-leading",children:[n.jsx("span",{className:"settings-mobile-choice-dot",style:{background:t.color},"aria-hidden":"true"}),n.jsx("span",{className:"settings-mobile-choice-label",children:fN(t)})]}),n.jsx("span",{className:"settings-mobile-choice-indicator","aria-hidden":"true",children:r?n.jsx(L7,{}):null})]},t.id)})]})]}),n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.fileManager")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.workspaceSessionSortModeDescription")}),n.jsxs("div",{className:"settings-mobile-list",children:[n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.workspaceSessionSortMode")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.workspaceSessionSortModeDescription")})]}),n.jsx("select",{"aria-label":o("settings.workspaceSessionSortMode"),className:"settings-select settings-mobile-select",value:e.sessionDisplaySortMode,onChange:t=>e.updateSessionDisplaySortMode(t.target.value),children:e.sessionDisplaySortModeOptions.map(t=>n.jsx("option",{value:t.value,children:t.label},t.value))})]}),n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.showSystemFiles")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.showSystemFilesDescription")})]}),n.jsx(Rs,{checked:e.showSystemFiles,label:o("settings.showSystemFiles"),onChange:e.updateShowSystemFiles})]})]})]})]})}function k7({model:e}){return n.jsxs(n.Fragment,{children:[e.canConfigureServerAddress?n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.serverAddress")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.serverDescription")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("form",{className:"settings-mobile-form-stack",onSubmit:e.handleHostBaseUrlSubmit,children:[n.jsx("input",{"aria-label":o("settings.serverAddress"),className:"settings-text-input settings-mobile-input",value:e.hostBaseUrlDraft,onChange:t=>e.setHostBaseUrlDraft(t.target.value)}),n.jsx("button",{className:"settings-mobile-primary-button",disabled:!e.canSaveHostBaseUrl,type:"submit",children:o("common.save")})]})})]}):null,n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.serverConnection")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.autoReconnect")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.autoReconnectDescription")})]}),n.jsx(Rs,{checked:e.runtimeConfig.autoReconnect,label:o("settings.autoReconnect"),onChange:e.updateAutoReconnect})]})})]})]})}function x7({model:e}){return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.securityPrivacy")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.securityPrivacySectionSummary")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.defaultPermissionMode")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.defaultPermissionModeDescription")})]}),n.jsx("select",{"aria-label":o("settings.defaultPermissionMode"),className:"settings-select settings-mobile-select",value:e.accountPreferences.defaultPermissionMode,onChange:t=>e.updateDefaultPermissionMode(t.target.value),children:e.permissionModeOptions.map(t=>n.jsx("option",{value:t.value,children:t.label},t.value))})]})})]}),n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.notificationSettings")}),n.jsx("p",{className:"settings-mobile-group-note",children:o("settings.notificationSettingsDescription")}),n.jsxs("div",{className:"settings-mobile-list",children:[n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.notifyOnPermissionRequest")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.notifyOnPermissionRequestDescription")})]}),n.jsx(Rs,{checked:e.notifyOnPermissionRequest,label:o("settings.notifyOnPermissionRequest"),onChange:e.updateNotifyOnPermissionRequest})]}),n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.notifyOnSessionCompleted")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.notifyOnSessionCompletedDescription")})]}),n.jsx(Rs,{checked:e.notifyOnSessionCompleted,label:o("settings.notifyOnSessionCompleted"),onChange:e.updateNotifyOnSessionCompleted})]}),n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.notifyOnSessionFailed")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.notifyOnSessionFailedDescription")})]}),n.jsx(Rs,{checked:e.notifyOnSessionFailed,label:o("settings.notifyOnSessionFailed"),onChange:e.updateNotifyOnSessionFailed})]})]})]})]})}function S7(){return n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.remoteAccess")}),n.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-remote-shell",children:n.jsx(NM,{})})]})}function C7(){return n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.modelManagement")}),n.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-model-shell",children:n.jsx(CM,{})})]})}function j7(){return n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.skills")}),n.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-skill-shell",children:n.jsx(TM,{})})]})}function T7({model:e}){return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.softwareUpdate")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsxs("div",{className:"settings-mobile-row-copy",children:[n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.releaseChannel")}),n.jsx("span",{className:"settings-mobile-row-description",children:o("settings.releaseChannelDescription")})]}),n.jsxs("select",{"aria-label":o("settings.releaseChannel"),className:"settings-select settings-mobile-select",value:e.runtimeConfig.releaseChannel,onChange:t=>e.updateReleaseChannel(t.target.value),children:[n.jsx("option",{value:"stable",children:o("settings.releaseStable")}),n.jsx("option",{value:"beta",children:o("settings.releaseBeta")})]})]})})]}),n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.serverUpdate")}),n.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-update-shell",children:n.jsx(jM,{})})]}),e.platform.isWeb?null:n.jsxs("section",{className:"settings-mobile-group-section",children:[n.jsx("h2",{className:"settings-mobile-group-title",children:o("settings.clientUpdate")}),n.jsx("div",{className:"settings-mobile-list",children:n.jsxs("div",{className:"settings-mobile-form-row",children:[n.jsx("div",{className:"settings-mobile-row-copy",children:n.jsx("span",{className:"settings-mobile-row-title",children:o("settings.autoCheckUpdate")})}),n.jsx(Rs,{checked:e.runtimeConfig.autoCheckUpdate,label:o("settings.autoCheckUpdate"),onChange:e.updateAutoCheckUpdate})]})}),n.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-update-shell",children:n.jsx(SM,{})})]})]})}function bT({onLogout:e}){return n.jsx("div",{className:"settings-mobile-sticky-footer",children:n.jsx("button",{type:"button",className:"settings-mobile-danger-button settings-mobile-danger-button-sticky",onClick:e,children:o("common.logout")})})}function Rs({checked:e,label:t,onChange:r}){return n.jsxs("label",{className:"settings-mobile-switch","aria-label":t,children:[n.jsx("input",{type:"checkbox","aria-label":t,checked:e,onChange:s=>r(s.target.checked)}),n.jsx("span",{className:"settings-mobile-switch-track","aria-hidden":"true",children:n.jsx("span",{className:"settings-mobile-switch-thumb"})})]})}function N7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M10 3.5a6.5 6.5 0 1 0 6.5 6.5c0-.8-.6-1.4-1.4-1.4h-1.6A1.5 1.5 0 0 1 12 7.1V5.5c0-1.1-.9-2-2-2Z"}),n.jsx("circle",{cx:"6.6",cy:"9.2",r:".8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"8.8",cy:"6.8",r:".8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"12.1",cy:"6.6",r:".8",fill:"currentColor",stroke:"none"})]})}function P7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M4 7.5 10 4l6 3.5v5L10 16l-6-3.5v-5Z"}),n.jsx("path",{d:"M10 9.5V16"}),n.jsx("path",{d:"M4 7.5 10 11l6-3.5"})]})}function D7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("rect",{x:"3.5",y:"4",width:"13",height:"9.5",rx:"2.2"}),n.jsx("path",{d:"M7 16h6"}),n.jsx("path",{d:"M10 13.5V16"}),n.jsx("path",{d:"m8 8 2 2 3-3"})]})}function R7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("circle",{cx:"10",cy:"10",r:"5.8"}),n.jsx("path",{d:"M10 4.2c1.5 1.3 2.4 3.5 2.4 5.8s-.9 4.5-2.4 5.8c-1.5-1.3-2.4-3.5-2.4-5.8s.9-4.5 2.4-5.8Z"}),n.jsx("path",{d:"M4.6 8.1h10.8"}),n.jsx("path",{d:"M4.6 11.9h10.8"})]})}function M7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[n.jsx("rect",{x:"3.5",y:"4",width:"13",height:"12",rx:"2.5"}),n.jsx("path",{d:"M6 7h8M6 10h8M6 13h4",strokeLinecap:"round"}),n.jsx("path",{d:"m12.7 13.2 1.4 1.4 2.6-2.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function A7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[n.jsx("rect",{x:"3.5",y:"4",width:"13",height:"12",rx:"2.5"}),n.jsx("path",{d:"M6.2 8.1h7.6M6.2 11.9h4.1",strokeLinecap:"round"}),n.jsx("path",{d:"m12.8 11.3 1.3 1.3 2-2.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function I7(){return n.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M10 3.2 15 5v4.4c0 3-1.9 5.8-5 7.4-3.1-1.6-5-4.4-5-7.4V5l5-1.8Z"}),n.jsx("path",{d:"m8.3 9.8 1.2 1.2 2.4-2.5"})]})}function E7(){return n.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:n.jsx("path",{d:"m4 2 4 4-4 4"})})}function L7(){return n.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:n.jsx("path",{d:"m3.5 8.2 2.6 2.6 6-6"})})}function F7({runtimeKey:e,children:t}){return n.jsx("div",{children:t},e)}function _7(){const e=dL();return n.jsx(F7,{runtimeKey:e,children:n.jsx(Ug,{})})}function O7(){const e=gu(r=>r.session),t=oi();if(!e){const r=`${t.pathname}${t.search}`;return n.jsx($a,{to:`/login?returnTo=${encodeURIComponent(r)}`,replace:!0})}return n.jsx(_7,{})}function vT(){const{shellMode:e}=Pr();return n.jsx($a,{to:e==="mobile"?"/workspaces":"/landing",replace:!0})}const B7=[{path:"/bootstrap",element:n.jsx(yL,{})},{path:"/login",element:n.jsx(NL,{})},{path:"/desktop-window-preview",element:n.jsx(u9,{})},{path:"/",element:n.jsx(O7,{}),children:[{path:"desktop-window/:windowId",element:n.jsx(f9,{})},{element:n.jsx(RK,{}),children:[{index:!0,element:n.jsx(vT,{})},{path:"landing",element:n.jsx(IK,{})},{path:"workspaces",element:n.jsx(G9,{})},{path:"workspaces/:workspaceId",element:n.jsx(xK,{})},{path:"workspaces/:workspaceId/debug",element:n.jsx(PK,{})},{path:"workspaces/:workspaceId/sessions",element:n.jsx(N9,{})},{path:"workspaces/:workspaceId/sessions/:sessionId",element:n.jsx(FG,{})},{path:"workspaces/:workspaceId/tools",element:n.jsx(_9,{})},{path:"workspaces/:workspaceId/tools/files",element:n.jsx(E9,{})},{path:"workspaces/:workspaceId/tools/git",element:n.jsx(L9,{})},{path:"workspaces/:workspaceId/tools/processes",element:n.jsx(F9,{})},{path:"workspaces/:workspaceId/terminals",lazy:async()=>({Component:(await Ml(()=>import("./TerminalPage-CgrfstRm.js"),__vite__mapDeps([0,1]))).TerminalPage})},{path:"workspaces/:workspaceId/butler",element:n.jsx(b$,{})},{path:"settings",element:n.jsx(gT,{})},{path:"settings/:section",element:n.jsx(gT,{})},{path:"*",element:n.jsx(vT,{})}]}]}];function W7(){return y1(B7)}function U7(){const e=ca(r=>r.profile.language),t=p.useMemo(()=>W7(),[]);return n.jsx(W1,{children:n.jsx(oL,{children:n.jsx(Y1,{language:e,children:n.jsx(nL,{children:n.jsxs(aL,{children:[n.jsx(cL,{}),n.jsx(D1,{router:t})]})})})})})}eE().finally(()=>{FA.createRoot(document.getElementById("root")).render(n.jsx(U7,{}))});export{qN as C,Hl as M,hG as T,br as a,li as b,cv as c,vr as d,Eo as e,Pr as f,_T as g,Qn as h,q7 as i,Er as j,n as k,uG as l,Y7 as m,Fj as n,V7 as o,K7 as p,$n as q,p as r,uv as s,o as t,nr as u,$7 as v,As as w,dG as x,G7 as y,z7 as z};
|