@evandu/super-pi 0.1.271 → 0.1.272
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/client/.super-pi-client-sources.json +5 -5
- package/dist/client/assets/{CodeMirrorEditor-Q77Plbqw.js → CodeMirrorEditor-BOfFOmcv.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-C0XYcNpE.js → GitDiffEditor-DaN0Ye4q.js} +1 -1
- package/dist/client/assets/{index-CoLvWsuI.js → index-BsfNx6DV.js} +5 -5
- package/dist/client/index.html +1 -1
- package/dist/server/application/run-service.js +2 -2
- package/dist/server/managed-model-adapter.js +10 -2
- package/dist/server/managed-servers.d.ts +1 -0
- package/dist/server/managed-servers.js +16 -4
- package/dist/server/turn-failure.d.ts +2 -0
- package/dist/server/turn-failure.js +11 -0
- package/dist/server/types.d.ts +1 -0
- package/dist/server/ws-server.js +2 -0
- package/dist/shared/managed-servers.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-DlPa5gNa.js","assets/CodeMirrorEditor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-DlPa5gNa.js","assets/CodeMirrorEditor-BOfFOmcv.js","assets/GitDiffEditor-DaN0Ye4q.js","assets/dist-ZAR1Tu2c.js","assets/dist-i79xiXVk.js","assets/GitDiffEditor-CpoDDQrA.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ne=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function re(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ne)}catch(e){ne(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function F(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else re(F.bind(null,e))}var ie={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ie,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=F,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=re,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),s=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=a(),n=r(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(o(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),F=Symbol.for(`react.memo`),ie=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ne:return`Suspense`;case re:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case F:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case ie:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?fp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=fp(t),e=pp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=pp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),lh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -7,7 +7,7 @@ import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.
|
|
|
7
7
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ne=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Me(n):``}function Fe(e,t){switch(e.tag){case 26:case 27:case 5:return Me(e.type);case 16:return Me(`Lazy`);case 13:return e.child!==t&&t!==null?Me(`Suspense Fallback`):Me(`Suspense`);case 19:return Me(`SuspenseList`);case 0:case 15:return Pe(e.type,!1);case 11:return Pe(e.type.render,!1);case 1:return Pe(e.type,!0);case 31:return Me(`Activity`);case 30:return Me(`ViewTransition`);default:return``}}function Ie(e){try{var t=``,n=null;do t+=Fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
8
|
Error generating stack: `+e.message+`
|
|
9
9
|
`+e.stack}}var L=Object.prototype.hasOwnProperty,Le=t.unstable_scheduleCallback,Re=t.unstable_cancelCallback,ze=t.unstable_shouldYield,Be=t.unstable_requestPaint,Ve=t.unstable_now,He=t.unstable_getCurrentPriorityLevel,Ue=t.unstable_ImmediatePriority,We=t.unstable_UserBlockingPriority,Ge=t.unstable_NormalPriority,Ke=t.unstable_LowPriority,qe=t.unstable_IdlePriority,Je=t.log,Ye=t.unstable_setDisableYieldValue,Xe=null,Ze=null;function Qe(e){if(typeof Je==`function`&&Ye(e),Ze&&typeof Ze.setStrictMode==`function`)try{Ze.setStrictMode(Xe,e)}catch{}}var $e=Math.clz32?Math.clz32:nt,et=Math.log,tt=Math.LN2;function nt(e){return e>>>=0,e===0?32:31-(et(e)/tt|0)|0}var rt=256,it=262144,at=4194304;function ot(e){var t=e&42;if(t!==0)return t;switch(e&-e){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function st(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ot(n))):i=ot(o):i=ot(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ot(n))):i=ot(o)):i=ot(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ct(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function lt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-$e(n),i=1<<r;t|=e[r],n&=~i}return t}function ut(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function dt(){var e=at;return at<<=1,!(at&62914560)&&(at=4194304),e}function ft(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function pt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function mt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-$e(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&ht(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function ht(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-$e(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function gt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-$e(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function _t(e,t){var n=t&-t;return n=n&42?1:vt(n),(n&(e.suspendedLanes|t))===0?n:0}function vt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function yt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function bt(){var e=he.p;return e===0?(e=window.event,e===void 0?32:Th(e.type)):e}function xt(e,t){var n=he.p;try{return he.p=e,t()}finally{he.p=n}}var St=Math.random().toString(36).slice(2),Ct=`__reactFiber$`+St,wt=`__reactProps$`+St,Tt=`__reactContainer$`+St,Et=`__reactEvents$`+St,Dt=`__reactListeners$`+St,Ot=`__reactHandles$`+St,kt=`__reactResources$`+St,At=`__reactMarker$`+St,jt=`__reactLoad$`+St;function Mt(e){delete e[Ct],delete e[wt],delete e[Dt],delete e[Ot]}function Nt(e){var t;if(t=e[Ct])return t;for(var n=e.parentNode;n;){if(t=n[Tt]||n[Ct]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[Ct])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function Pt(e){if(e=e[Ct]||e[Tt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ft(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function It(e){var t=e[kt];return t||=e[kt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Lt(e){e[At]=!0}function Rt(e){e[jt]=void 0}var zt=new Set,Bt={};function Vt(e,t){Ht(e,t),Ht(e+`Capture`,t)}function Ht(e,t){for(Bt[e]=t,e=0;e<t.length;e++)zt.add(t[e])}var Ut=RegExp(`^[: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]*$`),Wt={},Gt={};function Kt(e){return L.call(Gt,e)?!0:L.call(Wt,e)?!1:Ut.test(e)?Gt[e]=!0:(Wt[e]=!0,!1)}var qt=!1;function Jt(){var e=qt;return qt=!1,e}function Yt(e,t,n){if(Kt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Xt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Zt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Qt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function $t(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function en(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function tn(e){if(!e._valueTracker){var t=$t(e)?`checked`:`value`;e._valueTracker=en(e,t,``+e[t])}}function nn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=$t(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var rn=/[\n"\\]/g;function an(e){return e.replace(rn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function on(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Qt(t)):e.value!==``+Qt(t)&&(e.value=``+Qt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):cn(e,Qt(n)):o===`number`&&e.value==t?cn(e,Qt(e.value)):cn(e,Qt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Qt(s):e.removeAttribute(`name`)}function sn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){tn(e);return}n=n==null?``:``+Qt(n),t=t==null?n:``+Qt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),tn(e)}function cn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function ln(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Qt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function un(e,t,n){t!=null&&(t=``+Qt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Qt(n)}function dn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(me(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=Qt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),tn(e)}function fn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function mn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||pn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function hn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,qt=!0);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&(mn(e,i,r),qt=!0)}else for(var a in t)t.hasOwnProperty(a)&&mn(e,a,t[a])}function gn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){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 _n=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`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`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`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`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`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`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),vn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yn(e){return vn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function bn(){}var xn=null;function Sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cn=null,wn=null;function Tn(e){var t=Pt(e);if(t&&(e=t.stateNode)){var n=e[wt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(on(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+an(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[wt]||null;if(!i)throw Error(o(90));on(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&nn(r)}break a;case`textarea`:un(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&ln(e,!!n.multiple,t,!1)}}}var En=!1;function Dn(e,t,n){if(En)return e(t,n);En=!0;try{return e(t)}finally{if(En=!1,(Cn!==null||wn!==null)&&(Rd(),Cn&&(t=Cn,e=wn,wn=Cn=null,Tn(t),e)))for(t=0;t<e.length;t++)Tn(e[t])}}function On(e,t){var n=e.stateNode;if(n===null)return null;var r=n[wt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var kn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,An=!1;if(kn)try{var jn={};Object.defineProperty(jn,"passive",{get:function(){An=!0}}),window.addEventListener(`test`,jn,jn),window.removeEventListener(`test`,jn,jn)}catch{An=!1}var Mn=null,Nn=null,Pn=null;function Fn(){if(Pn)return Pn;var e,t=Nn,n=t.length,r,i=`value`in Mn?Mn.value:Mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Pn=i.slice(e,1<r?1-r:void 0)}function In(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ln(){return!0}function Rn(){return!1}function zn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Ln:Rn,this.isPropagationStopped=Rn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Ln)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Ln)},persist:function(){},isPersistent:Ln}),t}var Bn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vn=zn(Bn),Hn=D({},Bn,{view:0,detail:0}),Un=zn(Hn),Wn,Gn,Kn,qn=D({},Hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ir,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Kn&&(Kn&&e.type===`mousemove`?(Wn=e.screenX-Kn.screenX,Gn=e.screenY-Kn.screenY):Gn=Wn=0,Kn=e),Wn)},movementY:function(e){return`movementY`in e?e.movementY:Gn}}),Jn=zn(qn),Yn=zn(D({},qn,{dataTransfer:0})),Xn=zn(D({},Hn,{relatedTarget:0})),Zn=zn(D({},Bn,{animationName:0,elapsedTime:0,pseudoElement:0})),Qn=zn(D({},Bn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),$n=zn(D({},Bn,{data:0})),er={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},tr={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`},nr={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function rr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=nr[e])?!!t[e]:!1}function ir(){return rr}var ar=zn(D({},Hn,{key:function(e){if(e.key){var t=er[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=In(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?tr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ir,charCode:function(e){return e.type===`keypress`?In(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?In(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),or=zn(D({},qn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),sr=zn(D({},Bn,{submitter:0})),cr=zn(D({},Hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ir})),lr=zn(D({},Bn,{propertyName:0,elapsedTime:0,pseudoElement:0})),ur=zn(D({},qn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),dr=zn(D({},Bn,{newState:0,oldState:0,source:0})),fr=[9,13,27,32],pr=kn&&`CompositionEvent`in window,mr=null;kn&&`documentMode`in document&&(mr=document.documentMode);var hr=kn&&`TextEvent`in window&&!mr,gr=kn&&(!pr||mr&&8<mr&&11>=mr),_r=` `,vr=!1;function yr(e,t){switch(e){case`keyup`:return fr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function br(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var xr=!1;function Sr(e,t){switch(e){case`compositionend`:return br(t);case`keypress`:return t.which===32?(vr=!0,_r):null;case`textInput`:return e=t.data,e===_r&&vr?null:e;default:return null}}function Cr(e,t){if(xr)return e===`compositionend`||!pr&&yr(e,t)?(e=Fn(),Pn=Nn=Mn=null,xr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return gr&&t.locale!==`ko`?null:t.data;default:return null}}var wr={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 Tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!wr[e.type]:t===`textarea`}function Er(e,t,n,r){Cn?wn?wn.push(r):wn=[r]:Cn=r,t=Yf(t,`onChange`),0<t.length&&(n=new Vn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Dr=null,Or=null;function kr(e){Vf(e,0)}function Ar(e){if(nn(Ft(e)))return e}function jr(e,t){if(e===`change`)return t}var Mr=!1;if(kn){var Nr;if(kn){var Pr=`oninput`in document;if(!Pr){var Fr=document.createElement(`div`);Fr.setAttribute(`oninput`,`return;`),Pr=typeof Fr.oninput==`function`}Nr=Pr}else Nr=!1;Mr=Nr&&(!document.documentMode||9<document.documentMode)}function Ir(){Dr&&(Dr.detachEvent(`onpropertychange`,Lr),Or=Dr=null)}function Lr(e){if(e.propertyName===`value`&&Ar(Or)){var t=[];Er(t,Or,e,Sn(e)),Dn(kr,t)}}function Rr(e,t,n){e===`focusin`?(Ir(),Dr=t,Or=n,Dr.attachEvent(`onpropertychange`,Lr)):e===`focusout`&&Ir()}function zr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Ar(Or)}function Br(e,t){if(e===`click`)return Ar(t)}function Vr(e,t){if(e===`input`||e===`change`)return Ar(t)}function Hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Ur=typeof Object.is==`function`?Object.is:Hr;function Wr(e,t){if(Ur(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!L.call(t,i)||!Ur(e[i],t[i]))return!1}return!0}function Gr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Kr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function qr(e,t){var n=Kr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Kr(n)}}function Jr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Jr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Gr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gr(e.document)}return t}function Xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Zr=kn&&`documentMode`in document&&11>=document.documentMode,Qr=null,$r=null,ei=null,ti=!1;function ni(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ti||Qr==null||Qr!==Gr(r)||(r=Qr,`selectionStart`in r&&Xr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ei&&Wr(ei,r)||(ei=r,r=Yf($r,`onSelect`),0<r.length&&(t=new Vn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Qr)))}function ri(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ii={animationend:ri(`Animation`,`AnimationEnd`),animationiteration:ri(`Animation`,`AnimationIteration`),animationstart:ri(`Animation`,`AnimationStart`),transitionrun:ri(`Transition`,`TransitionRun`),transitionstart:ri(`Transition`,`TransitionStart`),transitioncancel:ri(`Transition`,`TransitionCancel`),transitionend:ri(`Transition`,`TransitionEnd`)},ai={},oi={};kn&&(oi=document.createElement(`div`).style,`AnimationEvent`in window||(delete ii.animationend.animation,delete ii.animationiteration.animation,delete ii.animationstart.animation),`TransitionEvent`in window||delete ii.transitionend.transition);function si(e){if(ai[e])return ai[e];if(!ii[e])return e;var t=ii[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in oi)return ai[e]=t[n];return e}var ci=si(`animationend`),R=si(`animationiteration`),li=si(`animationstart`),ui=si(`transitionrun`),di=si(`transitionstart`),fi=si(`transitioncancel`),pi=si(`transitionend`),mi=new Map,hi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError 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(` `);hi.push(`scrollEnd`);function gi(e,t){mi.set(e,t),Vt(t,[e])}var _i=0;function vi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=yd.identifierPrefix;var n=_i++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function yi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Dd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function bi(e,t){return e=yi(e),t=yi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var xi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Si=[],Ci=0,wi=0;function Ti(){for(var e=Ci,t=wi=Ci=0;t<e;){var n=Si[t];Si[t++]=null;var r=Si[t];Si[t++]=null;var i=Si[t];Si[t++]=null;var a=Si[t];if(Si[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ki(n,i,a)}}function Ei(e,t,n,r){Si[Ci++]=e,Si[Ci++]=t,Si[Ci++]=n,Si[Ci++]=r,wi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Di(e,t,n,r){return Ei(e,t,n,r),Ai(e)}function Oi(e,t){return Ei(e,null,null,t),Ai(e)}function ki(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-$e(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Ai(e){if(50<Od)throw Od=0,kd=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ji={};function Mi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ni(e,t,n,r){return new Mi(e,t,n,r)}function Pi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Fi(e,t){var n=e.alternate;return n===null?(n=Ni(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Ii(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function z(e,t,n,r,i,a){var s=0;if(r=e,typeof r==`function`)Pi(r)&&(s=1);else if(typeof r==`string`)s=Ym(e,n,Se.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ae:return e=Ni(31,n,t,i),e.elementType=ae,e.lanes=a,e;case j:return Li(n.children,i,a,t);case M:s=8,i|=24;break;case N:return e=Ni(12,n,t,i|2),e.elementType=N,e.lanes=a,e;case ne:return e=Ni(13,n,t,i),e.elementType=ne,e.lanes=a,e;case re:return e=Ni(19,n,t,i),e.elementType=re,e.lanes=a,e;case oe:case ce:return e=i|32,e=Ni(30,n,t,e),e.elementType=ce,e.lanes=a,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case P:s=10;break a;case ee:s=9;break a;case te:s=11;break a;case F:s=14;break a;case ie:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=Ni(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function Li(e,t,n,r){return e=Ni(7,e,r,t),e.lanes=n,e}function Ri(e,t,n){return e=Ni(6,e,null,t),e.lanes=n,e}function zi(e){var t=Ni(18,null,null,0);return t.stateNode=e,t}function Bi(e,t,n){return t=Ni(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Vi=new WeakMap;function Hi(e,t){if(typeof e==`object`&&e){var n=Vi.get(e);return n===void 0?(t={value:e,source:t,stack:Ie(t)},Vi.set(e,t),t):n}return{value:e,source:t,stack:Ie(t)}}var Ui=[],Wi=0,Gi=null,Ki=0,qi=[],Ji=0,Yi=null,Xi=1,Zi=``;function Qi(e,t){Ui[Wi++]=Ki,Ui[Wi++]=Gi,Gi=e,Ki=t}function $i(e,t,n){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Yi=e;var r=Xi;e=Zi;var i=32-$e(r)-1;r&=~(1<<i),n+=1;var a=32-$e(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Xi=1<<32-$e(t)+i|n<<i|r,Zi=a+e}else Xi=1<<a|n<<i|r,Zi=e}function ea(e){e.return!==null&&(Qi(e,1),$i(e,1,0))}function ta(e){for(;e===Gi;)Gi=Ui[--Wi],Ui[Wi]=null,Ki=Ui[--Wi],Ui[Wi]=null;for(;e===Yi;)Yi=qi[--Ji],qi[Ji]=null,Zi=qi[--Ji],qi[Ji]=null,Xi=qi[--Ji],qi[Ji]=null}function na(e,t){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Xi=t.id,Zi=t.overflow,Yi=e}var ra=null,ia=null,aa=!1,oa=null,sa=!1,ca=Error(o(519));function la(e){throw ha(Hi(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),ca}function ua(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Ct]=e,t[wt]=r,n){case`dialog`:Hf(`cancel`,t),Hf(`close`,t);break;case`iframe`:case`object`:case`embed`:Hf(`load`,t);break;case`video`:case`audio`:for(n=0;n<zf.length;n++)Hf(zf[n],t);break;case`source`:Hf(`error`,t);break;case`img`:case`image`:case`link`:Hf(`error`,t),Hf(`load`,t);break;case`details`:Hf(`toggle`,t);break;case`input`:Hf(`invalid`,t),sn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Hf(`invalid`,t);break;case`textarea`:Hf(`invalid`,t),dn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||tp(t.textContent,n)?(r.popover!=null&&(Hf(`beforetoggle`,t),Hf(`toggle`,t)),r.onScroll!=null&&Hf(`scroll`,t),r.onScrollEnd!=null&&Hf(`scrollend`,t),r.onClick!=null&&(t.onclick=bn),t=!0):t=!1,t||la(e,!0)}function da(e){for(ra=e.return;ra;)switch(ra.tag){case 5:case 31:case 13:sa=!1;return;case 27:case 3:sa=!0;return;default:ra=ra.return}}function fa(e){if(e!==ra)return!1;if(!aa)return da(e),aa=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||hp(e.type,e.memoizedProps)),n=!n),n&&ia&&la(e),da(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ia=pm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ia=pm(e)}else t===27?(t=ia,wp(e.type)?(e=fm,fm=null,ia=e):ia=t):ia=ra?dm(e.stateNode.nextSibling):null;return!0}function pa(){ia=ra=null,aa=!1}function ma(){var e=oa;return e!==null&&(dd===null?dd=e:dd.push.apply(dd,e),oa=null),e}function ha(e){oa===null?oa=[e]:oa.push(e)}var ga=ye(null),_a=null,va=null;function ya(e,t,n){xe(ga,t._currentValue),t._currentValue=n}function ba(e){e._currentValue=ga.current,be(ga)}function xa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Sa(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),xa(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),xa(s,n,e),s=null}else i.tag===13&&i.memoizedState!==null&&i.memoizedState.dehydrated===null?(i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),xa(i.return,n,e),s=i.child,s=s===null?null:s.sibling):s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function Ca(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;Ur(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===Te.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[lh]:e.push(lh))}i=i.return}return e!==null&&Sa(t,e,n,r),t.flags|=262144,e!==null}function wa(e){for(e=e.firstContext;e!==null;){if(!Ur(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ta(e){_a=e,va=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ea(e){return Oa(_a,e)}function Da(e,t){return _a===null&&Ta(e),Oa(e,t)}function Oa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},va===null){if(e===null)throw Error(o(308));va=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else va=va.next=t;return n}var ka=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Aa=t.unstable_scheduleCallback,ja=t.unstable_NormalPriority,Ma={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Na(){return{controller:new ka,data:new Map,refCount:0}}function Pa(e){e.refCount--,e.refCount===0&&Aa(ja,function(){e.controller.abort()})}function Fa(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var B=null;function V(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ia=null,La=0,Ra=0,za=null;function Ba(e,t){if(Ia===null){var n=Ia=[];La=0,Ra=Pf(),za={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return La++,t.then(Va,Va),t}function Va(){if(--La===0&&(B=null,Ia!==null)){za!==null&&(za.status=`fulfilled`);var e=Ia;Ia=null,Ra=0,za=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ha(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ua=I.S;I.S=function(e,t){if(md=Ve(),typeof t==`object`&&t&&typeof t.then==`function`&&Ba(e,t),B!==null)for(var n=bf;n!==null;)Fa(n,B),n=n.next;if(n=e.types,n!==null){for(var r=bf;r!==null;)Fa(r,n),r=r.next;if(Ra!==0){r=B,r===null&&(r=B=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ua!==null&&Ua(e,t)};var Wa=ye(null);function Ga(){var e=Wa.current;return e===null?Yu.pooledCache:e}function Ka(e,t){t===null?xe(Wa,Wa.current):xe(Wa,t.pool)}function qa(){var e=Ga();return e===null?null:{parent:Ma._currentValue,pool:e}}var Ja=Error(o(460)),Ya=Error(o(474)),Xa=Error(o(542)),Za={then:function(){}};function Qa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function $a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(bn,bn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ro(e),e===void 0&&!(`reason`in t)?Error(o(600)):e;default:if(typeof t.status==`string`)t.then(bn,bn);else{if(e=Yu,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ro(e),e}throw to=t,Ja}}function eo(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(to=e,Ja):e}}var to=null;function no(){if(to===null)throw Error(o(459));var e=to;return to=null,e}function ro(e){if(e===Ja||e===Xa)throw Error(o(483))}var io=null,ao=0;function oo(e){var t=ao;return ao+=1,io===null&&(io=[]),$a(io,e,t)}function H(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function U(e,t){throw t.$$typeof===O?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function W(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=Fi(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ri(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===j?(e=d(e,t,n.props.children,r,n.key),H(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===ie&&eo(a)===t.type)?(t=i(t,n.props),H(t,n),t.return=e,t):(t=z(n.type,n.key,n.props,null,e.mode,r),H(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Bi(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=Li(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ri(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=z(t.type,t.key,t.props,null,e.mode,n),H(n,t),n.return=e,n;case A:return t=Bi(t,e.mode,n),t.return=e,t;case ie:return t=eo(t),f(e,t,n)}if(me(t)||de(t))return t=Li(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,oo(t),n);if(t.$$typeof===P)return f(e,Da(e,t),n);U(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case ie:return n=eo(n),p(e,t,n,r)}if(me(n)||de(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,oo(n),r);if(n.$$typeof===P)return p(e,t,Da(e,n),r);U(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case ie:return r=eo(r),m(e,t,n,r,i)}if(me(r)||de(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,oo(r),i);if(r.$$typeof===P)return m(e,t,n,Da(t,r),i);U(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),aa&&Qi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return aa&&Qi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),aa&&Qi(i,h),l}function g(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),aa&&Qi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return aa&&Qi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),aa&&Qi(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===j&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case k:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),H(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ie&&eo(l)===r.type){n(e,r.sibling),c=i(r,a.props),H(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===j?(c=Li(a.props.children,e.mode,c,a.key),H(c,a),c.return=e,e=c):(c=z(a.type,a.key,a.props,null,e.mode,c),H(c,a),c.return=e,e=c)}return s(e);case A:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(a,e.mode,c),c.return=e,e=c}return s(e);case ie:return a=eo(a),_(e,r,a,c)}if(me(a))return h(e,r,a,c);if(de(a)){if(l=de(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,oo(a),c);if(a.$$typeof===P)return _(e,r,Da(e,a),c);U(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Ri(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ja||t===Xa)throw t;var a=Ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var G=W(!0),K=W(!1),so=!1;function co(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function uo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function fo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ju&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ai(e),ki(e,null,n),t}return Ei(e,r,t,n),Ai(e)}function po(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,gt(e,n)}}function mo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ho=!1;function q(){if(ho){var e=za;if(e!==null)throw e}}function go(e,t,n,r){ho=!1;var i=e.updateQueue;so=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Zu&f)===f:(r&f)===f){f!==0&&f===Ra&&(ho=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:so=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ad|=o,e.lanes=o,e.memoizedState=d}}function J(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function _o(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)J(n[e],t)}var vo=ye(null),yo=ye(0);function bo(e,t){e=rd,xe(yo,e),xe(vo,t),rd=e|t.baseLanes}function xo(){xe(yo,rd),xe(vo,vo.current)}function So(){rd=yo.current,be(vo),be(yo)}var Co=ye(null),wo=null;function To(e){var t=e.alternate;xe(Ao,Ao.current&1),xe(Co,e),wo===null&&(t===null||vo.current!==null||t.memoizedState!==null)&&(wo=e)}function Eo(e){xe(Ao,Ao.current),xe(Co,e),wo===null&&(wo=e)}function Do(e){e.tag===22?(xe(Ao,Ao.current),xe(Co,e),wo===null&&(wo=e)):Oo()}function Oo(){xe(Ao,Ao.current),xe(Co,Co.current)}function ko(e){be(Co),wo===e&&(wo=null),be(Ao)}var Ao=ye(0);function jo(e,t){xe(Co,Co.current),xe(Ao,t)}function Mo(e){be(Ao),be(Co),wo===e&&(wo=null)}function No(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cm(n)||lm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Po=0,Fo=null,Io=null,Lo=null,Ro=!1,zo=!1,Bo=!1,Vo=0,Ho=0,Uo=null,Wo=0;function Go(){throw Error(o(321))}function Ko(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ur(e[n],t[n]))return!1;return!0}function qo(e,t,n,r,i,a){return Po=a,Fo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?cc:lc,Bo=!1,a=n(r,i),Bo=!1,zo&&(a=Yo(t,n,r,i)),Jo(e),a}function Jo(e){I.H=sc;var t=Io!==null&&Io.next!==null;if(Po=0,Lo=Io=Fo=null,Ro=!1,Ho=0,Uo=null,t)throw Error(o(300));e===null||Ec||(e=e.dependencies,e!==null&&wa(e)&&(Ec=!0))}function Yo(e,t,n,r){Fo=e;var i=0;do{if(zo&&(Uo=null),Ho=0,zo=!1,25<=i)throw Error(o(301));if(i+=1,Lo=Io=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}I.H=uc,a=t(n,r)}while(zo);return a}function Xo(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?rs(t):t,e=e.useState()[0],(Io===null?null:Io.memoizedState)!==e&&(Fo.flags|=1024),t}function Zo(){var e=Vo!==0;return Vo=0,e}function Qo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function $o(e){if(Ro){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ro=!1}Po=0,Lo=Io=Fo=null,zo=!1,Ho=Vo=0,Uo=null}function es(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lo===null?Fo.memoizedState=Lo=e:Lo=Lo.next=e,Lo}function ts(){if(Io===null){var e=Fo.alternate;e=e===null?null:e.memoizedState}else e=Io.next;var t=Lo===null?Fo.memoizedState:Lo.next;if(t!==null)Lo=t,Io=e;else{if(e===null)throw Fo.alternate===null?Error(o(467)):Error(o(310));Io=e,e={memoizedState:Io.memoizedState,baseState:Io.baseState,baseQueue:Io.baseQueue,queue:Io.queue,next:null},Lo===null?Fo.memoizedState=Lo=e:Lo=Lo.next=e}return Lo}function ns(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function rs(e){var t=Ho;return Ho+=1,Uo===null&&(Uo=[]),e=$a(Uo,e,t),t=Fo,(Lo===null?t.memoizedState:Lo.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?cc:lc),e}function is(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return rs(e);if(e.$$typeof===le)return;if(e.$$typeof===P)return Ea(e)}throw Error(o(438,String(e)))}function Y(e){var t=null,n=Fo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Fo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ns(),Fo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=se;return t.index++,n}function as(e,t){return typeof t==`function`?t(e):t}function os(e){return ss(ts(),Io,e)}function ss(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Po&f)===f:(Zu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ra&&(d=!0);else if((Po&p)===p){u=u.next,p===Ra&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,Fo.lanes|=p,ad|=p;f=u.action,Bo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,Fo.lanes|=f,ad|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!Ur(a,e.memoizedState)&&(Ec=!0,d&&(n=za,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function cs(e){var t=ts(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);Ur(a,t.memoizedState)||(Ec=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function ls(e,t,n){var r=Fo,i=ts(),a=aa;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!Ur((Io||i).memoizedState,n);if(s&&(i.memoizedState=n,Ec=!0),i=i.queue,Ps(fs.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||s||Lo!==null&&!!(Lo.memoizedState.tag&1),ks(e?9:8,{destroy:void 0},ds.bind(null,r,i,n,t),null),e){if(r.flags|=2048,Yu===null)throw Error(o(349));a||Po&127||us(r,t,n)}return n}function us(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Fo.updateQueue,t===null?(t=ns(),Fo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ds(e,t,n,r){t.value=n,t.getSnapshot=r,ps(t)&&ms(e)}function fs(e,t,n){return n(function(){ps(t)&&ms(e)})}function ps(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ur(e,n)}catch{return!0}}function ms(e){var t=Oi(e,2);t!==null&&Nd(t,e,2)}function hs(e){var t=es();if(typeof e==`function`){var n=e;if(e=n(),Bo){Qe(!0);try{n()}finally{Qe(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:e},t}function gs(e,t,n,r){return e.baseState=n,ss(e,Io,typeof r==`function`?r:as)}function _s(e,t,n,r,i){if(ic(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};I.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,vs(t,a)):(a.next=n.next,t.pending=n.next=a)}}function vs(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};o.types=a===null?null:a.types,I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),ys(e,t,s)}catch(n){xs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),ys(e,t,a)}catch(n){xs(e,t,n)}}function ys(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){bs(e,t,n)},function(n){return xs(e,t,n)}):bs(e,t,n)}function bs(e,t,n){t.status=`fulfilled`,t.value=n,Ss(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,vs(e,n)))}function xs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ss(t),t=t.next;while(t!==r)}e.action=null}function Ss(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Cs(e,t){return t}function ws(e,t){if(aa){var n=Yu.formState;if(n!==null){a:{var r=Fo;if(aa){if(ia){b:{for(var i=ia,a=sa;i.nodeType!==8;)if(!a||(i=dm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ia=dm(i.nextSibling),r=i.data===`F!`;break a}}la(r)}r=!1}r&&(t=n[0])}}return n=es(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cs,lastRenderedState:t},n.queue=r,n=tc.bind(null,Fo,r),r.dispatch=n,r=hs(!1),a=rc.bind(null,Fo,!1,r.queue),r=es(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=_s.bind(null,Fo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ts(e){return Es(ts(),Io,e)}function Es(e,t,n){if(t=ss(e,t,Cs)[0],e=os(as)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=rs(t)}catch(e){throw e===Ja?Xa:e}else r=t;t=ts();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Fo.flags|=2048,ks(9,{destroy:void 0},Ds.bind(null,i,n),null)),[r,a,e]}function Ds(e,t){e.action=t}function Os(e){var t=ts(),n=Io;if(n!==null)return Es(t,n,e);ts(),t=t.memoizedState,n=ts();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ks(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Fo.updateQueue,t===null&&(t=ns(),Fo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function As(){return ts().memoizedState}function js(e,t,n,r){var i=es();Fo.flags|=e,i.memoizedState=ks(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ms(e,t,n,r){var i=ts();r=r===void 0?null:r;var a=i.memoizedState.inst;Io!==null&&r!==null&&Ko(r,Io.memoizedState.deps)?i.memoizedState=ks(t,a,n,r):(Fo.flags|=e,i.memoizedState=ks(1|t,a,n,r))}function Ns(e,t){js(8390656,8,e,t)}function Ps(e,t){Ms(2048,8,e,t)}function Fs(e){Fo.flags|=4;var t=Fo.updateQueue;if(t===null)t=ns(),Fo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Is(e){var t=ts().memoizedState;return Fs({ref:t,nextImpl:e}),function(){if(Ju&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Ls(e,t){return Ms(4,2,e,t)}function Rs(e,t){return Ms(4,4,e,t)}function zs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Bs(e,t,n){n=n==null?null:n.concat([e]),Ms(4,4,zs.bind(null,t,e),n)}function Vs(){}function Hs(e,t){var n=ts();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Ko(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function X(e,t){var n=ts();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Ko(t,r[1]))return r[0];if(r=e(),Bo){Qe(!0);try{e()}finally{Qe(!1)}}return n.memoizedState=[r,t],r}function Us(e,t,n){return n===void 0||Po&1073741824&&!(Zu&261930)?e.memoizedState=t:(e.memoizedState=n,e=jd(),Fo.lanes|=e,ad|=e,n)}function Ws(e,t,n,r){return Ur(n,t)?n:vo.current===null?!(Po&106)||Po&1073741824&&!(Zu&261930)?(Ec=!0,e.memoizedState=n):(e=jd(),Fo.lanes|=e,ad|=e,t):(e=Us(e,n,r),Ur(e,t)||(Ec=!0),e)}function Gs(e,t,n,r,i){var a=he.p;he.p=a!==0&&8>a?a:8;var o=I.T,s={};s.types=o===null?null:o.types,I.T=s,rc(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?nc(e,t,Ha(c,r),Ad(e)):nc(e,t,r,Ad(e))}catch(n){nc(e,t,{then:function(){},status:`rejected`,reason:n},Ad())}finally{he.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function Ks(){}function qs(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Js(e).queue;Gs(e,i,t,ge,n===null?Ks:function(){return Ys(e),n(r)})}function Js(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ge,baseState:ge,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:ge},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ys(e){var t=Js(e);t.next===null&&(t=e.alternate.memoizedState),nc(e,t.next.queue,{},Ad())}function Xs(){return Ea(lh)}function Zs(){return ts().memoizedState}function Qs(){return ts().memoizedState}function $s(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ad();e=uo(n);var r=fo(t,e,n);r!==null&&(Nd(r,t,n),po(r,t,n)),t={cache:Na()},e.payload=t;return}t=t.return}}function ec(e,t,n){var r=Ad();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ic(e)?ac(t,n):(n=Di(e,t,n,r),n!==null&&(Nd(n,e,r),oc(n,t,r)))}function tc(e,t,n){nc(e,t,n,Ad())}function nc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ic(e))ac(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Ur(s,o))return Ei(e,t,i,0),Yu===null&&Ti(),!1}catch{}if(n=Di(e,t,i,r),n!==null)return Nd(n,e,r),oc(n,t,r),!0}return!1}function rc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ic(e)){if(t)throw Error(o(479))}else t=Di(e,n,r,2),t!==null&&Nd(t,e,2)}function ic(e){var t=e.alternate;return e===Fo||t!==null&&t===Fo}function ac(e,t){zo=Ro=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,gt(e,n)}}var sc={readContext:Ea,use:is,useCallback:Go,useContext:Go,useEffect:Go,useImperativeHandle:Go,useLayoutEffect:Go,useInsertionEffect:Go,useMemo:Go,useReducer:Go,useRef:Go,useState:Go,useDebugValue:Go,useDeferredValue:Go,useTransition:Go,useSyncExternalStore:Go,useId:Go,useHostTransitionStatus:Go,useFormState:Go,useActionState:Go,useOptimistic:Go,useMemoCache:Go,useCacheRefresh:Go,useEffectEvent:Go},cc={readContext:Ea,use:is,useCallback:function(e,t){return es().memoizedState=[e,t===void 0?null:t],e},useContext:Ea,useEffect:Ns,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),js(4194308,4,zs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return js(4194308,4,e,t)},useInsertionEffect:function(e,t){js(4,2,e,t)},useMemo:function(e,t){var n=es();t=t===void 0?null:t;var r=e();if(Bo){Qe(!0);try{e()}finally{Qe(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=es();if(n!==void 0){var i=n(t);if(Bo){Qe(!0);try{n(t)}finally{Qe(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ec.bind(null,Fo,e),[r.memoizedState,e]},useRef:function(e){var t=es();return e={current:e},t.memoizedState=e},useState:function(e){e=hs(e);var t=e.queue,n=tc.bind(null,Fo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Vs,useDeferredValue:function(e,t){return Us(es(),e,t)},useTransition:function(){var e=hs(!1);return e=Gs.bind(null,Fo,e.queue,!0,!1),es().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Fo,i=es();if(aa){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Yu===null)throw Error(o(349));Zu&127||us(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ns(fs.bind(null,r,a,e),[e]),r.flags|=2048,ks(9,{destroy:void 0},ds.bind(null,r,a,n,t),null),n},useId:function(){var e=es(),t=Yu.identifierPrefix;if(aa){var n=Zi,r=Xi;n=(r&~(1<<32-$e(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Vo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Wo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Xs,useFormState:ws,useActionState:ws,useOptimistic:function(e){var t=es();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=rc.bind(null,Fo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Y,useCacheRefresh:function(){return es().memoizedState=$s.bind(null,Fo)},useEffectEvent:function(e){var t=es(),n={impl:e};return t.memoizedState=n,function(){if(Ju&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},lc={readContext:Ea,use:is,useCallback:Hs,useContext:Ea,useEffect:Ps,useImperativeHandle:Bs,useInsertionEffect:Ls,useLayoutEffect:Rs,useMemo:X,useReducer:os,useRef:As,useState:function(){return os(as)},useDebugValue:Vs,useDeferredValue:function(e,t){return Ws(ts(),Io.memoizedState,e,t)},useTransition:function(){var e=os(as)[0],t=ts().memoizedState;return[typeof e==`boolean`?e:rs(e),t]},useSyncExternalStore:ls,useId:Zs,useHostTransitionStatus:Xs,useFormState:Ts,useActionState:Ts,useOptimistic:function(e,t){return gs(ts(),Io,e,t)},useMemoCache:Y,useCacheRefresh:Qs,useEffectEvent:Is},uc={readContext:Ea,use:is,useCallback:Hs,useContext:Ea,useEffect:Ps,useImperativeHandle:Bs,useInsertionEffect:Ls,useLayoutEffect:Rs,useMemo:X,useReducer:cs,useRef:As,useState:function(){return cs(as)},useDebugValue:Vs,useDeferredValue:function(e,t){var n=ts();return Io===null?Us(n,e,t):Ws(n,Io.memoizedState,e,t)},useTransition:function(){var e=cs(as)[0],t=ts().memoizedState;return[typeof e==`boolean`?e:rs(e),t]},useSyncExternalStore:ls,useId:Zs,useHostTransitionStatus:Xs,useFormState:Os,useActionState:Os,useOptimistic:function(e,t){var n=ts();return Io===null?(n.baseState=e,[e,n.queue.dispatch]):gs(n,Io,e,t)},useMemoCache:Y,useCacheRefresh:Qs,useEffectEvent:Is};function dc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var fc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=uo(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=fo(e,i,r),t!==null&&(Nd(t,e,r),po(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ad(),r=uo(n);r.tag=2,t!=null&&(r.callback=t),t=fo(e,r,n),t!==null&&(Nd(t,e,n),po(t,e,n))}};function pc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Wr(n,r)||!Wr(i,a):!0}function mc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&fc.enqueueReplaceState(t,t.state,null)}function hc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function gc(e){xi(e)}function _c(e){console.error(e)}function vc(e){xi(e)}function yc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function bc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function xc(e,t,n){return n=uo(n),n.tag=3,n.payload={element:null},n.callback=function(){yc(e,t)},n}function Sc(e){return e=uo(e),e.tag=3,e}function Cc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){bc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){bc(t,n,r),typeof i!=`function`&&(_d===null?_d=new Set([this]):_d.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function wc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ca(t,n,i,!0),n=Co.current,n!==null){switch(n.tag){case 31:case 13:case 19:return wo===null?Gd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===Za?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),mf(e,r,i)),!1;case 22:return n.flags|=65536,r===Za?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),mf(e,r,i)),!1}throw Error(o(435,n.tag))}return mf(e,r,i),Gd(),!1}if(aa)return t=Co.current,t===null?(r!==ca&&(t=Error(o(423),{cause:r}),ha(Hi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Hi(r,n),i=xc(e.stateNode,r,i),mo(e,i),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==ca&&(e=Error(o(422),{cause:r}),ha(Hi(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=Hi(a,n),ud===null?ud=[a]:ud.push(a),id!==4&&(id=2),t===null)return!0;r=Hi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=xc(n.stateNode,r,e),mo(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(_d===null||!_d.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Sc(i),Cc(i,e,n,r),mo(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Tc=Error(o(461)),Ec=!1;function Dc(e,t,n,r){t.child=e===null?K(t,null,n,r):G(t,e.child,n,r)}function Oc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ta(t),r=qo(e,t,n,o,a,i),s=Zo(),e!==null&&!Ec?(Qo(e,t,i),nl(e,t,i)):(aa&&s&&ea(t),t.flags|=1,Dc(e,t,r,i),t.child)}function kc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Pi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Ac(e,t,a,r,i)):(e=z(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!rl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Wr:n,n(o,r)&&e.ref===t.ref)return nl(e,t,i)}return t.flags|=1,e=Fi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Wr(a,r)&&e.ref===t.ref){if(Ec=!1,t.pendingProps=r=a,rl(e,i))e.flags&131072&&(Ec=!0);else return t.lanes=e.lanes,nl(e,t,i)}}return Rc(e,t,n,r,i)}function jc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ka(t,a===null?null:a.cachePool),a===null?xo():bo(t,a),Do(t);else return r=t.lanes=536870912,Nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ka(t,null),xo(),Oo()):(Ka(t,a.cachePool),bo(t,a),Oo(),t.memoizedState=null);return Dc(e,t,i,n),t.child}function Mc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Nc(e,t,n,r,i){var a=Ga();return a=a===null?null:{parent:Ma._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ka(t,null),xo(),Do(t),e!==null&&Ca(e,t,r,!0),t.childLanes=i,null}function Pc(e,t){return t=qc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Fc(e,t,n){return G(t,e.child,null,n),e=Pc(t,t.pendingProps),e.flags|=2,ko(t),t.memoizedState=null,e}function Ic(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if(aa){if(r.mode===`hidden`)return e=Pc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Mc(null,e);if(Eo(t),(e=ia)?(e=sm(e,sa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=536870912,null}return Pc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(Eo(t),i){if(t.flags&256)t.flags&=-257,t=Fc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558))}else if(Ec||Ca(e,t,n,!1),i=(n&e.childLanes)!==0,Ec||i){if(vo.current===null){if(r=Yu,r!==null&&(s=_t(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Oi(e,s),Nd(r,e,s),Tc;Gd()}t=Fc(e,t,n)}else e=a.treeContext,ia=dm(s.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=Pc(t,r),t.flags|=134221824;return t}return e=Fi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Lc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Rc(e,t,n,r,i){return Ta(t),n=qo(e,t,n,r,void 0,i),r=Zo(),e!==null&&!Ec?(Qo(e,t,i),nl(e,t,i)):(aa&&r&&ea(t),t.flags|=1,Dc(e,t,n,i),t.child)}function zc(e,t,n,r,i,a){return Ta(t),t.updateQueue=null,n=Yo(t,r,n,i),Jo(e),r=Zo(),e!==null&&!Ec?(Qo(e,t,a),nl(e,t,a)):(aa&&r&&ea(t),t.flags|=1,Dc(e,t,n,a),t.child)}function Bc(e,t,n,r,i){if(Ta(t),t.stateNode===null){var a=ji,o=n.contextType;typeof o==`object`&&o&&(a=Ea(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=fc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},co(t),o=n.contextType,a.context=typeof o==`object`&&o?Ea(o):ji,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(dc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&fc.enqueueReplaceState(a,a.state,null),go(t,r,a,i),q(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=hc(n,s);a.props=c;var l=a.context,u=n.contextType;o=ji,typeof u==`object`&&u&&(o=Ea(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&mc(t,a,r,o),so=!1;var f=t.memoizedState;a.state=f,go(t,r,a,i),q(),l=t.memoizedState,s||f!==l||so?(typeof d==`function`&&(dc(t,n,d,r),l=t.memoizedState),(c=so||pc(t,n,c,r,f,l,o))?(u||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`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,lo(e,t),o=t.memoizedProps,u=hc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ji,typeof l==`object`&&l&&(c=Ea(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&mc(t,a,r,c),so=!1,f=t.memoizedState,a.state=f,go(t,r,a,i),q();var p=t.memoizedState;o!==d||f!==p||so||e!==null&&e.dependencies!==null&&wa(e.dependencies)?(typeof s==`function`&&(dc(t,n,s,r),p=t.memoizedState),(u=so||pc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&wa(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Lc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=G(t,e.child,null,i),t.child=G(t,null,n,i)):Dc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=nl(e,t,i),e}function Vc(e,t,n,r){return pa(),t.flags|=256,Dc(e,t,n,r),t.child}var Hc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Uc(e){return{baseLanes:e,cachePool:qa()}}function Wc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cd),e}function Gc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Ao.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(aa){if(i?To(t):Oo(),(e=ia)?(e=sm(e,sa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw la(t);return t.lanes=lm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Oo(),i=t.mode,a=qc({mode:`hidden`,children:a},i),r=Li(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Uc(n),r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(null,r)):(To(t),Kc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Yc(e,t,a,o,r,c,s,n)}return i?(Oo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Fi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Li(i,a,n,null),i.flags|=2):i=Fi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Mc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Uc(n):(a=i.cachePool,a===null?a=qa():(s=Ma._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(e.child,r)):(To(t),n=e.child,e=n.sibling,n=Fi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Kc(e,t){return t=qc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function qc(e,t){return e=Ni(22,e,null,t),e.lanes=0,e}function Jc(e,t,n){return G(t,e.child,null,n),e=Kc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yc(e,t,n,r,i,a,s,c){if(n)return t.flags&256?(To(t),t.flags&=-257,Jc(e,t,c)):t.memoizedState===null?(Oo(),a=i.fallback,s=t.mode,i=qc({mode:`visible`,children:i.children},s),a=Li(a,s,c,null),a.flags|=2,i.return=t,a.return=t,i.sibling=a,t.child=i,G(t,e.child,null,c),i=t.child,i.memoizedState=Uc(c),i.childLanes=Wc(e,r,c),t.memoizedState=Hc,Mc(null,i)):(Oo(),t.child=e.child,t.flags|=128,null);if(To(t),lm(a)){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(i=Error(o(419)),i.stack=``,i.digest=r,ha({value:i,source:null,stack:null})),Jc(e,t,c)}if(Ec||Ca(e,t,c,!1),r=(c&e.childLanes)!==0,Ec||r){if(vo.current!==null)return Jc(e,t,c);if(r=Yu,r!==null&&(i=_t(r,c),i!==0&&i!==s.retryLane))throw s.retryLane=i,Oi(e,i),Nd(r,e,i),Tc;return cm(a)||Gd(),Jc(e,t,c)}return cm(a)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ia=dm(a.nextSibling),ra=t,aa=!0,oa=null,sa=!1,e!==null&&na(t,e),t=Kc(t,i.children),t.flags|=134221824,t)}function Xc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),xa(e.return,t,n)}function Zc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&No(n)===null&&(t=e),e=e.sibling}return t}function Qc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function $c(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function el(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Ao.current;if(t.flags&128)return jo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,jo(t,o),i===`backwards`&&e!==null?($c(e),Dc(e,t,r,n),$c(e)):Dc(e,t,r,n),r=aa?Ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xc(e,n,t);else if(e.tag===19)Xc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,$c(t)),Qc(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&No(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Qc(t,!0,n,null,a,r);break;case`together`:Qc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Qc(t,!1,i,n,a,r)}return t.child}function tl(e,t,n){var r=t.pendingProps;return ya(t,t.type,r.value),Dc(e,t,r.children,n),t.child}function nl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ad|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ca(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Fi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Fi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&wa(e)))}function il(e,t,n){switch(t.tag){case 3:Ee(t,t.stateNode.containerInfo),ya(t,Ma,e.memoizedState.cache),pa();break;case 27:case 5:Oe(t);break;case 4:Ee(t,t.stateNode.containerInfo);break;case 10:ya(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Eo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return To(t),t.flags|=128,null;r=Ca(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Gc(e,t,n):(To(t),e=nl(e,t,n),e===null?null:e.sibling)}To(t);break;case 19:if(t.flags&128)return el(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ca(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return el(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),jo(t,Ao.current),r)break;return null;case 22:return t.lanes=0,jc(e,t,n,t.pendingProps);case 24:ya(t,Ma,e.memoizedState.cache)}return nl(e,t,n)}function al(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Ec=!0;else{if(!rl(e,n)&&!(t.flags&128))return Ec=!1,il(e,t,n);Ec=!!(e.flags&131072)}}else Ec=!1,aa&&t.flags&1048576&&$i(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=eo(t.elementType),t.type=e,typeof e==`function`)Pi(e)?(r=hc(e,r),t.tag=1,t=Bc(null,t,e,r,n)):(t.tag=0,t=Rc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===te){t.tag=11,t=Oc(null,t,e,r,n);break a}if(i===F){t.tag=14,t=kc(null,t,e,r,n);break a}if(i===P){t.tag=10,t.type=e,t=tl(null,t,n);break a}}throw t=pe(e)||e,Error(o(306,t,``))}}return t;case 0:return Rc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=hc(r,t.pendingProps),Bc(e,t,r,i,n);case 3:a:{if(Ee(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,lo(e,t),go(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ya(t,Ma,r),r!==a.cache&&Sa(t,[Ma],n,!0),q(),r=s.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=Vc(e,t,r,n);break a}if(r!==i){i=Hi(Error(o(424)),t),ha(i),t=Vc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ia=dm(e.firstChild),ra=t,aa=!0,oa=null,sa=!0,n=K(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(pa(),r===i){t=nl(e,t,n);break a}Dc(e,t,r,n)}t=t.child}return t;case 26:return Lc(e,t),e===null?(n=Fm(t.type,null,t.pendingProps,null))?t.memoizedState=n:aa||(t.stateNode=mp(t.type,t.pendingProps,we.current,t)):t.memoizedState=Fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Oe(t),e===null&&aa&&(r=t.stateNode=_m(t.type,t.pendingProps,we.current),ra=t,sa=!0,i=ia,wp(t.type)?(fm=i,ia=dm(r.firstChild)):ia=i),Dc(e,t,t.pendingProps.children,n),Lc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&aa&&((i=r=ia)&&(r=am(r,t.type,t.pendingProps,sa),r===null?i=!1:(t.stateNode=r,ra=t,ia=dm(r.firstChild),sa=!1,i=!0)),i||la(t)),Oe(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,hp(i,a)?r=null:s!==null&&hp(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=qo(e,t,Xo,null,null,n),lh._currentValue=i),Lc(e,t),Dc(e,t,r,n),t.child;case 6:return e===null&&aa&&((e=n=ia)&&(n=om(n,t.pendingProps,sa),n===null?e=!1:(t.stateNode=n,ra=t,ia=null,e=!0)),e||la(t)),null;case 13:return Gc(e,t,n);case 4:return Ee(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=G(t,null,r,n):Dc(e,t,r,n),t.child;case 11:return Oc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Lc(e,t),Dc(e,t,r,n),t.child;case 8:return Dc(e,t,t.pendingProps.children,n),t.child;case 12:return Dc(e,t,t.pendingProps.children,n),t.child;case 10:return tl(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,Ta(t),i=Ea(i),r=r(i),t.flags|=1,Dc(e,t,r,n),t.child;case 14:return kc(e,t,t.type,t.pendingProps,n);case 15:return Ac(e,t,t.type,t.pendingProps,n);case 19:return el(e,t,n);case 31:return Ic(e,t,n);case 22:return jc(e,t,n,t.pendingProps);case 24:return Ta(t),r=Ea(Ma),e===null?(i=Ga(),i===null&&(i=Yu,a=Na(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},co(t),ya(t,Ma,i)):((e.lanes&n)!==0&&(lo(e,t),go(t,null,null,n),q()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,ya(t,Ma,r),r!==i.cache&&Sa(t,[Ma],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),ya(t,Ma,r))),Dc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:aa&&ea(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Lc(e,t),Dc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function ol(e){e.flags|=4}function sl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Xm(t,r):Xm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Hd())e.flags|=8192;else throw to=Za,Ya}}else e.flags&=-16777217}function cl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Zm(t)){if(Hd())e.flags|=8192;else throw to=Za,Ya}}function ll(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:dt(),e.lanes|=t,ld|=t)}function ul(e,t){if(!aa)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function dl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function fl(e,t,n){var r=t.pendingProps;switch(ta(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dl(t),null;case 1:return dl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ba(Ma),De(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(fa(t)?ol(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ma())),dl(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(ol(t),a===null?(dl(t),sl(t,i,null,r,n)):(dl(t),cl(t,a))):a?a===e.memoizedState?(dl(t),t.flags&=-16777217):(ol(t),dl(t),cl(t,a)):(e=e.memoizedProps,e!==r&&ol(t),dl(t),sl(t,i,e,r,n)),null;case 27:if(ke(t),n=we.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return dl(t),t.subtreeFlags&=-33554433,null}e=Se.current,fa(t)?ua(t,e):(e=_m(i,r,n),t.stateNode=e,ol(t))}return dl(t),t.subtreeFlags&=-33554433,null;case 5:if(ke(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return dl(t),t.subtreeFlags&=-33554433,null}if(a=Se.current,fa(t))ua(t,a);else{var s=dp(we.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[Ct]=t,a[wt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(ip(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ol(t)}}return dl(t),t.subtreeFlags&=-33554433,sl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=we.current,fa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ra,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Ct]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||tp(e.nodeValue,n)),e||la(t,!0)}else e=dp(e).createTextNode(r),e[Ct]=t,t.stateNode=e}return dl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=fa(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[Ct]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),e=!1}else n=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ko(t),t):(ko(t),null);if(t.flags&128)throw Error(o(558))}return dl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=fa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[Ct]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),i=!1}else i=ma(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(ko(t),t):(ko(t),null)}return ko(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),dl(t),null);case 4:return De(),e===null&&Gf(t.stateNode.containerInfo),t.flags|=67108864,dl(t),null;case 10:return ba(t.type),dl(t),null;case 19:if(Mo(t),r=t.memoizedState,r===null)return dl(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)ul(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=No(e),a!==null){for(t.flags|=128,ul(r,!1),e=a.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ii(n,e),n=n.sibling;return jo(t,Ao.current&1|2),aa&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ve()>hd&&(t.flags|=128,i=!0,ul(r,!1),t.lanes=4194304)}}else{if(!i){if(e=No(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),ul(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!aa)return dl(t),null}else 2*Ve()-r.renderingStartTime>hd&&n!==536870912&&(t.flags|=128,i=!0,ul(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ve(),e.sibling=null,a=Ao.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||aa?jo(t,a):(n=a,xe(Co,t),xe(Ao,n),wo===null&&(wo=t)),aa&&Qi(t,r.treeForkCount),e}return dl(t),null;case 22:case 23:return ko(t),So(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(dl(t),t.subtreeFlags&6&&(t.flags|=8192)):dl(t),n=t.updateQueue,n!==null&&ll(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&be(Wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ba(Ma),dl(t),null;case 25:return null;case 30:return t.flags|=33554432,dl(t),null}throw Error(o(156,t.tag))}function pl(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ba(Ma),De(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(ko(t),t.alternate===null)throw Error(o(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ko(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Mo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return De(),null;case 10:return ba(t.type),null;case 22:case 23:return ko(t),So(),e!==null&&be(Wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ba(Ma),null;case 25:return null;default:return null}}function ml(e,t){switch(ta(t),t.tag){case 3:ba(Ma),De();break;case 26:case 27:case 5:ke(t);break;case 4:De();break;case 31:t.memoizedState!==null&&ko(t);break;case 13:ko(t);break;case 19:Mo(t);break;case 10:ba(t.type);break;case 22:case 23:ko(t),So(),e!==null&&be(Wa);break;case 24:ba(Ma)}}function hl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){pf(t,t.return,e)}}function gl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){pf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){pf(t,t.return,e)}}function _l(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{_o(t,n)}catch(t){pf(e,e.return,t)}}}function vl(e,t,n){n.props=hc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pf(e,t,n)}}function yl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=vi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Ip(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Lp(e);h(e.child,!1,em,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){pf(e,t,n)}}function bl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){pf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){pf(e,t,n)}else n.current=null}}function xl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)nm(e.stateNode,t[n])}function Sl(e){for(var t=e.return;t!==null&&(Tl(t)&&nm(e.stateNode,t.stateNode),!wl(t));)t=t.return}function Cl(e){for(var t=e.return;t!==null&&(Tl(t)&&rm(e.stateNode,t.stateNode),!wl(t));)t=t.return}function wl(e){return e.tag===5||e.tag===3||e.tag===27}function Tl(e){return e&&e.tag===7&&e.stateNode!==null}function Z(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pf(e,e.return,t)}}function El(e,t,n){try{var r=e.stateNode;op(r,e.type,n,t),r[wt]=t}catch(t){pf(e,e.return,t)}}function Dl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wp(e.type)||e.tag===4}function Ol(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Dl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&wp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function kl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=bn)),xl(e,r),qt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(kl(e,t,n,r),e=e.sibling;e!==null;)kl(e,t,n,r),e=e.sibling}function Al(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),xl(e,r),qt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Al(e,t,n,r),e=e.sibling;e!==null;)Al(e,t,n,r),e=e.sibling}function jl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ip(t,r,n),t[Ct]=e,t[wt]=n}catch(t){pf(e,e.return,t)}}var Ml=!1,Nl=null;function Pl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Ml=!0)}var Fl=null;function Il(){var e=Fl;return Fl=null,e}var Ll=0;function Rl(e,t,n,r,i){return Ll=0,zl(e.child,t,n,r,i)}function zl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Ap(o);r.push(s),s.view&&(a=!0)}else a||Ap(o).view&&(a=!0);Ml=!0,Dp(o,Ll===0?t:t+`_`+Ll,n),Ll++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||zl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Bl(e,t){for(;e!==null;)e.tag===5?Op(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Bl(e.child,t),e=e.sibling}function Vl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Vl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(o(544));var n=t.name;t=bi(t.default,t.share),t!==`none`&&(Rl(e,n,t,null,!1)||Bl(e.child,!1))}e=e.sibling}}function Hl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=vi(r,n),a=bi(r.default,n.paired?r.share:r.enter);a===`none`?Vl(e):Rl(e,i,a,null,!1)?(Vl(e),n.paired||t||Md(e,r.onEnter)):Bl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Hl(e,t),e=e.sibling;else Vl(e)}function Ul(e){if(Nl!==null&&Nl.size!==0){var t=Nl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=bi(n.default,n.share);if(a!==`none`&&(Rl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Md(e,n.onShare)):Bl(e.child,!1)),t.delete(r),t.size===0)break}}}Ul(e)}e=e.sibling}}}function Wl(e){if(e.tag===30){var t=e.memoizedProps,n=vi(t,e.stateNode),r=Nl===null?void 0:Nl.get(n),i=bi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Rl(e,n,i,null,!1)?r===void 0?Md(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Nl.delete(n),Md(e,t.onShare)):Bl(e.child,!1)),Nl!==null&&Ul(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e),e=e.sibling;else Nl!==null&&Ul(e)}function Gl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=vi(t,e.stateNode);t=bi(t.default,t.update),e.flags&=-5,t!==`none`&&Rl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Gl(e);e=e.sibling}}function Kl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Bl(e.child,!1))}Kl(e)}e=e.sibling}}function ql(e){if(e.tag===30)e.stateNode.paired=null,Bl(e.child,!1),Kl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)ql(e),e=e.sibling;else Kl(e)}function Jl(e){for(e=e.child;e!==null;)e.tag===30?Bl(e.child,!1):e.subtreeFlags&33554432&&Jl(e),e=e.sibling}function Yl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Ll<a.length){var l=a[Ll],u=Ap(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Dp(c,Ll===0?n:n+`_`+Ll,i),s&&e.flags&4||(Fl===null&&(Fl=[]),Fl.push(c,Ll===0?r:r+`_`+Ll,t.memoizedProps)),Ll++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Yl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Xl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=vi(n,r),a=bi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(jp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Ll=0,i=Yl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Md(e,n.onUpdate))}else e.subtreeFlags&33554432&&Xl(e,t);e=e.sibling}}var Zl=!1,Ql=!1,$l=!1,eu=!1,tu=typeof WeakSet==`function`?WeakSet:Set,nu=null,ru=!1,iu=!1,au=!1,ou=!1;function su(e,t,n){if(e=e.containerInfo,lp=vh,e=Yr(e),Xr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(up={focusedElem:e,selectionRange:r},vh=!1,n=(n&335544064)===n,nu=t,t=n?9270:1024;nu!==null;){if(e=nu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Wl(r[a]);if(e.alternate===null&&e.flags&2)n&&Pl(e),cu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Wl(r),cu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Pl(e),cu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,nu=r):(n&&Gl(e),cu(n))}}Nl=null}function cu(e){for(;nu!==null;){var t=nu,n=e,r=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(i&1024&&r!==null){n=void 0,i=r.memoizedProps,r=r.memoizedState;var a=t.stateNode;try{var s=hc(t.type,i);n=a.getSnapshotBeforeUpdate(s,r),a.__reactInternalSnapshotBeforeUpdate=n}catch(e){pf(t,t.return,e)}}break;case 3:if(i&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)im(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:im(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=vi(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=bi(i.default,i.update),i!==`none`&&Rl(r,n,i,r.memoizedState=[],!0));break;default:if(i&1024)throw Error(o(163))}if(r=t.sibling,r!==null){r.return=t.return,nu=r;break}nu=t.return}}function lu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ku(e,n),r&4&&hl(5,n);break;case 1:if(ku(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){pf(n,n.return,e)}else{var i=hc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pf(n,n.return,e)}}}r&64&&_l(n),r&512&&yl(n,n.return);break;case 3:if(ku(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{_o(e,t)}catch(e){pf(n,n.return,e)}}break;case 27:t===null&&r&4&&jl(n);case 26:case 5:ku(e,n),t===null&&r&4&&Z(n),r&512&&yl(n,n.return);break;case 12:ku(e,n);break;case 31:ku(e,n),r&4&&vu(e,n);break;case 13:ku(e,n),r&4&&yu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=_f.bind(null,n),um(e,n))));break;case 22:if(r=n.memoizedState!==null||Zl,!r){var a=t!==null&&t.memoizedState!==null||Ql;t=Zl,i=Ql,Zl=r,(Ql=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),ju(e,n,r)):ku(e,n),Zl=t,Ql=i}break;case 30:ku(e,n),r&512&&yl(n,n.return);break;case 7:r&512&&yl(n,n.return);default:ku(e,n)}}function uu(e,t){for(e=e.child;e!==null;)du(e,t),e=e.sibling}function du(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){pf(e,e.return,t)}fu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,qt=!0}catch(t){pf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Ep(s,!0):Ep(e.stateNode,!1)}catch(t){pf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&uu(e,t);break;default:uu(e,t)}}function fu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:du(n,r);break a;case 22:n.memoizedState===null&&fu(n,r);break a;default:fu(n,r)}}e=e.sibling}}function pu(e){var t=e.alternate;t!==null&&(e.alternate=null,pu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Mt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var mu=null,hu=!1;function gu(e,t,n){for(n=n.child;n!==null;)_u(e,t,n),n=n.sibling}function _u(e,t,n){if(Ze&&typeof Ze.onCommitFiberUnmount==`function`)try{Ze.onCommitFiberUnmount(Xe,n)}catch{}switch(n.tag){case 26:Ql||bl(n,t),gu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Ql&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ql||bl(n,t),Cl(n);var r=mu,i=hu;wp(n.type)&&(mu=n.stateNode,hu=!1),gu(e,t,n),vm(n.stateNode,n.type,n.memoizedProps),mu=r,hu=i;break;case 5:Ql||bl(n,t),Cl(n);case 6:if(n.tag===6&&Cl(n),r=mu,i=hu,mu=null,gu(e,t,n),mu=r,hu=i,mu!==null){if(hu)try{(mu.nodeType===9?mu.body:mu.nodeName===`HTML`?mu.ownerDocument.body:mu).removeChild(n.stateNode),qt=!0}catch(e){pf(n,t,e)}else try{mu.removeChild(n.stateNode),qt=!0}catch(e){pf(n,t,e)}}break;case 18:mu!==null&&(hu?(e=mu,Tp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wh(e)):Tp(mu,n.stateNode));break;case 4:r=mu,i=hu,mu=n.stateNode.containerInfo,hu=!0,gu(e,t,n),mu=r,hu=i;break;case 0:case 11:case 14:case 15:gl(2,n,t),Ql||gl(4,n,t),gu(e,t,n);break;case 1:Ql||(bl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&vl(n,t,r)),gu(e,t,n);break;case 21:gu(e,t,n);break;case 22:Ql=(r=Ql)||n.memoizedState!==null,gu(e,t,n),Ql=r;break;case 30:bl(n,t),gu(e,t,n);break;case 7:Ql||bl(n,t),gu(e,t,n);break;default:gu(e,t,n)}}function vu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wh(e)}catch(e){pf(t,t.return,e)}}}function yu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wh(e)}catch(e){pf(t,t.return,e)}}function bu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tu),t;default:throw Error(o(435,e.tag))}}function xu(e,t){var n=bu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=vf.bind(null,e,t);t.then(r,r)}})}function Su(e,t,n){var r=t.deletions;if(r!==null)for(var i=0;i<r.length;i++){var a=r[i],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(wp(l.type)){mu=l.stateNode,hu=!1;break a}break;case 5:mu=l.stateNode,hu=!1;break a;case 3:case 4:mu=l.stateNode.containerInfo,hu=!0;break a}l=l.return}if(mu===null)throw Error(o(160));_u(s,c,a),mu=null,hu=!1,s=a.alternate,s!==null&&(s.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)wu(t,e,n),t=t.sibling}var Cu=null;function wu(e,t,n){var r=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(i&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var a=0;a<r.length;a++){var s=r[a];s.ref.impl=s.nextImpl}Su(t,e,n),Tu(e),i&4&&(gl(3,e,e.return),hl(3,e),gl(5,e,e.return));break;case 1:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),i&64&&Zl&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(a=Cu,Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),i&4){if(i=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(Zl)e.stateNode=mp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,i=a.ownerDocument||a;b:switch(t){case`title`:r=i.getElementsByTagName(`title`)[0],(!r||r[At]||r[Ct]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=i.createElement(t),i.head.insertBefore(r,i.querySelector(`head > title`))),ip(r,t,n),r[Ct]=e,Lt(r),t=r;break a;case`link`:if(a=qm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;case`meta`:if(a=qm(`meta`,`content`,i).get(t+(n.content||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;default:throw Error(o(468,t))}r[Ct]=e,Lt(r),t=r}e.stateNode=t}}else Zl||Jm(a,e.type,e.stateNode)}else e.stateNode=Hm(a,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&El(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||Ql||t.parentNode.removeChild(t)):i.count--,n===null?Zl||Jm(a,e.type,e.stateNode):Hm(a,n,e.memoizedProps))}break;case 27:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),r!==null&&i&4&&El(e,e.memoizedProps,r.memoizedProps);break;case 5:if(a=$l,$l=!1,Su(t,e,n),$l=a,Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),e.flags&32){t=e.stateNode;try{fn(t,``),qt=!0}catch(t){pf(e,e.return,t)}}i&4&&e.stateNode!=null&&(t=e.memoizedProps,El(e,t,r===null?t:r.memoizedProps)),i&1024&&(eu=!0);break;case 6:if(Su(t,e,n),Tu(e),i&4){if(e.stateNode===null)throw Error(o(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,qt=!0}catch(t){pf(e,e.return,t)}}break;case 3:if(qt=!1,Km=null,a=Cu,Cu=Sm(t.containerInfo),Su(t,e,n),Cu=a,Tu(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Wh(t.containerInfo)}catch(t){pf(e,e.return,t)}eu&&(eu=!1,Eu(e)),qt=!1;break;case 4:i=$l,$l=Zl,r=Jt(),a=Cu,Cu=Sm(e.stateNode.containerInfo),Su(t,e,n),Tu(e),Cu=a,qt&&iu&&(au=!0),qt=r,$l=i;break;case 12:Su(t,e,n),Tu(e);break;case 31:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 13:Su(t,e,n),Tu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(pd=Ve()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 22:a=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Zl,l=Ql,u=$l;Zl=c||a,$l=u||a,Ql=l||s,Su(t,e,n),Ql=l,$l=u,Zl=c,Tu(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,!a||r===null||s||Zl||Ql||(t=s||Ql,n=Zl,r=Ql,Zl=a||Zl,Ql=t,Au(e,2),Zl=n,Ql=r),!a&&$l||uu(e,a)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,xu(e,n))));break;case 19:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 30:i&512&&(Ql||r===null||bl(r,r.return)),i=Jt(),a=iu,s=(n&335544064)===n,c=e.memoizedProps,iu=s&&bi(c.default,c.update)!==`none`,Su(t,e,n),Tu(e),s&&r!==null&&qt&&(e.flags|=4),iu=a,qt=i;break;case 21:break;case 7:i&512&&(Ql||r===null||bl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Su(t,e,n),Tu(e)}}function Tu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Dl(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(Tl(i)){var a=i.stateNode;r===null?r=[a]:r.push(a)}if(wl(i))break;i=i.return}var s=r;if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode;Al(e,Ol(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(fn(l,``),n.flags&=-33),Al(e,Ol(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;kl(e,Ol(e),u,s);break;default:throw Error(o(161))}}catch(t){pf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Eu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Eu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,vh=!0,t.reset(),vh=!1),e=e.sibling}}function Du(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Ou(t,e),t=t.sibling;else Xl(t,!1)}function Ou(e,t){var n=e.alternate;if(n===null)Hl(e,!1);else switch(e.tag){case 3:if(ou=ru=!1,Il(),Du(t,e),!ru&&!au){if(e=Fl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Op(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),ou=!0}Fl=null;break;case 5:Du(t,e);break;case 4:r=ru,ru=!1,Du(t,e),ru&&(au=!0),ru=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Du(t,e):Hl(e,!1));break;case 30:r=ru,i=Il(),ru=!1,Du(t,e),ru&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=vi(a,o),o=vi(n.memoizedProps,o);var s=bi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Ll=0,t=Yl(e,n,t,o,s,a,!0),Ll!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Md(e,e.memoizedProps.onUpdate),Fl=i):i!==null&&(i.push.apply(i,Fl),Fl=i),ru=e.flags&32?!0:r;break;default:Du(t,e)}}function ku(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)lu(e,t.alternate,t),t=t.sibling}function Au(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:gl(4,n,n.return),Au(n,r);break;case 1:bl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&vl(n,n.return,i),Au(n,r);break;case 27:r&2&&vm(n.stateNode,n.type,n.memoizedProps);case 5:bl(n,n.return),n.tag!==5&&n.tag!==27||Cl(n),Au(n,r);break;case 6:Cl(n);break;case 26:bl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Ql||i.parentNode.removeChild(i),Au(n,r);break;case 22:n.memoizedState===null&&Au(n,r);break;case 30:bl(n,n.return),Au(n,r);break;case 7:bl(n,n.return);default:Au(n,r)}e=e.sibling}}function ju(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:ju(i,a,n),hl(4,a);break;case 1:if(ju(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){pf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)J(l[i],c)}catch(e){pf(r,r.return,e)}}s&&o&64&&_l(a),yl(a,a.return);break;case 27:n&2&&jl(a);case 5:a.tag!==5&&a.tag!==27||Sl(a),ju(i,a,n),s&&r===null&&o&4&&Z(a),yl(a,a.return);break;case 6:Sl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Zl||Jm(Sm(c.ownerDocument),a.type,c),ju(i,a,n),s&&r===null&&o&4&&Z(a),yl(a,a.return);break;case 12:ju(i,a,n);break;case 31:ju(i,a,n),s&&o&4&&vu(i,a);break;case 13:ju(i,a,n),s&&o&4&&yu(i,a);break;case 22:a.memoizedState===null&&ju(i,a,n),yl(a,a.return);break;case 30:ju(i,a,n),yl(a,a.return);break;case 7:yl(a,a.return);default:ju(i,a,n)}t=t.sibling}}function Mu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Pa(n))}function Nu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Pa(e))}function Pu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Fu(e,t,n,r),t=t.sibling;else i&&Jl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&ql(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Pu(e,t,n,r),a&2048&&hl(9,t);break;case 1:Pu(e,t,n,r);break;case 3:Pu(e,t,n,r),i&&ou&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Pa(a)));break;case 12:if(a&2048){Pu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){pf(t,t.return,e)}}else Pu(e,t,n,r);break;case 31:Pu(e,t,n,r);break;case 13:Pu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&ql(t),o._visibility&2?Pu(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&ql(s),o._visibility&2?Pu(e,t,n,r):Lu(e,t)),a&2048&&Mu(s,t);break;case 24:Pu(e,t,n,r),a&2048&&Nu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Bl(a.child,!0),Bl(t.child,!0))),Pu(e,t,n,r);break;default:Pu(e,t,n,r)}}function Iu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Iu(a,o,s,c,i),hl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Iu(a,o,s,c,i)):u._visibility&2?Iu(a,o,s,c,i):Lu(a,o),i&&l&2048&&Mu(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Nu(o.alternate,o);break;default:Iu(a,o,s,c,i)}t=t.sibling}}function Lu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Lu(n,r),i&2048&&Mu(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Nu(r.alternate,r);break;default:Lu(n,r)}t=t.sibling}}var Ru=8192;function zu(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)Bu(e,t,n),e=e.sibling}function Bu(e,t,n){switch(e.tag){case 26:zu(e,t,n),e.flags&Ru&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&$m(n,e)):eh(n,Cu,e.memoizedState,e.memoizedProps));break;case 5:zu(e,t,n),e.flags&Ru&&(e=e.stateNode,(t&335544128)===t&&$m(n,e));break;case 3:case 4:var r=Cu;Cu=Sm(e.stateNode.containerInfo),zu(e,t,n),Cu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ru,Ru=16777216,zu(e,t,n),Ru=r):zu(e,t,n));break;case 30:if((e.flags&Ru)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Nl===null&&(Nl=new Map),Nl.set(r,i)}zu(e,t,n);break;default:zu(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&gl(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:gl(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;nu!==null;){var n=nu;switch(n.tag){case 0:case 11:case 15:gl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Pa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nu=r;else a:for(n=e;nu!==null;){r=nu;var i=r.sibling,a=r.return;if(pu(r),r===n){nu=null;break a}if(i!==null){i.return=a,nu=i;break a}nu=a}}}var Ku={getCacheForType:function(e){var t=Ea(Ma),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ea(Ma).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,Ju=0,Yu=null,Xu=null,Zu=0,Qu=0,$u=null,ed=!1,td=!1,nd=!1,rd=0,id=0,ad=0,od=0,sd=0,cd=0,ld=0,ud=null,dd=null,fd=!1,pd=0,md=0,hd=1/0,gd=null,_d=null,vd=0,yd=null,bd=null,xd=0,Sd=0,Cd=null,wd=null,Td=null,Ed=null,Dd=null,Od=0,kd=null;function Ad(){return Ju&2&&Zu!==0?Zu&-Zu:I.T===null?bt():Pf()}function jd(){if(cd===0){if(!(Zu&536870912)||aa){var e=it;it<<=1,!(it&3932160)&&(it=262144),cd=e}else cd=536870912}return e=Co.current,e!==null&&(e.flags|=32),cd}function Md(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Ip(vi(e.memoizedProps,n))),Ed===null&&(Ed=[]),Ed.push(t.bind(null,r))}}function Nd(e,t,n){(e===Yu&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)&&(Bd(e,0),Ld(e,Zu,cd,!1)),pt(e,n),Ju&2&&e===Yu||(e===Yu&&(!(Ju&2)&&(od|=n),id===4&&Ld(e,Zu,cd,!1)),Ef(e))}function Pd(e,t,n){if(Ju&6)throw Error(o(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||ct(e,t),i=r?Jd(e,t):Kd(e,t,!0),a=r;do{if(i===0){td&&!r&&Ld(e,t,0,!1);break}if(n=e.current.alternate,a&&!Id(n))i=Kd(e,t,!1),a=!1;else{if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=ud;var l=c.current.memoizedState.isDehydrated;if(l&&(Bd(c,s).flags|=256),s=Kd(c,s,!1),s!==2&&s!==6){if(nd&&!l){c.errorRecoveryDisabledLanes|=a,od|=a,i=4;break a}a=dd,dd=i,a!==null&&(dd===null?dd=a:dd.push.apply(dd,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Bd(e,0),Ld(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Ld(r,t,cd,!ed);break a;case 2:dd=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=pd+300-Ve(),10<i)){if(Ld(r,t,cd,!ed),st(r,0,!0)!==0)break a;xd=t,r.timeoutHandle=vp(Fd.bind(null,r,n,dd,gd,fd,t,cd,od,ld,ed,a,`Throttled`,-0,0),i);break a}Fd(r,n,dd,gd,fd,t,cd,od,ld,ed,a,null,-0,0)}break}}while(1);Ef(e)}function Fd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:bn},Nl=null,Bu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ih.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?pd-Ve():(a&4194048)===a?md-Ve():0,m=nh(d,m),m!==null)?(xd=a,e.cancelPendingCommit=m(tf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Ld(e,a,o,!l)):tf(e,t,a,n,r,i,o,s,c,l,u,d)}function Id(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ur(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ld(e,t,n,r){t=lt(e,t),t&=~sd,t&=~od,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-$e(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&ht(e,n,t)}function Rd(){return Ju&6?!0:(Df(0,!1),!1)}function zd(){if(Xu!==null){if(Qu===0)var e=Xu.return;else e=Xu,va=_a=null,$o(e),io=null,ao=0,e=Xu;for(;e!==null;)ml(e.alternate,e),e=e.return;Xu=null}}function Bd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,yp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),xd=0,zd(),Yu=e,Xu=n=Fi(e.current,null),Zu=t,Qu=0,$u=null,ed=!1,td=ct(e,t),nd=!1,ld=cd=sd=od=ad=id=0,dd=ud=null,fd=!1,rd=lt(e,t),Ti(),n}function Vd(e,t){Fo=null,I.H=sc,t===Ja||t===Xa?(t=no(),Qu=3):t===Ya?(t=no(),Qu=4):Qu=t===Tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,Xu===null&&(id=1,yc(e,Hi(t,e.current)))}function Hd(){var e=Co.current;return e===null?!0:(Zu&4194048)===Zu?wo===null:(Zu&62914560)===Zu||Zu&536870912?e===wo:!1}function Ud(){var e=I.H;return I.H=sc,e===null?sc:e}function Wd(){var e=I.A;return I.A=Ku,e}function Gd(){id=4,ed||(Zu&4194048)!==Zu&&Co.current!==null||(td=!0),!(ad&134217727)&&!(od&134217727)||Yu===null||Ld(Yu,Zu,cd,!1)}function Kd(e,t,n){var r=Ju;Ju|=2;var i=Ud(),a=Wd();(Yu!==e||Zu!==t)&&(gd=null,Bd(e,t)),t=!1;var o=id;a:do try{if(Qu!==0&&Xu!==null){var s=Xu,c=$u;switch(Qu){case 8:zd(),o=6;break a;case 3:case 2:case 9:case 6:Co.current===null&&(t=!0);var l=Qu;if(Qu=0,$u=null,Qd(e,s,c,l),n&&td){o=0;break a}break;default:l=Qu,Qu=0,$u=null,Qd(e,s,c,l)}}qd(),o=id;break}catch(t){Vd(e,t)}while(1);return t&&e.shellSuspendCounter++,va=_a=null,Ju=r,I.H=i,I.A=a,Xu===null&&(Yu=null,Zu=0,Ti()),o}function qd(){for(;Xu!==null;)Xd(Xu)}function Jd(e,t){var n=Ju;Ju|=2;var r=Ud(),i=Wd();Yu!==e||Zu!==t?(gd=null,hd=Ve()+500,Bd(e,t)):td=ct(e,t);a:do try{if(Qu!==0&&Xu!==null){t=Xu;var a=$u;b:switch(Qu){case 1:Qu=0,$u=null,Qd(e,t,a,1);break;case 2:case 9:if(Qa(a)){Qu=0,$u=null,Zd(t);break}t=function(){Qu!==2&&Qu!==9||Yu!==e||(Qu=7),Ef(e)},a.then(t,t);break a;case 3:Qu=7;break a;case 4:Qu=5;break a;case 7:Qa(a)?(Qu=0,$u=null,Zd(t)):(Qu=0,$u=null,Qd(e,t,a,7));break;case 5:var s=null;switch(Xu.tag){case 26:s=Xu.memoizedState;case 5:case 27:var c=Xu;if(s?Zm(s):c.stateNode.complete){Qu=0,$u=null;var l=c.sibling;if(l!==null)Xu=l;else{var u=c.return;u===null?Xu=null:(Xu=u,$d(u))}break b}}Qu=0,$u=null,Qd(e,t,a,5);break;case 6:Qu=0,$u=null,Qd(e,t,a,6);break;case 8:zd(),id=6;break a;default:throw Error(o(462))}}Yd();break}catch(t){Vd(e,t)}while(1);return va=_a=null,I.H=r,I.A=i,Ju=n,Xu===null?(Yu=null,Zu=0,Ti(),id):0}function Yd(){for(;Xu!==null&&!ze();)Xd(Xu)}function Xd(e){var t=al(e.alternate,e,rd);e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Zd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=zc(n,t,t.pendingProps,t.type,void 0,Zu);break;case 11:t=zc(n,t,t.pendingProps,t.type.render,t.ref,Zu);break;case 5:$o(t);var r=t;r===ra&&(aa?(da(r),r.tag===5&&r.stateNode!=null&&(ia=r.stateNode)):(da(r),aa=!0));default:ml(n,t),t=Xu=Ii(t,rd),t=al(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Qd(e,t,n,r){va=_a=null,$o(t),io=null,ao=0;var i=t.return;try{if(wc(e,i,t,n,Zu)){id=1,yc(e,Hi(n,e.current)),Xu=null;return}}catch(t){if(i!==null)throw Xu=i,t;id=1,yc(e,Hi(n,e.current)),Xu=null;return}t.flags&32768?(aa||r===1?e=!0:td||Zu&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=Co.current,r!==null&&r.tag===13&&(r.flags|=16384))),ef(t,e)):$d(t)}function $d(e){var t=e;do{if(t.flags&32768){ef(t,ed);return}e=t.return;var n=fl(t.alternate,t,rd);if(n!==null){Xu=n;return}if(t=t.sibling,t!==null){Xu=t;return}Xu=t=e}while(t!==null);id===0&&(id=5)}function ef(e,t){do{var n=pl(e.alternate,e);if(n!==null){n.flags&=32767,Xu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Xu=e;return}Xu=e=n}while(e!==null);id=6,Xu=null}function tf(e,t,n,r,i,a,s,c,l,u,d,f){e.cancelPendingCommit=null;do uf();while(vd!==0);if(Ju&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));e===Yu&&(Xu=Yu=null,Zu=0),bd=t,yd=e,xd=n,Cd=i,wd=r,nf(e,t,n,s,c,l,f)}}function nf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Sd=s,s|=wi,mt(e,n,s,r,i,a),Ed=null,(n&335544064)===n?(Dd=V(e),r=10262):(Dd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,yf(Ge,function(){return df(),null})):(e.callbackNode=null,e.callbackPriority=0),Ml=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=I.T,I.T=null,i=he.p,he.p=2,a=Ju,Ju|=4;try{su(e,t,n)}finally{Ju=a,he.p=i,I.T=r}}vd=1,Ml?Td=Pp(o,e.containerInfo,Dd,of,sf,af,cf,df,rf,null,null):(of(),sf(),cf())}function rf(e){if(vd!==0){var t=yd.onRecoverableError;t(e,{componentStack:null})}}function af(){vd===3&&(vd=0,Ou(bd,yd),vd=4)}function of(){if(vd===1){vd=0;var e=yd,t=bd,n=xd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=I.T,I.T=null;var i=he.p;he.p=2;var a=Ju;Ju|=4;try{iu=au=!1,wu(t,e,n),n=up;var o=Yr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Jr(s.ownerDocument.documentElement,s)){if(c!==null&&Xr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=qr(s,h),v=qr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vh=!!lp,up=lp=null}finally{Ju=a,he.p=i,I.T=r}}e.current=t,vd=2}}function sf(){if(vd===2){vd=0;var e=yd,t=bd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=he.p;he.p=2;var i=Ju;Ju|=4;try{lu(e,t.alternate,t)}finally{Ju=i,he.p=r,I.T=n}}vd=3}}function cf(){if(vd===4||vd===3){vd=0;var e=Td;Td=null,Be();var t=yd,n=bd,r=xd,i=wd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?vd=5:(vd=0,bd=yd=null,lf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(_d=null),yt(r),n=n.stateNode,Ze&&typeof Ze.onCommitFiberRoot==`function`)try{Ze.onCommitFiberRoot(Xe,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=I.T,a=he.p,he.p=2,I.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{I.T=n,he.p=a}}if(i=Ed,o=Dd,Dd=null,i!==null&&(Ed=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);xd&3&&uf(),Ef(t),a=t.pendingLanes,r&261930&&a&42?t===kd?Od++:(Od=0,kd=t):(Od=0,kd=null),Df(0,!1)}}function lf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Pa(t)))}function uf(){return Td!==null&&(Td.skipTransition(),Td=null),of(),sf(),cf(),df()}function df(){if(vd!==5)return!1;var e=yd,t=Sd;Sd=0;var n=yt(xd),r=I.T,i=he.p;try{he.p=32>n?32:n,I.T=null,n=Cd,Cd=null;var a=yd,s=xd;if(vd=0,bd=yd=null,xd=0,Ju&6)throw Error(o(331));var c=Ju;if(Ju|=4,Uu(a.current),Fu(a,a.current,s,n),Ju=c,Df(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot==`function`)try{Ze.onPostCommitFiberRoot(Xe,a)}catch{}return!0}finally{he.p=i,I.T=r,lf(e,t)}}function ff(e,t,n){t=Hi(n,t),t=xc(e.stateNode,t,2),e=fo(e,t,2),e!==null&&(pt(e,2),Ef(e))}function pf(e,t,n){if(e.tag===3)ff(e,e,n);else for(;t!==null;){if(t.tag===3){ff(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(_d===null||!_d.has(r))){e=Hi(n,e),n=Sc(2),r=fo(t,n,2),r!==null&&(Cc(n,r,t,e),pt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(nd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Yu===e&&(Zu&n)===n&&(id===4||id===3&&(Zu&62914560)===Zu&&300>Ve()-pd?Ju&2?sd|=n:Bd(e,0):sd|=n,ld===Zu&&(ld=0)),Ef(e)}function gf(e,t){t===0&&(t=dt()),e=Oi(e,t),e!==null&&(pt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Le(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-$e(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Zu,a=st(r,r===Yu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ct(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&_p()&&(e=Tf);for(var t=Ve(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}vd!==0&&vd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-$e(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ut(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yu,n=Zu,n=st(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Re(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ct(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Re(r),yt(n)){case 2:case 8:n=We;break;case 32:n=Ge;break;case 268435456:n=qe;break;default:n=Ge}return r=jf.bind(null,e),n=Le(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Re(r),e.callbackPriority=2,e.callbackNode=null,2}function jf(e,t){if(vd!==0&&vd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(uf()&&e.callbackNode!==n)return null;var r=Zu;return r=st(e,e===Yu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pd(e,r,t),Af(e,Ve()),e.callbackNode!=null&&e.callbackNode===n?jf.bind(null,e):null)}function Mf(e,t){if(uf())return null;Pd(e,t,!0)}function Nf(){Sp(function(){Ju&6?Le(Ue,Of):kf()})}function Pf(){if(Tf===0){var e=Ra;e===0&&(e=rt,rt<<=1,!(rt&261888)&&(rt=256)),Tf=e}return Tf}function Ff(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:yn(e)}function If(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ff((i[wt]||null).action),o=r.submitter;o&&(t=(t=o[wt]||null)?Ff(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Vn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Tf!==0){var e=new FormData(i,o);qs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),qs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Lf=0;Lf<hi.length;Lf++){var Rf=hi[Lf];gi(Rf.toLowerCase(),`on`+(Rf[0].toUpperCase()+Rf.slice(1)))}gi(ci,`onAnimationEnd`),gi(R,`onAnimationIteration`),gi(li,`onAnimationStart`),gi(`dblclick`,`onDoubleClick`),gi(`focusin`,`onFocus`),gi(`focusout`,`onBlur`),gi(ui,`onTransitionRun`),gi(di,`onTransitionStart`),gi(fi,`onTransitionCancel`),gi(pi,`onTransitionEnd`),Ht(`onMouseEnter`,[`mouseout`,`mouseover`]),Ht(`onMouseLeave`,[`mouseout`,`mouseover`]),Ht(`onPointerEnter`,[`pointerout`,`pointerover`]),Ht(`onPointerLeave`,[`pointerout`,`pointerover`]),Vt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Vt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Vt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Vt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Vt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Vt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var zf=`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(` `),Bf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(zf));function Vf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){xi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){xi(e)}i.currentTarget=null,a=c}}}}function Hf(e,t){var n=t[Et];n===void 0&&(n=t[Et]=new Set);var r=e+`__bubble`;n.has(r)||(Kf(t,e,2,!1),n.add(r))}function Uf(e,t,n){var r=0;t&&(r|=4),Kf(n,e,r,t)}var Wf=`_reactListening`+Math.random().toString(36).slice(2);function Gf(e){if(!e[Wf]){e[Wf]=!0,zt.forEach(function(t){t!==`selectionchange`&&(Bf.has(t)||Uf(t,!1,e),Uf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Wf]||(t[Wf]=!0,Uf(`selectionchange`,!1,t))}}function Kf(e,t,n,r){switch(Th(t)){case 2:var i=yh;break;case 8:i=bh;break;default:i=xh}n=i.bind(null,t,n,e),i=void 0,!An||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function qf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=Nt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}Dn(function(){var r=a,i=Sn(n),o=[];a:{var s=mi.get(e);if(s!==void 0){var c=Vn,u=e;switch(e){case`keypress`:if(In(n)===0)break a;case`keydown`:case`keyup`:c=ar;break;case`focusin`:u=`focus`,c=Xn;break;case`focusout`:u=`blur`,c=Xn;break;case`beforeblur`:case`afterblur`:c=Xn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Jn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Yn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=cr;break;case ci:case R:case li:c=Zn;break;case pi:c=lr;break;case`scroll`:case`scrollend`:c=Un;break;case`wheel`:c=ur;break;case`copy`:case`cut`:case`paste`:c=Qn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=or;break;case`submit`:c=sr;break;case`toggle`:case`beforetoggle`:c=dr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=On(m,p),g!=null&&d.push(Jf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,c&&n!==xn&&(u=n.relatedTarget||n.fromElement)&&(Nt(u)||u[Tt]))break a;(s||c)&&(u=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,s?(c=n.relatedTarget||n.toElement,s=r,c=c?Nt(c):null,c!==null&&(f=l(c),d=c.tag,c!==f||d!==5&&d!==27&&d!==6)&&(c=null)):(s=null,c=r),s!==c&&(d=Jn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=or,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:Ft(s),h=c==null?u:Ft(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Nt(i)===r&&(d=new d(p,m+`enter`,c,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&c?E(s,c,Xf):null,s!==null&&Zf(o,u,s,d,!1),c!==null&&f!==null&&Zf(o,f,c,d,!0)))}a:{if(s=r?Ft(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var _=jr;else if(Tr(s)){if(Mr)_=Vr;else{_=zr;var v=Rr}}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&gn(r.elementType)&&(_=jr):_=Br;if(_&&=_(e,r)){Er(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?Ft(r):window,e){case`focusin`:(Tr(v)||v.contentEditable===`true`)&&(Qr=v,$r=r,ei=null);break;case`focusout`:ei=$r=Qr=null;break;case`mousedown`:ti=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ti=!1,ni(o,n,i);break;case`selectionchange`:if(Zr)break;case`keydown`:case`keyup`:ni(o,n,i)}var y;if(pr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else xr?yr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(gr&&n.locale!==`ko`&&(xr||b!==`onCompositionStart`?b===`onCompositionEnd`&&xr&&(y=Fn()):(Mn=i,Nn=`value`in Mn?Mn.value:Mn.textContent,xr=!0)),v=Yf(r,b),0<v.length&&(b=new $n(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=br(n),y!==null&&(b.data=y)))),(y=hr?Sr(e,n):Cr(e,n))&&(b=Yf(r,`onBeforeInput`),0<b.length&&(v=new $n(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),If(o,e,r,n,i)}Vf(o,t)})}function Jf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Yf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=On(e,n),i!=null&&r.unshift(Jf(e,i,a)),i=On(e,t),i!=null&&r.push(Jf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Xf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Zf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=On(n,a),l!=null&&o.unshift(Jf(n,l,c))):i||(l=On(n,a),l!=null&&o.push(Jf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Qf=/\r\n?/g,$f=/\u0000|\uFFFD/g;function ep(e){return(typeof e==`string`?e:``+e).replace(Qf,`
|
|
10
|
-
`).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&fn(e,``+r);else return;break;case`className`:Xt(e,`class`,r);break;case`tabIndex`:Xt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Xt(e,n,r);break;case`style`:hn(e,r,a);return;case`data`:if(t!==`object`){Xt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=bn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=yn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Yt(e,`popover`,r);break;case`xlinkActuate`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Yt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=_n.get(n)||n,Yt(e,n,r);else return}qt=!0}function rp(e,t,n,r,i,a){switch(n){case`style`:hn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)fn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=bn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Bt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[wt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}qt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Yt(e,n,r)}return}qt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,a,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:np(e,t,r,d,n,null)}}sn(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&ln(e,!!r,n,!0):ln(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:np(e,t,s,c,n,null)}dn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,u,r,n,null)}return;default:if(gn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(qt=!0),a=m;break;case`name`:m!==f&&(qt=!0),i=m;break;case`checked`:m!==f&&(qt=!0),u=m;break;case`defaultChecked`:m!==f&&(qt=!0),d=m;break;case`value`:m!==f&&(qt=!0),s=m;break;case`defaultValue`:m!==f&&(qt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}on(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||np(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(qt=!0),p=a;break;case`defaultValue`:a!==l&&(qt=!0),c=a;break;case`multiple`:a!==l&&(qt=!0),s=a;default:a!==l&&np(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?ln(e,!!n,n?[]:``,!1):ln(e,!!n,t,!0)):ln(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:i!==a&&(qt=!0),p=i;break;case`defaultValue`:i!==a&&(qt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&np(e,t,s,i,r,a)}un(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(qt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(gn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[Ct]=r,n[wt]=t,ip(n,e,t),Lt(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[At]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Nt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(o(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Mt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[At])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===bn&&(e.onclick=null),Mt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Mt(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=he.d;he.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Pt(e);t!==null&&t.tag===5&&t.type===`form`?Ys(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=an(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Lt(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+an(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+an(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+an(n.imageSizes)+`"]`)):i+=`[href="`+an(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[jt]=!0,o.onload=o.onerror=function(){Rt(o)}),Lt(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+an(r)+`"][href="`+an(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Lt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=It(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Lt(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=It(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Lt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=It(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Lt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=we.current)?Sm(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=It(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var a=It(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Lm(e)))?a._p||(s.instance=a,s.state.loading=5):(a=bm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,a)),zm(i,e,a,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=It(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Im(e){return`href="`+an(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[jt]){r.loading=1;return}}else t=e.createElement(`link`),t[jt]=!0,t.onload=t.onerror=Rt.bind(null,t),ip(t,`link`,n),Lt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+an(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+an(n.href)+`"]`);if(r)return t.instance=r,Lt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Lt(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var a=e.querySelector(Lm(i));if(a)return t.state.loading|=4,t.instance=a,Lt(a),a;r=Rm(n),(i=bm.get(i))&&Wm(r,i),a=(e.ownerDocument||e).createElement(`link`),Lt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(a,`link`,r),t.state.loading|=4,Um(a,n.precedence,e),t.instance=a;case`script`:return a=Bm(n.src),(i=e.querySelector(Vm(a)))?(t.instance=i,Lt(i),i):(r=n,(i=bm.get(a))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Lt(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[At]||a[Ct]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Lt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:P,Provider:null,Consumer:null,_currentValue:ge,_currentValue2:ge,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ni(3,null,null,t),e.current=a,a.stateNode=e,t=Na(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},co(a),e}function fh(e){return e?(e=ji,e):ji}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=uo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=fo(e,r,t),n!==null&&(Nd(n,e,t),po(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=Oi(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=vt(t);var n=Oi(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=I.T;I.T=null;var a=he.p;try{he.p=2,xh(e,t,n,r)}finally{he.p=a,I.T=i}}function bh(e,t,n,r){var i=I.T;I.T=null;var a=he.p;try{he.p=8,xh(e,t,n,r)}finally{he.p=a,I.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Pt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ot(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-$e(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ve()+500,Df(0,!1))}}break;case 31:case 13:s=Oi(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=Sn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=Nt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`: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`seeked`:case`submit`:case`toggle`: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`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(He()){case Ue:return 2;case We:return 8;case Ge:case Ke:return 32;case qe:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`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`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Pt(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=Nt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,xt(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,xt(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);xn=r,n.target.dispatchEvent(r),xn=null}else return t=Pt(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Pt(n);a!==null&&(e.splice(t,3),t-=3,qs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[wt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[wt]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[Tt]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=bt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(o(527,Jh,`19.3.1`));he.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{Xe=Xh.inject(Yh),Ze=Xh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(o(299));var n=!1,r=``,i=gc,a=_c,s=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,a,s,Gh),e[Tt]=t.current,Gf(e),new Kh(t)}})),l=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=e(r(),1),d=l(),f=`entry`,p=`sp-remote:`;function m(e,t){return e===`entry`?t:`${p}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function h(e){if(!e.startsWith(p))return{server:f,id:e};let t=e.indexOf(`:`,10);if(t<0)throw Error(`服务器资源标识无效`);return{server:decodeURIComponent(e.slice(10,t)),id:decodeURIComponent(e.slice(t+1))}}function g(e,t){if(!t.startsWith(p))return t;let n=h(t);if(n.server!==e)throw Error(`图片不属于此服务器,请在当前会话重新上传`);return n.id}var _=new Set([`workspaceId`,`conversationId`,`contextConversationId`,`messageId`,`sessionId`,`runId`,`taskId`,`parentConversationId`,`originMessageId`,`followedWorktreeId`,`worktreeOf`,`ownerConversationId`,`parentRunId`,`projectId`,`roomId`,`topicId`,`entityId`,`sourceConversationId`,`targetConversationId`,`forkedId`,`checkoutId`,`replyToMessageId`,`parentMessageId`,`replyTo`,`activate`]),v=new Set([`workspaces`,`conversations`,`messages`,`subagentRuns`,`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`rooms`,`topics`,`run`,`workflow`,`room`,`task`,`conversation`,`workspace`,`withdrawn`,`terminals`,`sessions`,`tools`,`projects`]),y=new Set([`collapsedConversationIds`,`unlockedChildConversationIds`,`stoppingConversationIds`,`conversationIds`,`workspaceIds`,`messageIds`]),b=new Set([`todosByConversation`,`pendingUserDecisionsByConversation`]),x=new Set([`args`,`arguments`,`parameters`,`schema`,`result`,`providers`,`images`,`attachments`,`toolCalls`,`defaultModel`,`model`,`agents`]);function S(e,t,n=``){return Array.isArray(e)?e.map(e=>S(e,t,n)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([r,i])=>typeof i==`string`&&i.length>0&&(_.has(r)||(r===`id`||r===`execution`)&&i.startsWith(p)||r===`id`&&(v.has(n)||`workspaceId`in e||`conversationId`in e||e.type===`group.activity`))?[r,t(i)]:y.has(r)&&Array.isArray(i)?[r,i.map(e=>typeof e==`string`?t(e):e)]:b.has(r)&&i&&typeof i==`object`?[r,Object.fromEntries(Object.entries(i).map(([e,n])=>[t(e),n]))]:x.has(r)?[r,i]:[r,S(i,t,r)]))}function C(e){let t=new Set;return S(e,e=>(t.add(h(e).server),e)),t}var w=`super-pi.server-connections.v1`,T=`super-pi.server-credentials.v1`,E=globalThis.fetch.bind(globalThis),D=typeof location>`u`?`http://localhost`:location.origin,O=[{id:f,name:`当前入口`,url:D,enabled:!0}],k={};try{let e=JSON.parse(localStorage.getItem(w)??`[]`);O=[{...O[0],name:e.find(e=>e.id===`entry`)?.name||`当前入口`},...e.filter(e=>e.id!==f)],k=JSON.parse(localStorage.getItem(T)??`{}`)}catch{}var A=f,j=f,M=!1,N=new Map,ee=new Set;function P(e){if(!e)return!1;let t=h(e).server;return O.some(e=>e.id===t)&&!ee.has(t)}var te=0,ne=new Set,re=new Map,F=new Map,ie=()=>{te++;for(let e of ne)e()},ae=e=>(ne.add(e),()=>{ne.delete(e)});function oe(){return(0,u.useSyncExternalStore)(ae,()=>te),{connections:O,statuses:re,activeServer:A,settingsServer:j,settingsSnapshot:N.get(j)}}function se(e){return e?h(e).server:A}function ce(){return A}function le(){return j}function ue(e){if(!O.some(t=>t.id===e))throw Error(`目标服务器已移除`);j!==e&&(j=e,ie(),window.dispatchEvent(new Event(`super-pi-settings-server`)))}function de(){M=!0,ue(A)}function fe(){M=!1,ue(A)}function pe(e){return O.find(t=>t.id===e)?.name??`未知服务器`}function me(e){return pe(h(e).server)}function I(e){if(e!==A){if(!O.some(t=>t.id===e))throw Error(`服务器已被移除`);A=e,M||ue(e),ie(),window.dispatchEvent(new Event(`super-pi-active-server`))}}function he(){localStorage.setItem(w,JSON.stringify(O)),localStorage.setItem(T,JSON.stringify(k)),ie(),window.dispatchEvent(new Event(`super-pi-server-connections`))}function ge(e,t){if(!t.trim())throw Error(`服务器名称不能为空`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在,请使用容易区分的名称`);O=O.map(n=>n.id===e?{...n,name:t.trim()}:n),he()}function _e(e){if(e===`entry`)return;let t=A===e;O=O.filter(t=>t.id!==e),delete k[e],F.delete(e),t&&(A=f),j===e&&ue(f),he(),t&&window.dispatchEvent(new Event(`super-pi-active-server`))}function ve(e,t){O=O.map(n=>n.id===e?{...n,enabled:t}:n),he()}async function ye(e,t,n){let r=new URL(t);if(![`http:`,`https:`].includes(r.protocol)||r.username||r.password||r.search||r.hash||r.pathname!==`/`)throw Error(`请输入 http(s)://主机:端口,不能包含路径或凭证`);if(location.protocol===`https:`&&r.protocol===`http:`)throw Error(`HTTPS 页面无法连接 HTTP 服务,请为目标服务启用 HTTPS,或从 HTTP 入口访问`);if(!e.trim()||!n.trim())throw Error(`请填写服务器名称和连接密钥`);if(O.some(t=>t.name===e.trim()))throw Error(`服务器名称已存在,请使用不同的名称`);let i=await be(r.origin,n.trim());if(!i.ok)throw Error(`连接失败(${i.status}),请检查服务版本、地址和连接密钥`);let a=await i.json();if(a.protocol!==1||typeof a.id!=`string`)throw Error(`目标服务不支持多服务端协议,请先更新目标服务`);if(O.some(e=>e.url===r.origin||e.identity===a.id))throw Error(`这台服务器已经添加`);let o=await E(`/api/browser-access`).then(e=>e.json()).catch(()=>void 0);if(a.id===o?.id)throw Error(`这是当前入口服务器,无需重复添加`);let s=crypto.randomUUID();return k[s]=n.trim(),O=[...O,{id:s,name:e.trim(),url:r.origin,enabled:!0,identity:a.id}],he(),s}async function be(e,t){try{return await E(`${e}/api/browser-access`,{headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(15e3),credentials:`omit`})}catch(e){throw Error(e instanceof Error&&e.name===`TimeoutError`?`连接超时,请检查目标服务器是否启动、端口是否开放`:`浏览器无法连接目标服务器,请检查地址、网络可达性、HTTPS 证书,以及目标是否已更新到支持多服务端的版本`)}}async function xe(e,t,n,r){let i=Se(e),a=new URL(n);if(![`http:`,`https:`].includes(a.protocol)||a.username||a.password||a.search||a.hash||a.pathname!==`/`)throw Error(`请输入不包含路径或凭证的 HTTP(S) 服务地址`);if(location.protocol===`https:`&&a.protocol===`http:`)throw Error(`HTTPS 页面不能连接 HTTP 服务`);if(!t.trim())throw Error(`请输入服务器名称`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在`);let o=r.trim()||k[e],s=await be(a.origin,o);if(!s.ok)throw Error(`连接失败(${s.status}),请检查地址和密钥`);let c=await s.json();if(c.protocol!==1||c.id!==i.identity)throw Error(`地址指向另一台服务器,请使用“添加服务器”,以保护现有资源和标签的归属`);k[e]=o,O=O.map(n=>n.id===e?{...n,name:t.trim(),url:a.origin,revision:(n.revision??0)+1}:n),F.delete(e),he()}function Se(e){let t=O.find(t=>t.id===e);if(!t||!t.enabled)throw Error(`目标服务器已移除或停用,操作未发送`);return t}function Ce(e,t){return new URL(`${e.url.replace(/\/$/,``)}${t.startsWith(`/`)?t:`/${t}`}`)}async function we(){try{let e=await E(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)});if(!e.ok)return;let t=await e.json();if(!t.available||!Array.isArray(t.connections))return;let n=t.connections.map(e=>({...e,url:new URL(e.url,D).href})),r=[...O.filter(e=>!e.managed),...n];if(JSON.stringify(r)!==JSON.stringify(O)){O=r;let e=!O.some(e=>e.id===A);e&&(A=f),O.some(e=>e.id===j)||ue(f),he(),e&&window.dispatchEvent(new Event(`super-pi-active-server`))}}catch{}}function Te(e,t=A){let n=C(e);if(n.size>1)throw Error(`一次操作不能混用不同服务器的资源`);return[...n][0]??t}function Ee(e,t){return S(e,e=>{let n=h(e);if(n.server!==t)throw Error(`资源不属于目标服务器`);return n.id})}function De(e){let t=/^(\/api\/upload\/|\/api\/projects\/|\/tools\/)([^/]+)(.*)$/.exec(e.pathname);if(!t)return{path:e.pathname};let n=h(decodeURIComponent(t[2])),r=t[3];return t[1]===`/api/upload/`&&/^\/[^/]+$/.test(r)&&(r=`/${encodeURIComponent(g(n.server,decodeURIComponent(r.slice(1))))}`),{server:n.server,path:`${t[1]}${encodeURIComponent(n.id)}${r}`}}function Oe(e){let t=new URL(e,location.origin);if(O.some(e=>e.managed&&t.href.startsWith(`${e.url}/`))||t.origin!==location.origin)return e;let n=Object.fromEntries(t.searchParams),r=De(t),i=Te(n,r.server??A),a=Se(i);for(let[e,r]of Object.entries(Ee(n,i)))t.searchParams.set(e,r);if(i===`entry`)return`${r.path}${t.search}${t.hash}`;let o=Ce(a,`${r.path}${t.search}${t.hash}`),s=F.get(i);return s&&!a.managed&&o.searchParams.set(`browserAsset`,s),o.href}async function ke(e,t,n){if(typeof e!=`string`&&!(e instanceof URL))throw Error(`服务器请求必须使用明确的 URL`);let r=new URL(String(e),location.origin),i=O.find(e=>e.managed&&r.href.startsWith(`${e.url}/`));if(i){if(n&&n!==i.id)throw Error(`资源不属于指定的服务器`);return je(i.id,r,t)}if(r.origin!==location.origin){let n=O.find(e=>e.url===r.origin);return n?(r.searchParams.delete(`browserAsset`),je(n.id,r,t)):E(e,t)}if(!r.pathname.startsWith(`/api/`))return E(e,t);let a;if(typeof t?.body==`string`)try{a=JSON.parse(t.body)}catch{}t?.body instanceof FormData&&(a=Object.fromEntries([...t.body].filter(([,e])=>typeof e==`string`)));let o=De(r),s=Te({...Object.fromEntries(r.searchParams),payload:a},o.server??n??A);if(n&&n!==s)throw Error(`资源不属于指定的服务器`);if(o.server&&o.server!==s)throw Error(`路径和参数属于不同服务器`);let c=Se(s);for(let[e,t]of Object.entries(Ee(Object.fromEntries(r.searchParams),s)))r.searchParams.set(e,t);let l=t;if(typeof t?.body==`string`&&a&&(l={...t,body:JSON.stringify(Ee(a,s))}),t?.body instanceof FormData){let e=new FormData,n=Ee(a,s);for(let[r,i]of t.body)e.append(r,typeof i==`string`?n[r]:i);l={...t,body:e}}return je(s,Ce(c,`${o.path}${r.search}`),l)}function Ae(e,t){return ke(e,t,j)}async function je(e,t,n){let r=Se(e),i=new Headers(n?.headers);e!==`entry`&&!r.managed&&i.set(`authorization`,`Bearer ${k[e]??``}`);let a=await E(e===`entry`?`${t.pathname}${t.search}`:t.href,{...n,headers:i,...e!==`entry`&&!r.managed?{credentials:`omit`}:{}});if(e===`entry`||!a.headers.get(`content-type`)?.includes(`application/json`))return a;let o=a.json.bind(a);return a.json=async()=>S(await o(),t=>m(e,t)),a}var Me=new Set([`model.catalog`,`model.catalog.all`,`providers.list`,`agent.catalog`,`prompt.catalog`,`subagent.catalog`,`server.version`,`terminal.status`,`exec.status`]),Ne=class{focus;onserveropen=null;ondisconnect=null;onopen=null;onclose=null;onmessage=null;onerror=null;sockets=new Map;snapshots=new Map;catalogs=new Map;timers=new Map;connecting=new Set;socketRevisions=new Map;leaseTimers=new Map;terminalServer=f;stopped=!1;constructor(e){this.focus=e,window.addEventListener(`super-pi-server-connections`,this.reconfigure),window.addEventListener(`super-pi-active-server`,this.activate),window.addEventListener(`super-pi-settings-server`,this.activateSettings),queueMicrotask(this.reconfigure),we(),this.managementTimer=setInterval(()=>{we()},3e3)}managementTimer;get readyState(){return this.sockets.get(A)?.readyState??WebSocket.CLOSED}deliver(e){this.onmessage?.({data:JSON.stringify(e)})}aggregate(){let e=this.snapshots.get(A),t=[...this.snapshots.values()],n={...e,workspaces:t.flatMap(e=>e.workspaces),conversations:t.flatMap(e=>e.conversations),subagentRuns:t.flatMap(e=>e.subagentRuns)};for(let e of[`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`extensionUi`,`stoppingConversationIds`,`collapsedConversationIds`,`unlockedChildConversationIds`])n[e]=t.flatMap(t=>t[e]??[]);for(let e of[`todosByConversation`,`pendingUserDecisionsByConversation`])n[e]=Object.assign({},...t.map(t=>t[e]));t.length&&this.deliver({type:`state`,state:n})}activate=()=>{this.aggregate(),this.deliver({type:`server.version`,version:{runningVersion:``,diskVersion:``,needsRestart:!1}});let e={source:`unavailable`,models:[],levels:[],agents:[],problems:[],directory:``,prompts:[],workspaceId:``,skills:[],commands:[],fetchedAt:new Date().toISOString()};for(let t of[`model.catalog`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`,`prompt.catalog`])this.deliver({type:t,catalog:e});for(let[e,t]of this.catalogs.get(A)??[])[`providers.list`,`model.catalog.all`].includes(e)||this.deliver({...t,sourceServerId:A});let t=this.sockets.get(A);if(t?.readyState===WebSocket.OPEN){this.onopen?.();for(let e of[`catalog.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])t.send(JSON.stringify({type:e}))}this.activateSettings()};activateSettings=()=>{for(let e of[`agent.catalog`,`subagent.catalog`])this.deliver({type:e,catalog:{source:`unavailable`,agents:[],problems:[],directory:``,fetchedAt:``},sourceServerId:j});this.deliver({type:`model.catalog.all`,catalog:{source:`unavailable`,models:[],levels:[],fetchedAt:``},sourceServerId:j}),this.deliver({type:`providers.list`,providers:[],apis:[],sourceServerId:j});for(let[e,t]of this.catalogs.get(j)??[])[`providers.list`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`].includes(e)&&this.deliver({...t,sourceServerId:j});let e=this.sockets.get(j);if(e?.readyState===WebSocket.OPEN)for(let t of[`catalog.fetchAll`,`providers.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])e.send(JSON.stringify({type:t}))};reconfigure=()=>{for(let e of this.snapshots.keys())O.some(t=>t.id===e)||(this.snapshots.delete(e),N.delete(e),this.catalogs.delete(e),re.delete(e),ee.delete(e));for(let[e,t]of this.sockets)O.some(t=>t.id===e&&t.enabled&&(t.revision??0)===this.socketRevisions.get(e))||(this.sockets.delete(e),t.close(),clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),O.some(t=>t.id===e)||(this.snapshots.delete(e),ee.delete(e)));for(let e of O)e.enabled||re.set(e.id,{state:`disabled`}),e.enabled&&!this.sockets.has(e.id)&&!this.connecting.has(e.id)&&this.connect(e.id);this.aggregate()};async connect(e,t=0){if(!(this.stopped||this.sockets.has(e)||!O.some(t=>t.id===e&&t.enabled))){this.connecting.add(e),re.set(e,{state:`connecting`}),ie();try{let n=Se(e);if(e!==`entry`){let t=await je(e,Ce(n,`/api/browser-access`),{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw Error(`授权或连接失败(${t.status})`);let r=await t.json();if(r.id!==n.identity||r.protocol!==1)throw Error(`服务器身份或协议发生变化,请重新添加连接`);F.set(e,r.assetLease)}if(this.stopped||!O.some(t=>t.id===e&&t.enabled))return;let r=Ce(n,`/ws?state=focused`);r.protocol=r.protocol===`https:`?`wss:`:`ws:`,this.focus&&h(this.focus).server===e&&r.searchParams.set(`conversationId`,h(this.focus).id);let i=e===`entry`||n.managed?new WebSocket(r):new WebSocket(r,[`super-pi`,`super-pi-key.${k[e]}`]),a=!1;this.sockets.set(e,i),this.socketRevisions.set(e,n.revision??0),i.onopen=()=>{a=!0,re.set(e,{state:`online`}),ie(),i.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),e===A&&this.onopen?.(),this.onserveropen?.(e),e!==`entry`&&this.leaseTimers.set(e,setInterval(()=>{je(e,Ce(n,`/api/browser-access`)).then(e=>e.json()).then(t=>{t.assetLease&&(F.set(e,t.assetLease),ie())}).catch(()=>{})},9e5))},i.onmessage=({data:t})=>{let n=S(JSON.parse(String(t)),t=>m(e,t));if(n.type===`state`)ee.add(e),this.snapshots.set(e,n.state),N.set(e,n.state),this.aggregate();else{if(Me.has(n.type)){let t=this.catalogs.get(e)??new Map;t.set(n.type,n),this.catalogs.set(e,t);let r=[`providers.list`,`model.catalog.all`].includes(n.type),i=[`agent.catalog`,`subagent.catalog`].includes(n.type);if(r?e!==j:e!==A&&!(i&&e===j))return}this.deliver({...n,sourceServerId:e})}},i.onclose=()=>{this.stopped||this.sockets.get(e)!==i||(clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),this.sockets.delete(e),re.set(e,{state:`offline`,error:`连接中断,正在重连`}),ie(),a&&this.ondisconnect?.(e),this.retry(e,a?1:t+1))},i.onerror=()=>{}}catch(n){re.set(e,{state:`offline`,error:n instanceof Error?n.message:`连接失败`}),ie(),this.retry(e,t+1)}finally{this.connecting.delete(e)}}}retry(e,t){clearTimeout(this.timers.get(e)),this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.connect(e,t)},Math.min(3e4,1e3*2**Math.min(t,5))))}send(e){let t=JSON.parse(e),n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`,r=typeof t._server==`string`?t._server:void 0,i=Te(t,r??(n?this.terminalServer:A));if(r&&i!==r)throw Error(`命令资源不属于指定服务器`);delete t._server;let a=this.sockets.get(i);if(!a||a.readyState!==WebSocket.OPEN)throw Error(`${pe(i)} 未连接,操作未发送`);t.type===`state.subscribe`&&(this.focus=t.conversationId),t.type===`terminal.sync`&&(this.terminalServer=i),Array.isArray(t.images)&&(t.images=t.images.map(e=>({...e,id:g(i,e.id)}))),a.send(JSON.stringify(Ee(t,i)))}canSend(e){try{let t=e,n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`?this.terminalServer:A,r=Te(e,t._server??n);return(!t._server||r===t._server)&&this.sockets.get(r)?.readyState===WebSocket.OPEN}catch{return!1}}close(){this.stopped=!0,clearInterval(this.managementTimer),window.removeEventListener(`super-pi-server-connections`,this.reconfigure),window.removeEventListener(`super-pi-active-server`,this.activate),window.removeEventListener(`super-pi-settings-server`,this.activateSettings);for(let e of this.timers.values())clearTimeout(e);for(let e of this.leaseTimers.values())clearInterval(e);for(let e of this.sockets.values())e.close()}};function Pe(e,t){return new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}:${t}`).origin}var Fe=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ie=t(((e,t)=>{t.exports=Fe()})),L=Ie();function Le({verification:e,onAnswer:t,onCancel:n}){let r=(0,u.useId)(),[i,a]=(0,u.useState)(()=>e.prompts.map(()=>``)),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``);return(0,L.jsxs)(`form`,{className:`managed-server-form managed-auth-challenge`,"data-ssh-verification":e.id,"aria-labelledby":r,onSubmit:async n=>{n.preventDefault(),s(!0),l(``);let r=i;a(e.prompts.map(()=>``));try{await t(r)}catch(e){l(e instanceof Error?e.message:`验证未完成,请重试`)}finally{s(!1)}},children:[(0,L.jsxs)(`h4`,{id:r,children:[`等待 SSH 交互验证`,e.name?` · ${e.name}`:``]}),e.instruction&&(0,L.jsx)(`p`,{className:`managed-auth-instruction`,children:e.instruction}),e.prompts.map((e,t)=>(0,L.jsxs)(`label`,{children:[e.prompt||`验证输入 ${t+1}`,(0,L.jsx)(`input`,{type:e.echo?`text`:`password`,value:i[t],autoComplete:e.echo?`off`:`new-password`,spellCheck:!1,autoFocus:t===0,disabled:o,onChange:e=>a(n=>n.map((n,r)=>r===t?e.target.value:n))})]},t)),(0,L.jsxs)(`small`,{children:[`仅用于本次连接,不保存验证回答。请在 `,new Date(e.expiresAt).toLocaleTimeString(),` 前完成。`]}),c&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:c}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,disabled:o,children:o?`正在验证…`:e.prompts.length?`提交验证`:`继续验证`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{a(e.prompts.map(()=>``)),s(!0);try{await n()}catch(e){l(e instanceof Error?e.message:`取消失败,请重试`)}finally{s(!1)}},children:`取消验证`})]})]})}var Re=()=>({name:``,host:``,sshPort:`22`,username:``,servicePort:`3080`,serviceHost:`0.0.0.0`,authentication:`password`}),ze={offline:`未连接`,connecting:`连接中`,online:`已连接`,needsTrust:`等待确认指纹`,awaitingVerification:`等待交互验证`};function Be(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(Re),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(new Set),v=(0,u.useRef)(new Set),y=async()=>{let e=await ke(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)},f),n=await e.json();return r(e.ok&&n.available===!0),Array.isArray(n.profiles)&&t(n.profiles),n};(0,u.useEffect)(()=>{let e=!1,t=()=>{e||y().catch(()=>{e||r(!1)})};t();let n=setInterval(t,2e3);return()=>{e=!0,clearInterval(n)}},[]);let b=async e=>{let n=await ke(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(3e4)},f),r=await n.json();if(Array.isArray(r.profiles)&&t(r.profiles),we(),!n.ok)throw Error(r.error??`操作失败`);return r};(0,u.useEffect)(()=>{for(let t of e)g.has(t.id)&&!v.current.has(t.id)&&t.ssh===`online`&&[`idle`,`ready`].includes(t.phase)&&t.fingerprint&&(v.current.add(t.id),_(e=>new Set([...e].filter(e=>e!==t.id))),b({action:`deploy`,id:t.id}).catch(e=>l(e instanceof Error?e.message:`部署未开始`)).finally(()=>v.current.delete(t.id)))},[e,g]);let x=async(e,t,n={})=>{s(!0),l(``);try{await b({id:e,action:t,...n})}catch(e){l(e instanceof Error?e.message:`操作失败`)}finally{s(!1)}},S=e=>{a({id:e.id,name:e.name,host:e.host,username:e.username,sshPort:String(e.sshPort),servicePort:String(e.servicePort),serviceHost:e.serviceHost??`127.0.0.1`,authentication:e.authentication,identityFile:e.identityFile,serviceUrl:e.serviceUrl===Pe(e.host,e.servicePort)?``:e.serviceUrl}),h(!0),l(``)},C=async(e,t=e.id??`draft`)=>{s(!0),l(``);try{let n=await b({action:`probeService`,profile:{...e,servicePort:Number(e.servicePort),...e.sshPort===void 0?{}:{sshPort:Number(e.sshPort)}}});n.probe&&p(e=>({...e,[t]:n.probe}))}catch(e){l(e instanceof Error?e.message:`无法检测服务端口`)}finally{s(!1)}};return(0,u.useEffect)(()=>{p(e=>{let t={...e};return delete t.draft,t})},[i.host,i.servicePort,i.serviceUrl,i.serviceAccessToken]),n===!1?(0,L.jsxs)(`div`,{className:`server-managed-unavailable`,children:[(0,L.jsx)(`h4`,{children:`请使用本地完整安装开启 SSH 托管`}),(0,L.jsxs)(`p`,{children:[`运行 `,(0,L.jsx)(`code`,{children:`super_pi desktop`}),` 打开桌面端,或在自己的电脑启动完整包,再通过本机网页访问。纯服务包只负责远端执行,不保存其他服务器的 SSH 资料。`]})]}):(0,L.jsxs)(`div`,{className:`managed-servers-panel`,"data-managed-servers":`1`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`预览功能:SSH 自动部署仍在完善跨平台兼容性。部署失败时可查看下方日志并重试;已有服务也可以使用“已有服务直接连接”。`}),(0,L.jsxs)(`div`,{className:`managed-overview`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:`本地配置,统一接入`}),(0,L.jsx)(`p`,{children:`默认通过 Super Pi 的 IP 和端口直连。SSH 用于安装与维护,访问隧道可按服务器手动开启。`}),(0,L.jsx)(`small`,{children:`SSH 资料保存在当前入口服务所在的电脑。新托管服务调用模型时本地入口需在线;已有服务继续使用它原来的模型配置。`})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ue(f),window.dispatchEvent(new Event(`super-pi-open-local-model-settings`))},children:`配置本地模型`})]}),(0,L.jsxs)(`div`,{className:`managed-toolbar`,children:[(0,L.jsxs)(`span`,{children:[e.length,` 台服务器`]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(``,`syncAll`),children:`同步全部模型目录`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(Re()),h(!0)},children:`+ 添加 SSH 服务器`})]})]}),n===void 0&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取本地托管配置…`}),e.length===0&&!m&&(0,L.jsxs)(`div`,{className:`managed-empty`,children:[(0,L.jsx)(`strong`,{children:`尚未添加服务器`}),(0,L.jsx)(`p`,{children:`只需要提供 SSH 访问方式和希望使用的服务端口。通过 SSH 隧道访问时,无需向外网开放这个端口。`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(!0),children:`添加并部署第一台服务器`})]}),(0,L.jsx)(`div`,{className:`managed-server-list`,children:e.map(e=>(0,L.jsxs)(`section`,{className:`managed-server-card`,"data-managed-server":e.id,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:e.name}),(0,L.jsxs)(`small`,{children:[e.username,`@`,e.host,`:`,e.sshPort,` · Super Pi `,e.servicePort]})]}),(0,L.jsx)(`span`,{className:`managed-phase`,"data-phase":e.phase,children:e.enabled?e.phase===`deploying`?`部署中`:e.phase===`ready`?`可使用`:e.phase===`awaitingVerification`?`等待验证`:e.phase===`connecting`?`连接中`:e.phase===`needsTrust`?`待确认`:e.phase===`failed`?`需要处理`:e.ssh===`online`?`SSH 已连接`:e.enabled?`待连接`:`已停用`:`已停用`})]}),(0,L.jsxs)(`dl`,{className:`managed-connectivity`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`服务访问`}),(0,L.jsx)(`dd`,{children:e.enabled?e.service===`online`?e.transport===`direct`?`直连在线`:`SSH 隧道在线`:e.service===`offline`?`当前不可达`:`正在确认`:`已停用`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`SSH 管理`}),(0,L.jsxs)(`dd`,{children:[ze[e.ssh],e.sshError&&(0,L.jsx)(`small`,{className:`server-connection-error`,children:e.sshError})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.existingService?.attached?`模型配置`:`本地模型通道`}),(0,L.jsxs)(`dd`,{children:[e.existingService?.attached?`沿用远端配置`:e.modelChannel===`online`?`已连接`:`未连接`,e.modelError&&(0,L.jsxs)(`small`,{className:`server-connection-error`,children:[`模型同步未完成 · `,e.modelError]})]})]})]}),e.serviceUrl&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[e.enabled&&e.service===`offline`&&e.serviceError&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`status`,children:e.serviceError}),d[e.id]&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d[e.id].authorized?`online`:d[e.id].reachable?`reachable`:`offline`,children:[`上次手动测试 · `,d[e.id].message,` · `,d[e.id].latencyMs,` ms`]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void C({id:e.id}),children:`测试服务端口`}),e.ssh===`online`?(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(e.id,`disconnectSsh`),children:`断开 SSH 管理`}):(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh===`connecting`||e.ssh===`awaitingVerification`,onClick:()=>void x(e.id,`connectSsh`),children:`连接 SSH 管理`}),e.enabled&&(e.allowServiceTunnel||e.service===`offline`)&&(0,L.jsx)(`button`,{type:`button`,"data-service-tunnel-toggle":!0,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.allowServiceTunnel?`disableServiceTunnel`:`enableServiceTunnel`),children:e.allowServiceTunnel?`关闭 SSH 隧道访问`:`启用 SSH 隧道访问`})]})]}),e.existingService&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[(0,L.jsxs)(`h4`,{children:[e.existingService.attached?`已接入已有服务`:e.existingService.running?`发现正在运行的 Super Pi`:`发现已有 Super Pi 安装`,e.existingService.version?` · v${e.existingService.version}`:``]}),(0,L.jsx)(`p`,{children:e.existingService.attached?`保留原端口、工作区、会话和模型配置。未重装或重启原服务。`:e.existingService.running?`原服务仍在运行,补充访问授权后即可接入。`:`原有数据保持原样,不会自动创建空实例。`}),e.existingService.dataDirectory&&(0,L.jsxs)(`small`,{children:[`原数据目录:`,(0,L.jsx)(`code`,{children:e.existingService.dataDirectory})]}),!e.existingService.running&&e.existingService.canStart&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh!==`online`,onClick:()=>void x(e.id,`startExisting`),children:`启动并接入原服务`})]}),(0,L.jsx)(Ve,{profile:e,busy:o,onApply:t=>void x(e.id,`applyListener`,{serviceHost:t})}),e.phase===`deploying`&&(0,L.jsxs)(`div`,{className:`managed-progress`,role:`status`,children:[(0,L.jsx)(`progress`,{"aria-label":`远端部署进度`}),(0,L.jsx)(`span`,{children:e.step})]}),e.error&&(0,L.jsxs)(`p`,{className:`server-connection-error`,role:`status`,children:[`上次操作未完成 · `,e.error]}),e.verification&&(0,L.jsx)(Le,{verification:e.verification,onAnswer:t=>b({action:`answerVerification`,id:e.id,verificationId:e.verification.id,answers:t}).then(()=>{}),onCancel:()=>(_(t=>new Set([...t].filter(t=>t!==e.id))),b({action:`cancelVerification`,id:e.id,verificationId:e.verification.id}).then(()=>{}))},e.verification.id),e.observedFingerprint&&(0,L.jsxs)(`div`,{className:`managed-host-trust`,children:[(0,L.jsx)(`strong`,{children:e.fingerprint?`主机指纹已变化`:`首次连接:确认 SSH 主机指纹`}),(0,L.jsx)(`code`,{children:e.observedFingerprint}),(0,L.jsx)(`small`,{children:`请与服务器管理员或已有 SSH 记录核对;确认后才会安装或执行远端命令。`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0),l(``);try{await b({action:`trust`,id:e.id,fingerprint:e.observedFingerprint})}catch(e){l(e instanceof Error?e.message:`连接失败`)}finally{s(!1)}},children:g.has(e.id)?`确认指纹并继续部署`:`信任此主机并连接`})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o||!!e.existingService||e.phase===`deploying`||!e.fingerprint,title:e.existingService?`已识别原安装,保留原服务及数据`:void 0,onClick:()=>void x(e.id,`deploy`),children:e.existingService?.attached?`已保留原服务`:e.deployedAt?`重新部署/升级`:`一键安装并接入`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.enabled?`disconnect`:`connect`),children:e.enabled?`停用连接`:`启用连接`}),!e.serviceUrl&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`connectSsh`),children:`检测/连接 SSH`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.service!==`online`||e.existingService?.attached,title:e.existingService?.attached?`原服务沿用远端模型配置`:void 0,onClick:()=>void x(e.id,`sync`),children:`同步模型`}),(0,L.jsx)(`button`,{type:`button`,disabled:e.phase===`deploying`,onClick:()=>S(e),children:`编辑`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`remove`),children:`移除连接`})]}),(e.log?.length||e.remoteRoot)&&(0,L.jsxs)(`details`,{className:`managed-diagnostics`,children:[(0,L.jsx)(`summary`,{children:`部署记录与日志位置`}),e.remoteRoot&&(0,L.jsxs)(`p`,{children:[`远端目录:`,(0,L.jsx)(`code`,{children:e.remoteRoot}),(0,L.jsx)(`br`,{}),`服务日志:`,(0,L.jsxs)(`code`,{children:[e.remoteRoot,`/service.log`]})]}),e.log?.length?(0,L.jsx)(`pre`,{children:e.log.join(`
|
|
10
|
+
`).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&fn(e,``+r);else return;break;case`className`:Xt(e,`class`,r);break;case`tabIndex`:Xt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Xt(e,n,r);break;case`style`:hn(e,r,a);return;case`data`:if(t!==`object`){Xt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=bn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=yn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Yt(e,`popover`,r);break;case`xlinkActuate`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Yt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=_n.get(n)||n,Yt(e,n,r);else return}qt=!0}function rp(e,t,n,r,i,a){switch(n){case`style`:hn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)fn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=bn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Bt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[wt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}qt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Yt(e,n,r)}return}qt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,a,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:np(e,t,r,d,n,null)}}sn(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&ln(e,!!r,n,!0):ln(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:np(e,t,s,c,n,null)}dn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,u,r,n,null)}return;default:if(gn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(qt=!0),a=m;break;case`name`:m!==f&&(qt=!0),i=m;break;case`checked`:m!==f&&(qt=!0),u=m;break;case`defaultChecked`:m!==f&&(qt=!0),d=m;break;case`value`:m!==f&&(qt=!0),s=m;break;case`defaultValue`:m!==f&&(qt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}on(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||np(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(qt=!0),p=a;break;case`defaultValue`:a!==l&&(qt=!0),c=a;break;case`multiple`:a!==l&&(qt=!0),s=a;default:a!==l&&np(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?ln(e,!!n,n?[]:``,!1):ln(e,!!n,t,!0)):ln(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:i!==a&&(qt=!0),p=i;break;case`defaultValue`:i!==a&&(qt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&np(e,t,s,i,r,a)}un(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(qt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(gn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[Ct]=r,n[wt]=t,ip(n,e,t),Lt(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[At]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Nt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(o(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Mt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[At])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===bn&&(e.onclick=null),Mt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Mt(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=he.d;he.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Pt(e);t!==null&&t.tag===5&&t.type===`form`?Ys(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=an(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Lt(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+an(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+an(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+an(n.imageSizes)+`"]`)):i+=`[href="`+an(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[jt]=!0,o.onload=o.onerror=function(){Rt(o)}),Lt(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+an(r)+`"][href="`+an(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Lt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=It(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Lt(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=It(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Lt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=It(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Lt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=we.current)?Sm(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=It(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var a=It(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Lm(e)))?a._p||(s.instance=a,s.state.loading=5):(a=bm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,a)),zm(i,e,a,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=It(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Im(e){return`href="`+an(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[jt]){r.loading=1;return}}else t=e.createElement(`link`),t[jt]=!0,t.onload=t.onerror=Rt.bind(null,t),ip(t,`link`,n),Lt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+an(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+an(n.href)+`"]`);if(r)return t.instance=r,Lt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Lt(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var a=e.querySelector(Lm(i));if(a)return t.state.loading|=4,t.instance=a,Lt(a),a;r=Rm(n),(i=bm.get(i))&&Wm(r,i),a=(e.ownerDocument||e).createElement(`link`),Lt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(a,`link`,r),t.state.loading|=4,Um(a,n.precedence,e),t.instance=a;case`script`:return a=Bm(n.src),(i=e.querySelector(Vm(a)))?(t.instance=i,Lt(i),i):(r=n,(i=bm.get(a))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Lt(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[At]||a[Ct]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Lt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:P,Provider:null,Consumer:null,_currentValue:ge,_currentValue2:ge,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ni(3,null,null,t),e.current=a,a.stateNode=e,t=Na(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},co(a),e}function fh(e){return e?(e=ji,e):ji}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=uo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=fo(e,r,t),n!==null&&(Nd(n,e,t),po(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=Oi(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=vt(t);var n=Oi(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=I.T;I.T=null;var a=he.p;try{he.p=2,xh(e,t,n,r)}finally{he.p=a,I.T=i}}function bh(e,t,n,r){var i=I.T;I.T=null;var a=he.p;try{he.p=8,xh(e,t,n,r)}finally{he.p=a,I.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Pt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ot(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-$e(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ve()+500,Df(0,!1))}}break;case 31:case 13:s=Oi(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=Sn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=Nt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`: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`seeked`:case`submit`:case`toggle`: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`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(He()){case Ue:return 2;case We:return 8;case Ge:case Ke:return 32;case qe:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`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`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Pt(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=Nt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,xt(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,xt(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);xn=r,n.target.dispatchEvent(r),xn=null}else return t=Pt(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Pt(n);a!==null&&(e.splice(t,3),t-=3,qs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[wt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[wt]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[Tt]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=bt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(o(527,Jh,`19.3.1`));he.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{Xe=Xh.inject(Yh),Ze=Xh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(o(299));var n=!1,r=``,i=gc,a=_c,s=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,a,s,Gh),e[Tt]=t.current,Gf(e),new Kh(t)}})),l=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=e(r(),1),d=l(),f=`entry`,p=`sp-remote:`;function m(e,t){return e===`entry`?t:`${p}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function h(e){if(!e.startsWith(p))return{server:f,id:e};let t=e.indexOf(`:`,10);if(t<0)throw Error(`服务器资源标识无效`);return{server:decodeURIComponent(e.slice(10,t)),id:decodeURIComponent(e.slice(t+1))}}function g(e,t){if(!t.startsWith(p))return t;let n=h(t);if(n.server!==e)throw Error(`图片不属于此服务器,请在当前会话重新上传`);return n.id}var _=new Set([`workspaceId`,`conversationId`,`contextConversationId`,`messageId`,`sessionId`,`runId`,`taskId`,`parentConversationId`,`originMessageId`,`followedWorktreeId`,`worktreeOf`,`ownerConversationId`,`parentRunId`,`projectId`,`roomId`,`topicId`,`entityId`,`sourceConversationId`,`targetConversationId`,`forkedId`,`checkoutId`,`replyToMessageId`,`parentMessageId`,`replyTo`,`activate`]),v=new Set([`workspaces`,`conversations`,`messages`,`subagentRuns`,`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`rooms`,`topics`,`run`,`workflow`,`room`,`task`,`conversation`,`workspace`,`withdrawn`,`terminals`,`sessions`,`tools`,`projects`]),y=new Set([`collapsedConversationIds`,`unlockedChildConversationIds`,`stoppingConversationIds`,`conversationIds`,`workspaceIds`,`messageIds`]),b=new Set([`todosByConversation`,`pendingUserDecisionsByConversation`]),x=new Set([`args`,`arguments`,`parameters`,`schema`,`result`,`providers`,`images`,`attachments`,`toolCalls`,`defaultModel`,`model`,`agents`]);function S(e,t,n=``){return Array.isArray(e)?e.map(e=>S(e,t,n)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([r,i])=>typeof i==`string`&&i.length>0&&(_.has(r)||(r===`id`||r===`execution`)&&i.startsWith(p)||r===`id`&&(v.has(n)||`workspaceId`in e||`conversationId`in e||e.type===`group.activity`))?[r,t(i)]:y.has(r)&&Array.isArray(i)?[r,i.map(e=>typeof e==`string`?t(e):e)]:b.has(r)&&i&&typeof i==`object`?[r,Object.fromEntries(Object.entries(i).map(([e,n])=>[t(e),n]))]:x.has(r)?[r,i]:[r,S(i,t,r)]))}function C(e){let t=new Set;return S(e,e=>(t.add(h(e).server),e)),t}var w=`super-pi.server-connections.v1`,T=`super-pi.server-credentials.v1`,E=globalThis.fetch.bind(globalThis),D=typeof location>`u`?`http://localhost`:location.origin,O=[{id:f,name:`当前入口`,url:D,enabled:!0}],k={};try{let e=JSON.parse(localStorage.getItem(w)??`[]`);O=[{...O[0],name:e.find(e=>e.id===`entry`)?.name||`当前入口`},...e.filter(e=>e.id!==f)],k=JSON.parse(localStorage.getItem(T)??`{}`)}catch{}var A=f,j=f,M=!1,N=new Map,ee=new Set;function P(e){if(!e)return!1;let t=h(e).server;return O.some(e=>e.id===t)&&!ee.has(t)}var te=0,ne=new Set,re=new Map,F=new Map,ie=()=>{te++;for(let e of ne)e()},ae=e=>(ne.add(e),()=>{ne.delete(e)});function oe(){return(0,u.useSyncExternalStore)(ae,()=>te),{connections:O,statuses:re,activeServer:A,settingsServer:j,settingsSnapshot:N.get(j)}}function se(e){return e?h(e).server:A}function ce(){return A}function le(){return j}function ue(e){if(!O.some(t=>t.id===e))throw Error(`目标服务器已移除`);j!==e&&(j=e,ie(),window.dispatchEvent(new Event(`super-pi-settings-server`)))}function de(){M=!0,ue(A)}function fe(){M=!1,ue(A)}function pe(e){return O.find(t=>t.id===e)?.name??`未知服务器`}function me(e){return pe(h(e).server)}function I(e){if(e!==A){if(!O.some(t=>t.id===e))throw Error(`服务器已被移除`);A=e,M||ue(e),ie(),window.dispatchEvent(new Event(`super-pi-active-server`))}}function he(){localStorage.setItem(w,JSON.stringify(O)),localStorage.setItem(T,JSON.stringify(k)),ie(),window.dispatchEvent(new Event(`super-pi-server-connections`))}function ge(e,t){if(!t.trim())throw Error(`服务器名称不能为空`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在,请使用容易区分的名称`);O=O.map(n=>n.id===e?{...n,name:t.trim()}:n),he()}function _e(e){if(e===`entry`)return;let t=A===e;O=O.filter(t=>t.id!==e),delete k[e],F.delete(e),t&&(A=f),j===e&&ue(f),he(),t&&window.dispatchEvent(new Event(`super-pi-active-server`))}function ve(e,t){O=O.map(n=>n.id===e?{...n,enabled:t}:n),he()}async function ye(e,t,n){let r=new URL(t);if(![`http:`,`https:`].includes(r.protocol)||r.username||r.password||r.search||r.hash||r.pathname!==`/`)throw Error(`请输入 http(s)://主机:端口,不能包含路径或凭证`);if(location.protocol===`https:`&&r.protocol===`http:`)throw Error(`HTTPS 页面无法连接 HTTP 服务,请为目标服务启用 HTTPS,或从 HTTP 入口访问`);if(!e.trim()||!n.trim())throw Error(`请填写服务器名称和连接密钥`);if(O.some(t=>t.name===e.trim()))throw Error(`服务器名称已存在,请使用不同的名称`);let i=await be(r.origin,n.trim());if(!i.ok)throw Error(`连接失败(${i.status}),请检查服务版本、地址和连接密钥`);let a=await i.json();if(a.protocol!==1||typeof a.id!=`string`)throw Error(`目标服务不支持多服务端协议,请先更新目标服务`);if(O.some(e=>e.url===r.origin||e.identity===a.id))throw Error(`这台服务器已经添加`);let o=await E(`/api/browser-access`).then(e=>e.json()).catch(()=>void 0);if(a.id===o?.id)throw Error(`这是当前入口服务器,无需重复添加`);let s=crypto.randomUUID();return k[s]=n.trim(),O=[...O,{id:s,name:e.trim(),url:r.origin,enabled:!0,identity:a.id}],he(),s}async function be(e,t){try{return await E(`${e}/api/browser-access`,{headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(15e3),credentials:`omit`})}catch(e){throw Error(e instanceof Error&&e.name===`TimeoutError`?`连接超时,请检查目标服务器是否启动、端口是否开放`:`浏览器无法连接目标服务器,请检查地址、网络可达性、HTTPS 证书,以及目标是否已更新到支持多服务端的版本`)}}async function xe(e,t,n,r){let i=Se(e),a=new URL(n);if(![`http:`,`https:`].includes(a.protocol)||a.username||a.password||a.search||a.hash||a.pathname!==`/`)throw Error(`请输入不包含路径或凭证的 HTTP(S) 服务地址`);if(location.protocol===`https:`&&a.protocol===`http:`)throw Error(`HTTPS 页面不能连接 HTTP 服务`);if(!t.trim())throw Error(`请输入服务器名称`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在`);let o=r.trim()||k[e],s=await be(a.origin,o);if(!s.ok)throw Error(`连接失败(${s.status}),请检查地址和密钥`);let c=await s.json();if(c.protocol!==1||c.id!==i.identity)throw Error(`地址指向另一台服务器,请使用“添加服务器”,以保护现有资源和标签的归属`);k[e]=o,O=O.map(n=>n.id===e?{...n,name:t.trim(),url:a.origin,revision:(n.revision??0)+1}:n),F.delete(e),he()}function Se(e){let t=O.find(t=>t.id===e);if(!t||!t.enabled)throw Error(`目标服务器已移除或停用,操作未发送`);return t}function Ce(e,t){return new URL(`${e.url.replace(/\/$/,``)}${t.startsWith(`/`)?t:`/${t}`}`)}async function we(){try{let e=await E(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)});if(!e.ok)return;let t=await e.json();if(!t.available||!Array.isArray(t.connections))return;let n=t.connections.map(e=>({...e,url:new URL(e.url,D).href})),r=[...O.filter(e=>!e.managed),...n];if(JSON.stringify(r)!==JSON.stringify(O)){O=r;let e=!O.some(e=>e.id===A);e&&(A=f),O.some(e=>e.id===j)||ue(f),he(),e&&window.dispatchEvent(new Event(`super-pi-active-server`))}}catch{}}function Te(e,t=A){let n=C(e);if(n.size>1)throw Error(`一次操作不能混用不同服务器的资源`);return[...n][0]??t}function Ee(e,t){return S(e,e=>{let n=h(e);if(n.server!==t)throw Error(`资源不属于目标服务器`);return n.id})}function De(e){let t=/^(\/api\/upload\/|\/api\/projects\/|\/tools\/)([^/]+)(.*)$/.exec(e.pathname);if(!t)return{path:e.pathname};let n=h(decodeURIComponent(t[2])),r=t[3];return t[1]===`/api/upload/`&&/^\/[^/]+$/.test(r)&&(r=`/${encodeURIComponent(g(n.server,decodeURIComponent(r.slice(1))))}`),{server:n.server,path:`${t[1]}${encodeURIComponent(n.id)}${r}`}}function Oe(e){let t=new URL(e,location.origin);if(O.some(e=>e.managed&&t.href.startsWith(`${e.url}/`))||t.origin!==location.origin)return e;let n=Object.fromEntries(t.searchParams),r=De(t),i=Te(n,r.server??A),a=Se(i);for(let[e,r]of Object.entries(Ee(n,i)))t.searchParams.set(e,r);if(i===`entry`)return`${r.path}${t.search}${t.hash}`;let o=Ce(a,`${r.path}${t.search}${t.hash}`),s=F.get(i);return s&&!a.managed&&o.searchParams.set(`browserAsset`,s),o.href}async function ke(e,t,n){if(typeof e!=`string`&&!(e instanceof URL))throw Error(`服务器请求必须使用明确的 URL`);let r=new URL(String(e),location.origin),i=O.find(e=>e.managed&&r.href.startsWith(`${e.url}/`));if(i){if(n&&n!==i.id)throw Error(`资源不属于指定的服务器`);return je(i.id,r,t)}if(r.origin!==location.origin){let n=O.find(e=>e.url===r.origin);return n?(r.searchParams.delete(`browserAsset`),je(n.id,r,t)):E(e,t)}if(!r.pathname.startsWith(`/api/`))return E(e,t);let a;if(typeof t?.body==`string`)try{a=JSON.parse(t.body)}catch{}t?.body instanceof FormData&&(a=Object.fromEntries([...t.body].filter(([,e])=>typeof e==`string`)));let o=De(r),s=Te({...Object.fromEntries(r.searchParams),payload:a},o.server??n??A);if(n&&n!==s)throw Error(`资源不属于指定的服务器`);if(o.server&&o.server!==s)throw Error(`路径和参数属于不同服务器`);let c=Se(s);for(let[e,t]of Object.entries(Ee(Object.fromEntries(r.searchParams),s)))r.searchParams.set(e,t);let l=t;if(typeof t?.body==`string`&&a&&(l={...t,body:JSON.stringify(Ee(a,s))}),t?.body instanceof FormData){let e=new FormData,n=Ee(a,s);for(let[r,i]of t.body)e.append(r,typeof i==`string`?n[r]:i);l={...t,body:e}}return je(s,Ce(c,`${o.path}${r.search}`),l)}function Ae(e,t){return ke(e,t,j)}async function je(e,t,n){let r=Se(e),i=new Headers(n?.headers);e!==`entry`&&!r.managed&&i.set(`authorization`,`Bearer ${k[e]??``}`);let a=await E(e===`entry`?`${t.pathname}${t.search}`:t.href,{...n,headers:i,...e!==`entry`&&!r.managed?{credentials:`omit`}:{}});if(e===`entry`||!a.headers.get(`content-type`)?.includes(`application/json`))return a;let o=a.json.bind(a);return a.json=async()=>S(await o(),t=>m(e,t)),a}var Me=new Set([`model.catalog`,`model.catalog.all`,`providers.list`,`agent.catalog`,`prompt.catalog`,`subagent.catalog`,`server.version`,`terminal.status`,`exec.status`]),Ne=class{focus;onserveropen=null;ondisconnect=null;onopen=null;onclose=null;onmessage=null;onerror=null;sockets=new Map;snapshots=new Map;catalogs=new Map;timers=new Map;connecting=new Set;socketRevisions=new Map;leaseTimers=new Map;terminalServer=f;stopped=!1;constructor(e){this.focus=e,window.addEventListener(`super-pi-server-connections`,this.reconfigure),window.addEventListener(`super-pi-active-server`,this.activate),window.addEventListener(`super-pi-settings-server`,this.activateSettings),queueMicrotask(this.reconfigure),we(),this.managementTimer=setInterval(()=>{we()},3e3)}managementTimer;get readyState(){return this.sockets.get(A)?.readyState??WebSocket.CLOSED}deliver(e){this.onmessage?.({data:JSON.stringify(e)})}aggregate(){let e=this.snapshots.get(A),t=[...this.snapshots.values()],n={...e,workspaces:t.flatMap(e=>e.workspaces),conversations:t.flatMap(e=>e.conversations),subagentRuns:t.flatMap(e=>e.subagentRuns)};for(let e of[`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`extensionUi`,`stoppingConversationIds`,`collapsedConversationIds`,`unlockedChildConversationIds`])n[e]=t.flatMap(t=>t[e]??[]);for(let e of[`todosByConversation`,`pendingUserDecisionsByConversation`])n[e]=Object.assign({},...t.map(t=>t[e]));t.length&&this.deliver({type:`state`,state:n})}activate=()=>{this.aggregate(),this.deliver({type:`server.version`,version:{runningVersion:``,diskVersion:``,needsRestart:!1}});let e={source:`unavailable`,models:[],levels:[],agents:[],problems:[],directory:``,prompts:[],workspaceId:``,skills:[],commands:[],fetchedAt:new Date().toISOString()};for(let t of[`model.catalog`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`,`prompt.catalog`])this.deliver({type:t,catalog:e});for(let[e,t]of this.catalogs.get(A)??[])[`providers.list`,`model.catalog.all`].includes(e)||this.deliver({...t,sourceServerId:A});let t=this.sockets.get(A);if(t?.readyState===WebSocket.OPEN){this.onopen?.();for(let e of[`catalog.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])t.send(JSON.stringify({type:e}))}this.activateSettings()};activateSettings=()=>{for(let e of[`agent.catalog`,`subagent.catalog`])this.deliver({type:e,catalog:{source:`unavailable`,agents:[],problems:[],directory:``,fetchedAt:``},sourceServerId:j});this.deliver({type:`model.catalog.all`,catalog:{source:`unavailable`,models:[],levels:[],fetchedAt:``},sourceServerId:j}),this.deliver({type:`providers.list`,providers:[],apis:[],sourceServerId:j});for(let[e,t]of this.catalogs.get(j)??[])[`providers.list`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`].includes(e)&&this.deliver({...t,sourceServerId:j});let e=this.sockets.get(j);if(e?.readyState===WebSocket.OPEN)for(let t of[`catalog.fetchAll`,`providers.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])e.send(JSON.stringify({type:t}))};reconfigure=()=>{for(let e of this.snapshots.keys())O.some(t=>t.id===e)||(this.snapshots.delete(e),N.delete(e),this.catalogs.delete(e),re.delete(e),ee.delete(e));for(let[e,t]of this.sockets)O.some(t=>t.id===e&&t.enabled&&(t.revision??0)===this.socketRevisions.get(e))||(this.sockets.delete(e),t.close(),clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),O.some(t=>t.id===e)||(this.snapshots.delete(e),ee.delete(e)));for(let e of O)e.enabled||re.set(e.id,{state:`disabled`}),e.enabled&&!this.sockets.has(e.id)&&!this.connecting.has(e.id)&&this.connect(e.id);this.aggregate()};async connect(e,t=0){if(!(this.stopped||this.sockets.has(e)||!O.some(t=>t.id===e&&t.enabled))){this.connecting.add(e),re.set(e,{state:`connecting`}),ie();try{let n=Se(e);if(e!==`entry`){let t=await je(e,Ce(n,`/api/browser-access`),{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw Error(`授权或连接失败(${t.status})`);let r=await t.json();if(r.id!==n.identity||r.protocol!==1)throw Error(`服务器身份或协议发生变化,请重新添加连接`);F.set(e,r.assetLease)}if(this.stopped||!O.some(t=>t.id===e&&t.enabled))return;let r=Ce(n,`/ws?state=focused`);r.protocol=r.protocol===`https:`?`wss:`:`ws:`,this.focus&&h(this.focus).server===e&&r.searchParams.set(`conversationId`,h(this.focus).id);let i=e===`entry`||n.managed?new WebSocket(r):new WebSocket(r,[`super-pi`,`super-pi-key.${k[e]}`]),a=!1;this.sockets.set(e,i),this.socketRevisions.set(e,n.revision??0),i.onopen=()=>{a=!0,re.set(e,{state:`online`}),ie(),i.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),e===A&&this.onopen?.(),this.onserveropen?.(e),e!==`entry`&&this.leaseTimers.set(e,setInterval(()=>{je(e,Ce(n,`/api/browser-access`)).then(e=>e.json()).then(t=>{t.assetLease&&(F.set(e,t.assetLease),ie())}).catch(()=>{})},9e5))},i.onmessage=({data:t})=>{let n=S(JSON.parse(String(t)),t=>m(e,t));if(n.type===`state`)ee.add(e),this.snapshots.set(e,n.state),N.set(e,n.state),this.aggregate();else{if(Me.has(n.type)){let t=this.catalogs.get(e)??new Map;t.set(n.type,n),this.catalogs.set(e,t);let r=[`providers.list`,`model.catalog.all`].includes(n.type),i=[`agent.catalog`,`subagent.catalog`].includes(n.type);if(r?e!==j:e!==A&&!(i&&e===j))return}this.deliver({...n,sourceServerId:e})}},i.onclose=()=>{this.stopped||this.sockets.get(e)!==i||(clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),this.sockets.delete(e),re.set(e,{state:`offline`,error:`连接中断,正在重连`}),ie(),a&&this.ondisconnect?.(e),this.retry(e,a?1:t+1))},i.onerror=()=>{}}catch(n){re.set(e,{state:`offline`,error:n instanceof Error?n.message:`连接失败`}),ie(),this.retry(e,t+1)}finally{this.connecting.delete(e)}}}retry(e,t){clearTimeout(this.timers.get(e)),this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.connect(e,t)},Math.min(3e4,1e3*2**Math.min(t,5))))}send(e){let t=JSON.parse(e),n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`,r=typeof t._server==`string`?t._server:void 0,i=Te(t,r??(n?this.terminalServer:A));if(r&&i!==r)throw Error(`命令资源不属于指定服务器`);delete t._server;let a=this.sockets.get(i);if(!a||a.readyState!==WebSocket.OPEN)throw Error(`${pe(i)} 未连接,操作未发送`);t.type===`state.subscribe`&&(this.focus=t.conversationId),t.type===`terminal.sync`&&(this.terminalServer=i),Array.isArray(t.images)&&(t.images=t.images.map(e=>({...e,id:g(i,e.id)}))),a.send(JSON.stringify(Ee(t,i)))}canSend(e){try{let t=e,n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`?this.terminalServer:A,r=Te(e,t._server??n);return(!t._server||r===t._server)&&this.sockets.get(r)?.readyState===WebSocket.OPEN}catch{return!1}}close(){this.stopped=!0,clearInterval(this.managementTimer),window.removeEventListener(`super-pi-server-connections`,this.reconfigure),window.removeEventListener(`super-pi-active-server`,this.activate),window.removeEventListener(`super-pi-settings-server`,this.activateSettings);for(let e of this.timers.values())clearTimeout(e);for(let e of this.leaseTimers.values())clearInterval(e);for(let e of this.sockets.values())e.close()}};function Pe(e,t){return new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}:${t}`).origin}var Fe=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ie=t(((e,t)=>{t.exports=Fe()})),L=Ie();function Le({verification:e,onAnswer:t,onCancel:n}){let r=(0,u.useId)(),[i,a]=(0,u.useState)(()=>e.prompts.map(()=>``)),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``);return(0,L.jsxs)(`form`,{className:`managed-server-form managed-auth-challenge`,"data-ssh-verification":e.id,"aria-labelledby":r,onSubmit:async n=>{n.preventDefault(),s(!0),l(``);let r=i;a(e.prompts.map(()=>``));try{await t(r)}catch(e){l(e instanceof Error?e.message:`验证未完成,请重试`)}finally{s(!1)}},children:[(0,L.jsxs)(`h4`,{id:r,children:[`等待 SSH 交互验证`,e.name?` · ${e.name}`:``]}),e.instruction&&(0,L.jsx)(`p`,{className:`managed-auth-instruction`,children:e.instruction}),e.prompts.map((e,t)=>(0,L.jsxs)(`label`,{children:[e.prompt||`验证输入 ${t+1}`,(0,L.jsx)(`input`,{type:e.echo?`text`:`password`,value:i[t],autoComplete:e.echo?`off`:`new-password`,spellCheck:!1,autoFocus:t===0,disabled:o,onChange:e=>a(n=>n.map((n,r)=>r===t?e.target.value:n))})]},t)),(0,L.jsxs)(`small`,{children:[`仅用于本次连接,不保存验证回答。请在 `,new Date(e.expiresAt).toLocaleTimeString(),` 前完成。`]}),c&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:c}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,disabled:o,children:o?`正在验证…`:e.prompts.length?`提交验证`:`继续验证`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{a(e.prompts.map(()=>``)),s(!0);try{await n()}catch(e){l(e instanceof Error?e.message:`取消失败,请重试`)}finally{s(!1)}},children:`取消验证`})]})]})}var Re=()=>({name:``,host:``,sshPort:`22`,username:``,servicePort:`3080`,serviceHost:`0.0.0.0`,authentication:`password`}),ze={offline:`未连接`,connecting:`连接中`,online:`已连接`,needsTrust:`等待确认指纹`,awaitingVerification:`等待交互验证`};function Be(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(Re),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(new Set),v=(0,u.useRef)(new Set),y=async()=>{let e=await ke(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)},f),n=await e.json();return r(e.ok&&n.available===!0),Array.isArray(n.profiles)&&t(n.profiles),n};(0,u.useEffect)(()=>{let e=!1,t=()=>{e||y().catch(()=>{e||r(!1)})};t();let n=setInterval(t,2e3);return()=>{e=!0,clearInterval(n)}},[]);let b=async e=>{let n=await ke(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(3e4)},f),r=await n.json();if(Array.isArray(r.profiles)&&t(r.profiles),we(),!n.ok)throw Error(r.error??`操作失败`);return r};(0,u.useEffect)(()=>{for(let t of e)g.has(t.id)&&!v.current.has(t.id)&&t.ssh===`online`&&[`idle`,`ready`].includes(t.phase)&&t.fingerprint&&(v.current.add(t.id),_(e=>new Set([...e].filter(e=>e!==t.id))),b({action:`deploy`,id:t.id}).catch(e=>l(e instanceof Error?e.message:`部署未开始`)).finally(()=>v.current.delete(t.id)))},[e,g]);let x=async(e,t,n={})=>{s(!0),l(``);try{await b({id:e,action:t,...n})}catch(e){l(e instanceof Error?e.message:`操作失败`)}finally{s(!1)}},S=e=>{a({id:e.id,name:e.name,host:e.host,username:e.username,sshPort:String(e.sshPort),servicePort:String(e.servicePort),serviceHost:e.serviceHost??`127.0.0.1`,authentication:e.authentication,identityFile:e.identityFile,serviceUrl:e.serviceUrl===Pe(e.host,e.servicePort)?``:e.serviceUrl}),h(!0),l(``)},C=async(e,t=e.id??`draft`)=>{s(!0),l(``);try{let n=await b({action:`probeService`,profile:{...e,servicePort:Number(e.servicePort),...e.sshPort===void 0?{}:{sshPort:Number(e.sshPort)}}});n.probe&&p(e=>({...e,[t]:n.probe}))}catch(e){l(e instanceof Error?e.message:`无法检测服务端口`)}finally{s(!1)}};return(0,u.useEffect)(()=>{p(e=>{let t={...e};return delete t.draft,t})},[i.host,i.servicePort,i.serviceUrl,i.serviceAccessToken]),n===!1?(0,L.jsxs)(`div`,{className:`server-managed-unavailable`,children:[(0,L.jsx)(`h4`,{children:`请使用本地完整安装开启 SSH 托管`}),(0,L.jsxs)(`p`,{children:[`运行 `,(0,L.jsx)(`code`,{children:`super_pi desktop`}),` 打开桌面端,或在自己的电脑启动完整包,再通过本机网页访问。纯服务包只负责远端执行,不保存其他服务器的 SSH 资料。`]})]}):(0,L.jsxs)(`div`,{className:`managed-servers-panel`,"data-managed-servers":`1`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`预览功能:SSH 自动部署仍在完善跨平台兼容性。部署失败时可查看下方日志并重试;已有服务也可以使用“已有服务直接连接”。`}),(0,L.jsxs)(`div`,{className:`managed-overview`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:`本地配置,统一接入`}),(0,L.jsx)(`p`,{children:`默认通过 Super Pi 的 IP 和端口直连。SSH 用于安装与维护,访问隧道可按服务器手动开启。`}),(0,L.jsx)(`small`,{children:`SSH 资料保存在当前入口服务所在的电脑。新托管服务调用模型时本地入口需在线;已有服务继续使用它原来的模型配置。`})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ue(f),window.dispatchEvent(new Event(`super-pi-open-local-model-settings`))},children:`配置本地模型`})]}),(0,L.jsxs)(`div`,{className:`managed-toolbar`,children:[(0,L.jsxs)(`span`,{children:[e.length,` 台服务器`]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(``,`syncAll`),children:`同步全部模型目录`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(Re()),h(!0)},children:`+ 添加 SSH 服务器`})]})]}),n===void 0&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取本地托管配置…`}),e.length===0&&!m&&(0,L.jsxs)(`div`,{className:`managed-empty`,children:[(0,L.jsx)(`strong`,{children:`尚未添加服务器`}),(0,L.jsx)(`p`,{children:`只需要提供 SSH 访问方式和希望使用的服务端口。通过 SSH 隧道访问时,无需向外网开放这个端口。`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(!0),children:`添加并部署第一台服务器`})]}),(0,L.jsx)(`div`,{className:`managed-server-list`,children:e.map(e=>(0,L.jsxs)(`section`,{className:`managed-server-card`,"data-managed-server":e.id,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:e.name}),(0,L.jsxs)(`small`,{children:[e.username,`@`,e.host,`:`,e.sshPort,` · Super Pi `,e.servicePort]})]}),(0,L.jsx)(`span`,{className:`managed-phase`,"data-phase":e.phase,children:e.enabled?e.phase===`deploying`?`部署中`:e.phase===`ready`?`可使用`:e.phase===`awaitingVerification`?`等待验证`:e.phase===`connecting`?`连接中`:e.phase===`needsTrust`?`待确认`:e.phase===`failed`?`需要处理`:e.ssh===`online`?`SSH 已连接`:e.enabled?`待连接`:`已停用`:`已停用`})]}),(0,L.jsxs)(`dl`,{className:`managed-connectivity`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`服务访问`}),(0,L.jsx)(`dd`,{children:e.enabled?e.service===`online`?e.transport===`direct`?`直连在线`:`SSH 隧道在线`:e.service===`offline`?`当前不可达`:`正在确认`:`已停用`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`SSH 管理`}),(0,L.jsxs)(`dd`,{children:[ze[e.ssh],e.sshError&&(0,L.jsx)(`small`,{className:`server-connection-error`,children:e.sshError})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.existingService?.attached?`模型配置`:`本地模型通道`}),(0,L.jsxs)(`dd`,{children:[e.existingService?.attached?`沿用远端配置`:e.modelChannel===`online`?`已连接`:e.modelChannelPaused?`已暂停`:e.ssh===`awaitingVerification`?`等待 SSH 验证`:e.ssh===`connecting`?`正在恢复`:`未连接`,e.modelError&&(0,L.jsxs)(`small`,{className:`server-connection-error`,children:[`模型同步未完成 · `,e.modelError]}),e.modelChannelPaused&&e.enabled&&(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(e.id,`connectSsh`),children:`恢复本地模型通道`})]})]})]}),e.serviceUrl&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[e.enabled&&e.service===`offline`&&e.serviceError&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`status`,children:e.serviceError}),d[e.id]&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d[e.id].authorized?`online`:d[e.id].reachable?`reachable`:`offline`,children:[`上次手动测试 · `,d[e.id].message,` · `,d[e.id].latencyMs,` ms`]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void C({id:e.id}),children:`测试服务端口`}),e.ssh===`online`?(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(e.id,`disconnectSsh`),children:`断开 SSH 管理`}):(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh===`connecting`||e.ssh===`awaitingVerification`,onClick:()=>void x(e.id,`connectSsh`),children:`连接 SSH 管理`}),e.enabled&&(e.allowServiceTunnel||e.service===`offline`)&&(0,L.jsx)(`button`,{type:`button`,"data-service-tunnel-toggle":!0,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.allowServiceTunnel?`disableServiceTunnel`:`enableServiceTunnel`),children:e.allowServiceTunnel?`关闭 SSH 隧道访问`:`启用 SSH 隧道访问`})]})]}),e.existingService&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[(0,L.jsxs)(`h4`,{children:[e.existingService.attached?`已接入已有服务`:e.existingService.running?`发现正在运行的 Super Pi`:`发现已有 Super Pi 安装`,e.existingService.version?` · v${e.existingService.version}`:``]}),(0,L.jsx)(`p`,{children:e.existingService.attached?`保留原端口、工作区、会话和模型配置。未重装或重启原服务。`:e.existingService.running?`原服务仍在运行,补充访问授权后即可接入。`:`原有数据保持原样,不会自动创建空实例。`}),e.existingService.dataDirectory&&(0,L.jsxs)(`small`,{children:[`原数据目录:`,(0,L.jsx)(`code`,{children:e.existingService.dataDirectory})]}),!e.existingService.running&&e.existingService.canStart&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh!==`online`,onClick:()=>void x(e.id,`startExisting`),children:`启动并接入原服务`})]}),(0,L.jsx)(Ve,{profile:e,busy:o,onApply:t=>void x(e.id,`applyListener`,{serviceHost:t})}),e.phase===`deploying`&&(0,L.jsxs)(`div`,{className:`managed-progress`,role:`status`,children:[(0,L.jsx)(`progress`,{"aria-label":`远端部署进度`}),(0,L.jsx)(`span`,{children:e.step})]}),e.error&&(0,L.jsxs)(`p`,{className:`server-connection-error`,role:`status`,children:[`上次操作未完成 · `,e.error]}),e.verification&&(0,L.jsx)(Le,{verification:e.verification,onAnswer:t=>b({action:`answerVerification`,id:e.id,verificationId:e.verification.id,answers:t}).then(()=>{}),onCancel:()=>(_(t=>new Set([...t].filter(t=>t!==e.id))),b({action:`cancelVerification`,id:e.id,verificationId:e.verification.id}).then(()=>{}))},e.verification.id),e.observedFingerprint&&(0,L.jsxs)(`div`,{className:`managed-host-trust`,children:[(0,L.jsx)(`strong`,{children:e.fingerprint?`主机指纹已变化`:`首次连接:确认 SSH 主机指纹`}),(0,L.jsx)(`code`,{children:e.observedFingerprint}),(0,L.jsx)(`small`,{children:`请与服务器管理员或已有 SSH 记录核对;确认后才会安装或执行远端命令。`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0),l(``);try{await b({action:`trust`,id:e.id,fingerprint:e.observedFingerprint})}catch(e){l(e instanceof Error?e.message:`连接失败`)}finally{s(!1)}},children:g.has(e.id)?`确认指纹并继续部署`:`信任此主机并连接`})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o||!!e.existingService||e.phase===`deploying`||!e.fingerprint,title:e.existingService?`已识别原安装,保留原服务及数据`:void 0,onClick:()=>void x(e.id,`deploy`),children:e.existingService?.attached?`已保留原服务`:e.deployedAt?`重新部署/升级`:`一键安装并接入`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.enabled?`disconnect`:`connect`),children:e.enabled?`停用连接`:`启用连接`}),!e.serviceUrl&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`connectSsh`),children:`检测/连接 SSH`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.service!==`online`||e.existingService?.attached,title:e.existingService?.attached?`原服务沿用远端模型配置`:void 0,onClick:()=>void x(e.id,`sync`),children:`同步模型`}),(0,L.jsx)(`button`,{type:`button`,disabled:e.phase===`deploying`,onClick:()=>S(e),children:`编辑`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`remove`),children:`移除连接`})]}),(e.log?.length||e.remoteRoot)&&(0,L.jsxs)(`details`,{className:`managed-diagnostics`,children:[(0,L.jsx)(`summary`,{children:`部署记录与日志位置`}),e.remoteRoot&&(0,L.jsxs)(`p`,{children:[`远端目录:`,(0,L.jsx)(`code`,{children:e.remoteRoot}),(0,L.jsx)(`br`,{}),`服务日志:`,(0,L.jsxs)(`code`,{children:[e.remoteRoot,`/service.log`]})]}),e.log?.length?(0,L.jsx)(`pre`,{children:e.log.join(`
|
|
11
11
|
`)}):null]})]},e.id))}),m&&(0,L.jsxs)(`form`,{className:`managed-server-form`,onSubmit:async e=>{e.preventDefault(),s(!0),l(``);try{let t=(await b({action:`save`,profile:{...i,sshPort:Number(i.sshPort),servicePort:Number(i.servicePort)}})).profiles.find(e=>e.name===i.name.trim()),n=e.nativeEvent.submitter,r=n instanceof HTMLButtonElement&&n.value===`deploy`;r&&_(e=>new Set(e).add(t.id)),h(!1),a(Re()),await b({action:r?`connectSsh`:`test`,id:t.id})}catch(e){l(e instanceof Error?e.message:`无法保存连接`)}finally{s(!1)}},children:[(0,L.jsx)(`h4`,{children:i.id?`编辑 SSH 连接`:`添加 SSH 服务器`}),(0,L.jsxs)(`div`,{className:`managed-form-grid`,children:[(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{required:!0,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:`例如:开发服务器`})]}),(0,L.jsxs)(`label`,{children:[`SSH 地址`,(0,L.jsx)(`input`,{required:!0,value:i.host,onChange:e=>a({...i,host:e.target.value}),placeholder:`IP 或主机名`})]}),(0,L.jsxs)(`label`,{children:[`SSH 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.sshPort,onChange:e=>a({...i,sshPort:e.target.value})})]}),(0,L.jsxs)(`label`,{children:[`SSH 用户名`,(0,L.jsx)(`input`,{required:!0,value:i.username,onChange:e=>a({...i,username:e.target.value}),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.servicePort,onChange:e=>a({...i,servicePort:e.target.value})}),(0,L.jsx)(`small`,{children:`直连需使用已放行的端口;平台不修改防火墙。`})]}),(0,L.jsxs)(`label`,{children:[`服务监听方式`,(0,L.jsxs)(`select`,{"data-service-listener-mode":!0,value:i.serviceHost??`0.0.0.0`,onChange:e=>a({...i,serviceHost:e.target.value}),children:[(0,L.jsx)(`option`,{value:`0.0.0.0`,children:`可直连 · IPv4 所有网卡`}),(0,L.jsx)(`option`,{value:`::`,children:`可直连 · IPv4 / IPv6`}),(0,L.jsx)(`option`,{value:`127.0.0.1`,children:`仅本机回环`})]}),(0,L.jsx)(`small`,{children:`可直连模式强制访问鉴权。更改后需部署以应用,不会仅凭填写地址改变已运行的服务。`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 直连地址(可选)`,(0,L.jsx)(`input`,{type:`url`,value:i.serviceUrl??``,onChange:e=>a({...i,serviceUrl:e.target.value}),placeholder:`https://server.example:8088`}),(0,L.jsx)(`small`,{children:`留空自动使用上面的服务器地址和 Super Pi 端口;HTTPS 或不同地址可在这里指定。不自动开放远端端口。`})]}),(0,L.jsxs)(`label`,{children:[`认证方式`,(0,L.jsxs)(`select`,{"data-ssh-authentication":!0,value:i.authentication,onChange:e=>a({...i,authentication:e.target.value}),children:[(0,L.jsx)(`option`,{value:`password`,children:`SSH 密码`}),(0,L.jsx)(`option`,{value:`privateKey`,children:`SSH 私钥`}),(0,L.jsx)(`option`,{value:`agent`,children:`本地 SSH Agent`})]})]})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-service-port-probe":!0,disabled:o||!i.host.trim()||!i.servicePort,onClick:()=>void C(i,`draft`),children:o?`正在检测…`:`测试服务端口`}),(0,L.jsx)(`small`,{children:`只检测 Super Pi 的 IP 和端口,不进行 SSH 登录,也不安装或重启服务。`})]}),d.draft&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d.draft.authorized?`online`:d.draft.reachable?`reachable`:`offline`,children:[d.draft.message,(0,L.jsx)(`br`,{}),(0,L.jsxs)(`small`,{children:[d.draft.address,` · `,d.draft.latencyMs,` ms`]})]}),i.authentication===`password`&&(0,L.jsxs)(`label`,{children:[`SSH 密码`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.password??``,placeholder:i.id?`留空保留已有密码`:``,required:!i.id,onChange:e=>a({...i,password:e.target.value})})]}),i.authentication===`privateKey`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{children:[`本地私钥文件路径`,(0,L.jsx)(`input`,{value:i.identityFile??``,placeholder:`管理电脑上的私钥绝对路径`,onChange:e=>a({...i,identityFile:e.target.value})})]}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`或者粘贴私钥`}),(0,L.jsx)(`textarea`,{rows:4,value:i.privateKey??``,onChange:e=>a({...i,privateKey:e.target.value}),spellCheck:!1})]}),(0,L.jsxs)(`label`,{children:[`私钥口令(如有)`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.passphrase??``,onChange:e=>a({...i,passphrase:e.target.value})})]})]}),i.authentication===`agent`&&(0,L.jsx)(`small`,{children:`使用管理电脑当前用户的 SSH Agent;需提前将对应密钥加入 Agent。`}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`已有 Super Pi 服务的访问授权(可选)`}),(0,L.jsxs)(`label`,{children:[`原服务访问密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.serviceAccessToken??``,placeholder:`仅在原服务设置过访问密钥时填写;编辑时留空保留`,onChange:e=>a({...i,serviceAccessToken:e.target.value})})]}),(0,L.jsx)(`small`,{children:`用于访问原服务,单独加密保存,不修改原服务的授权设置。`})]}),(0,L.jsx)(`small`,{children:`认证资料在本地管理服务加密保存,不返回浏览器。端口测试不连接 SSH、不安装或重启;安装与维护使用 SSH,部署使用用户目录,无需 sudo。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,value:`connect`,disabled:o,children:o?`正在保存和检测…`:`保存并检测`}),(0,L.jsx)(`button`,{type:`submit`,value:`deploy`,disabled:o,children:`保存并部署`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(Re()),h(!1)},children:`取消`})]})]}),c&&(0,L.jsx)(`p`,{role:`alert`,className:`server-connection-error`,children:c})]})}function Ve({profile:e,busy:t,onApply:n}){if(!e.remoteRoot)return null;let r=e.deployedServiceHost??`127.0.0.1`,i=e.serviceHost??`127.0.0.1`,a=i!==r,o=a?i:`0.0.0.0`;return(0,L.jsxs)(`section`,{className:`managed-existing-service`,"data-service-listener":r,children:[(0,L.jsx)(`h4`,{children:`已部署的服务监听`}),(0,L.jsxs)(`p`,{children:[(0,L.jsxs)(`code`,{children:[r,`:`,e.servicePort]}),r===`127.0.0.1`?` · 仅本机及 SSH 隧道可达`:` · 可通过已放行的服务端口直连`]}),(a||r===`127.0.0.1`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-service-listener-apply":!0,disabled:t||e.phase===`deploying`||!e.fingerprint,onClick:()=>n(o),children:a?`应用监听配置并重新部署`:`启用直连并重新部署`}),(0,L.jsx)(`small`,{children:`保留原数据和会话;会重启远端服务,部署前需结束运行中的任务。`})]})]})}function He({workspaces:e}){let{connections:t}=oe();return(0,L.jsx)(L.Fragment,{children:t.map(t=>{let n=e.filter(e=>h(e.id).server===t.id);return n.length?(0,L.jsx)(`optgroup`,{label:t.name,children:n.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))},t.id):null})})}function Ue(){let{connections:e,settingsServer:t,statuses:n}=oe();return(0,L.jsxs)(`div`,{className:`server-settings-scope`,children:[(0,L.jsxs)(`label`,{children:[`设置目标服务器 `,(0,L.jsx)(`select`,{"aria-label":`设置目标服务器`,value:t,onChange:e=>ue(e.target.value),children:e.filter(e=>e.enabled).map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,L.jsxs)(`small`,{children:[`服务端设置仅应用于此服务器;外观和通知属于当前浏览器。`,n.get(t)?.state===`offline`?` 当前服务器离线。`:``]})]})}function We(){let{connections:e,statuses:t,settingsServer:n}=oe(),r=e.find(e=>e.id===n)?.managed,[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(!1);(0,u.useEffect)(()=>{v(``),g(``),Ae(`/api/browser-access`).then(e=>e.json()).then(e=>b(e.enabled)).catch(()=>g(`无法读取服务器授权设置`))},[n]);let x=async e=>{m(!0),g(``);try{let t=await Ae(`/api/browser-access`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:e})}),n=await t.json();if(!t.ok)throw Error(n.error);b(n.enabled),v(n.key??``)}catch(e){g(e instanceof Error?e.message:`授权设置失败`)}finally{m(!1)}};return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`当前浏览器直接连接每台服务器。关闭一个连接不会停止那台服务器上的任务。连接配置仅保存在当前浏览器。`}),(0,L.jsx)(`div`,{className:`server-connection-list`,children:e.filter(e=>!e.managed).map(e=>(0,L.jsxs)(`section`,{className:`server-connection-card`,children:[(0,L.jsxs)(`div`,{className:`server-connection-heading`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{"data-server-status":t.get(e.id)?.state??`disabled`,children:e.enabled?{online:`已连接`,connecting:`连接中`,offline:`离线`,disabled:`已停用`}[t.get(e.id)?.state??`connecting`]:`已停用`})]}),(0,L.jsxs)(`small`,{children:[e.url,e.id===`entry`?` · 网页入口`:``]}),t.get(e.id)?.error&&e.enabled&&(0,L.jsx)(`p`,{role:`status`,children:t.get(e.id)?.error}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>ue(e.id),disabled:!e.enabled||n===e.id,children:n===e.id?`当前设置目标`:`管理此服务器`}),(0,L.jsxs)(`label`,{children:[`名称 `,(0,L.jsx)(`input`,{"aria-label":`${e.name}的服务器名称`,defaultValue:e.name,onBlur:t=>{try{ge(e.id,t.target.value),g(``)}catch(n){g(n instanceof Error?n.message:`名称修改失败`),t.target.value=e.name}}})]}),e.id!==`entry`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>ve(e.id,!e.enabled),children:e.enabled?`断开`:`连接`}),(0,L.jsx)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>{a(e.id),s(e.name),l(e.url),f(``)},children:`编辑连接`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>_e(e.id),children:`移除连接`})]})]})]},e.id))}),(0,L.jsxs)(`form`,{className:`server-connect-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{i?await xe(i,o,c,d):await ye(o,c,d),a(void 0),s(``),l(``),f(``)}catch(e){g(e instanceof Error?e.message:`连接失败`)}finally{m(!1)}},children:[(0,L.jsx)(`h4`,{children:i?`编辑服务器连接`:`添加服务器`}),(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`例如:开发服务器`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`服务地址`,(0,L.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`http://主机:端口`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`连接密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`off`,value:d,onChange:e=>f(e.target.value),required:!i,placeholder:i?`留空保留已保存的密钥`:void 0})]}),(0,L.jsx)(`small`,{children:`先在目标服务器的“服务器连接”设置中生成连接密钥,再粘贴到这里。密钥具有该服务器的操作权限。`}),(0,L.jsx)(`button`,{type:`submit`,disabled:p,children:p?`正在连接…`:i?`验证并保存`:`验证并添加`}),i&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(void 0),s(``),l(``),f(``)},children:`取消编辑`})]}),r?(0,L.jsx)(`p`,{children:`SSH 托管连接由本地入口管理,无需手动生成或更换连接密钥。`}):(0,L.jsxs)(`section`,{className:`server-access-settings`,children:[(0,L.jsxs)(`h4`,{children:[`允许其他浏览器连接 · `,pe(n)]}),(0,L.jsx)(`p`,{children:y?`已开启。重新生成会使原连接密钥失效。`:`尚未开启远程浏览器授权。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`rotate`),children:y?`重新生成连接密钥`:`生成连接密钥`}),y&&(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`revoke`),children:`撤销授权`})]}),_&&(0,L.jsxs)(`label`,{children:[`连接密钥(仅本次显示,请妥善保存)`,(0,L.jsx)(`textarea`,{readOnly:!0,rows:3,value:_,onFocus:e=>e.target.select()})]})]}),h&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:h})]})}function Ge(){let[e,t]=(0,u.useState)(`managed`);return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsxs)(`div`,{className:`server-connection-modes`,role:`tablist`,"aria-label":`服务器接入方式`,children:[(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`managed`,"data-server-mode":`managed`,onClick:()=>t(`managed`),children:`SSH 托管`}),(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`direct`,"data-server-mode":`direct`,onClick:()=>t(`direct`),children:`已有服务直接连接`})]}),e===`managed`?(0,L.jsx)(Be,{}):(0,L.jsx)(We,{})]})}function Ke(e,t,n){let r=new Set,i=new Set,a=!1,o=o=>{let s=o.data;if(o.source!==e()?.contentWindow||o.origin!==`null`||s?.type!==`super-pi-tool-request`||s.owner!==n||typeof s.id!=`string`||i.has(s.id)||i.size>=64)return;let c=t=>{a||e()?.contentWindow?.postMessage({type:`super-pi-tool-response`,id:s.id,...t},`*`)};if(typeof s.path!=`string`||s.path.length>2048||!/^api\/(run|runs(?:\/[a-z0-9_-]+)?|llm(?:\/[a-z0-9_-]+)?)(?:\?[^#\r\n]*)?$/i.test(s.path)||![`GET`,`POST`,`DELETE`].includes(s.method)||s.body!==void 0&&(typeof s.body!=`string`||s.body.length>1048576)){c({error:`工具请求超出当前挂载范围`});return}i.add(s.id);let l=new AbortController;r.add(l),(async()=>{try{let e=await ke(Oe(`/tools/${encodeURIComponent(t)}/${s.path}`),{method:s.method,headers:{"content-type":`application/json`,"x-super-pi-tool-owner":n},body:s.body,signal:AbortSignal.any([l.signal,AbortSignal.timeout(25e3)])},se(t));c({status:e.status,headers:{"content-type":e.headers.get(`content-type`)??`application/json`},body:await e.text()})}catch{c({error:`工具所属服务器暂不可达,请检查该服务器连接后重试`})}finally{r.delete(l),i.delete(s.id)}})()};return window.addEventListener(`message`,o),()=>{a=!0,window.removeEventListener(`message`,o);for(let e of r)e.abort()}}function qe(e){return window.superPiDesktop?window.localStorage.getItem(e)??window.sessionStorage.getItem(e):window.sessionStorage.getItem(e)}function Je(e,t){(window.superPiDesktop?window.localStorage:window.sessionStorage).setItem(e,t)}function Ye(){try{let e=JSON.parse(qe(`super-pi.sidebar-scope.v1`)??`null`);if(e&&[`all`,`workspace`,`repo`,`recent`,`running`].includes(e.kind))return{kind:e.kind,...typeof e.workspaceId==`string`?{workspaceId:e.workspaceId}:{},...typeof e.repoId==`string`?{repoId:e.repoId}:{},...typeof e.serverId==`string`?{serverId:e.serverId}:{}}}catch{}return{kind:`workspace`}}function Xe(){let e={groups:[],gitDiffs:[],diffs:{paths:[]}};try{let t=JSON.parse(qe(`super-pi.workbench-scene.v1`)??`null`);return!t||typeof t!=`object`?e:{groups:Array.isArray(t.groups)?t.groups.filter(e=>e&&typeof e.workspaceId==`string`&&typeof e.roomId==`string`).slice(0,200):[],gitDiffs:Array.isArray(t.gitDiffs)?t.gitDiffs.filter(e=>e?.target&&typeof e.target.url==`string`&&e.target.url.startsWith(`/api/git?`)&&[e.target.path,e.target.label,e.target.comparison].every(e=>typeof e==`string`)).slice(0,200).map(e=>({target:e.target,workspaceId:e.workspaceId,revision:0,preview:e.preview===!0,reading:{}})):[],diffs:{paths:Array.isArray(t.diffs?.paths)?t.diffs.paths.filter(e=>typeof e==`string`).slice(0,200):[],...typeof t.diffs?.previewPath==`string`?{previewPath:t.diffs.previewPath}:{}},...[`session`,`file`,`diff`,`gitDiff`,`group`].includes(t.view)?{view:t.view}:{},...typeof t.gitDiffUrl==`string`?{gitDiffUrl:t.gitDiffUrl}:{}}}catch{return e}}function Ze(e){Je(`super-pi.workbench-scene.v1`,JSON.stringify({...e,gitDiffs:e.gitDiffs.map(e=>({target:e.target,workspaceId:e.workspaceId,preview:e.preview}))}))}var Qe=`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`;function $e(e,t){return e?!(!t||t.id!==e||t.archivedAt):!1}function et(e){let{conversation:t,parent:n,directChildren:r,isTopLevelUnread:i=!1}=e;return t.hasOpenEscalation?`awaiting_decision`:r.some(e=>{if(e.archivedAt)return!1;let t=e.status===`running`||e.status===`waiting`||e.status===`awaiting_background`,n=!!e.hasOpenEscalation;return t||n})?`awaiting_subordinates`:$e(t.parentConversationId,n)?t.hasPendingResult?`pending_report`:null:i?`unread`:null}function tt(e){let{conversation:t,directChildren:n}=e,r=t.hasOpenEscalation&&!t.parentConversationId&&t.escalationAudience===`boss`;return et({...e,conversation:{...t,hasOpenEscalation:r},directChildren:n.map(e=>e.hasOpenEscalation?{...e,hasOpenEscalation:!1}:e)})}function nt(e){let{status:t,reportingState:n,awaitingQuestion:r,quietWhenRead:i=!1}=e;return r?`question`:t===`failed`?`failed`:n===`awaiting_decision`?`awaiting_decision`:t===`waiting`?`waiting`:t===`running`?`running`:t===`awaiting_background`?`awaiting_background`:n===`pending_report`?`pending_report`:n===`awaiting_subordinates`?`awaiting_subordinates`:n===`unread`?t===`completed`?`completed`:`unread`:i?`idle`:t===`completed`?`completed`:`idle`}var rt=[`solution-designer`,`code-designer`,`code-auditor`,`document-organizer`];function it(e){return e.role===`assistant`?e.settledAt??e.createdAt:e.createdAt}function at(e){return e.filter(e=>e.role===`user`||![`queued`,`running`].includes(e.status)).slice().sort((e,t)=>it(e).localeCompare(it(t)))}function ot(e,t){return nt({status:e.status,quietWhenRead:!0,reportingState:e.lastReplyAt&&e.lastReplyAt>(t??``)?`unread`:null})}var st=`super-pi-active-group-workspace`,ct=e=>`super-pi-group-room:${e}`;function lt(){try{let e=localStorage.getItem(st),t=e&&localStorage.getItem(ct(e));if(e&&t)return{workspaceId:e,roomId:t}}catch{}}function ut(e){try{e?.roomId?(localStorage.setItem(ct(e.workspaceId),e.roomId),localStorage.setItem(st,e.workspaceId)):localStorage.removeItem(st)}catch{}}var dt=({workspaceId:e,roomId:t})=>`group:${JSON.stringify([e,t])}`;function ft(e){if(e.startsWith(`group:`))try{let t=JSON.parse(e.slice(6));if(Array.isArray(t)&&typeof t[0]==`string`&&typeof t[1]==`string`)return{workspaceId:t[0],roomId:t[1]}}catch{}}function pt(e,t,n,r){let i=new URLSearchParams({workspaceId:e});return t&&i.set(`id`,t),n&&i.set(`revision`,n),r&&i.set(`execution`,r),`/api/group-chats?${i}`}var mt=class extends Error{status;constructor(e,t){super(e),this.status=t}};async function ht(e,t){let n=await ke(e,t);if(n.status===204)return;let r=await n.json().catch(()=>void 0);if(!n.ok)throw new mt(r?.error||`群聊请求失败(${n.status})。`,n.status);return r}function gt(e,t){return ht(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}function _t(e,t){return e.archivedAt?`idle`:t&&t.revision>=e.activity.revision?t.status:e.activity.status}function vt(e,t,n){return e.archivedAt?`idle`:ot(t&&t.revision>=e.activity.revision?t:e.activity,n)}function yt(e,t){let n=JSON.stringify(e.filter(e=>!e.closedAt&&!e.id.startsWith(`pending:`)).map(e=>e.id)),[r,i]=(0,u.useState)({}),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)(0),l=(0,u.useRef)(new Map),d=(0,u.useRef)(new Set),f=(0,u.useRef)(0),p=(0,u.useCallback)(()=>{f.current+=1,c(e=>e+1)},[]);(0,u.useEffect)(()=>{if(!t)return;let e=JSON.parse(n),r=new AbortController,a=f.current,o=()=>!r.signal.aborted&&a===f.current;for(let t of e)ht(pt(t),{signal:r.signal}).then(e=>{if(!o()||!e)return;for(let t of e)l.current.delete(t.id);let n=[...l.current.values()].filter(e=>e.workspaceId===t);i(r=>({...r,[t]:{rooms:[...n.reverse(),...e],loaded:!0}}))}).catch(()=>{o()&&i(e=>({...e,[t]:{...e[t],rooms:e[t]?.rooms??[],failed:!0}}))});return window.addEventListener(`focus`,p),()=>{window.removeEventListener(`focus`,p),r.abort()}},[n,t,s,p]);let m=(0,u.useCallback)(({id:e,workspaceId:t,activity:n,cloneRequests:r})=>{d.current.has(e)||(r&&i(i=>{let a=i[t];return a?{...i,[t]:{...a,rooms:a.rooms.map(t=>t.id===e&&t.activity.revision<=n.revision?{...t,activity:n,cloneRequests:r}:t)}}:i}),o(t=>t[e]&&t[e].revision>=n.revision?t:{...t,[e]:n}))},[]);return{index:r,reload:p,remember:(0,u.useCallback)((e,t=!1)=>{if(d.current.has(e.id))return;let{id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c}=e,u={id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c};m(u),t&&l.current.set(u.id,u),i(t=>{let n=t[e.workspaceId],r=n?.rooms??[],i=r.find(t=>t.id===e.id);return i&&(i.updatedAt>u.updatedAt||i.title===u.title&&i.archivedAt===u.archivedAt)?t:{...t,[e.workspaceId]:{...n,rooms:i?r.map(t=>t.id===e.id?u:t):[u,...r]}}})},[m]),forget:(0,u.useCallback)(({workspaceId:e,roomId:t})=>{d.current.add(t),l.current.delete(t),o(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),i(n=>{let r=n[e];return r?{...n,[e]:{...r,rooms:r.rooms.filter(e=>e.id!==t)}}:n})},[]),activities:a,recordActivity:m}}function bt(e){return JSON.stringify([e.workspaceId,e.conversationId?`session`:`group`,e.conversationId??e.roomId])}function xt(e,t,n){let{connections:r}=oe(),i=(0,u.useRef)({conversations:t,onMerge:n});i.current={conversations:t,onMerge:n};let a=JSON.stringify(r.filter(e=>e.enabled).map(e=>e.id));(0,u.useEffect)(()=>{let t=!1,n=new Set,r=new Set,o=new Set,s=async a=>{if(r.has(a))return;r.add(a);let s=new AbortController;n.add(s);let c=window.setTimeout(()=>s.abort(),12e3),l=!1;try{let n=await ke(`/api/read-receipts`,{signal:s.signal},a);if(!n.ok||!n.headers.get(`content-type`)?.includes(`application/json`))return;let r=(await n.json()).receipts;if(t||!Array.isArray(r))return;let c=new Map(r.map(e=>[bt(e),e.at])),u=t=>{for(let n of t){let t=n.conversationId??dt({workspaceId:n.workspaceId,roomId:n.roomId});n.at>(e.current[t]??``)&&(e.current[t]=n.at,l=!0)}};u(r),l&&!t&&(i.current.onMerge(),l=!1);let d=[];for(let[t,n]of Object.entries(e.current)){let e;if(t.startsWith(`group:`))try{let[r,i]=JSON.parse(t.slice(6));e={workspaceId:r,roomId:i,at:n}}catch{continue}else{let r=i.current.conversations.find(e=>e.id===t);r&&(e={workspaceId:r.workspaceId,conversationId:t,at:n})}e&&!o.has(bt(e))&&h(e.workspaceId).server===a&&n>(c.get(bt(e))??``)&&d.push(e)}for(let e=0;e<d.length&&!t;e+=500){let t=d.slice(e,e+500),n=e=>ke(`/api/read-receipts`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({receipts:e}),signal:s.signal},a),r=await n(t);if(r.ok)u((await r.json()).receipts??[]);else if(r.status===400)for(let e of t){let t=await n([e]);t.ok?u((await t.json()).receipts??[]):t.status===400&&o.add(bt(e))}}}catch{}finally{l&&!t&&i.current.onMerge(),window.clearTimeout(c),n.delete(s),r.delete(a)}},c=()=>{for(let e of JSON.parse(a))s(e)};c();let l=window.setInterval(c,3e3);return window.addEventListener(`focus`,c),()=>{t=!0,window.clearInterval(l),window.removeEventListener(`focus`,c);for(let e of n)e.abort()}},[a,e])}function St(e,t){let n=e.trim();if(!n||n===t)return{path:t,prefix:``};let r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`));return r<0?n===`~`?{path:`~`,prefix:``}:{path:t,prefix:n}:{path:n.slice(0,r+1),prefix:n.slice(r+1)}}var Ct=s(),wt=`操作没有完成。`,Tt=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,Et=160,Dt=/[\u3400-\u9fff]/,Ot=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,kt=/failed to fetch|fetch failed|network\s*error|econnrefused|econnreset|enotfound|eai_again|socket hang up|connection refused|connection reset|broken pipe|load failed/i,At=/timeout|timed out|etimedout/i,jt=/aborterror|aborted|the user aborted a request|operation was aborted/i,Mt=/node-pty|pty unavailable|terminal unavailable/i,Nt=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,Pt=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,Ft=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,It=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,Lt=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function Rt(e){let t=``;if(e==null)t=``;else if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message;else if(typeof e==`object`&&typeof e.message==`string`)t=e.message;else try{t=String(e)}catch{t=``}return t.trim().replace(/^error:\s*/i,``).replace(/^\[object object\]$/i,``).trim()}var zt=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function Bt(e){let t=e.replace(/\s+/g,` `).trim().replace(/\bsk-[A-Za-z0-9_-]{6,}/g,`sk-***`).replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1***`);return t.length>Et?`${t.slice(0,Et)}…`:t}function Vt(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${Bt(t)})`}function Ht(e,t){let n=Rt(e);if(!n||zt.test(n))return t??Tt;if(Dt.test(n))return n;if(Ot.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(kt.test(n))return Vt(`连接不上 Super Pi 服务,请稍后再试。`,n);if(At.test(n))return Vt(`等待服务响应超时,请稍后再试。`,n);if(jt.test(n))return Vt(`请求被中断,请重试。`,n);if(Mt.test(n))return Vt(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if(Nt.test(n))return Vt(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(It.exec(n)?.[1]??It.exec(n)?.[2]??0);if(r===401||r===403)return Vt(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return Vt(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return Vt(`请求被拒绝(HTTP ${r})。`,n);if(Pt.test(n))return Vt(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(Ft.test(n))return Vt(`服务端出错了,请稍后再试。`,n);let i=Lt.exec(n)?.[1];return Vt(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??wt,n)}function Ut(e){let t=Rt(e);if(t&&!zt.test(t))return Ht(e).includes(t)?void 0:t}function Wt(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var Gt={ts:`code`,tsx:`code`,js:`code`,jsx:`code`,mjs:`code`,cjs:`code`,mts:`code`,cts:`code`,py:`code`,rb:`code`,go:`code`,rs:`code`,java:`code`,kt:`code`,kts:`code`,scala:`code`,c:`code`,h:`code`,cc:`code`,cpp:`code`,hpp:`code`,cs:`code`,swift:`code`,m:`code`,mm:`code`,php:`code`,pl:`code`,pm:`code`,lua:`code`,r:`code`,jl:`code`,ex:`code`,exs:`code`,erl:`code`,hs:`code`,dart:`code`,nim:`code`,zig:`code`,vue:`code`,svelte:`code`,astro:`code`,sh:`code`,bash:`code`,zsh:`code`,fish:`code`,ps1:`code`,bat:`code`,cmd:`code`,sql:`code`,graphql:`code`,gql:`code`,proto:`code`,tf:`code`,tfvars:`code`,hcl:`code`,sol:`code`,md:`markup`,mdx:`markup`,markdown:`markup`,txt:`markup`,text:`markup`,rst:`markup`,adoc:`markup`,org:`markup`,yaml:`config`,yml:`config`,toml:`config`,ini:`config`,cfg:`config`,conf:`config`,xml:`config`,env:`config`,properties:`config`,gitignore:`config`,editorconfig:`config`,eslintrc:`config`,prettierrc:`config`,css:`style`,scss:`style`,sass:`style`,less:`style`,stylus:`style`,pcss:`style`,postcss:`style`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,bmp:`image`,webp:`image`,avif:`image`,ico:`image`,svg:`image`,tif:`image`,tiff:`image`,heic:`image`,psd:`image`,ai:`image`,json:`data`,jsonc:`data`,json5:`data`,csv:`data`,tsv:`data`,parquet:`data`,db:`data`,sqlite:`data`,sqlite3:`data`,ndjson:`data`,zip:`archive`,tar:`archive`,gz:`archive`,tgz:`archive`,bz2:`archive`,xz:`archive`,"7z":`archive`,rar:`archive`,zst:`archive`,jar:`archive`,war:`archive`,whl:`archive`,woff:`font`,woff2:`font`,ttf:`font`,otf:`font`,eot:`font`,exe:`binary`,dll:`binary`,so:`binary`,dylib:`binary`,bin:`binary`,o:`binary`,obj:`binary`,a:`binary`,lib:`binary`,class:`binary`,node:`binary`,pyc:`binary`,pyo:`binary`,pack:`binary`,idx:`binary`,iso:`binary`,dmg:`binary`,msi:`binary`,apk:`binary`,deb:`binary`,rpm:`binary`,pdf:`binary`,doc:`binary`,docx:`binary`,xls:`binary`,xlsx:`binary`,ppt:`binary`,pptx:`binary`,odt:`binary`,ods:`binary`,odp:`binary`,wasm:`binary`},Kt={dockerfile:`config`,containerfile:`config`,makefile:`code`,cmakelists:`code`,rakefile:`code`,gemfile:`config`,procfile:`config`,license:`markup`,licence:`markup`,notice:`markup`,readme:`markup`,changelog:`markup`,authors:`markup`,contributing:`markup`,".gitignore":`config`,".gitattributes":`config`,".gitmodules":`config`,".npmrc":`config`,".nvmrc":`config`,".env":`config`};function qt(e){let t=Kt[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=Wt(e);return n?Gt[n]??`generic`:`generic`}var Jt={code:[`M6 4.5 2.5 8 6 11.5`,`M10 4.5 13.5 8 10 11.5`,`M9.2 3.5 6.8 12.5`],markup:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`,`M5.5 8.5h5`,`M5.5 11h3.5`],config:[`M8 10.2a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4z`,`M8 1.8v1.6`,`M8 12.6v1.6`,`M1.8 8h1.6`,`M12.6 8h1.6`,`M3.6 3.6l1.1 1.1`,`M11.3 11.3l1.1 1.1`,`M12.4 3.6l-1.1 1.1`,`M4.7 11.3l-1.1 1.1`],style:[`M8 13.5a5.5 5.5 0 1 1 0-11c3 0 5.5 2 5.5 4.5 0 1.4-1.1 2.2-2.3 2.2h-1c-.9 0-1.6.7-1.6 1.5 0 .4.2.7.4 1 .2.3.4.6.4 1a1.3 1.3 0 0 1-1.4.8z`,`M5.6 6.8h.01`,`M8.4 5.2h.01`,`M11 6.9h.01`],image:[`M2.5 4.5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-7z`,`M2.5 10.5 6 7.5l2.5 2 2-1.5 3 2.5`,`M5.8 6.4h.01`],data:[`M2.5 3.5h11v9h-11z`,`M2.5 8h11`,`M8 3.5v9`],archive:[`M2.5 5.5h11v8h-11z`,`M1.5 2.5h13v3h-13z`,`M6.8 8.5h2.4`],font:[`M3.5 13 8 3l4.5 10`,`M5.4 9.6h5.2`],binary:[`M2.5 4.5h11v7h-11z`,`M5 7h.01`,`M8 7h.01`,`M11 7h.01`,`M5 9.5h.01`,`M8 9.5h.01`],generic:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`],folder:[`M2.5 4.5a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-8z`],"folder-open":[`M2.5 12.5v-8a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v1`,`M2.5 12.5 4.6 6.8a1 1 0 0 1 .95-.7h8.1a.6.6 0 0 1 .55.85L12.9 12.5a1 1 0 0 1-.95.7H3.5a1 1 0 0 1-1-1z`]};function Yt({path:e,category:t,size:n=14}){let r=t??qt(e??``),i=Jt[r]??Jt.generic;return(0,L.jsx)(`svg`,{className:`file-icon file-icon-${r}`,"data-file-icon":r,width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:i.map((e,t)=>(0,L.jsx)(`path`,{d:e},t))})}var Xt={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`},Zt={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`},Qt=[`sessions`,`files`,`main`,`terminal`,`git`,`projects`,`tools`],$t=`super-pi.workbench.layout.v1`,en=e=>typeof e==`string`&&Qt.includes(e);function tn(){return{sides:{...Zt},order:[...Qt],unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1}}function nn(){let e=tn();try{let t=JSON.parse(window.localStorage.getItem($t)??`null`);if(!t)return e;let n={...Zt};for(let e of Qt)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(en):[];return{sides:n,order:[...new Set([...r,...Qt])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(en).filter(e=>e!==`sessions`):[],leftView:en(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function rn(e){try{window.localStorage.setItem($t,JSON.stringify(e))}catch{}}var an={sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,group:`M3 4h14v10H8l-5 4V4zM8 9h4m7 0h2v10h-7l-3 2v-4`,"group-add":`M3 4h14v10H8l-5 4V4zM8 9h4m6 7v6m-3-3h6`,archive:`M4 4h16v5H4zM6 9v11h12V9M10 13h4`,delete:`M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 10v7m4-7v7`,files:`M3 6h7l2 2h9v11H3zM3 9h18`,terminal:`M3 4h18v16H3zM7 8l4 4-4 4m7 0h4`,git:`M7 7v10m10-10v3a4 4 0 0 1-4 4H7M7 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4zm0 14a2 2 0 1 0 0 4 2 2 0 1 0 0-4zM17 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4z`,main:`m4 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8`,projects:`M3 4h18v16H3zM3 8h18M9 8v12M15 8v12`,worktree:`M3 5h8l2 2h8v5M3 5v14h8m3-9v8m0-4h6m-3-3 3 3-3 3`,tools:`M4 4h6v6H4zm10 0h6v6h-6zM4 14h6v6H4zm10 0h6v6h-6z`,search:`M11 3a7 7 0 1 0 0 14 7 7 0 1 0 0-14zm5 12 5 5`,settings:`M10 3h4l.6 2.5 2 .9L19 5l2 3.5-1.9 1.7v2.4l1.9 1.8-2 3.4-2.4-.9-2 .9L14 21h-4l-.6-2.6-2-.9-2.4.9-2-3.4 1.9-1.8v-2.4L3 8.5 5 5l2.4 1.4 2-.9zM12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`,help:`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zm-2.8 6.3a2.8 2.8 0 0 1 5.6 0c0 2-2.8 2.3-2.8 4M12 17h.01`,update:`M12 3v12m-4-4 4 4 4-4M4 15v5h16v-5`,restart:`M12 3v9M6 6a8 8 0 1 0 12 0`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`,back:`M19 12H5m7-7-7 7 7 7`,forward:`M5 12h14m-7-7 7 7-7 7`,split:`M3 4h18v16H3zM12 4v16`,pin:`m14 3 7 7-3 1-3 4-1 3-8-8 3-1 4-3zm-4 11-6 6`};function on({name:e}){return(0,L.jsx)(`svg`,{className:`workbench-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.55`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:an[e]})})}function sn({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,onArrange:s,onReorder:c,onReset:l,children:d,searchActive:f}){let p=t.filter(e=>n.includes(e)),m=t.filter(e=>!n.includes(e)),[h,g]=(0,u.useState)(),_=h&&m.includes(h)?h:r&&m.includes(r)?r:m[0],v=(0,u.useRef)(new Map),y=(0,u.useRef)(null),[b,x]=(0,u.useState)(),S=(0,u.useRef)(null),C=(0,u.useRef)(void 0),[w,T]=(0,u.useState)();return(0,u.useEffect)(()=>{if(!b)return;let e=()=>x(void 0),t=t=>{t.target instanceof Node&&!S.current?.contains(t.target)&&e()},n=t=>{t.key!==`Escape`||t.defaultPrevented||(t.preventDefault(),e(),v.current.get(b.view)?.focus())};return S.current?.querySelector(`button`)?.focus(),window.addEventListener(`pointerdown`,t),window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e)}},[b]),(0,u.useEffect)(()=>{let e=e=>{let t=y.current;t?.open&&e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]),(0,L.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,L.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:m.map((t,n)=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:t===`sessions`?`workbench-sessions-tab`:`right-tab-${t}`,className:`right-tab workbench-activity-button${r===t?` right-tab-active`:``}`,"data-workbench-view":t,"data-right-tab":t===`sessions`?void 0:t,"data-right-rail-open":e===`right`&&!r&&i===t?`1`:void 0,"aria-controls":t===`sessions`?`workbench-sessions`:`right-panel-${t}`,"aria-selected":r===t,tabIndex:t===_?0:-1,draggable:t!==`sessions`,"data-workbench-drop":w===t?`1`:void 0,onContextMenu:n=>{if(t===`sessions`)return;n.preventDefault();let r=n.currentTarget.getBoundingClientRect();x({view:t,x:Math.max(4,Math.min(window.innerWidth-200,n.clientX||(e===`left`?r.right:r.left-196))),y:Math.max(4,Math.min(window.innerHeight-146,n.clientY||r.top))})},onDragStart:e=>{t!==`sessions`&&(C.current=t,e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`)},onDragOver:e=>{C.current&&t!==`sessions`&&C.current!==t&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,T(t))},onDragLeave:()=>T(e=>e===t?void 0:e),onDrop:e=>{let n=C.current;n&&t!==`sessions`&&(e.preventDefault(),c(n,t),C.current=void 0,T(void 0))},onDragEnd:()=>{C.current=void 0,T(void 0)},ref:e=>{e?v.current.set(t,e):v.current.delete(t)},title:Xt[t],"aria-label":Xt[t],onFocus:()=>g(t),onClick:()=>a(t),onKeyDown:r=>{if(t!==`sessions`&&(r.key===`ContextMenu`||r.shiftKey&&r.key===`F10`)){r.preventDefault();let n=r.currentTarget.getBoundingClientRect();x({view:t,x:Math.max(4,e===`left`?n.right:n.left-196),y:Math.max(4,Math.min(window.innerHeight-146,n.top))});return}let i=r.key===`Home`?m[0]:r.key===`End`?m.at(-1):r.key===`ArrowDown`?m[(n+1)%m.length]:r.key===`ArrowUp`?m[(n+m.length-1)%m.length]:void 0;i&&(r.preventDefault(),v.current.get(i)?.focus())},children:(0,L.jsx)(on,{name:t})},t))}),o&&(0,L.jsx)(`button`,{type:`button`,className:`workbench-activity-button${f?` right-tab-active`:``}`,"data-workbench-search":`1`,title:`搜索`,"aria-label":`搜索`,"aria-pressed":!!f,onClick:o,children:(0,L.jsx)(on,{name:`search`})}),(p.length>0||e===`right`)&&(0,L.jsxs)(`details`,{className:`workbench-menu workbench-more`,ref:y,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,L.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,L.jsx)(on,{name:`more`})}),(0,L.jsxs)(`div`,{className:`workbench-menu-items`,children:[p.map(e=>(0,L.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),r===e?y.current?.querySelector(`summary`)?.focus():a(e)},children:[(0,L.jsx)(on,{name:e}),Xt[e]]},e)),e===`right`&&(0,L.jsx)(`button`,{type:`button`,"data-workbench-reset":`1`,onClick:()=>{y.current&&(y.current.open=!1),l()},children:`恢复默认布局`})]})]}),b&&(0,Ct.createPortal)((0,L.jsx)(`div`,{ref:S,className:`workbench-menu-items workbench-context-menu`,style:{left:b.x,top:b.y},"aria-label":`${Xt[b.view]}布局`,children:cn(e,!0).map(([e,t])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-context-action":e,onClick:()=>{x(void 0),s(b.view,e),e!==`move`&&e!==`pin`&&v.current.get(b.view)?.focus()},children:t},e))}),document.body),d&&(0,L.jsx)(`div`,{className:`workbench-activity-utilities`,children:d})]})}var cn=(e,t)=>[[`move`,e===`left`?`移到右侧`:`移到左侧`],[`pin`,t?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];function ln({view:e,side:t,pinned:n,onArrange:r}){let i=cn(t,n);return(0,L.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,L.jsx)(`summary`,{title:`视图布局`,"aria-label":`${Xt[e]}布局`,"data-workbench-panel-menu":e,children:(0,L.jsx)(on,{name:`more`})}),(0,L.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var un=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'self'; object-src 'none'; form-action 'none'; base-uri 'none'`,dn={png:{kind:`image`,mime:`image/png`},jpg:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},gif:{kind:`image`,mime:`image/gif`},webp:{kind:`image`,mime:`image/webp`},svg:{kind:`image`,mime:`image/svg+xml`},html:{kind:`html`,mime:`text/html; charset=utf-8`},htm:{kind:`html`,mime:`text/html; charset=utf-8`}};function fn(e){return dn[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function pn(e){if(!(!e||/[\u0000-\u001f\u007f]/.test(e)||/^[\\/]{2}/.test(e))&&(!/^[a-z][a-z\d+.-]*:/i.test(e)||/^[a-z]:[\\/]/i.test(e)))return fn(e)?.kind}function mn(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function hn(e){let t=/#L([1-9]\d*)(?:C([1-9]\d*))?(?:-L?[1-9]\d*)?$/i.exec(e)??/:([1-9]\d*)(?::([1-9]\d*))?$/.exec(e);if(!t||t.index===0)return;let n=Number(t[1]),r=t[2]?Number(t[2]):void 0;if(Number.isSafeInteger(n)&&(r===void 0||Number.isSafeInteger(r)))return{path:e.slice(0,t.index),line:n,column:r}}function gn(e){try{let t=decodeURIComponent(e).replaceAll(`\\`,`/`);if(!t||t.startsWith(`//`)||/[\u0000-\u001f\u007f?#]/.test(t)||/:/.test(t.replace(/^[a-z]:\//i,``)))return;let n=t.split(`/`).at(-1)??``;return!/^(?:[\w.-]*\.[\w.-]+|Makefile|Dockerfile|LICENSE)$/iu.test(n)&&!/\.[\p{L}\p{N}_-]+$/u.test(n)?void 0:t}catch{return}}function _n(e){let t=hn(e);return!!(t&&gn(t.path))}function vn(e,t){let n=e;if(/^https?:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return}let i=[`localhost`,`127.0.0.1`,`[::1]`].includes(r.hostname)&&r.port===`3080`;if(r.username||r.password||r.search||!r.hash||r.origin!==t.origin&&!i)return;n=r.pathname+r.hash}let r=hn(n);if(!r)return;let i=gn(r.path);if(!i)return;let a=t.root.replaceAll(`\\`,`/`).replace(/\/+$/,``),o=/^[a-z]:\//i.test(a),s=e=>o?e.toLowerCase():e,c=s(i).startsWith(s(a+`/`));if(/^[a-z]:\//i.test(i)&&!c)return;let l=(c||i.startsWith(`/`)?``:t.cwd).split(`/`).filter(Boolean),u=c?i.slice(a.length+1):i;for(let e of u.split(`/`))if(e&&e!==`.`){if(e===`..`){if(!l.length)return;l.pop()}else l.push(e)}return{...r,path:l.join(`/`)}}function yn(e){let t=/(\/\/.*|#[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:const|let|var|function|return|if|else|for|while|class|import|from|export|def|fn|true|false|null|undefined|async|await|try|catch|throw|switch|case|break|continue|new|this|static|public|private|interface|type|enum|struct|impl|pub|mod|use|as|where|match|loop|mut|ref|self|Self)\b|\b\d+(?:\.\d+)?\b)/g,n=[],r=0,i;for(;i=t.exec(e);){i.index>r&&n.push({text:e.slice(r,i.index),kind:`plain`});let t=i[0],a=/^(\/\/|#)/.test(t)?`comment`:/^["']/.test(t)?`string`:/^\d/.test(t)?`number`:`keyword`;n.push({text:t,kind:a}),r=i.index+t.length}return r<e.length&&n.push({text:e.slice(r),kind:`plain`}),n}var bn=new Set([`http`,`https`,`mailto`]),xn=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},Sn=/^([a-z][a-z0-9+.-]*):/i;function Cn(e){let t=[...e].filter(e=>!xn(e)).join(``);if(!t)return;let n=Sn.exec(t);return n?bn.has(n[1].toLowerCase())?e:void 0:e}var wn=/[!-/:-@[-`{-~]/,Tn=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function En(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function Dn(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function On(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=En(e,r,"`");if(t===n)return r;r+=t-1}return-1}function kn(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
|
|
12
12
|
`)break;if(e[i]==="`"){let t=En(e,i,"`");if(On(e,i+t,t)!==-1)break}}if(e.startsWith(n,i)||r&&e.startsWith(r,i))return i;e[i]===`\\`&&(i+=1)}return-1}function An(e,t){if(e[t]!==`(`)return;let n=1,r=-1;for(let i=t+1;i<e.length;i+=1){let t=e[i];if(t===`\\`)i+=1;else if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0)){r=i;break}}if(r===-1)return;let i=e.slice(t+1,r).trim();if(i.length>1&&i.startsWith(`<`)&&i.endsWith(`>`))return{href:i.slice(1,-1),next:r+1};let a=/^(.*?)\s+"([^"]*)"$/.exec(i);if(a)return{href:a[1],title:a[2],next:r+1};if(!/\s/.test(i))return{href:i,next:r+1}}function jn(e,t){let n=1;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`\\`)r+=1;else if(t===`[`)n+=1;else if(t===`]`&&(--n,n===0))return r}return-1}function Mn(e,t,n,r){for(let i=t;i<e.length;i+=1){let t=In(e,i);if(t)i=t.next-1;else if(e[i]===`\\`)i+=1;else if(e[i]==="`"){let t=En(e,i,"`"),n=On(e,i+t,t);if(n!==-1){i=n+t-1;continue}i+=t-1}else if(e[i]===r&&!(En(e,i,r)<n.length)&&!(r===`_`&&Tn(e[i-1])&&Tn(e[i+1])))return i}return-1}var Nn=/^<([a-z][a-z0-9+.-]*:[^<>\s]*)>/i,Pn=/[\s(\[{,:;=+\/|(【「『]/,Fn=/[\u2E80-\u9FFF\uF900-\uFAFF\u3000-\uFF60\uFFE0-\uFFE6]/;function In(e,t){let n=e[t],r=e[t+1],i=n===`$`&&r===`$`||n===`\\`&&r===`[`,a=n===`\\`&&r===`(`,o=n===`$`&&!i;if(!i&&!a&&!o||o&&t>0&&!Pn.test(e[t-1])&&!Fn.test(e[t-1]))return;let s=n===`\\`?a?`\\)`:`\\]`:i?`$$`:`$`,c=t+s.length,l=kn(e,c,s);if(l===-1)return;let u=e.slice(c,l);if(u.trim()&&!(o&&(/^\s|\s$/.test(u)||/[0-9$]/.test(e[l+1]??``)||/^\d[\d.,]*[\s,、:;。?!]*\p{Script=Han}/u.test(u))))return{node:{type:`math`,source:u,display:i},next:l+s.length}}function Ln(e,t={}){let n=[],r=``,i=()=>{r&&=(n.push({type:`text`,value:r}),``)},a=e=>{i(),n.push(e)};for(let o=0;o<e.length;){let s=e[o],c=In(e,o);if(c){a(c.node),o=c.next;continue}let l=e.slice(o,o+2);if(l===`$$`||l===`\\(`||l===`\\[`||l===`\\)`||l===`\\]`)r+=l,o+=2;else if(s===`\\`&&wn.test(e[o+1]??``))r+=e[o+1],o+=2;else if(s==="`"){let t=En(e,o,"`"),n=On(e,o+t,t);if(n!==-1){a({type:`code`,value:Dn(e.slice(o+t,n))}),o=n+t;continue}r+="`".repeat(t),o+=t}else if(s===`<`){let t=Nn.exec(e.slice(o));if(t){let e=Cn(t[1]);if(e){a({type:`link`,href:e,children:[{type:`text`,value:t[1]}]}),o+=t[0].length;continue}}r+=s,o+=1}else if(s===`!`&&e[o+1]===`[`||s===`[`){let n=s===`!`,i=o+(n?2:1),c=jn(e,i),l=c===-1?void 0:An(e,c+1);if(l){let r=pn(l.href);if(r&&(n||r===`html`)){a({type:`artifact`,kind:r,path:l.href,label:e.slice(i,c)}),o=l.next;continue}if(!n&&_n(l.href)){a({type:`source-link`,destination:l.href,children:Ln(e.slice(i,c),t)}),o=l.next;continue}let s=Cn(l.href);if(s){a({type:`link`,href:s,...l.title===void 0?{}:{title:l.title},children:Ln(e.slice(i,c),t)}),o=l.next;continue}}r+=s,o+=1}else if(t.strikethrough!==!1&&s===`~`&&e[o+1]===`~`){let n=Mn(e,o+2,`~~`,`~`);if(n>o+2){a({type:`del`,children:Ln(e.slice(o+2,n),t)}),o=n+2;continue}r+=`~~`,o+=2}else if(s===`*`||s===`_`){let n=En(e,o,s);if((n>=2?t.bold:t.italic)===!1){r+=s.repeat(n),o+=n;continue}let i=n>=2?s.repeat(2):s,c=s===`_`&&Tn(e[o-1])&&Tn(e[o+n])?-1:Mn(e,o+i.length,i,s);if(c>o+i.length){let r=Ln(e.slice(o+i.length,c),t);a(n>=2?{type:`strong`,children:r}:{type:`em`,children:r}),o=c+i.length;continue}r+=i,o+=i.length}else s===`
|
|
13
13
|
`?(/[ \t]{2,}$/.test(r)||r.endsWith(`\\`)?(r=r.replace(/(?:[ \t]+|\\)$/,``),i(),n.push({type:`break`})):r+=s,o+=1):(r+=s,o+=1)}return i(),n}var Rn=/^(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*$/,zn=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,Bn=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,Vn=/^(\s*)([-*+])(\s+)(.*)$/,Hn=/^(\s*)(\d{1,9})([.)])(\s+)(.*)$/,Un=/^ {0,3}>\s?(.*)$/,Wn=/^ {0,3}\|?\s*:?-{1,}:?\s*(?:\|\s*:?-{1,}:?\s*)*\|?\s*$/,Gn=/^\s*(\$\$(?!\$)|\\\[|\\begin\{((?:equation|align|alignat|gather|multline|flalign|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|Bmatrix|cases)\*?|aligned|alignedat|gathered|split|array|smallmatrix|dcases|rcases)\})/;function Kn(e,t){let n=Gn.exec(e[t]);if(!n)return;let r=n[1],i=n[2],a=i?`\\end{`+i+`}`:r===`$$`?`$$`:`\\]`,o=[],s=1;for(let c=t;c<e.length;c+=1){let l=e[c];if(c!==t&&(Rn.test(l)||zn.test(l)||l.trimStart().startsWith(`\\[`)))return;let u=c===t?n[0].length:0,d=kn(l,u,a,i&&r);for(;i&&d!==-1;){let e=l.startsWith(r,d);if(s+=e?1:-1,!s)break;d=kn(l,d+(e?r:a).length,a,r)}if(d===-1){o.push(l.slice(u));continue}if(l.slice(d+a.length).trim())return;o.push(l.slice(u,d));let f=o.join(`
|
|
@@ -284,7 +284,7 @@ ${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namesp
|
|
|
284
284
|
`&&(s+=1),n.length===500&&s<e.length-1))return{rows:n,clipped:!0}}else i+=c}return(i||r.length)&&(r.length<50?r.push(i):o=!0,n.push(r)),{rows:n,clipped:o}}function rf({workspaceId:e,cwd:t,path:n,name:r,kind:i,content:a,source:o,version:s,sourceRequest:c,external:l,navigation:d,assetTicket:f,onReload:p}){let[m,h]=(0,u.useState)(c!==void 0),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(!1),b=(r,i)=>f?tf(r,e,t,f,i):ef(r,e,t,n,i),x=b(`asset`,{v:s}),S=b(`asset`,{download:`1`}),C=b(`document`);(0,u.useEffect)(()=>{c!==void 0&&h(!0)},[c]),(0,u.useEffect)(()=>{y(!1)},[x]),(0,u.useEffect)(()=>{if(i!==`document`)return;let e=new AbortController;return ke(C,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`无法读取文档。`);_(t)}).catch(t=>{e.signal.aborted||_({error:String(t.message??t)})}),()=>e.abort()},[C,i,s]);let w=(0,u.useMemo)(()=>i===`table`&&!m?nf(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,L.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,L.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,L.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,L.jsxs)(`a`,{href:S,download:r,children:[(0,L.jsx)(Xd,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,L.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,L.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,L.jsxs)(L.Fragment,{children:[i===`download`&&(0,L.jsx)(`p`,{children:`此文件可以下载。`}),i===`image`&&(0,L.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,L.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,L.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,L.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,L.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,L.jsxs)(L.Fragment,{children:[g.warnings?.map(e=>(0,L.jsx)(`p`,{children:e},e)),(0,L.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,L.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,L.jsx)(`div`,{className:`workspace-file-table`,children:(0,L.jsx)(`table`,{children:(0,L.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,L.jsx)(`td`,{children:e},t))]},t))})})}):(0,L.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,L.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var af={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,pdf:`application/pdf`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,webm:`video/webm`,ogv:`video/ogg`};function of(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function sf(e){let t=of(e);return Object.hasOwn(af,t)?af[t]:void 0}function cf(e){let t=sf(e);if(t===`application/pdf`)return`pdf`;if(t?.startsWith(`image/`))return`image`;if(t?.startsWith(`audio/`))return`audio`;if(t?.startsWith(`video/`))return`video`;if(/\.(csv|tsv)$/i.test(e))return`table`;if(/\.docx$/i.test(e))return`document`}var lf=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),uf=(e,t)=>!t||e===t||e.startsWith(`${t}/`),df=e=>e.split(`/`).at(-1)??e;function ff(e){if(!(e instanceof Element))return;let t=e.closest(`[data-file-dir], [data-file-entry], [data-file-hit]`);if(!t)return;let n=t.dataset.fileDir??t.dataset.fileEntry??t.dataset.fileHit;if(n!==void 0)return{path:n,directory:t.dataset.fileDir!==void 0,linked:t.dataset.linked===`true`||t.dataset.fileOutside!==void 0}}function pf({title:e,cancel:t,children:n}){let r=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t?.isConnected&&t.focus()}},[]),(0,L.jsx)(`dialog`,{ref:r,className:`file-explorer-dialog`,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,L.jsx)(`h2`,{children:e}),n]})})}function mf({target:e,label:t,initial:n,busy:r,error:i,depth:a,submit:o,close:s}){let c=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=c.current;if(!t)return;t.focus();let r=n.lastIndexOf(`.`);t.setSelectionRange(0,!e.directory&&r>0?r:n.length)},[n,e.directory]),(0,L.jsxs)(`form`,{className:`file-inline-edit`,"data-file-inline-edit":e.path,"aria-label":t,style:{paddingInlineStart:23+a*15},onSubmit:o,onKeyDown:e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},children:[(0,L.jsxs)(`div`,{className:`file-inline-row`,children:[(0,L.jsx)(Yt,{path:e.path,category:e.directory?`folder`:void 0}),(0,L.jsx)(`input`,{ref:c,name:`name`,required:!0,defaultValue:n,placeholder:t,"aria-label":t,"aria-invalid":!!i,readOnly:r,autoComplete:`off`,spellCheck:!1}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,L.jsx)(Xd,{name:`right`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,L.jsx)(Xd,{name:`close`})})]}),i&&(0,L.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function hf({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)(lf(t.path)),a=e.listings[r],o=e.loadDirectory;(0,u.useEffect)(()=>{a||o(r)},[r,a,o]);let s=a&&`entries`in a?a.entries.filter(e=>e.kind===`directory`&&!e.symlink&&!(t.directory&&uf(e.path,t.path))):[];return(0,L.jsxs)(`div`,{className:`file-move-picker`,children:[(0,L.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,L.jsxs)(`div`,{className:`file-move-location`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(lf(r)),children:`↑`}),(0,L.jsx)(`span`,{title:r||n,children:r||n})]}),(0,L.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,L.jsx)(Yt,{category:`folder`}),(0,L.jsx)(`span`,{children:e.name}),(0,L.jsx)(Xd,{name:`right`})]})},e.path))}),!s.length&&(0,L.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function gf({workspaceId:e,scopeName:t,cwd:n,files:r,onOpen:i,onReference:a,onMoved:o,onSearchFolder:s}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(``),C=(0,u.useRef)(void 0),w=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let e={controller:new AbortController};return w.current=e,l(void 0),f(void 0),m(void 0),b(void 0),g(!1),v(``),()=>{e.controller.abort(),w.current===e&&(w.current=void 0)}},[e,n]);let T=(t,r=``,i)=>ef(t,e??``,n,r,i);async function E(e,t){let n=await ke(e,{...t,signal:w.current?.controller.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`操作失败(${n.status})`);return r}function D(e,t){c?.anchor.origin===t.origin&&c.target.path===e.path?l(void 0):l({target:e,anchor:t})}function O(e){l(void 0),e&&c?.anchor.origin.isConnected&&c.anchor.origin.focus({preventScroll:!0})}function k(e,t,n,i){C.current=i??c?.anchor.origin??(document.activeElement instanceof HTMLElement?document.activeElement:void 0),l(void 0),v(``),f({action:e,target:t,move:n}),e===`create-file`||e===`create-directory`?t.path?r.revealPath(`${t.path}/`):r.setQuery(``):e===`move`&&!n&&r.revealPath(t.path)}function A(){f(void 0);let e=C.current;requestAnimationFrame(()=>{e?.isConnected&&e.offsetParent?e.focus({preventScroll:!0}):d?.target.path&&r.locatePath(d.target.path,d.target.directory)})}async function j(t){let a=w.current;g(!0),v(``);try{let s=await E(T(`tree`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(w.current!==a)return;if(s.previousPath&&s.previousPath!==s.path?(r.movePath(s.previousPath,s.path,s.text),o?.(s.previousPath,s.path)):s.removed||r.revealPath(s.path),r.invalidateTree(e??``,[s.path,...s.previousPath?[s.previousPath]:[]].map(e=>n?`${n}/${e}`:e)),s.removed){for(let e of r.open)uf(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath(lf(s.path),!0)}f(void 0),t.action===`restore`&&m(e=>e?.filter(e=>e.id!==t.id)),t.action===`create-file`&&s.text!==!1&&i({path:s.path,name:df(s.path),text:!0},!0),t.action!==`restore`&&!s.removed&&r.locatePath(s.path,!!s.directory),r.setNotice(s.removed?`已移到回收站:${s.path}`:t.action===`restore`?`已恢复:${s.path}`:``)}catch(e){if(w.current===a){let t=e instanceof Error?e.message:String(e);v(t),d||r.setNotice(t)}}finally{w.current===a&&g(!1)}}function M(e){if(e.preventDefault(),!d||h)return;let{action:t,target:n}=d;if((t===`move`||t===`trash`)&&Object.entries(r.saves).some(([e,t])=>uf(e,n.path)&&t.state===`saving`)){v(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&uf(e.path,n.path))){v(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??df(n.path));if(t===`move`&&!n.directory&&of(n.path)!==of(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?lf(n.path):n.path));d.move&&o===lf(n.path)?v(`请选择另一个文件夹。`):j({action:t,path:n.path,parent:o,name:a})}async function N(){let e=w.current;l(void 0),v(``);try{let t=await E(T(`tree`));w.current===e&&m(t.entries)}catch(t){w.current===e&&r.setNotice(String(t.message))}}function ee(e){S.current=e,O(!0),x.current?.click()}async function P(t,i,a){let o=w.current;if(!e||!o||!i.length||h)return;g(!0),v(``),b(void 0);let s=[],c=[],l=[];try{for(let e of i){if(o!==w.current)return;try{let n=a?.find(t=>t.file===e)?.etag;if(!a){let n=await E(T(`upload-check`,t,{name:e.name}));if(n.exists){!n.replaceable||!n.meta?c.push(`${e.name}:同名目录或链接`):s.push({file:e,etag:n.meta.etag});continue}}let r=await E(T(`upload`,t,{name:e.name}),{method:`POST`,headers:{"content-type":`application/octet-stream`,...n?{"if-match":n}:{}},body:e});l.push(r.path)}catch(t){c.push(`${e.name}:${t.message}`)}}if(w.current!==o)return;l[0]&&r.revealPath(l[0]),l.length&&r.invalidateTree(e,l.map(e=>n?`${n}/${e}`:e)),s.length&&b({parent:t,items:s}),r.setNotice([l.length?`已上传 ${l.length} 个文件`:``,...c].filter(Boolean).join(`。`))}finally{w.current===o&&g(!1)}}function te(e,t){l(void 0),a?.(e||`.`,t)}function ne(e){O(!0),vd(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let re=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,F={path:``,directory:!0},ie=d?.action===`create-file`||d?.action===`create-directory`,ae=d?.action===`move`&&!d.move,oe=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!ie:!ae)?null:(0,L.jsx)(mf,{target:{...d.target,directory:ie?d.action===`create-directory`:d.target.directory},label:re,initial:ae?df(e):``,busy:h,error:_,depth:n,submit:M,close:A},`${d.action}:${e}`),se=(e,t)=>{h||e.linked||e.directory&&uf(t,e.path)||t===lf(e.path)||(Object.entries(r.saves).some(([t,n])=>uf(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):j({action:`move`,path:e.path,parent:t,name:df(e.path)}))},ce=(0,L.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,F,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(Xd,{name:`file`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,F,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(Xd,{name:`folder`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,L.jsx)(Xd,{name:`refresh`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-collapse-all":`1`,title:`折叠所有文件夹`,"aria-label":`折叠所有文件夹`,onClick:r.collapseDirectories,disabled:!r.expanded.size,children:(0,L.jsx)(Xd,{name:`collapse`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(F,Zd(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,L.jsx)(Xd,{name:`more`})})]}),le=(e,t,n,r,i)=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,L.jsx)(Xd,{name:t}),(0,L.jsx)(`span`,{children:e}),i&&(0,L.jsx)(`kbd`,{children:i})]});return{controls:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,P(S.current,t)}}),c&&(0,L.jsxs)(Qd,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[s&&le(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),le(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),le(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),le(`上传到此处`,`upload`,()=>ee(c.target.path),`upload`),(0,L.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[le(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),le(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,L.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&le(`引用到会话`,`reference`,()=>te(c.target.path,c.target.directory),`reference`),le(`复制相对路径`,`copy`,()=>ne(c.target.path)),!c.target.directory&&!c.target.linked&&(0,L.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:df(c.target.path),onClick:()=>O(!0),children:[(0,L.jsx)(Xd,{name:`download`}),(0,L.jsx)(`span`,{children:`下载`})]}),!c.target.path&&le(`打开回收站`,`trash`,()=>void N(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{role:`separator`}),le(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!ie&&!ae&&(0,L.jsx)(pf,{title:re,cancel:()=>{h||A()},children:(0,L.jsxs)(`form`,{onSubmit:M,className:`file-explorer-form`,children:[d.action===`trash`?(0,L.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,L.jsx)(hf,{files:r,source:d.target,scopeName:t}),_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,L.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:re})]})]})}),p&&(0,L.jsxs)(pf,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,L.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,L.jsx)(`p`,{children:`回收站为空。`}),(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,L.jsxs)(pf,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,L.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,L.jsx)(`ul`,{children:y.items.map(e=>(0,L.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,L.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void P(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:ce,inline:oe,editing:ie||ae,busy:h,openMenu:D,showAction:k,upload:P,moveTo:se}}var _f=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function vf({mode:e,query:t,onClose:n,onMode:r,children:i,presentation:a}){let o=e===`path`?{"data-quick-open":`1`}:e===`content`?{"data-content-search":`1`}:{"data-session-search":`1`},s=(0,L.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:_f.map(n=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-search-mode":n.id,"aria-pressed":n.id===e,title:n.shortcut,onClick:()=>{n.id!==e&&r(n.id,t)},children:n.label},n.id))});return a===`sidebar`?(0,L.jsxs)(`div`,{className:`workbench-search-embedded`,...o,children:[s,i]}):(0,L.jsx)(`div`,{className:`quick-open-backdrop`,...o,role:`presentation`,onMouseDown:n,children:(0,L.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":_f.find(t=>t.id===e)?.label,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),n())},children:[s,i]})})}function yf({workspaceId:e,initialQuery:t=``,onClose:n,onMode:r,onOpen:i,presentation:a}){let[o,s]=(0,u.useState)(t),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(null),v=(0,u.useRef)(null);return(0,u.useEffect)(()=>{_.current?.focus()},[]),(0,u.useEffect)(()=>{v.current?.scrollIntoView({block:`nearest`})},[p]),(0,u.useEffect)(()=>{let t=o.trim();if(l(void 0),m(0),f(``),g(!1),!e||!t)return;if(t.length>256){f(`搜索词不能超过 256 个字符。`);return}let n=new AbortController;g(!0);let r=setTimeout(()=>{ke(`/api/session-search?${new URLSearchParams({workspaceId:e,q:t})}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`会话搜索没有完成。`);return await e.json()}).then(e=>{n.signal.aborted||l(e)}).catch(e=>{n.signal.aborted||f(Ht(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||g(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[o,e]),(0,L.jsxs)(vf,{mode:`session`,query:o,onMode:r,onClose:n,presentation:a,children:[(0,L.jsx)(`input`,{ref:_,className:`quick-open-input`,"data-session-search-input":!0,value:o,"aria-label":`搜索会话消息`,placeholder:`输入要在会话消息中查找的文字`,onChange:e=>s(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`ArrowDown`&&(e.preventDefault(),m(e=>Math.min(e+1,Math.max(0,(c?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),m(e=>Math.max(0,e-1))),e.key===`Enter`)){e.preventDefault();let t=c?.hits[p];t&&i(t)}}}),(0,L.jsx)(`p`,{className:`quick-open-status`,role:`status`,"data-session-search-status":!0,children:d||(h?`搜索中…`:e?c?c.truncated?`显示前 60 条命中`:`${c.hits.length} 条命中`:`当前工作区的未归档会话 · 用户和 Agent 消息`:`请选择工作区`)}),(0,L.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:c?.hits.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===p?v:void 0,type:`button`,"data-session-search-result":e.messageId,className:`quick-open-result content-search-result${p===t?` quick-open-result-active`:``}`,onMouseEnter:()=>m(t),onClick:()=>i(e),children:[(0,L.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,L.jsxs)(`small`,{children:[e.before,(0,L.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var bf=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[SuperPi ErrorBoundary captured error]:`,e,t)}reset=()=>{this.setState({error:null})};render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):(0,L.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,L.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,L.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,L.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,L.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,L.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function xf(){}xf.prototype={diff:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.callback;typeof n==`function`&&(r=n,n={}),this.options=n;var i=this;function a(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var o=t.length,s=e.length,c=1,l=o+s;n.maxEditLength&&(l=Math.min(l,n.maxEditLength));var u=n.timeout??1/0,d=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],t,e,0);if(f[0].oldPos+1>=s&&p+1>=o)return a([{value:this.join(t),count:t.length}]);var m=-1/0,h=1/0;function g(){for(var n=Math.max(m,-c);n<=Math.min(h,c);n+=2){var r=void 0,l=f[n-1],u=f[n+1];l&&(f[n-1]=void 0);var d=!1;if(u){var g=u.oldPos-n;d=u&&0<=g&&g<o}var _=l&&l.oldPos+1<s;if(!d&&!_)f[n]=void 0;else{if(r=!_||d&&l.oldPos+1<u.oldPos?i.addToPath(u,!0,void 0,0):i.addToPath(l,void 0,!0,1),p=i.extractCommon(r,t,e,n),r.oldPos+1>=s&&p+1>=o)return a(Sf(i,r.lastComponent,t,e,i.useLongestToken));f[n]=r,r.oldPos+1>=s&&(h=Math.min(h,n-1)),p+1>=o&&(m=Math.max(m,n+1))}}c++}if(r)(function e(){setTimeout(function(){if(c>l||Date.now()>d)return r();g()||e()},0)})();else for(;c<=l&&Date.now()<=d;){var _=g();if(_)return _}},addToPath:function(e,t,n,r){var i=e.lastComponent;return i&&i.added===t&&i.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:i.count+1,added:t,removed:n,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:i}}},extractCommon:function(e,t,n,r){for(var i=t.length,a=n.length,o=e.oldPos,s=o-r,c=0;s+1<i&&o+1<a&&this.equals(t[s+1],n[o+1]);)s++,o++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=o,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split(``)},join:function(e){return e.join(``)}};function Sf(e,t,n,r,i){for(var a=[],o;t;)a.push(t),o=t.previousComponent,delete t.previousComponent,t=o;a.reverse();for(var s=0,c=a.length,l=0,u=0;s<c;s++){var d=a[s];if(!d.removed){if(!d.added&&i){var f=n.slice(l,l+d.count);f=f.map(function(e,t){var n=r[u+t];return n.length>e.length?n:e}),d.value=e.join(f)}else d.value=e.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}else if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,s&&a[s-1].added){var p=a[s-1];a[s-1]=a[s],a[s]=p}}var m=a[c-1];return c>1&&typeof m.value==`string`&&(m.added||m.removed)&&e.equals(``,m.value)&&(a[c-2].value+=m.value,a.pop()),a}new xf;var Cf=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,wf=/\S/,Tf=new xf;Tf.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!wf.test(e)&&!wf.test(t)},Tf.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&Cf.test(t[n])&&Cf.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var Ef=new xf;Ef.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
285
285
|
`));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var i=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),t.push(i))}return t};function Df(e,t,n){return Ef.diff(e,t,n)}var Of=new xf;Of.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var kf=new xf;kf.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Af(e){"@babel/helpers - typeof";return Af=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Af(e)}var jf=Object.prototype.toString,Mf=new xf;Mf.useLongestToken=!0,Mf.tokenize=Ef.tokenize,Mf.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,i=r===void 0?function(e,t){return t===void 0?n:t}:r;return typeof e==`string`?e:JSON.stringify(Nf(e,null,null,i),i,` `)},Mf.equals=function(e,t){return xf.prototype.equals.call(Mf,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Nf(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i,e));for(var a=0;a<t.length;a+=1)if(t[a]===e)return n[a];var o;if(jf.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Nf(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),Af(e)===`object`&&e!==null){t.push(e),o={},n.push(o);var s=[],c;for(c in e)e.hasOwnProperty(c)&&s.push(c);for(s.sort(),a=0;a<s.length;a+=1)c=s[a],o[c]=Nf(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var Pf=new xf;Pf.tokenize=function(e){return e.slice()},Pf.join=Pf.removeEmpty=function(e){return e};function Ff(e,t){let n=Df(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
|
|
286
286
|
`),n=t.length>0&&t[t.length-1]===``;n&&t.pop();for(let c=0;c<t.length;c+=1){let l=t[c],u=c===t.length-1&&!n;e.added?(r.push({kind:`added`,text:l,newLine:s,noNewline:u}),s+=1,i+=1):e.removed?(r.push({kind:`removed`,text:l,oldLine:o,noNewline:u}),o+=1,a+=1):(r.push({kind:`same`,text:l,oldLine:o,newLine:s,noNewline:u}),o+=1,s+=1)}}return{lines:r,added:i,removed:a,identical:i===0&&a===0}}function If(e,t=3){let n=new Set;e.lines.forEach((r,i)=>{if(r.kind!==`same`)for(let r=-t;r<=t;r+=1){let t=i+r;t>=0&&t<e.lines.length&&n.add(t)}});let r=[],i=0,a=!1;return e.lines.forEach((e,t)=>{n.has(t)?(a&&=(r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),!1),r.push(e)):a||(a=!0,i+=1)}),a&&r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),{lines:r,folded:i}}var Lf=`super-pi.outbox.v1.`,Rf=e=>Lf+JSON.stringify([e.conversationId,e.clientId]);function zf(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(Lf)))try{let n=JSON.parse(window.localStorage.getItem(t)??`null`),r=n?.send;r?.type===`message.send`&&typeof r.conversationId==`string`&&/^message_[0-9a-f-]{36}$/.test(r.clientId)&&typeof r.content==`string`&&t===Rf(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function Bf(e){try{return window.localStorage.setItem(Rf(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function Vf(e,t){try{window.localStorage.removeItem(Rf({conversationId:e,clientId:t}))}catch{}}function Hf(e){return m(h(e.conversationId).server,e.clientId)}function Uf(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId),i=Hf(t);if(!r||r.messages.some(e=>e.id===i))return e;let a=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...a?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:i,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...a?{delivery:`waiting`}:{}}]}:e)}}function Wf(e,t){try{return JSON.parse(qe(e)??`null`)??t}catch{return t}}function Gf(e,t){try{return Je(e,JSON.stringify(t)),!0}catch{return!1}}var Kf=`modulepreload`,qf=function(e){return`/`+e},Jf={},Yf=function(e){return e.pathname.endsWith(`.css`)},Xf=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Zf=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=qf(t,n);let r=s(t),i=Yf(r);return Xf(Jf,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Kf,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Qf=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},$f=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},ep=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function tp(e,t,n={}){if(n.signal?.aborted)throw new $f;let r=n.timeoutMs??15e3,i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},r),s=()=>i.abort();n.signal?.addEventListener(`abort`,s,{once:!0});try{let r=await ke(ep(e,t,n.cwd),{signal:i.signal}),a;try{a=await r.json()}catch{a=void 0}if(!r.ok){let e=a??{};throw new Qf(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new $f:a?new Qf(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var np=`\0`,rp=(e,t,n)=>[e,t,n??``].join(np),ip=24,ap=new Map;function op(e){let t=ap.get(e);if(t)return ap.delete(e),ap.set(e,t),t}function sp(e,t){for(ap.delete(e),ap.set(e,t);ap.size>ip;){let e=ap.keys().next();if(e.done)break;ap.delete(e.value)}}var cp={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},lp=`此工作区不是 Git 仓库`;function up(e){return e&&cp[e]?{code:e,text:cp[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function dp(e){return e instanceof Qf&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:lp}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var fp=`${np}uncommitted`;function pp(e){let t=new Map,n=0;for(let r of e.lines)t.has(r.line)||t.set(r.line,r),r.line>n&&(n=r.line);let r=[],i=null,a=0;for(let e=1;e<=n;e+=1){let n=t.get(e);if(!n){r.push({line:e,kind:`missing`,data:null}),i=null,a=e;continue}let o=n.isUncommitted?fp:n.commit??`${np}none`,s=o===i&&e===a+1?`continuation`:n.isUncommitted?`uncommitted`:`commit`;r.push({line:e,kind:s,data:n}),i=o,a=e}if(e.truncated)for(let t=n+1;t<=e.totalLines;t+=1)r.push({line:t,kind:`truncated`,data:null});return r}function mp(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function hp(e){switch(e.kind){case`commit`:{let t=e.data,n=t?.shortCommit??t?.commit?.slice(0,8)??`?`,r=t?.author?.trim();return r?`${n} · ${r}`:n}case`continuation`:return`│`;case`uncommitted`:return`● 未提交`;case`missing`:return`?`;case`truncated`:return`…`;default:return``}}function gp(e){if(e.kind===`uncommitted`||e.data?.isUncommitted)return[`未提交`,`这行尚不属于任何 Git 提交`];if(e.kind===`missing`)return[`没有 Blame 信息`,`这一行没有对应的提交记录`];if(e.kind===`truncated`)return[`Blame 数据已截断`,`文件太长,只显示了前面一部分的提交信息`];let t=e.data;if(!t)return[`没有 Blame 信息`];let n=t.shortCommit??t.commit?.slice(0,8)??`未知提交`,r=t.author?.trim()||`未知作者`;return[n,t.authorEmail?`${r} <${t.authorEmail}>`:r,_p(t.date),t.summary?.trim()||`(没有提交摘要)`]}function _p(e){if(!e)return`不详`;let t=new Date(e);if(!Number.isFinite(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function vp(e){if(e.length===0)return 0;let t=1;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&--t,t}function yp(e,t,n=!1){return!t||!t.supported?!1:n||vp(e)!==t.totalLines}var bp=new WeakMap;function xp(e){let t=bp.get(e);if(t)return t;let n={response:e,models:pp(e),covered:mp(e)};return bp.set(e,n),n}function Sp(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Cp=`a1b2c3d · Author`;async function wp(){let[e,t]=await Promise.all([Zf(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),Zf(()=>import(`./dist-DlPa5gNa.js`).then(e=>e.s),__vite__mapDeps([2,1,0]))]),n=e.StateEffect.define(),r=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(n))return e.value;return e}}),i=e.StateEffect.define(),a=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(i))return e.value;return e}}),o=t.GutterMarker;class s extends o{model;constructor(e){super(),this.model=e}eq(e){let t=e.model;return t?t.line===this.model.line&&t.kind===this.model.kind&&t.data?.commit===this.model.data?.commit&&t.data?.summary===this.model.data?.summary&&t.data?.author===this.model.data?.author:!1}toDOM(){let e=document.createElement(`span`);e.className=`cm-blame-marker cm-blame-${this.model.kind}`,e.setAttribute(`data-file-blame-line`,String(this.model.line)),e.setAttribute(`data-file-blame-kind`,this.model.kind),this.model.data?.commit&&e.setAttribute(`data-file-blame-commit`,this.model.data.commit);let t=gp(this.model);return e.setAttribute(`title`,t.join(`
|
|
287
|
-
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=hp(this.model),e}}class c extends o{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-blame-marker cm-blame-spacer`,e.textContent=Cp,e}}let l=t.gutter({class:`cm-blame-gutter`,initialSpacer:()=>new c,lineMarker:(e,t)=>{let n=e.state.field(r);if(!n)return null;let i=e.state.doc.lineAt(t.from).number,a=Sp(n,i);return new s(a??{line:i,kind:`missing`,data:null})},lineMarkerChange:e=>e.startState.field(r)!==e.state.field(r)}),u=t.ViewPlugin.fromClass(class{line=null;editorView;constructor(e){this.editorView=e,this.editorView.dom.addEventListener(`mousemove`,this.onMove),this.editorView.dom.addEventListener(`mouseleave`,this.onLeave)}destroy(){this.editorView.dom.removeEventListener(`mousemove`,this.onMove),this.editorView.dom.removeEventListener(`mouseleave`,this.onLeave)}update(e){e.startState.field(r)!==e.state.field(r)&&this.line!==null&&(this.line=null,this.editorView.dispatch({effects:i.of(null)}))}onMove=e=>{let t=this.lineAt(e);if(t===this.line)return;if(this.line=t,t===null){this.editorView.dispatch({effects:i.of(null)});return}let n=Sp(this.editorView.state.field(r),t);if(!n){this.editorView.dispatch({effects:i.of(null)});return}let a=this.editorView.state.doc,o=a.line(Math.min(t,a.lines));this.editorView.dispatch({effects:i.of({pos:o.from,above:!0,create:()=>({dom:Tp(n)})})})};onLeave=()=>{this.line=null,this.editorView.dispatch({effects:i.of(null)})};lineAt(e){let t=e.target,n=t?.closest?.(`[data-file-blame-line]`);if(n){let e=Number(n.getAttribute(`data-file-blame-line`));return Number.isInteger(e)&&e>0?e:null}if(t?.closest?.(`.cm-blame-gutter`))return null;let r=this.editorView.posAtCoords({x:e.clientX,y:e.clientY});return r==null?null:this.editorView.state.doc.lineAt(r).number}});return{field:r,setBlame:n,base:[r,a,t.showTooltip.from(a),u],gutter:l}}function Tp(e){let t=document.createElement(`div`);t.className=`cm-blame-tooltip`,t.setAttribute(`data-file-blame-tooltip`,`1`),t.setAttribute(`data-file-blame-kind`,e.kind),e.data?.commit&&t.setAttribute(`data-file-blame-commit`,e.data.commit);for(let n of gp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function Ep(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let e=r.current;r.current=void 0;let i=n.current;if(!i||!e)return;let a=i.querySelectorAll(t)[e.index];a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top-e.offset)},[e,t]),{scrollBox:n,capture:()=>{let e=n.current;if(!e)return;let i=e.getBoundingClientRect().top,a;e.querySelectorAll(t).forEach((e,t)=>{let n=e.getBoundingClientRect().top-i;(!a||Math.abs(n)<Math.abs(a.offset))&&(a={index:t,offset:n})}),r.current=a}}}var Dp=4e3,Op=(0,u.lazy)(()=>Zf(()=>import(`./CodeMirrorEditor-Q77Plbqw.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),kp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Ap=15e3,jp=e=>new kp(408,{error:`请求超时:${Ap/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Mp(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Ap);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await ke(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new kp(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?jp(e):t}finally{clearTimeout(r)}}var Np=e=>e instanceof kp?e:new kp(0,{error:e instanceof Error?e.message:`读取失败`}),Pp=e=>encodeURIComponent(e),Fp=e=>e?`&cwd=${Pp(e)}`:``,Ip=(e,t,n)=>`/api/files?workspaceId=${Pp(e)}&path=${Pp(t)}${Fp(n)}`,Lp=`//workspace/`,Rp=e=>e.startsWith(Lp)?e.slice(12):void 0,zp=(e,t,n)=>{let r=Rp(t);return`/api/file?workspaceId=${Pp(e)}&path=${Pp(r??t)}${Fp(r?``:n)}`},Bp=(e,t,n)=>zp(e,t,n)+`&meta=1`,Vp=(e,t,n)=>`/api/files?workspaceId=${Pp(e)}&q=${Pp(t)}${Fp(n)}`;async function Hp(e,t,n){let r=t.current;if(!r)return t.current=Mp(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return Mp(e,{cache:`no-store`})}function Up(e){let t=e.trim();if(/^(["']).*\1$/u.test(t)&&(t=t.slice(1,-1)),!/^file:\/\//iu.test(t))return t;try{let e=new URL(t);return e.hostname||e.search||e.hash?t:decodeURIComponent(e.pathname).replace(/^\/(?=[a-z]:[\\/])/iu,``)}catch{return t}}function Wp(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Gp(e){let t=Up(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Wp(t)}function Kp(e){return Up(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function qp(e,t,n){if(n.openLink){let r=await Mp(`/api/files/open?workspaceId=${Pp(e)}${Fp(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n.path})}),{path:i,name:a,text:o,ticket:s,content:c,meta:l}=r,u=cf(r.targetName??i),d=o===!1&&u===`table`?`download`:u??(o===!1?`download`:void 0);return{path:i,name:a,content:c??``,etag:l.etag,dirty:!1,view:d,assetTicket:s}}let{path:r,name:i,text:a}=n,o=cf(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await Mp(Bp(e,r,t))).etag,dirty:!1,view:o};try{let n=await Mp(zp(e,r,t));return{path:Rp(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof kp)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await Mp(Bp(e,r,t))).etag,dirty:!1,view:`download`}}}var Jp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Yp({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(Xd,{name:g?`down`:`right`})}),(0,L.jsx)(Yt,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(Xd,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Ut(h.error.message),children:Ht(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Yp,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(Xp,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function Xp({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=cf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Yt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Xd,{name:`more`})})]}),f]})}function Zp({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m}){let[h,g]=(0,u.useState)(!0),_=(0,u.useRef)(null),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),S=(0,u.useRef)(0),C=!!e.assetTicket,w=!C&&v[e.path]===!0&&!!l,T=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++S.current;if(!w||!l){x(null);return}let n=new AbortController,i=rp(T,e.path,e.etag),a=r?void 0:op(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:up(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=Rp(e.path);return tp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||sp(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:up(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof $f)return;let r=dp(n);x({state:r.state,response:null,path:e.path,workspaceId:T,note:r.note})}),()=>{n.abort()}},[w,l,d,T,e.path,e.etag,r]);let E=b&&b.path===e.path&&b.workspaceId===T?b:null,D=w?E?.state??`loading`:`off`,O=D===`ready`&&yp(e.content,E?.response??null,e.dirty||r),k=[];E?.note&&k.push(E.note),D===`ready`&&E?.response?.truncated&&k.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${E.response.totalLines} 行)`}),O&&k.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let A=D===`loading`?`⌛ Blame`:D===`ready`?`✓ Blame`:D===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&g(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=_.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
287
|
+
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=hp(this.model),e}}class c extends o{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-blame-marker cm-blame-spacer`,e.textContent=Cp,e}}let l=t.gutter({class:`cm-blame-gutter`,initialSpacer:()=>new c,lineMarker:(e,t)=>{let n=e.state.field(r);if(!n)return null;let i=e.state.doc.lineAt(t.from).number,a=Sp(n,i);return new s(a??{line:i,kind:`missing`,data:null})},lineMarkerChange:e=>e.startState.field(r)!==e.state.field(r)}),u=t.ViewPlugin.fromClass(class{line=null;editorView;constructor(e){this.editorView=e,this.editorView.dom.addEventListener(`mousemove`,this.onMove),this.editorView.dom.addEventListener(`mouseleave`,this.onLeave)}destroy(){this.editorView.dom.removeEventListener(`mousemove`,this.onMove),this.editorView.dom.removeEventListener(`mouseleave`,this.onLeave)}update(e){e.startState.field(r)!==e.state.field(r)&&this.line!==null&&(this.line=null,this.editorView.dispatch({effects:i.of(null)}))}onMove=e=>{let t=this.lineAt(e);if(t===this.line)return;if(this.line=t,t===null){this.editorView.dispatch({effects:i.of(null)});return}let n=Sp(this.editorView.state.field(r),t);if(!n){this.editorView.dispatch({effects:i.of(null)});return}let a=this.editorView.state.doc,o=a.line(Math.min(t,a.lines));this.editorView.dispatch({effects:i.of({pos:o.from,above:!0,create:()=>({dom:Tp(n)})})})};onLeave=()=>{this.line=null,this.editorView.dispatch({effects:i.of(null)})};lineAt(e){let t=e.target,n=t?.closest?.(`[data-file-blame-line]`);if(n){let e=Number(n.getAttribute(`data-file-blame-line`));return Number.isInteger(e)&&e>0?e:null}if(t?.closest?.(`.cm-blame-gutter`))return null;let r=this.editorView.posAtCoords({x:e.clientX,y:e.clientY});return r==null?null:this.editorView.state.doc.lineAt(r).number}});return{field:r,setBlame:n,base:[r,a,t.showTooltip.from(a),u],gutter:l}}function Tp(e){let t=document.createElement(`div`);t.className=`cm-blame-tooltip`,t.setAttribute(`data-file-blame-tooltip`,`1`),t.setAttribute(`data-file-blame-kind`,e.kind),e.data?.commit&&t.setAttribute(`data-file-blame-commit`,e.data.commit);for(let n of gp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function Ep(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let e=r.current;r.current=void 0;let i=n.current;if(!i||!e)return;let a=i.querySelectorAll(t)[e.index];a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top-e.offset)},[e,t]),{scrollBox:n,capture:()=>{let e=n.current;if(!e)return;let i=e.getBoundingClientRect().top,a;e.querySelectorAll(t).forEach((e,t)=>{let n=e.getBoundingClientRect().top-i;(!a||Math.abs(n)<Math.abs(a.offset))&&(a={index:t,offset:n})}),r.current=a}}}var Dp=4e3,Op=(0,u.lazy)(()=>Zf(()=>import(`./CodeMirrorEditor-BOfFOmcv.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),kp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Ap=15e3,jp=e=>new kp(408,{error:`请求超时:${Ap/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Mp(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Ap);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await ke(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new kp(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?jp(e):t}finally{clearTimeout(r)}}var Np=e=>e instanceof kp?e:new kp(0,{error:e instanceof Error?e.message:`读取失败`}),Pp=e=>encodeURIComponent(e),Fp=e=>e?`&cwd=${Pp(e)}`:``,Ip=(e,t,n)=>`/api/files?workspaceId=${Pp(e)}&path=${Pp(t)}${Fp(n)}`,Lp=`//workspace/`,Rp=e=>e.startsWith(Lp)?e.slice(12):void 0,zp=(e,t,n)=>{let r=Rp(t);return`/api/file?workspaceId=${Pp(e)}&path=${Pp(r??t)}${Fp(r?``:n)}`},Bp=(e,t,n)=>zp(e,t,n)+`&meta=1`,Vp=(e,t,n)=>`/api/files?workspaceId=${Pp(e)}&q=${Pp(t)}${Fp(n)}`;async function Hp(e,t,n){let r=t.current;if(!r)return t.current=Mp(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return Mp(e,{cache:`no-store`})}function Up(e){let t=e.trim();if(/^(["']).*\1$/u.test(t)&&(t=t.slice(1,-1)),!/^file:\/\//iu.test(t))return t;try{let e=new URL(t);return e.hostname||e.search||e.hash?t:decodeURIComponent(e.pathname).replace(/^\/(?=[a-z]:[\\/])/iu,``)}catch{return t}}function Wp(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Gp(e){let t=Up(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Wp(t)}function Kp(e){return Up(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function qp(e,t,n){if(n.openLink){let r=await Mp(`/api/files/open?workspaceId=${Pp(e)}${Fp(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n.path})}),{path:i,name:a,text:o,ticket:s,content:c,meta:l}=r,u=cf(r.targetName??i),d=o===!1&&u===`table`?`download`:u??(o===!1?`download`:void 0);return{path:i,name:a,content:c??``,etag:l.etag,dirty:!1,view:d,assetTicket:s}}let{path:r,name:i,text:a}=n,o=cf(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await Mp(Bp(e,r,t))).etag,dirty:!1,view:o};try{let n=await Mp(zp(e,r,t));return{path:Rp(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof kp)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await Mp(Bp(e,r,t))).etag,dirty:!1,view:`download`}}}var Jp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Yp({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(Xd,{name:g?`down`:`right`})}),(0,L.jsx)(Yt,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(Xd,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Ut(h.error.message),children:Ht(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Yp,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(Xp,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function Xp({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=cf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Yt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Xd,{name:`more`})})]}),f]})}function Zp({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m}){let[h,g]=(0,u.useState)(!0),_=(0,u.useRef)(null),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),S=(0,u.useRef)(0),C=!!e.assetTicket,w=!C&&v[e.path]===!0&&!!l,T=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++S.current;if(!w||!l){x(null);return}let n=new AbortController,i=rp(T,e.path,e.etag),a=r?void 0:op(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:up(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=Rp(e.path);return tp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||sp(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:up(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof $f)return;let r=dp(n);x({state:r.state,response:null,path:e.path,workspaceId:T,note:r.note})}),()=>{n.abort()}},[w,l,d,T,e.path,e.etag,r]);let E=b&&b.path===e.path&&b.workspaceId===T?b:null,D=w?E?.state??`loading`:`off`,O=D===`ready`&&yp(e.content,E?.response??null,e.dirty||r),k=[];E?.note&&k.push(E.note),D===`ready`&&E?.response?.truncated&&k.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${E.response.totalLines} 行)`}),O&&k.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let A=D===`loading`?`⌛ Blame`:D===`ready`?`✓ Blame`:D===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&g(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=_.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
288
288
|
`).length),n=e.value.split(`
|
|
289
289
|
`),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0),a=n[t-1].length;e.focus(),e.setSelectionRange(r+Math.min(a,(i.column??1)-1),r+a);let o=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*o-e.clientHeight/2),e.scrollLeft=0;let s=e.previousElementSibling;s instanceof HTMLElement&&(s.scrollTop=e.scrollTop,s.scrollLeft=0)},[e.path,i,h]);let j=/\.md$/i.test(e.path);return(0,L.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":C?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[j&&(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>g(e=>!e),children:h?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,L.jsx)(`a`,{className:`file-preview-toggle`,href:tf(`asset`,l,d,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!C&&(0,L.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":D,"aria-pressed":w,"aria-label":w?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>y(t=>({...t,[e.path]:t[e.path]!==!0})),children:A}),e.dirty&&(0,L.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!C&&(0,L.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,L.jsx)(Xd,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),k.length>0&&(0,L.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":k.map(e=>e.code).join(` `),role:`status`,children:k.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,L.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,L.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,L.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),j&&h?(0,L.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,L.jsx)(Md,{source:e.content})}):(0,L.jsx)(bf,{fallback:(t,n)=>(0,L.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,L.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,L.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,L.jsx)(`textarea`,{className:`file-textarea`,readOnly:C,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,L.jsx)(u.Suspense,{fallback:(0,L.jsx)(`div`,{className:`file-cm-wrap`,"data-file-text":e.path,"data-file-content":e.content,"data-file-selection":`0,0`,"data-file-editor-ready":`0`,children:(0,L.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,L.jsx)(Op,{path:e.path,value:e.content,onChange:a,jumpToLine:i,onSave:o,readOnly:C,workspaceId:l,onPosition:m,blame:w&&E&&!O?{state:E.state,response:E.response,path:E.path,workspaceId:l??``}:void 0})})})]})}function Qp({line:e}){if(e.kind===`fold`)return(0,L.jsx)(`div`,{className:`file-diff-line file-diff-fold`,"data-diff-kind":`fold`,children:e.text});let t=e.kind===`added`?`+`:e.kind===`removed`?`-`:` `;return(0,L.jsxs)(`div`,{className:`file-diff-line file-diff-${e.kind}`,"data-diff-kind":e.kind,"data-diff-no-newline":e.noNewline?`1`:void 0,children:[(0,L.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,L.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,L.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function $p({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){let[o,s]=(0,u.useState)(),c=JSON.stringify([e?.path,i]),l=o===c,{scrollBox:d,capture:f}=Ep(l,`.file-diff-added, .file-diff-removed`);if(t)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:Ut(n),children:Ht(n,`这个文件的差异读取失败。`)})});if(!e)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let p=typeof r==`string`,m=i===`buffer`&&p,h=m?e.after:e.before,g=m?r:e.after,_=m?`我未保存的修改`:e.label,v=m?`buffer`:e.baseline,y=p&&e.baseline!==`none`?(0,L.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,L.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!m,onClick:()=>a(`server`),children:`agent 的改动`}),(0,L.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":m,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(v===`none`)return(0,L.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":v,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsx)(`span`,{className:`file-editor-flags`,children:y})]}),(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:_})]});let b=Ff(h,g),x=If(b);return(0,L.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":v,"data-file-diff-added":b.added,"data-file-diff-removed":b.removed,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[y,(0,L.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:_}),(0,L.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,b.added,` / -`,b.removed]}),!b.identical&&x.folded>0&&(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-context":!0,"aria-pressed":l,onClick:()=>{f(),s(l?void 0:c)},children:l?`折叠未改动行`:`显示全文`})]})]}),e.beforeUnknown&&!m&&(0,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!m&&(0,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),b.identical?(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,L.jsx)(`div`,{ref:d,className:`file-diff-body`,"data-file-diff-body":`1`,"data-file-diff-context-mode":l?`full`:`compact`,children:(l?b.lines:x.lines).map((e,t)=>(0,L.jsx)(Qp,{line:e},t))})]})}function em({error:e}){let t=e.body.code,n=typeof e.body.details?.path==`string`?e.body.details.path:``,r=t===`workspace_missing`?`missing`:t===`timeout`?`timeout`:`failed`;return(0,L.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,L.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||Ht(e.message,`路径未知`)})]}),r===`timeout`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,L.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,Ap/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,title:Ut(e.message),children:Ht(e.message,`读取失败,请稍后重试。`)})]})]})}function tm(e,t=``,{navigation:n,showingFile:r=!1,splitFilePath:i}={}){let a=t.trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``),o=e?a?`${e}:${a}`:e:void 0,s=(0,u.useRef)(o);s.current=o;let[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(e),p=(0,u.useRef)(c);p.current=c;let[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)({}),[S,C]=(0,u.useState)({}),[w,T]=(0,u.useState)(()=>new Set),[E,D]=(0,u.useState)(),O=(0,u.useRef)(w);O.current=w;let k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Map),[j,M]=(0,u.useState)(0),[N,ee]=(0,u.useState)(``),[P,te]=(0,u.useState)(null),[ne,re]=(0,u.useState)(null),[F,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)({});(0,u.useEffect)(()=>{if(f(e),k.current=new Map,l([]),h(void 0),_(``),y({}),x({}),C({}),T(new Set),D(void 0),te(null),re(null),ee(``),ie(!1),!e)return;let t=!0;return Mp(Ip(e,``,a)).then(e=>{t&&C({"":e})}).catch(e=>{t&&C({"":{error:Np(e)}})}),()=>{if(t=!1,o&&s.current!==o){let e=p.current.filter(e=>e.dirty);e.length?A.current.set(o,e):A.current.delete(o),Gf(`super-pi.file-drafts.v1.`+o,e),am(o)}}},[e,a,o]);let[se,ce]=(0,u.useState)(),[le,ue]=(0,u.useState)(void 0);(0,u.useEffect)(()=>{if(!e||!o)return;let t=!0;ue(void 0),ce(void 0);let r=rm()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=Wf(`super-pi.file-drafts.v1.`+o,[]),c=new Map((A.current.get(o)??a).map(e=>[e.path,e]));r.expanded.length&&T(new Set(r.expanded)),typeof r.listHeight==`number`&&te(r.listHeight);let u=new Set([...r.open,...c.keys()]);if(!u.size){ce(o);return}let d=r.active??[...c.keys()].at(-1),f=n?.current,p=()=>t&&n?.current===f;return(async()=>{let e,n=r.preview&&!c.has(r.preview)?r.preview:void 0;for(let r of u){if(r===n)continue;let a=c.get(r);a&&l(e=>e.some(e=>e.path===r)?e:[...e,a]);let u=a?.path??await Se(i(r),{activate:!1,isCurrent:()=>t});if(!t||s.current!==o)return;r===d&&(e=u)}if(n&&p()&&(e=await Se(i(n),{activate:!1,isCurrent:p})),e&&s.current===o&&p()){let t=e;r.preview===r.active&&l(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),h(t),ue(t)}})().finally(()=>{t&&s.current===o&&ce(o)}),()=>{t=!1}},[e,a,o,n]),(0,u.useEffect)(()=>{if(!e||!o)return;let t=setTimeout(()=>{let e=rm();e[o]={open:c.map(e=>e.path),explicit:c.filter(e=>e.assetTicket).map(e=>e.path),expanded:[...w],...r&&m?{active:m}:{},...r&&m&&c.some(e=>e.path===m&&e.preview)?{preview:m}:{},...P===null?{}:{listHeight:P}},im(e)},400);return()=>{clearTimeout(t)}},[e,o,c,w,m,P,r]),(0,u.useEffect)(()=>{if(!o||se!==o)return;let e=()=>{if(s.current!==o)return;let e=p.current.filter(e=>e.dirty);return Gf(`super-pi.file-drafts.v1.`+o,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&_(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[o,se,c]);let de=(0,u.useCallback)(async(t,n=!1)=>{if(!e)return;let r={},i=k.current;i.set(t,r);let c=()=>s.current===o&&k.current===i&&i.get(t)===r;await Mp(Ip(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&C(n=>({...n,[t]:e}))}).catch(e=>{c()&&C(n=>({...n,[t]:{error:Np(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),fe=(0,u.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=(0,u.useCallback)(t=>{if(!e)return;let n=new Set([``,...O.current]),r=t&&new Set(t.map(lf)),i=e=>!r||r.has(e)||t.some(t=>uf(e,t));C(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of k.current.keys())!n.has(e)&&i(e)&&k.current.delete(e);Promise.all([...n].filter(i).map(e=>de(e,!t&&!e))).then(()=>{s.current===o&&M(e=>e+1)})},[e,o,de]),me=(0,u.useCallback)(()=>pe(),[pe]),I=(0,u.useRef)(void 0),he=(0,u.useRef)(new Set);(0,u.useEffect)(()=>()=>{clearTimeout(I.current),I.current=void 0,he.current=new Set},[o]);let ge=(0,u.useCallback)((t,n)=>{if(t!==e)return;let r=a?`${a}/`:``,i=n?.flatMap(e=>e.startsWith(r)?[e.slice(r.length)]:[]);if(i?.length===0){if(!n?.some(e=>uf(a,e)))return;he.current=null}else if(!i)he.current=null;else for(let e of i)he.current?.add(e);I.current||=setTimeout(()=>{I.current=void 0;let e=he.current;he.current=new Set,pe(e?[...e]:void 0)},100)},[e,a,pe]),_e=(0,u.useCallback)(e=>{let t=new Set;for(let n=lf(e);n;n=lf(n))t.add(n);ee(``),T(e=>new Set([...e,...t]))},[]),ve=(0,u.useCallback)((e,t)=>{_e(t&&e?`${e}/`:e),D({path:e,directory:t})},[_e]),ye=(0,u.useCallback)(()=>T(new Set),[]),be=(0,u.useCallback)((e,t,n)=>{let r=n=>uf(n,e)?t+n.slice(e.length):n,i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[r(e),t]));l(t=>t.map(t=>{let i=r(t.path);if(i===t.path)return t;let a=cf(i),o=t.view&&t.view!==`table`&&(!a||a===`table`)||t.path===e&&n===!1&&!a?`download`:a;return{...t,path:i,view:o,name:i.split(`/`).at(-1)??t.name}})),h(e=>e&&r(e)),T(e=>new Set([...e].map(r))),y(i),x(i);for(let t of k.current.keys())uf(t,e)&&k.current.delete(t);C(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!uf(t,e)))),_e(t)},[_e]),xe=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{xe.current=void 0},[e,a]),(0,u.useEffect)(()=>{let t=Kp(N);if(!e||!t||Gp(N)){xe.current=void 0,re(null),ie(!1);return}let n=!0,r,i=async()=>{try{let o=await Hp(Vp(e,t,a),xe,()=>n);if(!n||!o)return;re(o),ie(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;re(null),ie(!1),_(Ht(e,`文件查找没有完成`))}};return ie(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[N,e,a,j]);let Se=(0,u.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:i,throwOnError:c,requireText:u}={})=>{if(!(!e||i&&!i())){_(``);try{let c=p.current.find(e=>e.path===t.path),d=c??await qp(e,a,t);if(s.current!==o||i&&!i())return;if(u&&d.view&&d.view!==`table`)throw Error(`已找到匹配行,但此文件无法在文本编辑器中定位。可以在搜索结果中查看这一行。`);return c?(r&&h(t.path),t.path):(l(e=>e.some(e=>e.path===d.path)?e:[...e,{...d,...n?{preview:n}:{}}]),r&&h(d.path),x(e=>({...e,[d.path]:!1})),d.path)}catch(e){if(s.current!==o||i&&!i())return;if(c)throw e;_(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,a,o]),Ce=(0,u.useCallback)(e=>{o&&p.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&am(o,e),l(t=>{let n=t.find(t=>t.path===e);if(n?.dirty&&!window.confirm(`「${n.name}」有未保存的修改,关掉就丢了。仍然关闭?`))return t;let r=t.findIndex(t=>t.path===e),i=t.filter(t=>t.path!==e);return e===m&&h(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[m,o]),we=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),Te=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),h(t=>t===e?void 0:t),o&&am(o,e)},[o]),Ee=(0,u.useCallback)((e,t)=>{l(n=>n.map(n=>n.path===e&&!n.assetTicket&&n.content!==t?{...n,content:t,dirty:!0,preview:!1}:n))},[]);(0,u.useEffect)(()=>{if(!e||c.length===0)return;let t=!0,n=setInterval(()=>{for(let{path:n,assetTicket:r}of p.current)r||Mp(Bp(e,n,a)).then(e=>{if(!t)return;let r=p.current.find(e=>e.path===n);r?.view&&r.view!==`table`&&e.etag!==r.etag?l(t=>t.map(t=>t.path===n&&t.etag===r.etag?{...t,etag:e.etag}:t)):r&&e.etag!==r.etag&&x(e=>({...e,[n]:!0}))}).catch(e=>{t&&Np(e).status===404&&x(e=>({...e,[n]:!0}))})},Dp);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let De=(0,u.useCallback)(async(t,n)=>{if(!e)return;let r=c.find(e=>e.path===t);if(!r||r.assetTicket)return;y(e=>({...e,[t]:{state:`saving`,message:``}}));let i=r.etag;if(n)try{i=(await Mp(Bp(e,t,a))).etag}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let u=r.content;try{let n=await Mp(zp(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:Rp(t)??t,content:u,baseEtag:i})});if(s.current!==o)return;let r=p.current.find(e=>e.path===t),c=r!==void 0&&r.content!==u;l(e=>e.map(e=>e.path===t?{...e,etag:n.meta.etag,dirty:e.content!==u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:c?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${Jp(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof kp&&e.body.code===`stale`;y(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&x(e=>({...e,[t]:!0}))}},[e,a,o,c]),Oe=(0,u.useCallback)(async t=>{if(!e)return;let n=p.current.find(e=>e.path===t),r=n?.content;try{if(n?.assetTicket){let r=await qp(e,a,{path:t,name:n.name,text:null,openLink:!0});if(!r.assetTicket||r.path!==t)throw Error(`链接目标已变化,请关闭后重新打开。`);s.current===o&&(l(e=>e.map(e=>e.path===t?{...r,preview:e.preview}:e)),y(e=>({...e,[t]:{state:`idle`,message:``}})));return}let i=await Mp(zp(e,t,a));if(s.current!==o)return;let c=p.current.find(e=>e.path===t),u=c!==void 0&&c.content!==r;l(e=>e.map(e=>e.path===t?{...e,content:u?e.content:i.content,etag:i.meta.etag,dirty:u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,a,o]),ke=c.find(e=>e.path===m),Ae=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:Rp(e.path)??e.path,closable:!0,badge:e.dirty?(0,L.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),je=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),Me=(0,u.useCallback)((e,t,n)=>{oe(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Ne=e?ae[e]:void 0,Pe=(0,u.useMemo)(()=>{let e=Ne?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Ne,a]),Fe=Ne?.dropped??0,Ie=(0,u.useMemo)(()=>new Set(Pe.map(e=>e.path)),[Pe]),Le=(0,u.useMemo)(()=>{let e=new Set;for(let t of Pe){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Pe]);return{ownerWorkspaceId:d,open:c,activePath:m,visiblePath:r?m:i,location:E,active:ke,tabItems:Ae,openPaths:je,notice:g,setNotice:_,saves:v,external:b,restoringWorkbench:!!(o&&se!==o),openFile:Se,setActivePath:h,closeFile:Ce,pinFile:we,discardPreview:Te,updateBuffer:Ee,save:De,reload:Oe,listings:S,expanded:w,toggleDirectory:fe,loadDirectory:de,refreshTree:me,invalidateTree:ge,revealPath:_e,locatePath:ve,collapseDirectories:ye,movePath:be,listHeight:P,setListHeight:te,query:N,setQuery:ee,hits:ne,searching:F,changed:Pe,changedPaths:Ie,changedDirs:Le,changedDropped:Fe,setChangedFor:Me,restoredActive:le}}var nm=`super-pi.file-workbench.v1`;function rm(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.file-workbench.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`)continue;let e=r,i=Array.isArray(e.open)?e.open.filter(e=>typeof e==`string`):[],a=typeof e.preview==`string`?e.preview:void 0;a&&a!==e.active&&(i=i.filter(e=>e!==a));let o=Array.isArray(e.expanded)?e.expanded.filter(e=>typeof e==`string`):[],s=typeof e.listHeight==`number`&&Number.isFinite(e.listHeight)&&e.listHeight>0?Math.round(e.listHeight):void 0,c=Array.isArray(e.explicit)?e.explicit.filter(e=>typeof e==`string`):[];t[n]={open:i,expanded:o,explicit:c,...typeof e.active==`string`?{active:e.active}:{},...a&&a===e.active?{preview:a}:{},...s?{listHeight:s}:{}}}return t}catch{return{}}}function im(e){try{typeof window<`u`&&window.localStorage.setItem(nm,JSON.stringify(e))}catch{}}function am(e,t){let n=rm(),r=n[e];!r?.preview||t&&r.preview!==t||(n[e]={...r,open:r.open.filter(e=>e!==r.preview),active:void 0,preview:void 0},im(n))}function om({height:e,onHeight:t,panelRef:n,min:r=120}){let[i,a]=(0,u.useState)(!1),o=()=>{let e=n.current?.querySelector(`.files-tree`)??null;return{list:e,height:e?.getBoundingClientRect().height??0}},s=e=>{e.preventDefault(),e.currentTarget.focus();let n=e.clientY,{height:i}=o();a(!0);let s=document.body,c=s.style.cursor,l=s.style.userSelect;s.style.cursor=`row-resize`,s.style.userSelect=`none`;let u=e=>{let a=Math.round(i+(e.clientY-n));t(Math.max(r,a))},d=()=>{s.style.cursor=c,s.style.userSelect=l,a(!1),window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d)};window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},c=e=>e.shiftKey?96:24;return(0,L.jsx)(`div`,{className:`files-splitter${i?` files-splitter-dragging`:``}`,"data-file-splitter":`1`,"data-file-splitter-dragging":i?`true`:`false`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整文件列表高度`,"aria-valuenow":e??void 0,"aria-valuemin":r,tabIndex:0,onMouseDown:s,onKeyDown:e=>{let i=c(e);if(e.key===`ArrowDown`){e.preventDefault();let{height:n}=o();t(Math.max(r,Math.round(n)+i))}else if(e.key===`ArrowUp`){e.preventDefault();let{height:n}=o(),a=Math.round(n)-i;t(a<=r?null:a)}else if(e.key===`Home`)e.preventDefault(),t(null);else if(e.key===`End`){e.preventDefault();let i=n.current?.querySelector(`.files-tree`)?.parentElement?.clientHeight??0;t(Math.max(r,i))}}})}var sm=()=>null,cm=`application/x-super-pi-workspace-file`;function lm({workspaceId:e,workspaceName:t,cwd:n=``,files:r,onOpenFile:i,onOpenChanged:a,onReference:o,onMoved:s,onSearchFolder:c}){let{open:l,openPaths:d,notice:f,setNotice:p,openFile:m,listings:h,expanded:g,toggleDirectory:_,loadDirectory:v,refreshTree:y,listHeight:b,setListHeight:x,query:S,setQuery:C,hits:w,searching:T,changed:E,changedPaths:D,changedDirs:O,changedDropped:k}=r,A=(0,u.useCallback)((e,t)=>{i?i(e,t):m(e)},[i,m]),j=n.split(`/`).at(-1)||t||`工作目录`,M=gf({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[N,ee]=(0,u.useState)(),P=(0,u.useRef)(void 0),[te,ne]=(0,u.useState)(!1),re=M.editing?M.inline:sm,F=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:N,inline:re}),[r.visiblePath,N,re]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{ee(void 0),P.current=void 0,ne(!1)},[e,n]);let ie=h[``],ae=S.trim(),oe=e?Gp(S):void 0,se=(0,u.useRef)(null),ce=(0,u.useRef)(null),le=(0,u.useRef)(void 0);function ue(e){let t=ce.current;t&&(le.current&&le.current!==e&&(le.current.tabIndex=-1),le.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let de=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||de.current===e)return;let t=se.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(de.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,h,g,S]),(0,u.useEffect)(()=>{if(!N||g.has(N))return;let e=window.setTimeout(()=>_(N),650);return()=>window.clearTimeout(e)},[N,g,_]);let fe=(0,u.useCallback)(e=>{let t=se.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=ff(n);if(r&&!M.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),M.openMenu(r,Zd(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),M.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),M.showAction(`trash`,r,!1,n);return}}let i=[...(n.closest(`.files-tree, .files-changed`)??t).querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),a=i.indexOf(n);if(a<0)return;let o=e=>{let t=Math.max(0,Math.min(i.length-1,e));i[t]?.focus()};if(e.key===`ArrowDown`)e.preventDefault(),o(a+1);else if(e.key===`ArrowUp`)e.preventDefault(),o(a-1);else if(e.key===`Home`)e.preventDefault(),o(0);else if(e.key===`End`)e.preventDefault(),o(i.length-1);else if(e.key===`ArrowRight`){let t=n.getAttribute(`data-file-dir-toggle`);if(t&&n.getAttribute(`aria-expanded`)===`false`)e.preventDefault(),_(t);else if(t){let t=n.closest(`.file-node`)?.querySelector(`.file-children .file-row:not(:disabled)`);t&&(e.preventDefault(),t.focus())}}else if(e.key===`ArrowLeft`){let r=n.getAttribute(`data-file-dir-toggle`);if(r&&n.getAttribute(`aria-expanded`)===`true`){e.preventDefault(),_(r);return}let i=n.getAttribute(`data-file-open`)??n.getAttribute(`data-file-hit`)??r;if(i){e.preventDefault();let n=i.lastIndexOf(`/`),r=n<0?``:i.slice(0,n);(r?t.querySelector(`[data-file-dir-toggle="${CSS.escape(r)}"]`):null)?.focus()}}},[_,M]),[pe,me]=(0,u.useState)(200);(0,u.useEffect)(()=>{me(200)},[ae,e]);let I=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(ae===``)return;let e=I.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&me(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[ae,w]);let he=(0,u.useMemo)(()=>{if(oe)return(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":oe.path,title:oe.path,onClick:()=>A(oe),children:[(0,L.jsx)(Yt,{path:oe.path}),(0,L.jsxs)(`span`,{className:`file-name`,children:[`打开 `,oe.name]})]});if(ae){if(T)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${ae}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,pe),t=[],n=new Map;for(let r of e){let e=n.get(r.directory);if(e)e.push(r);else{let e=[r];n.set(r.directory,e),t.push({directory:r.directory,hits:e})}}return(0,L.jsxs)(L.Fragment,{children:[t.map(e=>(0,L.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,L.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,L.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,L.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,L.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,L.jsxs)(`li`,{className:`file-explorer-row`,"data-file-entry":e.path,"data-linked":e.openLink,"data-file-current":r.visiblePath===e.path?`1`:void 0,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-hit":e.path,tabIndex:-1,"aria-current":r.visiblePath===e.path?`true`:void 0,"data-file-hit-open":d.has(e.path)?`1`:`0`,onClick:()=>A({...e,text:!0}),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Yt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Xd,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,L.jsx)(`div`,{ref:I,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?ie===void 0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in ie?(0,L.jsx)(em,{error:ie.error}):(0,L.jsxs)(L.Fragment,{children:[ie.truncated&&(0,L.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),ie.entries.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,L.jsx)(`ul`,{className:`file-list`,children:ie.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Yp,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:h,expanded:g,toggle:_,loadDirectory:v,openPaths:d,changedDirs:O,changedPaths:D,onOpen:A,depth:0,presentation:F},t.path):(0,L.jsx)(Xp,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:F},t.path))})]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[oe,ae,T,w,pe,e,ie,h,g,_,v,A,d,O,D,F,r.visiblePath]),ge=e=>{let t=ff(e);if(!t?.linked)return t?t.directory?t.path:lf(t.path):``},_e=(e,t)=>e!==lf(t.path)&&!(t.directory&&uf(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ce.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=le.current;ue(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[he,M.editing]),(0,L.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:se,onKeyDown:fe,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=ff(t??null);t&&n&&!M.busy&&M.openMenu(n,Zd(t))},onContextMenu:e=>{let t=ff(e.target),n=e.target instanceof Element?e.target.closest(`.file-row, [data-explorer-action]`):void 0;t&&n&&!M.busy&&(e.preventDefault(),M.openMenu(t,{x:e.clientX,y:e.clientY,origin:n}))},onDragStart:e=>{let t=ff(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||M.busy||ae||(P.current=t,e.dataTransfer.setData(cm,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{P.current=void 0,ee(void 0)},onDragLeave:e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||ee(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=P.current&&t.dataTransfer.types.includes(cm)?P.current:void 0;if(!e||M.busy||!n&&!r)return;t.preventDefault();let i=ge(t.target),a=i!==void 0&&(!r||_e(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,ee(a?i:void 0)},onDrop:t=>{ee(void 0);let n=t.dataTransfer.types.includes(cm)?P.current:void 0;if(P.current=void 0,!e||M.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ge(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){_e(r,n)&&M.moveTo(n,r);return}let i=Array.from(t.dataTransfer.items).filter(e=>!e.webkitGetAsEntry?.()?.isDirectory).map(e=>e.getAsFile()).filter(e=>e!==null);i.length?M.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?M.upload(r,Array.from(t.dataTransfer.files)):p(`请选择要上传的文件。`)},children:[(0,L.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":N===``?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,L.jsx)(Yt,{category:`folder-open`}),(0,L.jsx)(`span`,{children:j})]}),M.toolbar]}),(0,L.jsxs)(`div`,{className:`files-search`,children:[(0,L.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Xd,{name:`search`})}),(0,L.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:S,placeholder:`筛选文件或输入绝对路径`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C(``)):e.key===`Enter`&&oe&&(e.preventDefault(),A(oe))},onChange:e=>C(e.target.value)}),(0,L.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!Rp(r.activePath)||!!(r.active?.assetTicket&&Gp(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,L.jsx)(Xd,{name:`locate`})})]}),M.controls,!oe&&ae&&w&&!T&&(0,L.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,L.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,L.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,L.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,L.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),M.busy&&(0,L.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,L.jsx)(`div`,{className:`files-tree`,ref:ce,"data-file-tree":ae?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&ue(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,L.jsxs)(`div`,{className:`files-tree-body`,children:[M.inline(``,`child`,0),he]})}),(0,L.jsx)(om,{height:b,onHeight:x,panelRef:se}),(0,L.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":te,onClick:()=>ne(e=>!e),children:[(0,L.jsx)(Xd,{name:te?`down`:`right`}),(0,L.jsx)(Xd,{name:`changes`}),(0,L.jsx)(`span`,{children:`改动`}),(0,L.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),te&&(0,L.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,L.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,L.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,L.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-changed-open":e.path,title:`${e.path}(点击查看改动)`,onClick:()=>a?.(e.path),children:[(0,L.jsx)(Yt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,L.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function um(e,t){let[n,r]=(0,u.useState)(!1),[i,a]=(0,u.useState)(``);return{choose:async(i,o,s)=>{if(i&&!n){r(!0),a(``);try{await e(i,o,s)&&t()}catch(e){a(Ht(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var dm=200;async function fm(e,t,n){let r=await ke(e,{signal:t,cache:`no-store`});if(!r.ok)throw new kp(r.status,await r.json());if(!r.body)throw Error(`服务端没有返回搜索结果。`);let i=r.body.pipeThrough(new TextDecoderStream).getReader(),a=``,o=!1;try{for(;;){let e=await i.read();if(e.done)break;let t=(a+e.value).split(`
|
|
290
290
|
`);a=t.pop();for(let e of t){if(!e)continue;let t=JSON.parse(e);if(t.type===`error`)throw Error(t.error);n(t),t.type===`done`&&(o=!0)}}if(!o)throw Error(`搜索连接提前断开,结果可能不完整。`)}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}}function pm(e,t){return{path:t?e.startsWith(t+`/`)?e.slice(t.length+1):Lp+e:e,name:e.split(`/`).at(-1)??e,text:!0}}function mm(e,t,n){return{...pm(t?t+`/`+e.path:e.path,n),name:e.name}}function hm({workspaceId:e,cwd:t=``,directory:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(n??``),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)([]),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(dm),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)(!1),[j,M]=(0,u.useState)(0),{choose:N,openError:ee,opening:P,setOpenError:te}=um(i,a),ne=!!Gp(c),re=(0,u.useRef)(null),F=(0,u.useRef)(null),ie=(0,u.useRef)(void 0),ae=(0,u.useId)();(0,u.useEffect)(()=>{re.current?.focus()},[]),(0,u.useEffect)(()=>{F.current?.scrollIntoView({block:`nearest`})},[j]),(0,u.useEffect)(()=>{let t=c.trim(),n=new AbortController;if(ie.current=n,b([]),S(void 0),E(``),A(!1),w(dm),M(0),!e||!t){O(!1);return}if(t.length>256){E(`搜索词不能超过 256 个字符。`),O(!1);return}let r=new URLSearchParams({workspaceId:e,q:t,stream:`1`,ignore:_?`1`:`0`});d&&r.set(`cwd`,d),p.trim()&&r.set(`include`,p.trim()),h.trim()&&r.set(`exclude`,h.trim()),O(!0);let i=setTimeout(()=>{n.signal.aborted||fm(`/api/files/search?`+r,n.signal,e=>{n.signal.aborted||(e.type===`matches`?b(t=>[...t,...e.hits]):e.type===`done`&&S(e.summary))}).catch(e=>{n.signal.aborted||E(Ht(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||O(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[c,e,d,p,h,_]);let oe=(0,u.useMemo)(()=>{let e=new Map;return y.slice(0,C).forEach((t,n)=>{let r=e.get(t.path);r?r.push({hit:t,row:n}):e.set(t.path,[{hit:t,row:n}])}),[...e]},[y,C]),se=e=>{e&&N(mm(e,d,t),e.line,e.column)},ce=x?.complete===!1,le={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,L.jsxs)(vf,{mode:`content`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:re,className:`quick-open-input`,"data-content-search-input":`1`,value:c,readOnly:P,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":ae,"aria-expanded":y.length>0,"aria-activedescendant":y[j]?`${ae}-${j}`:void 0,onChange:e=>{l(e.target.value),te(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),M(e=>Math.min(e+1,Math.max(0,Math.min(C,y.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),M(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),se(y[j])))}}),(0,L.jsxs)(`div`,{className:`content-search-controls`,children:[(0,L.jsxs)(`label`,{children:[`范围 `,(0,L.jsxs)(`select`,{value:d,"aria-label":`搜索范围`,onChange:e=>f(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,L.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,L.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),D&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ie.current?.abort(),re.current?.focus(),O(!1),A(!0)},children:`取消搜索`})]}),(0,L.jsxs)(`details`,{className:`content-search-filters`,children:[(0,L.jsx)(`summary`,{children:`文件筛选`}),(0,L.jsxs)(`label`,{children:[`包含 `,(0,L.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,L.jsxs)(`label`,{children:[`排除 `,(0,L.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":T?`error`:D?`searching`:k?`cancelled`:ce?`partial`:`complete`,children:[T?`搜索失败:`+T:D?`搜索中…`:k?`已取消`:e?ce?`结果不完整`:x?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(y.length>0||x)&&` · ${y.length} 条命中`]}),ne&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,c),children:`按文件路径打开`}),ce&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:x.reasons.map(e=>le[e]??e).join(`;`)}),x?.complete&&!y.length&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),ee&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:ee}),(0,L.jsx)(`ul`,{id:ae,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:oe.map(([e,t])=>(0,L.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,L.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,L.jsxs)(`button`,{id:`${ae}-${t}`,ref:t===j?F:void 0,type:`button`,role:`option`,tabIndex:-1,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${j===t?` quick-open-result-active`:``}`,"aria-selected":j===t,"aria-label":`${e.path}:${e.line}:${e.column} ${e.text}`,onMouseEnter:()=>M(t),onClick:()=>se(e),children:[(0,L.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,L.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),y.length>C&&(0,L.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{C+dm>=y.length&&re.current?.focus(),w(e=>e+dm)},children:[`显示更多结果(已显示 `,C,` / `,y.length,`)`]})]})}function gm({workspaceId:e,cwd:t=``,connected:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(0),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(),_=(0,u.useRef)(void 0),v=(0,u.useRef)(void 0),{choose:y,openError:b,opening:x,setOpenError:S}=um(i,a),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=Kp(c),E=e?Gp(c):void 0,D=!!E;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=Vp(e,``,t)+`&quick=1&refresh=1`;return _.current=Mp(i,{cache:`no-store`,signal:r.signal}).catch(()=>void 0),()=>{r.abort(),_.current=void 0}},[n,e,t]),(0,u.useEffect)(()=>{if(!n||!e||D)return;let r=new AbortController,i=r.signal,a=Vp(e,T,t)+`&quick=1&page=${p}`,o,s=async e=>{try{let t=e?await _.current:void 0;if(i.aborted)return;let n=e&&!T&&t?t:await Mp(a,{cache:`no-store`,signal:i});if(i.aborted)return;g({query:T,page:p,response:n}),n.indexed||(o=setTimeout(()=>void s(!1),350))}catch(e){i.aborted||g({query:T,page:p,error:Ht(e,`文件查找没有完成`)})}};return o=setTimeout(()=>void s(!0),T?120:0),()=>{r.abort(),clearTimeout(o)}},[n,e,t,T,D,p]);let O=h?.query===T&&h.page===p?h:void 0,k=O?.response,A=(0,u.useMemo)(()=>{if(E)return[E];let t=k?.hits.map(e=>({...e,text:null}))??[];return p>0||e&&T.includes(`/`)&&!T.endsWith(`/`)&&!T.split(`/`).includes(`..`)&&!t.some(e=>e.path.toLowerCase()===T.toLowerCase())&&(k?.total?t.push(Wp(T)):t.unshift(Wp(T))),t},[E,T,k,p,e]),j=e=>{v.current=void 0,m(e),g(void 0),f(0),S(``),C.current?.focus()},M=!D&&!(!e||O?.error||k?.indexed);return(0,u.useEffect)(()=>{let e=v.current;e===void 0||M||(v.current=void 0,y(A[Math.min(e,A.length-1)]))},[M,A,y]),(0,u.useEffect)(()=>{C.current?.focus()},[]),(0,u.useEffect)(()=>{w.current?.scrollIntoView({block:`nearest`})},[d]),(0,L.jsxs)(vf,{mode:`path`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:C,className:`quick-open-input`,"data-quick-open-input":`1`,value:c,readOnly:x,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>{let t=e.target.value;v.current=void 0,(Kp(t)!==T||p!==0)&&g(void 0),l(t),m(0),f(0),S(``)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`)e.preventDefault(),f(e=>Math.min(e+1,Math.max(0,A.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=A[Math.min(d,A.length-1)],n=k?.hits.some(e=>e.path===t?.path&&[e.name,e.path].some(e=>e.toLowerCase()===T.toLowerCase()));M&&!n?v.current=d:y(t)}}}}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"aria-live":`polite`,"data-quick-open-status":D||k?.indexed&&!k.incomplete?`complete`:`partial`,children:[D?`按 Enter 打开指定文件`:e?n?O?.error||(M?`正在检查文件索引…`:T?k?.incomplete?`索引不完整 · ${k.total} 条命中`:k?.total?`${k.total} 条命中${p?` · 第 ${p+1} 页`:``}`:A.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),b&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:b}),(0,L.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:A.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===d?w:void 0,type:`button`,"data-quick-open-result":e.path,className:t===d?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===d,onMouseMove:()=>f(t),onClick:()=>{v.current=void 0,y(e)},children:[(0,L.jsx)(`span`,{title:e.name,children:e.name}),(0,L.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),T&&k?.indexed&&(p>0||k.truncated)&&(0,L.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[p>0&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>j(p-1),children:`上一页`}),k.truncated&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>j(p+1),children:`下一页`})]})]})}function _m({workspaceId:e,workspaceName:t,cwd:n,connected:r,onOpen:i,onSession:a}){let[o,s]=(0,u.useState)(`content`),[c,l]=(0,u.useState)(``),d={workspaceId:e,cwd:n,initialQuery:c,presentation:`sidebar`,onClose:()=>{},onMode:(e,t)=>{l(t),s(e)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`workbench-search-heading`,children:[(0,L.jsx)(`strong`,{children:`搜索`}),(0,L.jsx)(`span`,{title:t,children:t??`请选择工作区`})]}),o===`content`?(0,L.jsx)(hm,{...d,onOpen:i}):o===`path`?(0,L.jsx)(gm,{...d,connected:r,onOpen:i}):(0,L.jsx)(yf,{...d,onOpen:a})]})}function vm(e,t,n=88,r=200){let i=Math.max(0,Math.floor(e));if(!Number.isFinite(t)||t<=0)return{perRow:Math.max(1,i),width:n};if(i===0)return{perRow:1,width:n};if(i===1)return{perRow:1,width:Math.min(r,t)};let a=t/i;if(a>=n)return{perRow:i,width:Math.min(a,r)};for(let e=2;e<=i;e+=1){let a=Math.ceil(i/e),o=t/a;if(o>=n)return{perRow:a,width:Math.min(o,r)}}return{perRow:1,width:n}}function ym(e,t){let n=Math.max(1,Math.floor(t)),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function bm(e,t,n=88,r=200){let[i,a]=(0,u.useState)(()=>vm(e,0,n,r)),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(()=>{let i=vm(e,t,n,r);s({count:e,containerWidth:t}),a(e=>e.perRow===i.perRow&&e.width===i.width?e:i)},[e,t,n,r]),l=(0,u.useRef)(t);(0,u.useLayoutEffect)(()=>{t<=0||l.current!==t&&(l.current=t,c())},[t,c]);let d=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=d.current;d.current=e,t!==null&&e>t&&c()},[e,c]),{layout:i,frozen:o!==null&&o.count!==e,recompute:c}}function xm({tabs:e,activeId:t,onSelect:n,onClose:r,onActivate:i,ariaLabel:a,minWidth:o=88,maxWidth:s=200,prefix:c=`workspace-tab`,idPrefix:l=c,className:d}){let f=(0,u.useRef)(null),[p,m]=(0,u.useState)(0),{layout:h,frozen:g,recompute:_}=bm(e.length,p,o,s);(0,u.useLayoutEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.clientWidth;t>0&&m(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let v=ym(e,h.perRow),y=(e,t)=>t===void 0?{}:{[`data-${c}-${e}`]:t},b=e.filter(e=>e.kind===`file`).length,x=e.filter(e=>e.kind===`session`||!e.kind).length,S=t=>({[`data-${t}-strip`]:`1`,...g?{[`data-${t}-frozen`]:`1`}:{},[`data-${t}-count`]:t===`file-tab`?b:t===`session-tab`?x:e.length,[`data-${t}-min`]:o,[`data-${t}-max`]:s,[`data-${t}-per-row`]:h.perRow,[`data-${t}-width`]:Math.round(h.width*100)/100}),C=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()},w=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()};(0,u.useEffect)(()=>{if(!g)return;let e=f.current;if(!e)return;let t=t=>{let n=e.getBoundingClientRect();t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom||_()};return document.addEventListener(`mousemove`,t,!0),()=>document.removeEventListener(`mousemove`,t,!0)},[g,_]);let T=[`${c}-strip`,`workspace-tab-strip`,`session-tab-strip`,`file-tab-strip`,d].filter(Boolean).join(` `);return(0,L.jsx)(`div`,{ref:f,className:T,role:`tablist`,"aria-label":a??`工作区标签页`,...y(`strip`,`1`),...S(`workspace-tab`),...S(`session-tab`),...S(`file-tab`),style:{"--tab-w":`${h.width}px`},onMouseEnter:C,onMouseLeave:w,children:v.map((a,o)=>(0,L.jsx)(`div`,{className:`${c}-row workspace-tab-row session-tab-row file-tab-row`,role:`presentation`,...y(`row`,o),children:a.map(a=>{let o=a.id===t||a.rawId!==void 0&&a.rawId===t,s=a.title??a.label,u=a.kind,d=a.rawId??a.id,f=e.findIndex(e=>e.id===a.id),p=[c,o?`${c}-active`:``,`workspace-tab`,o?`workspace-tab-active`:``,u?`${u}-tab`:``,u&&o?`${u}-tab-active`:``,a.preview?`${c}-preview`:``,a.preview?`workspace-tab-preview`:``,a.preview&&u?`${u}-tab-preview`:``].filter(Boolean).join(` `);return(0,L.jsxs)(`div`,{role:`tab`,id:`${l}-${a.id}`,"aria-selected":o,"aria-controls":`${l}-panel-${a.id}`,tabIndex:o?0:-1,className:p,...y(`id`,d),...y(`index`,f),...o?y(`active`,`1`):{},...y(`closable`,a.closable===!1?`0`:`1`),...u?{"data-tab-kind":u}:{},...a.preview?{"data-tab-preview":`1`}:{},...u===`session`||!u?{"data-session-tab-id":d,"data-session-tab-index":f,...o?{"data-session-tab-active":`1`}:{},"data-session-tab-closable":a.closable===!1?`0`:`1`,...a.preview?{"data-session-tab-preview":`1`}:{}}:{},...u===`file`?{"data-file-tab-id":d,"data-file-tab-index":f,...o?{"data-file-tab-active":`1`}:{},"data-file-tab-closable":a.closable===!1?`0`:`1`}:{},...u===`diff`?{"data-diff-tab-id":d,"data-diff-tab-index":f,...o?{"data-diff-tab-active":`1`}:{},"data-diff-tab-closable":a.closable===!1?`0`:`1`}:{},title:s,style:{width:h.width,boxSizing:`border-box`},onClick:()=>n?.(a.id),onDoubleClick:i?()=>i(a.id):void 0,onAuxClick:e=>{e.button===1&&(e.preventDefault(),e.stopPropagation(),a.closable!==!1&&r&&r(a.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let r=t.key===`ArrowRight`?1:-1,i=e[(e.findIndex(e=>e.id===a.id)+r+e.length)%e.length];i&&(document.getElementById(`${l}-${i.id}`)?.focus(),n?.(i.id))},children:[a.icon&&(0,L.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,L.jsx)(`span`,{className:`${c}-label workspace-tab-label ${u?`${u}-tab-label`:``}`,...y(`label`,d),...u===`session`||!u?{"data-session-tab-label":d}:{},...u===`file`?{"data-file-tab-label":d}:{},...u===`diff`?{"data-diff-tab-label":d}:{},children:a.label}),a.closable!==!1&&r&&(0,L.jsx)(`button`,{type:`button`,className:`${c}-close workspace-tab-close ${u?`${u}-tab-close`:``}`,...y(`close`,d),...u===`session`||!u?{"data-session-tab-close":d}:{},...u===`file`?{"data-file-tab-close":d}:{},...u===`diff`?{"data-diff-tab-close":d}:{},onClick:e=>{e.stopPropagation(),r(a.id)},onDoubleClick:e=>{e.stopPropagation()},title:`关闭 ${s}`,"aria-label":`关闭 ${s}`,children:`×`})]},a.id)})},`row_${o}`))})}var Sm=25,Cm=75;function wm({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(Cm,Math.max(Sm,e))));return(0,u.useLayoutEffect)(()=>{let e=n.current?.parentElement;if(!e)return;let t=()=>i(getComputedStyle(e).flexDirection===`column`);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),(0,L.jsx)(`div`,{ref:n,className:`workbench-split-divider`,"data-workbench-split-divider":!0,role:`separator`,"aria-label":`调整拆分大小`,"aria-orientation":r?`horizontal`:`vertical`,"aria-valuenow":e,"aria-valuemin":Sm,"aria-valuemax":Cm,tabIndex:0,onPointerDown:e=>{e.button===0&&(e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!e.currentTarget.hasPointerCapture(e.pointerId))return;let t=e.currentTarget.parentElement?.getBoundingClientRect();t&&a(r?(e.clientY-t.top)/t.height*100:(e.clientX-t.left)/t.width*100)},onKeyDown:t=>{let n=t.key===(r?`ArrowDown`:`ArrowRight`),i=t.key===(r?`ArrowUp`:`ArrowLeft`);if(n||i)a(e+(n?5:-5));else if(t.key===`Home`)a(Sm);else if(t.key===`End`)a(Cm);else return;t.preventDefault()}})}function Tm({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,L.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,L.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,L.jsxs)(`select`,{"aria-label":`拆分区标签页`,"data-workbench-split-tabs":!0,value:t??``,onChange:e=>n(e.target.value),title:s?.title,"data-workbench-split-preview":s?.preview||void 0,children:[(0,L.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,L.jsx)(on,{name:`pin`})}),t&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,L.jsx)(on,{name:`close`})}),(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,L.jsx)(on,{name:`split`})})]}),o??(0,L.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function Em(e,t){if(e.entries[e.index]?.key===t.key)return e;let n=[...e.entries.slice(0,e.index+1),t].slice(-100);return{entries:n,index:n.length-1}}function Dm(e,t,n,r){for(let i=t+n;i>=0&&i<e.entries.length;i+=n)if(r(e.entries[i]))return i;return-1}var Om={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},km={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},Am={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},jm={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function Mm(e){let t=Math.max(0,Math.round(e/1e3)),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=e=>String(e).padStart(2,`0`);return i>0?`${i}h ${a(r)}:${a(n)}`:`${r}:${a(n)}`}function Nm(e){let t=e.status===`running`,[n,r]=(0,u.useState)(0);(0,u.useEffect)(()=>{if(!t)return;r(Date.now());let e=window.setInterval(()=>r(Date.now()),200);return()=>window.clearInterval(e)},[t,e.startedAt]);let i=Date.parse(e.startedAt);if(Number.isFinite(i)){if(!t){let t=Date.parse(e.finishedAt??``);return Number.isFinite(t)?t-i:void 0}return n>0?n-i:void 0}}function Pm({step:e,names:t}){let n=e.attempts.length,r=e.attempts[n-1],i=t.get(e.agentId)||e.agentId,a=e.label?.trim()||i;return(0,L.jsxs)(`li`,{className:`workflow-step workflow-step-${e.status}`,"data-workflow-step":e.index+1,"data-workflow-step-status":e.status,"data-workflow-step-agent":e.agentId,"data-workflow-step-attempts":n,children:[(0,L.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:Am[e.status]}),(0,L.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,L.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,L.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,L.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,L.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:Om[e.status]}),e.status===`failed`&&r?.error&&(0,L.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:Ut(r.error),children:Ht(r.error,`这一步没有完成。`)})]})}function Fm({nodes:e,steps:t,names:n}){return(0,L.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,L.jsx)(Pm,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,L.jsxs)(`li`,{className:`workflow-node workflow-loop`,"data-workflow-loop":!0,"data-workflow-loop-rounds":e.rounds.length,"data-workflow-loop-max":e.max,"data-workflow-until":e.until,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,L.jsx)(`strong`,{children:`循环`}),(0,L.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,L.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,L.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,L.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,L.jsx)(Fm,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,L.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,L.jsx)(`strong`,{children:`逐项执行`}),(0,L.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,L.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,L.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,L.jsx)(Fm,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function Im({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=Nm(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,L.jsxs)(`article`,{className:`workflow-card workflow-${e.status}`,"data-workflow-card":e.id,"data-workflow-status":e.status,"data-workflow-steps":e.steps.length,"data-workflow-current":e.currentIndex+1,children:[(0,L.jsxs)(`div`,{className:`workflow-head`,children:[(0,L.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,L.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,L.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,L.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:km[e.status]??`未知状态`}),(0,L.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:jm[e.onFailure]??e.onFailure}),a!==void 0&&(0,L.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,Mm(a)]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,L.jsx)(Fm,{nodes:e.nodes,steps:e.steps,names:t}):(0,L.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,L.jsx)(Pm,{step:e,names:t},e.index))})]})}var Lm=[{id:`agents`,label:`智能体与创建`,icon:`🤖`,title:`Agent 智能体系统与创建指南`,description:`了解 Super Pi 的角色设定机制,以及如何一步步创建你自己的自定义 Agent。`},{id:`workspace`,label:`工作区与会话`,icon:`🗂️`,title:`工作区与多会话管理`,description:`高效管理本地代码仓库、独立会话标签页与多模态图文输入。`},{id:`subagents`,label:`子任务与编排`,icon:`⚡`,title:`子智能体委托与顺序编排使用指南`,description:`让主 Agent 安排分工、交接结果,并查看进度、处理失败与停止任务。`},{id:`model-policy`,label:`模型使用规则`,icon:`🔒`,title:`模型过滤规则(按工作区限制可用模型)`,description:`用正则规则限定哪些工作区只能用哪些模型,防止敏感代码被发到不该用的模型上。`},{id:`memory`,label:`主动记忆`,icon:`🧠`,title:`主动记忆与技能经验`,description:`让 Super Pi 在得到明确证据后保存长期事实、用户偏好和可复用工作方法。`},{id:`knowledge`,label:`知识库`,icon:`📚`,title:`工作区知识库`,description:`导入规范与设计文档,让 Agent 检索原文作答,而不是凭记忆编造。`},{id:`feishu`,label:`飞书`,icon:`📄`,title:`飞书云文档的读写`,description:`让 Agent 读一篇飞书文档、写回结论。接入方式、连接步骤与常见问题。`},{id:`tools`,label:`侧边栏工具`,icon:`🧩`,title:`全局工具:开发、导出与导入`,description:`让 Agent 写一个工具,用一个文件分享给别人,导入前先看清它会做什么。`},{id:`cli`,label:`指令与快捷键`,icon:`⌨️`,title:`Pi 终端命令与键盘快捷操作`,description:`利用 Pi 终端斜杠指令控制服务生命周期,掌握常用快捷键提升效率。`},{id:`themes`,label:`外观与主题`,icon:`🎨`,title:`界面主题与个性化显示`,description:`内置 4 款专业高对比度主题,针对不同环境提供舒适体验。`}];function Rm({onClose:e}){let[t,n]=(0,u.useState)(`agents`);(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!t.defaultPrevented&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let r=Lm.find(e=>e.id===t)??Lm[0];return(0,L.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,L.jsxs)(`div`,{className:`picker settings-window help-window`,"data-help-window":`1`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-window-title`,children:[(0,L.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,L.jsxs)(`div`,{className:`help-head-title`,children:[(0,L.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,L.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,L.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,L.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,L.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),Lm.map(e=>(0,L.jsxs)(`button`,{type:`button`,id:`help-tab-${e.id}`,className:`settings-category help-category`,role:`tab`,"aria-selected":e.id===r.id,"aria-controls":`help-panel`,tabIndex:e.id===r.id?0:-1,onClick:()=>n(e.id),children:[(0,L.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,L.jsx)(`span`,{children:e.label})]},e.id))]}),(0,L.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,L.jsxs)(`div`,{className:`help-panel-header`,children:[(0,L.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,L.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,L.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,L.jsx)(Vm,{}),r.id===`workspace`&&(0,L.jsx)(Hm,{}),r.id===`subagents`&&(0,L.jsx)(Wm,{}),r.id===`model-policy`&&(0,L.jsx)(Um,{}),r.id===`memory`&&(0,L.jsx)(zm,{}),r.id===`knowledge`&&(0,L.jsx)(Bm,{}),r.id===`feishu`&&(0,L.jsx)(Gm,{}),r.id===`tools`&&(0,L.jsx)(Km,{}),r.id===`cli`&&(0,L.jsx)(qm,{}),r.id===`themes`&&(0,L.jsx)(Jm,{})]}),(0,L.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function zm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,L.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,L.jsx)(`code`,{children:`memory`}),` 和 `,(0,L.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,L.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,L.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`权限与审批`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,L.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,L.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function Bm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,L.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`怎么用`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,L.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,L.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,L.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,L.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,L.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`语义检索是内置的`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,L.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,L.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,L.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`它不知道的事`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,L.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,L.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,L.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,L.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function Vm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,L.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,L.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,L.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,L.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,L.jsxs)(`div`,{className:`help-steps`,children:[(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`1`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,L.jsxs)(`p`,{children:[`在 `,(0,L.jsx)(`code`,{children:`agents/`}),` 或 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,L.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`2`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,L.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,L.jsx)(`pre`,{className:`help-code-block`,children:(0,L.jsx)(`code`,{children:`---
|
|
@@ -338,11 +338,11 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
338
338
|
`).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`,state:`running`};let t=(()=>{let t=/<summary>([\s\S]*?)<\/summary>/.exec(e.content);return t?t[1].trim():`后台回传`})(),n=/<task id="[^"]+" state="([^"]+)"/.exec(e.content);return{label:t,state:n?n[1]:`completed`}}function YD({message:e,order:t,total:n,running:r,interrupting:i=!1,selectable:a=!1,selected:o=!1,onToggleSelect:s,onSteer:c,onInterrupt:l,onSend:d,onCancel:f,onEdit:p}){let[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(e.content),v=e.delivery===`sending`,y=e.source===`session-reminder`,b=e.role===`tool`&&!y,{label:x,state:S}=b?JD(e):{label:qD(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,L.jsxs)(`li`,{className:`queue-row ${v?`queue-row-sending`:`queue-row-queued`} ${b?`queue-row-bg-result`:``}`,"data-queue-id":e.id,"data-message-delivery":e.delivery,"data-message-role":e.role,"data-bg-result-state":b?S:void 0,"data-waiting-order":t,"data-waiting-total":n,children:[a&&(0,L.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,L.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,L.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,L.jsxs)(`span`,{className:`reminder-label`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,L.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,L.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,L.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,L.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,L.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,L.jsx)(`textarea`,{value:g,autoFocus:!0,rows:2,"aria-label":`修改这条等待中的消息`,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),_(e.content),h(!1)),t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),C())}}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,L.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,L.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`queue-interrupt`,"data-waiting-interrupt":e.id,disabled:i,title:`停止当前任务,立即回答这条消息`,"aria-label":`停止当前任务并回答「${x}」`,onClick:()=>l(e.id),children:i?`◌ 打断中…`:`打断并回答`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-steer":e.id,title:t===1?`当前工具完成后回答这条消息`:`插到最前:让它成为下一条被回答的消息`,"aria-label":t===1?`当前工具完成后回答「${x}」`:`让「${x}」插到最前`,onClick:()=>c(e.id),children:t===1?`当前工具完成后回答`:`插到最前`})]}):(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-send":e.id,title:`现在就回答这条消息`,"aria-label":`现在就回答「${x}」`,onClick:()=>d(e.id),children:`现在就回答`}),e.role===`user`&&(0,L.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function XD(e,t,n){return`${e}:${t}:${n}`}function ZD(e){return{picked:Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected])),note:e.answers?.map(e=>e.note??``).join(`
|
|
339
339
|
`)??``}}function QD({question:e,index:t,expanded:n,draft:r,onDraftChange:i,onToggle:a,onAnswer:o}){return(0,L.jsxs)(`div`,{className:`call-block question-block-${e.status}`,"data-call-block":t,"data-call-tool":`question`,"data-call-detail":`提问`,"data-call-status":e.status===`answered`?`ok`:e.status===`cancelled`?`error`:`running`,"data-call-expanded":n?`true`:`false`,"data-question-block":t,children:[(0,L.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:a}),(0,L.jsxs)(`div`,{className:`call-head-row`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:a,children:[(0,L.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,L.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,L.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,L.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:a,children:`收起`})]}),n&&(0,L.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,L.jsx)($D,{question:e,draft:r,onDraftChange:i,instanceId:`inline`,onAnswer:o})})]})}function $D({question:e,draft:t,onDraftChange:n,instanceId:r,onAnswer:i}){let{picked:a,note:o}=t,s=(e,r,i)=>{let o=(()=>{let t=a,n=t[e]??[];return i?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}})();n({...t,picked:o})},c=()=>{i(e.items.map(e=>({id:e.id,selected:a[e.id]??[],...e.extraNote&&o.trim()?{note:o.trim()}:{}})),!1)},l=e.items.some(e=>(a[e.id]??[]).length>0);return(0,L.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(i=>(0,L.jsxs)(`div`,{className:`question-item`,children:[(0,L.jsx)(`div`,{className:`question-text`,children:i.header?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`question-header`,children:i.header}),(0,L.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,L.jsx)(Md,{source:i.question})]}):(0,L.jsx)(Md,{source:i.question})}),(0,L.jsx)(`div`,{className:`question-options`,"data-question-options":i.id,children:i.options.map(t=>{let n=e.status!==`pending`,o=(n?e.answers?.find(e=>e.id===i.id)?.selected:a[i.id])?.includes(t)??!1;return(0,L.jsxs)(`label`,{className:o?`is-chosen`:``,"data-chosen":n&&o?`1`:void 0,children:[(0,L.jsx)(`input`,{type:i.multiple?`checkbox`:`radio`,name:`q-${r}-${i.id}`,checked:o,disabled:n,onChange:()=>s(i.id,t,i.multiple)}),(0,L.jsx)(Nd,{source:t}),n&&o?(0,L.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},t)})}),e.status===`pending`&&i.extraNote?(0,L.jsx)(`textarea`,{value:o,placeholder:`补充说明(可选)`,onChange:e=>n({...t,note:e.target.value})}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,L.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,L.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},i.id)),e.status===`pending`&&(0,L.jsxs)(`div`,{className:`question-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:c,disabled:!l,children:`提交`}),(0,L.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>i([],!0),children:`跳过`})]})]})}function eO({question:e,pendingCount:t,minimized:n,floatingRight:r,onMinimize:i,onExpand:a,onLocate:o,draft:s,onDraftChange:c,onAnswer:l}){return n?(0,Ct.createPortal)((0,L.jsxs)(`button`,{type:`button`,className:`question-floating-ball`,style:{"--question-floating-right":r},"data-question-floating-ball":e.key,onClick:a,"aria-label":`展开待回答的问题${t>1?`,还有 ${t-1} 个待处理`:``}`,title:`展开待回答的问题`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`?`}),t>1&&(0,L.jsx)(`small`,{children:t})]}),document.body):(0,Ct.createPortal)((0,L.jsxs)(`section`,{className:`question-floating-panel`,style:{"--question-floating-right":r},"data-question-floating-panel":e.key,role:`dialog`,"aria-labelledby":`question-floating-title`,children:[(0,L.jsxs)(`header`,{className:`question-floating-head`,children:[(0,L.jsx)(`span`,{className:`question-floating-mark`,"aria-hidden":`true`,children:`?`}),(0,L.jsxs)(`h2`,{id:`question-floating-title`,children:[`需要你回答`,t>1?` · 还有 ${t-1} 个`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize`,onClick:o,title:`定位到消息上下文并最小化`,children:`查看上下文`}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize-icon`,onClick:i,title:`最小化为悬浮球`,"aria-label":`最小化问题`,children:`−`})]}),(0,L.jsx)(`div`,{className:`question-floating-body`,children:(0,L.jsx)($D,{question:e.value,draft:s,onDraftChange:c,instanceId:`floating`,onAnswer:l})})]}),document.body)}function tO({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,L.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,L.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,L.jsxs)(`div`,{className:`extui-head`,children:[(0,L.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,L.jsxs)(`span`,{className:`extui-deadline`,children:[Math.ceil(Math.max(0,e.deadlineAt===void 0?e.timeoutMs:e.deadlineAt-Date.now())/1e3),`s 超时`]})]}),n&&(0,L.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,L.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,L.jsx)(`h3`,{className:`extui-title`,children:e.title||hO[e.method]}),e.method===`confirm`&&(0,L.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,L.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,L.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,L.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,L.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,L.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&$E(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,L.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&$E(e)&&e.preventDefault()}}),(0,L.jsxs)(`div`,{className:`extui-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,L.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function nO({initial:e,label:t,onCommit:n,onClose:r}){let[i,a]=(0,u.useState)(e),o=(0,u.useRef)(null),s=(0,u.useRef)(!1);(0,u.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]);let c=!i.trim(),l=()=>{s.current=!0,r()},d=()=>{if(c)return;let t=i.trim();(t===e||n(t))&&l()};return(0,L.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,L.jsx)(`input`,{ref:o,className:`inline-edit-input`,value:i,"aria-label":t,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){if($E(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function rO({kind:e,label:t,value:n,detail:r,options:i,disabled:a,note:o,onChoose:s,scope:c,providerOptions:l}){let[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(0),[_,v]=(0,u.useState)(`*`),y=(0,u.useRef)(null),b=(0,u.useRef)(null),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)([]),w=i.find(e=>e.selected),T=TD(l?i.filter(e=>_===`*`||e.key!==iO&&e.key.split(`/`)[0]===_):i,p),E=T.length===0?-1:Math.min(Math.max(h,0),T.length-1),D=E<0?void 0:T[E],O=(e=!1)=>{f(!1),e&&b.current?.focus()},k=()=>{m(``),v(`*`),g(Math.max(i.findIndex(e=>e.selected),0)),f(!0)},A=e=>g(t=>T.length?Math.min(Math.max(t+e,0),T.length-1):0);(0,u.useEffect)(()=>{if(!d)return;let e=e=>{y.current?.contains(e.target)||O()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[d]),(0,u.useEffect)(()=>{if(!d)return;let e=y.current,t=t=>{e?.contains(t.relatedTarget)||O()};return e?.addEventListener(`focusout`,t),()=>e?.removeEventListener(`focusout`,t)},[d]),(0,u.useEffect)(()=>{d&&S.current?.focus()},[d]),(0,u.useEffect)(()=>{d&&E>=0&&C.current[E]?.scrollIntoView({block:`nearest`})},[d,E]),(0,u.useLayoutEffect)(()=>{if(!d)return;let e=x.current;if(!e)return;e.style.setProperty(`--picker-nudge`,`0px`),e.style.setProperty(`--picker-drop`,`0px`);let t=e.getBoundingClientRect(),n=Math.min(window.innerWidth-8-t.right,Math.max(8-t.left,0)),r=Math.min(window.innerHeight-8-t.bottom,Math.max(8-t.top,0));e.style.setProperty(`--picker-nudge`,`${n}px`),e.style.setProperty(`--picker-drop`,`${r}px`)},[d,T.length,i.length]);let j=e=>{if(d){if(e.key===`Escape`)e.preventDefault(),O(!0);else if(e.key===`ArrowDown`)e.preventDefault(),A(1);else if(e.key===`ArrowUp`)e.preventDefault(),A(-1);else if(e.key===`Home`)e.preventDefault(),g(0);else if(e.key===`End`)e.preventDefault(),g(Math.max(T.length-1,0));else if(e.key===`Enter`){if($E(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},M=`picker-list-${c??e}`,N=t=>`picker-option-${c??e}-${t}`;return(0,L.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,L.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${_D[e]}:${r?`${t} · ${r}`:t}`,"data-picker-trigger":e,"data-picker-value":n??t,"data-picker-selected":i.some(e=>e.selected),onClick:()=>d?O():k(),children:[(0,L.jsx)(`span`,{className:`session-picker-kind`,children:_D[e]}),(0,L.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,L.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,L.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,L.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,L.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,L.jsx)(`span`,{children:`Provider`}),(0,L.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,L.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]})]}),(0,L.jsxs)(`div`,{className:`picker-filter`,children:[(0,L.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,L.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${yD[e]}选项`,"aria-expanded":`true`,"aria-controls":M,"aria-autocomplete":`list`,"aria-activedescendant":D?N(E):void 0,value:p,placeholder:`输入以筛选…`,autoComplete:`off`,spellCheck:!1,onChange:e=>{m(e.target.value),g(0)}}),p&&(0,L.jsx)(`button`,{type:`button`,className:`picker-filter-clear`,"data-picker-filter-clear":e,title:`清空筛选`,"aria-label":`清空筛选`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(``),g(0),S.current?.focus()},children:`✕`})]}),w&&!T.some(e=>e.key===w.key)&&(0,L.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,L.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,L.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,L.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:M,"aria-label":xD[e],children:[T.map((e,t)=>(0,L.jsxs)(`button`,{id:N(t),type:`button`,role:`option`,"aria-selected":e.selected,ref:e=>{C.current[t]=e},className:`picker-option${e.selected?` selected`:``}${t===E&&!e.selected?` preview`:``}`,"data-picker-option":e.key,"data-picker-option-selected":e.selected,"data-picker-highlight":t===E,onClick:()=>{s(e.key),O(!0)},children:[e.color&&(0,L.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,L.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,L.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,L.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,L.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?bD[e]:`没有匹配「${p.trim()}」的${yD[e]}`})]})]})]})}var iO=`__pi_default__`;function aO({workspace:e,catalog:t,agents:n,onSave:r,onRename:i,onRemove:a,onClose:o}){let[s,c]=(0,u.useState)(e.defaultAgentId),[l,d]=(0,u.useState)(e.defaultModel),[f,p]=(0,u.useState)(e.defaultThinkingLevel);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let m=t?.source===`pi`,h=[{key:iO,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,UE(e.contextWindow)?`${UE(e.contextWindow)} 上下文`:``,WE(e.maxTokens)?`${WE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:CD(e),selected:l?.provider===e.provider&&l.modelId===e.modelId}))],g=t?.models.find(e=>e.provider===l?.provider&&e.modelId===l?.modelId),_=g?.thinkingLevels??t?.levels??[],v=[{key:iO,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===iO){d(void 0),p(void 0);return}let n=(t?.models??[]).find(t=>t.provider===e.split(`/`)[0]&&t.modelId===e.split(`/`)[1]);if(n){let e=l?.provider!==n.provider||l.modelId!==n.modelId;d({provider:n.provider,modelId:n.modelId,label:n.label}),e&&p(void 0)}},b=e=>p(e===iO?void 0:e),x=[{key:iO,label:`跟随 Pi 默认`,detail:`新会话不使用任何 agent 角色`,selected:s===void 0},...(n?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:s===e.id}))];return(0,L.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,L.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h2`,{children:`工作区设置`}),(0,L.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,L.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,L.jsx)(rO,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??iO,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:MD(n),onChoose:e=>c(e===iO?void 0:e)})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,L.jsx)(rO,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:iO,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:jD(`模型`,t),onChoose:y})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,L.jsx)(rO,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??iO,options:v,disabled:!m,note:jD(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,L.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,L.jsxs)(`div`,{className:`picker-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var oO=[{id:`main`,label:`任务`,name:`任务与后台任务`},{id:`projects`,label:`项目`,name:`项目控制面`},{id:`tools`,label:`工具`,name:`工具 tab`},{id:`files`,label:`文件`,name:`文件 tab`},{id:`git`,label:`Git`,name:`Git tab`},{id:`terminal`,label:`终端`,name:`终端 tab`}],sO=`super-pi.right-tabs.v1`;function cO(){let e=e=>oO.some(t=>t.id===e),t={tab:oO[0].id,byConversation:{}};try{let n=JSON.parse(qe(sO)??`null`);return!n||!e(n.tab)?t:{tab:n.tab,byConversation:Object.fromEntries(Object.entries(n.byConversation??{}).filter(t=>e(t[1])))}}catch{return t}}var lO={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},uO={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},dO={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},fO={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},pO=e=>e?.status===`running`||e?.status===`waiting`,mO={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},hO={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function gO(e,t){return t.some(t=>t.conversationId===e.id)?!0:e.messagesLoaded===!1?e.hasPendingQuestion===!0:e.messages.some(e=>(e.toolCalls??[]).some(e=>e.question?.status===`pending`))}function _O(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return tt({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function vO(e,t,n,r){let i=_O(e,r,n);return nt({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function yO(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,L.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:dO.awaiting_decision,children:dO.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:dO.awaiting_subordinates,children:dO.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:dO.pending_report,children:dO.pending_report}):null}function bO({state:e,label:t=dO[e]}){let n=lO[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,L.jsx)(`i`,{className:`session-state session-state-${e} session-state-${r}`,"data-session-state":e,title:t,"aria-label":t,...e===`awaiting_background`?{style:{color:`var(--accent)`}}:{},children:(0,L.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function xO(e,t){return(0,L.jsxs)(L.Fragment,{children:[e.origin===`orchestrator`&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function SO(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var CO={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},wO={pending:`○`,in_progress:`◐`,completed:`✓`},TO={high:`高`,medium:`中`,low:`低`};function EO(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function DO({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,L.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${CO[e.status]}`,children:[(0,L.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:wO[e.status]}),(0,L.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,L.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:CO[e.status]}),e.priority&&(0,L.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:TO[e.priority]})]})}function OO(e,t){if(!e)return[];let n=t.filter(t=>t.conversationId===e.id&&t.status===`running`),r=new Set(n.map(e=>e.id));for(let t of e.messages)t.toolCalls?.forEach((i,a)=>{let o=i.backgroundTask;o&&o.status===`running`&&!r.has(o.id)&&(r.add(o.id),n.push({id:o.id,conversationId:e.id,title:i.detail?.trim()||i.label?.trim()||o.id,status:o.status,originMessageId:t.id,originCallRow:a}))});return n}function kO({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,L.jsx)(`ul`,{className:`bg-list`,"data-bg-task-count":e.length,children:e.map((e,i)=>{let a=e.id||`bg_${i}`,o=e.status?.trim()||``,s=o?mO[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,L.jsx)(AO,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function AO({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=LD(e.id,r),c=n?JE(n):s?.text||e.output,l=c&&qE(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,L.jsxs)(`li`,{className:`bg-item${a?` bg-item-expanded`:``}`,"data-bg-task":e.id,"data-bg-task-status":e.status??`unknown`,title:`状态:${t}`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,L.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,L.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,L.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,L.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,L.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
|
|
340
340
|
|
|
341
|
-
`)||`运行中,暂无输出`})]})}var jO=(0,u.lazy)(()=>Zf(()=>import(`./GitDiffEditor-
|
|
341
|
+
`)||`运行中,暂无输出`})]})}var jO=(0,u.lazy)(()=>Zf(()=>import(`./GitDiffEditor-DaN0Ye4q.js`),__vite__mapDeps([4,1,2,0,5,6,3,7])));function MO({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,notify:M,serverTimeZone:N,onOpenSession:ee,side:P,onArrange:te,pinned:ne=!0,sharedGit:re}){let F=oO,ie=P===`left`;return(0,L.jsx)(`div`,{className:`right-rail${P?` workbench-panel workbench-panel-`+P:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":ie?`左侧栏`:`右侧栏`,"data-right-rail":ie?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":P,hidden:P&&s?!0:void 0,children:s?!P&&(0,L.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,L.jsxs)(L.Fragment,{children:[P?(0,L.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,L.jsx)(`h2`,{children:Xt[D]}),te&&(0,L.jsx)(ln,{view:D,side:P,pinned:ne,onArrange:te}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":ie?void 0:`1`,title:ie?`收起左侧栏`:`收起右侧栏`,"aria-label":ie?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,L.jsx)(on,{name:`close`})})]}):(0,L.jsxs)(`div`,{className:`right-rail-head`,children:[(0,L.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":F.length,children:F.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===D?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===D,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>O(e.id),children:e.label},e.id))}),(0,L.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),oO.filter(e=>e.id===D).map(s=>(0,L.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":P?Xt[s.id]:void 0,"aria-labelledby":P?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,L.jsxs)(L.Fragment,{children:[(e.length>0||t.length>0)&&(0,L.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,L.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,L.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,L.jsx)(tw,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,L.jsx)(`span`,{"data-todo-summary":`1`,children:EO(e)}),children:e.length>0?(0,L.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,L.jsx)(DO,{todo:e,index:t},e.id??`todo_${t}`))}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,L.jsx)(tw,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,L.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,L.jsx)(kO,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,L.jsx)(hw,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:M,serverTimeZone:N})]})]}),s.id===`projects`&&(0,L.jsx)(eT,{workspaceId:l,notify:M,onOpenSession:ee,onOpenFile:b,cwd:h},l),s.id===`tools`&&(0,L.jsx)(NO,{workspaceId:l},l),s.id===`files`&&(0,L.jsx)(lm,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,L.jsx)(hi,{repositoryOnly:d,workspaceId:u??null,conversationId:g,cwd:u===l?h:``,followedWorktreeId:_,onOpenDiff:e=>S({...e,comparison:m?`${m} · ${e.comparison}`:e.comparison}),activeDiffUrl:C,onOpenConversation:ee,sharedGit:re},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,L.jsx)(ew,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j},JSON.stringify([l,g]))]},s.id))]})})}function NO({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=TE(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await OE(e);t&&o(`移除工具失败:${Ht(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${QT(t)})`:`打开${e}`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`rail-section-head`,children:[(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,L.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,L.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-tool-icon":e.id,"data-tool-kind":e.kind,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),"aria-current":r===e.id?`true`:void 0,onClick:()=>EE.toggleTool(e.id),children:[(0,L.jsx)(AT,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${QT(i[e.id])}`,children:$T(i[e.id])}),e.kind===`link`&&(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>EE.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-mounted-tool-icon":e.id,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),onClick:()=>EE.toggleTool(e.id),children:[(0,L.jsx)(AT,{className:`tool-icon-glyph`,glyph:MT(e)}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${QT(i[e.id])}`,children:$T(i[e.id])}),(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>void s(e.id),children:`✕`})]},e.id))]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,L.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>EE.openSettings(),children:`⚙ 工具设置`}),a&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function PO({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=TE(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(),j=(0,u.useRef)(null),M=(0,u.useRef)(null),[N,ee]=(0,u.useState)(),[P,te]=(0,u.useState)(),ne=(0,u.useRef)(null),[re,F]=(0,u.useState)(()=>{let e=gE();return!e||typeof window>`u`?e:vE(e,window.innerWidth,window.innerHeight)}),ie=async()=>{let e=await vd(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
|
|
342
342
|
|
|
343
343
|
工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
|
|
344
344
|
|
|
345
|
-
如需本地计算,声明 script: { path, timeoutMs, parameters }。脚本必须是 Python,参数以 JSON 从 stdin 传入,stdout 必须只输出一个 JSON 对象。在 index.html 中加载 <script src="./super-pi-tool.js"><\/script>,然后调用 SuperPiTool.run(params)、SuperPiTool.get(runId)、SuperPiTool.wait(runId) 或 SuperPiTool.cancel(runId)。这些都是已绑定本工具身份的相对接口;不要调用 /api/exec,不要猜测 toolId,也不要传 shell 命令、任意文件路径或未声明参数。页面必须实际执行一次示例任务并显示运行状态、日志和结构化结果。第三方包写进 environment.requires(必须钉死成 pkg==version),首次运行时会装进这个工具自己的虚拟环境。需要模型能力(摘要、改写、抽取、分类)时调用 SuperPiTool.llm({ prompt, system }),不要自己写模型客户端或保管密钥,并在注册时声明 permissions: { llm: true }——否则服务端会拒绝,导入页面也会提示用户。最后返回注册 id、访问地址、文件清单和验证结果。`);f(e),window.setTimeout(()=>f(!1),1800)};(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let ae=(0,u.useMemo)(()=>[...t.map(e=>({id:e.id,name:e.name,glyph:e.glyph})),...n.map(e=>({id:e.id,name:e.name,glyph:MT(e)}))],[t,n]);(0,u.useEffect)(()=>{if(!N)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ee(void 0);return}if(YT(e.key)||iE(e.target))return;e.preventDefault(),e.stopPropagation();let t=N;if(ee(void 0),e.key===`Delete`||e.key===`Backspace`){EE.clearShortcut(t).then(e=>te(e));return}let n=XT(e);if(!n){te(`没有认出这个按键,换一个试试。`);return}let i=nE(n);if(!i.ok){te(i.reason);return}let a=cE(r,n,t);if(a){let e=ae.find(e=>e.id===a)?.name;te(e?`这个组合键已经被「${e}」占用了,换一个键。`:`这个组合键已经被另一个工具占用了,换一个键。`)}else EE.setShortcut(t,n).then(e=>te(e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[N,r,ae]);let oe=e=>{F(vE(e,window.innerWidth,window.innerHeight))},se=e=>{_E(e)},ce=()=>{F(void 0),_E(void 0)},le=(0,u.useRef)(!1),ue=n.map(e=>e.slug).filter(e=>typeof e==`string`),de=e=>{m(void 0),g(void 0),A(void 0),O({tool:e,name:IE({slug:e.slug??`tool`})})},fe=async(e,t)=>{m(void 0),g(void 0),A(void 0);let n=LE(t);if(!n.ok)A(n.reason);else try{let t=await ke(`/api/tools/export?id=${encodeURIComponent(e.id)}`),r=await t.json();if(!t.ok||!r.bundle)throw Error(r.error??`HTTP ${t.status}`);let i=new Blob([JSON.stringify(r.bundle,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n.name,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),g(r.skipped?.length?`已导出「${e.name}」,但有 ${r.skipped.length} 个文件没有包含:${r.skipped.join(`、`)}。`:`已导出「${e.name}」。`)}catch(e){m(`导出失败:${Ht(e)}`)}finally{O(void 0)}},pe=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;m(void 0),g(void 0),S(void 0);let n=NE(await t.text(),t.name);n.ok?(v({filename:t.name,bundle:n.bundle,unnamedFormat:n.unnamedFormat}),b(ue.includes(n.bundle.slug)?FE(n.bundle.slug,ue):n.bundle.slug),w(n.bundle.files[0]?.path)):m(n.reason)},me=()=>{v(void 0),b(``),S(void 0),w(void 0)},I=async()=>{if(!_)return;S(void 0);let e=PE(y);if(!e.ok)S(e.reason);else if(ue.includes(e.slug))S(`本机已经有 slug「${e.slug}」的工具,换一个名字再导入。`);else{E(!0);try{let t=await ke(`/api/tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(HE(_.bundle,e.slug))}),n=await t.json();if(!t.ok||!n.id)throw Error(n.error??`HTTP ${t.status}`);await DE(),g(`已导入「${_.bundle.name}」,它现在出现在工具栏里,所有工作区都能用。`),me()}catch(e){m(`导入失败:${Ht(e)}`)}finally{E(!1)}}};(0,u.useEffect)(()=>{D&&M.current?.scrollIntoView({block:`center`})},[D]);let he=()=>{let e=sr(i);e.ok?t.length>=32?l(`工具最多 32 个,先删掉一个再加。`):(EE.setTools([...t,{id:dr(`link`,t.map(e=>e.id)),kind:`link`,name:o.trim()||zO(e.url),glyph:`↗`,url:e.url}]),a(``),s(``),l(void 0)):l(e.reason)},ge=re?{width:`${re.width}px`,height:`${re.height}px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 32px)`}:void 0;return(0,Ct.createPortal)((0,L.jsxs)(`div`,{className:`tool-overlay`,"data-tool-settings-overlay":`1`,onPointerDown:()=>{le.current=!1},onClick:t=>{le.current?le.current=!1:t.target===t.currentTarget&&e()},children:[(0,L.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-settings-title`,"data-tool-settings":`1`,ref:ne,style:ge,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsx)(`h2`,{className:`tool-dialog-title`,id:`tool-settings-title`,children:`⚙ 工具设置`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-settings-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭工具设置`,onClick:e,children:`✕`})]}),(0,L.jsx)(`div`,{className:`tool-dialog-body`,children:_?(0,L.jsx)(RO,{pending:_,slugDraft:y,slugError:x,preview:C,busy:T,onSlugChange:e=>{b(e),S(void 0)},onPreviewChange:w,onCancel:me,onConfirm:()=>void I()}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`tool-prompt-card`,children:[(0,L.jsx)(`strong`,{children:`直接描述你要的工具`}),(0,L.jsx)(`p`,{className:`tool-hint`,children:`告诉 Super Pi Agent 你要创建什么,它会使用内置开发技能和 tool_register 完成注册。复制提示词仅作为备用入口。`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-development-prompt":`1`,onClick:()=>void ie(),children:d?`已复制`:`复制备用提示词`})]}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`从预置列表添加`})}),(0,L.jsx)(`div`,{className:`tool-presets`,"data-tool-presets":tr.length,children:tr.map(e=>{let n=t.some(t=>t.kind===e.kind);return(0,L.jsxs)(`div`,{className:`tool-preset`,"data-tool-preset":e.kind,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.blurb})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-add-preset":e.kind,disabled:n,title:n?`${e.name}已经在工具栏里了`:`添加${e.name}`,"aria-label":n?`${e.name}已添加`:`添加${e.name}`,onClick:()=>EE.setTools(fr(t,e.kind)),children:n?`已添加`:`添加`})]},e.kind)})}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`添加网址工具`})}),(0,L.jsx)(`p`,{className:`tool-hint`,children:`填一个网址,它会变成一个图标;点开后在弹窗里用按钮在新标签页打开。网址只接受 http / https / mailto。`}),(0,L.jsx)(`input`,{className:`tool-input`,"data-tool-url-input":`1`,value:i,maxLength:2048,placeholder:`https://example.com/工具`,"aria-label":`工具网址`,onChange:e=>{a(e.target.value),l(void 0)}}),(0,L.jsx)(`input`,{className:`tool-input`,"data-tool-url-name":`1`,value:o,maxLength:40,placeholder:`名称(可留空,默认用域名)`,"aria-label":`工具名称(可选)`,onChange:e=>s(e.target.value)}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-url-add":`1`,disabled:!i.trim(),onClick:he,children:`添加网址工具`}),c&&(0,L.jsx)(`p`,{className:`tool-error`,"data-tool-error":`1`,role:`alert`,children:c}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-scope-note":`1`,children:[`能自定义到哪:从上面挑预置工具,或自己填一个网址。`,(0,L.jsx)(`b`,{children:`没有开放「写一段脚本来执行」这一档`}),`——它在浏览器里等同于任意代码执行,会拿着本应用的权限跑。计算器是手写的算术解析器,不含 eval,也认不出变量名。`]}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`快捷键`})}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-shortcut-hint":`1`,children:[`给每个工具绑一个组合键,按下就直接打开它,不用先找到右侧栏。`,(0,L.jsx)(`b`,{children:`弹窗打开时快捷键不生效`}),`——模态弹窗期间键盘归它自己,关掉之后再按。`]}),(0,L.jsx)(`div`,{className:`tool-shortcuts`,"data-tool-shortcut-count":ae.length,children:ae.map(e=>(0,L.jsxs)(`div`,{className:`tool-shortcut-row`,"data-tool-shortcut-row":e.id,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:r[e.id]?`按 ${QT(r[e.id])} 打开`:`还没有快捷键`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-shortcut-set`,"data-tool-shortcut-set":e.id,"data-tool-shortcut-capturing":N===e.id?`1`:void 0,"aria-pressed":N===e.id,title:N===e.id?`按下想用的组合键(Esc 取消,Delete 清除)`:`点一下,然后按下想用的组合键`,onClick:()=>{te(void 0),ee(N===e.id?void 0:e.id)},children:N===e.id?`按下组合键…`:r[e.id]?QT(r[e.id]):`未设置`}),r[e.id]&&(0,L.jsx)(`button`,{type:`button`,className:`tool-shortcut-clear`,"data-tool-shortcut-clear":e.id,title:`清除${e.name}的快捷键`,"aria-label":`清除${e.name}的快捷键`,onClick:()=>{EE.clearShortcut(e.id),te(void 0),ee(void 0)},children:`清除`})]},e.id))}),P&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-shortcut-error":`1`,children:P}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsxs)(`h2`,{className:`rail-section-title`,children:[`已安装的全局工具(`,n.length,`)`]})}),n.length===0?(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-mounted-empty":`1`,children:`还没有注册全局工具。直接告诉 Agent 你想做什么即可开始。`}):(0,L.jsx)(`div`,{className:`tool-presets`,"data-tool-mounted-list":n.length,children:n.map(e=>{let t=BE(e.environmentState);return(0,L.jsxs)(`div`,{className:`tool-share-row`,"data-tool-share-row":e.id,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:MT(e)}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{"data-tool-env":e.environmentState?.state??`unknown`,children:t?`${t.warn?`⚠ `:``}${t.text}${e.environmentState?.detail?` · ${e.environmentState.detail}`:``}`:`环境未知`}),e.permissions?.llm&&(0,L.jsx)(`small`,{"data-tool-model":`1`,children:`⚠ 会调用模型`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export":e.id,title:`导出${e.name},得到一个可以发给别人导入的文件`,"aria-label":`导出${e.name}`,onClick:()=>de(e),children:`导出`})]},e.id)})}),D&&(0,L.jsxs)(`div`,{className:`tool-share-review`,ref:M,"data-tool-export-name":`1`,children:[(0,L.jsxs)(`h3`,{className:`tool-share-title`,children:[`导出「`,D.tool.name,`」`]}),(0,L.jsxs)(`label`,{className:`tool-hint`,children:[`文件名(发给别人的就是这个文件)`,(0,L.jsx)(`input`,{className:`tool-input`,value:D.name,"aria-label":`导出文件名`,"data-tool-export-input":`1`,onChange:e=>O({...D,name:e.target.value})})]}),k&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-export-name-error":`1`,children:k}),(0,L.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export-cancel":`1`,onClick:()=>{O(void 0),A(void 0)},children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-export-confirm":`1`,onClick:()=>void fe(D.tool,D.name),children:`导出`})]})]}),h&&(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-share-notice":`1`,children:h}),p&&(0,L.jsx)(`p`,{className:`tool-error`,"data-tool-share-error":`1`,role:`alert`,children:p}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`从文件导入`})}),(0,L.jsxs)(`p`,{className:`tool-hint`,children:[`收到别人分享的工具文件(`,(0,L.jsx)(`code`,{children:kE}),`)?导入后它出现在工具栏里,所有工作区都能用。`,(0,L.jsx)(`b`,{children:`导入前会先给你看这个包里有什么。`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-pick":`1`,onClick:()=>j.current?.click(),children:`选择文件…`}),(0,L.jsx)(`input`,{ref:j,type:`file`,accept:`.json,application/json`,style:{display:`none`},"data-tool-import-input":`1`,onChange:e=>void pe(e)})]})})]}),(0,L.jsx)(IO,{targetRef:ne,onResize:oe,onCommit:se,onDragEnd:()=>{le.current=!0},onReset:ce})]}),document.body)}var FO=18;function IO({targetRef:e,onResize:t,onCommit:n,onDragEnd:r,onReset:i}){let[a,o]=(0,u.useState)(),s=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{let e=t.getBoundingClientRect();o({left:e.right-FO,top:e.bottom-FO})};n();let r=new ResizeObserver(n);return r.observe(t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{r.disconnect(),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[e]),(0,L.jsx)(`div`,{className:`tool-dialog-grip`,"data-tool-settings-grip":`1`,role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":`调整工具设置弹窗大小:拖动或用方向键,Enter 恢复默认尺寸`,style:a?{left:`${a.left}px`,top:`${a.top}px`}:void 0,onPointerDown:i=>{i.preventDefault(),i.stopPropagation();let a=e.current;if(!a)return;let o=a.getBoundingClientRect(),c=o.left+o.width/2,l=o.top+o.height/2;s.current=void 0;let u=e=>{let n=vE({width:2*(e.clientX-c),height:2*(e.clientY-l)},window.innerWidth,window.innerHeight);s.current=n,t(n)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),s.current&&(n(s.current),r())};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},onDoubleClick:()=>i(),onKeyDown:r=>{if(r.key===`Enter`||r.key===` `){r.preventDefault(),i();return}let a=r.shiftKey?8:24,o=e.current?.getBoundingClientRect(),c=o?.width??uE.width,l=o?.height??uE.height;if(r.key===`ArrowRight`)c+=a;else if(r.key===`ArrowLeft`)c-=a;else if(r.key===`ArrowDown`)l+=a;else if(r.key===`ArrowUp`)l-=a;else return;r.preventDefault();let u=vE({width:c,height:l},window.innerWidth,window.innerHeight);s.current=u,t(u),n(u)},onClick:e=>e.stopPropagation()})}function LO(){let{tools:e,mountedTools:t,openToolId:n,settingsOpen:r,shortcuts:i}=TE(),a=e.find(e=>e.id===n),o=t.find(e=>e.id===n);return(0,u.useEffect)(()=>{let n=n=>{if(!r&&!document.querySelector(`[aria-modal="true"]`)&&!(n.isComposing||n.defaultPrevented)){for(let[r,a]of Object.entries(i))if(aE(a,n)&&(e.some(e=>e.id===r)||t.some(e=>e.id===r))){n.preventDefault(),EE.openTool(r);return}}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[i,e,t,r]),(0,u.useEffect)(()=>{DE();let e=()=>{DE()};return window.addEventListener(`super-pi-tools-updated`,e),window.addEventListener(`super-pi-active-server`,e),()=>{window.removeEventListener(`super-pi-tools-updated`,e),window.removeEventListener(`super-pi-active-server`,e)}},[]),(0,u.useEffect)(()=>{EE.persistTools()},[]),(0,L.jsxs)(L.Fragment,{children:[r&&(0,L.jsx)(PO,{onClose:()=>EE.closeSettings()}),a&&(0,L.jsx)(BO,{tool:a,onClose:()=>EE.closeTool()}),o&&(0,L.jsx)(JO,{tool:o,onClose:()=>EE.closeTool()})]})}function RO({pending:e,slugDraft:t,slugError:n,preview:r,busy:i,onSlugChange:a,onPreviewChange:o,onCancel:s,onConfirm:c}){let l=e.bundle,u=l.files.reduce((e,t)=>e+new TextEncoder().encode(t.content).length,0),d=zE(l),f=RE(l),p=l.files.find(e=>e.path===r)??l.files[0];return(0,L.jsxs)(`div`,{className:`tool-share-review`,"data-tool-import-review":`1`,children:[(0,L.jsx)(`h3`,{className:`tool-share-title`,"data-tool-import-name":`1`,children:l.name}),l.description&&(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-import-desc":`1`,children:l.description}),e.unnamedFormat&&(0,L.jsx)(`p`,{className:`tool-import-note`,"data-tool-import-unbranded":`1`,children:`这个文件没有 Super Pi 的工具标记,已按内容形状读取——粘出来的 tool_register 参数也认。`}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-import-files":`1`,children:[l.files.length,` 个文件 · 共 `,VE(u)]}),(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-import-paths":`1`,children:l.files.map(e=>e.path).join(` · `)}),l.script&&(0,L.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-script":l.script.path,children:[(0,L.jsxs)(`b`,{children:[`⚠ 含 Python 脚本 `,l.script.path]}),(0,L.jsx)(`br`,{}),`导入后运行这个工具时,这段代码会在本机上执行,权限和你自己的 Python 一样(能读你的文件、能联网)。 可以先展开下面的文件列表把它读完。`]}),(0,L.jsxs)(`p`,{className:d.tone===`warn`?`tool-import-warn`:`tool-import-note`,"data-tool-import-env":d.tone,children:[(0,L.jsxs)(`b`,{children:[d.tone===`warn`?`⚠ `:`✓ `,d.text]}),l.environment?.fingerprint?.python&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`br`,{}),`导出方环境:Python `,l.environment.fingerprint.python,` · `,l.environment.fingerprint.platform||`未知平台`,`。版本对不上时会标出来,但不会拦住你运行。`]})]}),f&&(0,L.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-model":`1`,children:[(0,L.jsx)(`b`,{children:`⚠ 这个工具可以调用模型`}),(0,L.jsx)(`br`,{}),f.text,`。模型由 Super Pi 通过 Pi 调用(凭据和模型选择都在 Super Pi 这边),工具只拿到文字。`]}),(0,L.jsxs)(`details`,{className:`tool-import-files`,"data-tool-import-filebox":l.files.length,children:[(0,L.jsxs)(`summary`,{children:[`查看文件(`,l.files.length,`)`]}),(0,L.jsx)(`div`,{className:`tool-share-tabs`,children:l.files.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`tool-share-tab`,"aria-pressed":e.path===p?.path,"data-tool-import-file":e.path,onClick:()=>o(e.path),children:e.path},e.path))}),(0,L.jsx)(`pre`,{className:`tool-import-code`,"data-tool-import-code":p?.path,children:p?.content??``})]}),(0,L.jsxs)(`label`,{className:`tool-hint`,"data-tool-import-slug":`1`,children:[`导入后的 slug(工具的短名字,也是它在磁盘上的目录名)`,(0,L.jsx)(`input`,{className:`tool-input`,value:t,"aria-label":`导入后的 slug`,onChange:e=>a(e.target.value)})]}),n&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-import-slug-error":`1`,children:n}),(0,L.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-import-cancel":`1`,onClick:s,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-confirm":`1`,disabled:i,onClick:c,children:i?`导入中…`:`导入`})]})]})}function zO(e){let t=e.replace(/^[./]+/,``).slice(0,30).trim();if(!/^[a-z][a-z0-9+.-]*:/i.test(e))return t||e.slice(0,30);try{return new URL(e,typeof window>`u`?`http://localhost`:window.location.href).hostname||t||e.slice(0,30)}catch{return e.slice(0,30)}}function BO({tool:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`tool-overlay`,"data-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-dialog-title`,"data-tool-dialog":e.id,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsxs)(`h2`,{className:`tool-dialog-title`,id:`tool-dialog-title`,children:[(0,L.jsx)(AT,{className:`tool-dialog-glyph`,glyph:e.glyph}),e.name]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭${e.name}`,onClick:t,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`tool-dialog-body`,children:[e.kind===`calculator`&&(0,L.jsx)(HO,{}),e.kind===`timestamp`&&(0,L.jsx)(UO,{}),e.kind===`link`&&(0,L.jsx)(WO,{tool:e})]})]})}),document.body)}function VO({image:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`lightbox-overlay`,"data-lightbox-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`lightbox-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`lightbox-title`,"data-lightbox-dialog":`1`,children:[(0,L.jsxs)(`div`,{className:`lightbox-head`,children:[(0,L.jsx)(`h2`,{className:`lightbox-title`,id:`lightbox-title`,children:e.name||`图片大图`}),(0,L.jsx)(`button`,{type:`button`,className:`lightbox-close`,"data-lightbox-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭大图`,onClick:t,children:`✕`})]}),(0,L.jsx)(`div`,{className:`lightbox-body`,children:(0,L.jsx)(`img`,{src:e.url,alt:e.name||`图片大图`,className:`lightbox-image`})})]})}),document.body)}function HO(){let[e,t]=(0,u.useState)(`12 * (3 + 4)`),n=Er(e),r=e=>{t(t=>t+e)};return(0,L.jsxs)(`div`,{className:`tool-calc`,"data-tool-calc":`1`,children:[(0,L.jsx)(`input`,{className:`tool-input tool-calc-input`,"data-calc-input":`1`,value:e,maxLength:200,"aria-label":`算式`,spellCheck:!1,autoComplete:`off`,placeholder:`例如 (12 + 8) / 4`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()}}),(0,L.jsx)(`div`,{className:`tool-calc-keys`,"data-calc-keys":`1`,children:[[`7`,`7`],[`8`,`8`],[`9`,`9`],[`÷`,`/`],[`(`,`(`],[`)`,`)`],[`4`,`4`],[`5`,`5`],[`6`,`6`],[`×`,`*`],[`^`,`^`],[`%`,`%`],[`1`,`1`],[`2`,`2`],[`3`,`3`],[`-`,`-`],[`←`,`back`],[`C`,`clear`],[`0`,`0`],[`.`,`.`],[`+`,`+`]].map(([e,n])=>(0,L.jsx)(`button`,{type:`button`,className:`tool-calc-key`,"data-calc-key":n,"aria-label":e===`C`?`清空`:e===`←`?`退格`:`输入 ${e}`,onClick:()=>{n===`clear`?t(``):n===`back`?t(e=>e.slice(0,-1)):r(n)},children:e},e))}),n.ok?(0,L.jsx)(`p`,{className:`tool-calc-result`,"data-calc-result":`1`,"data-calc-value":String(n.value),children:Dr(n.value)}):(0,L.jsx)(`p`,{className:`tool-calc-error`,"data-calc-error":`1`,role:`alert`,children:n.reason})]})}function UO(){let[e,t]=(0,u.useState)(``),n=Or(e),r=n.ok?Ar(n.ms):null;return(0,L.jsxs)(`div`,{className:`tool-stamp`,"data-tool-stamp":`1`,children:[(0,L.jsx)(`input`,{className:`tool-input`,"data-stamp-input":`1`,value:e,maxLength:64,spellCheck:!1,"aria-label":`时间戳或日期`,placeholder:`1757000000 或 2026-10-08T09:00:00`,onChange:e=>t(e.target.value)}),r?(0,L.jsxs)(`dl`,{className:`tool-stamp-out`,"data-stamp-result":`1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`本地时间`}),(0,L.jsx)(`dd`,{"data-stamp-local":`1`,children:r.local})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`ISO(UTC)`}),(0,L.jsx)(`dd`,{"data-stamp-iso":`1`,children:r.iso})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`秒`}),(0,L.jsx)(`dd`,{"data-stamp-seconds":`1`,children:r.seconds})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`毫秒`}),(0,L.jsx)(`dd`,{"data-stamp-ms":`1`,children:r.milliseconds})]})]}):(0,L.jsx)(`p`,{className:`tool-stamp-error`,"data-stamp-error":`1`,role:`alert`,children:n.ok?`这个日期无法显示。`:n.reason})]})}function WO({tool:e}){let[t,n]=(0,u.useState)(!1),r=async()=>{let e=await vd(`请为 Super Pi 开发一个全局右侧栏工具并自动挂载。不要启动独立 HTTP 服务器。通过内置 tool_register 提交完整的 HTML/JS/CSS 文件;工具将被 Super Pi 保存并在所有 workspace 可用。如需计算,注册一个 Python 脚本(不接受 shell 命令),参数经 JSON stdin 传入,stdout 只输出 JSON 结果。在页面里加载 ./super-pi-tool.js,使用 SuperPiTool.run(params)、wait(runId)、get(runId) 和 cancel(runId) 执行、等待、查看和取消任务。它们会自动绑定当前工具;不要调用 /api/exec,也不要猜测 toolId。`);n(e),window.setTimeout(()=>n(!1),1800)};return(0,L.jsxs)(`div`,{className:`tool-link`,"data-tool-link":e.id,children:[(0,L.jsx)(`p`,{className:`tool-hint`,children:`这是旧版外部网页链接;新工具由 Super Pi 统一托管,并可选绑定受控 Python 脚本。`}),(0,L.jsx)(`code`,{className:`tool-link-url`,"data-tool-link-url":e.id,children:e.url}),(0,L.jsxs)(`div`,{className:`tool-link-actions`,children:[(0,L.jsx)(`a`,{className:`tool-link-open`,"data-tool-link-open":e.id,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:e.url,children:`在新标签页打开 ↗`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-copy-prompt":e.id,onClick:()=>void r(),children:t?`已复制`:`复制开发 Prompt`})]}),/^https?:\/\//i.test(e.url??``)&&(0,L.jsx)(`iframe`,{className:`tool-link-frame`,"data-tool-frame":e.id,src:e.url,title:e.name,sandbox:`allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,referrerPolicy:`no-referrer`})]})}var GO=`(max-width: 1100px)`,KO=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function qO(e){let t=`super-pi.mounted-tool.owner.`+e;try{let e=window.localStorage.getItem(t);if(e&&/^[0-9a-f]{32}$/.test(e))return e}catch{}let n=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(t,n)}catch{}return n}function JO({tool:e,onClose:t}){let n=(0,u.useRef)(null);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,u.useMemo)(()=>qO(e.id),[e.id]);(0,u.useLayoutEffect)(()=>Ke(()=>n.current,e.id,r),[e.id,r]);let i=e.dialogSize??{width:1100,height:780},a={width:`min(${i.width}px, calc(100vw - 32px))`,height:`min(${i.height}px, calc(100dvh - 32px))`};return(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`tool-overlay`,"data-mounted-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`tool-dialog mounted-tool-dialog`,style:a,"data-mounted-tool-dialog":e.id,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsxs)(`h2`,{className:`tool-dialog-title`,children:[(0,L.jsx)(AT,{className:`tool-dialog-glyph`,glyph:MT(e)}),e.name]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,onClick:t,children:`✕`})]}),(0,L.jsx)(`div`,{className:`tool-dialog-body`,children:(0,L.jsx)(`iframe`,{ref:n,className:`tool-link-frame`,src:Oe(`/tools/${encodeURIComponent(e.id)}/#super-pi-owner=${r}`),title:e.name,sandbox:`allow-forms allow-modals allow-popups allow-scripts`,referrerPolicy:`no-referrer`})})]})}),document.body)}function YO(e,t,n){let r=Math.max(0,Math.round(n)-480),i=KO(520,180,Math.max(180,r-240)),a=KO(Math.round(e),180,i),o=KO(640,240,Math.max(240,r-a));return{sidebar:a,rail:KO(Math.round(t),240,o),sidebarMin:180,sidebarMax:i,railMin:240,railMax:o,sumCap:r}}var XO=`super-pi.rail-widths.v1`,ZO=`super-pi.reader-state.v1`,QO=`super-pi.folded-groups.v1`;function $O(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.folded-groups.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t=e=>{let t={};if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t};return{workspaces:t(e.workspaces),archived:t(e.archived)}}catch{return{}}}function ek(e){try{typeof window<`u`&&window.localStorage.setItem(QO,JSON.stringify(e))}catch{}}var tk=e=>{let t=document.querySelector(`[data-workspace-group="${CSS.escape(e)}"]`);return t?[...t.querySelectorAll(`.conversation-row[data-session-root]`)].map(e=>({id:e.dataset.sessionRoot??``,middle:(()=>{let t=e.getBoundingClientRect();return t.top+t.height/2})()})).filter(e=>e.id!==``):[]},nk=6,rk=400,ik=32,ak=48,ok=e=>{e.dataset.programmaticScroll=`true`,window.setTimeout(()=>{delete e.dataset.programmaticScroll},0)};function sk(e,t,n=!1,r=!1){let i=e.scrollHeight-e.clientHeight-e.scrollTop,a=n?!1:r?!0:t.followTail?i<=ak:i<=ik,o,s;if(!a){let t=e.getBoundingClientRect().top,n=[...e.querySelectorAll(`[data-transcript-key]`)].find(e=>e.getBoundingClientRect().bottom>t);o=n?.dataset.transcriptKey,s=n?n.getBoundingClientRect().top-t:void 0}return{followTail:a,scrollTop:e.scrollTop,...o?{anchorKey:o,anchorOffset:s}:{}}}function ck(){try{if(typeof window>`u`)return{conversations:{}};let e=JSON.parse(window.localStorage.getItem(`super-pi.reader-state.v1`)??`null`);if(!e||typeof e!=`object`)return{conversations:{}};let t={};if(e.conversations&&typeof e.conversations==`object`)for(let[n,r]of Object.entries(e.conversations)){let e=r;typeof e.followTail==`boolean`&&(t[n]={followTail:e.followTail,scrollTop:Number.isFinite(e.scrollTop)?Math.max(0,Number(e.scrollTop)):0,...typeof e.anchorKey==`string`?{anchorKey:e.anchorKey}:{},...Number.isFinite(e.anchorOffset)?{anchorOffset:Number(e.anchorOffset)}:{}})}let n={};if(e.readAt&&typeof e.readAt==`object`)for(let[t,r]of Object.entries(e.readAt))typeof r==`string`&&(n[t]=r);return{activeId:typeof e.activeId==`string`?e.activeId:void 0,workspaceId:typeof e.workspaceId==`string`?e.workspaceId:void 0,conversations:t,readAt:n}}catch{return{conversations:{}}}}function lk(e){try{typeof window<`u`&&window.localStorage.setItem(ZO,JSON.stringify(e))}catch{}}var uk=`super-pi.session-tabs.v1`;function dk(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function fk(e,t,n){let r=e.touched.has(t),i=e.touched;if(r){let r=new Set(e.touched);r.delete(t),n&&r.add(n),i=r}return{ids:e.ids.flatMap(e=>e===t?n?[n]:[]:[e]),previewId:e.previewId===t?n&&!r?n:void 0:e.previewId,emptied:e.emptied,touched:i}}function pk(){try{if(typeof window>`u`)return{ids:[]};let e=JSON.parse(qe(`super-pi.session-tabs.v1`)??`null`);if(!e||typeof e!=`object`)return{ids:[]};let t=e,n=Array.isArray(t.ids)?[...new Set(t.ids.filter(e=>typeof e==`string`))]:[],r=Array.isArray(t.touched)?[...new Set(t.touched.filter(e=>typeof e==`string`))]:[],i=typeof t.previewId==`string`&&n.includes(t.previewId)&&!r.includes(t.previewId)?t.previewId:void 0;i&&i!==t.activeId&&(n=n.filter(e=>e!==i));let a=typeof t.activeId==`string`&&n.includes(t.activeId)?t.activeId:void 0,o=typeof t.workspaceLandingId==`string`?t.workspaceLandingId:void 0;return{ids:n,activeId:a,workspaceLandingId:o,previewId:i===a?i:void 0,touched:r,emptied:n.length===0&&(t.emptied===!0||!!i),selectionCleared:t.selectionCleared===!0}}catch{return{ids:[]}}}function mk(e,t,n,r=!1){try{if(typeof window>`u`)return;let{ids:i,previewId:a,touched:o,emptied:s}=e;Je(uk,JSON.stringify({ids:i,...t&&i.includes(t)?{activeId:t}:{},...n?{workspaceLandingId:n}:{},...a&&i.includes(a)?{previewId:a}:{},...o.size?{touched:[...o]}:{},...s?{emptied:s}:{},...r?{selectionCleared:!0}:{}}))}catch{}}function hk(){try{if(typeof window>`u`)return{};let e=window.localStorage.getItem(XO);if(e===null)return{};let t=JSON.parse(e),n=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?Math.round(e):void 0;return{sidebar:n(t.sidebar),rail:n(t.rail)}}catch{return{}}}function gk(e){try{if(typeof window>`u`)return;window.localStorage.setItem(XO,JSON.stringify(e))}catch{}}function _k({side:e,width:t,min:n,max:r,label:i,onWidth:a}){let[o,s]=(0,u.useState)(!1),c=e=>e.shiftKey?64:16;return(0,L.jsx)(`div`,{className:`rail-resizer rail-resizer-${e}${o?` rail-resizer-dragging`:``}`,"data-rail-resizer":e,"data-rail-resizer-dragging":o?`true`:`false`,"data-rail-resizer-width":t,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,"aria-valuenow":t,"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,onMouseDown:i=>{i.preventDefault(),i.currentTarget.focus();let o=i.clientX,c=t;s(!0);let l=document.body,u=l.style.cursor,d=l.style.userSelect;l.style.cursor=`col-resize`,l.style.userSelect=`none`;let f=t=>{let i=e===`left`?t.clientX-o:o-t.clientX;a(KO(c+i,n,r))},p=()=>{l.style.cursor=u,l.style.userSelect=d,s(!1),window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,p)};window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,p)},onKeyDown:i=>{let o=c(i);i.key===`ArrowLeft`?(i.preventDefault(),a(KO(e===`left`?t-o:t+o,n,r))):i.key===`ArrowRight`?(i.preventDefault(),a(KO(e===`left`?t+o:t-o,n,r))):i.key===`Home`?(i.preventDefault(),a(n)):i.key===`End`&&(i.preventDefault(),a(r))}})}var vk=`super-pi.composer-height.v1`,yk=148,bk=.55,xk=()=>Math.max(yk,Math.round((typeof window>`u`?800:window.innerHeight)*bk)),Sk=e=>{let t=Number.isFinite(e)?e:yk;return Math.round(Math.min(xk(),Math.max(yk,t)))},Ck=()=>{try{let e=window.localStorage.getItem(vk);return e===null?yk:Sk(Number(e))}catch{return yk}};function wk({height:e,onHeight:t}){let[n,r]=(0,u.useState)(!1),i=e=>e.shiftKey?64:16,a=xk();return(0,L.jsx)(`div`,{className:`composer-resize${n?` composer-resize-dragging`:``}`,"data-composer-resize":`1`,"data-composer-resize-dragging":n?`true`:`false`,"data-composer-height":e,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整消息编辑区高度`,"aria-valuenow":e,"aria-valuemin":yk,"aria-valuemax":a,tabIndex:0,onMouseDown:n=>{n.preventDefault(),n.currentTarget.focus();let i=n.clientY,a=e;r(!0);let o=document.documentElement,s=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let c=e=>{let t=Sk(a+(i-e.clientY));o.style.setProperty(`--composer-height`,`${t}px`)},l=()=>{document.body.style.cursor=``,document.body.style.userSelect=s;let n=Number.parseFloat(o.style.getPropertyValue(`--composer-height`));r(!1),window.removeEventListener(`mousemove`,c),window.removeEventListener(`mouseup`,l),t(Number.isFinite(n)?n:e)};window.addEventListener(`mousemove`,c),window.addEventListener(`mouseup`,l)},onKeyDown:n=>{let r=i(n);n.key===`ArrowUp`?(n.preventDefault(),t(Sk(e+r))):n.key===`ArrowDown`?(n.preventDefault(),t(Sk(e-r))):n.key===`Home`?(n.preventDefault(),t(yk)):n.key===`End`?(n.preventDefault(),t(a)):n.key===`PageUp`?(n.preventDefault(),t(Sk(e+96))):n.key===`PageDown`&&(n.preventDefault(),t(Sk(e-96)))}})}function Tk(e,t,n){if(!e.length)return;let r=n?e.find(e=>e.workspaceId===n):void 0;if(r)return r;if(!(n&&t.some(e=>e.id===n)))return n?e.find(e=>h(e.workspaceId).server===h(n).server):e[0]}function Ek(e,t,n){let r=n&&e?JSON.stringify([e,t,n]):void 0,[i,a]=(0,u.useState)();(0,u.useEffect)(()=>{if(!r||!n||!e)return;let i=new AbortController;return ke(`/api/files/diff?${new URLSearchParams({workspaceId:e,path:n,...t?{cwd:t}:{}})}`,{signal:i.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{i.signal.aborted||a({scope:r,diff:e,error:``})}).catch(e=>{i.signal.aborted||a({scope:r,diff:null,error:e instanceof Error?e.message:`读取差异失败`})}),()=>i.abort()},[r,e,t,n]);let o=i?.scope===r?i:void 0;return{diff:o?.diff??null,error:o?.error??``,loading:!!r&&!o}}function Dk(e){try{let t=`super-pi.browser-notification-events`,n=Date.now(),r=JSON.parse(window.localStorage.getItem(t)??`[]`).filter(e=>Array.isArray(e)&&typeof e[0]==`string`&&typeof e[1]==`number`&&n-e[1]<864e5);return!r.some(([t])=>t===e)&&(window.localStorage.setItem(t,JSON.stringify([...r.slice(-63),[e,n]])),!0)}catch{return!0}}function Ok(){let[e,t]=(0,u.useState)(QE),[n,r]=(0,u.useState)(()=>{try{return typeof window<`u`&&window.localStorage.getItem(`super-pi.browser-notifications`)===`enabled`}catch{return!1}}),[i,a]=(0,u.useState)(()=>Mi()),o=(0,u.useCallback)(()=>a(Mi()),[]),s=(0,u.useRef)(new Map),c=(0,u.useRef)(!1),l=(0,u.useRef)(new Map),d=(0,u.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return Lt(n,t)})},[]),[f,p]=(0,u.useState)(()=>zf().map(e=>{let t=new Date().toISOString();return{id:e.clientId,key:`send:${e.conversationId}:${e.clientId}`,serverId:se(e.conversationId),retry:!0,command:{...e},apply:n=>Uf(n,e,t),accepted:t=>!!t.conversations.find(t=>t.id===e.conversationId)?.messages.some(t=>t.id===Hf(e))}})),m=(0,u.useRef)(f),_=(0,u.useRef)(null);_.current||=ck();let v=(0,u.useRef)(null);v.current||=pk();let y=v.current,b=(0,u.useRef)(null);b.current||=Ye();let x={current:b.current},S=(0,u.useRef)(null);S.current||=Xe();let w=S.current,T=f.reduce((e,t)=>t.apply(e),e),[E,D]=(0,u.useState)(y.workspaceLandingId||y.selectionCleared||y.emptied?void 0:y.activeId??_.current.activeId),[O,k]=(0,u.useState)(y.workspaceLandingId??(y.selectionCleared?x.current.kind===`workspace`?x.current.workspaceId:void 0:_.current.workspaceId)),[A,j]=(0,u.useState)(!1),M=oe(),N=A&&M.statuses.get(M.activeServer)?.state===`online`,[ee,te]=(0,u.useState)(),[ne,re]=(0,u.useState)(()=>$O().workspaces??{}),[F,ie]=(0,u.useState)(()=>({ids:y.ids,previewId:y.previewId,touched:new Set(y.touched??[]),emptied:y.emptied})),ae=F.ids,he=F.previewId,ge=(0,u.useRef)(0),[_e,ve]=(0,u.useState)(),[ye,be]=(0,u.useState)({entries:[],index:-1}),[xe,Se]=(0,u.useState)(),Ce=(0,u.useRef)(new Set),we=F.emptied===!0,[Te,Ee]=(0,u.useState)(!1),[De,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(),Pe=(0,u.useRef)(null),Fe=(0,u.useRef)(void 0),Ie=(0,u.useRef)(_.current.conversations),Le=(0,u.useRef)(ae);Le.current=ae;let Re=(0,u.useRef)(_.current.readAt??{}),[ze,Be]=(0,u.useState)(0),[Ve,Ue]=(0,u.useState)(lt),[We,Ge]=(0,u.useState)(()=>w.groups.length?w.groups:Ve?[Ve]:[]),[Ke,qe]=(0,u.useState)(w.view?w.view===`group`:!!Ve),[et,nt]=(0,u.useState)(()=>w.view??(Ve?`group`:`session`)),{index:rt,reload:it,remember:at,forget:ot,activities:st,recordActivity:ct}=yt(T.workspaces,N),[mt,ht]=(0,u.useState)(()=>new Set),bt=Ve?.workspaceId??``,St=Ve?.roomId??``,Ct=rt[bt]?.rooms.find(e=>e.id===St),wt=Ct?.title;(0,u.useEffect)(()=>{ut(et===`group`?Ve:void 0)},[Ve,et]),(0,u.useEffect)(()=>{et===`group`&&Te&&!T.workspaces.some(e=>e.id===bt&&!e.closedAt)&&(qe(!1),nt(`session`))},[et,Te,T.workspaces,bt]);let Tt=(0,u.useRef)(null),Et=(0,u.useRef)(null),Dt=(0,u.useRef)(void 0),Ot=(0,u.useRef)(!1),kt=(0,u.useRef)(!0),[At,jt]=(0,u.useState)({followTail:!0,scrollTop:0}),Mt=(0,u.useRef)(!1),Nt=(0,u.useRef)(new Map),Pt=(0,u.useRef)(void 0),Ft=(0,u.useRef)([]),It=(0,u.useRef)(void 0),Lt=(0,u.useCallback)((e,t)=>{let n=new Map(t.conversations.map(e=>[e.id,e]));return{...e,conversations:e.conversations.map(e=>{let t=n.get(e.id);if(e.messagesLoaded===!1||!t||t.messagesLoaded===!1||t.status!==`running`)return e;let r=new Map(t.messages.map(e=>[e.id,e]));return{...e,messages:e.messages.map(e=>{let t=r.get(e.id);return!t||!(t.content.length>e.content.length||(t.thinking?.length??0)>(e.thinking?.length??0))?e:{...e,content:t.content,thinking:t.thinking,thinkingActive:t.thinkingActive,thinkingBlocks:iD(t.thinkingBlocks,e.thinkingBlocks)}})}})}},[]),Rt=(0,u.useCallback)(()=>{if(It.current!==void 0&&(cancelAnimationFrame(It.current),It.current=void 0),!Ft.current.length)return;let e=Ft.current;Ft.current=[];let t=new Map;for(let n of e){let e=`${n.conversationId}\u0000${n.messageId}`,r=t.get(e)??[];r.push(n),t.set(e,r)}d(e=>({...e,conversations:e.conversations.map(e=>{let n=e.messages.map(n=>{let r=t.get(`${e.id}\u0000${n.id}`);if(!r)return n;let i={...n};for(let e of r){if(e.type===`message.delta`){i.content+=e.delta;continue}if(i.thinkingActive=e.active,!e.delta)continue;let t=e.at??i.content.length,n=rD(i.thinkingBlocks??[],e,t);i={...i,thinking:(i.thinking??``)+e.delta,thinkingBlocks:n}}return i});return n.every((t,n)=>t===e.messages[n])?e:{...e,messages:n}})}))},[]),zt=(0,u.useCallback)(e=>{let t=Ft.current,n=t.at(-1);n&&n.type===e.type&&n.conversationId===e.conversationId&&n.messageId===e.messageId&&(e.type!==`message.thinking`||n.type===`message.thinking`&&n.at===e.at&&n.active===e.active&&n.blockIndex===e.blockIndex)?t[t.length-1]={...e,delta:n.delta+e.delta}:t.push(e),It.current===void 0&&(It.current=requestAnimationFrame(Rt))},[Rt]),Bt=(0,u.useCallback)(e=>{Pt.current=e},[]),[Vt,Wt]=(0,u.useState)(()=>$O().archived??{});(0,u.useEffect)(()=>{ek({workspaces:ne,archived:Vt})},[ne,Vt]);let[Gt,Kt]=(0,u.useState)(()=>zT());(0,u.useEffect)(()=>{BT(Gt)},[Gt]);let[qt,Jt]=(0,u.useState)(),Yt=(0,u.useRef)(0),Xt=(0,u.useRef)(``),Zt=(e,t,n,r)=>{let i=(e.target instanceof Element?e.target:void 0)?.closest(`button`);if(i&&!i.classList.contains(`conversation`)||e.button!==0)return;let a=e.clientY,o=e.pointerType===`touch`,s=!1,c,l=[],u,d=!1,f=e=>{let t=l.filter(e=>e.id!==n);if(t.length===0){u=void 0,d=!1;return}let r=0;for(;r<t.length&&t[r].middle<e;)r+=1;r<t.length?(u=t[r].id,d=!1):(u=t[t.length-1].id,d=!0)},p=()=>Jt(e=>e&&e.dropRootId===u&&e.dropAfter===d?e:{workspaceId:t,conversationId:n,dropRootId:u,dropAfter:d}),m=()=>{s||(s=!0,l=tk(t),f(a),document.body.style.userSelect=`none`,p())},h=e=>{if(!s){if(o){c!==void 0&&window.clearTimeout(c),c=void 0;return}if(Math.abs(e.clientY-a)<nk)return;m()}f(e.clientY),p()},g=e=>{if(window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,v),document.removeEventListener(`touchmove`,y),c!==void 0&&window.clearTimeout(c),document.body.style.userSelect=``,s&&e){let e=r.filter(e=>e!==n),i=u===void 0?e.length:d?e.indexOf(u)+1:e.indexOf(u);Kt(e=>({...e,[t]:LT(r,n,i)})),Yt.current=Date.now(),Xt.current=n}Jt(void 0)},_=()=>g(!0),v=()=>g(!1),y=e=>{s&&e.preventDefault()};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,v),o&&(document.addEventListener(`touchmove`,y,{passive:!1}),c=window.setTimeout(m,rk))},[Qt,$t]=(0,u.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage.getItem(`super-pi.user-nickname`)??``}catch{return``}}),en=e=>{let t=e.slice(0,24);$t(t);try{window.localStorage.setItem(`super-pi.user-nickname`,t)}catch{}},an=Qt.trim()||`你`,[cn,ln]=(0,u.useState)(),[un,dn]=(0,u.useState)([]),[fn,pn]=(0,u.useState)([]),[mn,hn]=(0,u.useState)(),[gn,_n]=(0,u.useState)(),[yn,bn]=(0,u.useState)([]),[xn,Sn]=(0,u.useState)([]),[Cn,wn]=(0,u.useState)(),[Tn,En]=(0,u.useState)(),[Dn,On]=(0,u.useState)(),[kn,An]=(0,u.useState)(),[jn,Mn]=(0,u.useState)(),Nn=Ei(Dn),Pn=(0,u.useMemo)(()=>un.filter(e=>e.request.blocking),[un]),[Fn,In]=(0,u.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1100px)`).matches),[Ln,Rn]=(0,u.useState)(`chat`),[zn,Bn]=(0,u.useState)(!1),Vn=(0,u.useCallback)(()=>{Rn(`chat`),window.matchMedia(`(max-width: 700px)`).matches&&In(!0)},[]),[Hn,Un]=(0,u.useState)(!1),[Wn,Gn]=(0,u.useState)(x.current.kind),[Kn,qn]=(0,u.useState)(()=>x.current.serverId??localStorage.getItem(`super-pi.server-filter`)??`all`),[Jn,Yn]=(0,u.useState)(x.current.workspaceId??_.current.workspaceId),[Xn,Zn]=(0,u.useState)(x.current.repoId??_.current.workspaceId),[Qn,$n]=(0,u.useState)(y.selectionCleared===!0);(0,u.useEffect)(()=>{try{Je(`super-pi.sidebar-scope.v1`,JSON.stringify({kind:Wn,serverId:Kn,workspaceId:Jn,repoId:Xn}))}catch{}},[Wn,Kn,Jn,Xn]);let er=(0,u.useRef)(Qn);er.current=Qn;let[tr,nr]=(0,u.useState)(()=>typeof window>`u`?1440:window.innerWidth);(0,u.useEffect)(()=>{let e=()=>nr(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let[rr,ir]=(0,u.useState)(nn);(0,u.useEffect)(()=>rn(rr),[rr]);let[ar,or]=(0,u.useState)(hk),sr=YO(ar.sidebar??270,ar.rail??320,tr>1100?tr-80:tr);(0,u.useEffect)(()=>{gk({sidebar:ar.sidebar??270,rail:ar.rail??320})},[ar.sidebar,ar.rail]);let cr=e=>or(t=>({...t,sidebar:e})),lr=e=>or(t=>({...t,rail:e})),[dr,fr]=(0,u.useState)(null);(0,u.useEffect)(()=>{fr(Ck())},[]),(0,u.useEffect)(()=>{dr!==null&&document.documentElement.style.setProperty(`--composer-height`,`${dr}px`)},[dr]);let pr=e=>{let t=Sk(e);fr(t);try{window.localStorage.setItem(vk,String(t))}catch{}};(0,u.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(GO),t=e=>{e.matches&&In(!0)};return e.addEventListener(`change`,t),e.matches&&In(!0),()=>e.removeEventListener(`change`,t)},[]);let mr=tr<=1100;(0,u.useEffect)(()=>{if(!mr||Fn)return;let e=e=>{e.key===`Escape`&&(e.defaultPrevented||document.querySelector(`.tool-overlay, .lightbox-overlay, .quick-open-backdrop, .ctx-menu, .overlay, .picker-menu, .content-search-overlay`)||(e.preventDefault(),In(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[mr,Fn]);let[hr,gr]=(0,u.useState)({}),[_r,vr]=(0,u.useState)({}),[yr,br]=(0,u.useState)({}),[xr,Sr]=(0,u.useState)({}),[Cr,wr]=(0,u.useState)(null),[Tr,Er]=(0,u.useState)(),[Dr,Or]=(0,u.useState)(()=>new Set);(0,u.useEffect)(()=>{Or(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>{let t=T.conversations.find(t=>t.id===e);return t?pO(t):!1}));return t.size===e.size?e:t})},[T.conversations]);let[kr,Ar]=(0,u.useState)(),[jr,Mr]=(0,u.useState)(),Nr=(0,u.useRef)(new Map),[Pr,Fr]=(0,u.useState)(()=>{let e=Wf(`super-pi.composer-drafts.v1`,{});return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,attachments:UD(t.text,t.attachments)}]))}),Ir=(0,u.useRef)(Pr),Lr=(0,u.useRef)(!1);Ir.current=Pr,(0,u.useEffect)(()=>{let e=()=>{let e=Object.entries(Ir.current).filter(([e,t])=>!e.startsWith(`pending:`)&&(t.text||t.images.length||t.attachments.length)).map(([e,{text:t,images:n,attachments:r}])=>[e,{text:t,images:n,attachments:r,uploading:0}]),t=Gf(`super-pi.composer-drafts.v1`,Object.fromEntries(e));!t&&e.length&&!Lr.current&&Ds(`浏览器无法保存聊天草稿,刷新前请先保留这段内容。`,`warning`),Lr.current=!t&&e.length>0},t=window.setTimeout(e,250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[Pr]);let Rr=(0,u.useRef)(new Set),[zr,Br]=(0,u.useState)([]),[Vr,Hr]=(0,u.useState)([]),[Ur,Wr]=(0,u.useState)(),[Gr,Kr]=(0,u.useState)(!1),qr=(0,u.useRef)(null),Jr=(0,u.useRef)(!1),Yr=(0,u.useRef)(0),Xr=(0,u.useRef)([]),Zr=(0,u.useRef)(void 0),Qr=(0,u.useRef)(!1),ei=(0,u.useRef)(new Set),ti=(0,u.useRef)(new Set),ni=(0,u.useRef)(new Map),ri=(0,u.useRef)(new Map),[ii,ai]=(0,u.useState)(()=>Date.now());(0,u.useEffect)(()=>{let e=window.setInterval(()=>ai(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let oi=(0,u.useMemo)(()=>T.conversations.filter(e=>!e.archivedAt),[T.conversations]),si=(0,u.useMemo)(()=>e.conversations.filter(e=>!e.archivedAt),[e.conversations]),ci=(0,u.useMemo)(()=>new Set(T.collapsedConversationIds??[]),[T.collapsedConversationIds]),R=(0,u.useMemo)(()=>{let e=oi.find(e=>e.id===E);if(e)return e;if(!(we||Qn||P(E??O)))return Tk(oi,T.workspaces,O)},[we,Qn,E,oi,O,T.workspaces]),li=(0,u.useMemo)(()=>R?{workspaceId:R.workspaceId,conversationId:R.id,onImageOpen:Wr}:void 0,[R?.workspaceId,R?.id]),[ui,di]=(0,u.useState)(`queue`),fi=!!(R&&pO(R));(0,u.useEffect)(()=>{di(`queue`)},[R?.id,fi]);let[pi,mi]=(0,u.useState)([]),hi=(0,u.useMemo)(()=>$e(R?.parentConversationId,R?.parentConversationId?T.conversations.find(e=>e.id===R.parentConversationId):void 0),[R,T.conversations]),gi=!!(R&&T.unlockedChildConversationIds?.includes(R.id)),_i=hi&&!gi,vi=(0,u.useMemo)(()=>(T.conversations||[]).filter(e=>e.parentConversationId===R?.id),[T.conversations,R?.id]),yi=(0,u.useMemo)(()=>(T.conversations||[]).find(e=>e.id===R?.parentConversationId),[T.conversations,R?.parentConversationId]),bi=(0,u.useMemo)(()=>R?tt({conversation:R,parent:yi,directChildren:vi,isTopLevelUnread:!1}):null,[R,yi,vi]),xi=Tt.current;if(xi){let e=xi.dataset.messageScrollContainer;e&&R?.id&&e!==R?.id&&xi.querySelector(`[data-transcript-key]`)&&(Ie.current[e]=sk(xi,Ie.current[e]??{followTail:!0,scrollTop:0}))}kt.current=R?.messagesLoaded!==!1,(0,u.useEffect)(()=>{if(!Te||P(E??O)||(we||Qn)&&!E||E&&si.some(e=>e.id===E)||E&&m.current.some(e=>e.temporaryId===E))return;let e=Tk(oi,T.workspaces,O);we&&e||(E&&!e&&et!==`group`&&(ge.current++,nt(`session`)),D(e?.id),e&&ie(t=>t.emptied||t.ids.length===0||t.ids.includes(e.id)?t:{...t,ids:[...t.ids,e.id]}))},[we,Qn,E,si,oi,Te,O,T.workspaces,et]),(0,u.useEffect)(()=>{te(void 0)},[E,O]);let Si=(0,u.useMemo)(()=>T.workspaces.find(e=>e.id===O)??(Qn||P(O)?void 0:T.workspaces[0]),[T.workspaces,O,Qn]),Ci=Si&&!oi.some(e=>e.workspaceId===Si.id)?Si:void 0,wi=Si?.id.startsWith(`pending:`)===!0,[Ti,Oi]=(0,u.useState)(``);(0,u.useEffect)(()=>{Oi(``)},[Si?.id]);let ki=(0,u.useRef)(O);ki.current=O,(0,u.useEffect)(()=>{R&&k(R.workspaceId)},[R?.id]),(0,u.useEffect)(()=>{Zr.current=E},[E]),(0,u.useEffect)(()=>{Dt.current=R?.id},[R?.id]);let Ai=(0,u.useCallback)(e=>{let t=e.activity.lastReplyAt,n=dt({workspaceId:e.workspaceId,roomId:e.id});!t||t<=(Re.current[n]??``)||(Re.current[n]=t,Be(e=>e+1),lk({activeId:Zr.current,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current}))},[]);xt(Re,T.conversations,()=>{Be(e=>e+1),lk({activeId:Zr.current,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current})}),(0,u.useEffect)(()=>{let e=R?.id;if(!e)return;let t=T.conversations.find(t=>t.id===e);if(!t||t.messagesLoaded===!1)return;let n=()=>{let n=Tt.current;document.visibilityState!==`visible`||!n||n.getBoundingClientRect().height<=0||t.updatedAt<=(Re.current[e]??``)||(Re.current[e]=t.updatedAt,Be(e=>e+1),lk({activeId:Zr.current,workspaceId:R?.workspaceId??O,conversations:Ie.current,readAt:Re.current}))},r=requestAnimationFrame(n);return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{cancelAnimationFrame(r),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[R?.id,T.conversations,et]),(0,u.useEffect)(()=>{let e=R?.workspaceId??O;N&&Te&&e&&!e.startsWith(`pending:`)&&!R?.id.startsWith(`pending:`)&&lk({activeId:R?.id,workspaceId:e,conversations:Ie.current,readAt:Re.current})},[R?.id,R?.workspaceId,N,Te,O]),(0,u.useEffect)(()=>{let e=Tt.current;if(et!==`session`||!e||!R?.id||R.messagesLoaded===!1)return;let t=R.id;Mt.current=!1;let n=Ie.current[t]??{followTail:!0,scrollTop:0};Ie.current[t]=n,jt(n);let r=requestAnimationFrame(()=>{if(Tt.current!==e)Ot.current=!1;else{if(n.followTail)ok(e),e.scrollTop=e.scrollHeight;else{let t=n.anchorKey?e.querySelector(`[data-transcript-key="${CSS.escape(n.anchorKey)}"]`):null;e.scrollTop=t?Math.max(0,e.scrollTop+t.getBoundingClientRect().top-(n.anchorOffset??0)-e.getBoundingClientRect().top):n.scrollTop}Ot.current=!1}});return()=>cancelAnimationFrame(r)},[R?.id,R?.messagesLoaded,et]),(0,u.useLayoutEffect)(()=>{Ot.current=!0},[R?.id,R?.messagesLoaded,et]);let ji=(0,u.useCallback)((e,t=!1,n=!1)=>{let r=Dt.current;if(!r||Ot.current||!kt.current)return;let i=sk(e,Ie.current[r]??{followTail:!0,scrollTop:0},t,n);Mt.current=!i.followTail,Ie.current[r]=i,jt(i),lk({activeId:r,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current})},[]),z=R?.id??``,Li=Pr[z]??{text:``,images:[],attachments:[],uploading:0},Ri=Li.text,zi=Li.images,Bi=Li.attachments,Vi=Object.keys(Li.pendingSkills??{}).length>0,Hi=Li.uploading,Ui=(e,t)=>Fr(n=>({...n,[e]:t(n[e]??{text:``,images:[],attachments:[],uploading:0})})),Wi=(e,t)=>({...e,text:t,attachments:UD(t,e.attachments),pendingSkills:e.pendingSkills&&Object.fromEntries(Object.entries(e.pendingSkills).filter(([e])=>Wd(t,e)))}),Gi=e=>Ui(z,t=>Wi(t,e)),Ki=(e,t,n,r)=>{let i=ur();Ui(n,n=>{let r=Wi(n,t);return{...r,pendingSkills:{...r.pendingSkills,[e]:i}}});let a=t=>t[n]?.pendingSkills?.[e]===i?n:n.startsWith(`pending:`)?Object.keys(t).find(n=>t[n].pendingSkills?.[e]===i):void 0,o=t=>Fr(n=>{let r=a(n);if(!r)return n;let i=n[r],o={...i.pendingSkills};delete o[e];let s=t?[...i.attachments.filter(t=>t.id!==e),t]:i.attachments;return{...n,[r]:{...i,pendingSkills:o,attachments:s}}});ke(`/api/skills/read?${new URLSearchParams({name:e,workspaceId:r})}`,{signal:AbortSignal.timeout(1e4)}).then(async t=>{if(!t.ok)throw Error(`读取技能失败`);let n=await t.json();if(typeof n.content!=`string`)throw Error(`读取技能失败`);o({kind:`skill`,id:e,name:n.name??e.slice(6),content:n.content})}).catch(()=>{a(Ir.current)&&Ds(`读取技能失败`,`error`),o()})},qi=(e,t)=>Ui(R?.id??``,n=>({...n,attachments:n.attachments.filter(n=>n.kind!==e||n.id!==t)})),[Ji,Yi]=(0,u.useState)({visible:!1,query:``,rect:null}),Xi=JSON.stringify([R?.id,R?.workspaceId,R?.cwd??``]),[Zi,Qi]=(0,u.useState)(),$i=(0,u.useRef)(null),[ea,ta]=(0,u.useState)(),na=(0,u.useRef)(void 0),ra=(0,u.useRef)(``),ia=!_i&&Zi?.scope===Xi?Zi:void 0,aa=e=>{let t=!Jr.current&&!_i&&R?qd(e.value,e.selectionStart,e.selectionEnd):void 0,n=JSON.stringify([Xi,t]);return!t||ra.current===n?(Qi(void 0),!1):(Qi({scope:Xi,token:t,rect:e.getBoundingClientRect()}),Yi({visible:!1,query:``,rect:null}),!0)},oa=()=>{ra.current=JSON.stringify([Xi,ia?.token]),Qi(void 0)};(0,u.useEffect)(()=>{Qi(void 0),ra.current=``},[Xi]),(0,u.useLayoutEffect)(()=>{let e=na.current;na.current=void 0,e?.scope===Xi&&e.text===Ri&&(Et.current?.focus(),Et.current?.setSelectionRange(e.caret,e.caret))},[Ri,Xi]),(0,u.useEffect)(()=>{let e=()=>{let e=Et.current;e&&Qi(t=>t?{...t,rect:e.getBoundingClientRect()}:void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let sa=e=>Ui(R?.id??``,t=>({...t,images:typeof e==`function`?e(t.images):e})),ca=ae.length>0?ae:we?[]:R?[R.id]:[],la=(0,u.useMemo)(()=>ca.map(e=>oi.find(t=>t.id===e)).filter(e=>e!==void 0),[ca,oi]),ua=Ci?void 0:la.filter(e=>e.id!==he).at(-1)?.id,da=la.some(e=>e.id===R?.id);(0,u.useEffect)(()=>{if(!Te)return;let e=new Set(oi.map(e=>e.id));ie(t=>{let n=t.ids.filter(t=>e.has(t)||P(t)),r=t.previewId&&(e.has(t.previewId)||P(t.previewId))?t.previewId:void 0;return n.length===t.ids.length&&r===t.previewId?t:{...t,ids:n,previewId:r}})},[Te,oi]),(0,u.useEffect)(()=>{!Te||wi||E?.startsWith(`pending:`)||P(E??O)||mk(F,E,E?void 0:Ci?.id,Qn||!E&&!Ke)},[E,Te,F,wi,Ci?.id,Qn,Ke]);let fa=(0,u.useCallback)(e=>{e&&ie(t=>{if(t.touched.has(e))return t;let n=t.previewId===e?void 0:t.previewId;return{...t,previewId:n,touched:dk(t.touched,e)}})},[]),pa=(0,u.useCallback)(e=>{I(se(e)),$n(!1),ge.current++,qe(!1),D(e);let t=oi.find(t=>t.id===e)?.workspaceId;t&&k(t),nt(`session`),ie(t=>{let n=t.emptied===!0,r=n?{...t,emptied:!1}:t;if(r.ids.includes(e))return r;let i=!n&&r.ids.length===0&&R?.id&&R.id!==e?[R.id]:[],a=[...r.ids,...i];if(r.touched.has(e))return{...r,ids:[...a,e]};let o=r.previewId?a.indexOf(r.previewId):-1,s=o>=0?a.map((t,n)=>n===o?e:t):[...a,e];return{...r,ids:s,previewId:e}})},[R,oi]);(0,u.useEffect)(()=>{if(!Te)return;let t=new Map(e.conversations.filter(e=>!e.archivedAt).map(e=>[e.id,{status:e.status,hasPendingQuestion:!!e.hasPendingQuestion,title:e.title,workspaceId:e.workspaceId,parentConversationId:e.parentConversationId}]));if(!c.current){s.current=t,c.current=!0;return}let r=document.visibilityState===`visible`&&document.hasFocus(),a=n&&[`granted`,`native`].includes(i)&&!r;for(let[n,r]of t){let t=s.current.get(n);if(!t||r.parentConversationId||!a)continue;let i=!t.hasPendingQuestion&&r.hasPendingQuestion,o=r.status===`completed`&&t.status!==`completed`&&[`waiting`,`running`,`awaiting_background`].includes(t.status);if(!i&&!o)continue;let c=i?`question`:`completed`;if(Dk(`${n}:${c}:${e.conversations.find(e=>e.id===n)?.updatedAt??``}`))try{let e=`${n}:${c}`,t=Pi(i?`Super Pi · 等你回答`:`Super Pi · Agent 已完成`,{body:`${me(r.workspaceId)} · ${i?`「${r.title}」需要你的回答。`:`「${r.title}」已完成。`}`,tag:`super-pi-${c}-${n}`});l.current.set(e,t),t.onclose=()=>{l.current.get(e)===t&&l.current.delete(e)},t.onclick=()=>{t.close(),l.current.delete(e),window.focus(),pa(n)}}catch(e){console.warn(`[Super Pi] Browser notification could not be shown:`,e instanceof Error?e.message:`unknown error`)}}s.current=t},[e.conversations,Te,n,i,pa]);let ma=(0,u.useCallback)(e=>{e&&(fa(e),pa(e))},[fa,pa]),ha=e=>{e.startsWith(`pending:`)||I(se(e)),$n(!0),ge.current++,qe(!1),R&&da&&ie(e=>e.ids.length||e.emptied?e:{...e,ids:[R.id]}),k(e),D(void 0),nt(`session`),Un(!1),Vn()},ga=(0,u.useCallback)((e,t=``)=>{ge.current++;let n={workspaceId:e,roomId:t};t&&Ge(r=>r.some(n=>n.workspaceId===e&&n.roomId===t)?r:[...r,n]),Ue(n),qe(!0),k(e),Un(!1),nt(`group`),Vn()},[Vn]),_a=(0,u.useCallback)((e,t)=>{at(e,!0),t&&(re(t=>t[e.workspaceId]?{...t,[e.workspaceId]:!1}:t),ga(e.workspaceId,e.id))},[ga,at]);(0,u.useEffect)(()=>{let e=new Set;if(!n||i!==`granted`)Ii(e);else{for(let t of Object.values(rt))for(let n of t.rooms)if(!n.archivedAt)for(let t of n.cloneRequests??[]){if(t.status!==`pending`||t.automatic)continue;let r=`group-clone:${n.id}:${t.id}`;e.add(r),Fi(r,`${me(n.workspaceId)} · ${n.title} · 需要决定是否创建分身`,t.reason,et===`group`&&St===n.id&&document.visibilityState===`visible`&&document.hasFocus(),()=>ga(n.workspaceId,n.id))}Ii(e)}},[rt,et,St,ga,n,i]);let va=(0,u.useCallback)(e=>{it(),ot(e)},[ot,it]);async function ya(e,t){if(!mt.has(e.id)&&(t!==`delete`||window.confirm(`永久删除群聊「${e.title}」及其聊天记录?删除后无法恢复。`))){ht(t=>new Set(t).add(e.id));try{let n=await gt(pt(e.workspaceId,e.id),{action:t});if(t===`delete`)va({workspaceId:e.workspaceId,roomId:e.id});else{if(!n)throw Error(`服务没有确认群聊状态。`);it(),at(n),t===`archive`&&Wt(t=>({...t,[e.workspaceId]:!1}))}}catch(e){Ds(e instanceof Error?e.message:`群聊操作失败。`,`error`)}finally{ht(t=>new Set([...t].filter(t=>t!==e.id)))}}}let ba=Ke&&et!==`session`,xa=ba?bt:R?.workspaceId??O,Sa=xa?.startsWith(`pending:`)?void 0:xa,Ca=Sa??(Wn===`repo`?T.workspaces.find(e=>e.id===Xn&&(!e.worktreeOf||!T.workspaces.some(t=>t.id===e.worktreeOf)))?.id??T.workspaces.find(e=>(Kn===`all`||h(e.id).server===Kn)&&(!e.worktreeOf||!T.workspaces.some(t=>t.id===e.worktreeOf)))?.id:void 0),wa=Ca?.startsWith(`pending:`)?void 0:Ca,Ta=ba?``:R?.cwd??``;(0,u.useEffect)(()=>{Sa&&I(se(Sa))},[Sa]);let Ea=Wn===`repo`&&(!R||ba),Da=JSON.stringify([Sa,Ta]),[Oa,ka]=(0,u.useState)(),[Aa,ja]=(0,u.useState)(50),Ma=Oa?.scope===Da?Oa:void 0,Na=!!Ma,Pa=Ma?.tabId;(0,u.useEffect)(()=>{ka(e=>e?.scope===Da?e:void 0)},[Da]);let Fa=(0,u.useCallback)(e=>{ka(t=>t?.scope===Da?{...t,tabId:e}:t)},[Da]),B=tm(Sa,Ta,{navigation:ge,showingFile:et===`file`,splitFilePath:Pa?.startsWith(`file:`)?Pa.slice(5):void 0}),V=$r(wa,wa===Sa?Ta:``,N&&Te),Ia=(0,u.useRef)(V.refresh);Ia.current=V.refresh;let La=(0,u.useRef)(B.setChangedFor),Ra=(0,u.useRef)(B.invalidateTree);Ra.current=B.invalidateTree;let za=(0,u.useRef)(Sa);za.current=Sa,(0,u.useEffect)(()=>{La.current=B.setChangedFor},[B.setChangedFor]);let[Ba]=(0,u.useState)(cO),[Va,Ha]=(0,u.useState)(Ba.tab),[Ua,Wa]=(0,u.useState)(Ba.byConversation),Ga=(R?.id?Ua[R.id]:void 0)??Va;(0,u.useEffect)(()=>{try{Je(sO,JSON.stringify({tab:Va,byConversation:Ua}))}catch{}},[Va,Ua]);let Ka=(0,u.useCallback)(e=>{Ha(e),R?.id&&Wa(t=>({...t,[R.id]:e}))},[R?.id]),qa=rr.order.filter(e=>rr.sides[e]===`left`),[Ja,Ya]=(0,u.useState)(!1),[Xa,Za]=(0,u.useState)(!1),Qa=rr.order.filter(e=>e!==`sessions`&&rr.sides[e]===`right`),$a=qa.includes(rr.leftView)?rr.leftView:`sessions`,eo=Qa.includes(Ga)?Ga:Qa[0],to=rr.rightClosed||!eo,no=mr||!rr.leftClosed&&!Ja&&$a===`sessions`,ro=(e,t=!1)=>{(e===`sessions`||rr.sides[e]===`left`)&&Ya(!1),mr?e===`sessions`?(Vn(),Un(!0)):(Ka(e),In(!1),tr<=700&&Rn(`rail`)):rr.sides[e]===`left`?ir(n=>({...n,leftView:e,leftClosed:t&&!Ja&&!n.leftClosed&&$a===e})):e!==`sessions`&&(Ka(e),ir(n=>({...n,rightClosed:t&&!n.rightClosed&&eo===e})))},io=(e,t)=>{let n=rr.sides[e];if(t===`move`){let t=n===`left`?`right`:`left`;t===`left`&&Ya(!1),ir(n=>({...n,sides:{...n.sides,[e]:t},...t===`left`?{leftView:e,leftClosed:!1}:{rightClosed:!1}})),t===`right`&&Ka(e),requestAnimationFrame(()=>{(document.querySelector(`[data-workbench-view="${e}"]`)??document.querySelector(`[data-workbench-panel-menu="${e}"]`))?.focus()})}else ir(t===`pin`?t=>({...t,unpinned:t.unpinned.includes(e)?t.unpinned.filter(t=>t!==e):[...t.unpinned,e]}):r=>{let i=r.order.filter(e=>r.sides[e]===n&&!r.unpinned.includes(e)),a=i.indexOf(e),o=a>=0?i[a+(t===`up`?-1:1)]:void 0;if(!o||o===`sessions`)return r;let s=r.order.slice(),c=s.indexOf(e),l=s.indexOf(o);return[s[c],s[l]]=[s[l],s[c]],{...r,order:s}})},ao=(e,t)=>{e!==t&&ir(n=>{if(n.sides[e]!==n.sides[t])return n;let r=n.order.slice(),i=r.indexOf(e),a=r.indexOf(t);return r.splice(i,1),r.splice(a,0,e),{...n,order:r}})},oo=()=>{Ya(!1),ir(tn()),or({}),Ka(`main`)},H=JSON.stringify([Sa,Ta]),[U,W]=(0,u.useState)(),G=U?.scope===H?U:void 0,K=G?.mode===`path`;(0,u.useEffect)(()=>{W(e=>e?.scope===H?e:void 0)},[H]);let so=(0,u.useCallback)((e,t,n)=>{ge.current++,W(r=>r?.mode===e&&r.scope===H&&r.directory===n?r:{mode:e,scope:H,initialQuery:t,directory:n}),Un(!1)},[H]),co=(0,u.useCallback)(()=>{ge.current++,W(void 0)},[]),[lo,uo]=(0,u.useState)(),fo=(0,u.useRef)(0),po=e=>{pa(e.conversationId),uo({hit:e,request:ge.current}),W(void 0),Vn()};(0,u.useEffect)(()=>{if(!lo||lo.request===fo.current||R?.id!==lo.hit.conversationId||R?.messagesLoaded===!1||et!==`session`||!da)return;let{hit:e,request:t}=lo,n=null,r,i=requestAnimationFrame(()=>{let i=Tt.current;i&&ge.current===t&&(n=i.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`),n&&(fo.current=t,ok(i),i.scrollTop+=n.getBoundingClientRect().top-i.getBoundingClientRect().top-24,ji(i,!0),n.dataset.sessionSearchHit=`true`,n.tabIndex=-1,n.focus({preventScroll:!0}),r=setTimeout(()=>{n&&delete n.dataset.sessionSearchHit},2400)))});return()=>{cancelAnimationFrame(i),clearTimeout(r),n&&delete n.dataset.sessionSearchHit}},[R?.id,R?.messagesLoaded,et,ji,da,lo]);let[mo,ho]=(0,u.useState)(),[q,go]=(0,u.useState)(),[J,_o]=(0,u.useState)(w.diffs),vo=J.paths,[yo,bo]=(0,u.useState)(w.gitDiffs),[xo,So]=(0,u.useState)(w.gitDiffUrl);(0,u.useEffect)(()=>{if(!(!Te||B.restoringWorkbench||P(E??O)))try{Ze({view:et,groups:We,gitDiffs:yo,gitDiffUrl:xo,diffs:J})}catch{}},[Te,B.restoringWorkbench,E,O,et,We,yo,xo,J]);let Co=et===`gitDiff`?yo.find(e=>e.target.url===xo):void 0,wo=et===`gitDiff`?`diff`:et,To=Co?.target.path??q,Eo=(0,u.useCallback)(e=>{if(Ea&&!e.commitHash)return;ge.current++;let t=document.activeElement instanceof HTMLElement?document.activeElement:void 0;bo(n=>{let r=n.find(t=>t.target.url===e.url);if(!r){let r={target:e,workspaceId:Sa,reading:{},revision:0,preview:!0,origin:t},i=Na&&et===`gitDiff`?xo:void 0,a=n.find(e=>e.preview&&e.target.url!==i);return a?n.map(e=>e===a?r:e):[...n,r]}if(e.commitHash)return n;let i=r.target.label===e.label?{...r.reading,snapshot:void 0}:{split:r.reading.split};return n.map(n=>n===r?{...n,target:e,reading:i,revision:n.revision+1,origin:t}:n)}),Na?(Fa(`git-diff:${e.url}`),et===`gitDiff`&&xo===e.url&&nt(`session`)):(So(e.url),nt(`gitDiff`)),Vn()},[Sa,Ea,xo,et,Fa,Vn,Na]),Do=(0,u.useCallback)(()=>{!da&&ua?pa(ua):nt(`session`)},[da,ua,pa]);(0,u.useEffect)(()=>{let e=e=>{let t=rt[e.workspaceId];return!t?.loaded||t.rooms.some(t=>t.id===e.roomId)},t=We.filter(e);if(t.length!==We.length&&Ge(t),et!==`group`||!Ve?.roomId||e(Ve))return;let n=t.filter(e=>e.workspaceId===Ve.workspaceId).at(-1);n?ga(n.workspaceId,n.roomId):Do()},[rt,Ve,We,et,ga,Do]),(0,u.useEffect)(()=>{et===`file`&&!B.active&&Do()},[et,B.active,Do]),(0,u.useEffect)(()=>{et===`diff`&&!q&&Do()},[et,q,Do]);let Oo=(0,u.useRef)(`${Sa??``}:${Ta}`);(0,u.useEffect)(()=>{let e=`${Sa??``}:${Ta}`;Oo.current!==e&&(Oo.current=e,_o({paths:[]}),go(void 0),nt(e=>e===`gitDiff`||e===`group`?e:`session`))},[Sa,Ta]);let ko=(0,u.useCallback)((e,t=!1)=>{ge.current++;let n=Na&&!t;_o(t=>{if(t.paths.includes(e))return t;let r=n&&et===`diff`&&q===t.previewPath;return{paths:t.previewPath&&!r?t.paths.map(n=>n===t.previewPath?e:n):[...t.paths,e],previewPath:e}}),n?(Fa(`diff:${e}`),et===`diff`&&q===e&&nt(`session`)):(go(e),nt(`diff`)),Vn(),Ha(`files`)},[q,et,Fa,Vn,Na]),Ao=et===`diff`?q:void 0,jo=Pa?.startsWith(`diff:`)?Pa.slice(5):void 0,Mo=jo&&jo!==Ao&&vo.includes(jo)?jo:void 0,No=Ek(Sa,Ta,Ao),Po=Ek(Sa,Ta,Mo),[Fo,Io]=(0,u.useState)(`server`),[Lo,Ro]=(0,u.useState)(`server`),zo=e=>{let t=B.open.find(t=>t.path===e);return t?.dirty?t.content:void 0},Bo=(0,u.useCallback)(e=>{ge.current++,B.setActivePath(e),nt(`file`),Ha(`files`)},[B.setActivePath]),Vo=(0,u.useCallback)(async(e,t,n=!1,r=!1,i=!1,a)=>{let o=++ge.current,s=()=>ge.current===o,c=Na&&!i,l=await B.openFile(e,{preview:!n,activate:!c,isCurrent:s,throwOnError:r,requireText:a!==void 0});if(l&&s())return n&&B.pinFile(l),ho(t?{scope:H,path:l,line:t,column:a,request:o}:void 0),c?(Fa(`file:${l}`),et===`file`&&B.activePath===l&&nt(`session`)):nt(`file`),Vn(),l},[B.openFile,B.pinFile,B.activePath,H,et,Fa,Vn,Na]),Ho=(0,u.useCallback)((e,t)=>{Vo(e,void 0,t)},[Vo]),Uo=R&&!_i?(e,t)=>{let n=Ri&&!/\s$/u.test(Ri)?`${Ri} `:Ri,r=Jd(n,{start:n.length,end:n.length,query:``},{path:e,kind:t?`directory`:`file`});na.current={scope:Xi,...r},fa(R.id),pa(R.id),Vn(),Gi(r.text)}:void 0,Wo=(e,t)=>{ge.current+=1,_o(t=>({paths:t.paths.filter(t=>!uf(t,e)),previewPath:t.previewPath&&!uf(t.previewPath,e)?t.previewPath:void 0})),q&&uf(q,e)&&go(void 0),ka(n=>{let r=n?.tabId?.startsWith(`file:`)?n.tabId.slice(5):void 0;return n&&r&&uf(r,e)?{...n,tabId:`file:${t}${r.slice(e.length)}`}:n}),ho(n=>n?.scope===H&&uf(n.path,e)?{...n,path:t+n.path.slice(e.length)}:n)};(0,u.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.altKey||e.isComposing)return;let t=e.key.toLowerCase();e.shiftKey&&t===`f`?(e.preventDefault(),so(`content`)):!e.shiftKey&&t===`p`&&(e.preventDefault(),so(`path`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[so]);let Go=(0,u.useMemo)(()=>la.map(e=>({id:`session:${e.id}`,workspaceId:e.workspaceId,rawId:e.id,kind:`session`,label:e.title,title:e.title,closable:!0,preview:he===e.id,badge:(0,L.jsx)(bO,{state:vO(e,gO(e,Pn),Re.current[e.id],T.conversations)})})),[la,Pn,T.conversations,ze,he]),Ko=(0,u.useMemo)(()=>B.open.map(e=>({id:`file:${e.path}`,workspaceId:B.ownerWorkspaceId,rawId:e.path,kind:`file`,label:e.name,title:e.path,closable:!0,preview:e.preview,badge:e.dirty?(0,L.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[B.ownerWorkspaceId,B.open]),qo=(0,u.useMemo)(()=>vo.map(e=>({id:`diff:${e}`,workspaceId:Sa,rawId:e,kind:`diff`,label:e.split(/[\\/]/).pop()||e,title:`${e}(改动)`,closable:!0,preview:J.previewPath===e,icon:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`±`})})),[Sa,vo,J.previewPath]),Jo=(0,u.useMemo)(()=>[...Go,...[...We,...et===`group`&&Ve&&!St?[Ve]:[]].flatMap(e=>{let t=T.workspaces.find(t=>t.id===e.workspaceId&&!t.closedAt);if(!t)return[];let n=rt[e.workspaceId]?.rooms.find(t=>t.id===e.roomId),r=e.roomId?n?.title??`群聊`:`新建群聊`,i=n?_t(n,st[n.id]):`idle`,a=n?vt(n,st[n.id],Re.current[dt(e)]):`idle`,o=a===`completed`?`讨论已完成,有新回复未读`:a===`unread`?`有新回复未读`:uO[i],s=`${r} · ${t.name}${i===`idle`?``:` · ${o}`}`;return[{id:dt(e),workspaceId:e.workspaceId,label:r,title:s,closable:!0,icon:(0,L.jsx)(on,{name:`group`}),badge:(0,L.jsx)(bO,{state:a,label:o})}]}),...Ko,...qo,...yo.map(({target:e,preview:t,workspaceId:n})=>({id:`git-diff:${e.url}`,workspaceId:n,kind:`diff`,closable:!0,preview:t,label:`${e.path.split(/[\\/]/).pop()||e.path} (${e.label})`,title:`${e.path} · ${e.comparison}`,icon:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`±`})}))],[Go,Ko,qo,yo,We,rt,st,Ve,St,et,T.workspaces,ze]),Yo=et===`group`&&Ve?dt(Ve):et===`file`&&B.activePath?`file:${B.activePath}`:et===`diff`&&q?`diff:${q}`:Co?`git-diff:${Co.target.url}`:da&&R?.id?`session:${R.id}`:void 0,Xo=(0,u.useRef)(!1),Zo=(0,u.useRef)(void 0);(0,u.useLayoutEffect)(()=>{let e=Xo.current;if(Xo.current=!1,Zo.current!==B.restoredActive&&(Zo.current=B.restoredActive,!xe&&B.restoredActive&&B.restoredActive===B.activePath&&et!==`file`&&et!==`gitDiff`&&et!==`group`)){nt(`file`);return}if(!e&&Te&&he&&Yo!==`session:${he}`&&oi.some(e=>e.id===he)&&ie(e=>{if(e.previewId!==he)return e;let t=e.ids.filter(e=>e!==he);return{...e,ids:t,previewId:void 0,emptied:t.length===0}}),!e)for(let e of B.open)e.preview&&Yo!==`file:${e.path}`&&Pa!==`file:${e.path}`&&B.discardPreview(e.path);let t=J.previewPath;!e&&t&&Yo!==`diff:${t}`&&Pa!==`diff:${t}`&&_o(e=>e.previewPath===t?{paths:e.paths.filter(e=>e!==t)}:e);let n=e=>{let t=`git-diff:${e.target.url}`;return!e.preview||t===Yo||t===Pa};!e&&yo.some(e=>!n(e))&&bo(e=>e.filter(n)),Te&&et===`session`&&R&&R.id===E&&!da&&!B.restoringWorkbench&&ua&&pa(ua)},[Yo,Te,he,B.open,B.activePath,B.restoredActive,B.discardPreview,J.previewPath,et,R?.id,E,da,B.restoringWorkbench,ua,pa,oi,xe,Pa,yo]);let Qo=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=ft(e);t&&ga(t.workspaceId,t.roomId)}else if(e.startsWith(`file:`)){let t=e.slice(5);Bo(t)}else if(e.startsWith(`diff:`)){ge.current++;let t=e.slice(5);go(t),nt(`diff`)}else if(e.startsWith(`git-diff:`))ge.current++,So(e.slice(9)),nt(`gitDiff`);else if(e.startsWith(`session:`)){let t=e.slice(8);pa(t)}},[Bo,pa,ga]),$o=Jo.find(e=>e.id===Yo),es=et===`file`?B.active:void 0,ts=(0,u.useMemo)(()=>{if(!Te||!$o||$o.id.startsWith(`session:pending:`))return;let{id:e,label:t}=$o;if(et!==`group`||St&&wt){if(et===`session`)return e.startsWith(`session:`)?{key:e,tabId:e,title:t}:void 0;if(et===`file`||et===`diff`){if(!Sa||B.restoringWorkbench||et===`file`&&!es||et===`diff`&&!q)return;let n={workspaceId:Sa,cwd:Ta,conversationId:R?.id},r=es&&{path:es.path,name:es.name,text:null,...es.assetTicket||/^(?:[a-z]:[\\/]|[\\/])/i.test(es.path)?{openLink:!0}:{}};return{key:JSON.stringify([n.workspaceId,n.cwd,e]),tabId:e,title:t,scope:n,file:r}}return{key:e,tabId:e,title:t}}},[Te,$o,et,Sa,Ta,R?.id,B.restoringWorkbench,q,es?.path,es?.name,es?.assetTicket,St,wt]);(0,u.useEffect)(()=>{!xe&&ts&&(Ce.current.delete(ts.key),be(e=>Em(e,ts)))},[ts,xe]);let ns=e=>{let t=oi.filter(t=>t.workspaceId===e.workspaceId&&(t.cwd??``)===e.cwd);return t.find(t=>t.id===e.conversationId)??t[0]},rs=e=>{if(e.key===ts?.key||Ce.current.has(e.key))return!1;if(e.tabId.startsWith(`session:`))return oi.some(t=>`session:${t.id}`===e.tabId);let t=ft(e.tabId);if(t)return T.workspaces.some(e=>e.id===t.workspaceId&&!e.closedAt)&&!!rt[t.workspaceId]?.rooms.some(e=>e.id===t.roomId);if(!e.scope)return Jo.some(t=>t.id===e.tabId);let{scope:n}=e;return T.workspaces.some(e=>e.id===n.workspaceId)?n.workspaceId===Sa&&n.cwd===Ta||!!ns(n)||!n.cwd&&!oi.some(e=>e.workspaceId===n.workspaceId):!1},is=Dm(ye,ye.index+ +!ts,-1,rs),Y=Dm(ye,ye.index,1,rs),as=e=>{let t=e<0?is:Y;xe||t<0||Se({index:t,direction:e,ticket:++ge.current,stage:`start`})},os=(0,u.useRef)(as);os.current=as,(0,u.useEffect)(()=>{let e=e=>{(e.button===3||e.button===4)&&(e.preventDefault(),e.type===`mouseup`&&os.current(e.button===3?-1:1))};for(let t of[`mousedown`,`mouseup`,`auxclick`])window.addEventListener(t,e,!0);return()=>{for(let t of[`mousedown`,`mouseup`,`auxclick`])window.removeEventListener(t,e,!0)}},[]),(0,u.useEffect)(()=>{let e=xe;if(!e)return;if(ge.current!==e.ticket){Se(void 0);return}let t=ye.entries[e.index];if(t.key===ts?.key){be(t=>({...t,index:e.index})),Se(void 0);return}let n=(t=e.ticket)=>{let n=Dm(ye,e.index,e.direction,rs);Se(n<0?void 0:{...e,index:n,ticket:t,stage:`start`})};if(!rs(t)){n();return}let r=t.scope;if(r&&(r.workspaceId!==Sa||r.cwd!==Ta)){if(e.stage!==`start`){n();return}let t=ns(r);t?pa(t.id):ha(r.workspaceId),Se({...e,stage:`scope`,ticket:ge.current});return}if(e.stage===`opening`||r&&B.restoringWorkbench)return;Un(!1),Vn();let i=t.file;if(i&&!B.open.some(e=>e.path===i.path)){let r=Vo(i,void 0,!1,!0,!0),a=ge.current;Se({...e,stage:`opening`,ticket:a}),r.then(e=>{!e&&ge.current===a&&Se(void 0)}).catch(e=>{ge.current===a&&(e instanceof kp&&e.status===404?(Ce.current.add(t.key),n(a)):(Ds(Ht(e instanceof Error?e.message:void 0,`无法打开导航历史中的文件。`),`error`),Se(void 0)))})}else t.tabId.startsWith(`diff:`)&&!Jo.some(e=>e.id===t.tabId)?ko(t.tabId.slice(5),!0):Qo(t.tabId),Se({...e,stage:`opening`,ticket:ge.current})});let ss=(0,u.useCallback)(e=>{if(e.startsWith(`session:`))ma(e.slice(8));else if(e.startsWith(`file:`))B.pinFile(e.slice(5));else if(e.startsWith(`diff:`)){let t=e.slice(5);_o(e=>e.previewPath===t?{paths:e.paths}:e)}else e.startsWith(`git-diff:`)&&bo(t=>t.map(t=>t.preview&&`git-diff:${t.target.url}`===e?{...t,preview:!1}:t))},[ma,B.pinFile]),cs=Jo.filter(e=>e.kind===`file`||e.kind===`diff`),ls=Na&&Pa!==Yo?cs.find(e=>e.id===Pa):void 0,us=e=>{cs.some(t=>t.id===e)&&(ge.current++,Fa(e),e===Yo&&Do())},ds=()=>{if(Na){ge.current++,ls&&ss(ls.id),ka(void 0);return}ge.current++;let e=cs.find(e=>e.id===Yo)??cs.at(-1);ka({scope:Da,tabId:e?.id}),e&&e.id===Yo&&(R&&!da?pa(R.id):Do())},fs=(0,u.useCallback)(e=>{let t=ca.indexOf(e);if(t<0)return;let n=ca.filter(t=>t!==e);if(ie(t=>({...t,ids:t.ids.filter(t=>t!==e),previewId:t.previewId===e?void 0:t.previewId,emptied:n.length===0||t.emptied})),R?.id!==e||et!==`session`)return;ge.current++;let r=n[Math.min(t,n.length-1)];if(r)D(r);else if(B.open.length>0){let e=B.activePath&&B.open.some(e=>e.path===B.activePath)?B.activePath:B.open[0].path;B.setActivePath(e),nt(`file`)}else vo.length>0?(go(vo[0]),nt(`diff`)):yo.length>0?(So(yo[0].target.url),nt(`gitDiff`)):D(void 0)},[ca,R,B,vo,yo,et]),ps=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=We.filter(t=>dt(t)!==e);if(Ge(t),et===`group`&&Yo===e){let e=t.filter(e=>e.workspaceId===bt).at(-1);e?ga(e.workspaceId,e.roomId):Do()}}else if(e.startsWith(`file:`)){let t=e.slice(5);B.closeFile(t),et===`file`&&B.activePath===t&&B.open.length<=1&&ge.current++}else if(e.startsWith(`diff:`)){let t=e.slice(5);_o(e=>({paths:e.paths.filter(e=>e!==t),previewPath:e.previewPath===t?void 0:e.previewPath})),et===`diff`&&q===t&&(ge.current++,go(void 0),Do())}else if(e.startsWith(`session:`)){let t=e.slice(8);fs(t)}else if(e.startsWith(`git-diff:`)){let t=e.slice(9),n=yo.findIndex(e=>e.target.url===t);if(n<0)return;let r=yo.filter(e=>e.target.url!==t);bo(r);let i=document.activeElement?.getAttribute(`data-diff-tab-close`)===e;if(Co?.target.url===t){ge.current++;let e=r[Math.max(0,n-1)];So(e?.target.url),e||Do()}i&&requestAnimationFrame(()=>{let e=document.querySelector(`.chat-tab-strip [role="tab"][aria-selected="true"]`),t=yo[n].origin;(e??(t?.getClientRects().length?t:void 0)??document.querySelector(`[data-workspace-welcome-create]:not(:disabled)`))?.focus()})}},[B,fs,q,et,yo,Co?.target.url,Do,bt,We,Yo,ga]),ms=B.active,hs=JSON.stringify([Sa,Ta,ms?.path]),[gs,_s]=(0,u.useState)(),vs=(0,u.useCallback)(e=>{_s(t=>e?{scope:hs,position:e}:t?.scope===hs?void 0:t)},[hs]),ys=gs?.scope===hs?gs.position:void 0,bs=T.workspaces.find(e=>e.id===Sa),xs=T.workspaces.find(e=>e.id===wa),Ss=(e,t)=>{let n=e&&Rp(e.path),r=e&&(e.assetTicket||n?(0,L.jsx)(`span`,{className:`file-editor-path`,title:n??e.path,children:n??e.path}):(0,L.jsx)($d,{root:Ta.split(`/`).at(-1)||bs?.name||`工作目录`,path:e.path,reveal:(e,t)=>{ro(`files`),B.locatePath(e,t)}})),i=mo?.scope===H&&mo?.path===e?.path?mo:void 0,a=e&&(!e.view||e.view===`table`)&&(0,L.jsx)(Zp,{file:e,state:B.saves[e.path]?.state??`idle`,message:B.saves[e.path]?.message??``,external:B.external[e.path]===!0,jumpToLine:i,onChange:t=>B.updateBuffer(e.path,t),onSave:()=>void B.save(e.path,!1),onReload:()=>void B.reload(e.path),onOverwrite:()=>void B.save(e.path,!0),workspaceId:Sa,cwd:Ta,navigation:e.view?void 0:r,embedded:!!e.view,onPosition:t?vs:void 0});return(0,L.jsx)(`div`,{className:`chat-file-view`,"data-main-file-view":e?.path,"data-file-view-kind":`editor`,children:e?.view&&Sa?(0,L.jsx)(rf,{workspaceId:Sa,cwd:n?``:Ta,path:n??e.path,name:e.name,kind:e.view,content:e.content,version:e.etag,source:a||void 0,external:B.external[e.path],navigation:r,assetTicket:e.assetTicket,onReload:()=>void B.reload(e.path),sourceRequest:i?.request},JSON.stringify([Sa,Ta,e.path])):a||(0,L.jsx)(`p`,{className:`rail-empty`,"data-main-file-empty":`1`,children:`没有选中的文件。`})})},Cs=e=>Ea&&!e.target.commitHash?(0,L.jsx)(`div`,{className:`chat-file-view`,role:`status`,children:(0,L.jsx)(`p`,{className:`rail-empty`,children:`请选择具体 session 以确定工作区,再查看或编辑工作区差异。`})}):(0,L.jsx)(`div`,{className:`chat-file-view chat-git-diff`,"data-main-diff-view":e.target.path,"data-file-view-kind":`diff`,children:(0,L.jsx)(u.Suspense,{fallback:(0,L.jsx)(`p`,{className:`rail-empty`,role:`status`,children:`正在读取差异…`}),children:(0,L.jsx)(jO,{tab:e,dark:el!==`github-light`&&el!==`solarized-light`},JSON.stringify([e.target.url,e.revision]))})}),ws=(e,t)=>{let n=t?Po:No;return(0,L.jsx)(`div`,{className:`chat-file-view`,"data-main-diff-view":e??``,"data-file-view-kind":`diff`,children:(0,L.jsx)($p,{diff:n.diff,loading:n.loading,error:n.error,bufferContent:zo(e),mode:t?Lo:Fo,onMode:t?Ro:Io})})},Ts=()=>{let e=ls?.id;if(!e)return null;if(e.startsWith(`file:`))return Ss(B.open.find(t=>`file:${t.path}`===e),!1);if(Mo)return ws(Mo,!0);let t=yo.find(t=>`git-diff:${t.target.url}`===e);return t?Cs(t):null},Es=R?.id;(0,u.useEffect)(()=>{Es&&!Es.startsWith(`pending:`)&&Fs({type:`conversation.select`,conversationId:Es})},[Es]);let Ds=(e,t=`info`)=>{if(!e)return;let n=++Yr.current;pn(r=>[...r,{key:n,text:e,kind:t}]),Xr.current.push(window.setTimeout(()=>pn(e=>e.filter(e=>e.key!==n)),7e3))},Os=(e,t=``)=>{if(bs&&bs.id===e&&Ta===t)return e=>{let n=vn(e,{root:bs.path,cwd:t,origin:window.location.origin});if(n)return{title:`${n.path}:${n.line}${n.column?`:${n.column}`:``}`,open:()=>{let e=pm(n.path,t);Vo(e,n.line,!1,!0,!1,n.column??1).catch(t=>Ds(`打不开「${e.name}」:${t instanceof Error?t.message:`文件不可用`}`,`error`))}}}},ks=Os(R?.workspaceId,R?.cwd),As=async e=>{if(!e){r(!1);try{window.localStorage.setItem(`super-pi.browser-notifications`,`disabled`)}catch{}}else if(typeof window>`u`||typeof Notification>`u`&&!window.superPiDesktop?.notifications)a(`unsupported`);else if(!window.isSecureContext&&!window.superPiDesktop?.notifications)a(`insecure`);else try{let e=await Ni();a(e);let t=e===`granted`||e===`native`;r(t);try{window.localStorage.setItem(`super-pi.browser-notifications`,t?`enabled`:`disabled`)}catch{}}catch{a(Mi()),r(!1),Ds(`请求浏览器通知权限失败,请检查站点权限后重试。`,`error`)}};(0,u.useEffect)(()=>{let e=()=>{for(let e of l.current.values())e.close();l.current.clear()},t=()=>{if(a(Mi()),document.visibilityState===`visible`&&document.hasFocus()){e();try{window.localStorage.setItem(`super-pi.browser-notification-focus`,String(Date.now()))}catch{}}},n=t=>{t.key===`super-pi.browser-notification-focus`&&e()};window.addEventListener(`focus`,t);let r=!1,i;return navigator.permissions?.query&&navigator.permissions.query({name:`notifications`}).then(e=>{r||(i=e,e.addEventListener(`change`,t),t())}).catch(()=>{}),window.addEventListener(`storage`,n),document.addEventListener(`visibilitychange`,t),()=>{r=!0,i?.removeEventListener(`change`,t),window.removeEventListener(`focus`,t),window.removeEventListener(`storage`,n),document.removeEventListener(`visibilitychange`,t),e()}},[]),(0,u.useEffect)(()=>{let e=R?.id,t=R?.agentNotice;e&&t&&!ei.current.has(e)&&(ei.current.add(e),Ds(t,`info`))},[R?.id,R?.agentNotice]);let js=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},Ms=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},Ns=(e,t)=>{if(t.method===`notify`)Ds(t.message||t.title,t.notifyType??`info`);else if(t.blocking||t.method===`setStatus`||t.method===`setWidget`||t.method===`setTitle`){let n=e=>e.blocking?e.requestId:e.statusKey??e.widgetKey??``,r=t.method===`setStatus`&&t.statusText===void 0||t.method===`setWidget`&&t.widgetLines===void 0||t.method===`setTitle`&&!t.title;dn(i=>{let a=i.filter(r=>r.conversationId!==e||r.request.method!==t.method||n(r.request)!==n(t));return r?a:[...a,{conversationId:e,request:t}]})}else t.method===`set_editor_text`&&e===Zr.current&&Gi(t.text??``)},Ps=(e,t,n)=>{dn(n=>n.filter(n=>!(n.conversationId===e&&n.request.blocking&&n.request.requestId===t)));let r=kD[n];r&&Ds(r,`warning`)};(0,u.useEffect)(()=>{let e=!1;return(()=>{if(e)return;let t=new Ne(Zr.current);Fe.current=t,t.onopen=()=>{if(!e){j(!0);for(let e of[{type:`stream.configure`,coalesce:!0},{type:`catalog.fetch`,conversationId:Zr.current},...ki.current?[{type:`prompt.catalog.fetch`,workspaceId:ki.current}]:[],{type:`catalog.fetchAll`},{type:`agent.catalog.fetch`},{type:`subagent.catalog.fetch`}])t.canSend(e)&&t.send(JSON.stringify(e))}},t.onserveropen=e=>{for(let n of m.current)n.retry&&n.command&&n.serverId===e&&t.canSend(n.command)&&t.send(JSON.stringify({...n.command,operationRequestId:n.id}))},t.ondisconnect=t=>{if(e)return;let n=PT(m.current.filter(e=>e.serverId===t));for(let e of n.failed)e.onFailure?.(`${pe(t)} 连接中断`);m.current=m.current.filter(e=>!n.failed.includes(e)),p(m.current),Ds(`${pe(t)} 连接中断,正在自动重连。`,`warning`)},t.onmessage=({data:t})=>{if(e)return;let n=JSON.parse(t);if(n.type===`group.activity`)ct(n);else if(n.type!==`message.delta`&&n.type!==`message.thinking`&&Rt(),n.type===`message.accepted`){Vf(n.conversationId,n.clientId);for(let e of m.current)e.command?.conversationId===n.conversationId&&e.command?.clientId===n.clientId&&(e.receipt=!0)}else if(n.type===`exec.output`){let e=Nt.current.get(n.sessionId),t=e?.raw??e?.text??``,r=n.offset===void 0?void 0:n.offset-n.data.length;if(!n.replace&&e?.offset!==void 0&&n.offset!==void 0&&n.offset<=e.offset)return;let i=e&&(r===void 0||e.offset!==void 0&&e.offset>=r),a=r!==void 0&&e?.offset!==void 0?Math.max(0,e.offset-r):0,o=(n.replace||!i?n.data:t+n.data.slice(a)).slice(-KE),s=qE(o);Nt.current.delete(n.sessionId),Nt.current.set(n.sessionId,{text:s.slice(-KE),raw:o,offset:n.offset,truncated:n.offset===void 0?n.truncated||o.length>128e3:n.offset>o.length}),Nt.current.size>64&&Nt.current.delete(Nt.current.keys().next().value),window.dispatchEvent(new CustomEvent(`super-pi-exec-output`,{detail:n.sessionId}))}else if(n.type===`run.stopping`)Or(e=>{let t=new Set(e);return t.add(n.conversationId),t});else if(n.type!==`exec.exit`){if(n.type.startsWith(`terminal.`))Pt.current?.(n);else if(n.type===`conversation.autoRename.result`){let e=Nr.current.get(n.conversationId);e&&(Nr.current.delete(n.conversationId),n.ok?e.resolve(n.title):e.reject(Error(n.error)))}else if(n.type===`message.thinking`)zt(n);else if(n.type===`state`){Rt(),Qr.current=!1;let e=Zr.current,t=!!(e&&ti.current.has(e)),r=!(!e||n.state.conversations.some(t=>t.id===e)),i=t&&r&&e&&ni.current.has(e)?{...n.state,conversations:[ni.current.get(e),...n.state.conversations]}:n.state;e&&!r&&(ti.current.delete(e),ni.current.delete(e)),m.current=m.current.filter(e=>!e.accepted?.(i)||i.sendReceipts&&e.retry&&!e.receipt?!0:(e.retry&&typeof e.command?.conversationId==`string`&&typeof e.command.clientId==`string`&&Vf(e.command.conversationId,e.command.clientId),!1)),p(m.current),Or(e=>{let t=new Set(e);for(let e of[...t]){let n=i.conversations.find(t=>t.id===e);(!n||n.status!==`running`&&n.status!==`waiting`)&&t.delete(e)}return t}),i.extensionUi&&dn(i.extensionUi),i.stoppingConversationIds&&Or(new Set(i.stoppingConversationIds)),d(i),Ee(!0),j(!0);let a=m.current.filter(e=>e.key===`create-workspace`).map(e=>e.temporaryId);k(e=>{if(!e&&er.current)return;if(e&&(P(e)||i.workspaces.some(t=>t.id===e)||a.includes(e)))return e;let t=_.current?.workspaceId;return t&&i.workspaces.some(e=>e.id===t)?t:i.workspaces[0]?.id})}else if(n.type===`message.delta`)zt(n);else if(n.type===`queue.withdrawn`){mi(e=>[...e.filter(e=>e.conversationId!==n.conversationId).slice(-9),{id:`withdrawn_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,conversationId:n.conversationId,actor:n.actor,withdrawn:n.withdrawn}]);let e=n.withdrawn.slice(0,2).map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,24)}」`).join(`、`),t=n.actor===`agent`?`上级 Agent 已撤回`:`已撤回`;Ds(`${t} ${n.withdrawn.length} 条排队消息:${e}${n.withdrawn.length>2?`…`:``}`,`info`)}else if(n.type===`message.revert.result`)Dl(void 0),Er(void 0),n.ok||(console.error(`[Super Pi Error] revert failed:`,n.message),te(n.message));else if(n.type===`operation.result`){let e=m.current.find(e=>e.id===n.requestId),t=e?.retry?e.command:void 0;if(t&&Vf(t.conversationId,t.clientId),m.current=m.current.filter(e=>e.id!==n.requestId),p(m.current),e?.temporaryId){let t=e.temporaryId;if(e.key===`create-workspace`&&n.ok&&n.entityId){let r=n.entityId;d(n=>{if(n.workspaces.some(e=>e.id===r))return n;let i=e.apply(n).workspaces.find(e=>e.id===t);return i?{...n,workspaces:[...n.workspaces,{...i,id:r}]}:n})}else if(n.ok&&n.entityId){let e=n.entityId,r=ri.current.get(t);if(r&&ni.current.set(e,{...r,id:e}),ti.current.add(e),r){let t={...r,id:e};d(n=>n.conversations.some(t=>t.id===e)?n:{...n,conversations:[t,...n.conversations]})}Fr(n=>{let r=n[t];if(!r)return n;let i=n[e],a={...n};return a[e]=i?{...i,text:r.text||i.text,images:r.images.length?r.images:i.images,attachments:r.text?r.attachments:i.attachments,pendingSkills:r.text?r.pendingSkills:i.pendingSkills,uploading:r.uploading+i.uploading}:r,delete a[t],a}),ri.current.delete(t)}D(r=>r===t?n.ok?n.entityId:e.previousActiveId:r),ie(e=>fk(e,t,n.ok&&n.entityId?n.entityId:void 0)),k(r=>r===t?n.ok?n.entityId:e.previousWorkspaceId:r),!n.ok&&e.key===`create-workspace`&&ki.current===t&&D(t=>t??e.previousActiveId)}if(!n.ok){if(console.error(`[Super Pi Error] operation failed:`,n.message),!e?.receipt){if(e?.onFailure)e.onFailure(n.message);else if(t){let e=t.images??[],r=UD(t.content,t.attachments);Br(i=>[...i,{id:t.clientId,conversationId:t.conversationId,content:t.content,images:e,attachments:r,reason:n.message}]),Ui(t.conversationId,n=>n.text||n.images.length||n.attachments.length?n:{...n,text:t.content,images:e,attachments:r})}}let r=n.message??`操作失败`;te(r),e?.onFailure||Ds(Ht(r),`error`)}}else n.type===`tools.updated`?window.dispatchEvent(new Event(`super-pi-tools-updated`)):n.type===`files.changed`?(La.current(n.workspaceId,n.changes,n.dropped),n.workspaceId===za.current&&Ia.current()):n.type===`files.invalidated`?(Ra.current(n.workspaceId,n.paths),n.workspaceId===za.current&&Ia.current()):n.type===`error`?(console.error(`[Super Pi Error]`,n.message),te(n.message),Ds(Ht(n.message),`error`),Qr.current&&=!1):n.type===`extension.ui`?Ns(n.conversationId,n.request):n.type===`extension.ui.closed`?Ps(n.conversationId,n.requestId,n.reason):n.type===`model.catalog`?n.conversationId&&n.conversationId!==Zr.current||hn(n.catalog):n.type===`model.catalog.all`?_n(n.catalog):n.type===`providers.list`?(bn(n.providers),Sn(n.apis)):n.type===`agent.catalog`?((n.sourceServerId??ce())===ce()&&wn(n.catalog),(n.sourceServerId??ce())===le()&&An(n.catalog)):n.type===`prompt.catalog`?ln(n.catalog):n.type===`subagent.catalog`?((n.sourceServerId??ce())===ce()&&En(n.catalog),(n.sourceServerId??ce())===le()&&Mn(n.catalog)):n.type===`server.version`?On(n.version):n.type===`subagent.event`?d(e=>({...e,subagentRuns:js(e.subagentRuns??[],n.run)})):n.type===`workflow.event`?d(e=>({...e,workflows:Ms(e.workflows??[],n.workflow)})):n.type===`message.tools`?d(e=>({...e,conversations:e.conversations.map(e=>e.id===n.conversationId?{...e,messages:e.messages.map(e=>e.id===n.messageId?{...e,toolCalls:n.toolCalls}:e)}:e)})):n.type===`conversation.fork.result`&&(Fl(e=>e===n.conversationId?void 0:e),Ds(n.ok?`已从「${n.title}」分叉出新会话,放在侧边栏最上面;没有切换过去。${n.messagesCopied?`复制了 ${n.messagesCopied} 条消息。`:`原会话还没有消息,只复制了会话本身。`}`:`分叉失败:${Ht(n.message)}`,n.ok?`info`:`error`))}}})(),()=>{e=!0,Rt();for(let e of Xr.current)window.clearTimeout(e);Fe.current?.close()}},[zt,Rt,ct]);let Fs=(0,u.useCallback)(e=>{if(!Fe.current?.canSend(e))return!1;try{return Fe.current.send(JSON.stringify(e)),!0}catch(e){return Ds(e instanceof Error?e.message:`服务器未连接`,`error`),!1}},[]),Is=(0,u.useCallback)(e=>{ve({id:e,ticket:++ge.current});let t=Zr.current;t?.startsWith(`pending:`)||Fs({type:`state.subscribe`,...t?{conversationId:t}:{}}),Vn()},[Fs,Vn]);(0,u.useEffect)(()=>{if(!_e)return;if(_e.ticket!==ge.current){ve(void 0);return}let e=si.find(e=>e.id===_e.id);e&&T.workspaces.some(t=>t.id===e.workspaceId)&&(ve(void 0),pa(e.id),k(e.workspaceId))},[_e,si,T.workspaces,pa]),(0,u.useEffect)(()=>{if(!N)return;let e=R?.id;e?.startsWith(`pending:`)||Fs({type:`state.subscribe`,...e?{conversationId:e}:{}})},[R?.id,N,Fs]);let Ls=(e,t,n,r,i,a,o)=>{let s=Fe.current?.canSend(e)===!0,c=NT(e);if(m.current.some(e=>e.key===t)||!s&&!c)return!1;if(c&&!Bf(e))return Ds(`浏览器无法保存待发消息,正文仍在输入框。`,`error`),!1;let l=ur(),u=C(e),d=[...u][0]??e._server??ce(),f={id:l,key:t,serverId:d,apply:e=>u.size||ce()===d?n(e):e,temporaryId:r,previousActiveId:Zr.current,previousWorkspaceId:ki.current,onFailure:i,accepted:a,...o?{expiresAt:Date.now()+o}:{},...c?{retry:!0,command:e}:{}};return m.current=[...m.current,f],p(m.current),s&&Fe.current.send(JSON.stringify({...e,operationRequestId:l})),!0},Rs=e=>Fs({...e,_server:le()}),zs=(e,...t)=>Ls({...e,_server:le()},...t),Bs=(e,t)=>{Fs({type:`conversation.childLock`,conversationId:e,unlocked:t})||Ds(t?`连接断开,这个子会话没有解锁,请重试`:`连接断开,这个子会话没有上锁,请重试`,`error`)},Vs=e=>{if(!e)return;let t=`message_${ur()}`;Ls({type:`message.send`,conversationId:e,content:vD,clientId:t},`continue-truncated:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===e?{...t,warning:void 0}:t)}),void 0,void 0,void 0)};(0,u.useEffect)(()=>{let e=f.flatMap(e=>e.expiresAt?[e.expiresAt]:[]);if(!e.length)return;let t=window.setTimeout(()=>{let e=m.current.filter(e=>e.expiresAt&&e.expiresAt<=Date.now());if(e.length){m.current=m.current.filter(t=>!e.includes(t)),p(m.current);for(let t of e)t.onFailure?.(`打断请求超时,尚未确认是否开始回答;请检查会话状态后重试`)}},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[f]);let Hs=(e,t)=>n=>({...n,conversations:n.conversations.map(n=>n.id===e?{...n,...t}:n)}),X=(e,t)=>n=>({...n,workspaces:n.workspaces.map(n=>n.id===e?{...n,...t}:n)}),Us=R?.id.startsWith(`pending:`)===!0,Ws=!!(R&&pO(R)&&(Dr.has(R.id)||f.some(e=>e.key===`stop:${R.id}`))),Gs=R?.messagesLoaded===!1||f.some(e=>e.key.startsWith(`send:${R?.id}:`)||e.key===`configuration:${R?.id}`||e.temporaryId===R?.id||e.key===`archive:${R?.id}`),Ks=(e,t,n,r,i)=>{e&&Fs({type:`question.answer`,conversationId:e,messageId:t,callIndex:n,answers:r,cancelled:i})},qs=(e,t)=>Sr(n=>({...n,[e]:t})),Js=(e,t,n)=>(fa(e),Ls({type:`extension.ui.answer`,conversationId:e,requestId:t,...n},`answer:${e}:${t}`,e=>e)),Ys=R?.model??mn?.defaultModel,Xs=R?.thinkingLevel??mn?.defaultThinkingLevel,Zs=Xs&&mn?.levels.includes(Xs)?Xs:void 0,Qs=mn?.source===`pi`,$s=mn?.models.find(e=>e.provider===Ys?.provider&&e.modelId===Ys?.modelId),ec=!!$s?.imageInput,tc=(e,t)=>!e||!t?e:{...e,models:e.models.filter(e=>(T.modelFilterRules??[]).every(n=>{try{let r=new RegExp(n.workspacePattern,`i`),i=[t.name,t.path,t.worktreeProjectPath].filter(e=>!!e).some(e=>r.test(e.replaceAll(`\\`,`/`))),a=new RegExp(n.modelPattern,`i`);return!i||a.test(e.label)||a.test(`${e.provider}/${e.modelId}`)}catch{return!0}}))},nc=!!R?.messages?.some(e=>e.images&&e.images.length>0),rc=tc(mn,T.workspaces.find(e=>e.id===R?.workspaceId))?.models??[],ic=nc?rc.filter(e=>e.imageInput):rc,ac=ic.map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,UE(e.contextWindow)?`${UE(e.contextWindow)} 上下文`:``,WE(e.maxTokens)?`${WE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:CD(e),selected:Ys?.provider===e.provider&&Ys.modelId===e.modelId})),oc=(mn?.levels??[]).map(e=>({key:e,label:e,selected:e===Xs})),sc=e=>{if(!R)return;let[t,n]=e.split(`/`);t&&n&&(fa(R.id),Ls({type:`conversation.model`,conversationId:R.id,provider:t,modelId:n},`configuration:${R.id}`,Hs(R.id,{model:mn?.models.find(e=>e.provider===t&&e.modelId===n)??{provider:t,modelId:n,label:n}})))},cc=e=>{R&&(fa(R.id),Ls({type:`conversation.thinking`,conversationId:R.id,level:e},`configuration:${R.id}`,Hs(R.id,{thinkingLevel:e})))},lc=Cn?.agents.find(e=>e.id===R?.agentId),uc=[{key:iO,label:`跟随 Pi 默认`,detail:`不使用任何 agent 角色`,selected:!R?.agentId},...(Cn?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:R?.agentId===e.id}))],dc=lc?.model,fc=!!(dc&&R?.model&&R.model.provider===dc.provider&&R.model.modelId===dc.modelId);lc?.thinkingLevel&&(R?.thinkingLevel,lc.thinkingLevel);let pc=e=>{if(R){let t=Cn?.agents.find(t=>t.id===e);Ls({type:`conversation.agent`,conversationId:R.id,agentId:e===iO?null:e},`configuration:${R.id}`,Hs(R.id,{agentId:t?.id,...t?.model?{model:{...t.model,label:t.model.modelId}}:{},...t?.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}}))}},mc=Pn.filter(e=>e.conversationId===R?.id),hc=(0,u.useMemo)(()=>{let e=R?.id;return e?(R.messages??[]).flatMap(t=>(t.toolCalls??[]).flatMap((n,r)=>n.question?.status===`pending`?[{key:XD(e,t.id,r),messageId:t.id,index:r,value:n.question}]:[])):[]},[R?.id,R?.messages]),gc=hc[0],_c=()=>{let e=gc;e&&(wr(e.key),nt(`session`),window.setTimeout(()=>{(Tt.current?.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`))?.scrollIntoView({block:`center`,behavior:`smooth`})},0))},vc=un.filter(e=>e.conversationId===R?.id).map(e=>e.request),yc=new Map(vc.filter(e=>e.method===`setStatus`).map(e=>[e.statusKey??``,e.statusText??``])),bc=new Map(vc.filter(e=>e.method===`setWidget`).map(e=>[e.widgetKey??``,{lines:e.widgetLines??[],placement:e.widgetPlacement??`aboveEditor`}])),xc=vc.find(e=>e.method===`setTitle`)?.title,Sc=(0,u.useMemo)(()=>(T.subagentRuns??[]).filter(e=>e.conversationId===R?.id),[T.subagentRuns,R?.id]),Cc=(0,u.useMemo)(()=>(T.workflows??[]).filter(e=>e.conversationId===R?.id),[T.workflows,R?.id]),wc=(0,u.useMemo)(()=>new Map(Cc.map(e=>[e.id,e])),[Cc]),Tc=(0,u.useMemo)(()=>new Map((Tn?.agents??[]).map(e=>[e.id,e.name])),[Tn]),Ec=(0,u.useMemo)(()=>new Map((R?.messages??[]).map(e=>[e.id,e])),[R?.messages]),Dc=(0,u.useMemo)(()=>new Map(Sc.map(e=>[e.id,e])),[Sc]),Oc=(0,u.useMemo)(()=>{let e=new Map;for(let t of Sc)t.originMessageId!==void 0&&t.originCallRow!==void 0&&e.set(`${t.originMessageId}:${t.originCallRow}`,t);return e},[Sc]),kc=(0,u.useMemo)(()=>{if(!R||!da)return[];let e=Tr?.conversationId===R.id?(()=>{let e=R.messages.find(e=>e.id===Tr.messageId);if(e)return{index:R.messages.indexOf(e),at:Date.parse(e.createdAt)||0,...Tr.kind===`withdraw`?{inclusive:!0}:{inclusive:!1}}})():void 0,t=[];return R.messages.forEach((n,r)=>{e&&(r>e.index||e.inclusive&&r===e.index)||n.delivery||t.push({at:Date.parse(n.createdAt)||0,seq:r,key:`m:${n.id}`})}),Sc.forEach((n,r)=>{n.originMessageId&&n.originCallRow!==void 0&&R?.messages.some(e=>e.id===n.originMessageId&&e.toolCalls?.[n.originCallRow])||e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`r:${n.id}`})}),Cc.forEach((n,r)=>{e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`w:${n.id}`})}),Di(t)},[R,Sc,Cc,Tr]),Ac=(0,u.useMemo)(()=>{for(let e=kc.length-1;e>=0;--e){let t=kc[e];if(t.startsWith(`m:`)&&Ec.get(t.slice(2))?.role===`user`)return t.slice(2)}},[kc,Ec]);(0,u.useEffect)(()=>{let e=Tt.current;if(!e||!R?.id)return;let t=()=>{!Mt.current&&Ie.current[R.id]?.followTail&&(ok(e),e.scrollTop=e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return()=>n.disconnect()},[R?.id,R?.messages,Sc,Cc,da,kc,et]);let jc=e=>gr(t=>({...t,[e]:!t[e]})),Mc=(e,t)=>vr(n=>({...n,[`${e}:${t}`]:!n[`${e}:${t}`]})),Nc=(e,t)=>br(n=>({...n,[`${e}:${t}`]:n[`${e}:${t}`]!==!1})),[Pc,Fc]=(0,u.useState)({}),Ic=e=>Fc(t=>({...t,[e]:t[e]!==!0})),Lc=e=>{Ls({type:`subagent.stop`,runId:e},`stop:${e}`,e=>e)||Ds(`连接断开,无法停止子智能体,请重试`,`error`)},Rc=e=>{Ls({type:`workflow.stop`,workflowId:e},`stop:${e}`,e=>e)||Ds(`连接断开,无法停止编排,请重试`,`error`)},zc=e=>[...bc].filter(([,t])=>t.placement===e).map(([e,t])=>{let n=t.lines;return(0,L.jsxs)(`div`,{className:`extui-widget`,"data-widget-key":e,"data-widget-lines":n.length,children:[n.slice(0,AD).map((e,t)=>(0,L.jsx)(`div`,{children:e},`${t}:${e}`)),n.length>AD&&(0,L.jsx)(`div`,{children:`… (widget truncated)`})]},e)}),Bc=(e,t)=>{let n=`pending:${ur()}`,r={id:n,name:e,path:t,updatedAt:new Date().toISOString()};Ls({type:`workspace.create`,name:e,path:t},`create-workspace`,e=>({...e,workspaces:[...e.workspaces,r]}),n)&&(ha(n),Ae(!1))},[Vc,Hc]=(0,u.useState)(),Uc=(e,t)=>Hc(n=>n?.kind===e&&n.id===t?n:{kind:e,id:t}),Wc=()=>Hc(void 0),Gc=(e,t)=>Vc?.kind===e&&Vc.id===t,Kc=(e,t,n)=>!t.startsWith(`pending:`)&&(e===`conversation`&&fa(t),Ls(e===`workspace`?{type:`workspace.rename`,workspaceId:t,name:n}:{type:`conversation.rename`,conversationId:t,name:n},`rename:${t}`,e===`workspace`?X(t,{name:n}):Hs(t,{title:n}))?(Qr.current=!0,Wc(),!0):(Ds(`连接断开,改名未保存,请重试`,`error`),!1)),qc=async e=>{if(e.startsWith(`pending:`)){Ds(`这个会话还在创建中,稍后再试`,`warning`);return}if(Nr.current.has(e))return;Ds(`正在根据对话内容生成标题…`,`info`);let t=new Promise((t,n)=>{Nr.current.set(e,{resolve:t,reject:n}),window.setTimeout(()=>{Nr.current.delete(e)&&n(Error(`模型在 ${Math.round(YE/1e3)} 秒内没有返回标题`))},YE)});if(!Fs({type:`conversation.autoRename`,conversationId:e}))Nr.current.delete(e),Ds(`连接断开,无法生成标题`,`error`);else try{let n=await t;Kc(`conversation`,e,n),Ds(`已重命名为「${n}」`,`info`)}catch(e){Ds(`重命名失败:${Ht(e)}`,`error`)}},Jc=e=>{if(e.id.startsWith(`pending:`))return;let t=T.conversations.filter(t=>t.workspaceId===e.id).length;window.confirm(`从列表移除工作区「${e.name}」?${t?`其中的 ${t} 条会话会保留,`:``}重新添加同一个目录即可恢复,不会删除任何会话。`)&&(Xc(void 0),Ls({type:`workspace.delete`,workspaceId:e.id},`delete:${e.id}`,t=>({...t,workspaces:t.workspaces.filter(t=>t.id!==e.id),conversations:t.conversations.filter(t=>t.workspaceId!==e.id)})))},[Yc,Xc]=(0,u.useState)(),[Zc,Qc]=(0,u.useState)(!1),$c=Yc?T.workspaces.find(e=>e.id===Yc):void 0,{theme:el,setTheme:tl}=Th(),[nl,rl]=(0,u.useState)(!1),[il,al]=(0,u.useState)();(0,u.useEffect)(()=>{let e=()=>{de(),ue(`entry`),al(`servers`),rl(!0)};return window.addEventListener(`super-pi-open-server-management`,e),()=>window.removeEventListener(`super-pi-open-server-management`,e)},[]);let[ol,sl]=(0,u.useState)(!1),cl=(e,t,n,r)=>{e.startsWith(`pending:`)||(Ls({type:`workspace.settings`,workspaceId:e,model:n?{provider:n.provider,modelId:n.modelId}:null,thinkingLevel:r??null,agentId:t??null},`defaults:${e}`,X(e,{defaultModel:n,defaultThinkingLevel:r,defaultAgentId:t}))?Xc(void 0):Ds(`连接断开,设置未保存,请重试`,`error`))},ll=(e,t)=>{let n=M.activeServer;Ls({type:`workspaces.settings.bulk`,model:e?{provider:e.provider,modelId:e.modelId}:null,thinkingLevel:t??null},`workspace-defaults-bulk`,r=>({...r,workspaces:r.workspaces.map(r=>{if(h(r.id).server!==n||r.closedAt||r.id.startsWith(`pending:`))return r;let i={...r};return e?i.defaultModel=e:delete i.defaultModel,t?i.defaultThinkingLevel=t:delete i.defaultThinkingLevel,i})}))?Qc(!1):Ds(`连接断开,批量设置未保存,请重试`,`error`)},ul=(e,t=``)=>{if(e.startsWith(`pending:`))return;if(m.current.some(t=>t.key===`defaults:${e}`)){Ds(`工作区设置正在保存,请稍后再新建会话`,`warning`);return}let n=`pending:${ur()}`,r={id:n,workspaceId:e,title:`新会话`,status:`idle`,updatedAt:new Date().toISOString(),messages:[],...t?{cwd:t}:{}};ri.current.set(n,r),Ls({type:`conversation.create`,workspaceId:e,...t?{cwd:t}:{}},`create-session:${e}:${n}`,e=>({...e,conversations:[r,...e.conversations]}),n)?(ge.current++,k(e),D(n),nt(`session`),ie(e=>({...e,ids:[...e.ids.filter(e=>e!==n),n],touched:dk(e.touched,n)}))):(ri.current.delete(n),Ds(`连接断开,会话未创建,请重试`,`error`))},dl=e=>{if(e.startsWith(`pending:`))return;let t=T.conversations.find(t=>t.id===e);if(!t||t.archivedAt||t.parentConversationId&&T.conversations.some(e=>e.id===t.parentConversationId))return;let n=pD(T.conversations,e),r=n.filter(e=>!e.archivedAt),i=r.length-1,a=n.length-r.length,o=GE(T.pendingUserDecisionsByConversation,n.map(e=>e.id)),s=XE({title:t.title,activeCount:r.length,activeDescendants:i,alreadyArchived:a,pendingDecisions:o});if(ZE({activeDescendants:i,pendingDecisions:o})&&!window.confirm(s))return;let c=new Date().toISOString(),l=new Set(r.map(e=>e.id));Ls({type:`conversation.archive`,conversationId:e},`archive:${e}`,e=>({...e,conversations:e.conversations.map(e=>l.has(e.id)&&!e.archivedAt?{...e,archivedAt:c}:e)}))},fl=(e,t)=>Ls({type:`conversation.collapse`,conversationId:e,collapsed:t},`collapse:${e}`,n=>{let r=new Set(n.collapsedConversationIds??[]);t?r.add(e):r.delete(e);let i={...n};return r.size===0?delete i.collapsedConversationIds:i.collapsedConversationIds=[...r],i}),pl=e=>{let t=T.conversations.find(t=>t.id===e);if(!t?.archivedAt||(t.parentConversationId?T.conversations.find(e=>e.id===t.parentConversationId):void 0)?.archivedAt)return;let n=new Set(pD(T.conversations,e).filter(e=>e.archivedAt).map(e=>e.id));Ls({type:`conversation.unarchive`,conversationId:e},`unarchive:${e}`,e=>({...e,conversations:e.conversations.map(e=>{if(!n.has(e.id)||!e.archivedAt)return e;let t={...e};return delete t.archivedAt,t})}))},ml=async e=>{if(!R){Ds(`请先选择或创建会话`,`error`);return}if(!ec){Ds(`当前模型不支持图片输入`,`error`);return}let t=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],n=e.filter(e=>t.includes(e.type)?e.size>5242880?(Ds(`图片「${e.name}」超过 5MB 上限`,`error`),!1):!0:(Ds(`不支持的文件格式「${e.name}」,仅支持 PNG/JPEG/GIF/WebP`,`error`),!1));if(n.length===0)return;let r=R.id;Ui(r,e=>({...e,uploading:e.uploading+n.length}));let i=n.map(e=>({id:ur(),conversationId:r,name:e.name,url:URL.createObjectURL(e)}));Hr(e=>[...e,...i]);for(let[e,t]of n.entries()){let n=i[e];try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>{let t=r.result,n=t.indexOf(`,`);e(n>=0?t.slice(n+1):t)},r.onerror=n,r.readAsDataURL(t)}),i=await ke(`/api/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({conversationId:r,name:t.name,mimeType:t.type,data:e})});if(!(i.headers.get(`content-type`)??``).includes(`application/json`)){Ds(`服务器未返回 JSON 响应,请刷新或重启服务`,`error`);continue}if(i.ok){let e=await i.json();if(Rr.current.has(n.id))continue;Hr(e=>e.filter(e=>e.id!==n.id)),URL.revokeObjectURL(n.url),Ui(r,t=>({...t,images:[...t.images,{id:g(se(r),e.id),name:e.name,mimeType:e.mimeType,bytes:e.bytes}]}))}else{let e=await i.json().catch(()=>({error:`上传失败`}));Ds(Ht(e.error,`上传失败(HTTP ${i.status})`),`error`)}}catch(e){Ds(`上传失败:${Ht(e,`网络或服务暂时不可用`)}`,`error`)}finally{Hr(e=>e.map(e=>e.id===n.id?{...e,failed:!0}:e)),Ui(r,e=>({...e,uploading:Math.max(0,e.uploading-1)}))}}},hl=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.type.startsWith(`image/`)){let e=r.getAsFile();e&&n.push(e)}}if(n.length>0){if(!ec){Ds(`当前模型不支持图片输入`,`error`);return}e.preventDefault(),ml(n)}},gl=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),Kr(!0))},_l=e=>{e.currentTarget.contains(e.relatedTarget)||Kr(!1)},vl=e=>{Kr(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>e.type.startsWith(`image/`));if(t.length>0){if(e.preventDefault(),!ec){Ds(`当前模型不支持图片输入`,`error`);return}ml(t)}},yl=t=>{if(t.preventDefault(),!R)return;if(_i){Ds(Qe,`warning`);return}if(Gs){Ds(Us?`会话正在创建,请稍候再发送`:R.messagesLoaded===!1?`正在加载会话,请稍候再发送`:`正在保存配置,请稍候再发送`,`info`);return}if(!Ri.trim()&&zi.length===0)return;if(zi.length>0&&!ec){Ds(`当前模型不支持图片输入,请移除图片或切换至支持图文的模型`,`error`);return}if(Hi>0){Ds(`图片正在上传中,请稍候…`,`info`);return}if(Vi){Ds(`技能正在读取中,请稍候…`,`info`);return}let n=`message_${ur()}`,r=R.id,i=Ri,a=zi,o=Bi;fa(r),e.stoppingConversationIds||Or(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t});let s=WD({conversationId:r,content:i,clientId:n,images:a,attachments:o,inFlight:pO(R),deliveryMode:ui}),c=new Date().toISOString();Ls(s,`send:${r}:${n}`,e=>Uf(e,s,c),n,e=>{Br(t=>[...t,{id:n,conversationId:r,content:i,images:a,attachments:o,reason:e}]),Ui(r,e=>e.text||e.images.length||e.attachments.length?e:{...e,text:i,images:a,attachments:o})},e=>!!e.conversations.find(e=>e.id===r)?.messages.some(e=>e.id===Hf(s)))&&Ui(r,e=>({...e,text:``,images:[],attachments:[],pendingSkills:void 0}))},bl=(0,u.useMemo)(()=>(R?.messages??[]).filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),[R?.messages]),xl=e=>{Ls({type:`message.cancel`,conversationId:R?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===R?.id?{...t,messages:t.messages.filter(t=>t.id!==e)}:t)}))||Ds(`连接断开,撤回没有生效,请重试`,`error`)},Sl=e=>{if(!R?.id||!e.length)return;let t=new Set(e),n=`queue-many:${R.id}:${e.join(`,`)}`;Ls({type:`message.cancelMany`,conversationId:R.id,messageIds:e},n,e=>({...e,conversations:e.conversations.map(e=>e.id===R.id?{...e,messages:e.messages.filter(e=>!t.has(e.id))}:e)}),void 0,e=>Ds(e??`撤回所选消息失败,请重试`,`error`),t=>{let n=t.conversations.find(e=>e.id===R.id);return!!(n&&e.every(e=>!n.messages.some(t=>t.id===e&&t.delivery)))})||Ds(`连接断开,批量撤回没有生效,请重试`,`error`)},Cl=e=>{Ls({type:`message.steer`,conversationId:R?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===R?.id?{...t,messages:eD(t.messages,e,0)}:t)}),void 0,void 0,t=>t.conversations.find(e=>e.id===R?.id)?.messages.find(t=>t.id===e)?.delivery===`sending`)||Ds(`连接断开,插到最前没有生效,请重试`,`error`)},wl=e=>{let t=R?.id;t&&(Fe.current?.readyState===WebSocket.OPEN?Ls({type:`message.interrupt`,conversationId:t,messageId:e},`interrupt:${t}:${e}`,e=>e,void 0,e=>Ds(e??`打断失败,请重试`,`error`),n=>{let r=n.conversations.find(e=>e.id===t)?.messages.find(t=>t.id===e);return!(!r||r.delivery)},3e4)||Ds(`正在打断,请稍候`,`info`):Ds(`连接断开,打断没有生效,请重试`,`error`))},Tl=e=>{Ls({type:`message.sendQueued`,conversationId:R?.id??``,messageId:e},`send-queued:${e}`,e=>e,void 0,void 0,t=>!t.conversations.find(e=>e.id===R?.id)?.messages.find(t=>t.id===e)?.delivery)||Ds(`连接断开,发送没有生效,请重试`,`error`)},Z=(e,t)=>{Ls({type:`message.edit`,conversationId:R?.id??``,messageId:e,content:t},`edit:${e}`,n=>({...n,conversations:n.conversations.map(n=>n.id===R?.id?{...n,messages:n.messages.map(n=>n.id===e?{...n,content:t}:n)}:n)}))||Ds(`连接断开,修改没有生效,请重试`,`error`)},[El,Dl]=(0,u.useState)(),Ol=(e,t=!1)=>{if(!R||R.messagesLoaded===!1||El)return;let n=R.messages.find(t=>t.id===e);n&&(n&&Fr(e=>{let t=e[R.id]??{text:``,images:[],attachments:[],uploading:0};return t.text.trim()||t.images.length||t.attachments.length?e:{...e,[R.id]:{...t,text:n.content,images:n.images??[],attachments:UD(n.content,n.attachments)}}}),Er({conversationId:R.id,messageId:e,kind:t?`withdraw`:`revert`})),Fs({type:`message.revert`,conversationId:R.id,messageId:e,withdraw:t})?Dl(e):(Er(void 0),Ds(`连接断开,回退未执行,请重试`,`error`))},[kl,Al]=(0,u.useState)(),jl=(0,u.useRef)(void 0),Ml=(0,u.useRef)(0),Nl=async(e,t)=>{let n=++Ml.current,r=await vd(t);n===Ml.current&&(clearTimeout(jl.current),Al({id:e,kind:r?`copied`:`error`}),r||Ds(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中这条消息的文字复制`,`error`),jl.current=setTimeout(()=>Al(void 0),2e3))};(0,u.useEffect)(()=>()=>{Ml.current+=1,clearTimeout(jl.current)},[]);let[Pl,Fl]=(0,u.useState)(),Il=e=>{Pl||e.startsWith(`pending:`)||(fa(e),Fs({type:`conversation.fork`,conversationId:e})?Fl(e):Ds(`连接断开,分叉没有执行,请重试`,`error`))},Ll=new Map;for(let e of T.scheduledTasks??[])e.conversationId&&!Ll.has(e.conversationId)&&Ll.set(e.conversationId,e);let Rl=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-theme-open":`1`,title:`设置`,"aria-haspopup":`dialog`,"aria-expanded":nl,onClick:()=>{al(void 0),de(),rl(!0),Rs({type:`catalog.fetchAll`}),Rs({type:`providers.fetch`})},children:[(0,L.jsx)(on,{name:`settings`}),(0,L.jsx)(`span`,{className:`workbench-action-label`,children:`设置`})]}),(0,L.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-help-open":`1`,title:`使用指南`,"aria-haspopup":`dialog`,"aria-expanded":ol,onClick:()=>sl(!0),children:[(0,L.jsx)(on,{name:`help`}),(0,L.jsx)(`span`,{className:`workbench-action-label`,children:`使用指南`})]})]}),zl=ba?void 0:R,Bl=ge.current,Vl={onOpenSession:e=>{Bl===ge.current&&Is(e)},todos:T.todosByConversation?.[zl?.id??``]??[],tasks:OO(zl,T.backgroundTasks??[]),backgroundRuns:zl?Dc:void 0,execOutputs:Nt.current,scheduledTasks:(T.scheduledTasks??[]).filter(e=>e.workspaceId===Sa),scheduledCatalog:tc(mn,bs),scheduledAgents:Cn,notify:Ds,serverTimeZone:T.serverTimeZone,workspaceId:Sa,gitWorkspaceId:wa,gitRepositoryOnly:Ea,gitWorkspaceName:xs?.name,workspaceLabel:bs?.path,workspaceName:bs?.name,conversationId:zl?.id,followedWorktreeId:zl?.followedWorktreeId,cwd:Ta,connected:N&&M.statuses.get(M.activeServer)?.state===`online`&&Te&&!zl?.id.startsWith(`pending:`),files:B,onOpenFile:Ho,onOpenChanged:ko,onOpenGitDiff:Eo,activeGitDiffUrl:Co?.target.url,onFileReference:Uo,onFilesMoved:Wo,onSearchFolder:e=>so(`content`,void 0,[Ta,e].filter(Boolean).join(`/`)),onSelectTab:Ka,sendCommand:Fs,registerTerminalSink:Bt,terminalShell:T.terminalShell,sharedGit:V},Hl=e=>M.connections.some(t=>t.id===h(e).server)&&(Kn===`all`||h(e).server===Kn),Ul=new Set(T.workspaces.map(e=>e.id)),Wl=T.workspaces.filter(e=>Hl(e.id)&&(!e.worktreeOf||!Ul.has(e.worktreeOf))),Gl=Wl.flatMap(e=>[e,...T.workspaces.filter(t=>t.worktreeOf===e.id)]),Kl=(0,u.useMemo)(()=>{let e=new Map;for(let t of T.workspaces){if(t.closedAt)continue;let n=t.name.trim().toLowerCase();n&&e.set(n,(e.get(n)??0)+1)}return new Set([...e].filter(([,e])=>e>1).map(([e])=>e))},[T.workspaces]),ql=Jn&&Gl.some(e=>e.id===Jn)?Jn:O&&Gl.some(e=>e.id===O)?O:Gl[0]?.id,Jl=T.workspaces.find(e=>e.id===O),Yl=Jl?.worktreeOf&&Ul.has(Jl.worktreeOf)?Jl.worktreeOf:Jl?.id,Xl=Xn&&Wl.some(e=>e.id===Xn)?Xn:Yl&&Wl.some(e=>e.id===Yl)?Yl:Wl[0]?.id,Zl=Date.now()-18e6,Ql=Gl.filter(e=>e.id===Xl||e.worktreeOf===Xl),$l=e=>{let t=T.conversations.some(t=>t.workspaceId===e&&!t.archivedAt&&(Wn===`recent`?Date.parse(t.updatedAt)>=Zl:t.status===`running`||t.status===`waiting`)),n=(rt[e]?.rooms??[]).some(e=>!e.archivedAt&&(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id]))));return t||n},eu=Wl.flatMap(e=>{let t=Gl.filter(t=>t.worktreeOf===e.id&&$l(t.id));return $l(e.id)||t.length>0?[e,...t]:[]}),tu=Wn===`all`?Gl:Wn===`workspace`?Gl.filter(e=>e.id===ql):Wn===`repo`?Ql:eu,nu=Wn===`all`||Wn===`workspace`||Wn===`repo`,ru=(e,t=Wn,n=ql,r=Xl)=>{if(!e||!Hl(e))return!1;if(t===`all`)return!0;if(t===`workspace`)return e===n;if(t===`repo`)return e===r||Gl.some(t=>t.id===e&&t.worktreeOf===r);let i=T.conversations.filter(t=>t.workspaceId===e&&!t.archivedAt).some(e=>t===`recent`?Date.parse(e.updatedAt)>=Zl:e.status===`running`||e.status===`waiting`),a=(rt[e]?.rooms??[]).some(e=>!e.archivedAt&&(t===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id]))));return i||a},iu=(e,t=ql,n=Xl)=>{Gn(e),t&&Yn(t),n&&Zn(n);let r=et===`group`&&bt&&St?rt[bt]?.rooms.find(e=>e.id===St):void 0,i=et===`group`?!!(bt&&r&&!r.archivedAt&&ru(bt,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(r.updatedAt)>=Zl:[`running`,`queued`].includes(_t(r,st[r.id]))))):!!(R&&!R.archivedAt&&ru(R.workspaceId,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(R.updatedAt)>=Zl:R.status===`running`||R.status===`waiting`)));if(Xo.current=!0,i){e===`workspace`&&k(t);let r=Jo.find(e=>e.id===Yo)?.workspaceId;e!==`recent`&&e!==`running`&&(e!==`workspace`&&e!==`repo`||ru(r,e,t,n))||nt(`session`)}else $n(!0),D(void 0),qe(!1),et===`session`||et===`group`?nt(`session`):e!==`recent`&&e!==`running`&&(e!==`workspace`&&e!==`repo`||ru(Jo.find(e=>e.id===Yo)?.workspaceId,e,t,n))||nt(`session`),k(e===`workspace`?t:void 0)},au=e=>{qn(e),localStorage.setItem(`super-pi.server-filter`,e),e!==`all`&&I(e);let t=et===`group`?bt:R?.workspaceId??O;if(t&&e!==`all`&&h(t).server!==e){Xo.current=!0,$n(!0),D(void 0),qe(!1);let t=T.workspaces.filter(t=>h(t.id).server===e);if(Wn===`workspace`){let e=t.find(e=>e.id===Jn)?.id??t[0]?.id;Yn(e),k(e)}else k(void 0),Wn===`repo`&&Zn(t.find(e=>!e.worktreeOf)?.id);nt(`session`)}};(0,u.useEffect)(()=>{Kn!==`all`&&!M.connections.some(e=>e.id===Kn)&&au(`all`)},[Kn,M.connections]);let ou=Jo.filter(e=>{if(!e.workspaceId||!Hl(e.workspaceId))return!1;if(Wn===`all`)return!0;if(Wn===`workspace`||Wn===`repo`)return ru(e.workspaceId);if(e.id.startsWith(`session:`)){let t=T.conversations.find(t=>t.id===e.rawId);return!!(t&&!t.archivedAt&&ru(t.workspaceId)&&(Wn===`recent`?Date.parse(t.updatedAt)>=Zl:t.status===`running`||t.status===`waiting`))}if(e.id.startsWith(`group:`)){let t=ft(e.id),n=t?.roomId?rt[t.workspaceId]?.rooms.find(e=>e.id===t.roomId):void 0;return!!(t&&n&&!n.archivedAt&&ru(t.workspaceId)&&(Wn===`recent`?Date.parse(n.updatedAt)>=Zl:[`running`,`queued`].includes(_t(n,st[n.id]))))}return!1}),su=Ea?`未选工作区`:V.status?.detached?`游离 HEAD`:V.status?.branch,cu=!Ea&&V.status&&new Set([...V.status.staged,...V.status.unstaged,...V.status.untracked].map(e=>e.path)).size,lu=!Ea&&V.status&&(V.status.ahead||V.status.behind)?[V.status.ahead?`↑`+V.status.ahead:``,V.status.behind?`↓`+V.status.behind:``].filter(Boolean).join(` `):``,uu=()=>ir(e=>({...e,rightClosed:!0})),du=()=>ir(e=>({...e,leftClosed:!0})),fu=mr?Fn:to;return(0,L.jsxs)(`main`,{className:`shell workbench-shell${fu?` shell-rail-collapsed`:``} mobile-panel-${Ln}${Hn?` mobile-drawer-open`:``}`,"data-rail-collapsed":fu,"data-workbench-left-closed":!mr&&rr.leftClosed,"data-selected-workspace":O??``,style:{"--sidebar-width":`${sr.sidebar}px`,"--rail-col":fu?void 0:`${sr.rail}px`},children:[!mr&&(0,L.jsx)(sn,{side:`left`,views:qa,unpinned:rr.unpinned,active:rr.leftClosed||Ja?void 0:$a,onSelect:e=>ro(e,!0),searchActive:!rr.leftClosed&&Ja,onSearch:()=>{Za(!0),Ya(!0),ir(e=>({...e,leftClosed:Ja&&!e.leftClosed}))},onArrange:io,onReorder:ao,onReset:oo,children:Rl}),(0,L.jsxs)(`aside`,{className:`workbench-sessions`,id:`workbench-sessions`,"data-workbench-session-view":no?`shown`:`hidden`,children:[(0,L.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,L.jsx)(`button`,{className:`workspace-new`,onClick:()=>Ae(!0),children:`+ 添加工作区`}),R&&da&&ou.length===1&&(0,L.jsx)(`button`,{type:`button`,className:`mobile-close-session`,onClick:()=>{fs(R.id),Un(!1)},children:`关闭当前标签`})]}),(0,L.jsxs)(`div`,{className:`label label-desktop workspace-title-row`,children:[(0,L.jsx)(`span`,{children:`工作区`}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-bulk-settings`,title:`批量设置所有工作区`,"aria-label":`批量设置所有工作区`,onClick:()=>Qc(!0),children:`⚙`})]}),(0,L.jsx)(`div`,{className:`label label-phone`,children:`会话`}),Zc&&(0,L.jsx)(kT,{workspaces:T.workspaces.filter(e=>h(e.id).server===M.activeServer&&!e.closedAt&&!e.id.startsWith(`pending:`)),catalog:gn??{source:`unavailable`,models:[],levels:[],fetchedAt:``},onClose:()=>Qc(!1),onSave:ll}),(0,L.jsxs)(`div`,{className:`sidebar-session-filters`,"aria-label":`会话与群聊筛选`,children:[(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`span`,{children:`服务器`}),(0,L.jsxs)(`select`,{"aria-label":`服务器范围`,value:Kn,onChange:e=>au(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`全部服务器`}),M.connections.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.name,M.statuses.get(e.id)?.state===`offline`?` · 离线`:``]},e.id))]})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`span`,{children:`显示`}),(0,L.jsxs)(`select`,{"aria-label":`会话列表筛选方式`,value:Wn,onChange:e=>iu(e.currentTarget.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`全部`}),(0,L.jsx)(`option`,{value:`workspace`,children:`按工作区`}),(0,L.jsx)(`option`,{value:`repo`,children:`按仓库`}),(0,L.jsx)(`option`,{value:`recent`,children:`近期活跃 · 5 小时`}),(0,L.jsx)(`option`,{value:`running`,children:`正在运行`})]})]}),Wn===`workspace`&&(0,L.jsx)(`select`,{"aria-label":`选择工作区`,value:ql??``,onChange:e=>iu(`workspace`,e.currentTarget.value,Xl),children:(0,L.jsx)(He,{workspaces:Gl})}),Wn===`repo`&&(0,L.jsx)(`select`,{"aria-label":`选择仓库`,value:Xl??``,onChange:e=>iu(`repo`,ql,e.currentTarget.value),children:(0,L.jsx)(He,{workspaces:Wl})})]}),(0,L.jsx)(`nav`,{"aria-label":`工作区、会话与群聊`,children:tu.length===0?(0,L.jsx)(`div`,{className:`sidebar-filter-empty`,children:Wn===`recent`?`近 5 小时没有活跃的会话或群聊`:`当前没有正在运行的会话或群聊`}):tu.map((e,t)=>{let n=rt[e.id],r=(n?.rooms.filter(e=>!e.archivedAt)??[]).filter(e=>nu||(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id])))),i=nu?n?.rooms.filter(e=>e.archivedAt)??[]:[],a=T.conversations.filter(t=>t.workspaceId===e.id),o=a.filter(e=>!e.archivedAt&&(nu||(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:e.status===`running`||e.status===`waiting`))),s=VT(o,ci,{manualRoots:Gt[e.id]}),c=s.filter(e=>e.depth===0).map(e=>e.conversation.id),l=nu?a.filter(e=>e.archivedAt):[],u=VT(l,new Set),d=nu?l.length+i.length:0,f=ne[e.id]??!1,p=Vt[e.id]??!0,m=Kl.has(e.name.trim().toLowerCase()),g=!e.worktreeOf||!Ul.has(e.worktreeOf),_=(Wn===`recent`||Wn===`running`)&&g,v=t=>et===`group`&&bt===e.id&&St===t;return(0,L.jsxs)(`section`,{className:`workspace-group${e.worktreeOf&&Ul.has(e.worktreeOf)?` workspace-linked-checkout`:``}${_?` workspace-active-repo-root`:``}`,"data-workspace-parent":e.worktreeOf,"data-workspace-group":e.id,"data-sidebar-repo-root":_?e.id:void 0,"data-current-workspace":O===e.id,children:[M.connections.length>1&&(t===0||h(tu[t-1].id).server!==h(e.id).server)&&(0,L.jsxs)(`div`,{className:`workspace-server-label`,children:[me(e.id),M.statuses.get(h(e.id).server)?.state===`offline`?` · 离线`:``]}),(0,L.jsx)(`div`,{className:`workspace-header`,children:Gc(`workspace`,e.id)?(0,L.jsx)(nO,{initial:e.name,label:`重命名工作区 ${e.name}`,onCommit:t=>Kc(`workspace`,e.id,t),onClose:Wc}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`workspace-disclosure`,"data-workspace-fold":e.id,"aria-expanded":!f,"aria-label":`${f?`展开`:`折叠`}工作区 ${e.name}`,onClick:()=>re(t=>({...t,[e.id]:!t[e.id]})),children:(0,L.jsx)(`span`,{className:`chevron-folder`,"aria-hidden":`true`,children:f?`▸`:`▾`})}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-toggle`,"aria-label":e.name,"aria-describedby":m?`workspace-name-warning-${e.id}`:void 0,title:e.path,onContextMenu:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect();Ar({workspace:e,x:t.clientX||n.left+24,y:t.clientY||n.top+n.height})},onClick:()=>{Yn(e.id);let t=oi.find(t=>t.workspaceId===e.id)?.id;t?t===R?.id&&et===`session`&&da||pa(t):ha(e.id)},children:(0,L.jsxs)(`span`,{children:[(0,L.jsxs)(`span`,{className:`workspace-name-line`,children:[(0,L.jsx)(`strong`,{onDoubleClick:()=>Uc(`workspace`,e.id),children:e.name}),m&&(0,L.jsx)(`small`,{id:`workspace-name-warning-${e.id}`,className:`workspace-name-warning`,"data-workspace-name-warning":e.id,title:`请重命名其中一个工作区;名称唯一后提示会自动消失。`,children:`存在同名,易混淆`})]}),(0,L.jsx)(`small`,{children:e.path})]})}),(0,L.jsx)(`button`,{className:`workspace-add`,disabled:e.id.startsWith(`pending:`),title:`在此工作区新建会话`,onClick:t=>{Yn(e.id),Pe.current=t.currentTarget,Me({workspaceId:e.id})},children:`+`}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-group-chat`,"data-open-group-chat":e.id,disabled:e.id.startsWith(`pending:`),title:`新建群聊`,"aria-label":`在 ${e.name} 新建群聊`,onClick:()=>{Yn(e.id),ga(e.id)},children:(0,L.jsx)(on,{name:`group-add`})}),(0,L.jsx)(`button`,{className:`workspace-settings`,title:`工作区设置(默认智能体 / 模型 / 思考强度)`,"aria-label":`工作区设置 ${e.name}`,onClick:()=>Xc(e.id),children:`⚙`})]})}),!f&&r.map(t=>{let n=v(t.id),r=_t(t,st[t.id]),i=vt(t,st[t.id],Re.current[dt({workspaceId:e.id,roomId:t.id})]),a=i===`completed`?`讨论已完成,有新回复未读`:i===`unread`?`有新回复未读`:uO[r];return(0,L.jsxs)(`div`,{className:`conversation-row group-room-row`,children:[(0,L.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),(0,L.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-sidebar-group-chat":t.id,"aria-current":n?`true`:void 0,"aria-label":`打开群聊 ${t.title},${a}`,title:t.title,onClick:()=>{Yn(e.id),ga(e.id,t.id)},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,children:(0,L.jsx)(bO,{state:i,label:a})}),(0,L.jsx)(on,{name:`group`}),(0,L.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-archive`,"data-archive-group":t.id,title:`归档群聊`,"aria-label":`归档群聊 ${t.title}`,disabled:mt.has(t.id),onClick:()=>void ya(t,`archive`),children:(0,L.jsx)(on,{name:`archive`})})]},t.id)}),!f&&n?.failed&&(0,L.jsx)(`button`,{type:`button`,className:`group-rooms-retry`,onClick:it,children:`重试载入群聊`}),!f&&(s.length?s.map(({conversation:t,depth:n,childCount:r,isLastSibling:i})=>(0,L.jsxs)(`div`,{className:`conversation-row`,style:{"--tree-depth":n},"data-session-root":n===0?t.id:void 0,"data-session-dragging":qt?.conversationId===t.id?`true`:void 0,"data-session-drop":qt?.dropRootId===t.id?qt.dropAfter?`after`:`before`:void 0,onPointerDown:n===0?n=>Zt(n,e.id,t.id,c):void 0,children:[r>0?(0,L.jsxs)(`button`,{type:`button`,className:`conversation-tree-toggle`,"data-tree-toggle":t.id,"aria-expanded":!ci.has(t.id),title:ci.has(t.id)?`展开 ${r} 个子会话`:`折叠 ${r} 个子会话`,"aria-label":ci.has(t.id)?`展开会话 ${t.title} 的 ${r} 个子会话`:`折叠会话 ${t.title} 的 ${r} 个子会话`,onClick:()=>fl(t.id,!ci.has(t.id)),children:[(0,L.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:ci.has(t.id)?`▸`:`▾`}),(0,L.jsx)(`small`,{children:r})]}):(0,L.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),Gc(`conversation`,t.id)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(nO,{initial:t.title,label:`重命名会话 ${t.title}`,onCommit:e=>Kc(`conversation`,t.id,e),onClose:Wc}),(0,L.jsx)(`small`,{className:`conversation-time`,children:fD(t.updatedAt,ii)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{className:`conversation ${!ba&&R?.id===t.id?`selected`:``}`,"data-conversation":t.id,"aria-current":!ba&&R?.id===t.id?`true`:void 0,"data-tree-child":n>0?`true`:void 0,"data-tree-last":n>0&&i?`true`:void 0,title:n>0?`${t.title}(由「${o.find(e=>e.id===t.parentConversationId)?.title??`已不存在的会话`}」创建)`:t.title,"aria-label":`打开会话 ${t.title}${SO(t,Ll.get(t.id))}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.getBoundingClientRect();Mr({conversation:t,x:e.clientX||n.left+24,y:e.clientY||n.top+n.height})},onClick:()=>{t.id===Xt.current&&Date.now()-Yt.current<300||(Yn(e.id),pa(t.id),k(e.id),Un(!1))},onDoubleClick:()=>{ma(t.id)},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,children:(0,L.jsx)(bO,{state:vO(t,gO(t,Pn),Re.current[t.id],T.conversations)})}),(0,L.jsx)(`span`,{"data-conversation-title":t.id,onDoubleClick:e=>{e.stopPropagation(),Uc(`conversation`,t.id)},style:{flex:`0 1 auto`,minWidth:`3.5em`},children:t.title}),(0,L.jsx)(`span`,{className:`conversation-title-gap`,"aria-hidden":`true`,style:{marginLeft:`-8px`}}),yO(vO(t,gO(t,Pn),Re.current[t.id],T.conversations),_O(t,T.conversations,Re.current[t.id])),xO(t,Ll.get(t.id)),(0,L.jsx)(`small`,{children:fD(t.updatedAt,ii)})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-fork`,"data-fork-conversation":t.id,"data-fork-state":Pl===t.id?`pending`:`idle`,disabled:!!Pl,title:`从此会话分叉出一个新会话`,"aria-label":`从会话 ${t.title} 分叉出一个新会话`,onClick:()=>Il(t.id),children:`⑂`}),!(t.parentConversationId&&T.conversations.some(e=>e.id===t.parentConversationId))&&(0,L.jsx)(`button`,{className:`conversation-archive`,"data-archive-conversation":t.id,title:`归档整棵会话树`,"aria-label":`归档会话 ${t.title}`,onClick:()=>dl(t.id),children:`×`})]})]},t.id)):!r.length&&(0,L.jsx)(`div`,{className:`conversation-empty`,children:`暂无会话`})),!f&&d>0&&(0,L.jsxs)(`div`,{className:`archived-group`,"data-archived-count":d,children:[(0,L.jsxs)(`button`,{className:`archived-toggle`,title:p?`展开已归档`:`收起已归档`,"aria-expanded":!p,onClick:()=>Wt(t=>({...t,[e.id]:!p})),children:[(0,L.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:p?`▸`:`▾`}),(0,L.jsxs)(`span`,{className:`archived-label`,children:[`已归档 (`,d,`)`]})]}),!p&&u.map(({conversation:e,depth:t,isLastSibling:n})=>{let r=pD(l,e.id).length-1,i=!!(e.parentConversationId&&T.conversations.some(t=>t.id===e.parentConversationId&&t.archivedAt));return(0,L.jsxs)(`div`,{className:`conversation-archived`,"data-archived-conversation":e.id,"data-archived-at":e.archivedAt,"data-tree-child":t>0?`true`:void 0,"data-tree-last":t>0&&n?`true`:void 0,style:{"--tree-depth":t},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{"data-archived-title":e.id,children:e.title}),xO(e,Ll.get(e.id)),(0,L.jsx)(`small`,{children:mD(e.archivedAt)}),!i&&(0,L.jsx)(`button`,{className:`conversation-restore`,"data-restore-conversation":e.id,title:r?`恢复这个会话和它的 ${r} 个子孙会话`:`恢复为正常会话`,"aria-label":r?`恢复会话 ${e.title} 及其 ${r} 个子孙会话`:`恢复会话 ${e.title}`,onClick:()=>pl(e.id),children:`↑`})]},e.id)}),!p&&i.map(t=>{let n=v(t.id),r=mt.has(t.id);return(0,L.jsxs)(`div`,{className:`conversation-row group-room-row group-room-history`,"data-archived-group":t.id,children:[(0,L.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-open-archived-group":t.id,"aria-current":n?`true`:void 0,"aria-label":`查看已归档群聊 ${t.title}`,title:t.title,onClick:()=>ga(e.id,t.id),children:[(0,L.jsx)(on,{name:`group`}),(0,L.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-restore-group":t.id,title:`恢复群聊`,"aria-label":`恢复群聊 ${t.title}`,disabled:r,onClick:()=>void ya(t,`restore`),children:`↑`}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-delete-group":t.id,title:`永久删除群聊`,"aria-label":`永久删除群聊 ${t.title}`,disabled:r,onClick:()=>void ya(t,`delete`),children:(0,L.jsx)(on,{name:`delete`})})]},t.id)})]}),!f&&(()=>{let t=T.warmSessions?.filter(t=>t.workspaceId===e.id)??[];return t.length?(0,L.jsxs)(`details`,{className:`archived-group`,"data-warm-sessions":e.id,children:[(0,L.jsx)(`summary`,{className:`archived-toggle`,children:(0,L.jsxs)(`span`,{className:`archived-label`,children:[`预热会话 (`,t.length,`)`]})}),t.map(e=>(0,L.jsxs)(`div`,{className:`conversation-archived`,"data-warm-session":e.id,children:[(0,L.jsx)(`span`,{title:e.title,children:e.title}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"aria-label":`移除预热会话 ${e.title}`,onClick:()=>{window.confirm(`移除预热会话「${e.title}」?`)&&!Fs({type:`conversation.warm.delete`,conversationId:e.id})&&Ds(`连接断开,未移除预热会话`,`error`)},children:`×`})]},e.id))]}):null})()]},e.id)})}),mr&&(0,L.jsxs)(`footer`,{className:`workbench-mobile-utilities`,children:[(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-mobile-workbench-search":!0,"aria-label":`搜索`,title:`搜索`,onClick:()=>so(`content`),children:(0,L.jsx)(on,{name:`search`})}),Rl]})]}),Xa&&(0,L.jsx)(`section`,{className:`workbench-panel workbench-panel-left workbench-search-panel`,"data-workbench-search-panel":!0,"aria-label":`侧栏搜索`,hidden:mr||!Ja||rr.leftClosed,children:(0,L.jsx)(_m,{workspaceId:Sa,workspaceName:bs?.name,cwd:Ta,connected:N,onOpen:(e,t,n)=>Vo(e,t,!1,!0,!1,n),onSession:po},H)}),!mr&&!rr.leftClosed&&!Ja&&$a!==`sessions`&&(0,L.jsx)(MO,{...Vl,side:`left`,activeTab:$a,collapsed:!1,onToggle:du,pinned:!rr.unpinned.includes($a),onArrange:io}),(mr||!rr.leftClosed)&&(0,L.jsx)(_k,{side:`left`,width:sr.sidebar,min:sr.sidebarMin,max:sr.sidebarMax,label:`调整左侧栏宽度`,onWidth:cr}),(0,L.jsx)(`div`,{className:`workbench-main`,children:(0,L.jsxs)(`div`,{className:`workbench-main-panes`,"data-workbench-split":Na,style:{"--split-share":`${Aa}%`},children:[(0,L.jsxs)(`section`,{className:`chat`,"data-main-view":wo,"data-main-view-kind":wo,children:[ou.length>0&&(0,L.jsx)(`div`,{className:`chat-tab-strip`,"data-chat-tab-strip":`1`,"data-session-count":la.length,"data-file-count":B.open.length,children:(0,L.jsx)(xm,{tabs:(ls?ou.filter(e=>e.id!==ls.id):ou).map(e=>M.connections.length>1&&e.workspaceId?{...e,label:`${e.label} · ${me(e.workspaceId)}`,title:`${me(e.workspaceId)} · ${e.title??e.label}`}:e),prefix:`workspace-tab`,ariaLabel:`工作区标签页`,activeId:Yo,onSelect:Qo,onClose:ps,onActivate:ss,minWidth:120,maxWidth:320})}),(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`button`,{type:`button`,className:`mobile-drawer-toggle`,"data-mobile-drawer-toggle":`1`,"aria-label":`打开会话列表`,title:`会话列表`,"aria-expanded":Hn,onClick:()=>Un(!0),children:`☰`}),(0,L.jsxs)(`div`,{className:`chat-head`,children:[(0,L.jsx)(`h1`,{children:et===`group`?St?wt??`群聊`:`新建群聊`:R?.title??`准备开始`}),et!==`group`&&yc.size>0?[...yc].map(([e,t])=>(0,L.jsx)(`p`,{"data-role":`run-status`,"data-status-key":e,children:`扩展状态:${e?`${e} · `:``}${t}`},e)):null]}),(0,L.jsxs)(`div`,{className:`workbench-history-controls`,role:`group`,"aria-label":`主区导航`,"data-workbench-history":is>=0||Y>=0?`available`:`empty`,children:[(0,L.jsx)(`button`,{type:`button`,"data-workbench-history-back":!0,"aria-label":`后退`,className:`workbench-icon-button`,title:is<0?`后退`:`后退到 ${ye.entries[is].title}`,disabled:is<0||!!xe,onClick:()=>as(-1),children:(0,L.jsx)(on,{name:`back`})}),(0,L.jsx)(`button`,{type:`button`,"data-workbench-history-forward":!0,"aria-label":`前进`,className:`workbench-icon-button`,title:Y<0?`前进`:`前进到 ${ye.entries[Y].title}`,disabled:Y<0||!!xe,onClick:()=>as(1),children:(0,L.jsx)(on,{name:`forward`})}),Sa&&(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-toggle-workbench-split":!0,"aria-pressed":Na,"aria-label":Na?`合并主区`:`拆分主区`,title:Na?`合并主区`:`拆分主区`,onClick:ds,children:(0,L.jsx)(on,{name:`split`})})]}),Nn.entry(`workbench-status-button software-update-mobile`),(0,L.jsxs)(`span`,{className:`chat-view chat-view-${wo}`,"data-main-view-indicator":wo,"data-main-view-kind":wo,title:et===`file`?`中间主画面正在显示文件 ${B.active?.path??``}`:wo===`diff`?`中间主画面正在显示 ${To??``} 的改动`:`中间主画面正在显示这个会话的消息流`,children:[(0,L.jsx)(`span`,{className:`chat-view-kind`,children:et===`group`?`群聊`:et===`file`?`文件`:wo===`diff`?`改动`:`会话`}),et===`file`&&B.active&&(0,L.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":B.active.name,children:B.active.name}),wo===`diff`&&To&&(0,L.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":To,children:To})]}),!ba&&(0,L.jsx)(`div`,{className:`badge`,"data-workbench-header-status":bi||R?.status===`failed`?`attention`:`routine`,"data-conversation-status":R?.status??`idle`,...bi?{"data-reporting-status":bi}:{},children:bi===`awaiting_decision`?`等上面拍板`:pO(R)?fO[R?.status??`idle`]:bi===`awaiting_subordinates`?`等待下级`:bi===`pending_report`?`待汇报`:fO[R?.status??`idle`]}),(0,L.jsx)(`button`,{type:`button`,className:`mobile-tools-toggle`,"data-mobile-nav":`rail`,onClick:()=>{Rn(`rail`),In(!1)},children:`工具`})]}),ee&&(0,L.jsxs)(`div`,{className:`error`,role:`alert`,"data-global-error":!0,children:[(0,L.jsx)(`span`,{title:Ut(ee),children:Ht(ee)}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`关闭错误提示`,title:`关闭错误提示`,onClick:()=>te(void 0),children:`×`})]}),!ba&&R?.error&&(0,L.jsx)(`div`,{className:`error`,"data-role":`conversation-error`,title:Ut(R.error),children:Ht(R.error)}),R?.warning&&(0,L.jsxs)(`div`,{className:`warning`,role:`status`,"data-role":`conversation-warning`,title:Ut(R.warning),children:[(0,L.jsx)(`span`,{children:R.warning}),(0,L.jsx)(`button`,{type:`button`,"data-role":`conversation-warning-continue`,title:`让模型接着把被截断的部分写完`,onClick:()=>Vs(R?.id??``),children:`继续写完`})]}),!ba&&R?.modelNotice&&(0,L.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-model-notice`,children:R.modelNotice}),R?.agentNotice&&(0,L.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-agent-notice`,children:R.agentNotice}),xc&&(0,L.jsxs)(`div`,{className:`extui-title-note`,children:[`扩展建议标题:`,xc]}),fn.length>0&&(0,L.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,"data-toast-count":fn.length,children:fn.map(e=>(0,L.jsx)(`div`,{className:`toast toast-${e.kind}`,"data-toast-kind":e.kind,children:e.text},e.key))}),et===`group`?bs?(0,L.jsx)(ET,{workspaceId:bt,roomId:St,sourceLink:Os(bt),composerResize:dr===null?void 0:(0,L.jsx)(wk,{height:dr,onHeight:pr}),onEnableNotifications:()=>As(!0),agents:Cn?.agents??[],catalog:tc(mn,bs),userLabel:an,archivedAt:Ct?.archivedAt,restoring:mt.has(St),onRestore:e=>void ya(e,`restore`),onRoomSeen:at,onRoomRead:Ai,onRoomMissing:va,onCreated:_a,onCancelCreate:()=>Ve&&ps(dt(Ve))},Ve&&dt(Ve)):(0,L.jsx)(`div`,{className:`group-empty`,children:Te?`这个群聊的工作区已不可用。`:`正在加载工作区…`}):et===`file`?Ss(ms,!0):Co?Cs(Co):et===`diff`?ws(q,!1):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`messages`,ref:Tt,"data-message-scroll-container":R?.id??``,onWheel:e=>{e.deltaY<0&&Ie.current[R?.id??``]?.followTail&&(Mt.current=!0,ji(e.currentTarget,!0))},onScroll:e=>{let t=e.currentTarget;t.dataset.programmaticScroll===`true`?delete t.dataset.programmaticScroll:ji(t)},children:[(!R||!da)&&(0,L.jsxs)(`div`,{className:`empty`,"data-workspace-welcome":Ci?.id,children:[(0,L.jsx)(`div`,{className:`orb`,children:`π`}),(0,L.jsx)(`h2`,{children:Ci?.name??`开始一个新会话`}),T.workspaces.length===0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`先创建一个工作区,再开始会话。`}),(0,L.jsx)(`button`,{onClick:()=>Ae(!0),children:`+ 新建工作区`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:Ci?`暂无活跃会话。你可以创建会话,也可以直接使用资源管理器、Git 和终端。`:T.workspaces.length===1&&Si?`在「${Si.name}」中创建会话,即可向 Super Pi 发送任务。`:`选择工作区即可开始会话,向 Super Pi 发送任务。`}),Ci&&(0,L.jsx)(`p`,{className:`workspace-welcome-path`,title:Ci.path,children:Ci.path}),T.workspaces.length>1&&(0,L.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,L.jsx)(`label`,{htmlFor:`empty-workspace-choice`,children:`工作区:`}),(0,L.jsxs)(`select`,{id:`empty-workspace-choice`,"aria-label":`选择工作区`,value:Si?.id,onChange:e=>{e.target.value===`__new__`?Ae(!0):ha(e.target.value)},children:[(0,L.jsx)(He,{workspaces:T.workspaces}),(0,L.jsx)(`option`,{value:`__new__`,children:`+ 新建工作区…`})]})]}),Si&&(0,L.jsxs)(L.Fragment,{children:[!wi&&(0,L.jsx)(ED,{workspaceId:Si.id,value:Ti,onChange:Oi}),(0,L.jsx)(`button`,{"data-workspace-welcome-create":Ci?`1`:void 0,disabled:wi||!N,onClick:()=>ul(Si.id,Ti),children:wi?`正在创建工作区…`:`新建会话`})]}),(0,L.jsx)(`span`,{className:`empty-secondary-action`,role:`button`,tabIndex:0,onClick:()=>Ae(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ae(!0))},children:`+ 新建工作区`})]})]}),R?.messagesLoaded===!1&&(0,L.jsx)(`p`,{role:`status`,"data-conversation-loading":`1`,children:`正在加载会话…`}),kc.map(e=>{if(e.startsWith(`m:`)){let t=Ec.get(e.slice(2));if(!t)return null;let n=t.id===Ac,r=t.role===`user`&&R?.status!==`running`&&R?.status!==`waiting`&&El!==t.id,i=r&&n&&!t.id.startsWith(`pending:`),a=r&&!n&&!!t.piEntryId,o=t.content?(0,L.jsx)(Md,{source:t.content,media:li,sourceLink:ks}):(0,L.jsx)(`span`,{className:`typing`,children:`正在思考`});if(t.source===`session-reminder`)return(0,L.jsx)(`article`,{className:`message message-reminder`,"data-transcript-key":e,"data-message-reminder":t.id,children:(0,L.jsxs)(`details`,{children:[(0,L.jsxs)(`summary`,{className:`reminder-header`,children:[(0,L.jsxs)(`span`,{className:`reminder-label`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,L.jsx)(`time`,{dateTime:t.createdAt,children:aD(t.createdAt)})]}),(0,L.jsx)(`div`,{className:`content`,children:o})]})},e);let s=t.toolCalls??[],c=kl?.id===t.id?kl.kind:void 0;if(t.role===`user`){let n=t.content||(t.images?.length?`[图片]`:``),r=UD(t.content,t.attachments);return(0,L.jsxs)(`article`,{className:`message user`,"data-transcript-key":e,children:[(0,L.jsxs)(`div`,{className:`message-body`,children:[(0,L.jsxs)(`div`,{className:`bubble`,children:[(0,L.jsxs)(`div`,{className:`meta`,children:[an,(0,L.jsx)(`time`,{children:aD(t.createdAt)})]}),t.images&&t.images.length>0&&(0,L.jsx)(`div`,{className:`message-images`,"data-message-images":`1`,children:t.images.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`message-image-btn`,"data-message-image-id":e.id,onClick:()=>Wr({url:Oe(`/api/upload/${encodeURIComponent(R?.id??``)}/${encodeURIComponent(e.id)}`),name:e.name,bytes:e.bytes}),title:e.name?`查看大图:${e.name}`:`查看大图`,children:(0,L.jsx)(`img`,{src:Oe(`/api/upload/${encodeURIComponent(R?.id??``)}/${encodeURIComponent(e.id)}`),alt:e.name||`图片`,className:`message-image-thumb`,loading:`lazy`})},e.id))}),(0,L.jsx)(`div`,{className:`content`,children:o})]}),r.length>0&&(0,L.jsx)(`div`,{className:`message-attachments`,"data-message-attachments":`1`,children:r.map(e=>{let n=`att:${t.id}:${e.kind}:${e.id}`,r=_r[n]??!1;return(0,L.jsxs)(`div`,{className:`message-attachment`,"data-message-attachment":e.kind,children:[(0,L.jsxs)(`button`,{type:`button`,className:`message-attachment-head`,"data-message-attachment-toggle":e.id,"aria-expanded":r,onClick:()=>vr(e=>({...e,[n]:!r})),children:[(0,L.jsx)(`span`,{className:`message-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,L.jsx)(`span`,{className:`message-attachment-label`,children:`技能`}),(0,L.jsx)(`span`,{className:`message-attachment-name`,title:e.name,children:e.name}),(0,L.jsx)(`span`,{className:`message-attachment-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`})]}),r&&(0,L.jsx)(`pre`,{className:`message-attachment-body`,"data-message-attachment-body":e.id,children:e.content})]},n)})}),(0,L.jsxs)(`div`,{className:`message-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":c,"aria-label":`复制这条消息:${n}`,onClick:()=>Nl(t.id,n),children:c===`copied`?`已复制`:c===`error`?`复制失败`:`复制`}),i&&(0,L.jsx)(`button`,{type:`button`,className:`message-revert`,"data-withdraw-message":t.id,title:`撤回并编辑:删除这条消息并将文字恢复到输入框继续编辑`,onClick:()=>Ol(t.id,!0),children:`撤回`}),a&&(0,L.jsx)(`button`,{type:`button`,className:`message-revert`,"data-revert-message":t.id,title:`回退到这里:删除后续全部内容(Pi 的记录和这里的历史一起清掉,不会新建会话,也不动任何代码文件)`,onClick:()=>Ol(t.id),children:`回退`})]})]}),(0,L.jsx)(`div`,{className:`avatar`,title:an,children:an})]},e)}if(t.role===`tool`){let n=/<task id="[^"]+" state="[^"]+"/.test(t.content),r=(()=>{let e=/<summary>([\s\S]*?)<\/summary>/.exec(t.content);return e?e[1].trim():n?`后台回传`:(t.content.split(`
|
|
345
|
+
如需本地计算,声明 script: { path, timeoutMs, parameters }。脚本必须是 Python,参数以 JSON 从 stdin 传入,stdout 必须只输出一个 JSON 对象。在 index.html 中加载 <script src="./super-pi-tool.js"><\/script>,然后调用 SuperPiTool.run(params)、SuperPiTool.get(runId)、SuperPiTool.wait(runId) 或 SuperPiTool.cancel(runId)。这些都是已绑定本工具身份的相对接口;不要调用 /api/exec,不要猜测 toolId,也不要传 shell 命令、任意文件路径或未声明参数。页面必须实际执行一次示例任务并显示运行状态、日志和结构化结果。第三方包写进 environment.requires(必须钉死成 pkg==version),首次运行时会装进这个工具自己的虚拟环境。需要模型能力(摘要、改写、抽取、分类)时调用 SuperPiTool.llm({ prompt, system }),不要自己写模型客户端或保管密钥,并在注册时声明 permissions: { llm: true }——否则服务端会拒绝,导入页面也会提示用户。最后返回注册 id、访问地址、文件清单和验证结果。`);f(e),window.setTimeout(()=>f(!1),1800)};(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let ae=(0,u.useMemo)(()=>[...t.map(e=>({id:e.id,name:e.name,glyph:e.glyph})),...n.map(e=>({id:e.id,name:e.name,glyph:MT(e)}))],[t,n]);(0,u.useEffect)(()=>{if(!N)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ee(void 0);return}if(YT(e.key)||iE(e.target))return;e.preventDefault(),e.stopPropagation();let t=N;if(ee(void 0),e.key===`Delete`||e.key===`Backspace`){EE.clearShortcut(t).then(e=>te(e));return}let n=XT(e);if(!n){te(`没有认出这个按键,换一个试试。`);return}let i=nE(n);if(!i.ok){te(i.reason);return}let a=cE(r,n,t);if(a){let e=ae.find(e=>e.id===a)?.name;te(e?`这个组合键已经被「${e}」占用了,换一个键。`:`这个组合键已经被另一个工具占用了,换一个键。`)}else EE.setShortcut(t,n).then(e=>te(e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[N,r,ae]);let oe=e=>{F(vE(e,window.innerWidth,window.innerHeight))},se=e=>{_E(e)},ce=()=>{F(void 0),_E(void 0)},le=(0,u.useRef)(!1),ue=n.map(e=>e.slug).filter(e=>typeof e==`string`),de=e=>{m(void 0),g(void 0),A(void 0),O({tool:e,name:IE({slug:e.slug??`tool`})})},fe=async(e,t)=>{m(void 0),g(void 0),A(void 0);let n=LE(t);if(!n.ok)A(n.reason);else try{let t=await ke(`/api/tools/export?id=${encodeURIComponent(e.id)}`),r=await t.json();if(!t.ok||!r.bundle)throw Error(r.error??`HTTP ${t.status}`);let i=new Blob([JSON.stringify(r.bundle,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n.name,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),g(r.skipped?.length?`已导出「${e.name}」,但有 ${r.skipped.length} 个文件没有包含:${r.skipped.join(`、`)}。`:`已导出「${e.name}」。`)}catch(e){m(`导出失败:${Ht(e)}`)}finally{O(void 0)}},pe=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;m(void 0),g(void 0),S(void 0);let n=NE(await t.text(),t.name);n.ok?(v({filename:t.name,bundle:n.bundle,unnamedFormat:n.unnamedFormat}),b(ue.includes(n.bundle.slug)?FE(n.bundle.slug,ue):n.bundle.slug),w(n.bundle.files[0]?.path)):m(n.reason)},me=()=>{v(void 0),b(``),S(void 0),w(void 0)},I=async()=>{if(!_)return;S(void 0);let e=PE(y);if(!e.ok)S(e.reason);else if(ue.includes(e.slug))S(`本机已经有 slug「${e.slug}」的工具,换一个名字再导入。`);else{E(!0);try{let t=await ke(`/api/tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(HE(_.bundle,e.slug))}),n=await t.json();if(!t.ok||!n.id)throw Error(n.error??`HTTP ${t.status}`);await DE(),g(`已导入「${_.bundle.name}」,它现在出现在工具栏里,所有工作区都能用。`),me()}catch(e){m(`导入失败:${Ht(e)}`)}finally{E(!1)}}};(0,u.useEffect)(()=>{D&&M.current?.scrollIntoView({block:`center`})},[D]);let he=()=>{let e=sr(i);e.ok?t.length>=32?l(`工具最多 32 个,先删掉一个再加。`):(EE.setTools([...t,{id:dr(`link`,t.map(e=>e.id)),kind:`link`,name:o.trim()||zO(e.url),glyph:`↗`,url:e.url}]),a(``),s(``),l(void 0)):l(e.reason)},ge=re?{width:`${re.width}px`,height:`${re.height}px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 32px)`}:void 0;return(0,Ct.createPortal)((0,L.jsxs)(`div`,{className:`tool-overlay`,"data-tool-settings-overlay":`1`,onPointerDown:()=>{le.current=!1},onClick:t=>{le.current?le.current=!1:t.target===t.currentTarget&&e()},children:[(0,L.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-settings-title`,"data-tool-settings":`1`,ref:ne,style:ge,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsx)(`h2`,{className:`tool-dialog-title`,id:`tool-settings-title`,children:`⚙ 工具设置`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-settings-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭工具设置`,onClick:e,children:`✕`})]}),(0,L.jsx)(`div`,{className:`tool-dialog-body`,children:_?(0,L.jsx)(RO,{pending:_,slugDraft:y,slugError:x,preview:C,busy:T,onSlugChange:e=>{b(e),S(void 0)},onPreviewChange:w,onCancel:me,onConfirm:()=>void I()}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`tool-prompt-card`,children:[(0,L.jsx)(`strong`,{children:`直接描述你要的工具`}),(0,L.jsx)(`p`,{className:`tool-hint`,children:`告诉 Super Pi Agent 你要创建什么,它会使用内置开发技能和 tool_register 完成注册。复制提示词仅作为备用入口。`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-development-prompt":`1`,onClick:()=>void ie(),children:d?`已复制`:`复制备用提示词`})]}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`从预置列表添加`})}),(0,L.jsx)(`div`,{className:`tool-presets`,"data-tool-presets":tr.length,children:tr.map(e=>{let n=t.some(t=>t.kind===e.kind);return(0,L.jsxs)(`div`,{className:`tool-preset`,"data-tool-preset":e.kind,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.blurb})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-add-preset":e.kind,disabled:n,title:n?`${e.name}已经在工具栏里了`:`添加${e.name}`,"aria-label":n?`${e.name}已添加`:`添加${e.name}`,onClick:()=>EE.setTools(fr(t,e.kind)),children:n?`已添加`:`添加`})]},e.kind)})}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`添加网址工具`})}),(0,L.jsx)(`p`,{className:`tool-hint`,children:`填一个网址,它会变成一个图标;点开后在弹窗里用按钮在新标签页打开。网址只接受 http / https / mailto。`}),(0,L.jsx)(`input`,{className:`tool-input`,"data-tool-url-input":`1`,value:i,maxLength:2048,placeholder:`https://example.com/工具`,"aria-label":`工具网址`,onChange:e=>{a(e.target.value),l(void 0)}}),(0,L.jsx)(`input`,{className:`tool-input`,"data-tool-url-name":`1`,value:o,maxLength:40,placeholder:`名称(可留空,默认用域名)`,"aria-label":`工具名称(可选)`,onChange:e=>s(e.target.value)}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-url-add":`1`,disabled:!i.trim(),onClick:he,children:`添加网址工具`}),c&&(0,L.jsx)(`p`,{className:`tool-error`,"data-tool-error":`1`,role:`alert`,children:c}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-scope-note":`1`,children:[`能自定义到哪:从上面挑预置工具,或自己填一个网址。`,(0,L.jsx)(`b`,{children:`没有开放「写一段脚本来执行」这一档`}),`——它在浏览器里等同于任意代码执行,会拿着本应用的权限跑。计算器是手写的算术解析器,不含 eval,也认不出变量名。`]}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`快捷键`})}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-shortcut-hint":`1`,children:[`给每个工具绑一个组合键,按下就直接打开它,不用先找到右侧栏。`,(0,L.jsx)(`b`,{children:`弹窗打开时快捷键不生效`}),`——模态弹窗期间键盘归它自己,关掉之后再按。`]}),(0,L.jsx)(`div`,{className:`tool-shortcuts`,"data-tool-shortcut-count":ae.length,children:ae.map(e=>(0,L.jsxs)(`div`,{className:`tool-shortcut-row`,"data-tool-shortcut-row":e.id,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:r[e.id]?`按 ${QT(r[e.id])} 打开`:`还没有快捷键`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-shortcut-set`,"data-tool-shortcut-set":e.id,"data-tool-shortcut-capturing":N===e.id?`1`:void 0,"aria-pressed":N===e.id,title:N===e.id?`按下想用的组合键(Esc 取消,Delete 清除)`:`点一下,然后按下想用的组合键`,onClick:()=>{te(void 0),ee(N===e.id?void 0:e.id)},children:N===e.id?`按下组合键…`:r[e.id]?QT(r[e.id]):`未设置`}),r[e.id]&&(0,L.jsx)(`button`,{type:`button`,className:`tool-shortcut-clear`,"data-tool-shortcut-clear":e.id,title:`清除${e.name}的快捷键`,"aria-label":`清除${e.name}的快捷键`,onClick:()=>{EE.clearShortcut(e.id),te(void 0),ee(void 0)},children:`清除`})]},e.id))}),P&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-shortcut-error":`1`,children:P}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsxs)(`h2`,{className:`rail-section-title`,children:[`已安装的全局工具(`,n.length,`)`]})}),n.length===0?(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-mounted-empty":`1`,children:`还没有注册全局工具。直接告诉 Agent 你想做什么即可开始。`}):(0,L.jsx)(`div`,{className:`tool-presets`,"data-tool-mounted-list":n.length,children:n.map(e=>{let t=BE(e.environmentState);return(0,L.jsxs)(`div`,{className:`tool-share-row`,"data-tool-share-row":e.id,children:[(0,L.jsx)(AT,{className:`tool-preset-glyph`,glyph:MT(e)}),(0,L.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{"data-tool-env":e.environmentState?.state??`unknown`,children:t?`${t.warn?`⚠ `:``}${t.text}${e.environmentState?.detail?` · ${e.environmentState.detail}`:``}`:`环境未知`}),e.permissions?.llm&&(0,L.jsx)(`small`,{"data-tool-model":`1`,children:`⚠ 会调用模型`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export":e.id,title:`导出${e.name},得到一个可以发给别人导入的文件`,"aria-label":`导出${e.name}`,onClick:()=>de(e),children:`导出`})]},e.id)})}),D&&(0,L.jsxs)(`div`,{className:`tool-share-review`,ref:M,"data-tool-export-name":`1`,children:[(0,L.jsxs)(`h3`,{className:`tool-share-title`,children:[`导出「`,D.tool.name,`」`]}),(0,L.jsxs)(`label`,{className:`tool-hint`,children:[`文件名(发给别人的就是这个文件)`,(0,L.jsx)(`input`,{className:`tool-input`,value:D.name,"aria-label":`导出文件名`,"data-tool-export-input":`1`,onChange:e=>O({...D,name:e.target.value})})]}),k&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-export-name-error":`1`,children:k}),(0,L.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export-cancel":`1`,onClick:()=>{O(void 0),A(void 0)},children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-export-confirm":`1`,onClick:()=>void fe(D.tool,D.name),children:`导出`})]})]}),h&&(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-share-notice":`1`,children:h}),p&&(0,L.jsx)(`p`,{className:`tool-error`,"data-tool-share-error":`1`,role:`alert`,children:p}),(0,L.jsx)(`div`,{className:`rail-section-head`,children:(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`从文件导入`})}),(0,L.jsxs)(`p`,{className:`tool-hint`,children:[`收到别人分享的工具文件(`,(0,L.jsx)(`code`,{children:kE}),`)?导入后它出现在工具栏里,所有工作区都能用。`,(0,L.jsx)(`b`,{children:`导入前会先给你看这个包里有什么。`})]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-pick":`1`,onClick:()=>j.current?.click(),children:`选择文件…`}),(0,L.jsx)(`input`,{ref:j,type:`file`,accept:`.json,application/json`,style:{display:`none`},"data-tool-import-input":`1`,onChange:e=>void pe(e)})]})})]}),(0,L.jsx)(IO,{targetRef:ne,onResize:oe,onCommit:se,onDragEnd:()=>{le.current=!0},onReset:ce})]}),document.body)}var FO=18;function IO({targetRef:e,onResize:t,onCommit:n,onDragEnd:r,onReset:i}){let[a,o]=(0,u.useState)(),s=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{let e=t.getBoundingClientRect();o({left:e.right-FO,top:e.bottom-FO})};n();let r=new ResizeObserver(n);return r.observe(t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{r.disconnect(),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[e]),(0,L.jsx)(`div`,{className:`tool-dialog-grip`,"data-tool-settings-grip":`1`,role:`separator`,"aria-orientation":`vertical`,tabIndex:0,"aria-label":`调整工具设置弹窗大小:拖动或用方向键,Enter 恢复默认尺寸`,style:a?{left:`${a.left}px`,top:`${a.top}px`}:void 0,onPointerDown:i=>{i.preventDefault(),i.stopPropagation();let a=e.current;if(!a)return;let o=a.getBoundingClientRect(),c=o.left+o.width/2,l=o.top+o.height/2;s.current=void 0;let u=e=>{let n=vE({width:2*(e.clientX-c),height:2*(e.clientY-l)},window.innerWidth,window.innerHeight);s.current=n,t(n)},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),s.current&&(n(s.current),r())};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},onDoubleClick:()=>i(),onKeyDown:r=>{if(r.key===`Enter`||r.key===` `){r.preventDefault(),i();return}let a=r.shiftKey?8:24,o=e.current?.getBoundingClientRect(),c=o?.width??uE.width,l=o?.height??uE.height;if(r.key===`ArrowRight`)c+=a;else if(r.key===`ArrowLeft`)c-=a;else if(r.key===`ArrowDown`)l+=a;else if(r.key===`ArrowUp`)l-=a;else return;r.preventDefault();let u=vE({width:c,height:l},window.innerWidth,window.innerHeight);s.current=u,t(u),n(u)},onClick:e=>e.stopPropagation()})}function LO(){let{tools:e,mountedTools:t,openToolId:n,settingsOpen:r,shortcuts:i}=TE(),a=e.find(e=>e.id===n),o=t.find(e=>e.id===n);return(0,u.useEffect)(()=>{let n=n=>{if(!r&&!document.querySelector(`[aria-modal="true"]`)&&!(n.isComposing||n.defaultPrevented)){for(let[r,a]of Object.entries(i))if(aE(a,n)&&(e.some(e=>e.id===r)||t.some(e=>e.id===r))){n.preventDefault(),EE.openTool(r);return}}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[i,e,t,r]),(0,u.useEffect)(()=>{DE();let e=()=>{DE()};return window.addEventListener(`super-pi-tools-updated`,e),window.addEventListener(`super-pi-active-server`,e),()=>{window.removeEventListener(`super-pi-tools-updated`,e),window.removeEventListener(`super-pi-active-server`,e)}},[]),(0,u.useEffect)(()=>{EE.persistTools()},[]),(0,L.jsxs)(L.Fragment,{children:[r&&(0,L.jsx)(PO,{onClose:()=>EE.closeSettings()}),a&&(0,L.jsx)(BO,{tool:a,onClose:()=>EE.closeTool()}),o&&(0,L.jsx)(JO,{tool:o,onClose:()=>EE.closeTool()})]})}function RO({pending:e,slugDraft:t,slugError:n,preview:r,busy:i,onSlugChange:a,onPreviewChange:o,onCancel:s,onConfirm:c}){let l=e.bundle,u=l.files.reduce((e,t)=>e+new TextEncoder().encode(t.content).length,0),d=zE(l),f=RE(l),p=l.files.find(e=>e.path===r)??l.files[0];return(0,L.jsxs)(`div`,{className:`tool-share-review`,"data-tool-import-review":`1`,children:[(0,L.jsx)(`h3`,{className:`tool-share-title`,"data-tool-import-name":`1`,children:l.name}),l.description&&(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-import-desc":`1`,children:l.description}),e.unnamedFormat&&(0,L.jsx)(`p`,{className:`tool-import-note`,"data-tool-import-unbranded":`1`,children:`这个文件没有 Super Pi 的工具标记,已按内容形状读取——粘出来的 tool_register 参数也认。`}),(0,L.jsxs)(`p`,{className:`tool-hint`,"data-tool-import-files":`1`,children:[l.files.length,` 个文件 · 共 `,VE(u)]}),(0,L.jsx)(`p`,{className:`tool-hint`,"data-tool-import-paths":`1`,children:l.files.map(e=>e.path).join(` · `)}),l.script&&(0,L.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-script":l.script.path,children:[(0,L.jsxs)(`b`,{children:[`⚠ 含 Python 脚本 `,l.script.path]}),(0,L.jsx)(`br`,{}),`导入后运行这个工具时,这段代码会在本机上执行,权限和你自己的 Python 一样(能读你的文件、能联网)。 可以先展开下面的文件列表把它读完。`]}),(0,L.jsxs)(`p`,{className:d.tone===`warn`?`tool-import-warn`:`tool-import-note`,"data-tool-import-env":d.tone,children:[(0,L.jsxs)(`b`,{children:[d.tone===`warn`?`⚠ `:`✓ `,d.text]}),l.environment?.fingerprint?.python&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`br`,{}),`导出方环境:Python `,l.environment.fingerprint.python,` · `,l.environment.fingerprint.platform||`未知平台`,`。版本对不上时会标出来,但不会拦住你运行。`]})]}),f&&(0,L.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-model":`1`,children:[(0,L.jsx)(`b`,{children:`⚠ 这个工具可以调用模型`}),(0,L.jsx)(`br`,{}),f.text,`。模型由 Super Pi 通过 Pi 调用(凭据和模型选择都在 Super Pi 这边),工具只拿到文字。`]}),(0,L.jsxs)(`details`,{className:`tool-import-files`,"data-tool-import-filebox":l.files.length,children:[(0,L.jsxs)(`summary`,{children:[`查看文件(`,l.files.length,`)`]}),(0,L.jsx)(`div`,{className:`tool-share-tabs`,children:l.files.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`tool-share-tab`,"aria-pressed":e.path===p?.path,"data-tool-import-file":e.path,onClick:()=>o(e.path),children:e.path},e.path))}),(0,L.jsx)(`pre`,{className:`tool-import-code`,"data-tool-import-code":p?.path,children:p?.content??``})]}),(0,L.jsxs)(`label`,{className:`tool-hint`,"data-tool-import-slug":`1`,children:[`导入后的 slug(工具的短名字,也是它在磁盘上的目录名)`,(0,L.jsx)(`input`,{className:`tool-input`,value:t,"aria-label":`导入后的 slug`,onChange:e=>a(e.target.value)})]}),n&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-import-slug-error":`1`,children:n}),(0,L.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-import-cancel":`1`,onClick:s,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-confirm":`1`,disabled:i,onClick:c,children:i?`导入中…`:`导入`})]})]})}function zO(e){let t=e.replace(/^[./]+/,``).slice(0,30).trim();if(!/^[a-z][a-z0-9+.-]*:/i.test(e))return t||e.slice(0,30);try{return new URL(e,typeof window>`u`?`http://localhost`:window.location.href).hostname||t||e.slice(0,30)}catch{return e.slice(0,30)}}function BO({tool:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`tool-overlay`,"data-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-dialog-title`,"data-tool-dialog":e.id,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsxs)(`h2`,{className:`tool-dialog-title`,id:`tool-dialog-title`,children:[(0,L.jsx)(AT,{className:`tool-dialog-glyph`,glyph:e.glyph}),e.name]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭${e.name}`,onClick:t,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`tool-dialog-body`,children:[e.kind===`calculator`&&(0,L.jsx)(HO,{}),e.kind===`timestamp`&&(0,L.jsx)(UO,{}),e.kind===`link`&&(0,L.jsx)(WO,{tool:e})]})]})}),document.body)}function VO({image:e,onClose:t}){return(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`lightbox-overlay`,"data-lightbox-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`lightbox-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`lightbox-title`,"data-lightbox-dialog":`1`,children:[(0,L.jsxs)(`div`,{className:`lightbox-head`,children:[(0,L.jsx)(`h2`,{className:`lightbox-title`,id:`lightbox-title`,children:e.name||`图片大图`}),(0,L.jsx)(`button`,{type:`button`,className:`lightbox-close`,"data-lightbox-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭大图`,onClick:t,children:`✕`})]}),(0,L.jsx)(`div`,{className:`lightbox-body`,children:(0,L.jsx)(`img`,{src:e.url,alt:e.name||`图片大图`,className:`lightbox-image`})})]})}),document.body)}function HO(){let[e,t]=(0,u.useState)(`12 * (3 + 4)`),n=Er(e),r=e=>{t(t=>t+e)};return(0,L.jsxs)(`div`,{className:`tool-calc`,"data-tool-calc":`1`,children:[(0,L.jsx)(`input`,{className:`tool-input tool-calc-input`,"data-calc-input":`1`,value:e,maxLength:200,"aria-label":`算式`,spellCheck:!1,autoComplete:`off`,placeholder:`例如 (12 + 8) / 4`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()}}),(0,L.jsx)(`div`,{className:`tool-calc-keys`,"data-calc-keys":`1`,children:[[`7`,`7`],[`8`,`8`],[`9`,`9`],[`÷`,`/`],[`(`,`(`],[`)`,`)`],[`4`,`4`],[`5`,`5`],[`6`,`6`],[`×`,`*`],[`^`,`^`],[`%`,`%`],[`1`,`1`],[`2`,`2`],[`3`,`3`],[`-`,`-`],[`←`,`back`],[`C`,`clear`],[`0`,`0`],[`.`,`.`],[`+`,`+`]].map(([e,n])=>(0,L.jsx)(`button`,{type:`button`,className:`tool-calc-key`,"data-calc-key":n,"aria-label":e===`C`?`清空`:e===`←`?`退格`:`输入 ${e}`,onClick:()=>{n===`clear`?t(``):n===`back`?t(e=>e.slice(0,-1)):r(n)},children:e},e))}),n.ok?(0,L.jsx)(`p`,{className:`tool-calc-result`,"data-calc-result":`1`,"data-calc-value":String(n.value),children:Dr(n.value)}):(0,L.jsx)(`p`,{className:`tool-calc-error`,"data-calc-error":`1`,role:`alert`,children:n.reason})]})}function UO(){let[e,t]=(0,u.useState)(``),n=Or(e),r=n.ok?Ar(n.ms):null;return(0,L.jsxs)(`div`,{className:`tool-stamp`,"data-tool-stamp":`1`,children:[(0,L.jsx)(`input`,{className:`tool-input`,"data-stamp-input":`1`,value:e,maxLength:64,spellCheck:!1,"aria-label":`时间戳或日期`,placeholder:`1757000000 或 2026-10-08T09:00:00`,onChange:e=>t(e.target.value)}),r?(0,L.jsxs)(`dl`,{className:`tool-stamp-out`,"data-stamp-result":`1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`本地时间`}),(0,L.jsx)(`dd`,{"data-stamp-local":`1`,children:r.local})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`ISO(UTC)`}),(0,L.jsx)(`dd`,{"data-stamp-iso":`1`,children:r.iso})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`秒`}),(0,L.jsx)(`dd`,{"data-stamp-seconds":`1`,children:r.seconds})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`毫秒`}),(0,L.jsx)(`dd`,{"data-stamp-ms":`1`,children:r.milliseconds})]})]}):(0,L.jsx)(`p`,{className:`tool-stamp-error`,"data-stamp-error":`1`,role:`alert`,children:n.ok?`这个日期无法显示。`:n.reason})]})}function WO({tool:e}){let[t,n]=(0,u.useState)(!1),r=async()=>{let e=await vd(`请为 Super Pi 开发一个全局右侧栏工具并自动挂载。不要启动独立 HTTP 服务器。通过内置 tool_register 提交完整的 HTML/JS/CSS 文件;工具将被 Super Pi 保存并在所有 workspace 可用。如需计算,注册一个 Python 脚本(不接受 shell 命令),参数经 JSON stdin 传入,stdout 只输出 JSON 结果。在页面里加载 ./super-pi-tool.js,使用 SuperPiTool.run(params)、wait(runId)、get(runId) 和 cancel(runId) 执行、等待、查看和取消任务。它们会自动绑定当前工具;不要调用 /api/exec,也不要猜测 toolId。`);n(e),window.setTimeout(()=>n(!1),1800)};return(0,L.jsxs)(`div`,{className:`tool-link`,"data-tool-link":e.id,children:[(0,L.jsx)(`p`,{className:`tool-hint`,children:`这是旧版外部网页链接;新工具由 Super Pi 统一托管,并可选绑定受控 Python 脚本。`}),(0,L.jsx)(`code`,{className:`tool-link-url`,"data-tool-link-url":e.id,children:e.url}),(0,L.jsxs)(`div`,{className:`tool-link-actions`,children:[(0,L.jsx)(`a`,{className:`tool-link-open`,"data-tool-link-open":e.id,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:e.url,children:`在新标签页打开 ↗`}),(0,L.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-copy-prompt":e.id,onClick:()=>void r(),children:t?`已复制`:`复制开发 Prompt`})]}),/^https?:\/\//i.test(e.url??``)&&(0,L.jsx)(`iframe`,{className:`tool-link-frame`,"data-tool-frame":e.id,src:e.url,title:e.name,sandbox:`allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,referrerPolicy:`no-referrer`})]})}var GO=`(max-width: 1100px)`,KO=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function qO(e){let t=`super-pi.mounted-tool.owner.`+e;try{let e=window.localStorage.getItem(t);if(e&&/^[0-9a-f]{32}$/.test(e))return e}catch{}let n=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(t,n)}catch{}return n}function JO({tool:e,onClose:t}){let n=(0,u.useRef)(null);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,u.useMemo)(()=>qO(e.id),[e.id]);(0,u.useLayoutEffect)(()=>Ke(()=>n.current,e.id,r),[e.id,r]);let i=e.dialogSize??{width:1100,height:780},a={width:`min(${i.width}px, calc(100vw - 32px))`,height:`min(${i.height}px, calc(100dvh - 32px))`};return(0,Ct.createPortal)((0,L.jsx)(`div`,{className:`tool-overlay`,"data-mounted-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`tool-dialog mounted-tool-dialog`,style:a,"data-mounted-tool-dialog":e.id,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,L.jsxs)(`h2`,{className:`tool-dialog-title`,children:[(0,L.jsx)(AT,{className:`tool-dialog-glyph`,glyph:MT(e)}),e.name]}),(0,L.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,onClick:t,children:`✕`})]}),(0,L.jsx)(`div`,{className:`tool-dialog-body`,children:(0,L.jsx)(`iframe`,{ref:n,className:`tool-link-frame`,src:Oe(`/tools/${encodeURIComponent(e.id)}/#super-pi-owner=${r}`),title:e.name,sandbox:`allow-forms allow-modals allow-popups allow-scripts`,referrerPolicy:`no-referrer`})})]})}),document.body)}function YO(e,t,n){let r=Math.max(0,Math.round(n)-480),i=KO(520,180,Math.max(180,r-240)),a=KO(Math.round(e),180,i),o=KO(640,240,Math.max(240,r-a));return{sidebar:a,rail:KO(Math.round(t),240,o),sidebarMin:180,sidebarMax:i,railMin:240,railMax:o,sumCap:r}}var XO=`super-pi.rail-widths.v1`,ZO=`super-pi.reader-state.v1`,QO=`super-pi.folded-groups.v1`;function $O(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.folded-groups.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t=e=>{let t={};if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t};return{workspaces:t(e.workspaces),archived:t(e.archived)}}catch{return{}}}function ek(e){try{typeof window<`u`&&window.localStorage.setItem(QO,JSON.stringify(e))}catch{}}var tk=e=>{let t=document.querySelector(`[data-workspace-group="${CSS.escape(e)}"]`);return t?[...t.querySelectorAll(`.conversation-row[data-session-root]`)].map(e=>({id:e.dataset.sessionRoot??``,middle:(()=>{let t=e.getBoundingClientRect();return t.top+t.height/2})()})).filter(e=>e.id!==``):[]},nk=6,rk=400,ik=32,ak=48,ok=e=>{e.dataset.programmaticScroll=`true`,window.setTimeout(()=>{delete e.dataset.programmaticScroll},0)};function sk(e,t,n=!1,r=!1){let i=e.scrollHeight-e.clientHeight-e.scrollTop,a=n?!1:r?!0:t.followTail?i<=ak:i<=ik,o,s;if(!a){let t=e.getBoundingClientRect().top,n=[...e.querySelectorAll(`[data-transcript-key]`)].find(e=>e.getBoundingClientRect().bottom>t);o=n?.dataset.transcriptKey,s=n?n.getBoundingClientRect().top-t:void 0}return{followTail:a,scrollTop:e.scrollTop,...o?{anchorKey:o,anchorOffset:s}:{}}}function ck(){try{if(typeof window>`u`)return{conversations:{}};let e=JSON.parse(window.localStorage.getItem(`super-pi.reader-state.v1`)??`null`);if(!e||typeof e!=`object`)return{conversations:{}};let t={};if(e.conversations&&typeof e.conversations==`object`)for(let[n,r]of Object.entries(e.conversations)){let e=r;typeof e.followTail==`boolean`&&(t[n]={followTail:e.followTail,scrollTop:Number.isFinite(e.scrollTop)?Math.max(0,Number(e.scrollTop)):0,...typeof e.anchorKey==`string`?{anchorKey:e.anchorKey}:{},...Number.isFinite(e.anchorOffset)?{anchorOffset:Number(e.anchorOffset)}:{}})}let n={};if(e.readAt&&typeof e.readAt==`object`)for(let[t,r]of Object.entries(e.readAt))typeof r==`string`&&(n[t]=r);return{activeId:typeof e.activeId==`string`?e.activeId:void 0,workspaceId:typeof e.workspaceId==`string`?e.workspaceId:void 0,conversations:t,readAt:n}}catch{return{conversations:{}}}}function lk(e){try{typeof window<`u`&&window.localStorage.setItem(ZO,JSON.stringify(e))}catch{}}var uk=`super-pi.session-tabs.v1`;function dk(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function fk(e,t,n){let r=e.touched.has(t),i=e.touched;if(r){let r=new Set(e.touched);r.delete(t),n&&r.add(n),i=r}return{ids:e.ids.flatMap(e=>e===t?n?[n]:[]:[e]),previewId:e.previewId===t?n&&!r?n:void 0:e.previewId,emptied:e.emptied,touched:i}}function pk(){try{if(typeof window>`u`)return{ids:[]};let e=JSON.parse(qe(`super-pi.session-tabs.v1`)??`null`);if(!e||typeof e!=`object`)return{ids:[]};let t=e,n=Array.isArray(t.ids)?[...new Set(t.ids.filter(e=>typeof e==`string`))]:[],r=Array.isArray(t.touched)?[...new Set(t.touched.filter(e=>typeof e==`string`))]:[],i=typeof t.previewId==`string`&&n.includes(t.previewId)&&!r.includes(t.previewId)?t.previewId:void 0;i&&i!==t.activeId&&(n=n.filter(e=>e!==i));let a=typeof t.activeId==`string`&&n.includes(t.activeId)?t.activeId:void 0,o=typeof t.workspaceLandingId==`string`?t.workspaceLandingId:void 0;return{ids:n,activeId:a,workspaceLandingId:o,previewId:i===a?i:void 0,touched:r,emptied:n.length===0&&(t.emptied===!0||!!i),selectionCleared:t.selectionCleared===!0}}catch{return{ids:[]}}}function mk(e,t,n,r=!1){try{if(typeof window>`u`)return;let{ids:i,previewId:a,touched:o,emptied:s}=e;Je(uk,JSON.stringify({ids:i,...t&&i.includes(t)?{activeId:t}:{},...n?{workspaceLandingId:n}:{},...a&&i.includes(a)?{previewId:a}:{},...o.size?{touched:[...o]}:{},...s?{emptied:s}:{},...r?{selectionCleared:!0}:{}}))}catch{}}function hk(){try{if(typeof window>`u`)return{};let e=window.localStorage.getItem(XO);if(e===null)return{};let t=JSON.parse(e),n=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?Math.round(e):void 0;return{sidebar:n(t.sidebar),rail:n(t.rail)}}catch{return{}}}function gk(e){try{if(typeof window>`u`)return;window.localStorage.setItem(XO,JSON.stringify(e))}catch{}}function _k({side:e,width:t,min:n,max:r,label:i,onWidth:a}){let[o,s]=(0,u.useState)(!1),c=e=>e.shiftKey?64:16;return(0,L.jsx)(`div`,{className:`rail-resizer rail-resizer-${e}${o?` rail-resizer-dragging`:``}`,"data-rail-resizer":e,"data-rail-resizer-dragging":o?`true`:`false`,"data-rail-resizer-width":t,role:`separator`,"aria-orientation":`vertical`,"aria-label":i,"aria-valuenow":t,"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,onMouseDown:i=>{i.preventDefault(),i.currentTarget.focus();let o=i.clientX,c=t;s(!0);let l=document.body,u=l.style.cursor,d=l.style.userSelect;l.style.cursor=`col-resize`,l.style.userSelect=`none`;let f=t=>{let i=e===`left`?t.clientX-o:o-t.clientX;a(KO(c+i,n,r))},p=()=>{l.style.cursor=u,l.style.userSelect=d,s(!1),window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,p)};window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,p)},onKeyDown:i=>{let o=c(i);i.key===`ArrowLeft`?(i.preventDefault(),a(KO(e===`left`?t-o:t+o,n,r))):i.key===`ArrowRight`?(i.preventDefault(),a(KO(e===`left`?t+o:t-o,n,r))):i.key===`Home`?(i.preventDefault(),a(n)):i.key===`End`&&(i.preventDefault(),a(r))}})}var vk=`super-pi.composer-height.v1`,yk=148,bk=.55,xk=()=>Math.max(yk,Math.round((typeof window>`u`?800:window.innerHeight)*bk)),Sk=e=>{let t=Number.isFinite(e)?e:yk;return Math.round(Math.min(xk(),Math.max(yk,t)))},Ck=()=>{try{let e=window.localStorage.getItem(vk);return e===null?yk:Sk(Number(e))}catch{return yk}};function wk({height:e,onHeight:t}){let[n,r]=(0,u.useState)(!1),i=e=>e.shiftKey?64:16,a=xk();return(0,L.jsx)(`div`,{className:`composer-resize${n?` composer-resize-dragging`:``}`,"data-composer-resize":`1`,"data-composer-resize-dragging":n?`true`:`false`,"data-composer-height":e,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整消息编辑区高度`,"aria-valuenow":e,"aria-valuemin":yk,"aria-valuemax":a,tabIndex:0,onMouseDown:n=>{n.preventDefault(),n.currentTarget.focus();let i=n.clientY,a=e;r(!0);let o=document.documentElement,s=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let c=e=>{let t=Sk(a+(i-e.clientY));o.style.setProperty(`--composer-height`,`${t}px`)},l=()=>{document.body.style.cursor=``,document.body.style.userSelect=s;let n=Number.parseFloat(o.style.getPropertyValue(`--composer-height`));r(!1),window.removeEventListener(`mousemove`,c),window.removeEventListener(`mouseup`,l),t(Number.isFinite(n)?n:e)};window.addEventListener(`mousemove`,c),window.addEventListener(`mouseup`,l)},onKeyDown:n=>{let r=i(n);n.key===`ArrowUp`?(n.preventDefault(),t(Sk(e+r))):n.key===`ArrowDown`?(n.preventDefault(),t(Sk(e-r))):n.key===`Home`?(n.preventDefault(),t(yk)):n.key===`End`?(n.preventDefault(),t(a)):n.key===`PageUp`?(n.preventDefault(),t(Sk(e+96))):n.key===`PageDown`&&(n.preventDefault(),t(Sk(e-96)))}})}function Tk(e,t,n){if(!e.length)return;let r=n?e.find(e=>e.workspaceId===n):void 0;if(r)return r;if(!(n&&t.some(e=>e.id===n)))return n?e.find(e=>h(e.workspaceId).server===h(n).server):e[0]}function Ek(e,t,n){let r=n&&e?JSON.stringify([e,t,n]):void 0,[i,a]=(0,u.useState)();(0,u.useEffect)(()=>{if(!r||!n||!e)return;let i=new AbortController;return ke(`/api/files/diff?${new URLSearchParams({workspaceId:e,path:n,...t?{cwd:t}:{}})}`,{signal:i.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{i.signal.aborted||a({scope:r,diff:e,error:``})}).catch(e=>{i.signal.aborted||a({scope:r,diff:null,error:e instanceof Error?e.message:`读取差异失败`})}),()=>i.abort()},[r,e,t,n]);let o=i?.scope===r?i:void 0;return{diff:o?.diff??null,error:o?.error??``,loading:!!r&&!o}}function Dk(e){try{let t=`super-pi.browser-notification-events`,n=Date.now(),r=JSON.parse(window.localStorage.getItem(t)??`[]`).filter(e=>Array.isArray(e)&&typeof e[0]==`string`&&typeof e[1]==`number`&&n-e[1]<864e5);return!r.some(([t])=>t===e)&&(window.localStorage.setItem(t,JSON.stringify([...r.slice(-63),[e,n]])),!0)}catch{return!0}}function Ok(){let[e,t]=(0,u.useState)(QE),[n,r]=(0,u.useState)(()=>{try{return typeof window<`u`&&window.localStorage.getItem(`super-pi.browser-notifications`)===`enabled`}catch{return!1}}),[i,a]=(0,u.useState)(()=>Mi()),o=(0,u.useCallback)(()=>a(Mi()),[]),s=(0,u.useRef)(new Map),c=(0,u.useRef)(!1),l=(0,u.useRef)(new Map),d=(0,u.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return Lt(n,t)})},[]),[f,p]=(0,u.useState)(()=>zf().map(e=>{let t=new Date().toISOString();return{id:e.clientId,key:`send:${e.conversationId}:${e.clientId}`,serverId:se(e.conversationId),retry:!0,command:{...e},apply:n=>Uf(n,e,t),accepted:t=>!!t.conversations.find(t=>t.id===e.conversationId)?.messages.some(t=>t.id===Hf(e))}})),m=(0,u.useRef)(f),_=(0,u.useRef)(null);_.current||=ck();let v=(0,u.useRef)(null);v.current||=pk();let y=v.current,b=(0,u.useRef)(null);b.current||=Ye();let x={current:b.current},S=(0,u.useRef)(null);S.current||=Xe();let w=S.current,T=f.reduce((e,t)=>t.apply(e),e),[E,D]=(0,u.useState)(y.workspaceLandingId||y.selectionCleared||y.emptied?void 0:y.activeId??_.current.activeId),[O,k]=(0,u.useState)(y.workspaceLandingId??(y.selectionCleared?x.current.kind===`workspace`?x.current.workspaceId:void 0:_.current.workspaceId)),[A,j]=(0,u.useState)(!1),M=oe(),N=A&&M.statuses.get(M.activeServer)?.state===`online`,[ee,te]=(0,u.useState)(),[ne,re]=(0,u.useState)(()=>$O().workspaces??{}),[F,ie]=(0,u.useState)(()=>({ids:y.ids,previewId:y.previewId,touched:new Set(y.touched??[]),emptied:y.emptied})),ae=F.ids,he=F.previewId,ge=(0,u.useRef)(0),[_e,ve]=(0,u.useState)(),[ye,be]=(0,u.useState)({entries:[],index:-1}),[xe,Se]=(0,u.useState)(),Ce=(0,u.useRef)(new Set),we=F.emptied===!0,[Te,Ee]=(0,u.useState)(!1),[De,Ae]=(0,u.useState)(!1),[je,Me]=(0,u.useState)(),Pe=(0,u.useRef)(null),Fe=(0,u.useRef)(void 0),Ie=(0,u.useRef)(_.current.conversations),Le=(0,u.useRef)(ae);Le.current=ae;let Re=(0,u.useRef)(_.current.readAt??{}),[ze,Be]=(0,u.useState)(0),[Ve,Ue]=(0,u.useState)(lt),[We,Ge]=(0,u.useState)(()=>w.groups.length?w.groups:Ve?[Ve]:[]),[Ke,qe]=(0,u.useState)(w.view?w.view===`group`:!!Ve),[et,nt]=(0,u.useState)(()=>w.view??(Ve?`group`:`session`)),{index:rt,reload:it,remember:at,forget:ot,activities:st,recordActivity:ct}=yt(T.workspaces,N),[mt,ht]=(0,u.useState)(()=>new Set),bt=Ve?.workspaceId??``,St=Ve?.roomId??``,Ct=rt[bt]?.rooms.find(e=>e.id===St),wt=Ct?.title;(0,u.useEffect)(()=>{ut(et===`group`?Ve:void 0)},[Ve,et]),(0,u.useEffect)(()=>{et===`group`&&Te&&!T.workspaces.some(e=>e.id===bt&&!e.closedAt)&&(qe(!1),nt(`session`))},[et,Te,T.workspaces,bt]);let Tt=(0,u.useRef)(null),Et=(0,u.useRef)(null),Dt=(0,u.useRef)(void 0),Ot=(0,u.useRef)(!1),kt=(0,u.useRef)(!0),[At,jt]=(0,u.useState)({followTail:!0,scrollTop:0}),Mt=(0,u.useRef)(!1),Nt=(0,u.useRef)(new Map),Pt=(0,u.useRef)(void 0),Ft=(0,u.useRef)([]),It=(0,u.useRef)(void 0),Lt=(0,u.useCallback)((e,t)=>{let n=new Map(t.conversations.map(e=>[e.id,e]));return{...e,conversations:e.conversations.map(e=>{let t=n.get(e.id);if(e.messagesLoaded===!1||!t||t.messagesLoaded===!1||t.status!==`running`)return e;let r=new Map(t.messages.map(e=>[e.id,e]));return{...e,messages:e.messages.map(e=>{let t=r.get(e.id);return!t||!(t.content.length>e.content.length||(t.thinking?.length??0)>(e.thinking?.length??0))?e:{...e,content:t.content,thinking:t.thinking,thinkingActive:t.thinkingActive,thinkingBlocks:iD(t.thinkingBlocks,e.thinkingBlocks)}})}})}},[]),Rt=(0,u.useCallback)(()=>{if(It.current!==void 0&&(cancelAnimationFrame(It.current),It.current=void 0),!Ft.current.length)return;let e=Ft.current;Ft.current=[];let t=new Map;for(let n of e){let e=`${n.conversationId}\u0000${n.messageId}`,r=t.get(e)??[];r.push(n),t.set(e,r)}d(e=>({...e,conversations:e.conversations.map(e=>{let n=e.messages.map(n=>{let r=t.get(`${e.id}\u0000${n.id}`);if(!r)return n;let i={...n};for(let e of r){if(e.type===`message.delta`){i.content+=e.delta;continue}if(i.thinkingActive=e.active,!e.delta)continue;let t=e.at??i.content.length,n=rD(i.thinkingBlocks??[],e,t);i={...i,thinking:(i.thinking??``)+e.delta,thinkingBlocks:n}}return i});return n.every((t,n)=>t===e.messages[n])?e:{...e,messages:n}})}))},[]),zt=(0,u.useCallback)(e=>{let t=Ft.current,n=t.at(-1);n&&n.type===e.type&&n.conversationId===e.conversationId&&n.messageId===e.messageId&&(e.type!==`message.thinking`||n.type===`message.thinking`&&n.at===e.at&&n.active===e.active&&n.blockIndex===e.blockIndex)?t[t.length-1]={...e,delta:n.delta+e.delta}:t.push(e),It.current===void 0&&(It.current=requestAnimationFrame(Rt))},[Rt]),Bt=(0,u.useCallback)(e=>{Pt.current=e},[]),[Vt,Wt]=(0,u.useState)(()=>$O().archived??{});(0,u.useEffect)(()=>{ek({workspaces:ne,archived:Vt})},[ne,Vt]);let[Gt,Kt]=(0,u.useState)(()=>zT());(0,u.useEffect)(()=>{BT(Gt)},[Gt]);let[qt,Jt]=(0,u.useState)(),Yt=(0,u.useRef)(0),Xt=(0,u.useRef)(``),Zt=(e,t,n,r)=>{let i=(e.target instanceof Element?e.target:void 0)?.closest(`button`);if(i&&!i.classList.contains(`conversation`)||e.button!==0)return;let a=e.clientY,o=e.pointerType===`touch`,s=!1,c,l=[],u,d=!1,f=e=>{let t=l.filter(e=>e.id!==n);if(t.length===0){u=void 0,d=!1;return}let r=0;for(;r<t.length&&t[r].middle<e;)r+=1;r<t.length?(u=t[r].id,d=!1):(u=t[t.length-1].id,d=!0)},p=()=>Jt(e=>e&&e.dropRootId===u&&e.dropAfter===d?e:{workspaceId:t,conversationId:n,dropRootId:u,dropAfter:d}),m=()=>{s||(s=!0,l=tk(t),f(a),document.body.style.userSelect=`none`,p())},h=e=>{if(!s){if(o){c!==void 0&&window.clearTimeout(c),c=void 0;return}if(Math.abs(e.clientY-a)<nk)return;m()}f(e.clientY),p()},g=e=>{if(window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,v),document.removeEventListener(`touchmove`,y),c!==void 0&&window.clearTimeout(c),document.body.style.userSelect=``,s&&e){let e=r.filter(e=>e!==n),i=u===void 0?e.length:d?e.indexOf(u)+1:e.indexOf(u);Kt(e=>({...e,[t]:LT(r,n,i)})),Yt.current=Date.now(),Xt.current=n}Jt(void 0)},_=()=>g(!0),v=()=>g(!1),y=e=>{s&&e.preventDefault()};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,v),o&&(document.addEventListener(`touchmove`,y,{passive:!1}),c=window.setTimeout(m,rk))},[Qt,$t]=(0,u.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage.getItem(`super-pi.user-nickname`)??``}catch{return``}}),en=e=>{let t=e.slice(0,24);$t(t);try{window.localStorage.setItem(`super-pi.user-nickname`,t)}catch{}},an=Qt.trim()||`你`,[cn,ln]=(0,u.useState)(),[un,dn]=(0,u.useState)([]),[fn,pn]=(0,u.useState)([]),[mn,hn]=(0,u.useState)(),[gn,_n]=(0,u.useState)(),[yn,bn]=(0,u.useState)([]),[xn,Sn]=(0,u.useState)([]),[Cn,wn]=(0,u.useState)(),[Tn,En]=(0,u.useState)(),[Dn,On]=(0,u.useState)(),[kn,An]=(0,u.useState)(),[jn,Mn]=(0,u.useState)(),Nn=Ei(Dn),Pn=(0,u.useMemo)(()=>un.filter(e=>e.request.blocking),[un]),[Fn,In]=(0,u.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1100px)`).matches),[Ln,Rn]=(0,u.useState)(`chat`),[zn,Bn]=(0,u.useState)(!1),Vn=(0,u.useCallback)(()=>{Rn(`chat`),window.matchMedia(`(max-width: 700px)`).matches&&In(!0)},[]),[Hn,Un]=(0,u.useState)(!1),[Wn,Gn]=(0,u.useState)(x.current.kind),[Kn,qn]=(0,u.useState)(()=>x.current.serverId??localStorage.getItem(`super-pi.server-filter`)??`all`),[Jn,Yn]=(0,u.useState)(x.current.workspaceId??_.current.workspaceId),[Xn,Zn]=(0,u.useState)(x.current.repoId??_.current.workspaceId),[Qn,$n]=(0,u.useState)(y.selectionCleared===!0);(0,u.useEffect)(()=>{try{Je(`super-pi.sidebar-scope.v1`,JSON.stringify({kind:Wn,serverId:Kn,workspaceId:Jn,repoId:Xn}))}catch{}},[Wn,Kn,Jn,Xn]);let er=(0,u.useRef)(Qn);er.current=Qn;let[tr,nr]=(0,u.useState)(()=>typeof window>`u`?1440:window.innerWidth);(0,u.useEffect)(()=>{let e=()=>nr(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let[rr,ir]=(0,u.useState)(nn);(0,u.useEffect)(()=>rn(rr),[rr]);let[ar,or]=(0,u.useState)(hk),sr=YO(ar.sidebar??270,ar.rail??320,tr>1100?tr-80:tr);(0,u.useEffect)(()=>{gk({sidebar:ar.sidebar??270,rail:ar.rail??320})},[ar.sidebar,ar.rail]);let cr=e=>or(t=>({...t,sidebar:e})),lr=e=>or(t=>({...t,rail:e})),[dr,fr]=(0,u.useState)(null);(0,u.useEffect)(()=>{fr(Ck())},[]),(0,u.useEffect)(()=>{dr!==null&&document.documentElement.style.setProperty(`--composer-height`,`${dr}px`)},[dr]);let pr=e=>{let t=Sk(e);fr(t);try{window.localStorage.setItem(vk,String(t))}catch{}};(0,u.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(GO),t=e=>{e.matches&&In(!0)};return e.addEventListener(`change`,t),e.matches&&In(!0),()=>e.removeEventListener(`change`,t)},[]);let mr=tr<=1100;(0,u.useEffect)(()=>{if(!mr||Fn)return;let e=e=>{e.key===`Escape`&&(e.defaultPrevented||document.querySelector(`.tool-overlay, .lightbox-overlay, .quick-open-backdrop, .ctx-menu, .overlay, .picker-menu, .content-search-overlay`)||(e.preventDefault(),In(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[mr,Fn]);let[hr,gr]=(0,u.useState)({}),[_r,vr]=(0,u.useState)({}),[yr,br]=(0,u.useState)({}),[xr,Sr]=(0,u.useState)({}),[Cr,wr]=(0,u.useState)(null),[Tr,Er]=(0,u.useState)(),[Dr,Or]=(0,u.useState)(()=>new Set);(0,u.useEffect)(()=>{Or(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>{let t=T.conversations.find(t=>t.id===e);return t?pO(t):!1}));return t.size===e.size?e:t})},[T.conversations]);let[kr,Ar]=(0,u.useState)(),[jr,Mr]=(0,u.useState)(),Nr=(0,u.useRef)(new Map),[Pr,Fr]=(0,u.useState)(()=>{let e=Wf(`super-pi.composer-drafts.v1`,{});return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,attachments:UD(t.text,t.attachments)}]))}),Ir=(0,u.useRef)(Pr),Lr=(0,u.useRef)(!1);Ir.current=Pr,(0,u.useEffect)(()=>{let e=()=>{let e=Object.entries(Ir.current).filter(([e,t])=>!e.startsWith(`pending:`)&&(t.text||t.images.length||t.attachments.length)).map(([e,{text:t,images:n,attachments:r}])=>[e,{text:t,images:n,attachments:r,uploading:0}]),t=Gf(`super-pi.composer-drafts.v1`,Object.fromEntries(e));!t&&e.length&&!Lr.current&&Ds(`浏览器无法保存聊天草稿,刷新前请先保留这段内容。`,`warning`),Lr.current=!t&&e.length>0},t=window.setTimeout(e,250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[Pr]);let Rr=(0,u.useRef)(new Set),[zr,Br]=(0,u.useState)([]),[Vr,Hr]=(0,u.useState)([]),[Ur,Wr]=(0,u.useState)(),[Gr,Kr]=(0,u.useState)(!1),qr=(0,u.useRef)(null),Jr=(0,u.useRef)(!1),Yr=(0,u.useRef)(0),Xr=(0,u.useRef)([]),Zr=(0,u.useRef)(void 0),Qr=(0,u.useRef)(!1),ei=(0,u.useRef)(new Set),ti=(0,u.useRef)(new Set),ni=(0,u.useRef)(new Map),ri=(0,u.useRef)(new Map),[ii,ai]=(0,u.useState)(()=>Date.now());(0,u.useEffect)(()=>{let e=window.setInterval(()=>ai(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let oi=(0,u.useMemo)(()=>T.conversations.filter(e=>!e.archivedAt),[T.conversations]),si=(0,u.useMemo)(()=>e.conversations.filter(e=>!e.archivedAt),[e.conversations]),ci=(0,u.useMemo)(()=>new Set(T.collapsedConversationIds??[]),[T.collapsedConversationIds]),R=(0,u.useMemo)(()=>{let e=oi.find(e=>e.id===E);if(e)return e;if(!(we||Qn||P(E??O)))return Tk(oi,T.workspaces,O)},[we,Qn,E,oi,O,T.workspaces]),li=(0,u.useMemo)(()=>R?{workspaceId:R.workspaceId,conversationId:R.id,onImageOpen:Wr}:void 0,[R?.workspaceId,R?.id]),[ui,di]=(0,u.useState)(`queue`),fi=!!(R&&pO(R));(0,u.useEffect)(()=>{di(`queue`)},[R?.id,fi]);let[pi,mi]=(0,u.useState)([]),hi=(0,u.useMemo)(()=>$e(R?.parentConversationId,R?.parentConversationId?T.conversations.find(e=>e.id===R.parentConversationId):void 0),[R,T.conversations]),gi=!!(R&&T.unlockedChildConversationIds?.includes(R.id)),_i=hi&&!gi,vi=(0,u.useMemo)(()=>(T.conversations||[]).filter(e=>e.parentConversationId===R?.id),[T.conversations,R?.id]),yi=(0,u.useMemo)(()=>(T.conversations||[]).find(e=>e.id===R?.parentConversationId),[T.conversations,R?.parentConversationId]),bi=(0,u.useMemo)(()=>R?tt({conversation:R,parent:yi,directChildren:vi,isTopLevelUnread:!1}):null,[R,yi,vi]),xi=Tt.current;if(xi){let e=xi.dataset.messageScrollContainer;e&&R?.id&&e!==R?.id&&xi.querySelector(`[data-transcript-key]`)&&(Ie.current[e]=sk(xi,Ie.current[e]??{followTail:!0,scrollTop:0}))}kt.current=R?.messagesLoaded!==!1,(0,u.useEffect)(()=>{if(!Te||P(E??O)||(we||Qn)&&!E||E&&si.some(e=>e.id===E)||E&&m.current.some(e=>e.temporaryId===E))return;let e=Tk(oi,T.workspaces,O);we&&e||(E&&!e&&et!==`group`&&(ge.current++,nt(`session`)),D(e?.id),e&&ie(t=>t.emptied||t.ids.length===0||t.ids.includes(e.id)?t:{...t,ids:[...t.ids,e.id]}))},[we,Qn,E,si,oi,Te,O,T.workspaces,et]),(0,u.useEffect)(()=>{te(void 0)},[E,O]);let Si=(0,u.useMemo)(()=>T.workspaces.find(e=>e.id===O)??(Qn||P(O)?void 0:T.workspaces[0]),[T.workspaces,O,Qn]),Ci=Si&&!oi.some(e=>e.workspaceId===Si.id)?Si:void 0,wi=Si?.id.startsWith(`pending:`)===!0,[Ti,Oi]=(0,u.useState)(``);(0,u.useEffect)(()=>{Oi(``)},[Si?.id]);let ki=(0,u.useRef)(O);ki.current=O,(0,u.useEffect)(()=>{R&&k(R.workspaceId)},[R?.id]),(0,u.useEffect)(()=>{Zr.current=E},[E]),(0,u.useEffect)(()=>{Dt.current=R?.id},[R?.id]);let Ai=(0,u.useCallback)(e=>{let t=e.activity.lastReplyAt,n=dt({workspaceId:e.workspaceId,roomId:e.id});!t||t<=(Re.current[n]??``)||(Re.current[n]=t,Be(e=>e+1),lk({activeId:Zr.current,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current}))},[]);xt(Re,T.conversations,()=>{Be(e=>e+1),lk({activeId:Zr.current,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current})}),(0,u.useEffect)(()=>{let e=R?.id;if(!e)return;let t=T.conversations.find(t=>t.id===e);if(!t||t.messagesLoaded===!1)return;let n=()=>{let n=Tt.current;document.visibilityState!==`visible`||!n||n.getBoundingClientRect().height<=0||t.updatedAt<=(Re.current[e]??``)||(Re.current[e]=t.updatedAt,Be(e=>e+1),lk({activeId:Zr.current,workspaceId:R?.workspaceId??O,conversations:Ie.current,readAt:Re.current}))},r=requestAnimationFrame(n);return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{cancelAnimationFrame(r),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[R?.id,T.conversations,et]),(0,u.useEffect)(()=>{let e=R?.workspaceId??O;N&&Te&&e&&!e.startsWith(`pending:`)&&!R?.id.startsWith(`pending:`)&&lk({activeId:R?.id,workspaceId:e,conversations:Ie.current,readAt:Re.current})},[R?.id,R?.workspaceId,N,Te,O]),(0,u.useEffect)(()=>{let e=Tt.current;if(et!==`session`||!e||!R?.id||R.messagesLoaded===!1)return;let t=R.id;Mt.current=!1;let n=Ie.current[t]??{followTail:!0,scrollTop:0};Ie.current[t]=n,jt(n);let r=requestAnimationFrame(()=>{if(Tt.current!==e)Ot.current=!1;else{if(n.followTail)ok(e),e.scrollTop=e.scrollHeight;else{let t=n.anchorKey?e.querySelector(`[data-transcript-key="${CSS.escape(n.anchorKey)}"]`):null;e.scrollTop=t?Math.max(0,e.scrollTop+t.getBoundingClientRect().top-(n.anchorOffset??0)-e.getBoundingClientRect().top):n.scrollTop}Ot.current=!1}});return()=>cancelAnimationFrame(r)},[R?.id,R?.messagesLoaded,et]),(0,u.useLayoutEffect)(()=>{Ot.current=!0},[R?.id,R?.messagesLoaded,et]);let ji=(0,u.useCallback)((e,t=!1,n=!1)=>{let r=Dt.current;if(!r||Ot.current||!kt.current)return;let i=sk(e,Ie.current[r]??{followTail:!0,scrollTop:0},t,n);Mt.current=!i.followTail,Ie.current[r]=i,jt(i),lk({activeId:r,workspaceId:ki.current,conversations:Ie.current,readAt:Re.current})},[]),z=R?.id??``,Li=Pr[z]??{text:``,images:[],attachments:[],uploading:0},Ri=Li.text,zi=Li.images,Bi=Li.attachments,Vi=Object.keys(Li.pendingSkills??{}).length>0,Hi=Li.uploading,Ui=(e,t)=>Fr(n=>({...n,[e]:t(n[e]??{text:``,images:[],attachments:[],uploading:0})})),Wi=(e,t)=>({...e,text:t,attachments:UD(t,e.attachments),pendingSkills:e.pendingSkills&&Object.fromEntries(Object.entries(e.pendingSkills).filter(([e])=>Wd(t,e)))}),Gi=e=>Ui(z,t=>Wi(t,e)),Ki=(e,t,n,r)=>{let i=ur();Ui(n,n=>{let r=Wi(n,t);return{...r,pendingSkills:{...r.pendingSkills,[e]:i}}});let a=t=>t[n]?.pendingSkills?.[e]===i?n:n.startsWith(`pending:`)?Object.keys(t).find(n=>t[n].pendingSkills?.[e]===i):void 0,o=t=>Fr(n=>{let r=a(n);if(!r)return n;let i=n[r],o={...i.pendingSkills};delete o[e];let s=t?[...i.attachments.filter(t=>t.id!==e),t]:i.attachments;return{...n,[r]:{...i,pendingSkills:o,attachments:s}}});ke(`/api/skills/read?${new URLSearchParams({name:e,workspaceId:r})}`,{signal:AbortSignal.timeout(1e4)}).then(async t=>{if(!t.ok)throw Error(`读取技能失败`);let n=await t.json();if(typeof n.content!=`string`)throw Error(`读取技能失败`);o({kind:`skill`,id:e,name:n.name??e.slice(6),content:n.content})}).catch(()=>{a(Ir.current)&&Ds(`读取技能失败`,`error`),o()})},qi=(e,t)=>Ui(R?.id??``,n=>({...n,attachments:n.attachments.filter(n=>n.kind!==e||n.id!==t)})),[Ji,Yi]=(0,u.useState)({visible:!1,query:``,rect:null}),Xi=JSON.stringify([R?.id,R?.workspaceId,R?.cwd??``]),[Zi,Qi]=(0,u.useState)(),$i=(0,u.useRef)(null),[ea,ta]=(0,u.useState)(),na=(0,u.useRef)(void 0),ra=(0,u.useRef)(``),ia=!_i&&Zi?.scope===Xi?Zi:void 0,aa=e=>{let t=!Jr.current&&!_i&&R?qd(e.value,e.selectionStart,e.selectionEnd):void 0,n=JSON.stringify([Xi,t]);return!t||ra.current===n?(Qi(void 0),!1):(Qi({scope:Xi,token:t,rect:e.getBoundingClientRect()}),Yi({visible:!1,query:``,rect:null}),!0)},oa=()=>{ra.current=JSON.stringify([Xi,ia?.token]),Qi(void 0)};(0,u.useEffect)(()=>{Qi(void 0),ra.current=``},[Xi]),(0,u.useLayoutEffect)(()=>{let e=na.current;na.current=void 0,e?.scope===Xi&&e.text===Ri&&(Et.current?.focus(),Et.current?.setSelectionRange(e.caret,e.caret))},[Ri,Xi]),(0,u.useEffect)(()=>{let e=()=>{let e=Et.current;e&&Qi(t=>t?{...t,rect:e.getBoundingClientRect()}:void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let sa=e=>Ui(R?.id??``,t=>({...t,images:typeof e==`function`?e(t.images):e})),ca=ae.length>0?ae:we?[]:R?[R.id]:[],la=(0,u.useMemo)(()=>ca.map(e=>oi.find(t=>t.id===e)).filter(e=>e!==void 0),[ca,oi]),ua=Ci?void 0:la.filter(e=>e.id!==he).at(-1)?.id,da=la.some(e=>e.id===R?.id);(0,u.useEffect)(()=>{if(!Te)return;let e=new Set(oi.map(e=>e.id));ie(t=>{let n=t.ids.filter(t=>e.has(t)||P(t)),r=t.previewId&&(e.has(t.previewId)||P(t.previewId))?t.previewId:void 0;return n.length===t.ids.length&&r===t.previewId?t:{...t,ids:n,previewId:r}})},[Te,oi]),(0,u.useEffect)(()=>{!Te||wi||E?.startsWith(`pending:`)||P(E??O)||mk(F,E,E?void 0:Ci?.id,Qn||!E&&!Ke)},[E,Te,F,wi,Ci?.id,Qn,Ke]);let fa=(0,u.useCallback)(e=>{e&&ie(t=>{if(t.touched.has(e))return t;let n=t.previewId===e?void 0:t.previewId;return{...t,previewId:n,touched:dk(t.touched,e)}})},[]),pa=(0,u.useCallback)(e=>{I(se(e)),$n(!1),ge.current++,qe(!1),D(e);let t=oi.find(t=>t.id===e)?.workspaceId;t&&k(t),nt(`session`),ie(t=>{let n=t.emptied===!0,r=n?{...t,emptied:!1}:t;if(r.ids.includes(e))return r;let i=!n&&r.ids.length===0&&R?.id&&R.id!==e?[R.id]:[],a=[...r.ids,...i];if(r.touched.has(e))return{...r,ids:[...a,e]};let o=r.previewId?a.indexOf(r.previewId):-1,s=o>=0?a.map((t,n)=>n===o?e:t):[...a,e];return{...r,ids:s,previewId:e}})},[R,oi]);(0,u.useEffect)(()=>{if(!Te)return;let t=new Map(e.conversations.filter(e=>!e.archivedAt).map(e=>[e.id,{status:e.status,hasPendingQuestion:!!e.hasPendingQuestion,title:e.title,workspaceId:e.workspaceId,parentConversationId:e.parentConversationId}]));if(!c.current){s.current=t,c.current=!0;return}let r=document.visibilityState===`visible`&&document.hasFocus(),a=n&&[`granted`,`native`].includes(i)&&!r;for(let[n,r]of t){let t=s.current.get(n);if(!t||r.parentConversationId||!a)continue;let i=!t.hasPendingQuestion&&r.hasPendingQuestion,o=r.status===`completed`&&t.status!==`completed`&&[`waiting`,`running`,`awaiting_background`].includes(t.status);if(!i&&!o)continue;let c=i?`question`:`completed`;if(Dk(`${n}:${c}:${e.conversations.find(e=>e.id===n)?.updatedAt??``}`))try{let e=`${n}:${c}`,t=Pi(i?`Super Pi · 等你回答`:`Super Pi · Agent 已完成`,{body:`${me(r.workspaceId)} · ${i?`「${r.title}」需要你的回答。`:`「${r.title}」已完成。`}`,tag:`super-pi-${c}-${n}`});l.current.set(e,t),t.onclose=()=>{l.current.get(e)===t&&l.current.delete(e)},t.onclick=()=>{t.close(),l.current.delete(e),window.focus(),pa(n)}}catch(e){console.warn(`[Super Pi] Browser notification could not be shown:`,e instanceof Error?e.message:`unknown error`)}}s.current=t},[e.conversations,Te,n,i,pa]);let ma=(0,u.useCallback)(e=>{e&&(fa(e),pa(e))},[fa,pa]),ha=e=>{e.startsWith(`pending:`)||I(se(e)),$n(!0),ge.current++,qe(!1),R&&da&&ie(e=>e.ids.length||e.emptied?e:{...e,ids:[R.id]}),k(e),D(void 0),nt(`session`),Un(!1),Vn()},ga=(0,u.useCallback)((e,t=``)=>{ge.current++;let n={workspaceId:e,roomId:t};t&&Ge(r=>r.some(n=>n.workspaceId===e&&n.roomId===t)?r:[...r,n]),Ue(n),qe(!0),k(e),Un(!1),nt(`group`),Vn()},[Vn]),_a=(0,u.useCallback)((e,t)=>{at(e,!0),t&&(re(t=>t[e.workspaceId]?{...t,[e.workspaceId]:!1}:t),ga(e.workspaceId,e.id))},[ga,at]);(0,u.useEffect)(()=>{let e=new Set;if(!n||i!==`granted`)Ii(e);else{for(let t of Object.values(rt))for(let n of t.rooms)if(!n.archivedAt)for(let t of n.cloneRequests??[]){if(t.status!==`pending`||t.automatic)continue;let r=`group-clone:${n.id}:${t.id}`;e.add(r),Fi(r,`${me(n.workspaceId)} · ${n.title} · 需要决定是否创建分身`,t.reason,et===`group`&&St===n.id&&document.visibilityState===`visible`&&document.hasFocus(),()=>ga(n.workspaceId,n.id))}Ii(e)}},[rt,et,St,ga,n,i]);let va=(0,u.useCallback)(e=>{it(),ot(e)},[ot,it]);async function ya(e,t){if(!mt.has(e.id)&&(t!==`delete`||window.confirm(`永久删除群聊「${e.title}」及其聊天记录?删除后无法恢复。`))){ht(t=>new Set(t).add(e.id));try{let n=await gt(pt(e.workspaceId,e.id),{action:t});if(t===`delete`)va({workspaceId:e.workspaceId,roomId:e.id});else{if(!n)throw Error(`服务没有确认群聊状态。`);it(),at(n),t===`archive`&&Wt(t=>({...t,[e.workspaceId]:!1}))}}catch(e){Ds(e instanceof Error?e.message:`群聊操作失败。`,`error`)}finally{ht(t=>new Set([...t].filter(t=>t!==e.id)))}}}let ba=Ke&&et!==`session`,xa=ba?bt:R?.workspaceId??O,Sa=xa?.startsWith(`pending:`)?void 0:xa,Ca=Sa??(Wn===`repo`?T.workspaces.find(e=>e.id===Xn&&(!e.worktreeOf||!T.workspaces.some(t=>t.id===e.worktreeOf)))?.id??T.workspaces.find(e=>(Kn===`all`||h(e.id).server===Kn)&&(!e.worktreeOf||!T.workspaces.some(t=>t.id===e.worktreeOf)))?.id:void 0),wa=Ca?.startsWith(`pending:`)?void 0:Ca,Ta=ba?``:R?.cwd??``;(0,u.useEffect)(()=>{Sa&&I(se(Sa))},[Sa]);let Ea=Wn===`repo`&&(!R||ba),Da=JSON.stringify([Sa,Ta]),[Oa,ka]=(0,u.useState)(),[Aa,ja]=(0,u.useState)(50),Ma=Oa?.scope===Da?Oa:void 0,Na=!!Ma,Pa=Ma?.tabId;(0,u.useEffect)(()=>{ka(e=>e?.scope===Da?e:void 0)},[Da]);let Fa=(0,u.useCallback)(e=>{ka(t=>t?.scope===Da?{...t,tabId:e}:t)},[Da]),B=tm(Sa,Ta,{navigation:ge,showingFile:et===`file`,splitFilePath:Pa?.startsWith(`file:`)?Pa.slice(5):void 0}),V=$r(wa,wa===Sa?Ta:``,N&&Te),Ia=(0,u.useRef)(V.refresh);Ia.current=V.refresh;let La=(0,u.useRef)(B.setChangedFor),Ra=(0,u.useRef)(B.invalidateTree);Ra.current=B.invalidateTree;let za=(0,u.useRef)(Sa);za.current=Sa,(0,u.useEffect)(()=>{La.current=B.setChangedFor},[B.setChangedFor]);let[Ba]=(0,u.useState)(cO),[Va,Ha]=(0,u.useState)(Ba.tab),[Ua,Wa]=(0,u.useState)(Ba.byConversation),Ga=(R?.id?Ua[R.id]:void 0)??Va;(0,u.useEffect)(()=>{try{Je(sO,JSON.stringify({tab:Va,byConversation:Ua}))}catch{}},[Va,Ua]);let Ka=(0,u.useCallback)(e=>{Ha(e),R?.id&&Wa(t=>({...t,[R.id]:e}))},[R?.id]),qa=rr.order.filter(e=>rr.sides[e]===`left`),[Ja,Ya]=(0,u.useState)(!1),[Xa,Za]=(0,u.useState)(!1),Qa=rr.order.filter(e=>e!==`sessions`&&rr.sides[e]===`right`),$a=qa.includes(rr.leftView)?rr.leftView:`sessions`,eo=Qa.includes(Ga)?Ga:Qa[0],to=rr.rightClosed||!eo,no=mr||!rr.leftClosed&&!Ja&&$a===`sessions`,ro=(e,t=!1)=>{(e===`sessions`||rr.sides[e]===`left`)&&Ya(!1),mr?e===`sessions`?(Vn(),Un(!0)):(Ka(e),In(!1),tr<=700&&Rn(`rail`)):rr.sides[e]===`left`?ir(n=>({...n,leftView:e,leftClosed:t&&!Ja&&!n.leftClosed&&$a===e})):e!==`sessions`&&(Ka(e),ir(n=>({...n,rightClosed:t&&!n.rightClosed&&eo===e})))},io=(e,t)=>{let n=rr.sides[e];if(t===`move`){let t=n===`left`?`right`:`left`;t===`left`&&Ya(!1),ir(n=>({...n,sides:{...n.sides,[e]:t},...t===`left`?{leftView:e,leftClosed:!1}:{rightClosed:!1}})),t===`right`&&Ka(e),requestAnimationFrame(()=>{(document.querySelector(`[data-workbench-view="${e}"]`)??document.querySelector(`[data-workbench-panel-menu="${e}"]`))?.focus()})}else ir(t===`pin`?t=>({...t,unpinned:t.unpinned.includes(e)?t.unpinned.filter(t=>t!==e):[...t.unpinned,e]}):r=>{let i=r.order.filter(e=>r.sides[e]===n&&!r.unpinned.includes(e)),a=i.indexOf(e),o=a>=0?i[a+(t===`up`?-1:1)]:void 0;if(!o||o===`sessions`)return r;let s=r.order.slice(),c=s.indexOf(e),l=s.indexOf(o);return[s[c],s[l]]=[s[l],s[c]],{...r,order:s}})},ao=(e,t)=>{e!==t&&ir(n=>{if(n.sides[e]!==n.sides[t])return n;let r=n.order.slice(),i=r.indexOf(e),a=r.indexOf(t);return r.splice(i,1),r.splice(a,0,e),{...n,order:r}})},oo=()=>{Ya(!1),ir(tn()),or({}),Ka(`main`)},H=JSON.stringify([Sa,Ta]),[U,W]=(0,u.useState)(),G=U?.scope===H?U:void 0,K=G?.mode===`path`;(0,u.useEffect)(()=>{W(e=>e?.scope===H?e:void 0)},[H]);let so=(0,u.useCallback)((e,t,n)=>{ge.current++,W(r=>r?.mode===e&&r.scope===H&&r.directory===n?r:{mode:e,scope:H,initialQuery:t,directory:n}),Un(!1)},[H]),co=(0,u.useCallback)(()=>{ge.current++,W(void 0)},[]),[lo,uo]=(0,u.useState)(),fo=(0,u.useRef)(0),po=e=>{pa(e.conversationId),uo({hit:e,request:ge.current}),W(void 0),Vn()};(0,u.useEffect)(()=>{if(!lo||lo.request===fo.current||R?.id!==lo.hit.conversationId||R?.messagesLoaded===!1||et!==`session`||!da)return;let{hit:e,request:t}=lo,n=null,r,i=requestAnimationFrame(()=>{let i=Tt.current;i&&ge.current===t&&(n=i.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`),n&&(fo.current=t,ok(i),i.scrollTop+=n.getBoundingClientRect().top-i.getBoundingClientRect().top-24,ji(i,!0),n.dataset.sessionSearchHit=`true`,n.tabIndex=-1,n.focus({preventScroll:!0}),r=setTimeout(()=>{n&&delete n.dataset.sessionSearchHit},2400)))});return()=>{cancelAnimationFrame(i),clearTimeout(r),n&&delete n.dataset.sessionSearchHit}},[R?.id,R?.messagesLoaded,et,ji,da,lo]);let[mo,ho]=(0,u.useState)(),[q,go]=(0,u.useState)(),[J,_o]=(0,u.useState)(w.diffs),vo=J.paths,[yo,bo]=(0,u.useState)(w.gitDiffs),[xo,So]=(0,u.useState)(w.gitDiffUrl);(0,u.useEffect)(()=>{if(!(!Te||B.restoringWorkbench||P(E??O)))try{Ze({view:et,groups:We,gitDiffs:yo,gitDiffUrl:xo,diffs:J})}catch{}},[Te,B.restoringWorkbench,E,O,et,We,yo,xo,J]);let Co=et===`gitDiff`?yo.find(e=>e.target.url===xo):void 0,wo=et===`gitDiff`?`diff`:et,To=Co?.target.path??q,Eo=(0,u.useCallback)(e=>{if(Ea&&!e.commitHash)return;ge.current++;let t=document.activeElement instanceof HTMLElement?document.activeElement:void 0;bo(n=>{let r=n.find(t=>t.target.url===e.url);if(!r){let r={target:e,workspaceId:Sa,reading:{},revision:0,preview:!0,origin:t},i=Na&&et===`gitDiff`?xo:void 0,a=n.find(e=>e.preview&&e.target.url!==i);return a?n.map(e=>e===a?r:e):[...n,r]}if(e.commitHash)return n;let i=r.target.label===e.label?{...r.reading,snapshot:void 0}:{split:r.reading.split};return n.map(n=>n===r?{...n,target:e,reading:i,revision:n.revision+1,origin:t}:n)}),Na?(Fa(`git-diff:${e.url}`),et===`gitDiff`&&xo===e.url&&nt(`session`)):(So(e.url),nt(`gitDiff`)),Vn()},[Sa,Ea,xo,et,Fa,Vn,Na]),Do=(0,u.useCallback)(()=>{!da&&ua?pa(ua):nt(`session`)},[da,ua,pa]);(0,u.useEffect)(()=>{let e=e=>{let t=rt[e.workspaceId];return!t?.loaded||t.rooms.some(t=>t.id===e.roomId)},t=We.filter(e);if(t.length!==We.length&&Ge(t),et!==`group`||!Ve?.roomId||e(Ve))return;let n=t.filter(e=>e.workspaceId===Ve.workspaceId).at(-1);n?ga(n.workspaceId,n.roomId):Do()},[rt,Ve,We,et,ga,Do]),(0,u.useEffect)(()=>{et===`file`&&!B.active&&Do()},[et,B.active,Do]),(0,u.useEffect)(()=>{et===`diff`&&!q&&Do()},[et,q,Do]);let Oo=(0,u.useRef)(`${Sa??``}:${Ta}`);(0,u.useEffect)(()=>{let e=`${Sa??``}:${Ta}`;Oo.current!==e&&(Oo.current=e,_o({paths:[]}),go(void 0),nt(e=>e===`gitDiff`||e===`group`?e:`session`))},[Sa,Ta]);let ko=(0,u.useCallback)((e,t=!1)=>{ge.current++;let n=Na&&!t;_o(t=>{if(t.paths.includes(e))return t;let r=n&&et===`diff`&&q===t.previewPath;return{paths:t.previewPath&&!r?t.paths.map(n=>n===t.previewPath?e:n):[...t.paths,e],previewPath:e}}),n?(Fa(`diff:${e}`),et===`diff`&&q===e&&nt(`session`)):(go(e),nt(`diff`)),Vn(),Ha(`files`)},[q,et,Fa,Vn,Na]),Ao=et===`diff`?q:void 0,jo=Pa?.startsWith(`diff:`)?Pa.slice(5):void 0,Mo=jo&&jo!==Ao&&vo.includes(jo)?jo:void 0,No=Ek(Sa,Ta,Ao),Po=Ek(Sa,Ta,Mo),[Fo,Io]=(0,u.useState)(`server`),[Lo,Ro]=(0,u.useState)(`server`),zo=e=>{let t=B.open.find(t=>t.path===e);return t?.dirty?t.content:void 0},Bo=(0,u.useCallback)(e=>{ge.current++,B.setActivePath(e),nt(`file`),Ha(`files`)},[B.setActivePath]),Vo=(0,u.useCallback)(async(e,t,n=!1,r=!1,i=!1,a)=>{let o=++ge.current,s=()=>ge.current===o,c=Na&&!i,l=await B.openFile(e,{preview:!n,activate:!c,isCurrent:s,throwOnError:r,requireText:a!==void 0});if(l&&s())return n&&B.pinFile(l),ho(t?{scope:H,path:l,line:t,column:a,request:o}:void 0),c?(Fa(`file:${l}`),et===`file`&&B.activePath===l&&nt(`session`)):nt(`file`),Vn(),l},[B.openFile,B.pinFile,B.activePath,H,et,Fa,Vn,Na]),Ho=(0,u.useCallback)((e,t)=>{Vo(e,void 0,t)},[Vo]),Uo=R&&!_i?(e,t)=>{let n=Ri&&!/\s$/u.test(Ri)?`${Ri} `:Ri,r=Jd(n,{start:n.length,end:n.length,query:``},{path:e,kind:t?`directory`:`file`});na.current={scope:Xi,...r},fa(R.id),pa(R.id),Vn(),Gi(r.text)}:void 0,Wo=(e,t)=>{ge.current+=1,_o(t=>({paths:t.paths.filter(t=>!uf(t,e)),previewPath:t.previewPath&&!uf(t.previewPath,e)?t.previewPath:void 0})),q&&uf(q,e)&&go(void 0),ka(n=>{let r=n?.tabId?.startsWith(`file:`)?n.tabId.slice(5):void 0;return n&&r&&uf(r,e)?{...n,tabId:`file:${t}${r.slice(e.length)}`}:n}),ho(n=>n?.scope===H&&uf(n.path,e)?{...n,path:t+n.path.slice(e.length)}:n)};(0,u.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.altKey||e.isComposing)return;let t=e.key.toLowerCase();e.shiftKey&&t===`f`?(e.preventDefault(),so(`content`)):!e.shiftKey&&t===`p`&&(e.preventDefault(),so(`path`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[so]);let Go=(0,u.useMemo)(()=>la.map(e=>({id:`session:${e.id}`,workspaceId:e.workspaceId,rawId:e.id,kind:`session`,label:e.title,title:e.title,closable:!0,preview:he===e.id,badge:(0,L.jsx)(bO,{state:vO(e,gO(e,Pn),Re.current[e.id],T.conversations)})})),[la,Pn,T.conversations,ze,he]),Ko=(0,u.useMemo)(()=>B.open.map(e=>({id:`file:${e.path}`,workspaceId:B.ownerWorkspaceId,rawId:e.path,kind:`file`,label:e.name,title:e.path,closable:!0,preview:e.preview,badge:e.dirty?(0,L.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[B.ownerWorkspaceId,B.open]),qo=(0,u.useMemo)(()=>vo.map(e=>({id:`diff:${e}`,workspaceId:Sa,rawId:e,kind:`diff`,label:e.split(/[\\/]/).pop()||e,title:`${e}(改动)`,closable:!0,preview:J.previewPath===e,icon:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`±`})})),[Sa,vo,J.previewPath]),Jo=(0,u.useMemo)(()=>[...Go,...[...We,...et===`group`&&Ve&&!St?[Ve]:[]].flatMap(e=>{let t=T.workspaces.find(t=>t.id===e.workspaceId&&!t.closedAt);if(!t)return[];let n=rt[e.workspaceId]?.rooms.find(t=>t.id===e.roomId),r=e.roomId?n?.title??`群聊`:`新建群聊`,i=n?_t(n,st[n.id]):`idle`,a=n?vt(n,st[n.id],Re.current[dt(e)]):`idle`,o=a===`completed`?`讨论已完成,有新回复未读`:a===`unread`?`有新回复未读`:uO[i],s=`${r} · ${t.name}${i===`idle`?``:` · ${o}`}`;return[{id:dt(e),workspaceId:e.workspaceId,label:r,title:s,closable:!0,icon:(0,L.jsx)(on,{name:`group`}),badge:(0,L.jsx)(bO,{state:a,label:o})}]}),...Ko,...qo,...yo.map(({target:e,preview:t,workspaceId:n})=>({id:`git-diff:${e.url}`,workspaceId:n,kind:`diff`,closable:!0,preview:t,label:`${e.path.split(/[\\/]/).pop()||e.path} (${e.label})`,title:`${e.path} · ${e.comparison}`,icon:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`±`})}))],[Go,Ko,qo,yo,We,rt,st,Ve,St,et,T.workspaces,ze]),Yo=et===`group`&&Ve?dt(Ve):et===`file`&&B.activePath?`file:${B.activePath}`:et===`diff`&&q?`diff:${q}`:Co?`git-diff:${Co.target.url}`:da&&R?.id?`session:${R.id}`:void 0,Xo=(0,u.useRef)(!1),Zo=(0,u.useRef)(void 0);(0,u.useLayoutEffect)(()=>{let e=Xo.current;if(Xo.current=!1,Zo.current!==B.restoredActive&&(Zo.current=B.restoredActive,!xe&&B.restoredActive&&B.restoredActive===B.activePath&&et!==`file`&&et!==`gitDiff`&&et!==`group`)){nt(`file`);return}if(!e&&Te&&he&&Yo!==`session:${he}`&&oi.some(e=>e.id===he)&&ie(e=>{if(e.previewId!==he)return e;let t=e.ids.filter(e=>e!==he);return{...e,ids:t,previewId:void 0,emptied:t.length===0}}),!e)for(let e of B.open)e.preview&&Yo!==`file:${e.path}`&&Pa!==`file:${e.path}`&&B.discardPreview(e.path);let t=J.previewPath;!e&&t&&Yo!==`diff:${t}`&&Pa!==`diff:${t}`&&_o(e=>e.previewPath===t?{paths:e.paths.filter(e=>e!==t)}:e);let n=e=>{let t=`git-diff:${e.target.url}`;return!e.preview||t===Yo||t===Pa};!e&&yo.some(e=>!n(e))&&bo(e=>e.filter(n)),Te&&et===`session`&&R&&R.id===E&&!da&&!B.restoringWorkbench&&ua&&pa(ua)},[Yo,Te,he,B.open,B.activePath,B.restoredActive,B.discardPreview,J.previewPath,et,R?.id,E,da,B.restoringWorkbench,ua,pa,oi,xe,Pa,yo]);let Qo=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=ft(e);t&&ga(t.workspaceId,t.roomId)}else if(e.startsWith(`file:`)){let t=e.slice(5);Bo(t)}else if(e.startsWith(`diff:`)){ge.current++;let t=e.slice(5);go(t),nt(`diff`)}else if(e.startsWith(`git-diff:`))ge.current++,So(e.slice(9)),nt(`gitDiff`);else if(e.startsWith(`session:`)){let t=e.slice(8);pa(t)}},[Bo,pa,ga]),$o=Jo.find(e=>e.id===Yo),es=et===`file`?B.active:void 0,ts=(0,u.useMemo)(()=>{if(!Te||!$o||$o.id.startsWith(`session:pending:`))return;let{id:e,label:t}=$o;if(et!==`group`||St&&wt){if(et===`session`)return e.startsWith(`session:`)?{key:e,tabId:e,title:t}:void 0;if(et===`file`||et===`diff`){if(!Sa||B.restoringWorkbench||et===`file`&&!es||et===`diff`&&!q)return;let n={workspaceId:Sa,cwd:Ta,conversationId:R?.id},r=es&&{path:es.path,name:es.name,text:null,...es.assetTicket||/^(?:[a-z]:[\\/]|[\\/])/i.test(es.path)?{openLink:!0}:{}};return{key:JSON.stringify([n.workspaceId,n.cwd,e]),tabId:e,title:t,scope:n,file:r}}return{key:e,tabId:e,title:t}}},[Te,$o,et,Sa,Ta,R?.id,B.restoringWorkbench,q,es?.path,es?.name,es?.assetTicket,St,wt]);(0,u.useEffect)(()=>{!xe&&ts&&(Ce.current.delete(ts.key),be(e=>Em(e,ts)))},[ts,xe]);let ns=e=>{let t=oi.filter(t=>t.workspaceId===e.workspaceId&&(t.cwd??``)===e.cwd);return t.find(t=>t.id===e.conversationId)??t[0]},rs=e=>{if(e.key===ts?.key||Ce.current.has(e.key))return!1;if(e.tabId.startsWith(`session:`))return oi.some(t=>`session:${t.id}`===e.tabId);let t=ft(e.tabId);if(t)return T.workspaces.some(e=>e.id===t.workspaceId&&!e.closedAt)&&!!rt[t.workspaceId]?.rooms.some(e=>e.id===t.roomId);if(!e.scope)return Jo.some(t=>t.id===e.tabId);let{scope:n}=e;return T.workspaces.some(e=>e.id===n.workspaceId)?n.workspaceId===Sa&&n.cwd===Ta||!!ns(n)||!n.cwd&&!oi.some(e=>e.workspaceId===n.workspaceId):!1},is=Dm(ye,ye.index+ +!ts,-1,rs),Y=Dm(ye,ye.index,1,rs),as=e=>{let t=e<0?is:Y;xe||t<0||Se({index:t,direction:e,ticket:++ge.current,stage:`start`})},os=(0,u.useRef)(as);os.current=as,(0,u.useEffect)(()=>{let e=e=>{(e.button===3||e.button===4)&&(e.preventDefault(),e.type===`mouseup`&&os.current(e.button===3?-1:1))};for(let t of[`mousedown`,`mouseup`,`auxclick`])window.addEventListener(t,e,!0);return()=>{for(let t of[`mousedown`,`mouseup`,`auxclick`])window.removeEventListener(t,e,!0)}},[]),(0,u.useEffect)(()=>{let e=xe;if(!e)return;if(ge.current!==e.ticket){Se(void 0);return}let t=ye.entries[e.index];if(t.key===ts?.key){be(t=>({...t,index:e.index})),Se(void 0);return}let n=(t=e.ticket)=>{let n=Dm(ye,e.index,e.direction,rs);Se(n<0?void 0:{...e,index:n,ticket:t,stage:`start`})};if(!rs(t)){n();return}let r=t.scope;if(r&&(r.workspaceId!==Sa||r.cwd!==Ta)){if(e.stage!==`start`){n();return}let t=ns(r);t?pa(t.id):ha(r.workspaceId),Se({...e,stage:`scope`,ticket:ge.current});return}if(e.stage===`opening`||r&&B.restoringWorkbench)return;Un(!1),Vn();let i=t.file;if(i&&!B.open.some(e=>e.path===i.path)){let r=Vo(i,void 0,!1,!0,!0),a=ge.current;Se({...e,stage:`opening`,ticket:a}),r.then(e=>{!e&&ge.current===a&&Se(void 0)}).catch(e=>{ge.current===a&&(e instanceof kp&&e.status===404?(Ce.current.add(t.key),n(a)):(Ds(Ht(e instanceof Error?e.message:void 0,`无法打开导航历史中的文件。`),`error`),Se(void 0)))})}else t.tabId.startsWith(`diff:`)&&!Jo.some(e=>e.id===t.tabId)?ko(t.tabId.slice(5),!0):Qo(t.tabId),Se({...e,stage:`opening`,ticket:ge.current})});let ss=(0,u.useCallback)(e=>{if(e.startsWith(`session:`))ma(e.slice(8));else if(e.startsWith(`file:`))B.pinFile(e.slice(5));else if(e.startsWith(`diff:`)){let t=e.slice(5);_o(e=>e.previewPath===t?{paths:e.paths}:e)}else e.startsWith(`git-diff:`)&&bo(t=>t.map(t=>t.preview&&`git-diff:${t.target.url}`===e?{...t,preview:!1}:t))},[ma,B.pinFile]),cs=Jo.filter(e=>e.kind===`file`||e.kind===`diff`),ls=Na&&Pa!==Yo?cs.find(e=>e.id===Pa):void 0,us=e=>{cs.some(t=>t.id===e)&&(ge.current++,Fa(e),e===Yo&&Do())},ds=()=>{if(Na){ge.current++,ls&&ss(ls.id),ka(void 0);return}ge.current++;let e=cs.find(e=>e.id===Yo)??cs.at(-1);ka({scope:Da,tabId:e?.id}),e&&e.id===Yo&&(R&&!da?pa(R.id):Do())},fs=(0,u.useCallback)(e=>{let t=ca.indexOf(e);if(t<0)return;let n=ca.filter(t=>t!==e);if(ie(t=>({...t,ids:t.ids.filter(t=>t!==e),previewId:t.previewId===e?void 0:t.previewId,emptied:n.length===0||t.emptied})),R?.id!==e||et!==`session`)return;ge.current++;let r=n[Math.min(t,n.length-1)];if(r)D(r);else if(B.open.length>0){let e=B.activePath&&B.open.some(e=>e.path===B.activePath)?B.activePath:B.open[0].path;B.setActivePath(e),nt(`file`)}else vo.length>0?(go(vo[0]),nt(`diff`)):yo.length>0?(So(yo[0].target.url),nt(`gitDiff`)):D(void 0)},[ca,R,B,vo,yo,et]),ps=(0,u.useCallback)(e=>{if(e.startsWith(`group:`)){let t=We.filter(t=>dt(t)!==e);if(Ge(t),et===`group`&&Yo===e){let e=t.filter(e=>e.workspaceId===bt).at(-1);e?ga(e.workspaceId,e.roomId):Do()}}else if(e.startsWith(`file:`)){let t=e.slice(5);B.closeFile(t),et===`file`&&B.activePath===t&&B.open.length<=1&&ge.current++}else if(e.startsWith(`diff:`)){let t=e.slice(5);_o(e=>({paths:e.paths.filter(e=>e!==t),previewPath:e.previewPath===t?void 0:e.previewPath})),et===`diff`&&q===t&&(ge.current++,go(void 0),Do())}else if(e.startsWith(`session:`)){let t=e.slice(8);fs(t)}else if(e.startsWith(`git-diff:`)){let t=e.slice(9),n=yo.findIndex(e=>e.target.url===t);if(n<0)return;let r=yo.filter(e=>e.target.url!==t);bo(r);let i=document.activeElement?.getAttribute(`data-diff-tab-close`)===e;if(Co?.target.url===t){ge.current++;let e=r[Math.max(0,n-1)];So(e?.target.url),e||Do()}i&&requestAnimationFrame(()=>{let e=document.querySelector(`.chat-tab-strip [role="tab"][aria-selected="true"]`),t=yo[n].origin;(e??(t?.getClientRects().length?t:void 0)??document.querySelector(`[data-workspace-welcome-create]:not(:disabled)`))?.focus()})}},[B,fs,q,et,yo,Co?.target.url,Do,bt,We,Yo,ga]),ms=B.active,hs=JSON.stringify([Sa,Ta,ms?.path]),[gs,_s]=(0,u.useState)(),vs=(0,u.useCallback)(e=>{_s(t=>e?{scope:hs,position:e}:t?.scope===hs?void 0:t)},[hs]),ys=gs?.scope===hs?gs.position:void 0,bs=T.workspaces.find(e=>e.id===Sa),xs=T.workspaces.find(e=>e.id===wa),Ss=(e,t)=>{let n=e&&Rp(e.path),r=e&&(e.assetTicket||n?(0,L.jsx)(`span`,{className:`file-editor-path`,title:n??e.path,children:n??e.path}):(0,L.jsx)($d,{root:Ta.split(`/`).at(-1)||bs?.name||`工作目录`,path:e.path,reveal:(e,t)=>{ro(`files`),B.locatePath(e,t)}})),i=mo?.scope===H&&mo?.path===e?.path?mo:void 0,a=e&&(!e.view||e.view===`table`)&&(0,L.jsx)(Zp,{file:e,state:B.saves[e.path]?.state??`idle`,message:B.saves[e.path]?.message??``,external:B.external[e.path]===!0,jumpToLine:i,onChange:t=>B.updateBuffer(e.path,t),onSave:()=>void B.save(e.path,!1),onReload:()=>void B.reload(e.path),onOverwrite:()=>void B.save(e.path,!0),workspaceId:Sa,cwd:Ta,navigation:e.view?void 0:r,embedded:!!e.view,onPosition:t?vs:void 0});return(0,L.jsx)(`div`,{className:`chat-file-view`,"data-main-file-view":e?.path,"data-file-view-kind":`editor`,children:e?.view&&Sa?(0,L.jsx)(rf,{workspaceId:Sa,cwd:n?``:Ta,path:n??e.path,name:e.name,kind:e.view,content:e.content,version:e.etag,source:a||void 0,external:B.external[e.path],navigation:r,assetTicket:e.assetTicket,onReload:()=>void B.reload(e.path),sourceRequest:i?.request},JSON.stringify([Sa,Ta,e.path])):a||(0,L.jsx)(`p`,{className:`rail-empty`,"data-main-file-empty":`1`,children:`没有选中的文件。`})})},Cs=e=>Ea&&!e.target.commitHash?(0,L.jsx)(`div`,{className:`chat-file-view`,role:`status`,children:(0,L.jsx)(`p`,{className:`rail-empty`,children:`请选择具体 session 以确定工作区,再查看或编辑工作区差异。`})}):(0,L.jsx)(`div`,{className:`chat-file-view chat-git-diff`,"data-main-diff-view":e.target.path,"data-file-view-kind":`diff`,children:(0,L.jsx)(u.Suspense,{fallback:(0,L.jsx)(`p`,{className:`rail-empty`,role:`status`,children:`正在读取差异…`}),children:(0,L.jsx)(jO,{tab:e,dark:el!==`github-light`&&el!==`solarized-light`},JSON.stringify([e.target.url,e.revision]))})}),ws=(e,t)=>{let n=t?Po:No;return(0,L.jsx)(`div`,{className:`chat-file-view`,"data-main-diff-view":e??``,"data-file-view-kind":`diff`,children:(0,L.jsx)($p,{diff:n.diff,loading:n.loading,error:n.error,bufferContent:zo(e),mode:t?Lo:Fo,onMode:t?Ro:Io})})},Ts=()=>{let e=ls?.id;if(!e)return null;if(e.startsWith(`file:`))return Ss(B.open.find(t=>`file:${t.path}`===e),!1);if(Mo)return ws(Mo,!0);let t=yo.find(t=>`git-diff:${t.target.url}`===e);return t?Cs(t):null},Es=R?.id;(0,u.useEffect)(()=>{Es&&!Es.startsWith(`pending:`)&&Fs({type:`conversation.select`,conversationId:Es})},[Es]);let Ds=(e,t=`info`)=>{if(!e)return;let n=++Yr.current;pn(r=>[...r,{key:n,text:e,kind:t}]),Xr.current.push(window.setTimeout(()=>pn(e=>e.filter(e=>e.key!==n)),7e3))},Os=(e,t=``)=>{if(bs&&bs.id===e&&Ta===t)return e=>{let n=vn(e,{root:bs.path,cwd:t,origin:window.location.origin});if(n)return{title:`${n.path}:${n.line}${n.column?`:${n.column}`:``}`,open:()=>{let e=pm(n.path,t);Vo(e,n.line,!1,!0,!1,n.column??1).catch(t=>Ds(`打不开「${e.name}」:${t instanceof Error?t.message:`文件不可用`}`,`error`))}}}},ks=Os(R?.workspaceId,R?.cwd),As=async e=>{if(!e){r(!1);try{window.localStorage.setItem(`super-pi.browser-notifications`,`disabled`)}catch{}}else if(typeof window>`u`||typeof Notification>`u`&&!window.superPiDesktop?.notifications)a(`unsupported`);else if(!window.isSecureContext&&!window.superPiDesktop?.notifications)a(`insecure`);else try{let e=await Ni();a(e);let t=e===`granted`||e===`native`;r(t);try{window.localStorage.setItem(`super-pi.browser-notifications`,t?`enabled`:`disabled`)}catch{}}catch{a(Mi()),r(!1),Ds(`请求浏览器通知权限失败,请检查站点权限后重试。`,`error`)}};(0,u.useEffect)(()=>{let e=()=>{for(let e of l.current.values())e.close();l.current.clear()},t=()=>{if(a(Mi()),document.visibilityState===`visible`&&document.hasFocus()){e();try{window.localStorage.setItem(`super-pi.browser-notification-focus`,String(Date.now()))}catch{}}},n=t=>{t.key===`super-pi.browser-notification-focus`&&e()};window.addEventListener(`focus`,t);let r=!1,i;return navigator.permissions?.query&&navigator.permissions.query({name:`notifications`}).then(e=>{r||(i=e,e.addEventListener(`change`,t),t())}).catch(()=>{}),window.addEventListener(`storage`,n),document.addEventListener(`visibilitychange`,t),()=>{r=!0,i?.removeEventListener(`change`,t),window.removeEventListener(`focus`,t),window.removeEventListener(`storage`,n),document.removeEventListener(`visibilitychange`,t),e()}},[]),(0,u.useEffect)(()=>{let e=R?.id,t=R?.agentNotice;e&&t&&!ei.current.has(e)&&(ei.current.add(e),Ds(t,`info`))},[R?.id,R?.agentNotice]);let js=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},Ms=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n<0)return[t,...e];let r=[...e];return r[n]=t,r},Ns=(e,t)=>{if(t.method===`notify`)Ds(t.message||t.title,t.notifyType??`info`);else if(t.blocking||t.method===`setStatus`||t.method===`setWidget`||t.method===`setTitle`){let n=e=>e.blocking?e.requestId:e.statusKey??e.widgetKey??``,r=t.method===`setStatus`&&t.statusText===void 0||t.method===`setWidget`&&t.widgetLines===void 0||t.method===`setTitle`&&!t.title;dn(i=>{let a=i.filter(r=>r.conversationId!==e||r.request.method!==t.method||n(r.request)!==n(t));return r?a:[...a,{conversationId:e,request:t}]})}else t.method===`set_editor_text`&&e===Zr.current&&Gi(t.text??``)},Ps=(e,t,n)=>{dn(n=>n.filter(n=>!(n.conversationId===e&&n.request.blocking&&n.request.requestId===t)));let r=kD[n];r&&Ds(r,`warning`)};(0,u.useEffect)(()=>{let e=!1;return(()=>{if(e)return;let t=new Ne(Zr.current);Fe.current=t,t.onopen=()=>{if(!e){j(!0);for(let e of[{type:`stream.configure`,coalesce:!0},{type:`catalog.fetch`,conversationId:Zr.current},...ki.current?[{type:`prompt.catalog.fetch`,workspaceId:ki.current}]:[],{type:`catalog.fetchAll`},{type:`agent.catalog.fetch`},{type:`subagent.catalog.fetch`}])t.canSend(e)&&t.send(JSON.stringify(e))}},t.onserveropen=e=>{for(let n of m.current)n.retry&&n.command&&n.serverId===e&&t.canSend(n.command)&&t.send(JSON.stringify({...n.command,operationRequestId:n.id}))},t.ondisconnect=t=>{if(e)return;let n=PT(m.current.filter(e=>e.serverId===t));for(let e of n.failed)e.onFailure?.(`${pe(t)} 连接中断`);m.current=m.current.filter(e=>!n.failed.includes(e)),p(m.current),Ds(`${pe(t)} 连接中断,正在自动重连。`,`warning`)},t.onmessage=({data:t})=>{if(e)return;let n=JSON.parse(t);if(n.type===`group.activity`)ct(n);else if(n.type!==`message.delta`&&n.type!==`message.thinking`&&Rt(),n.type===`message.accepted`){Vf(n.conversationId,n.clientId);for(let e of m.current)e.command?.conversationId===n.conversationId&&e.command?.clientId===n.clientId&&(e.receipt=!0)}else if(n.type===`exec.output`){let e=Nt.current.get(n.sessionId),t=e?.raw??e?.text??``,r=n.offset===void 0?void 0:n.offset-n.data.length;if(!n.replace&&e?.offset!==void 0&&n.offset!==void 0&&n.offset<=e.offset)return;let i=e&&(r===void 0||e.offset!==void 0&&e.offset>=r),a=r!==void 0&&e?.offset!==void 0?Math.max(0,e.offset-r):0,o=(n.replace||!i?n.data:t+n.data.slice(a)).slice(-KE),s=qE(o);Nt.current.delete(n.sessionId),Nt.current.set(n.sessionId,{text:s.slice(-KE),raw:o,offset:n.offset,truncated:n.offset===void 0?n.truncated||o.length>128e3:n.offset>o.length}),Nt.current.size>64&&Nt.current.delete(Nt.current.keys().next().value),window.dispatchEvent(new CustomEvent(`super-pi-exec-output`,{detail:n.sessionId}))}else if(n.type===`run.stopping`)Or(e=>{let t=new Set(e);return t.add(n.conversationId),t});else if(n.type!==`exec.exit`){if(n.type.startsWith(`terminal.`))Pt.current?.(n);else if(n.type===`conversation.autoRename.result`){let e=Nr.current.get(n.conversationId);e&&(Nr.current.delete(n.conversationId),n.ok?e.resolve(n.title):e.reject(Error(n.error)))}else if(n.type===`message.thinking`)zt(n);else if(n.type===`state`){Rt(),Qr.current=!1;let e=Zr.current,t=!!(e&&ti.current.has(e)),r=!(!e||n.state.conversations.some(t=>t.id===e)),i=t&&r&&e&&ni.current.has(e)?{...n.state,conversations:[ni.current.get(e),...n.state.conversations]}:n.state;e&&!r&&(ti.current.delete(e),ni.current.delete(e)),m.current=m.current.filter(e=>!e.accepted?.(i)||i.sendReceipts&&e.retry&&!e.receipt?!0:(e.retry&&typeof e.command?.conversationId==`string`&&typeof e.command.clientId==`string`&&Vf(e.command.conversationId,e.command.clientId),!1)),p(m.current),Or(e=>{let t=new Set(e);for(let e of[...t]){let n=i.conversations.find(t=>t.id===e);(!n||n.status!==`running`&&n.status!==`waiting`)&&t.delete(e)}return t}),i.extensionUi&&dn(i.extensionUi),i.stoppingConversationIds&&Or(new Set(i.stoppingConversationIds)),d(i),Ee(!0),j(!0);let a=m.current.filter(e=>e.key===`create-workspace`).map(e=>e.temporaryId);k(e=>{if(!e&&er.current)return;if(e&&(P(e)||i.workspaces.some(t=>t.id===e)||a.includes(e)))return e;let t=_.current?.workspaceId;return t&&i.workspaces.some(e=>e.id===t)?t:i.workspaces[0]?.id})}else if(n.type===`message.delta`)zt(n);else if(n.type===`queue.withdrawn`){mi(e=>[...e.filter(e=>e.conversationId!==n.conversationId).slice(-9),{id:`withdrawn_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,conversationId:n.conversationId,actor:n.actor,withdrawn:n.withdrawn}]);let e=n.withdrawn.slice(0,2).map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,24)}」`).join(`、`),t=n.actor===`agent`?`上级 Agent 已撤回`:`已撤回`;Ds(`${t} ${n.withdrawn.length} 条排队消息:${e}${n.withdrawn.length>2?`…`:``}`,`info`)}else if(n.type===`message.revert.result`)Dl(void 0),Er(void 0),n.ok||(console.error(`[Super Pi Error] revert failed:`,n.message),te(n.message));else if(n.type===`operation.result`){let e=m.current.find(e=>e.id===n.requestId),t=e?.retry?e.command:void 0;if(t&&Vf(t.conversationId,t.clientId),m.current=m.current.filter(e=>e.id!==n.requestId),p(m.current),e?.temporaryId){let t=e.temporaryId;if(e.key===`create-workspace`&&n.ok&&n.entityId){let r=n.entityId;d(n=>{if(n.workspaces.some(e=>e.id===r))return n;let i=e.apply(n).workspaces.find(e=>e.id===t);return i?{...n,workspaces:[...n.workspaces,{...i,id:r}]}:n})}else if(n.ok&&n.entityId){let e=n.entityId,r=ri.current.get(t);if(r&&ni.current.set(e,{...r,id:e}),ti.current.add(e),r){let t={...r,id:e};d(n=>n.conversations.some(t=>t.id===e)?n:{...n,conversations:[t,...n.conversations]})}Fr(n=>{let r=n[t];if(!r)return n;let i=n[e],a={...n};return a[e]=i?{...i,text:r.text||i.text,images:r.images.length?r.images:i.images,attachments:r.text?r.attachments:i.attachments,pendingSkills:r.text?r.pendingSkills:i.pendingSkills,uploading:r.uploading+i.uploading}:r,delete a[t],a}),ri.current.delete(t)}D(r=>r===t?n.ok?n.entityId:e.previousActiveId:r),ie(e=>fk(e,t,n.ok&&n.entityId?n.entityId:void 0)),k(r=>r===t?n.ok?n.entityId:e.previousWorkspaceId:r),!n.ok&&e.key===`create-workspace`&&ki.current===t&&D(t=>t??e.previousActiveId)}if(!n.ok){if(console.error(`[Super Pi Error] operation failed:`,n.message),!e?.receipt){if(e?.onFailure)e.onFailure(n.message);else if(t){let e=t.images??[],r=UD(t.content,t.attachments);Br(i=>[...i,{id:t.clientId,conversationId:t.conversationId,content:t.content,images:e,attachments:r,reason:n.message}]),Ui(t.conversationId,n=>n.text||n.images.length||n.attachments.length?n:{...n,text:t.content,images:e,attachments:r})}}let r=n.message??`操作失败`;te(r),e?.onFailure||Ds(Ht(r),`error`)}}else n.type===`tools.updated`?window.dispatchEvent(new Event(`super-pi-tools-updated`)):n.type===`files.changed`?(La.current(n.workspaceId,n.changes,n.dropped),n.workspaceId===za.current&&Ia.current()):n.type===`files.invalidated`?(Ra.current(n.workspaceId,n.paths),n.workspaceId===za.current&&Ia.current()):n.type===`error`?(console.error(`[Super Pi Error]`,n.message),n.recordedTurnFailure||(te(n.message),Ds(Ht(n.message),`error`),Qr.current&&=!1)):n.type===`extension.ui`?Ns(n.conversationId,n.request):n.type===`extension.ui.closed`?Ps(n.conversationId,n.requestId,n.reason):n.type===`model.catalog`?n.conversationId&&n.conversationId!==Zr.current||hn(n.catalog):n.type===`model.catalog.all`?_n(n.catalog):n.type===`providers.list`?(bn(n.providers),Sn(n.apis)):n.type===`agent.catalog`?((n.sourceServerId??ce())===ce()&&wn(n.catalog),(n.sourceServerId??ce())===le()&&An(n.catalog)):n.type===`prompt.catalog`?ln(n.catalog):n.type===`subagent.catalog`?((n.sourceServerId??ce())===ce()&&En(n.catalog),(n.sourceServerId??ce())===le()&&Mn(n.catalog)):n.type===`server.version`?On(n.version):n.type===`subagent.event`?d(e=>({...e,subagentRuns:js(e.subagentRuns??[],n.run)})):n.type===`workflow.event`?d(e=>({...e,workflows:Ms(e.workflows??[],n.workflow)})):n.type===`message.tools`?d(e=>({...e,conversations:e.conversations.map(e=>e.id===n.conversationId?{...e,messages:e.messages.map(e=>e.id===n.messageId?{...e,toolCalls:n.toolCalls}:e)}:e)})):n.type===`conversation.fork.result`&&(Fl(e=>e===n.conversationId?void 0:e),Ds(n.ok?`已从「${n.title}」分叉出新会话,放在侧边栏最上面;没有切换过去。${n.messagesCopied?`复制了 ${n.messagesCopied} 条消息。`:`原会话还没有消息,只复制了会话本身。`}`:`分叉失败:${Ht(n.message)}`,n.ok?`info`:`error`))}}})(),()=>{e=!0,Rt();for(let e of Xr.current)window.clearTimeout(e);Fe.current?.close()}},[zt,Rt,ct]);let Fs=(0,u.useCallback)(e=>{if(!Fe.current?.canSend(e))return!1;try{return Fe.current.send(JSON.stringify(e)),!0}catch(e){return Ds(e instanceof Error?e.message:`服务器未连接`,`error`),!1}},[]),Is=(0,u.useCallback)(e=>{ve({id:e,ticket:++ge.current});let t=Zr.current;t?.startsWith(`pending:`)||Fs({type:`state.subscribe`,...t?{conversationId:t}:{}}),Vn()},[Fs,Vn]);(0,u.useEffect)(()=>{if(!_e)return;if(_e.ticket!==ge.current){ve(void 0);return}let e=si.find(e=>e.id===_e.id);e&&T.workspaces.some(t=>t.id===e.workspaceId)&&(ve(void 0),pa(e.id),k(e.workspaceId))},[_e,si,T.workspaces,pa]),(0,u.useEffect)(()=>{if(!N)return;let e=R?.id;e?.startsWith(`pending:`)||Fs({type:`state.subscribe`,...e?{conversationId:e}:{}})},[R?.id,N,Fs]);let Ls=(e,t,n,r,i,a,o)=>{let s=Fe.current?.canSend(e)===!0,c=NT(e);if(m.current.some(e=>e.key===t)||!s&&!c)return!1;if(c&&!Bf(e))return Ds(`浏览器无法保存待发消息,正文仍在输入框。`,`error`),!1;let l=ur(),u=C(e),d=[...u][0]??e._server??ce(),f={id:l,key:t,serverId:d,apply:e=>u.size||ce()===d?n(e):e,temporaryId:r,previousActiveId:Zr.current,previousWorkspaceId:ki.current,onFailure:i,accepted:a,...o?{expiresAt:Date.now()+o}:{},...c?{retry:!0,command:e}:{}};return m.current=[...m.current,f],p(m.current),s&&Fe.current.send(JSON.stringify({...e,operationRequestId:l})),!0},Rs=e=>Fs({...e,_server:le()}),zs=(e,...t)=>Ls({...e,_server:le()},...t),Bs=(e,t)=>{Fs({type:`conversation.childLock`,conversationId:e,unlocked:t})||Ds(t?`连接断开,这个子会话没有解锁,请重试`:`连接断开,这个子会话没有上锁,请重试`,`error`)},Vs=e=>{if(!e)return;let t=`message_${ur()}`;Ls({type:`message.send`,conversationId:e,content:vD,clientId:t},`continue-truncated:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===e?{...t,warning:void 0}:t)}),void 0,void 0,void 0)};(0,u.useEffect)(()=>{let e=f.flatMap(e=>e.expiresAt?[e.expiresAt]:[]);if(!e.length)return;let t=window.setTimeout(()=>{let e=m.current.filter(e=>e.expiresAt&&e.expiresAt<=Date.now());if(e.length){m.current=m.current.filter(t=>!e.includes(t)),p(m.current);for(let t of e)t.onFailure?.(`打断请求超时,尚未确认是否开始回答;请检查会话状态后重试`)}},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[f]);let Hs=(e,t)=>n=>({...n,conversations:n.conversations.map(n=>n.id===e?{...n,...t}:n)}),X=(e,t)=>n=>({...n,workspaces:n.workspaces.map(n=>n.id===e?{...n,...t}:n)}),Us=R?.id.startsWith(`pending:`)===!0,Ws=!!(R&&pO(R)&&(Dr.has(R.id)||f.some(e=>e.key===`stop:${R.id}`))),Gs=R?.messagesLoaded===!1||f.some(e=>e.key.startsWith(`send:${R?.id}:`)||e.key===`configuration:${R?.id}`||e.temporaryId===R?.id||e.key===`archive:${R?.id}`),Ks=(e,t,n,r,i)=>{e&&Fs({type:`question.answer`,conversationId:e,messageId:t,callIndex:n,answers:r,cancelled:i})},qs=(e,t)=>Sr(n=>({...n,[e]:t})),Js=(e,t,n)=>(fa(e),Ls({type:`extension.ui.answer`,conversationId:e,requestId:t,...n},`answer:${e}:${t}`,e=>e)),Ys=R?.model??mn?.defaultModel,Xs=R?.thinkingLevel??mn?.defaultThinkingLevel,Zs=Xs&&mn?.levels.includes(Xs)?Xs:void 0,Qs=mn?.source===`pi`,$s=mn?.models.find(e=>e.provider===Ys?.provider&&e.modelId===Ys?.modelId),ec=!!$s?.imageInput,tc=(e,t)=>!e||!t?e:{...e,models:e.models.filter(e=>(T.modelFilterRules??[]).every(n=>{try{let r=new RegExp(n.workspacePattern,`i`),i=[t.name,t.path,t.worktreeProjectPath].filter(e=>!!e).some(e=>r.test(e.replaceAll(`\\`,`/`))),a=new RegExp(n.modelPattern,`i`);return!i||a.test(e.label)||a.test(`${e.provider}/${e.modelId}`)}catch{return!0}}))},nc=!!R?.messages?.some(e=>e.images&&e.images.length>0),rc=tc(mn,T.workspaces.find(e=>e.id===R?.workspaceId))?.models??[],ic=nc?rc.filter(e=>e.imageInput):rc,ac=ic.map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,UE(e.contextWindow)?`${UE(e.contextWindow)} 上下文`:``,WE(e.maxTokens)?`${WE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:CD(e),selected:Ys?.provider===e.provider&&Ys.modelId===e.modelId})),oc=(mn?.levels??[]).map(e=>({key:e,label:e,selected:e===Xs})),sc=e=>{if(!R)return;let[t,n]=e.split(`/`);t&&n&&(fa(R.id),Ls({type:`conversation.model`,conversationId:R.id,provider:t,modelId:n},`configuration:${R.id}`,Hs(R.id,{model:mn?.models.find(e=>e.provider===t&&e.modelId===n)??{provider:t,modelId:n,label:n}})))},cc=e=>{R&&(fa(R.id),Ls({type:`conversation.thinking`,conversationId:R.id,level:e},`configuration:${R.id}`,Hs(R.id,{thinkingLevel:e})))},lc=Cn?.agents.find(e=>e.id===R?.agentId),uc=[{key:iO,label:`跟随 Pi 默认`,detail:`不使用任何 agent 角色`,selected:!R?.agentId},...(Cn?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:R?.agentId===e.id}))],dc=lc?.model,fc=!!(dc&&R?.model&&R.model.provider===dc.provider&&R.model.modelId===dc.modelId);lc?.thinkingLevel&&(R?.thinkingLevel,lc.thinkingLevel);let pc=e=>{if(R){let t=Cn?.agents.find(t=>t.id===e);Ls({type:`conversation.agent`,conversationId:R.id,agentId:e===iO?null:e},`configuration:${R.id}`,Hs(R.id,{agentId:t?.id,...t?.model?{model:{...t.model,label:t.model.modelId}}:{},...t?.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}}))}},mc=Pn.filter(e=>e.conversationId===R?.id),hc=(0,u.useMemo)(()=>{let e=R?.id;return e?(R.messages??[]).flatMap(t=>(t.toolCalls??[]).flatMap((n,r)=>n.question?.status===`pending`?[{key:XD(e,t.id,r),messageId:t.id,index:r,value:n.question}]:[])):[]},[R?.id,R?.messages]),gc=hc[0],_c=()=>{let e=gc;e&&(wr(e.key),nt(`session`),window.setTimeout(()=>{(Tt.current?.querySelector(`[data-transcript-key="${CSS.escape(`m:${e.messageId}`)}"]`))?.scrollIntoView({block:`center`,behavior:`smooth`})},0))},vc=un.filter(e=>e.conversationId===R?.id).map(e=>e.request),yc=new Map(vc.filter(e=>e.method===`setStatus`).map(e=>[e.statusKey??``,e.statusText??``])),bc=new Map(vc.filter(e=>e.method===`setWidget`).map(e=>[e.widgetKey??``,{lines:e.widgetLines??[],placement:e.widgetPlacement??`aboveEditor`}])),xc=vc.find(e=>e.method===`setTitle`)?.title,Sc=(0,u.useMemo)(()=>(T.subagentRuns??[]).filter(e=>e.conversationId===R?.id),[T.subagentRuns,R?.id]),Cc=(0,u.useMemo)(()=>(T.workflows??[]).filter(e=>e.conversationId===R?.id),[T.workflows,R?.id]),wc=(0,u.useMemo)(()=>new Map(Cc.map(e=>[e.id,e])),[Cc]),Tc=(0,u.useMemo)(()=>new Map((Tn?.agents??[]).map(e=>[e.id,e.name])),[Tn]),Ec=(0,u.useMemo)(()=>new Map((R?.messages??[]).map(e=>[e.id,e])),[R?.messages]),Dc=(0,u.useMemo)(()=>new Map(Sc.map(e=>[e.id,e])),[Sc]),Oc=(0,u.useMemo)(()=>{let e=new Map;for(let t of Sc)t.originMessageId!==void 0&&t.originCallRow!==void 0&&e.set(`${t.originMessageId}:${t.originCallRow}`,t);return e},[Sc]),kc=(0,u.useMemo)(()=>{if(!R||!da)return[];let e=Tr?.conversationId===R.id?(()=>{let e=R.messages.find(e=>e.id===Tr.messageId);if(e)return{index:R.messages.indexOf(e),at:Date.parse(e.createdAt)||0,...Tr.kind===`withdraw`?{inclusive:!0}:{inclusive:!1}}})():void 0,t=[];return R.messages.forEach((n,r)=>{e&&(r>e.index||e.inclusive&&r===e.index)||n.delivery||t.push({at:Date.parse(n.createdAt)||0,seq:r,key:`m:${n.id}`})}),Sc.forEach((n,r)=>{n.originMessageId&&n.originCallRow!==void 0&&R?.messages.some(e=>e.id===n.originMessageId&&e.toolCalls?.[n.originCallRow])||e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`r:${n.id}`})}),Cc.forEach((n,r)=>{e&&(Date.parse(n.startedAt)||0)>e.at||t.push({at:Date.parse(n.startedAt)||0,seq:t.length+r,key:`w:${n.id}`})}),Di(t)},[R,Sc,Cc,Tr]),Ac=(0,u.useMemo)(()=>{for(let e=kc.length-1;e>=0;--e){let t=kc[e];if(t.startsWith(`m:`)&&Ec.get(t.slice(2))?.role===`user`)return t.slice(2)}},[kc,Ec]);(0,u.useEffect)(()=>{let e=Tt.current;if(!e||!R?.id)return;let t=()=>{!Mt.current&&Ie.current[R.id]?.followTail&&(ok(e),e.scrollTop=e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return()=>n.disconnect()},[R?.id,R?.messages,Sc,Cc,da,kc,et]);let jc=e=>gr(t=>({...t,[e]:!t[e]})),Mc=(e,t)=>vr(n=>({...n,[`${e}:${t}`]:!n[`${e}:${t}`]})),Nc=(e,t)=>br(n=>({...n,[`${e}:${t}`]:n[`${e}:${t}`]!==!1})),[Pc,Fc]=(0,u.useState)({}),Ic=e=>Fc(t=>({...t,[e]:t[e]!==!0})),Lc=e=>{Ls({type:`subagent.stop`,runId:e},`stop:${e}`,e=>e)||Ds(`连接断开,无法停止子智能体,请重试`,`error`)},Rc=e=>{Ls({type:`workflow.stop`,workflowId:e},`stop:${e}`,e=>e)||Ds(`连接断开,无法停止编排,请重试`,`error`)},zc=e=>[...bc].filter(([,t])=>t.placement===e).map(([e,t])=>{let n=t.lines;return(0,L.jsxs)(`div`,{className:`extui-widget`,"data-widget-key":e,"data-widget-lines":n.length,children:[n.slice(0,AD).map((e,t)=>(0,L.jsx)(`div`,{children:e},`${t}:${e}`)),n.length>AD&&(0,L.jsx)(`div`,{children:`… (widget truncated)`})]},e)}),Bc=(e,t)=>{let n=`pending:${ur()}`,r={id:n,name:e,path:t,updatedAt:new Date().toISOString()};Ls({type:`workspace.create`,name:e,path:t},`create-workspace`,e=>({...e,workspaces:[...e.workspaces,r]}),n)&&(ha(n),Ae(!1))},[Vc,Hc]=(0,u.useState)(),Uc=(e,t)=>Hc(n=>n?.kind===e&&n.id===t?n:{kind:e,id:t}),Wc=()=>Hc(void 0),Gc=(e,t)=>Vc?.kind===e&&Vc.id===t,Kc=(e,t,n)=>!t.startsWith(`pending:`)&&(e===`conversation`&&fa(t),Ls(e===`workspace`?{type:`workspace.rename`,workspaceId:t,name:n}:{type:`conversation.rename`,conversationId:t,name:n},`rename:${t}`,e===`workspace`?X(t,{name:n}):Hs(t,{title:n}))?(Qr.current=!0,Wc(),!0):(Ds(`连接断开,改名未保存,请重试`,`error`),!1)),qc=async e=>{if(e.startsWith(`pending:`)){Ds(`这个会话还在创建中,稍后再试`,`warning`);return}if(Nr.current.has(e))return;Ds(`正在根据对话内容生成标题…`,`info`);let t=new Promise((t,n)=>{Nr.current.set(e,{resolve:t,reject:n}),window.setTimeout(()=>{Nr.current.delete(e)&&n(Error(`模型在 ${Math.round(YE/1e3)} 秒内没有返回标题`))},YE)});if(!Fs({type:`conversation.autoRename`,conversationId:e}))Nr.current.delete(e),Ds(`连接断开,无法生成标题`,`error`);else try{let n=await t;Kc(`conversation`,e,n),Ds(`已重命名为「${n}」`,`info`)}catch(e){Ds(`重命名失败:${Ht(e)}`,`error`)}},Jc=e=>{if(e.id.startsWith(`pending:`))return;let t=T.conversations.filter(t=>t.workspaceId===e.id).length;window.confirm(`从列表移除工作区「${e.name}」?${t?`其中的 ${t} 条会话会保留,`:``}重新添加同一个目录即可恢复,不会删除任何会话。`)&&(Xc(void 0),Ls({type:`workspace.delete`,workspaceId:e.id},`delete:${e.id}`,t=>({...t,workspaces:t.workspaces.filter(t=>t.id!==e.id),conversations:t.conversations.filter(t=>t.workspaceId!==e.id)})))},[Yc,Xc]=(0,u.useState)(),[Zc,Qc]=(0,u.useState)(!1),$c=Yc?T.workspaces.find(e=>e.id===Yc):void 0,{theme:el,setTheme:tl}=Th(),[nl,rl]=(0,u.useState)(!1),[il,al]=(0,u.useState)();(0,u.useEffect)(()=>{let e=()=>{de(),ue(`entry`),al(`servers`),rl(!0)};return window.addEventListener(`super-pi-open-server-management`,e),()=>window.removeEventListener(`super-pi-open-server-management`,e)},[]);let[ol,sl]=(0,u.useState)(!1),cl=(e,t,n,r)=>{e.startsWith(`pending:`)||(Ls({type:`workspace.settings`,workspaceId:e,model:n?{provider:n.provider,modelId:n.modelId}:null,thinkingLevel:r??null,agentId:t??null},`defaults:${e}`,X(e,{defaultModel:n,defaultThinkingLevel:r,defaultAgentId:t}))?Xc(void 0):Ds(`连接断开,设置未保存,请重试`,`error`))},ll=(e,t)=>{let n=M.activeServer;Ls({type:`workspaces.settings.bulk`,model:e?{provider:e.provider,modelId:e.modelId}:null,thinkingLevel:t??null},`workspace-defaults-bulk`,r=>({...r,workspaces:r.workspaces.map(r=>{if(h(r.id).server!==n||r.closedAt||r.id.startsWith(`pending:`))return r;let i={...r};return e?i.defaultModel=e:delete i.defaultModel,t?i.defaultThinkingLevel=t:delete i.defaultThinkingLevel,i})}))?Qc(!1):Ds(`连接断开,批量设置未保存,请重试`,`error`)},ul=(e,t=``)=>{if(e.startsWith(`pending:`))return;if(m.current.some(t=>t.key===`defaults:${e}`)){Ds(`工作区设置正在保存,请稍后再新建会话`,`warning`);return}let n=`pending:${ur()}`,r={id:n,workspaceId:e,title:`新会话`,status:`idle`,updatedAt:new Date().toISOString(),messages:[],...t?{cwd:t}:{}};ri.current.set(n,r),Ls({type:`conversation.create`,workspaceId:e,...t?{cwd:t}:{}},`create-session:${e}:${n}`,e=>({...e,conversations:[r,...e.conversations]}),n)?(ge.current++,k(e),D(n),nt(`session`),ie(e=>({...e,ids:[...e.ids.filter(e=>e!==n),n],touched:dk(e.touched,n)}))):(ri.current.delete(n),Ds(`连接断开,会话未创建,请重试`,`error`))},dl=e=>{if(e.startsWith(`pending:`))return;let t=T.conversations.find(t=>t.id===e);if(!t||t.archivedAt||t.parentConversationId&&T.conversations.some(e=>e.id===t.parentConversationId))return;let n=pD(T.conversations,e),r=n.filter(e=>!e.archivedAt),i=r.length-1,a=n.length-r.length,o=GE(T.pendingUserDecisionsByConversation,n.map(e=>e.id)),s=XE({title:t.title,activeCount:r.length,activeDescendants:i,alreadyArchived:a,pendingDecisions:o});if(ZE({activeDescendants:i,pendingDecisions:o})&&!window.confirm(s))return;let c=new Date().toISOString(),l=new Set(r.map(e=>e.id));Ls({type:`conversation.archive`,conversationId:e},`archive:${e}`,e=>({...e,conversations:e.conversations.map(e=>l.has(e.id)&&!e.archivedAt?{...e,archivedAt:c}:e)}))},fl=(e,t)=>Ls({type:`conversation.collapse`,conversationId:e,collapsed:t},`collapse:${e}`,n=>{let r=new Set(n.collapsedConversationIds??[]);t?r.add(e):r.delete(e);let i={...n};return r.size===0?delete i.collapsedConversationIds:i.collapsedConversationIds=[...r],i}),pl=e=>{let t=T.conversations.find(t=>t.id===e);if(!t?.archivedAt||(t.parentConversationId?T.conversations.find(e=>e.id===t.parentConversationId):void 0)?.archivedAt)return;let n=new Set(pD(T.conversations,e).filter(e=>e.archivedAt).map(e=>e.id));Ls({type:`conversation.unarchive`,conversationId:e},`unarchive:${e}`,e=>({...e,conversations:e.conversations.map(e=>{if(!n.has(e.id)||!e.archivedAt)return e;let t={...e};return delete t.archivedAt,t})}))},ml=async e=>{if(!R){Ds(`请先选择或创建会话`,`error`);return}if(!ec){Ds(`当前模型不支持图片输入`,`error`);return}let t=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],n=e.filter(e=>t.includes(e.type)?e.size>5242880?(Ds(`图片「${e.name}」超过 5MB 上限`,`error`),!1):!0:(Ds(`不支持的文件格式「${e.name}」,仅支持 PNG/JPEG/GIF/WebP`,`error`),!1));if(n.length===0)return;let r=R.id;Ui(r,e=>({...e,uploading:e.uploading+n.length}));let i=n.map(e=>({id:ur(),conversationId:r,name:e.name,url:URL.createObjectURL(e)}));Hr(e=>[...e,...i]);for(let[e,t]of n.entries()){let n=i[e];try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>{let t=r.result,n=t.indexOf(`,`);e(n>=0?t.slice(n+1):t)},r.onerror=n,r.readAsDataURL(t)}),i=await ke(`/api/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({conversationId:r,name:t.name,mimeType:t.type,data:e})});if(!(i.headers.get(`content-type`)??``).includes(`application/json`)){Ds(`服务器未返回 JSON 响应,请刷新或重启服务`,`error`);continue}if(i.ok){let e=await i.json();if(Rr.current.has(n.id))continue;Hr(e=>e.filter(e=>e.id!==n.id)),URL.revokeObjectURL(n.url),Ui(r,t=>({...t,images:[...t.images,{id:g(se(r),e.id),name:e.name,mimeType:e.mimeType,bytes:e.bytes}]}))}else{let e=await i.json().catch(()=>({error:`上传失败`}));Ds(Ht(e.error,`上传失败(HTTP ${i.status})`),`error`)}}catch(e){Ds(`上传失败:${Ht(e,`网络或服务暂时不可用`)}`,`error`)}finally{Hr(e=>e.map(e=>e.id===n.id?{...e,failed:!0}:e)),Ui(r,e=>({...e,uploading:Math.max(0,e.uploading-1)}))}}},hl=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.type.startsWith(`image/`)){let e=r.getAsFile();e&&n.push(e)}}if(n.length>0){if(!ec){Ds(`当前模型不支持图片输入`,`error`);return}e.preventDefault(),ml(n)}},gl=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),Kr(!0))},_l=e=>{e.currentTarget.contains(e.relatedTarget)||Kr(!1)},vl=e=>{Kr(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>e.type.startsWith(`image/`));if(t.length>0){if(e.preventDefault(),!ec){Ds(`当前模型不支持图片输入`,`error`);return}ml(t)}},yl=t=>{if(t.preventDefault(),!R)return;if(_i){Ds(Qe,`warning`);return}if(Gs){Ds(Us?`会话正在创建,请稍候再发送`:R.messagesLoaded===!1?`正在加载会话,请稍候再发送`:`正在保存配置,请稍候再发送`,`info`);return}if(!Ri.trim()&&zi.length===0)return;if(zi.length>0&&!ec){Ds(`当前模型不支持图片输入,请移除图片或切换至支持图文的模型`,`error`);return}if(Hi>0){Ds(`图片正在上传中,请稍候…`,`info`);return}if(Vi){Ds(`技能正在读取中,请稍候…`,`info`);return}let n=`message_${ur()}`,r=R.id,i=Ri,a=zi,o=Bi;fa(r),e.stoppingConversationIds||Or(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t});let s=WD({conversationId:r,content:i,clientId:n,images:a,attachments:o,inFlight:pO(R),deliveryMode:ui}),c=new Date().toISOString();Ls(s,`send:${r}:${n}`,e=>Uf(e,s,c),n,e=>{Br(t=>[...t,{id:n,conversationId:r,content:i,images:a,attachments:o,reason:e}]),Ui(r,e=>e.text||e.images.length||e.attachments.length?e:{...e,text:i,images:a,attachments:o})},e=>!!e.conversations.find(e=>e.id===r)?.messages.some(e=>e.id===Hf(s)))&&Ui(r,e=>({...e,text:``,images:[],attachments:[],pendingSkills:void 0}))},bl=(0,u.useMemo)(()=>(R?.messages??[]).filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),[R?.messages]),xl=e=>{Ls({type:`message.cancel`,conversationId:R?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===R?.id?{...t,messages:t.messages.filter(t=>t.id!==e)}:t)}))||Ds(`连接断开,撤回没有生效,请重试`,`error`)},Sl=e=>{if(!R?.id||!e.length)return;let t=new Set(e),n=`queue-many:${R.id}:${e.join(`,`)}`;Ls({type:`message.cancelMany`,conversationId:R.id,messageIds:e},n,e=>({...e,conversations:e.conversations.map(e=>e.id===R.id?{...e,messages:e.messages.filter(e=>!t.has(e.id))}:e)}),void 0,e=>Ds(e??`撤回所选消息失败,请重试`,`error`),t=>{let n=t.conversations.find(e=>e.id===R.id);return!!(n&&e.every(e=>!n.messages.some(t=>t.id===e&&t.delivery)))})||Ds(`连接断开,批量撤回没有生效,请重试`,`error`)},Cl=e=>{Ls({type:`message.steer`,conversationId:R?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===R?.id?{...t,messages:eD(t.messages,e,0)}:t)}),void 0,void 0,t=>t.conversations.find(e=>e.id===R?.id)?.messages.find(t=>t.id===e)?.delivery===`sending`)||Ds(`连接断开,插到最前没有生效,请重试`,`error`)},wl=e=>{let t=R?.id;t&&(Fe.current?.readyState===WebSocket.OPEN?Ls({type:`message.interrupt`,conversationId:t,messageId:e},`interrupt:${t}:${e}`,e=>e,void 0,e=>Ds(e??`打断失败,请重试`,`error`),n=>{let r=n.conversations.find(e=>e.id===t)?.messages.find(t=>t.id===e);return!(!r||r.delivery)},3e4)||Ds(`正在打断,请稍候`,`info`):Ds(`连接断开,打断没有生效,请重试`,`error`))},Tl=e=>{Ls({type:`message.sendQueued`,conversationId:R?.id??``,messageId:e},`send-queued:${e}`,e=>e,void 0,void 0,t=>!t.conversations.find(e=>e.id===R?.id)?.messages.find(t=>t.id===e)?.delivery)||Ds(`连接断开,发送没有生效,请重试`,`error`)},Z=(e,t)=>{Ls({type:`message.edit`,conversationId:R?.id??``,messageId:e,content:t},`edit:${e}`,n=>({...n,conversations:n.conversations.map(n=>n.id===R?.id?{...n,messages:n.messages.map(n=>n.id===e?{...n,content:t}:n)}:n)}))||Ds(`连接断开,修改没有生效,请重试`,`error`)},[El,Dl]=(0,u.useState)(),Ol=(e,t=!1)=>{if(!R||R.messagesLoaded===!1||El)return;let n=R.messages.find(t=>t.id===e);n&&(n&&Fr(e=>{let t=e[R.id]??{text:``,images:[],attachments:[],uploading:0};return t.text.trim()||t.images.length||t.attachments.length?e:{...e,[R.id]:{...t,text:n.content,images:n.images??[],attachments:UD(n.content,n.attachments)}}}),Er({conversationId:R.id,messageId:e,kind:t?`withdraw`:`revert`})),Fs({type:`message.revert`,conversationId:R.id,messageId:e,withdraw:t})?Dl(e):(Er(void 0),Ds(`连接断开,回退未执行,请重试`,`error`))},[kl,Al]=(0,u.useState)(),jl=(0,u.useRef)(void 0),Ml=(0,u.useRef)(0),Nl=async(e,t)=>{let n=++Ml.current,r=await vd(t);n===Ml.current&&(clearTimeout(jl.current),Al({id:e,kind:r?`copied`:`error`}),r||Ds(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中这条消息的文字复制`,`error`),jl.current=setTimeout(()=>Al(void 0),2e3))};(0,u.useEffect)(()=>()=>{Ml.current+=1,clearTimeout(jl.current)},[]);let[Pl,Fl]=(0,u.useState)(),Il=e=>{Pl||e.startsWith(`pending:`)||(fa(e),Fs({type:`conversation.fork`,conversationId:e})?Fl(e):Ds(`连接断开,分叉没有执行,请重试`,`error`))},Ll=new Map;for(let e of T.scheduledTasks??[])e.conversationId&&!Ll.has(e.conversationId)&&Ll.set(e.conversationId,e);let Rl=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-theme-open":`1`,title:`设置`,"aria-haspopup":`dialog`,"aria-expanded":nl,onClick:()=>{al(void 0),de(),rl(!0),Rs({type:`catalog.fetchAll`}),Rs({type:`providers.fetch`})},children:[(0,L.jsx)(on,{name:`settings`}),(0,L.jsx)(`span`,{className:`workbench-action-label`,children:`设置`})]}),(0,L.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-help-open":`1`,title:`使用指南`,"aria-haspopup":`dialog`,"aria-expanded":ol,onClick:()=>sl(!0),children:[(0,L.jsx)(on,{name:`help`}),(0,L.jsx)(`span`,{className:`workbench-action-label`,children:`使用指南`})]})]}),zl=ba?void 0:R,Bl=ge.current,Vl={onOpenSession:e=>{Bl===ge.current&&Is(e)},todos:T.todosByConversation?.[zl?.id??``]??[],tasks:OO(zl,T.backgroundTasks??[]),backgroundRuns:zl?Dc:void 0,execOutputs:Nt.current,scheduledTasks:(T.scheduledTasks??[]).filter(e=>e.workspaceId===Sa),scheduledCatalog:tc(mn,bs),scheduledAgents:Cn,notify:Ds,serverTimeZone:T.serverTimeZone,workspaceId:Sa,gitWorkspaceId:wa,gitRepositoryOnly:Ea,gitWorkspaceName:xs?.name,workspaceLabel:bs?.path,workspaceName:bs?.name,conversationId:zl?.id,followedWorktreeId:zl?.followedWorktreeId,cwd:Ta,connected:N&&M.statuses.get(M.activeServer)?.state===`online`&&Te&&!zl?.id.startsWith(`pending:`),files:B,onOpenFile:Ho,onOpenChanged:ko,onOpenGitDiff:Eo,activeGitDiffUrl:Co?.target.url,onFileReference:Uo,onFilesMoved:Wo,onSearchFolder:e=>so(`content`,void 0,[Ta,e].filter(Boolean).join(`/`)),onSelectTab:Ka,sendCommand:Fs,registerTerminalSink:Bt,terminalShell:T.terminalShell,sharedGit:V},Hl=e=>M.connections.some(t=>t.id===h(e).server)&&(Kn===`all`||h(e).server===Kn),Ul=new Set(T.workspaces.map(e=>e.id)),Wl=T.workspaces.filter(e=>Hl(e.id)&&(!e.worktreeOf||!Ul.has(e.worktreeOf))),Gl=Wl.flatMap(e=>[e,...T.workspaces.filter(t=>t.worktreeOf===e.id)]),Kl=(0,u.useMemo)(()=>{let e=new Map;for(let t of T.workspaces){if(t.closedAt)continue;let n=t.name.trim().toLowerCase();n&&e.set(n,(e.get(n)??0)+1)}return new Set([...e].filter(([,e])=>e>1).map(([e])=>e))},[T.workspaces]),ql=Jn&&Gl.some(e=>e.id===Jn)?Jn:O&&Gl.some(e=>e.id===O)?O:Gl[0]?.id,Jl=T.workspaces.find(e=>e.id===O),Yl=Jl?.worktreeOf&&Ul.has(Jl.worktreeOf)?Jl.worktreeOf:Jl?.id,Xl=Xn&&Wl.some(e=>e.id===Xn)?Xn:Yl&&Wl.some(e=>e.id===Yl)?Yl:Wl[0]?.id,Zl=Date.now()-18e6,Ql=Gl.filter(e=>e.id===Xl||e.worktreeOf===Xl),$l=e=>{let t=T.conversations.some(t=>t.workspaceId===e&&!t.archivedAt&&(Wn===`recent`?Date.parse(t.updatedAt)>=Zl:t.status===`running`||t.status===`waiting`)),n=(rt[e]?.rooms??[]).some(e=>!e.archivedAt&&(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id]))));return t||n},eu=Wl.flatMap(e=>{let t=Gl.filter(t=>t.worktreeOf===e.id&&$l(t.id));return $l(e.id)||t.length>0?[e,...t]:[]}),tu=Wn===`all`?Gl:Wn===`workspace`?Gl.filter(e=>e.id===ql):Wn===`repo`?Ql:eu,nu=Wn===`all`||Wn===`workspace`||Wn===`repo`,ru=(e,t=Wn,n=ql,r=Xl)=>{if(!e||!Hl(e))return!1;if(t===`all`)return!0;if(t===`workspace`)return e===n;if(t===`repo`)return e===r||Gl.some(t=>t.id===e&&t.worktreeOf===r);let i=T.conversations.filter(t=>t.workspaceId===e&&!t.archivedAt).some(e=>t===`recent`?Date.parse(e.updatedAt)>=Zl:e.status===`running`||e.status===`waiting`),a=(rt[e]?.rooms??[]).some(e=>!e.archivedAt&&(t===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id]))));return i||a},iu=(e,t=ql,n=Xl)=>{Gn(e),t&&Yn(t),n&&Zn(n);let r=et===`group`&&bt&&St?rt[bt]?.rooms.find(e=>e.id===St):void 0,i=et===`group`?!!(bt&&r&&!r.archivedAt&&ru(bt,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(r.updatedAt)>=Zl:[`running`,`queued`].includes(_t(r,st[r.id]))))):!!(R&&!R.archivedAt&&ru(R.workspaceId,e,t,n)&&(e===`all`||e===`workspace`||e===`repo`||(e===`recent`?Date.parse(R.updatedAt)>=Zl:R.status===`running`||R.status===`waiting`)));if(Xo.current=!0,i){e===`workspace`&&k(t);let r=Jo.find(e=>e.id===Yo)?.workspaceId;e!==`recent`&&e!==`running`&&(e!==`workspace`&&e!==`repo`||ru(r,e,t,n))||nt(`session`)}else $n(!0),D(void 0),qe(!1),et===`session`||et===`group`?nt(`session`):e!==`recent`&&e!==`running`&&(e!==`workspace`&&e!==`repo`||ru(Jo.find(e=>e.id===Yo)?.workspaceId,e,t,n))||nt(`session`),k(e===`workspace`?t:void 0)},au=e=>{qn(e),localStorage.setItem(`super-pi.server-filter`,e),e!==`all`&&I(e);let t=et===`group`?bt:R?.workspaceId??O;if(t&&e!==`all`&&h(t).server!==e){Xo.current=!0,$n(!0),D(void 0),qe(!1);let t=T.workspaces.filter(t=>h(t.id).server===e);if(Wn===`workspace`){let e=t.find(e=>e.id===Jn)?.id??t[0]?.id;Yn(e),k(e)}else k(void 0),Wn===`repo`&&Zn(t.find(e=>!e.worktreeOf)?.id);nt(`session`)}};(0,u.useEffect)(()=>{Kn!==`all`&&!M.connections.some(e=>e.id===Kn)&&au(`all`)},[Kn,M.connections]);let ou=Jo.filter(e=>{if(!e.workspaceId||!Hl(e.workspaceId))return!1;if(Wn===`all`)return!0;if(Wn===`workspace`||Wn===`repo`)return ru(e.workspaceId);if(e.id.startsWith(`session:`)){let t=T.conversations.find(t=>t.id===e.rawId);return!!(t&&!t.archivedAt&&ru(t.workspaceId)&&(Wn===`recent`?Date.parse(t.updatedAt)>=Zl:t.status===`running`||t.status===`waiting`))}if(e.id.startsWith(`group:`)){let t=ft(e.id),n=t?.roomId?rt[t.workspaceId]?.rooms.find(e=>e.id===t.roomId):void 0;return!!(t&&n&&!n.archivedAt&&ru(t.workspaceId)&&(Wn===`recent`?Date.parse(n.updatedAt)>=Zl:[`running`,`queued`].includes(_t(n,st[n.id]))))}return!1}),su=Ea?`未选工作区`:V.status?.detached?`游离 HEAD`:V.status?.branch,cu=!Ea&&V.status&&new Set([...V.status.staged,...V.status.unstaged,...V.status.untracked].map(e=>e.path)).size,lu=!Ea&&V.status&&(V.status.ahead||V.status.behind)?[V.status.ahead?`↑`+V.status.ahead:``,V.status.behind?`↓`+V.status.behind:``].filter(Boolean).join(` `):``,uu=()=>ir(e=>({...e,rightClosed:!0})),du=()=>ir(e=>({...e,leftClosed:!0})),fu=mr?Fn:to;return(0,L.jsxs)(`main`,{className:`shell workbench-shell${fu?` shell-rail-collapsed`:``} mobile-panel-${Ln}${Hn?` mobile-drawer-open`:``}`,"data-rail-collapsed":fu,"data-workbench-left-closed":!mr&&rr.leftClosed,"data-selected-workspace":O??``,style:{"--sidebar-width":`${sr.sidebar}px`,"--rail-col":fu?void 0:`${sr.rail}px`},children:[!mr&&(0,L.jsx)(sn,{side:`left`,views:qa,unpinned:rr.unpinned,active:rr.leftClosed||Ja?void 0:$a,onSelect:e=>ro(e,!0),searchActive:!rr.leftClosed&&Ja,onSearch:()=>{Za(!0),Ya(!0),ir(e=>({...e,leftClosed:Ja&&!e.leftClosed}))},onArrange:io,onReorder:ao,onReset:oo,children:Rl}),(0,L.jsxs)(`aside`,{className:`workbench-sessions`,id:`workbench-sessions`,"data-workbench-session-view":no?`shown`:`hidden`,children:[(0,L.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,L.jsx)(`button`,{className:`workspace-new`,onClick:()=>Ae(!0),children:`+ 添加工作区`}),R&&da&&ou.length===1&&(0,L.jsx)(`button`,{type:`button`,className:`mobile-close-session`,onClick:()=>{fs(R.id),Un(!1)},children:`关闭当前标签`})]}),(0,L.jsxs)(`div`,{className:`label label-desktop workspace-title-row`,children:[(0,L.jsx)(`span`,{children:`工作区`}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-bulk-settings`,title:`批量设置所有工作区`,"aria-label":`批量设置所有工作区`,onClick:()=>Qc(!0),children:`⚙`})]}),(0,L.jsx)(`div`,{className:`label label-phone`,children:`会话`}),Zc&&(0,L.jsx)(kT,{workspaces:T.workspaces.filter(e=>h(e.id).server===M.activeServer&&!e.closedAt&&!e.id.startsWith(`pending:`)),catalog:gn??{source:`unavailable`,models:[],levels:[],fetchedAt:``},onClose:()=>Qc(!1),onSave:ll}),(0,L.jsxs)(`div`,{className:`sidebar-session-filters`,"aria-label":`会话与群聊筛选`,children:[(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`span`,{children:`服务器`}),(0,L.jsxs)(`select`,{"aria-label":`服务器范围`,value:Kn,onChange:e=>au(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`全部服务器`}),M.connections.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.name,M.statuses.get(e.id)?.state===`offline`?` · 离线`:``]},e.id))]})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`span`,{children:`显示`}),(0,L.jsxs)(`select`,{"aria-label":`会话列表筛选方式`,value:Wn,onChange:e=>iu(e.currentTarget.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`全部`}),(0,L.jsx)(`option`,{value:`workspace`,children:`按工作区`}),(0,L.jsx)(`option`,{value:`repo`,children:`按仓库`}),(0,L.jsx)(`option`,{value:`recent`,children:`近期活跃 · 5 小时`}),(0,L.jsx)(`option`,{value:`running`,children:`正在运行`})]})]}),Wn===`workspace`&&(0,L.jsx)(`select`,{"aria-label":`选择工作区`,value:ql??``,onChange:e=>iu(`workspace`,e.currentTarget.value,Xl),children:(0,L.jsx)(He,{workspaces:Gl})}),Wn===`repo`&&(0,L.jsx)(`select`,{"aria-label":`选择仓库`,value:Xl??``,onChange:e=>iu(`repo`,ql,e.currentTarget.value),children:(0,L.jsx)(He,{workspaces:Wl})})]}),(0,L.jsx)(`nav`,{"aria-label":`工作区、会话与群聊`,children:tu.length===0?(0,L.jsx)(`div`,{className:`sidebar-filter-empty`,children:Wn===`recent`?`近 5 小时没有活跃的会话或群聊`:`当前没有正在运行的会话或群聊`}):tu.map((e,t)=>{let n=rt[e.id],r=(n?.rooms.filter(e=>!e.archivedAt)??[]).filter(e=>nu||(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:[`running`,`queued`].includes(_t(e,st[e.id])))),i=nu?n?.rooms.filter(e=>e.archivedAt)??[]:[],a=T.conversations.filter(t=>t.workspaceId===e.id),o=a.filter(e=>!e.archivedAt&&(nu||(Wn===`recent`?Date.parse(e.updatedAt)>=Zl:e.status===`running`||e.status===`waiting`))),s=VT(o,ci,{manualRoots:Gt[e.id]}),c=s.filter(e=>e.depth===0).map(e=>e.conversation.id),l=nu?a.filter(e=>e.archivedAt):[],u=VT(l,new Set),d=nu?l.length+i.length:0,f=ne[e.id]??!1,p=Vt[e.id]??!0,m=Kl.has(e.name.trim().toLowerCase()),g=!e.worktreeOf||!Ul.has(e.worktreeOf),_=(Wn===`recent`||Wn===`running`)&&g,v=t=>et===`group`&&bt===e.id&&St===t;return(0,L.jsxs)(`section`,{className:`workspace-group${e.worktreeOf&&Ul.has(e.worktreeOf)?` workspace-linked-checkout`:``}${_?` workspace-active-repo-root`:``}`,"data-workspace-parent":e.worktreeOf,"data-workspace-group":e.id,"data-sidebar-repo-root":_?e.id:void 0,"data-current-workspace":O===e.id,children:[M.connections.length>1&&(t===0||h(tu[t-1].id).server!==h(e.id).server)&&(0,L.jsxs)(`div`,{className:`workspace-server-label`,children:[me(e.id),M.statuses.get(h(e.id).server)?.state===`offline`?` · 离线`:``]}),(0,L.jsx)(`div`,{className:`workspace-header`,children:Gc(`workspace`,e.id)?(0,L.jsx)(nO,{initial:e.name,label:`重命名工作区 ${e.name}`,onCommit:t=>Kc(`workspace`,e.id,t),onClose:Wc}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`workspace-disclosure`,"data-workspace-fold":e.id,"aria-expanded":!f,"aria-label":`${f?`展开`:`折叠`}工作区 ${e.name}`,onClick:()=>re(t=>({...t,[e.id]:!t[e.id]})),children:(0,L.jsx)(`span`,{className:`chevron-folder`,"aria-hidden":`true`,children:f?`▸`:`▾`})}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-toggle`,"aria-label":e.name,"aria-describedby":m?`workspace-name-warning-${e.id}`:void 0,title:e.path,onContextMenu:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect();Ar({workspace:e,x:t.clientX||n.left+24,y:t.clientY||n.top+n.height})},onClick:()=>{Yn(e.id);let t=oi.find(t=>t.workspaceId===e.id)?.id;t?t===R?.id&&et===`session`&&da||pa(t):ha(e.id)},children:(0,L.jsxs)(`span`,{children:[(0,L.jsxs)(`span`,{className:`workspace-name-line`,children:[(0,L.jsx)(`strong`,{onDoubleClick:()=>Uc(`workspace`,e.id),children:e.name}),m&&(0,L.jsx)(`small`,{id:`workspace-name-warning-${e.id}`,className:`workspace-name-warning`,"data-workspace-name-warning":e.id,title:`请重命名其中一个工作区;名称唯一后提示会自动消失。`,children:`存在同名,易混淆`})]}),(0,L.jsx)(`small`,{children:e.path})]})}),(0,L.jsx)(`button`,{className:`workspace-add`,disabled:e.id.startsWith(`pending:`),title:`在此工作区新建会话`,onClick:t=>{Yn(e.id),Pe.current=t.currentTarget,Me({workspaceId:e.id})},children:`+`}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-group-chat`,"data-open-group-chat":e.id,disabled:e.id.startsWith(`pending:`),title:`新建群聊`,"aria-label":`在 ${e.name} 新建群聊`,onClick:()=>{Yn(e.id),ga(e.id)},children:(0,L.jsx)(on,{name:`group-add`})}),(0,L.jsx)(`button`,{className:`workspace-settings`,title:`工作区设置(默认智能体 / 模型 / 思考强度)`,"aria-label":`工作区设置 ${e.name}`,onClick:()=>Xc(e.id),children:`⚙`})]})}),!f&&r.map(t=>{let n=v(t.id),r=_t(t,st[t.id]),i=vt(t,st[t.id],Re.current[dt({workspaceId:e.id,roomId:t.id})]),a=i===`completed`?`讨论已完成,有新回复未读`:i===`unread`?`有新回复未读`:uO[r];return(0,L.jsxs)(`div`,{className:`conversation-row group-room-row`,children:[(0,L.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),(0,L.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-sidebar-group-chat":t.id,"aria-current":n?`true`:void 0,"aria-label":`打开群聊 ${t.title},${a}`,title:t.title,onClick:()=>{Yn(e.id),ga(e.id,t.id)},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,children:(0,L.jsx)(bO,{state:i,label:a})}),(0,L.jsx)(on,{name:`group`}),(0,L.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-archive`,"data-archive-group":t.id,title:`归档群聊`,"aria-label":`归档群聊 ${t.title}`,disabled:mt.has(t.id),onClick:()=>void ya(t,`archive`),children:(0,L.jsx)(on,{name:`archive`})})]},t.id)}),!f&&n?.failed&&(0,L.jsx)(`button`,{type:`button`,className:`group-rooms-retry`,onClick:it,children:`重试载入群聊`}),!f&&(s.length?s.map(({conversation:t,depth:n,childCount:r,isLastSibling:i})=>(0,L.jsxs)(`div`,{className:`conversation-row`,style:{"--tree-depth":n},"data-session-root":n===0?t.id:void 0,"data-session-dragging":qt?.conversationId===t.id?`true`:void 0,"data-session-drop":qt?.dropRootId===t.id?qt.dropAfter?`after`:`before`:void 0,onPointerDown:n===0?n=>Zt(n,e.id,t.id,c):void 0,children:[r>0?(0,L.jsxs)(`button`,{type:`button`,className:`conversation-tree-toggle`,"data-tree-toggle":t.id,"aria-expanded":!ci.has(t.id),title:ci.has(t.id)?`展开 ${r} 个子会话`:`折叠 ${r} 个子会话`,"aria-label":ci.has(t.id)?`展开会话 ${t.title} 的 ${r} 个子会话`:`折叠会话 ${t.title} 的 ${r} 个子会话`,onClick:()=>fl(t.id,!ci.has(t.id)),children:[(0,L.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:ci.has(t.id)?`▸`:`▾`}),(0,L.jsx)(`small`,{children:r})]}):(0,L.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),Gc(`conversation`,t.id)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(nO,{initial:t.title,label:`重命名会话 ${t.title}`,onCommit:e=>Kc(`conversation`,t.id,e),onClose:Wc}),(0,L.jsx)(`small`,{className:`conversation-time`,children:fD(t.updatedAt,ii)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{className:`conversation ${!ba&&R?.id===t.id?`selected`:``}`,"data-conversation":t.id,"aria-current":!ba&&R?.id===t.id?`true`:void 0,"data-tree-child":n>0?`true`:void 0,"data-tree-last":n>0&&i?`true`:void 0,title:n>0?`${t.title}(由「${o.find(e=>e.id===t.parentConversationId)?.title??`已不存在的会话`}」创建)`:t.title,"aria-label":`打开会话 ${t.title}${SO(t,Ll.get(t.id))}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.getBoundingClientRect();Mr({conversation:t,x:e.clientX||n.left+24,y:e.clientY||n.top+n.height})},onClick:()=>{t.id===Xt.current&&Date.now()-Yt.current<300||(Yn(e.id),pa(t.id),k(e.id),Un(!1))},onDoubleClick:()=>{ma(t.id)},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,children:(0,L.jsx)(bO,{state:vO(t,gO(t,Pn),Re.current[t.id],T.conversations)})}),(0,L.jsx)(`span`,{"data-conversation-title":t.id,onDoubleClick:e=>{e.stopPropagation(),Uc(`conversation`,t.id)},style:{flex:`0 1 auto`,minWidth:`3.5em`},children:t.title}),(0,L.jsx)(`span`,{className:`conversation-title-gap`,"aria-hidden":`true`,style:{marginLeft:`-8px`}}),yO(vO(t,gO(t,Pn),Re.current[t.id],T.conversations),_O(t,T.conversations,Re.current[t.id])),xO(t,Ll.get(t.id)),(0,L.jsx)(`small`,{children:fD(t.updatedAt,ii)})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-fork`,"data-fork-conversation":t.id,"data-fork-state":Pl===t.id?`pending`:`idle`,disabled:!!Pl,title:`从此会话分叉出一个新会话`,"aria-label":`从会话 ${t.title} 分叉出一个新会话`,onClick:()=>Il(t.id),children:`⑂`}),!(t.parentConversationId&&T.conversations.some(e=>e.id===t.parentConversationId))&&(0,L.jsx)(`button`,{className:`conversation-archive`,"data-archive-conversation":t.id,title:`归档整棵会话树`,"aria-label":`归档会话 ${t.title}`,onClick:()=>dl(t.id),children:`×`})]})]},t.id)):!r.length&&(0,L.jsx)(`div`,{className:`conversation-empty`,children:`暂无会话`})),!f&&d>0&&(0,L.jsxs)(`div`,{className:`archived-group`,"data-archived-count":d,children:[(0,L.jsxs)(`button`,{className:`archived-toggle`,title:p?`展开已归档`:`收起已归档`,"aria-expanded":!p,onClick:()=>Wt(t=>({...t,[e.id]:!p})),children:[(0,L.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:p?`▸`:`▾`}),(0,L.jsxs)(`span`,{className:`archived-label`,children:[`已归档 (`,d,`)`]})]}),!p&&u.map(({conversation:e,depth:t,isLastSibling:n})=>{let r=pD(l,e.id).length-1,i=!!(e.parentConversationId&&T.conversations.some(t=>t.id===e.parentConversationId&&t.archivedAt));return(0,L.jsxs)(`div`,{className:`conversation-archived`,"data-archived-conversation":e.id,"data-archived-at":e.archivedAt,"data-tree-child":t>0?`true`:void 0,"data-tree-last":t>0&&n?`true`:void 0,style:{"--tree-depth":t},children:[(0,L.jsx)(`i`,{className:`conversation-mark`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{"data-archived-title":e.id,children:e.title}),xO(e,Ll.get(e.id)),(0,L.jsx)(`small`,{children:mD(e.archivedAt)}),!i&&(0,L.jsx)(`button`,{className:`conversation-restore`,"data-restore-conversation":e.id,title:r?`恢复这个会话和它的 ${r} 个子孙会话`:`恢复为正常会话`,"aria-label":r?`恢复会话 ${e.title} 及其 ${r} 个子孙会话`:`恢复会话 ${e.title}`,onClick:()=>pl(e.id),children:`↑`})]},e.id)}),!p&&i.map(t=>{let n=v(t.id),r=mt.has(t.id);return(0,L.jsxs)(`div`,{className:`conversation-row group-room-row group-room-history`,"data-archived-group":t.id,children:[(0,L.jsxs)(`button`,{type:`button`,className:`conversation group-room-button${n?` selected`:``}`,"data-open-archived-group":t.id,"aria-current":n?`true`:void 0,"aria-label":`查看已归档群聊 ${t.title}`,title:t.title,onClick:()=>ga(e.id,t.id),children:[(0,L.jsx)(on,{name:`group`}),(0,L.jsx)(`span`,{className:`group-room-title`,children:t.title})]}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-restore-group":t.id,title:`恢复群聊`,"aria-label":`恢复群聊 ${t.title}`,disabled:r,onClick:()=>void ya(t,`restore`),children:`↑`}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"data-delete-group":t.id,title:`永久删除群聊`,"aria-label":`永久删除群聊 ${t.title}`,disabled:r,onClick:()=>void ya(t,`delete`),children:(0,L.jsx)(on,{name:`delete`})})]},t.id)})]}),!f&&(()=>{let t=T.warmSessions?.filter(t=>t.workspaceId===e.id)??[];return t.length?(0,L.jsxs)(`details`,{className:`archived-group`,"data-warm-sessions":e.id,children:[(0,L.jsx)(`summary`,{className:`archived-toggle`,children:(0,L.jsxs)(`span`,{className:`archived-label`,children:[`预热会话 (`,t.length,`)`]})}),t.map(e=>(0,L.jsxs)(`div`,{className:`conversation-archived`,"data-warm-session":e.id,children:[(0,L.jsx)(`span`,{title:e.title,children:e.title}),(0,L.jsx)(`button`,{type:`button`,className:`conversation-restore`,"aria-label":`移除预热会话 ${e.title}`,onClick:()=>{window.confirm(`移除预热会话「${e.title}」?`)&&!Fs({type:`conversation.warm.delete`,conversationId:e.id})&&Ds(`连接断开,未移除预热会话`,`error`)},children:`×`})]},e.id))]}):null})()]},e.id)})}),mr&&(0,L.jsxs)(`footer`,{className:`workbench-mobile-utilities`,children:[(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-mobile-workbench-search":!0,"aria-label":`搜索`,title:`搜索`,onClick:()=>so(`content`),children:(0,L.jsx)(on,{name:`search`})}),Rl]})]}),Xa&&(0,L.jsx)(`section`,{className:`workbench-panel workbench-panel-left workbench-search-panel`,"data-workbench-search-panel":!0,"aria-label":`侧栏搜索`,hidden:mr||!Ja||rr.leftClosed,children:(0,L.jsx)(_m,{workspaceId:Sa,workspaceName:bs?.name,cwd:Ta,connected:N,onOpen:(e,t,n)=>Vo(e,t,!1,!0,!1,n),onSession:po},H)}),!mr&&!rr.leftClosed&&!Ja&&$a!==`sessions`&&(0,L.jsx)(MO,{...Vl,side:`left`,activeTab:$a,collapsed:!1,onToggle:du,pinned:!rr.unpinned.includes($a),onArrange:io}),(mr||!rr.leftClosed)&&(0,L.jsx)(_k,{side:`left`,width:sr.sidebar,min:sr.sidebarMin,max:sr.sidebarMax,label:`调整左侧栏宽度`,onWidth:cr}),(0,L.jsx)(`div`,{className:`workbench-main`,children:(0,L.jsxs)(`div`,{className:`workbench-main-panes`,"data-workbench-split":Na,style:{"--split-share":`${Aa}%`},children:[(0,L.jsxs)(`section`,{className:`chat`,"data-main-view":wo,"data-main-view-kind":wo,children:[ou.length>0&&(0,L.jsx)(`div`,{className:`chat-tab-strip`,"data-chat-tab-strip":`1`,"data-session-count":la.length,"data-file-count":B.open.length,children:(0,L.jsx)(xm,{tabs:(ls?ou.filter(e=>e.id!==ls.id):ou).map(e=>M.connections.length>1&&e.workspaceId?{...e,label:`${e.label} · ${me(e.workspaceId)}`,title:`${me(e.workspaceId)} · ${e.title??e.label}`}:e),prefix:`workspace-tab`,ariaLabel:`工作区标签页`,activeId:Yo,onSelect:Qo,onClose:ps,onActivate:ss,minWidth:120,maxWidth:320})}),(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`button`,{type:`button`,className:`mobile-drawer-toggle`,"data-mobile-drawer-toggle":`1`,"aria-label":`打开会话列表`,title:`会话列表`,"aria-expanded":Hn,onClick:()=>Un(!0),children:`☰`}),(0,L.jsxs)(`div`,{className:`chat-head`,children:[(0,L.jsx)(`h1`,{children:et===`group`?St?wt??`群聊`:`新建群聊`:R?.title??`准备开始`}),et!==`group`&&yc.size>0?[...yc].map(([e,t])=>(0,L.jsx)(`p`,{"data-role":`run-status`,"data-status-key":e,children:`扩展状态:${e?`${e} · `:``}${t}`},e)):null]}),(0,L.jsxs)(`div`,{className:`workbench-history-controls`,role:`group`,"aria-label":`主区导航`,"data-workbench-history":is>=0||Y>=0?`available`:`empty`,children:[(0,L.jsx)(`button`,{type:`button`,"data-workbench-history-back":!0,"aria-label":`后退`,className:`workbench-icon-button`,title:is<0?`后退`:`后退到 ${ye.entries[is].title}`,disabled:is<0||!!xe,onClick:()=>as(-1),children:(0,L.jsx)(on,{name:`back`})}),(0,L.jsx)(`button`,{type:`button`,"data-workbench-history-forward":!0,"aria-label":`前进`,className:`workbench-icon-button`,title:Y<0?`前进`:`前进到 ${ye.entries[Y].title}`,disabled:Y<0||!!xe,onClick:()=>as(1),children:(0,L.jsx)(on,{name:`forward`})}),Sa&&(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-toggle-workbench-split":!0,"aria-pressed":Na,"aria-label":Na?`合并主区`:`拆分主区`,title:Na?`合并主区`:`拆分主区`,onClick:ds,children:(0,L.jsx)(on,{name:`split`})})]}),Nn.entry(`workbench-status-button software-update-mobile`),(0,L.jsxs)(`span`,{className:`chat-view chat-view-${wo}`,"data-main-view-indicator":wo,"data-main-view-kind":wo,title:et===`file`?`中间主画面正在显示文件 ${B.active?.path??``}`:wo===`diff`?`中间主画面正在显示 ${To??``} 的改动`:`中间主画面正在显示这个会话的消息流`,children:[(0,L.jsx)(`span`,{className:`chat-view-kind`,children:et===`group`?`群聊`:et===`file`?`文件`:wo===`diff`?`改动`:`会话`}),et===`file`&&B.active&&(0,L.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":B.active.name,children:B.active.name}),wo===`diff`&&To&&(0,L.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":To,children:To})]}),!ba&&(0,L.jsx)(`div`,{className:`badge`,"data-workbench-header-status":bi||R?.status===`failed`?`attention`:`routine`,"data-conversation-status":R?.status??`idle`,...bi?{"data-reporting-status":bi}:{},children:bi===`awaiting_decision`?`等上面拍板`:pO(R)?fO[R?.status??`idle`]:bi===`awaiting_subordinates`?`等待下级`:bi===`pending_report`?`待汇报`:fO[R?.status??`idle`]}),(0,L.jsx)(`button`,{type:`button`,className:`mobile-tools-toggle`,"data-mobile-nav":`rail`,onClick:()=>{Rn(`rail`),In(!1)},children:`工具`})]}),ee&&(0,L.jsxs)(`div`,{className:`error`,role:`alert`,"data-global-error":!0,children:[(0,L.jsx)(`span`,{title:Ut(ee),children:Ht(ee)}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`关闭错误提示`,title:`关闭错误提示`,onClick:()=>te(void 0),children:`×`})]}),!ba&&R?.error&&(0,L.jsx)(`div`,{className:`error`,"data-role":`conversation-error`,title:Ut(R.error),children:Ht(R.error)}),R?.warning&&(0,L.jsxs)(`div`,{className:`warning`,role:`status`,"data-role":`conversation-warning`,title:Ut(R.warning),children:[(0,L.jsx)(`span`,{children:R.warning}),(0,L.jsx)(`button`,{type:`button`,"data-role":`conversation-warning-continue`,title:`让模型接着把被截断的部分写完`,onClick:()=>Vs(R?.id??``),children:`继续写完`})]}),!ba&&R?.modelNotice&&(0,L.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-model-notice`,children:R.modelNotice}),R?.agentNotice&&(0,L.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-agent-notice`,children:R.agentNotice}),xc&&(0,L.jsxs)(`div`,{className:`extui-title-note`,children:[`扩展建议标题:`,xc]}),fn.length>0&&(0,L.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,"data-toast-count":fn.length,children:fn.map(e=>(0,L.jsx)(`div`,{className:`toast toast-${e.kind}`,"data-toast-kind":e.kind,children:e.text},e.key))}),et===`group`?bs?(0,L.jsx)(ET,{workspaceId:bt,roomId:St,sourceLink:Os(bt),composerResize:dr===null?void 0:(0,L.jsx)(wk,{height:dr,onHeight:pr}),onEnableNotifications:()=>As(!0),agents:Cn?.agents??[],catalog:tc(mn,bs),userLabel:an,archivedAt:Ct?.archivedAt,restoring:mt.has(St),onRestore:e=>void ya(e,`restore`),onRoomSeen:at,onRoomRead:Ai,onRoomMissing:va,onCreated:_a,onCancelCreate:()=>Ve&&ps(dt(Ve))},Ve&&dt(Ve)):(0,L.jsx)(`div`,{className:`group-empty`,children:Te?`这个群聊的工作区已不可用。`:`正在加载工作区…`}):et===`file`?Ss(ms,!0):Co?Cs(Co):et===`diff`?ws(q,!1):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`messages`,ref:Tt,"data-message-scroll-container":R?.id??``,onWheel:e=>{e.deltaY<0&&Ie.current[R?.id??``]?.followTail&&(Mt.current=!0,ji(e.currentTarget,!0))},onScroll:e=>{let t=e.currentTarget;t.dataset.programmaticScroll===`true`?delete t.dataset.programmaticScroll:ji(t)},children:[(!R||!da)&&(0,L.jsxs)(`div`,{className:`empty`,"data-workspace-welcome":Ci?.id,children:[(0,L.jsx)(`div`,{className:`orb`,children:`π`}),(0,L.jsx)(`h2`,{children:Ci?.name??`开始一个新会话`}),T.workspaces.length===0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`先创建一个工作区,再开始会话。`}),(0,L.jsx)(`button`,{onClick:()=>Ae(!0),children:`+ 新建工作区`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:Ci?`暂无活跃会话。你可以创建会话,也可以直接使用资源管理器、Git 和终端。`:T.workspaces.length===1&&Si?`在「${Si.name}」中创建会话,即可向 Super Pi 发送任务。`:`选择工作区即可开始会话,向 Super Pi 发送任务。`}),Ci&&(0,L.jsx)(`p`,{className:`workspace-welcome-path`,title:Ci.path,children:Ci.path}),T.workspaces.length>1&&(0,L.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,L.jsx)(`label`,{htmlFor:`empty-workspace-choice`,children:`工作区:`}),(0,L.jsxs)(`select`,{id:`empty-workspace-choice`,"aria-label":`选择工作区`,value:Si?.id,onChange:e=>{e.target.value===`__new__`?Ae(!0):ha(e.target.value)},children:[(0,L.jsx)(He,{workspaces:T.workspaces}),(0,L.jsx)(`option`,{value:`__new__`,children:`+ 新建工作区…`})]})]}),Si&&(0,L.jsxs)(L.Fragment,{children:[!wi&&(0,L.jsx)(ED,{workspaceId:Si.id,value:Ti,onChange:Oi}),(0,L.jsx)(`button`,{"data-workspace-welcome-create":Ci?`1`:void 0,disabled:wi||!N,onClick:()=>ul(Si.id,Ti),children:wi?`正在创建工作区…`:`新建会话`})]}),(0,L.jsx)(`span`,{className:`empty-secondary-action`,role:`button`,tabIndex:0,onClick:()=>Ae(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ae(!0))},children:`+ 新建工作区`})]})]}),R?.messagesLoaded===!1&&(0,L.jsx)(`p`,{role:`status`,"data-conversation-loading":`1`,children:`正在加载会话…`}),kc.map(e=>{if(e.startsWith(`m:`)){let t=Ec.get(e.slice(2));if(!t)return null;let n=t.id===Ac,r=t.role===`user`&&R?.status!==`running`&&R?.status!==`waiting`&&El!==t.id,i=r&&n&&!t.id.startsWith(`pending:`),a=r&&!n&&!!t.piEntryId,o=t.content?(0,L.jsx)(Md,{source:t.content,media:li,sourceLink:ks}):(0,L.jsx)(`span`,{className:`typing`,children:`正在思考`});if(t.source===`session-reminder`)return(0,L.jsx)(`article`,{className:`message message-reminder`,"data-transcript-key":e,"data-message-reminder":t.id,children:(0,L.jsxs)(`details`,{children:[(0,L.jsxs)(`summary`,{className:`reminder-header`,children:[(0,L.jsxs)(`span`,{className:`reminder-label`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,L.jsx)(`time`,{dateTime:t.createdAt,children:aD(t.createdAt)})]}),(0,L.jsx)(`div`,{className:`content`,children:o})]})},e);let s=t.toolCalls??[],c=kl?.id===t.id?kl.kind:void 0;if(t.role===`user`){let n=t.content||(t.images?.length?`[图片]`:``),r=UD(t.content,t.attachments);return(0,L.jsxs)(`article`,{className:`message user`,"data-transcript-key":e,children:[(0,L.jsxs)(`div`,{className:`message-body`,children:[(0,L.jsxs)(`div`,{className:`bubble`,children:[(0,L.jsxs)(`div`,{className:`meta`,children:[an,(0,L.jsx)(`time`,{children:aD(t.createdAt)})]}),t.images&&t.images.length>0&&(0,L.jsx)(`div`,{className:`message-images`,"data-message-images":`1`,children:t.images.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`message-image-btn`,"data-message-image-id":e.id,onClick:()=>Wr({url:Oe(`/api/upload/${encodeURIComponent(R?.id??``)}/${encodeURIComponent(e.id)}`),name:e.name,bytes:e.bytes}),title:e.name?`查看大图:${e.name}`:`查看大图`,children:(0,L.jsx)(`img`,{src:Oe(`/api/upload/${encodeURIComponent(R?.id??``)}/${encodeURIComponent(e.id)}`),alt:e.name||`图片`,className:`message-image-thumb`,loading:`lazy`})},e.id))}),(0,L.jsx)(`div`,{className:`content`,children:o})]}),r.length>0&&(0,L.jsx)(`div`,{className:`message-attachments`,"data-message-attachments":`1`,children:r.map(e=>{let n=`att:${t.id}:${e.kind}:${e.id}`,r=_r[n]??!1;return(0,L.jsxs)(`div`,{className:`message-attachment`,"data-message-attachment":e.kind,children:[(0,L.jsxs)(`button`,{type:`button`,className:`message-attachment-head`,"data-message-attachment-toggle":e.id,"aria-expanded":r,onClick:()=>vr(e=>({...e,[n]:!r})),children:[(0,L.jsx)(`span`,{className:`message-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,L.jsx)(`span`,{className:`message-attachment-label`,children:`技能`}),(0,L.jsx)(`span`,{className:`message-attachment-name`,title:e.name,children:e.name}),(0,L.jsx)(`span`,{className:`message-attachment-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`})]}),r&&(0,L.jsx)(`pre`,{className:`message-attachment-body`,"data-message-attachment-body":e.id,children:e.content})]},n)})}),(0,L.jsxs)(`div`,{className:`message-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":c,"aria-label":`复制这条消息:${n}`,onClick:()=>Nl(t.id,n),children:c===`copied`?`已复制`:c===`error`?`复制失败`:`复制`}),i&&(0,L.jsx)(`button`,{type:`button`,className:`message-revert`,"data-withdraw-message":t.id,title:`撤回并编辑:删除这条消息并将文字恢复到输入框继续编辑`,onClick:()=>Ol(t.id,!0),children:`撤回`}),a&&(0,L.jsx)(`button`,{type:`button`,className:`message-revert`,"data-revert-message":t.id,title:`回退到这里:删除后续全部内容(Pi 的记录和这里的历史一起清掉,不会新建会话,也不动任何代码文件)`,onClick:()=>Ol(t.id),children:`回退`})]})]}),(0,L.jsx)(`div`,{className:`avatar`,title:an,children:an})]},e)}if(t.role===`tool`){let n=/<task id="[^"]+" state="[^"]+"/.test(t.content),r=(()=>{let e=/<summary>([\s\S]*?)<\/summary>/.exec(t.content);return e?e[1].trim():n?`后台回传`:(t.content.split(`
|
|
346
346
|
`).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`})(),i=(()=>{let e=/<task id="[^"]+" state="([^"]+)"/.exec(t.content);return e?e[1]:`completed`})(),a=(()=>{let e=/<task_(?:result|error)>\n?([\s\S]*?)\n?<\/(?:task_result|task_error)>/.exec(t.content);return e?e[1]:t.content})(),o=t.backgroundTask,s=o?.output===void 0?a:[o.reason,o.outputTruncated?`日志仅保留最近一段。`:``,o.output||`任务未产生输出。`].filter(Boolean).join(`
|
|
347
347
|
|
|
348
348
|
`),c=(()=>{let e=/<result_file>([\s\S]*?)<\/result_file>/.exec(t.content);return e&&e[1].trim()?e[1].trim():void 0})(),l=(()=>{let e=/<task id="([^"]+)"/.exec(t.content);return e?e[1]:void 0})(),u=!!(l&&oi.some(e=>e.id===l)),d=`tool:${t.id}`,f=_r[d]??!1,p=n?`后台回传`:`智能体下发`;return(0,L.jsx)(`article`,{className:`message tool${n?``:` tool-order`}`,"data-transcript-key":e,"data-tool-state":i,"data-tool-kind":n?`delivery`:`order`,children:(0,L.jsxs)(`div`,{className:`message-body`,children:[(0,L.jsxs)(`div`,{className:`bg-result-head`,"data-bg-result-head":t.id,children:[(0,L.jsxs)(`button`,{type:`button`,className:`bg-result-toggle`,"data-bg-result-toggle":t.id,"aria-expanded":f,title:f?`折叠${p}`:`展开${p}`,onClick:()=>vr(e=>({...e,[d]:!f})),children:[(0,L.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:i===`error`?`✕`:n?`↩`:`↓`}),(0,L.jsx)(`span`,{className:`bg-result-label`,children:o&&(o.status===`cancelled`||o.status===`interrupted`)?mO[o.status]:p}),(0,L.jsx)(`span`,{className:`bg-result-summary`,title:r,children:r}),!f&&(0,L.jsx)(`span`,{className:`bg-result-preview`,"data-bg-result-preview":t.id,title:`展开查看任务输出`,children:o?.reason||ID(s)}),(0,L.jsx)(`span`,{className:`bg-result-chevron`,"aria-hidden":`true`,children:f?`▾`:`▸`})]}),(c||u&&l)&&(0,L.jsxs)(`div`,{className:`bg-result-actions`,"data-bg-result-actions":t.id,children:[c&&(0,L.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-file-link":c,title:`在主区域打开产物文件:${c}`,onClick:e=>{e.stopPropagation();let t=c.split(/[/\\]/).pop()||c;Vo({path:c,name:t,text:!0}).catch(e=>{console.warn(`打开产物文件失败:`,e)})},children:[(0,L.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`📄`}),(0,L.jsx)(`span`,{children:`查看产物文件`})]}),u&&l&&(0,L.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-session-link":l,title:`跳转到子会话:${l}`,onClick:e=>{e.stopPropagation(),pa(l)},children:[(0,L.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`↗`}),(0,L.jsx)(`span`,{children:`跳转到子会话`})]})]})]}),f&&(0,L.jsx)(`div`,{className:`bg-result-body`,"data-bg-result-body":t.id,children:(0,L.jsx)(`pre`,{className:`bg-result-pre`,"data-bg-result-pre":t.id,children:s})})]})},e)}let l=t.thinking?.trim()?t.thinking:``,u=t.thinkingBlocks?.length?t.thinkingBlocks:l?[{at:0,text:l}]:[],d=(e,n)=>{let r=typeof e.at==`number`&&Number.isFinite(e.at)?e.at:n;return Math.max(0,Math.min(r,t.content.length))},p=e=>e.thinkingBlock===void 0?typeof e.thinkingAt!=`number`||!(e.thinkingAt<l.length||t.thinkingActive)?-1:u.findIndex((t,n)=>(e.at??0)>=t.at&&(u[n+1]===void 0||(e.at??0)<u[n+1].at)):e.thinkingBlock??-1,m=e=>s.map((e,t)=>({call:e,index:t})).filter(({call:t})=>p(t)===e),h=[],g=[...u.map((e,t)=>({at:e.at,order:u.slice(0,t).reduce((e,t)=>e+t.text.length,0)*2+1,segment:{blockIndex:t}})),...s.map((e,t)=>({at:d(e,t),order:(e.thinkingAt??0)*2,segment:{call:e,index:t}})).filter(({segment:e})=>`call`in e&&p(e.call)<0)].sort((e,t)=>e.at-t.at||e.order-t.order),_=0;for(let e of g){let n=Math.max(_,Math.min(e.at,t.content.length));n>_&&h.push({text:t.content.slice(_,n)}),h.push(e.segment),_=n}_<t.content.length&&h.push({text:t.content.slice(_)});let v=e=>{let t=Oc.get(e);if(t)return(0,L.jsx)(`div`,{className:`call-anchored-run`,"data-call-anchored-run":t.id,"data-call-anchored-site":e,children:(0,L.jsx)(HD,{run:t,name:Tc.get(t.agentId)??``,expanded:!!hr[t.id],onToggle:()=>jc(t.id),onStop:()=>Lc(t.id),stopping:f.some(e=>e.key===`stop:${t.id}`)})})},y=e=>e.call.question?(()=>{let n=XD(R?.id??``,t.id,e.index),r=xr[n]??ZD(e.call.question);return(0,L.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,L.jsx)(QD,{question:e.call.question,index:e.index,draft:r,onDraftChange:e=>qs(n,e),expanded:`${t.id}:${e.index}`in yr?!!yr[`${t.id}:${e.index}`]:!0,onToggle:()=>Nc(t.id,e.index),onAnswer:(n,r)=>Ks(R?.id??``,t.id,e.index,n,r)})},`c${e.index}`)})():(0,L.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,L.jsx)(zD,{call:e.call,index:e.index,expanded:`${t.id}:${e.index}`in _r&&!!_r[`${t.id}:${e.index}`],onToggle:()=>Mc(t.id,e.index),backgroundOutput:e.call.backgroundTask&&(0,L.jsx)(RD,{task:e.call.backgroundTask,execOutputs:Nt.current,expanded:`${t.id}:${e.index}`in _r&&!!_r[`${t.id}:${e.index}`]}),runCard:v(`${t.id}:${e.index}`)})},`c${e.index}`),b=e=>{let n=u[e],r=u.slice(0,e).reduce((e,t)=>e+t.text.length,0),i=0,a=[];for(let{call:t,index:o}of m(e).sort((e,t)=>(e.call.thinkingAt??r)-(t.call.thinkingAt??r)||e.index-t.index)){let e=Math.max(i,Math.min(n.text.length,(t.thinkingAt??r)-r));e>i&&a.push((0,L.jsx)(`div`,{className:`content thinking-text`,children:(0,L.jsx)(Md,{source:n.text.slice(i,e),media:li})},`t${o}`)),a.push(y({call:t,index:o})),i=e}i<n.text.length&&a.push((0,L.jsx)(`div`,{className:`content thinking-text`,children:(0,L.jsx)(Md,{source:n.text.slice(i),media:li})},`tail`));let o=m(e).filter(e=>e.call.status===void 0),s=o.find(e=>e.call.question?.status===`pending`);return(0,L.jsx)(VD,{liveCall:s?`question`:o.at(-1)?.call.label,liveAwaitingReader:!!s,liveExtra:o.length>1?o.length-1:void 0,messageId:`${t.id}:${e}`,nestedCount:m(e).length,preview:n.text.split(`
|