@evandu/super-pi 0.1.227 → 0.1.228

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.
Files changed (28) hide show
  1. package/dist/client/.super-pi-client-sources.json +5 -5
  2. package/dist/client/assets/{CodeMirrorEditor-XhzxZkT7.js → CodeMirrorEditor-CxXNu7GH.js} +2 -2
  3. package/dist/client/assets/{dist-BMHkRAwL.js → dist-B0pL2s9O.js} +1 -1
  4. package/dist/client/assets/{dist-CAyeJkNm.js → dist-BKlkCgMf.js} +1 -1
  5. package/dist/client/assets/{dist-DKrX9esY.js → dist-BOEvTs9l.js} +1 -1
  6. package/dist/client/assets/{dist-BIv-XqpX.js → dist-BpSOZduy.js} +1 -1
  7. package/dist/client/assets/{dist-B8wnqcB8.js → dist-BtgsKGbq.js} +1 -1
  8. package/dist/client/assets/{dist-CRftoecI.js → dist-BtlJzzIK.js} +1 -1
  9. package/dist/client/assets/{dist-CJi5dBLp.js → dist-C2XjTF4u.js} +1 -1
  10. package/dist/client/assets/{dist-Dw8HA8Ry.js → dist-COPu8Vm9.js} +1 -1
  11. package/dist/client/assets/{dist-D8cB1d6i.js → dist-CaZy3sqX.js} +1 -1
  12. package/dist/client/assets/{dist-Htne-Kr-.js → dist-CpR-RFPW.js} +1 -1
  13. package/dist/client/assets/{dist-BKi0MAJ5.js → dist-D0ju5zPn.js} +1 -1
  14. package/dist/client/assets/{dist-op2EQonz.js → dist-D127yGCt.js} +1 -1
  15. package/dist/client/assets/{dist-O-xCO-hU.js → dist-D55pWayC.js} +1 -1
  16. package/dist/client/assets/{dist-DFwptgo1.js → dist-DJBS8YA6.js} +1 -1
  17. package/dist/client/assets/{dist-Dsg7Czd_.js → dist-DMSAfmmB.js} +1 -1
  18. package/dist/client/assets/{dist-TXlunA37.js → dist-DRnA8Kcg.js} +1 -1
  19. package/dist/client/assets/{dist-C0V02hc8.js → dist-DZe_6qck.js} +1 -1
  20. package/dist/client/assets/{dist-B6SJNYWR.js → dist-DgSnOG8y.js} +1 -1
  21. package/dist/client/assets/{dist-CgbC-Rvt.js → dist-DmnIdTvT.js} +1 -1
  22. package/dist/client/assets/{dist-BnnkCy4V.js → dist-Do27T1qW.js} +1 -1
  23. package/dist/client/assets/{dist-YYc286O7.js → dist-DsybCJLu.js} +1 -1
  24. package/dist/client/assets/{dist-CJWED9g3.js → dist-Dz3IKScu.js} +1 -1
  25. package/dist/client/assets/{index-BE91t5ax.js → index--Y4BWQa7.js} +5 -5
  26. package/dist/client/assets/{index-Cnz4ZLQJ.css → index-DIinpKE8.css} +1 -1
  27. package/dist/client/index.html +2 -2
  28. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Dw8HA8Ry.js","assets/dist-Dsg7Czd_.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-COPu8Vm9.js","assets/dist-DMSAfmmB.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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 u=o((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 ee=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function M(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 N(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,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),N(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(ee,`$&/`)+`/`)+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+j(a,u),c+=N(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+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(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 te(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(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 re=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 ie(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,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ae(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 ie(ae.bind(null,e))}var oe={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(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=oe,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=ae,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:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ie,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`})),d=o(((e,t)=>{t.exports=u()})),f=o((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&&ee(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&&ee(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 ee(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,ee(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}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();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 r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(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=i,e.browser=function(e){return{$$typeof:o,_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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.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,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,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=u(t.as,t.crossOrigin);i.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??i.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=u(n,t.crossOrigin);i.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=u(t.as,t.crossOrigin);i.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 i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),h=o(((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=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(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)&&m(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(i(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`),ee=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ee:return`Fragment`;case M:return`Profiler`;case j:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case te:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,_e=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ye={pending:!1,data:null,method:null,action:null},be=[],xe=-1;function Se(e){return{current:e}}function Ce(e){0>xe||(e.current=be[xe],be[xe]=null,xe--)}function we(e,t){xe++,be[xe]=e.current,e.current=t}var Te=Se(null),Ee=Se(null),De=Se(null),Oe=Se(null);function ke(e,t){switch(we(De,t),we(Ee,e),we(Te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=wp(t),e=Tp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Ce(Te),we(Te,e)}function Ae(){Ce(Te),Ce(Ee),Ce(De)}function je(e){var t=e.memoizedState;t!==null&&(bh._currentValue=t.memoizedState,we(Oe,e)),t=Te.current;var n=Tp(t,e.type);t!==n&&(we(Ee,e),we(Te,n))}function Me(e){Ee.current===e&&(Ce(Te),Ce(Ee)),Oe.current===e&&(Ce(Oe),bh._currentValue=ye)}var Ne,Pe;function Fe(e){if(Ne===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ne=t&&t[1]||``,Pe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ne+e+Pe}var Ie=!1;function Le(e,t){if(!e||Ie)return``;Ie=!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(`
@@ -32,7 +32,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
32
32
  `);this.rawLength=e.length,this.maxLineNumber=e.length,this.rawFile={},this.plainFile={};let t=Qa();for(let n=0;n<e.length;n++)this.rawFile[n+1]=n<e.length-1?e[n]+`
33
33
  `:e[n],this.plainFile[n+1]={value:this.rawFile[n+1],template:t?ao(this.rawFile[n+1]):void 0};this.hasDoRaw=!0}};Oo=new WeakMap,Do=new WeakSet;function Mo(e,t,n,r,i){let a=e+`--0.1.8--`+n+`--`+t;i&&(a=i+`--0.1.8--`+n+`--`+t);let o=e+`--0.1.8--`+(n===`light`?`dark`:`light`)+`--`+t;if(i&&(o=i+`--0.1.8--`+(n===`light`?`dark`:`light`)+`--`+t),ko.has(a))return ko.get(a);if(ko.has(o)){let e=ko.get(o);if(e?.highlighterType===`class`)return e}let s=new jo(e,t,r);return ko.set(a,s),s}var No=ko,Po;(function(e){e[e.hunk=1]=`hunk`,e[e.content=2]=`content`,e[e.widget=3]=`widget`,e[e.extend=4]=`extend`})(Po||={});var z;(function(e){e[e.old=1]=`old`,e[e.new=2]=`new`})(z||={});var Fo=e=>{let t=e.splitLineLength,n=[];return lo(t,t=>{let r=e.getSplitLeftLine(t),i=e.getSplitRightLine(t);!r?.isHidden&&!i?.isHidden&&n.push({type:Po.content,index:t,lineNumber:t+1,splitLine:{left:r,right:i}})}),n},Io=e=>{let t=e.unifiedLineLength,n=[];return lo(t,t=>{let r=e.getUnifiedLine(t);r?.isHidden||n.push({type:Po.content,index:t,lineNumber:t+1,unifiedLine:r})}),n},Lo=(e,t,n)=>{let r=e.getSplitLineByLineNumber(t,n),i=e.getUnifiedLineByLineNumber(t,n);return{split:!r||r.isHidden,unified:!i||i.isHidden}},Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs=40,Us=new Set,Ws=(e,t)=>{let n=new Map;for(let r=0;r<e.length;r++){let i=t(e[r]);i!==void 0&&!n.has(i)&&n.set(i,r)}return n},Gs=class e{static createInstance(t,n){let r=new e(t?.oldFile?.fileName||``,t?.oldFile?.content||``,t?.newFile?.fileName||``,t?.newFile?.content||``,t?.hunks||[],t?.oldFile?.fileLang||``,t?.newFile?.fileLang||``);return n&&(n.isFullMerge?r._mergeFullBundle(n):r.mergeBundle(n)),r}constructor(t,n,r,i,a,o,s,c){Ro.add(this),this.uuid=c,zo.set(this,void 0),Bo.set(this,void 0),Vo.set(this,void 0),Ho.set(this,void 0),Uo.set(this,void 0),Wo.set(this,void 0),Go.set(this,void 0),Ko.set(this,void 0),qo.set(this,void 0),Jo.set(this,void 0),Yo.set(this,void 0),Xo.set(this,void 0),Zo.set(this,void 0),Qo.set(this,void 0),$o.set(this,[]),es.set(this,[]),ts.set(this,void 0),ns.set(this,void 0),rs.set(this,void 0),is.set(this,[]),as.set(this,void 0),os.set(this,new Set),ss.set(this,!1),cs.set(this,!1),ls.set(this,!1),us.set(this,!1),ds.set(this,0),fs.set(this,0),ps.set(this,!1),ms.set(this,!1),hs.set(this,!1),gs.set(this,!1),_s.set(this,void 0),vs.set(this,void 0),ys.set(this,!1),bs.set(this,`light`),xs.set(this,{state:!1}),Ss.set(this,{state:!1}),this._version_=`0.1.8`,this._oldFileName=``,this._oldFileContent=``,this._oldFileLang=``,this._newFileName=``,this._newFileContent=``,this._newFileLang=``,this._diffList=[],this.diffLineLength=0,this.splitLineLength=0,this.unifiedLineLength=0,this.fileLineLength=0,this.additionLength=0,this.deletionLength=0,this.hasSomeLineCollapsed=!1,Cs.set(this,``),ws.set(this,new Map),this.getSplitLeftLine=e=>L(this,$o,`f`)[e],this.getSplitLineByLineNumber=(e,t)=>{let n=L(this,Ro,`m`,Bs).call(this,t).get(e);if(n!==void 0)return(t===z.old?L(this,$o,`f`):L(this,es,`f`))[n]},this.getSplitLineIndexByLineNumber=(e,t)=>L(this,Ro,`m`,Bs).call(this,t).get(e)??-1,this.getSplitRightLine=e=>L(this,es,`f`)[e],this.getSplitHunkLine=e=>L(this,rs,`f`)?.[e],this.onSplitHunkExpand=(e,t,n=!0)=>{var r,i;if(!this.getExpandEnabled())return;let a=L(this,rs,`f`)?.[t];if(a&&a.splitInfo){if(e===`all`){for(let e=a.splitInfo.startHiddenIndex;e<a.splitInfo.endHiddenIndex;e++){let t=L(this,$o,`f`)[e],n=L(this,es,`f`)[e];t?.isHidden&&(t.isHidden=!1),n?.isHidden&&(n.isHidden=!1)}a.splitInfo={...a.splitInfo,...a.hunkInfo,plainText:a.text,startHiddenIndex:a.splitInfo.endHiddenIndex}}else if(e===`down`){for(let e=a.splitInfo.startHiddenIndex;e<a.splitInfo.startHiddenIndex+Hs;e++){let t=L(this,$o,`f`)[e],n=L(this,es,`f`)[e];t?.isHidden&&(t.isHidden=!1),n?.isHidden&&(n.isHidden=!1)}a.splitInfo=a.isLast?{...a.splitInfo,startHiddenIndex:a.splitInfo.startHiddenIndex+Hs}:{...a.splitInfo,startHiddenIndex:a.splitInfo.startHiddenIndex+Hs,plainText:`@@ -${a.splitInfo.oldStartIndex},${a.splitInfo.oldLength} +${a.splitInfo.newStartIndex},${a.splitInfo.newLength}`}}else if(e===`down-all`){for(let e=a.splitInfo.startHiddenIndex;e<a.splitInfo.endHiddenIndex;e++){let t=L(this,$o,`f`)[e],n=L(this,es,`f`)[e];t?.isHidden&&(t.isHidden=!1),n?.isHidden&&(n.isHidden=!1)}a.splitInfo={...a.splitInfo,plainText:``,startHiddenIndex:a.splitInfo.endHiddenIndex}}else if(e===`up`){if(a.isLast)return;for(let e=a.splitInfo.endHiddenIndex-Hs;e<a.splitInfo.endHiddenIndex;e++){let t=L(this,$o,`f`)[e],n=L(this,es,`f`)[e];t?.isHidden&&(t.isHidden=!1),n?.isHidden&&(n.isHidden=!1)}let e=a.splitInfo.oldStartIndex-Hs,n=a.splitInfo.oldLength+Hs,i=a.splitInfo.newStartIndex-Hs,o=a.splitInfo.newLength+Hs;a.splitInfo={...a.splitInfo,endHiddenIndex:a.splitInfo.endHiddenIndex-Hs,oldStartIndex:e,oldLength:n,newStartIndex:i,newLength:o,plainText:`@@ -${e},${n} +${i},${o}`},(r=L(this,rs,`f`))==null||delete r[t],L(this,rs,`f`)[a.splitInfo.endHiddenIndex]=a}else if(e===`up-all`){if(a.isLast)return;for(let e=a.splitInfo.startHiddenIndex;e<a.splitInfo.endHiddenIndex;e++){let t=L(this,$o,`f`)[e],n=L(this,es,`f`)[e];t?.isHidden&&(t.isHidden=!1),n?.isHidden&&(n.isHidden=!1)}a.splitInfo={...a.splitInfo,plainText:``,endHiddenIndex:a.splitInfo.startHiddenIndex},(i=L(this,rs,`f`))==null||delete i[t],L(this,rs,`f`)[a.splitInfo.endHiddenIndex]=a}n&&this.notifyAll()}},this.getUnifiedLine=e=>L(this,is,`f`)[e],this.getUnifiedLineByLineNumber=(e,t)=>{let n=L(this,Ro,`m`,Vs).call(this,t).get(e);if(n!==void 0)return L(this,is,`f`)[n]},this.getUnifiedLineIndexByLineNumber=(e,t)=>L(this,Ro,`m`,Vs).call(this,t).get(e)??-1,this.getUnifiedHunkLine=e=>L(this,as,`f`)?.[e],this.onUnifiedHunkExpand=(e,t,n=!0)=>{var r,i;if(!this.getExpandEnabled())return;let a=L(this,as,`f`)?.[t];if(a&&a.unifiedInfo){if(e===`all`){for(let e=a.unifiedInfo.startHiddenIndex;e<a.unifiedInfo.endHiddenIndex;e++){let t=L(this,is,`f`)?.[e];t?.isHidden&&(t.isHidden=!1)}a.unifiedInfo={...a.unifiedInfo,...a.hunkInfo,plainText:a.text,startHiddenIndex:a.unifiedInfo.endHiddenIndex}}else if(e===`down`){for(let e=a.unifiedInfo.startHiddenIndex;e<a.unifiedInfo.startHiddenIndex+Hs;e++){let t=L(this,is,`f`)[e];t?.isHidden&&(t.isHidden=!1)}a.unifiedInfo=a.isLast?{...a.unifiedInfo,startHiddenIndex:a.unifiedInfo.startHiddenIndex+Hs}:{...a.unifiedInfo,startHiddenIndex:a.unifiedInfo.startHiddenIndex+Hs,plainText:`@@ -${a.unifiedInfo.oldStartIndex},${a.unifiedInfo.oldLength} +${a.unifiedInfo.newStartIndex},${a.unifiedInfo.newLength}`}}else if(e===`down-all`){for(let e=a.unifiedInfo.startHiddenIndex;e<a.unifiedInfo.endHiddenIndex;e++){let t=L(this,is,`f`)[e];t?.isHidden&&(t.isHidden=!1)}a.unifiedInfo={...a.unifiedInfo,plainText:``,startHiddenIndex:a.unifiedInfo.endHiddenIndex}}else if(e===`up`){if(a.isLast)return;for(let e=a.unifiedInfo.endHiddenIndex-Hs;e<a.unifiedInfo.endHiddenIndex;e++){let t=L(this,is,`f`)[e];t?.isHidden&&(t.isHidden=!1)}let e=a.unifiedInfo.oldStartIndex-Hs,n=a.unifiedInfo.oldLength+Hs,i=a.unifiedInfo.newStartIndex-Hs,o=a.unifiedInfo.newLength+Hs;a.unifiedInfo={...a.unifiedInfo,endHiddenIndex:a.unifiedInfo.endHiddenIndex-Hs,oldStartIndex:e,oldLength:n,newStartIndex:i,newLength:o,plainText:`@@ -${e},${n} +${i},${o}`},(r=L(this,as,`f`))==null||delete r[t],L(this,as,`f`)[a.unifiedInfo.endHiddenIndex]=a}else if(e===`up-all`){if(a.isLast)return;for(let e=a.unifiedInfo.startHiddenIndex;e<a.unifiedInfo.endHiddenIndex;e++){let t=L(this,is,`f`)[e];t?.isHidden&&(t.isHidden=!1)}a.unifiedInfo={...a.unifiedInfo,plainText:``,endHiddenIndex:a.unifiedInfo.startHiddenIndex},(i=L(this,as,`f`))==null||delete i[t],L(this,as,`f`)[a.unifiedInfo.endHiddenIndex]=a}n&&this.notifyAll()}},this.onAllExpand=e=>{this.getExpandEnabled()&&(e===`split`?(Object.keys(L(this,rs,`f`)||{}).forEach(e=>{this.onSplitHunkExpand(`all`,+e,!1)}),L(this,xs,`f`).state=!0):(Object.keys(L(this,as,`f`)||{}).forEach(e=>{this.onUnifiedHunkExpand(`all`,+e,!1)}),L(this,Ss,`f`).state=!0),this.notifyAll())},this.onAllCollapse=e=>{this.getExpandEnabled()&&(e===`split`?(Object.values(L(this,$o,`f`)||{}).forEach(e=>{!e.isHidden&&e._isHidden&&(e.isHidden=e._isHidden)}),Object.values(L(this,es,`f`)||{}).forEach(e=>{!e.isHidden&&e._isHidden&&(e.isHidden=e._isHidden)}),Object.values(L(this,rs,`f`)||{}).forEach(e=>{e.splitInfo&&={...e.splitInfo,oldStartIndex:e.splitInfo._oldStartIndex,oldLength:e.splitInfo._oldLength,newStartIndex:e.splitInfo._newStartIndex,newLength:e.splitInfo._newLength,startHiddenIndex:e.splitInfo._startHiddenIndex,endHiddenIndex:e.splitInfo._endHiddenIndex,plainText:e.splitInfo._plainText}}),Object.keys(L(this,rs,`f`)||{}).forEach(e=>{let t=L(this,rs,`f`)[e];t.splitInfo&&t.splitInfo.endHiddenIndex!==+e&&(delete L(this,rs,`f`)[e],L(this,rs,`f`)[t.splitInfo.endHiddenIndex]=t)}),L(this,xs,`f`).state=!1):(Object.values(L(this,is,`f`)||{}).forEach(e=>{!e.isHidden&&e._isHidden&&(e.isHidden=e._isHidden)}),Object.values(L(this,as,`f`)||{}).forEach(e=>{e.unifiedInfo&&={...e.unifiedInfo,oldStartIndex:e.unifiedInfo._oldStartIndex,oldLength:e.unifiedInfo._oldLength,newStartIndex:e.unifiedInfo._newStartIndex,newLength:e.unifiedInfo._newLength,startHiddenIndex:e.unifiedInfo._startHiddenIndex,endHiddenIndex:e.unifiedInfo._endHiddenIndex,plainText:e.unifiedInfo._plainText}}),Object.keys(L(this,as,`f`)||{}).forEach(e=>{let t=L(this,as,`f`)[e];t.unifiedInfo&&t.unifiedInfo.endHiddenIndex!==+e&&(delete L(this,as,`f`)[e],L(this,as,`f`)[t.unifiedInfo.endHiddenIndex]=t)}),L(this,Ss,`f`).state=!1),this.notifyAll())},this.getOldFileContent=()=>L(this,zo,`f`)?.raw,this.getNewFileContent=()=>L(this,Bo,`f`)?.raw,this.getOldPlainLine=e=>L(this,qo,`f`)?.[e],this.getOldSyntaxLine=e=>L(this,Yo,`f`)?.[e],this.getNewPlainLine=e=>L(this,Jo,`f`)?.[e],this.getNewSyntaxLine=e=>L(this,Xo,`f`)?.[e],this.subscribe=e=>(L(this,os,`f`).add(e),()=>{L(this,os,`f`).delete(e)}),this.notifyAll=e=>{var t;R(this,ds,(t=L(this,ds,`f`),t++,t),`f`),L(this,os,`f`).forEach(t=>{e&&t.isSyncExternal||t()}),L(this,ws,`f`).forEach((e,t)=>{t.notifyAll(!0)})},this.getUpdateCount=()=>L(this,ds,`f`),this.getContentVersion=()=>L(this,fs,`f`),this.getExpandEnabled=()=>!L(this,ps,`f`)&&!L(this,ms,`f`),this.getBundle=()=>{let e=L(this,ss,`f`),t=L(this,cs,`f`),n=L(this,ls,`f`),r=L(this,us,`f`),i=L(this,Go,`f`),a=L(this,Uo,`f`),o=L(this,qo,`f`),s=L(this,Yo,`f`),c=L(this,Zo,`f`),l=L(this,Ko,`f`),u=L(this,Wo,`f`),d=L(this,Jo,`f`),f=L(this,Xo,`f`),p=L(this,Qo,`f`),m=this.splitLineLength,h=this.unifiedLineLength,g=this.fileLineLength,_=this.additionLength,v=this.deletionLength,y=L(this,ps,`f`),b=L(this,ms,`f`),x=L(this,_s,`f`),S=L(this,vs,`f`),C=this.hasSomeLineCollapsed,w=L(this,xs,`f`),T=L(this,Ss,`f`);return{hasInitRaw:e,hasInitSyntax:t,hasBuildSplit:n,hasBuildUnified:r,oldFileLines:i,oldFileDiffLines:a,oldFilePlainLines:o,oldFileSyntaxLines:s,oldFilePlaceholderLines:c,newFileLines:l,newFileDiffLines:u,newFilePlainLines:d,newFileSyntaxLines:f,newFilePlaceholderLines:p,splitLineLength:m,unifiedLineLength:h,fileLineLength:g,additionLength:_,deletionLength:v,splitLeftLines:L(this,$o,`f`),splitRightLines:L(this,es,`f`),splitHunkLines:L(this,rs,`f`),unifiedLines:L(this,is,`f`),unifiedHunkLines:L(this,as,`f`),highlighterName:x,highlighterType:S,composeByDiff:y,composeByRange:b,hasSomeLineCollapsed:C,hasExpandSplitAll:w,hasExpandUnifiedAll:T,version:this._version_,theme:L(this,bs,`f`),isFullMerge:!1}},this.mergeBundle=(e,t=!0)=>{var n;R(this,ss,e.hasInitRaw,`f`),R(this,cs,e.hasInitSyntax,`f`),R(this,ls,e.hasBuildSplit,`f`),R(this,us,e.hasBuildUnified,`f`),R(this,ps,e.composeByDiff,`f`),R(this,ms,e.composeByRange,`f`),R(this,_s,e.highlighterName,`f`),R(this,vs,e.highlighterType,`f`),R(this,Go,e.oldFileLines,`f`),R(this,Uo,e.oldFileDiffLines,`f`),R(this,qo,e.oldFilePlainLines,`f`),R(this,Yo,e.oldFileSyntaxLines,`f`),R(this,Zo,e.oldFilePlaceholderLines,`f`),R(this,Ko,e.newFileLines,`f`),R(this,Wo,e.newFileDiffLines,`f`),R(this,Jo,e.newFilePlainLines,`f`),R(this,Xo,e.newFileSyntaxLines,`f`),R(this,Qo,e.newFilePlaceholderLines,`f`),this.splitLineLength=e.splitLineLength,this.unifiedLineLength=e.unifiedLineLength,this.fileLineLength=e.fileLineLength,this.additionLength=e.additionLength,this.deletionLength=e.deletionLength,this.hasSomeLineCollapsed=e.hasSomeLineCollapsed,R(this,xs,e.hasExpandSplitAll,`f`),R(this,Ss,e.hasExpandUnifiedAll,`f`),R(this,$o,e.splitLeftLines,`f`),R(this,es,e.splitRightLines,`f`),R(this,rs,e.splitHunkLines,`f`),R(this,is,e.unifiedLines,`f`),R(this,as,e.unifiedHunkLines,`f`),L(this,Ro,`m`,zs).call(this),R(this,fs,(n=L(this,fs,`f`),n++,n),`f`),R(this,bs,e.theme,`f`),R(this,hs,!0,`f`),R(this,ys,!0,`f`),t&&this.notifyAll()},this.generateInstanceFromLineNumberRange=(t,n,r=z.new)=>{if(t>=n)return this;let i=this.getSplitLineIndexByLineNumber(t,r),a=this.getSplitLineIndexByLineNumber(n,r),o=this.getUnifiedLineIndexByLineNumber(t,r),s=this.getUnifiedLineIndexByLineNumber(n,r),c=[],l=[],u=[];for(let e=i;e<=a;e++){let t=this.getSplitLeftLine(e),n=this.getSplitRightLine(e);(t?.value||n?.value)&&(c.push({...t,isHidden:!1}),l.push({...n,isHidden:!1}))}for(let e=o;e<=s;e++){let t=this.getUnifiedLine(e);t?.value&&u.push({...t,isHidden:!1})}return e.createInstance({},{...this._getFullBundle(),composeByRange:!0,splitHunkLines:{},splitLeftLines:c,splitRightLines:l,splitLineLength:c.length,unifiedHunkLines:{},unifiedLines:u,unifiedLineLength:u.length})},this._getHighlighterName=()=>L(this,_s,`f`)||``,this._getHighlighterType=()=>L(this,vs,`f`)||``,this._getIsPureDiffRender=()=>L(this,ps,`f`),this._getTheme=()=>L(this,bs,`f`),this._getIsCloned=()=>L(this,ys,`f`),this._addClonedInstance=e=>{let t=()=>{this._notifyOthers(e),this._mergeFullBundle(e._getFullBundle(),!1)};t.isSyncExternal=!0;let n=e.subscribe(t);L(this,ws,`f`).set(e,n)},this._notifyOthers=e=>{L(this,ws,`f`).forEach((t,n)=>{n!==e&&n.notifyAll(!0)})},this._delClonedInstance=e=>{L(this,ws,`f`).get(e)?.(),L(this,ws,`f`).delete(e)},this._getFullBundle=()=>{let e=this.getBundle(),t=L(this,zo,`f`),n=L(this,Bo,`f`),r=L(this,Ho,`f`),i=L(this,Vo,`f`);return{...e,oldFileResult:t,newFileResult:n,diffLines:r,diffListResults:i,isFullMerge:!L(this,hs,`f`)||L(this,gs,`f`)}},this._mergeFullBundle=(e,t=!0)=>{this.mergeBundle(e,t);try{R(this,zo,e.oldFileResult?jo.createInstance(e.oldFileResult):null,`f`),R(this,Bo,e.newFileResult?jo.createInstance(e.newFileResult):null,`f`),R(this,Ho,e.diffLines,`f`),R(this,Vo,e.diffListResults,`f`),R(this,gs,e.isFullMerge,`f`)}catch{}},this._getAllListener=()=>L(this,os,`f`),this._destroy=()=>{this.clearId(),L(this,os,`f`).clear(),L(this,ws,`f`).forEach(e=>e()),L(this,ws,`f`).clear()},this.clear=()=>{this._destroy(),R(this,zo,void 0,`f`),R(this,Bo,void 0,`f`),R(this,Ho,void 0,`f`),R(this,Vo,void 0,`f`),R(this,Wo,void 0,`f`),R(this,Uo,void 0,`f`),R(this,Ko,void 0,`f`),R(this,Go,void 0,`f`),R(this,Xo,void 0,`f`),R(this,Yo,void 0,`f`),R(this,rs,void 0,`f`),R(this,$o,[],`f`),R(this,es,[],`f`),R(this,as,void 0,`f`),R(this,is,[],`f`),L(this,Ro,`m`,zs).call(this),R(this,bs,`light`,`f`)},Object.defineProperty(this,"__v_skip",{value:!0});let l=Array.from(new Set(a));this._oldFileName=t,this._newFileName=r,this._diffList=l,this._oldFileLang=uo(o||t||s||r)||`txt`,this._newFileLang=uo(s||r||o||t)||`txt`,this._oldFileContent=n,this._newFileContent=i,this.initId()}initId(){let e=`-diff--`+Math.random().toString().slice(2);for(;Us.has(e);)e=`-diff--`+Math.random().toString().slice(2);Us.add(e),R(this,Cs,e,`f`)}getId(){return L(this,Cs,`f`)}clearId(){Us.delete(L(this,Cs,`f`))}initTheme(e){R(this,bs,e||L(this,bs,`f`)||`light`,`f`)}initRaw(){L(this,ss,`f`)||(L(this,Ro,`m`,Es).call(this),L(this,Ro,`m`,Ds).call(this),L(this,Ro,`m`,Ts).call(this),L(this,Ro,`m`,ks).call(this),L(this,Ro,`m`,Os).call(this),L(this,Ro,`m`,As).call(this),R(this,ss,!0,`f`))}initSyntax({registerHighlighter:e}={}){L(this,cs,`f`)&&(!e||e.name===L(this,_s,`f`)&&e.type===L(this,vs,`f`))?(R(this,Xo,L(this,Bo,`f`)?.syntaxFile,`f`),R(this,Yo,L(this,zo,`f`)?.syntaxFile,`f`)):(L(this,Ro,`m`,Ms).call(this,{registerHighlighter:e}),L(this,Ro,`m`,ks).call(this),R(this,cs,!0,`f`))}init(){this.initRaw(),this.initSyntax()}buildSplitDiffLines(){if(L(this,ls,`f`))return;L(this,Ro,`m`,zs).call(this);let e=1,t=1,n=!0,r=1/0,i=L(this,zo,`f`)?.maxLineNumber||0,a=L(this,Bo,`f`)?.maxLineNumber||0;for(;e<=i||t<=a;){let i=L(this,Ro,`m`,Ns).call(this,e),a=L(this,Ro,`m`,Ps).call(this,t),o=L(this,Ro,`m`,Fs).call(this,e),s=L(this,Ro,`m`,Is).call(this,t),c=Va.prototype.isIncludeableLine.call(i||{}),l=Va.prototype.isIncludeableLine.call(a||{}),u=L(this,es,`f`).length,d=!i&&!a;if(i&&!a){if(i.newLineNumber&&i.newLineNumber>t){t++;continue}(i.newLineNumber===null||i.newLineNumber===void 0)&&t++}if(a&&!i){if(a.oldLineNumber&&a.oldLineNumber>e){e++;continue}(a.oldLineNumber===null||a.oldLineNumber===void 0)&&e++}if(!i&&!o&&!a&&!s)break;if(!i&&!a){if(L(this,Zo,`f`)?.[e]&&L(this,Qo,`f`)?.[t]){e++,t++;continue}if(!o&&L(this,Qo,`f`)?.[t]){t++;continue}if(!s&&L(this,Zo,`f`)?.[e]){e++;continue}}if(c&&l||!c&&!l?(L(this,$o,`f`).push({lineNumber:e++,value:o,diff:i,isHidden:d,_isHidden:d}),L(this,es,`f`).push({lineNumber:t++,value:s,diff:a,isHidden:d,_isHidden:d})):c?(L(this,$o,`f`).push({lineNumber:e++,value:o,diff:i,isHidden:d,_isHidden:d}),L(this,es,`f`).push({})):l&&(L(this,$o,`f`).push({}),L(this,es,`f`).push({lineNumber:t++,value:s,diff:a,isHidden:d,_isHidden:d})),!n&&d&&(r=u),d&&(this.hasSomeLineCollapsed=!0),n=d,i?.prevHunkLine||a?.prevHunkLine){let e=i?.prevHunkLine||a?.prevHunkLine;e&&(e.isFirst?(e.splitInfo={...e.hunkInfo,startHiddenIndex:0,endHiddenIndex:e.hunkInfo.newStartIndex-1,plainText:e.text,_startHiddenIndex:0,_endHiddenIndex:e.hunkInfo.newStartIndex-1,_plainText:e.text},r=1/0):Number.isFinite(r)&&(e.splitInfo={...e.hunkInfo,startHiddenIndex:r,endHiddenIndex:u,plainText:e.text,_startHiddenIndex:r,_endHiddenIndex:u,_plainText:e.text},r=1/0),R(this,rs,{...L(this,rs,`f`),[u]:e},`f`))}}if(Number.isFinite(r)){let e=new Va(``,Ba.Hunk,null,null,null);e.isLast=!0,e.splitInfo={startHiddenIndex:r,endHiddenIndex:L(this,es,`f`).length,_startHiddenIndex:r,_endHiddenIndex:L(this,es,`f`).length,plainText:``,oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:``,_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},R(this,rs,{...L(this,rs,`f`),[L(this,es,`f`).length]:e},`f`),r=1/0}this.splitLineLength=L(this,es,`f`).length,R(this,ls,!0,`f`),this.notifyAll()}buildUnifiedDiffLines(){if(L(this,us,`f`))return;L(this,Ro,`m`,zs).call(this);let e=1,t=1,n=!0,r=1/0,i=L(this,zo,`f`)?.maxLineNumber||0,a=L(this,Bo,`f`)?.maxLineNumber||0;for(;e<=i||t<=a;){let i=L(this,Ro,`m`,Fs).call(this,e),a=L(this,Ro,`m`,Ns).call(this,e),o=L(this,Ro,`m`,Is).call(this,t),s=L(this,Ro,`m`,Ps).call(this,t),c=Va.prototype.isIncludeableLine.call(a||{}),l=Va.prototype.isIncludeableLine.call(s||{}),u=L(this,is,`f`).length,d=!a&&!s;if(a&&!s){if(a.newLineNumber&&a.newLineNumber>t){t++;continue}(a.newLineNumber===null||a.newLineNumber===void 0)&&t++}if(s&&!a){if(s.oldLineNumber&&s.oldLineNumber>e){e++;continue}(s.oldLineNumber===null||s.oldLineNumber===void 0)&&e++}if(!i&&!o&&!s&&!a)break;if(!a&&!s){if(L(this,Zo,`f`)?.[e]&&L(this,Qo,`f`)?.[t]){e++,t++;continue}if(!i&&L(this,Qo,`f`)?.[t]){t++;continue}if(!o&&L(this,Zo,`f`)?.[e]){e++;continue}}if(!c&&!l?L(this,is,`f`).push({oldLineNumber:e++,newLineNumber:t++,value:o,diff:s,isHidden:d,_isHidden:d}):c?L(this,is,`f`).push({oldLineNumber:e++,value:i,diff:a,isHidden:d,_isHidden:d}):l&&L(this,is,`f`).push({newLineNumber:t++,value:o,diff:s,isHidden:d,_isHidden:d}),!n&&d&&(r=u),d&&(this.hasSomeLineCollapsed=!0),n=d,a?.prevHunkLine||s?.prevHunkLine){let e=a?.prevHunkLine||s?.prevHunkLine;e&&(e.isFirst?(e.unifiedInfo={...e.hunkInfo,startHiddenIndex:0,endHiddenIndex:e.hunkInfo.newStartIndex-1,plainText:e.text,_startHiddenIndex:0,_endHiddenIndex:e.hunkInfo.newStartIndex-1,_plainText:e.text},r=1/0):Number.isFinite(r)&&(e.unifiedInfo={...e.hunkInfo,startHiddenIndex:r,endHiddenIndex:u,plainText:e.text,_startHiddenIndex:r,_endHiddenIndex:u,_plainText:e.text},r=1/0),R(this,as,{...L(this,as,`f`),[u]:e},`f`))}}if(Number.isFinite(r)){let e=new Va(``,Ba.Hunk,null,null,null);e.isLast=!0,e.unifiedInfo={startHiddenIndex:r,endHiddenIndex:L(this,is,`f`).length,_startHiddenIndex:r,_endHiddenIndex:L(this,is,`f`).length,plainText:``,oldStartIndex:0,newStartIndex:0,oldLength:0,newLength:0,_plainText:``,_oldStartIndex:0,_newStartIndex:0,_oldLength:0,_newLength:0},R(this,as,{...L(this,as,`f`),[L(this,is,`f`).length]:e},`f`),r=1/0}this.unifiedLineLength=L(this,is,`f`).length,R(this,us,!0,`f`),this.notifyAll()}get hasExpandSplitAll(){return L(this,xs,`f`).state}get hasExpandUnifiedAll(){return L(this,Ss,`f`).state}};zo=new WeakMap,Bo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Ko=new WeakMap,qo=new WeakMap,Jo=new WeakMap,Yo=new WeakMap,Xo=new WeakMap,Zo=new WeakMap,Qo=new WeakMap,$o=new WeakMap,es=new WeakMap,ts=new WeakMap,ns=new WeakMap,rs=new WeakMap,is=new WeakMap,as=new WeakMap,os=new WeakMap,ss=new WeakMap,cs=new WeakMap,ls=new WeakMap,us=new WeakMap,ds=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakMap,hs=new WeakMap,gs=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,xs=new WeakMap,Ss=new WeakMap,Cs=new WeakMap,ws=new WeakMap,Ro=new WeakSet,Ts=function(){this._diffList&&R(this,Vo,this._diffList.map(e=>xo.parse(e)),`f`)},Es=function(){(this._oldFileContent||this._newFileContent)&&(this._oldFileContent&&R(this,zo,Mo(this._oldFileContent,this._oldFileLang,L(this,bs,`f`),this._oldFileName,this.uuid?this.uuid+`-old`:void 0),`f`),this._newFileContent&&R(this,Bo,Mo(this._newFileContent,this._newFileLang,L(this,bs,`f`),this._newFileName,this.uuid?this.uuid+`-new`:void 0),`f`))},Ds=function(){var e,t;(e=L(this,zo,`f`))==null||e.doRaw(),R(this,Go,L(this,zo,`f`)?.rawFile,`f`),R(this,qo,L(this,zo,`f`)?.plainFile,`f`),(t=L(this,Bo,`f`))==null||t.doRaw(),R(this,Ko,L(this,Bo,`f`)?.rawFile,`f`),R(this,Jo,L(this,Bo,`f`)?.plainFile,`f`),this.fileLineLength=Math.max(this.fileLineLength,L(this,zo,`f`)?.maxLineNumber||0,L(this,Bo,`f`)?.maxLineNumber||0)},Os=function(){if(this._oldFileContent&&this._newFileContent)return;let e={},t={};if(!this._oldFileContent&&!this._newFileContent){let n=1,r=1,i=``,a=``,o=!1;for(;r<=this.diffLineLength||n<=this.diffLineLength;){let s=r++,c=n++,l=L(this,Ro,`m`,Ns).call(this,s),u=L(this,Ro,`m`,Ps).call(this,c);l?i+=l.text:(i+=`
34
34
  `,e[s]=!0),u?a+=u.text:(a+=`
35
- `,t[c]=!0),!o&&l&&u&&(o||=l.noTrailingNewLine!==u.noTrailingNewLine)}if(!o&&i===a)return;this._oldFileContent=i,this._newFileContent=a,R(this,zo,Mo(this._oldFileContent,this._oldFileLang,L(this,bs,`f`),this._oldFileName,this.uuid?this.uuid+`-old`:void 0),`f`),R(this,Bo,Mo(this._newFileContent,this._newFileLang,L(this,bs,`f`),this._newFileName,this.uuid?this.uuid+`-new`:void 0),`f`),R(this,Zo,e,`f`),R(this,Qo,t,`f`),R(this,ps,!0,`f`)}else if(L(this,zo,`f`)){let e=1,t=1,n=``,r=!1;for(;t<=L(this,zo,`f`).maxLineNumber;){let i=L(this,Ro,`m`,Ps).call(this,e++),a=L(this,Ro,`m`,Ns).call(this,t);i?(n+=i.text,t=i.oldLineNumber?i.oldLineNumber+1:t):(a||(n+=L(this,Ro,`m`,Fs).call(this,t)),t++),!r&&i&&a&&(r||=i.noTrailingNewLine!==a.noTrailingNewLine)}if(!r&&n===this._oldFileContent)return;this._newFileContent=n,R(this,Bo,Mo(this._newFileContent,this._newFileLang,L(this,bs,`f`),this._newFileName,this.uuid?this.uuid+`-new`:void 0),`f`)}else if(L(this,Bo,`f`)){let e=1,t=1,n=``,r=!1;for(;t<=L(this,Bo,`f`).maxLineNumber;){let i=L(this,Ro,`m`,Ns).call(this,e++),a=L(this,Ro,`m`,Ps).call(this,t);i?(n+=i.text,t=i.newLineNumber?i.newLineNumber+1:t):(a||(n+=L(this,Ro,`m`,Is).call(this,t)),t++),!r&&a&&i&&(r||=a.noTrailingNewLine!==i.noTrailingNewLine)}if(!r&&n===this._newFileContent)return;this._oldFileContent=n,R(this,zo,Mo(this._oldFileContent,this._oldFileLang,L(this,bs,`f`),this._oldFileName,this.uuid?this.uuid+`-old`:void 0),`f`)}L(this,Ro,`m`,Ds).call(this)},ks=function(){var e;if(!L(this,Vo,`f`)?.length)return;R(this,fs,(e=L(this,fs,`f`),e++,e),`f`);let t=e=>L(this,Ro,`m`,Is).call(this,e),n=e=>L(this,Ro,`m`,Fs).call(this,e),r=e=>L(this,Ro,`m`,Rs).call(this,e),i=e=>L(this,Ro,`m`,Ls).call(this,e);R(this,Ho,[],`f`),this.additionLength=0,this.deletionLength=0;let a=[];L(this,Vo,`f`).forEach(e=>{e.hunks.forEach(e=>{let o=[],s=[];e.lines.forEach(e=>{e.type===Ba.Add?(o.push(e),this.additionLength++):e.type===Ba.Delete?(s.push(e),this.deletionLength++):(fo(o,s,{diffFile:this,getAdditionRaw:t,getDeletionRaw:n,getAdditionSyntax:r,getDeletionSyntax:i}),o=[],s=[]),a.push(e)}),fo(o,s,{diffFile:this,getAdditionRaw:t,getDeletionRaw:n,getAdditionSyntax:r,getDeletionSyntax:i})})});let o=null;R(this,Ho,a.map((e,t)=>{let n=e;if(n.index=t,n.isFirst=t===0,n.type===Ba.Hunk){let e=n.text.split(`@@`)?.[1].split(` `).filter(Boolean),t=e?.[0]||``,r=e?.[1]||``,[i,a]=t.split(`,`),[s,c]=r.split(`,`);n.hunkInfo={oldStartIndex:-Number(i),oldLength:Number(a),newStartIndex:+Number(s),newLength:Number(c),_oldStartIndex:-Number(i),_oldLength:Number(a),_newStartIndex:+Number(s),_newLength:Number(c)},o=n}else if(n.type===Ba.Context){let t=e;o&&=(t.prevHunkLine=o,null)}else o=null;return n}),`f`),R(this,Uo,{},`f`),R(this,Wo,{},`f`),L(this,Ho,`f`).forEach(e=>{e.oldLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,e.oldLineNumber),L(this,Uo,`f`)[e.oldLineNumber]=e),e.newLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,e.newLineNumber),L(this,Wo,`f`)[e.newLineNumber]=e)})},As=function(){R(this,_s,L(this,zo,`f`)?.highlighterName||L(this,Bo,`f`)?.highlighterName||L(this,_s,`f`),`f`),R(this,vs,L(this,zo,`f`)?.highlighterType||L(this,Bo,`f`)?.highlighterType||L(this,vs,`f`),`f`),L(this,zo,`f`)?.highlighterName&&R(this,Yo,L(this,zo,`f`).syntaxFile,`f`),L(this,Bo,`f`)?.highlighterName&&R(this,Xo,L(this,Bo,`f`).syntaxFile,`f`)},js=function({registerHighlighter:e}){var t,n;(t=L(this,zo,`f`))==null||t.doSyntax({registerHighlighter:e,theme:L(this,bs,`f`)}),R(this,Yo,L(this,zo,`f`)?.syntaxFile,`f`),(n=L(this,Bo,`f`))==null||n.doSyntax({registerHighlighter:e,theme:L(this,bs,`f`)}),R(this,Xo,L(this,Bo,`f`)?.syntaxFile,`f`)},Ms=function({registerHighlighter:e}={}){(!L(this,hs,`f`)||L(this,gs,`f`))&&(L(this,Ro,`m`,js).call(this,{registerHighlighter:e}),L(this,Ro,`m`,As).call(this))},Ns=function(e){if(e)return L(this,Uo,`f`)?.[e]},Ps=function(e){if(e)return L(this,Wo,`f`)?.[e]},Fs=function(e){return L(this,Go,`f`)?.[e]},Is=function(e){return L(this,Ko,`f`)?.[e]},Ls=function(e){return L(this,Yo,`f`)?.[e]},Rs=function(e){return L(this,Xo,`f`)?.[e]},zs=function(){R(this,ts,void 0,`f`),R(this,ns,void 0,`f`)},Bs=function(e){return L(this,ts,`f`)||R(this,ts,{old:Ws(L(this,$o,`f`),e=>e.lineNumber),new:Ws(L(this,es,`f`),e=>e.lineNumber)},`f`),e===z.old?L(this,ts,`f`).old:L(this,ts,`f`).new},Vs=function(e){return L(this,ns,`f`)||R(this,ns,{old:Ws(L(this,is,`f`),e=>e.oldLineNumber),new:Ws(L(this,is,`f`),e=>e.newLineNumber)},`f`),e===z.old?L(this,ns,`f`).old:L(this,ns,`f`).new};var Ks=`diff-multi-select-active`,qs={selected:Ks,selecting:`diff-multi-selecting`};function Js(e){if(!e)return null;let t=e.querySelector(`span[data-line-num]`);if(!t)return null;let n=t.getAttribute(`data-line-num`),r=parseInt(n??``,10);return n===r.toString()?isNaN(r)?null:r:null}function Ys(e){if(!e)return null;let t=e.closest(`[data-side]`);return t?t.getAttribute(`data-side`):null}function Xs(e,t=!1){if(!e||t&&e.closest(`.diff-add-widget-wrapper`))return null;let n=e.closest(`.diff-line-num`);if(!n)return null;let r=n.querySelector(`span[data-line-old-num]`),i=n.querySelector(`span[data-line-new-num]`),a=r?.getAttribute(`data-line-old-num`),o=i?.getAttribute(`data-line-new-num`),s=a?parseInt(a,10):void 0,c=o?parseInt(o,10):void 0;return s===void 0&&c===void 0?null:{old:s,new:c}}function Zs(e,t=!1){if(!e||t&&e.closest(`.diff-add-widget-wrapper`))return null;let n=null;if(!t){let t=e.closest(`.diff-line-new-content`),r=e.closest(`.diff-line-old-content`);t&&(n=t.parentElement?.querySelector(`.diff-line-new-num`)??null),r&&(n=r.parentElement?.querySelector(`.diff-line-old-num`)??null)}return n||=e.closest(`.diff-line-new-num`)||e.closest(`.diff-line-old-num`),n}function Qs(e){let t=Math.min(e.startLineNumber,e.endLineNumber),n=Math.max(e.startLineNumber,e.endLineNumber);return{...e,startLineNumber:t,endLineNumber:n}}var $s=e=>{let t=[];return e.new&&e.new.length&&t.push({side:`new`,startLineNumber:Math.min(...e.new),endLineNumber:Math.max(...e.new)}),e.old&&e.old.length&&t.push({side:`old`,startLineNumber:Math.min(...e.old),endLineNumber:Math.max(...e.old)}),t},ec=(e,t,n,r)=>{rc(t,n).forEach(t=>{var i,a;if(!t.isHide&&t.index){let o=e.filter(e=>e.getAttribute(`data-line`)===t.index.toString());o.length===2?t.isContext?o.forEach(e=>e.querySelectorAll(`td`).forEach(e=>e.classList.add(r))):o.find(e=>e.getAttribute(`data-side`)===n.side)?.querySelectorAll(`td`).forEach(e=>e.classList.add(r)):t.isContext?(i=o[0])==null||i.querySelectorAll(`td`).forEach(e=>e.classList.add(r)):(a=o[0])==null||a.querySelectorAll(`td[data-side="${n.side}"]`).forEach(e=>e.classList.add(r))}})};function tc(e,t,n,r={old:[],new:[]},i=Ks){if(!e)return;let a=`diff-root${n?.getId()}`,o=Array.from(e.querySelectorAll(`tr[data-line]`)).filter(e=>e.closest(`.diff-view-wrapper`)?.getAttribute(`id`)===a),s=$s(r),c=(t?s.concat(t):s).map(Qs);o.forEach(e=>{e.querySelectorAll(`td`).forEach(e=>e.classList.remove(i))}),c.forEach(e=>{e&&n&&ec(o,n,e,i)})}function nc(e,t,n,r={old:[],new:[]},i=Ks){if(!e)return;let a=`diff-root${n?.getId()}`,o=Array.from(e.querySelectorAll(`tr[data-line]`)).filter(e=>e.closest(`.diff-view-wrapper`)?.getAttribute(`id`)===a),s=$s(r),c=(t?s.concat(t):s).map(Qs);o.forEach(e=>{let t=e.querySelector(`.diff-line-num`),n=e.querySelector(`.diff-line-content`);if(!t||!n)return;t.classList.remove(i),n.classList.remove(i);let r=t.querySelector(`span[data-line-old-num]`),a=t.querySelector(`span[data-line-new-num]`),o=r?.getAttribute(`data-line-old-num`),s=a?.getAttribute(`data-line-new-num`),l=o?parseInt(o,10):void 0,u=s?parseInt(s,10):void 0;c.some(e=>e.side===`old`&&l&&l>=e.startLineNumber&&l<=e.endLineNumber||e.side===`new`&&u&&u>=e.startLineNumber&&u<=e.endLineNumber)&&(t.classList.add(i),n.classList.add(i))})}function rc(e,t){let n=Qs(t),r=[],{side:i,startLineNumber:a,endLineNumber:o}=n,s=i===`old`?z.old:z.new;for(let t=a;t<=o;t++){let n=e.getSplitLineByLineNumber(t,s),i=e.getSplitLineIndexByLineNumber(t,s);if(n&&n.lineNumber!==void 0){let a=n.diff?.type;r.push({index:i+1,lineNumber:n.lineNumber,value:n.value,isHide:Lo(e,t,s).split,isDelete:a===Ba.Delete,isAdd:a===Ba.Add,isContext:a===Ba.Context||a===void 0})}}return r}function ic(e,t){let n=Qs(t),r=[],{side:i,startLineNumber:a,endLineNumber:o}=n,s=i===`old`?z.old:z.new;for(let t=a;t<=o;t++){let n=e.getUnifiedLineByLineNumber(t,s),a=e.getUnifiedLineIndexByLineNumber(t,s);if(n){let o=i===`old`?n.oldLineNumber:n.newLineNumber;if(o!==void 0){let i=n.diff?.type;r.push({index:a+1,lineNumber:o,value:n.value,isHide:Lo(e,t,s).unified,isDelete:i===Ba.Delete,isAdd:i===Ba.Add,isContext:i===Ba.Context||i===void 0})}}}return r}var ac,oc,sc,cc,lc,uc,dc,fc,pc,mc,hc,gc,_c,vc,yc,bc,xc,Sc,Cc=class{constructor(e,t,n={}){ac.add(this),oc.set(this,null),sc.set(this,null),cc.set(this,void 0),lc.set(this,{isSelecting:!1,startInfo:null,currentRange:null}),uc.set(this,{old:[],new:[]}),dc.set(this,null),fc.set(this,!1),pc.set(this,()=>void 0),mc.set(this,()=>void 0),R(this,oc,e,`f`),R(this,sc,t,`f`),R(this,cc,{enabled:n.enabled??!0,onSelectionChange:n.onSelectionChange??(()=>{}),onSelectionComplete:n.onSelectionComplete??(()=>{}),scopeToHunk:n.scopeToHunk??(e=>e),selectedClassName:n.selectedClassName??Ks,isUnifiedMode:n.isUnifiedMode??!1},`f`),L(this,cc,`f`).enabled&&L(this,ac,`m`,hc).call(this);let r=null;R(this,mc,()=>{r&&clearTimeout(r),r=setTimeout(()=>L(this,ac,`m`,xc).call(this),16)},`f`),Object.defineProperty(this,"__v_skip",{value:!0})}getSelectionResult(){if(!L(this,lc,`f`).currentRange||!L(this,sc,`f`))return null;let e=Qs(L(this,lc,`f`).currentRange);return{range:e,lines:L(this,cc,`f`).isUnifiedMode?ic(L(this,sc,`f`),e):rc(L(this,sc,`f`),e)}}getState(){return{...L(this,lc,`f`)}}setPreselectedLines(e){R(this,uc,e,`f`),L(this,ac,`m`,xc).call(this)}clearSelection(){L(this,ac,`m`,Sc).call(this),L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(null,{...L(this,lc,`f`)})}updateOptions(e){let t=L(this,cc,`f`).enabled;R(this,cc,{...L(this,cc,`f`),...e},`f`),!t&&L(this,cc,`f`).enabled?L(this,ac,`m`,hc).call(this):t&&!L(this,cc,`f`).enabled&&this.destroy()}updateDiffFile(e){L(this,pc,`f`).call(this),R(this,sc,e,`f`),R(this,pc,L(this,sc,`f`).subscribe(()=>L(this,mc,`f`).call(this)),`f`),L(this,ac,`m`,xc).call(this)}updateContainer(e){this.destroy(),R(this,oc,e,`f`),R(this,fc,!1,`f`),L(this,cc,`f`).enabled&&L(this,ac,`m`,hc).call(this)}destroy(){L(this,fc,`f`)||(L(this,dc,`f`)&&L(this,oc,`f`)&&(L(this,oc,`f`).removeEventListener(`mousedown`,L(this,dc,`f`).mousedown),L(this,oc,`f`).removeEventListener(`mouseover`,L(this,dc,`f`).mouseover),document.removeEventListener(`mouseup`,L(this,dc,`f`).mouseup),R(this,dc,null,`f`)),L(this,pc,`f`).call(this),this.clearSelection(),R(this,fc,!0,`f`))}};oc=new WeakMap,sc=new WeakMap,cc=new WeakMap,lc=new WeakMap,uc=new WeakMap,dc=new WeakMap,fc=new WeakMap,pc=new WeakMap,mc=new WeakMap,ac=new WeakSet,hc=function(){if(!L(this,oc,`f`)||L(this,dc,`f`))return;let e=e=>{L(this,cc,`f`).isUnifiedMode?L(this,ac,`m`,_c).call(this,e):L(this,ac,`m`,gc).call(this,e)},t=e=>{L(this,cc,`f`).isUnifiedMode?L(this,ac,`m`,yc).call(this,e):L(this,ac,`m`,vc).call(this,e)},n=()=>{L(this,ac,`m`,bc).call(this)};R(this,dc,{mousedown:e,mouseover:t,mouseup:n},`f`),L(this,oc,`f`).addEventListener(`mousedown`,e),L(this,oc,`f`).addEventListener(`mouseover`,t),document.addEventListener(`mouseup`,n),R(this,pc,L(this,sc,`f`)?.subscribe(()=>L(this,mc,`f`).call(this))||(()=>void 0),`f`)},gc=function(e){let t=Zs(e.target,!0);if(!t)return;let n=Js(t);if(n===null)return;let r=Ys(t);if(!r)return;L(this,lc,`f`).isSelecting=!0,L(this,lc,`f`).startInfo={lineNumber:n,side:r};let i={side:r,startLineNumber:n,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(i);e&&(i=e)}L(this,lc,`f`).currentRange=i,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(i,{...L(this,lc,`f`)})},_c=function(e){let t=Xs(e.target,!0);if(!t)return;let n=t.new??t.old;if(n===void 0)return;let r=t.new===void 0?`old`:`new`;L(this,lc,`f`).isSelecting=!0,L(this,lc,`f`).startInfo={lineNumber:n,side:r};let i={side:r,startLineNumber:n,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(i);e&&(i=e)}L(this,lc,`f`).currentRange=i,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(i,{...L(this,lc,`f`)})},vc=function(e){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).startInfo)return;let t=Zs(e.target);if(!t)return;let n=Js(t);if(n===null)return;let r={side:L(this,lc,`f`).startInfo.side,startLineNumber:L(this,lc,`f`).startInfo.lineNumber,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(r);e&&(r=e)}L(this,lc,`f`).currentRange=r,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(r,{...L(this,lc,`f`)})},yc=function(e){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).startInfo)return;let t=Xs(e.target);if(!t)return;let n=t[L(this,lc,`f`).startInfo.side];if(n===void 0)return;let r={side:L(this,lc,`f`).startInfo.side,startLineNumber:L(this,lc,`f`).startInfo.lineNumber,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(r);e&&(r=e)}L(this,lc,`f`).currentRange=r,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(r,{...L(this,lc,`f`)})},bc=function(){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).currentRange){L(this,ac,`m`,Sc).call(this);return}let e=Qs(L(this,lc,`f`).currentRange);L(this,lc,`f`).currentRange=e,L(this,lc,`f`).isSelecting=!1;let t=this.getSelectionResult();L(this,cc,`f`).onSelectionComplete(t)},xc=function(){L(this,cc,`f`).isUnifiedMode?nc(L(this,oc,`f`),L(this,lc,`f`).currentRange,L(this,sc,`f`),L(this,uc,`f`),L(this,cc,`f`).selectedClassName):tc(L(this,oc,`f`),L(this,lc,`f`).currentRange,L(this,sc,`f`),L(this,uc,`f`),L(this,cc,`f`).selectedClassName)},Sc=function(){R(this,lc,{isSelecting:!1,startInfo:null,currentRange:null},`f`)};function wc(e,t,n){return new Cc(e,t,n)}var Tc=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ec=o(((e,t)=>{t.exports=Tc()}))();function Dc(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var Oc={},kc=()=>{},Ac=Object.assign,jc=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},Mc=Object.prototype.hasOwnProperty,Nc=(e,t)=>Mc.call(e,t),Pc=Array.isArray,Fc=e=>Uc(e)===`[object Map]`,Ic=e=>Uc(e)===`[object Set]`,Lc=e=>typeof e==`function`,Rc=e=>typeof e==`string`,zc=e=>typeof e==`symbol`,Bc=e=>typeof e==`object`&&!!e,Vc=e=>(Bc(e)||Lc(e))&&Lc(e.then)&&Lc(e.catch),Hc=Object.prototype.toString,Uc=e=>Hc.call(e),Wc=e=>Uc(e).slice(8,-1),Gc=e=>Uc(e)===`[object Object]`,Kc=e=>Rc(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,qc=(e,t)=>!Object.is(e,t),Jc,Yc=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&Jc&&(Jc.active?(this.parent=Jc,this.index=(Jc.scopes||(Jc.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].pause()}for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}let n=this.effects.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}}run(e){if(this._active){let t=Jc;try{return Jc=this,e()}finally{Jc=t}}}on(){++this._on===1&&(this.prevScope=Jc,Jc=this)}off(){if(this._on>0&&--this._on===0){if(Jc===this)Jc=this.prevScope;else{let e=Jc;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){let e=this.scopes.slice();for(t=0,n=e.length;t<n;t++)e[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function Xc(e){return new Yc(e)}function Zc(){return Jc}var Qc,$c=new WeakSet,el=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Jc&&(Jc.active?Jc.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,$c.has(this)&&($c.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||il(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,_l(this),sl(this);let e=Qc,t=pl;Qc=this,pl=!0;try{return this.fn()}finally{cl(this),Qc=e,pl=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)dl(e);this.deps=this.depsTail=void 0,_l(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?$c.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){ll(this)&&this.run()}get dirty(){return ll(this)}},tl=0,nl,rl;function il(e,t=!1){e.flags|=8,t?(e.next=rl,rl=e):(e.next=nl,nl=e)}function al(){tl++}function ol(){if(--tl>0)return;if(rl){let e=rl;for(rl=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;nl;){let t=nl;for(nl=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function sl(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function cl(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),dl(r),fl(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function ll(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(ul(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function ul(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===vl)||(e.globalVersion=vl,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!ll(e))))return;e.flags|=2;let t=e.dep,n=Qc,r=pl;Qc=e,pl=!0;try{sl(e);let n=e.fn(e._value);(t.version===0||qc(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{Qc=n,pl=r,cl(e),e.flags&=-3}}function dl(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)dl(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function fl(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var pl=!0,ml=[];function hl(){ml.push(pl),pl=!1}function gl(){let e=ml.pop();pl=e===void 0||e}function _l(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=Qc;Qc=void 0;try{t()}finally{Qc=e}}}var vl=0,yl=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},bl=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!Qc||!pl||Qc===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==Qc)t=this.activeLink=new yl(Qc,this),Qc.deps?(t.prevDep=Qc.depsTail,Qc.depsTail.nextDep=t,Qc.depsTail=t):Qc.deps=Qc.depsTail=t,xl(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=Qc.depsTail,t.nextDep=void 0,Qc.depsTail.nextDep=t,Qc.depsTail=t,Qc.deps===t&&(Qc.deps=e)}return t}trigger(e){this.version++,vl++,this.notify(e)}notify(e){al();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{ol()}}};function xl(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)xl(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var Sl=new WeakMap,Cl=Symbol(``),wl=Symbol(``),Tl=Symbol(``);function El(e,t,n){if(pl&&Qc){let t=Sl.get(e);t||Sl.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new bl),r.map=t,r.key=n),r.track()}}function Dl(e,t,n,r,i,a){let o=Sl.get(e);if(!o){vl++;return}let s=e=>{e&&e.trigger()};if(al(),t===`clear`)o.forEach(s);else{let i=Pc(e),a=i&&Kc(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===Tl||!zc(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(Tl)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(Cl)),Fc(e)&&s(o.get(wl)));break;case`delete`:i||(s(o.get(Cl)),Fc(e)&&s(o.get(wl)));break;case`set`:Fc(e)&&s(o.get(Cl))}}ol()}function Ol(e){let t=pu(e);return t===e||(El(t,`iterate`,Tl),du(e))?t:uu(e)?lu(e)?t.map(e=>hu(mu(e))):t.map(hu):t.map(mu)}function kl(e){return El(e=pu(e),`iterate`,Tl),e}function Al(e,t){return uu(e)?hu(lu(e)?mu(t):t):mu(t)}var jl={__proto__:null,[Symbol.iterator](){return Ml(this,Symbol.iterator,e=>Al(this,e))},concat(...e){return Ol(this).concat(...e.map(e=>Pc(e)?Ol(e):e))},entries(){return Ml(this,`entries`,e=>(e[1]=Al(this,e[1]),e))},every(e,t){return Fl(this,`every`,e,t,void 0,arguments)},filter(e,t){return Fl(this,`filter`,e,t,e=>e.map(e=>Al(this,e)),arguments)},find(e,t){return Fl(this,`find`,e,t,e=>Al(this,e),arguments)},findIndex(e,t){return Fl(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return Fl(this,`findLast`,e,t,e=>Al(this,e),arguments)},findLastIndex(e,t){return Fl(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return Fl(this,`forEach`,e,t,void 0,arguments)},includes(...e){return Ll(this,`includes`,e)},indexOf(...e){return Ll(this,`indexOf`,e)},join(e){return Ol(this).join(e)},lastIndexOf(...e){return Ll(this,`lastIndexOf`,e)},map(e,t){return Fl(this,`map`,e,t,void 0,arguments)},pop(){return Rl(this,`pop`)},push(...e){return Rl(this,`push`,e)},reduce(e,...t){return Il(this,`reduce`,e,t)},reduceRight(e,...t){return Il(this,`reduceRight`,e,t)},shift(){return Rl(this,`shift`)},some(e,t){return Fl(this,`some`,e,t,void 0,arguments)},splice(...e){return Rl(this,`splice`,e)},toReversed(){return Ol(this).toReversed()},toSorted(e){return Ol(this).toSorted(e)},toSpliced(...e){return Ol(this).toSpliced(...e)},unshift(...e){return Rl(this,`unshift`,e)},values(){return Ml(this,`values`,e=>Al(this,e))}};function Ml(e,t,n){let r=kl(e),i=r[t],a=i.call(r);if(r!==e&&!du(e)){if(a[Symbol.toStringTag]===`Array Iterator`){let e=Object.create(Object.getPrototypeOf(a));return e.next=()=>Nl(a.next(),n),i!==Pl[t]&&Object.defineProperties(e,{return:{get(){let e=a.return;return typeof e==`function`?e.bind(a):e}},throw:{get(){let e=a.throw;return typeof e==`function`?e.bind(a):e}}}),e}a._next=a.next,a.next=()=>Nl(a._next(),n)}return a}function Nl(e,t){return e.done||(e.value=t(e.value)),e}var Pl=Array.prototype;function Fl(e,t,n,r,i,a){let o=kl(e),s=o!==e&&!du(e),c=o[t];if(c!==Pl[t]){let t=c.apply(e,a);return s?mu(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,Al(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function Il(e,t,n,r){let i=kl(e),a=i!==e&&!du(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=Al(e,t)),n.call(this,t,Al(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?Al(e,c):c}function Ll(e,t,n){let r=pu(e);El(r,`iterate`,Tl);let i=r[t](...n);return(i===-1||i===!1)&&fu(n[0])?(n[0]=pu(n[0]),r[t](...n)):i}function Rl(e,t,n=[]){hl(),al();let r=pu(e)[t].apply(e,n);return ol(),gl(),r}var zl=Dc(`__proto__,__v_isRef,__isVue`),Bl=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(zc));function Vl(e){zc(e)||(e=String(e));let t=pu(this);return El(t,`has`,e),t.hasOwnProperty(e)}var Hl=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?iu:ru:i?nu:tu).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=Pc(e);if(!r){let e;if(a&&(e=jl[t]))return e;if(t===`hasOwnProperty`)return Vl}let o=Reflect.get(e,t,gu(e)?e:n);if((zc(t)?Bl.has(t):zl(t))||(r||El(e,`get`,t),i))return o;if(gu(o)){let e=a&&Kc(t)?o:o.value;return r&&Bc(e)?su(e):e}return Bc(o)?r?su(o):ou(o):o}},Ul=class extends Hl{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=Pc(e)&&Kc(t);if(!this._isShallow){let e=uu(i);if(!du(n)&&!uu(n)&&(i=pu(i),n=pu(n)),!a&&gu(i)&&!gu(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:Nc(e,t),s=Reflect.set(e,t,n,gu(e)?e:r);return e===pu(r)&&s&&(o?qc(n,i)&&Dl(e,`set`,t,n,i):Dl(e,`add`,t,n)),s}deleteProperty(e,t){let n=Nc(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&Dl(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!zc(t)||!Bl.has(t))&&El(e,`has`,t),n}ownKeys(e){return El(e,`iterate`,Pc(e)?`length`:Cl),Reflect.ownKeys(e)}},Wl=class extends Hl{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Gl=new Ul,Kl=new Wl,ql=e=>e,Jl=e=>Reflect.getPrototypeOf(e);function Yl(e,t,n){return function(...r){let i=this.__v_raw,a=pu(i),o=Fc(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?ql:t?hu:mu;return!t&&El(a,`iterate`,c?wl:Cl),Ac(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function Xl(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Zl(e,t){let n={get(n){let r=this.__v_raw,i=pu(r),a=pu(n);e||(qc(n,a)&&El(i,`get`,n),El(i,`get`,a));let{has:o}=Jl(i),s=t?ql:e?hu:mu;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&El(pu(t),`iterate`,Cl),t.size},has(t){let n=this.__v_raw,r=pu(n),i=pu(t);return e||(qc(t,i)&&El(r,`has`,t),El(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=pu(a),s=t?ql:e?hu:mu;return!e&&El(o,`iterate`,Cl),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return Ac(n,e?{add:Xl(`add`),set:Xl(`set`),delete:Xl(`delete`),clear:Xl(`clear`)}:{add(e){let n=pu(this),r=Jl(n),i=pu(e),a=!t&&!du(e)&&!uu(e)?i:e;return r.has.call(n,a)||qc(e,a)&&r.has.call(n,e)||qc(i,a)&&r.has.call(n,i)||(n.add(a),Dl(n,`add`,a,a)),this},set(e,n){!t&&!du(n)&&!uu(n)&&(n=pu(n));let r=pu(this),{has:i,get:a}=Jl(r),o=i.call(r,e);o||=(e=pu(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?qc(n,s)&&Dl(r,`set`,e,n,s):Dl(r,`add`,e,n),this},delete(e){let t=pu(this),{has:n,get:r}=Jl(t),i=n.call(t,e);i||=(e=pu(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&Dl(t,`delete`,e,void 0,a),o},clear(){let e=pu(this),t=e.size!==0,n=e.clear();return t&&Dl(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Yl(r,e,t)}),n}function Ql(e,t){let n=Zl(e,t);return(r,i,a)=>i===`__v_isReactive`?!e:i===`__v_isReadonly`?e:i===`__v_isShallow`?t:i===`__v_raw`?r:Reflect.get(Nc(n,i)&&i in r?n:r,i,a)}var $l={get:Ql(!1,!1)},eu={get:Ql(!0,!1)},tu=new WeakMap,nu=new WeakMap,ru=new WeakMap,iu=new WeakMap;function au(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function ou(e){return uu(e)?e:cu(e,!1,Gl,$l,tu)}function su(e){return cu(e,!0,Kl,eu,ru)}function cu(e,t,n,r,i){if(!Bc(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=au(Wc(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function lu(e){return uu(e)?lu(e.__v_raw):!!(e&&e.__v_isReactive)}function uu(e){return!!(e&&e.__v_isReadonly)}function du(e){return!!(e&&e.__v_isShallow)}function fu(e){return e?!!e.__v_raw:!1}function pu(e){let t=e&&e.__v_raw;return t?pu(t):e}var mu=e=>Bc(e)?ou(e):e,hu=e=>Bc(e)?su(e):e;function gu(e){return e?e.__v_isRef===!0:!1}function _u(e){return vu(e,!1)}function vu(e,t){return gu(e)?e:new yu(e,t)}var yu=class{constructor(e,t){this.dep=new bl,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:pu(e),this._value=t?e:mu(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||du(e)||uu(e);e=n?e:pu(e),qc(e,t)&&(this._rawValue=e,this._value=n?e:mu(e),this.dep.trigger())}},bu={SKIP:`__v_skip`,IS_REACTIVE:`__v_isReactive`,IS_READONLY:`__v_isReadonly`,IS_SHALLOW:`__v_isShallow`,RAW:`__v_raw`,IS_REF:`__v_isRef`},xu={},Su=new WeakMap,Cu=void 0;function wu(e,t=!1,n=Cu){if(n){let t=Su.get(n);t||Su.set(n,t=[]),t.push(e)}}function Tu(e,t,n=Oc){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:du(e)||i===!1||i===0?Eu(e,1):Eu(e),u,d,f,p,m=!1,h=!1;if(gu(e)?(d=()=>e.value,m=du(e)):lu(e)?(d=()=>l(e),m=!0):Pc(e)?(h=!0,m=e.some(e=>lu(e)||du(e)),d=()=>e.map(e=>{if(gu(e))return e.value;if(lu(e))return l(e);if(Lc(e))return c?c(e,2):e()})):d=Lc(e)?t?c?()=>c(e,2):e:()=>{if(f){hl();try{f()}finally{gl()}}let t=Cu;Cu=u;try{return c?c(e,3,[p]):e(p)}finally{Cu=t}}:kc,t&&i){let e=d,t=i===!0?1/0:i;d=()=>Eu(e(),t)}let g=Zc(),_=()=>{u.stop(),g&&g.active&&jc(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{try{return e(...t)}finally{_()}}}let v=h?Array(e.length).fill(xu):xu,y=e=>{if(u.flags&1&&(u.dirty||e)){if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>qc(e,v[t])):qc(n,v))){let e=Cu;hl();try{f&&f(),Cu=u;let e=[n,v===xu?void 0:h&&v[0]===xu?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{Cu=e,gl()}}}else u.run()}};return s&&s(y),u=new el(d),u.scheduler=o?()=>o(y,!1):y,p=e=>wu(e,!1,u),f=u.onStop=()=>{let e=Su.get(u);if(e){if(c)c(e,4);else for(let t of e)t();Su.delete(u)}},t?r?y(!0):v=u.run():o?o(y.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function Eu(e,t=1/0,n){if(t<=0||!Bc(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,gu(e))Eu(e.value,t,n);else if(Pc(e))for(let r=0;r<e.length;r++)Eu(e[r],t,n);else if(Ic(e)||Fc(e))e.forEach(e=>{Eu(e,t,n)});else if(Gc(e)){for(let r in e)Eu(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Eu(e[r],t,n)}return e}var Du;(function(e){e.$$__ignore__$$=`$$__ignore__$$`,e.$$__persist__$$=`$$__persist__$$`,e.$$__subscribe__$$=`$$__subscribe__$$`,e.$$__redux_dev_tool__$$=`$$__redux_dev_tool__$$`})(Du||={});var Ou=new Set,ku=20,Au=!1,ju=0,Mu=()=>{let e=[...Ou.values()].slice(0);Ou.clear();for(let t of e)t.notify();if(Au=!1,Ou.size){if(ju++,ju>ku)throw Error(`[reactivity-store] detected an infinite update loop, pendingJobs: ${[...Ou].map(e=>e._namespace||`unknown`).join(`, `)}`);Mu()}},Nu=e=>{Ou.add(e),!Au&&(Au=!0,ju=0,Promise.resolve().then(Mu))},Pu=null;function Fu(){return Pu}var Iu=class extends el{get _isControllerEffect(){return!0}constructor(e){super(e)}},Lu=(e,t)=>()=>{if(t._isActive)try{let t=e();if(Vc(t))throw Error(`[reactivity-store] selector should be a pure function, but current is an async function`);return t}catch{return null}},Ru=class{constructor(e,t,n,r,i){this._getState=e,this._compare=t,this._lifeCycle=n,this._namespace=r,this._onUpdate=i,this._listeners=new Set,this._updateCount=0,this._isActive=!0,this.notify=()=>{var e;if(this._isActive){this._updateCount++;try{(e=this._onUpdate)==null||e.call(this)}catch{this._lifeCycle.canUpdateComponent=!1}this._listeners.forEach(e=>e())}},this._scheduler=()=>{let e=Fu();Pu=this;let t=this._effect.run();if(Pu=e,!this._isActive)return;let n=this._compare(this._state,t);this._state=t,n||this._lifeCycle.canUpdateComponent&&(this._lifeCycle.syncUpdateComponent?this.notify():Nu(this))},this.subscribe=e=>(this._listeners.add(e),()=>this._listeners.delete(e)),this.getState=()=>this._updateCount,this.getEffect=()=>this._effect,this.getSelectorState=()=>this._getStateSafe(),this.getLifeCycle=()=>this._lifeCycle,this._getStateSafe=Lu(e,this),this._effect=new Iu(this._getStateSafe),this._effect.scheduler=this._scheduler}run(){let e=Fu();Pu=this,this._state=this._effect.run(),Pu=e}stop(){this._effect.stop(),this._listeners.clear(),this._isActive=!1,this._state=null}setActive(e){this._isActive=e}},zu=()=>({onBeforeMount:[],onBeforeUpdate:[],onBeforeUnmount:[],onMounted:[],onUpdated:[],onUnmounted:[],hasHookInstall:!1,canUpdateComponent:!0,syncUpdateComponent:!1});function Bu(e,t){if(!Bc(e)||e[bu.SKIP]||(0,F.isValidElement)(e)||(t||=new Set,t.has(e)))return e;if(t.add(e),gu(e))Hu(e.value,t);else if(Pc(e))for(let n=0;n<e.length;n++)Hu(e[n],t);else if(Ic(e)||Fc(e))e.forEach(e=>{Hu(e,t)});else if(Gc(e))for(let n in e)Hu(e[n],t);return e}function Vu(e){if(!Bc(e)||e[bu.SKIP]||(0,F.isValidElement)(e))return e;if(gu(e))e.value;else if(Pc(e))for(let t=0;t<e.length;t++)e[t];else if(Ic(e)||Fc(e))e.forEach(e=>{});else if(Gc(e))for(let t in e)e[t];return e}function Hu(e,t){return Bu(e,t)}var Uu=e=>{let t=(0,F.useRef)(e);return t.current=e,(0,F.useCallback)((...e)=>t.current?.call(null,...e),[])},Wu=(e,t)=>{let n=(0,F.useRef)();return n.current=typeof e==`function`?e:null,Uu(e=>{if(n.current){let r=n.current(e);return t?Hu(r):Vu(r),r}return t?Hu(e):Vu(e),e})},Gu=e=>{let t=(0,F.useRef)(e);return(0,F.useEffect)(()=>{t.current=e},[e]),t.current},Ku=(e,t,n,r,i=!0,a=!1,o=!0,s,c=void 0)=>{let l=new Set,u=!0;s||=Du.$$__ignore__$$;let d=s===Du.$$__ignore__$$?`RStoreAnonymous`:s;d=d.startsWith(`use`)?d:`use${d.charAt(0).toUpperCase()}${d.slice(1)}`;let f=n=>{let u=n==="default"?i:n===`deep`||n===`deep-stable`,d=n==="default"?a:n===`deep-stable`||n===`shallow-stable`;function f(n,i){let a=(0,F.useRef)(),f=Wu(n,u),p=Uu(()=>{n?a.current=n(Object.assign(Object.assign({},t),c)):a.current=Object.assign(Object.assign({},t),c)}),m=Uu((e,t)=>i&&typeof i==`function`?i(e,t):!1),h=d?n:Gu(n),g=o?i:Gu(i),_=(0,F.useMemo)(()=>new Ru(()=>f(e),m,r,s,p),[]);return(0,Ec.useSyncExternalStore)(_.subscribe,_.getState,_.getState),(0,F.useMemo)(()=>{_.run(),p()},[_,p]),(0,F.useMemo)(()=>{h!==n&&(_.run(),p())},[_,h,n]),(0,F.useMemo)(()=>{g!==i&&(_.run(),p())},[_,g,i]),(0,F.useEffect)(()=>(_.setActive(!0),l.add(_),()=>{_.stop(),l.delete(_)}),[_]),a.current}return f},p=()=>{let[e,t]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(r.hasHookInstall){if(!e)r.onBeforeMount.forEach(e=>e()),r.onMounted.forEach(e=>e()),t(!0);else{let e=r.syncUpdateComponent;r.syncUpdateComponent=!0,r.canUpdateComponent=!1,r.onBeforeUpdate.forEach(e=>e()),r.canUpdateComponent=!0,r.syncUpdateComponent=e,r.onUpdated.forEach(e=>e())}}}),(0,F.useEffect)(()=>()=>{r.hasHookInstall&&(r.onBeforeUnmount.forEach(e=>e()),r.onUnmounted.forEach(e=>e()))},[r])},m=({key:t,value:n,single:r,compare:i=Object.is})=>new Promise((a,o)=>{if(r?.aborted){o(r.reason);return}let s=()=>e[t],c=({cb:e}={})=>i(pu(s()),pu(n))?(e?.(),a(),!0):!1;if(!c()){let e=Tu(s,()=>c({cb:()=>e.stop()}));r&&r.addEventListener(`abort`,()=>{e.stop(),o(r.reason)},{once:!0})}}),h=f(`default`),g=f(`deep`),_=f(`deep-stable`),v=f(`shallow`),y=f(`shallow-stable`);function b(e,t){return h(e,t)}let x=b;return x.getState=()=>pu(n),x.getLifeCycle=()=>r,x.getActions=()=>c,x.getReactiveState=()=>e,x.getReadonlyState=()=>t,x.waitingValueTo=m,x.useLifeCycle=p,x.useDeepSelector=g,x.useDeepStableSelector=_,x.useShallowSelector=v,x.useShallowStableSelector=y,x.subscribe=(t,n,i)=>{let a=new Ru(()=>{let n=t(e);return i?Vu(n):Hu(n),n},Object.is,r,Du.$$__subscribe__$$,()=>n());return a.run(),l.add(a),()=>{l.delete(a),a.stop()}},x.getIsActive=()=>u,x.clear=()=>{l.forEach(e=>e.stop()),u=!1},x},qu=e=>e.$$__state__$$?e.$$__state__$$:e,Ju=(e,t=`createStore`,n)=>{let r=qu(e());return Ku(ou(r),su(r),pu(r),n||zu())},Yu=(e,t=`createStore`,n)=>{let r=Xc(),i=r.run(()=>Ju(e,t,n));return i.scope=r,i},Xu=e=>Yu(e);function Zu(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Qu(e,t,n,r,i){if(typeof t==`function`||!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return t.set(e,n),n}var $u,ed,td,nd,rd=null,id=(e,t)=>`${e.fontFamily}-${e.fontStyle}-${e.fontSize}-${t}`,ad=(e,t)=>id(e,`0`.repeat(t.length)),od=class{constructor(){$u.add(this),ed.set(this,``),td.set(this,{})}measure(e,t){let n=ad(t||{},e);if(Zu(this,td,`f`)[n])return Zu(this,td,`f`)[n];let r=Zu(this,$u,`m`,nd).call(this);if(t){let e=`${t.fontFamily}-${t.fontStyle}-${t.fontSize}`;Zu(this,ed,`f`)!==e&&(Qu(this,ed,e),r.font=`${t.fontStyle||``} ${t.fontSize||``} ${t.fontFamily||``}`)}else r.font=``;return r.measureText(e).width}};ed=new WeakMap,td=new WeakMap,$u=new WeakSet,nd=function(){return rd||=document.createElement(`canvas`).getContext(`2d`),rd};var sd=null,cd=()=>(sd||=new od,sd),ld=`--diff-add-content--`,ud=`--diff-del-content--`,dd=`--diff-border--`,fd=`--diff-add-lineNumber--`,pd=`--diff-del-lineNumber--`,md=`--diff-plain-content--`,hd=`--diff-expand-content--`,gd=`--diff-plain-lineNumber-color--`,_d=`--diff-expand-lineNumber-color--`,vd=`--diff-plain-lineNumber--`,yd=`--diff-expand-lineNumber--`,bd=`--diff-hunk-content--`,xd=`--diff-hunk-content-color--`,Sd=`--diff-hunk-lineNumber--`,Cd=`--diff-add-widget--`,wd=`--diff-add-widget-color--`,Td=`--diff-empty-content--`,Ed=(e,t,n)=>e?`var(${ld})`:t?`var(${ud})`:n?`var(${md})`:`var(${hd})`,Dd=(e,t,n)=>e?`var(${fd})`:t?`var(${pd})`:n?`var(${vd})`:`var(${yd})`,Od=()=>{var e;(e=window.getSelection())==null||e.removeAllRanges()},kd=(e,t)=>{let n=function(n){n!==null&&n.target!==null&&(n.target===e?(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft):(e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft))};return e.onscroll||=n,t.onscroll||=n,()=>{e.onscroll=null,t.onscroll=null}},Ad=e=>{if(e){let t=e.getRootNode();return t instanceof ShadowRoot?t:e.ownerDocument}return document},jd=e=>{if(e){if(typeof e.closest==`function`){let t=e.closest(`[data-component="git-diff-view"]`),n=(t?.querySelector)?.call(t,`.diff-view-wrapper`);return(n?.getAttribute)?.call(n,`id`)}{let t=e;for(;t;){if(t.getAttribute&&t.getAttribute(`data-component`)===`git-diff-view`)return t.querySelector(`.diff-view-wrapper`)?.getAttribute(`id`);t=t.parentElement}}}},Md=`--diff-font-size--`,Nd=`--diff-aside-width--`,Pd=e=>{let t={};return(n=>{if(t[n])return t[n];let r=e(n);return t[n]=r,r})},Fd;(function(e){e[e.CRLF=1]=`CRLF`,e[e.CR=2]=`CR`,e[e.LF=3]=`LF`,e[e.NEWLINE=4]=`NEWLINE`,e[e.NORMAL=5]=`NORMAL`,e[e.NULL=6]=`NULL`})(Fd||={});var Id;(function(e){e[e.SplitGitHub=1]=`SplitGitHub`,e[e.SplitGitLab=2]=`SplitGitLab`,e[e.Split=3]=`Split`,e[e.Unified=4]=`Unified`})(Id||={});var Ld=()=>{let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{t(!0)},[]),e},Rd=typeof window<`u`?F.useLayoutEffect:F.useEffect,zd=({text:e,font:t})=>{let[n,r]=(0,F.useState)(()=>{let n=parseInt(t.fontSize||`13`),r=6;return r+=n>10?(n-10)*.6:0,r*e.length});return Rd(()=>{let n=cd().measure(e,t);r(n)},[e,t]),n},Bd=({side:e,className:t,lineNumber:n,onWidgetClick:r,onOpenAddWidget:i})=>(0,I.jsx)(`div`,{"data-add-widget":z[e],className:`diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible`+(t?` `+t:``),style:{width:`calc(var(${Md}) * 1.4)`,height:`calc(var(${Md}) * 1.4)`,top:`calc(var(${Md}) * 0.1)`},children:(0,I.jsx)(`button`,{className:`diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]`,style:{color:`var(${wd})`,backgroundColor:`var(${Cd})`},onMouseDown:t=>{t.stopPropagation(),i(n,e),r?.(n,e)},children:`+`})}),Vd=({lineNumber:e,side:t,onWidgetClick:n,onOpenAddWidget:r})=>(0,I.jsx)(`div`,{"data-add-widget":z[t],className:`diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible`,style:{width:`calc(var(${Md}) * 1.4)`,height:`calc(var(${Md}) * 1.4)`,top:`calc(var(${Md}) * 0.1)`},children:(0,I.jsx)(`button`,{className:`diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]`,style:{color:`var(${wd})`,backgroundColor:`var(${Cd})`},onMouseDown:i=>{i.stopPropagation(),r(e,t),n?.(e,t)},children:`+`})}),Hd=()=>(0,I.jsxs)(`svg`,{"aria-label":`No newline at end of file`,role:`img`,viewBox:`0 0 16 16`,version:`1.1`,fill:`currentColor`,children:[(0,I.jsx)(`path`,{d:`M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z`}),(0,I.jsx)(`path`,{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z`})]}),Ud={},Wd=e=>{if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)},Gd=Pd(e=>{if(!e)return Ud;let t={};return e.split(`;`).forEach(e=>{let[n,r]=e.split(`:`);if(!n)return;let i=Wd(n.trim());t[i]=r.trim()}),t}),Kd=({rawLine:e,diffLine:t,operator:n,plainLine:r,enableWrap:i})=>{let a=t?.changes;if(a?.hasLineChange){let r=a.newLineSymbol;if(!t?.plainTemplate&&typeof eo==`function`&&eo({diffLine:t,rawLine:e,operator:n}),t?.plainTemplate)return(0,I.jsxs)(`span`,{className:`diff-line-content-raw`,children:[(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:t.plainTemplate}}),r===Fd.NEWLINE&&(0,I.jsx)(`span`,{"data-no-newline-at-end-of-file-symbol":!0,className:i?`block !text-red-500`:`inline-block align-middle !text-red-500`,style:{width:`var(${Md})`,height:`var(${Md})`},children:(0,I.jsx)(Hd,{})})]})}return r&&!r?.template&&(r.template=ao(r.value)),r?.template?(0,I.jsx)(`span`,{className:`diff-line-content-raw`,children:(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:r.template}})}):(0,I.jsx)(`span`,{className:`diff-line-content-raw`,children:e})},qd=({rawLine:e,diffFile:t,diffLine:n,operator:r,syntaxLine:i,enableWrap:a})=>{if(!i)return(0,I.jsx)(Kd,{rawLine:e,diffLine:n,operator:r,enableWrap:a});let o=n?.changes;if(o?.hasLineChange){let e=o.newLineSymbol;if(!n?.syntaxTemplate&&typeof no==`function`&&no({diffFile:t,diffLine:n,syntaxLine:i,operator:r}),n?.syntaxTemplate)return(0,I.jsxs)(`span`,{className:`diff-line-syntax-raw`,children:[(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:n.syntaxTemplate}}),e===Fd.NEWLINE&&(0,I.jsx)(`span`,{"data-no-newline-at-end-of-file-symbol":!0,className:a?`block !text-red-500`:`inline-block align-middle !text-red-500`,style:{width:`var(${Md})`,height:`var(${Md})`},children:(0,I.jsx)(Hd,{})})]})}return i.template||=io(i),i?.template?(0,I.jsx)(`span`,{className:`diff-line-syntax-raw`,children:(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:i.template}})}):(0,I.jsx)(`span`,{className:`diff-line-syntax-raw`,children:(i?.nodeList)?.map(({node:e,wrapper:t},n)=>(0,I.jsx)(`span`,{"data-start":e.startIndex,"data-end":e.endIndex,className:(t?.properties?.className)?.join(` `),style:Gd(t?.properties?.style||``),children:e.value},n))})},Jd=({diffFile:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,enableWrap:a,enableHighlight:o})=>{let s=t?.type===Ba.Add,c=t?.type===Ba.Delete,l=i&&i?.nodeList?.length>150;return(0,I.jsxs)(`div`,{className:`diff-line-content-item pl-[2.0em]`,style:{whiteSpace:a?`pre-wrap`:`pre`,wordBreak:a?`break-all`:`initial`},children:[(0,I.jsx)(`span`,{"data-operator":s?`+`:c?`-`:void 0,className:`diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]`,children:s?`+`:c?`-`:` `}),o&&i&&!l?(0,I.jsx)(qd,{operator:s?`add`:c?`del`:void 0,rawLine:n,diffFile:e,diffLine:t,syntaxLine:i,enableWrap:a}):(0,I.jsx)(Kd,{operator:s?`add`:c?`del`:void 0,rawLine:n,diffLine:t,plainLine:r,enableWrap:a})]})},Yd=(0,F.createContext)(null);Yd.displayName=`DiffViewContext`;var Xd=()=>(0,F.useContext)(Yd),Zd=(0,F.createContext)(null);Zd.displayName=`DiffWidgetContext`;var Qd=()=>(0,F.useContext)(Zd),$d=({index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})=>{let o=r===z.old?t.getOldSyntaxLine:t.getNewSyntaxLine,s=r===z.old?t.getOldPlainLine:t.getNewPlainLine,c=t.getSplitLeftLine(e),l=t.getSplitRightLine(e),u=r===z.old?c:l,d=!!u?.diff,f=!!u?.lineNumber,p=Ha(u?.diff),m=u?.diff?.type===Ba.Add,h=u?.diff?.type===Ba.Delete,{useDiffContext:g}=Xd(),_=g.getReadonlyState().onAddWidgetClick,{useWidget:v}=Qd(),y=v.getReadonlyState().setWidget,b=Ed(m,h,d),x=Dd(m,h,d),S=o(u.lineNumber??-1),C=s(u.lineNumber??-1);return(0,I.jsx)(`tr`,{"data-line":n,"data-state":d||!f?`diff`:`plain`,"data-side":z[r],className:`diff-line`+(f?` group`:``),children:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-${z[r]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`,style:{backgroundColor:x,color:`var(${d?gd:_d})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:[d&&i&&(0,I.jsx)(Bd,{index:e,lineNumber:u.lineNumber??-1,side:r,diffFile:t,onWidgetClick:(...e)=>_.current?.call(_,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>y({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":u.lineNumber,style:{opacity:p?void 0:.5},children:u.lineNumber})]}),(0,I.jsx)(`td`,{className:`diff-line-${z[r]}-content pr-[10px] align-top`,style:{backgroundColor:b},children:(0,I.jsx)(Jd,{enableWrap:!1,diffFile:t,rawLine:u?.value||``,diffLine:u?.diff,plainLine:C,syntaxLine:S,enableHighlight:a})})]}):(0,I.jsx)(`td`,{className:`diff-line-${z[r]}-placeholder select-none`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`span`,{children:` `})})})},ef=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})=>(r===z.old?t.getSplitLeftLine:t.getSplitRightLine)(e)?.isHidden?null:(0,I.jsx)($d,{index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})),tf=({selector:e,enable:t})=>{let[n,r]=(0,F.useState)(0),{useDiffContext:i}=Xd(),{id:a,mounted:o,dom:s}=i.useShallowStableSelector(e=>({id:e.id,mounted:e.mounted,dom:e.dom}));return(0,F.useEffect)(()=>{if(t){let t=Ad(s).querySelector(`#diff-root${a}`)?.querySelector(e);if(!t)return;let n=t,i=()=>{let e=t?.getBoundingClientRect();r(e?.width??0)};i();let o=()=>{var e,t;(e=n?.__observeCallback)==null||e.delete(i),n?.__observeCallback?.size===0&&((t=n.__observeInstance)==null||t.disconnect(),n.removeAttribute(`data-observe`),delete n.__observeCallback,delete n.__observeInstance)};if(n.__observeCallback)return n.__observeCallback.add(i),()=>o();n.__observeCallback=new Set,n.__observeCallback.add(i);let c=new ResizeObserver(()=>(n?.__observeCallback)?.forEach(e=>e()));return n.__observeInstance=c,c.observe(n),n.setAttribute(`data-observe`,`height`),()=>o()}},[e,t,a,o,s]),n},nf=({selector:e,wrapper:t,side:n,enable:r})=>{let{useDiffContext:i}=Xd(),{id:a,mounted:o,dom:s}=i.useShallowStableSelector(e=>({id:e.id,mounted:e.mounted,dom:e.dom}));(0,F.useEffect)(()=>{if(r){let r=Ad(s).querySelector(`#diff-root${a}`),i=Array.from(r?.querySelectorAll(e)||[]),o=t?Array.from(r?.querySelectorAll(t)||[]):i;if(i.length===2&&o.length===2){let e=i[0],t=i[1],r=o[0],a=o[1],s=e.getAttribute(`data-side`)===n?e:t,c=s,l=()=>{e.style.height=`auto`,t.style.height=`auto`;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=Math.max(n.height,i.height);r.style.height=o+`px`,a.style.height=o+`px`,r.setAttribute(`data-sync-height`,String(o)),a.setAttribute(`data-sync-height`,String(o))};l();let u=()=>{var e,t;(e=c?.__observeCallback)==null||e.delete(l),c?.__observeCallback?.size===0&&((t=c.__observeInstance)==null||t.disconnect(),c.removeAttribute(`data-observe`),delete c.__observeCallback,delete c.__observeInstance)};if(c.__observeCallback)return c.__observeCallback.add(l),()=>u();c.__observeCallback=new Set,c.__observeCallback.add(l);let d=new ResizeObserver(()=>(c?.__observeCallback)?.forEach(e=>e()));return c.__observeInstance=d,d.observe(s),s.setAttribute(`data-observe`,`height`),()=>u()}}},[e,r,n,a,t,o,s])},rf=({index:e,diffFile:t,oldLineExtend:n,newLineExtend:r,side:i,lineNumber:a})=>{let{useDiffContext:o}=Xd(),s=t.getSplitLeftLine(e),c=t.getSplitRightLine(e),l=o.useShallowStableSelector(e=>e.renderExtendLine),u=i===z.old?n:r,d=i===z.old?z.new:z.old,f=i===z.old?s.lineNumber:c.lineNumber,p=u?.data!==void 0&&u?.data!==null,m=n?.data!==void 0&&n?.data!==null||r?.data!==void 0&&r?.data!==null,h=m&&l?.({diffFile:t,side:i,lineNumber:f??-1,data:u?.data,onUpdate:t.notifyAll});nf({selector:`div[data-line="${a}-extend-content"]`,wrapper:`tr[data-line="${a}-extend"]`,side:z[p?i:d],enable:m&&typeof l==`function`});let g=tf({selector:i===z.old?`.old-diff-table-wrapper`:`.new-diff-table-wrapper`,enable:p&&typeof l==`function`});return l?(0,I.jsx)(`tr`,{"data-line":`${a}-extend`,"data-state":`extend`,"data-side":z[i],className:`diff-line diff-line-extend`,children:p?(0,I.jsx)(`td`,{className:`diff-line-extend-${z[i]}-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${a}-extend-content`,"data-side":z[i],className:`diff-line-extend-wrapper sticky left-0 z-[1]`,style:{width:g},children:g>0&&h})}):(0,I.jsx)(`td`,{className:`diff-line-extend-${z[i]}-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${a}-extend-content`,"data-side":z[i]})})}):null},af=({index:e,diffFile:t,side:n,lineNumber:r})=>{let{useDiffContext:i}=Xd(),a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),{oldLineExtend:s,newLineExtend:c}=i(F.useCallback(e=>({oldLineExtend:e.extendData?.oldFile?.[a?.lineNumber??-1],newLineExtend:e.extendData?.newFile?.[o?.lineNumber??-1]}),[a?.lineNumber,o?.lineNumber])),l=s?.data||c?.data,u=t.getExpandEnabled(),d=n===z.old?a:o;return!l||d.isHidden&&u?null:(0,I.jsx)(rf,{side:n,index:e,diffFile:t,lineNumber:r,oldLineExtend:s,newLineExtend:c})},of=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z`})}),sf=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z`})}),cf=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z`})}),lf=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=t.getExpandEnabled();nf({selector:`tr[data-line="${r}-hunk"]`,side:z[z.old],enable:n===z.new});let o=n===z.old,s=a&&i&&i.splitInfo,c=i&&i.splitInfo&&i.splitInfo.endHiddenIndex-i.splitInfo.startHiddenIndex<Hs,l=i&&i.isFirst,u=i&&i.isLast;return(0,I.jsx)(`tr`,{"data-line":`${r}-hunk`,"data-state":`hunk`,"data-side":z[n],className:`diff-line diff-line-hunk`,children:o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:s?l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):u?(0,I.jsx)(`button`,{className:`diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:i.splitInfo?.plainText||i.text})})]}):(0,I.jsx)(`td`,{className:`diff-line-hunk-placeholder select-none`,colSpan:2,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})})})},uf=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=t.getExpandEnabled();nf({selector:`tr[data-line="${r}-hunk"]`,side:z[z.old],enable:n===z.new});let o=a&&i&&i.splitInfo,s=i&&i.splitInfo&&i.splitInfo.endHiddenIndex-i.splitInfo.startHiddenIndex<Hs,c=i&&i.isFirst,l=i&&i.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${r}-hunk`,"data-state":`hunk`,"data-side":z[n],className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:o?c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:i.splitInfo?.plainText||i.text})})]})},df=({index:e,diffFile:t,side:n,lineNumber:r})=>{let{useDiffContext:i}=Xd(),a=i.useShallowStableSelector(e=>e.mode);return a===Id.SplitGitHub||a===Id.Split||a===Id.Unified?(0,I.jsx)(lf,{index:e,diffFile:t,side:n,lineNumber:r}):(0,I.jsx)(uf,{index:e,diffFile:t,side:n,lineNumber:r})},ff=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=i&&i.splitInfo&&i.splitInfo.startHiddenIndex<i.splitInfo.endHiddenIndex,o=i&&t._getIsPureDiffRender()&&!i.splitInfo;return!a&&!o?null:(0,I.jsx)(df,{index:e,diffFile:t,side:n,lineNumber:r})},pf=({index:e,side:t,diffFile:n,lineNumber:r})=>{let{useWidget:i}=Qd(),{useDiffContext:a}=Xd(),o=n.getSplitLeftLine(e),s=n.getSplitRightLine(e),c=i.useShallowStableSelector(e=>e.widgetSide),l=i.getReadonlyState().widgetLineNumber,u=i.getReadonlyState().setWidget,d=o.lineNumber&&c===z.old&&l===o.lineNumber,f=s.lineNumber&&c===z.new&&l===s.lineNumber,p=t===z.old?o:s,m=t===z.old?z.new:z.old,h=t===z.old?d:f,g=d||f,_=a.useShallowStableSelector(e=>e.renderWidgetLine),v=h&&_?.({diffFile:n,side:t,lineNumber:p.lineNumber??-1,onClose:()=>u({})});nf({selector:`div[data-line="${r}-widget-content"]`,wrapper:`tr[data-line="${r}-widget"]`,side:z[h?t:m],enable:!!g&&typeof _==`function`});let y=tf({selector:t===z.old?`.old-diff-table-wrapper`:`.new-diff-table-wrapper`,enable:!!h&&typeof _==`function`});return _?(0,I.jsx)(`tr`,{"data-line":`${r}-widget`,"data-state":`widget`,"data-side":z[t],className:`diff-line diff-line-widget`,children:h?(0,I.jsx)(`td`,{className:`diff-line-widget-${z[t]}-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${r}-widget-content`,"data-side":z[t],className:`diff-line-widget-wrapper sticky left-0 z-[1]`,style:{width:y},children:y>0&&v})}):(0,I.jsx)(`td`,{className:`diff-line-widget-${z[t]}-placeholder p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${r}-widget-content`,"data-side":z[t]})})}):null},mf=({index:e,side:t,diffFile:n,lineNumber:r})=>{let{useWidget:i}=Qd();return i.useShallowSelector(F.useCallback(t=>{let r=t.widgetLineNumber,i=t.widgetSide,a=n.getSplitLeftLine(e),o=n.getSplitRightLine(e),s=a.lineNumber&&i===z.old&&r===a.lineNumber,c=o.lineNumber&&i===z.new&&r===o.lineNumber;return s||c},[n,e]),(e,t)=>e===t)?(0,I.jsx)(pf,{index:e,side:t,diffFile:n,lineNumber:r}):null},hf=({side:e,diffFile:t,enableAddWidget:n,enableHighlight:r,onMouseDown:i})=>{let a=e===z.new?`new-diff-table`:`old-diff-table`,o=Fo(t),s=t.getContentVersion();return(0,I.jsxs)(`table`,{className:a+` w-full border-collapse border-spacing-0`,"data-mode":z[e],children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`diff-table-${z[e]}-num-col`}),(0,I.jsx)(`col`,{className:`diff-table-${z[e]}-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsxs)(`th`,{scope:`col`,children:[z[e],` line number`]}),(0,I.jsxs)(`th`,{scope:`col`,children:[z[e],` line content`]})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:i,children:[o.map(i=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(ff,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t}),(0,I.jsx)(ef,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t,enableAddWidget:n,enableHighlight:r,contentVersion:s}),(0,I.jsx)(mf,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t}),(0,I.jsx)(af,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t})]},i.index)),(0,I.jsx)(ff,{side:e,index:t.splitLineLength,lineNumber:t.splitLineLength,diffFile:t})]})]})},gf=(0,F.memo)(({diffFile:e})=>{let t=(0,F.useRef)(null),n=(0,F.useRef)(null),r=(0,F.useRef)(null),i=(0,F.useRef)(void 0),a=Math.max(e.splitLineLength,e.fileLineLength),{useDiffContext:o}=Xd(),{fontSize:s,enableAddWidget:c,enableHighlight:l}=o.useShallowStableSelector(e=>({fontSize:e.fontSize,enableAddWidget:e.enableAddWidget,enableHighlight:e.enableHighlight}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount),(0,F.useEffect)(()=>{let e=t.current,r=n.current;if(e&&r)return kd(e,r)},[]);let u=F.useMemo(()=>({fontSize:s+`px`,fontFamily:`Menlo, Consolas, monospace`}),[s]),d=zd({text:a.toString(),font:u}),f=Math.max(40,d+20),p=t=>{if(r.current){if(!t)r.current.textContent=``;else{let t=`diff-root${e.getId()}`;r.current.textContent=`#${t} [data-state="extend"] {user-select: none} \n#${t} [data-state="hunk"] {user-select: none} \n#${t} [data-state="widget"] {user-select: none}`}}},m=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let r=jd(n);if(!(r&&r!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`),t=n.getAttribute(`data-side`);if(t&&i.current!==z[t]&&(i.current=z[t],p(z[t]),Od()),e){if(e===`extend`||e===`hunk`||e===`widget`){i.current!==void 0&&(i.current=void 0,p(void 0),Od());return}return}n=n.parentElement}};return(0,I.jsxs)(`div`,{className:`split-diff-view split-diff-view-normal flex w-full basis-[50%]`,children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:r}),(0,I.jsx)(`div`,{className:`old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,ref:t,style:{[Nd]:`${Math.round(f)}px`,overscrollBehaviorX:`none`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsx)(hf,{side:z.old,diffFile:e,enableAddWidget:!!c,enableHighlight:!!l,onMouseDown:m})}),(0,I.jsx)(`div`,{className:`diff-split-line w-[1.5px]`,style:{backgroundColor:`var(${dd})`}}),(0,I.jsx)(`div`,{className:`new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,ref:n,style:{[Nd]:`${Math.round(f)}px`,overscrollBehaviorX:`none`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsx)(hf,{side:z.new,diffFile:e,enableAddWidget:!!c,enableHighlight:!!l,onMouseDown:m})})]})});gf.displayName=`DiffSplitViewNormal`;var _f=({index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})=>{let a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),s=t.getOldSyntaxLine(a?.lineNumber??-1),c=t.getOldPlainLine(a.lineNumber??-1),l=t.getNewSyntaxLine(o?.lineNumber??-1),u=t.getNewPlainLine(o.lineNumber??-1),d=!!a?.diff||!!o?.diff,f=Ha(a?.diff)||Ha(o?.diff),p=a?.diff?.type===Ba.Delete,m=o?.diff?.type===Ba.Add,{useDiffContext:h}=Xd(),g=h.getReadonlyState().onAddWidgetClick,{useWidget:_}=Qd(),v=_.getReadonlyState().setWidget,y=!!a.lineNumber,b=!!o.lineNumber,x=Ed(!1,p,d),S=Dd(!1,p,d),C=Ed(m,!1,d),w=Dd(m,!1,d);return(0,I.jsxs)(`tr`,{"data-line":n,"data-state":d?`diff`:`plain`,className:`diff-line`,children:[y?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`,"data-side":z[z.old],style:{backgroundColor:S,color:`var(${d?gd:_d})`},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:a.lineNumber??-1,side:z.old,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":a.lineNumber,style:{opacity:f?void 0:.5},children:a.lineNumber})]}),(0,I.jsxs)(`td`,{className:`diff-line-old-content group relative pr-[10px] align-top`,"data-side":z[z.old],style:{backgroundColor:x},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:a.lineNumber??-1,side:z.old,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute right-[100%] z-[1] translate-x-[50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(Jd,{enableWrap:!0,diffFile:t,rawLine:a.value||``,diffLine:a.diff,plainLine:c,syntaxLine:s,enableHighlight:i})]})]}):(0,I.jsx)(`td`,{className:`diff-line-old-placeholder select-none`,"data-side":z[z.old],style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`span`,{children:` `})}),b?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top`,"data-side":z[z.new],style:{backgroundColor:w,color:`var(${d?gd:_d})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:o.lineNumber??-1,side:z.new,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":o.lineNumber,style:{opacity:f?void 0:.5},children:o.lineNumber})]}),(0,I.jsxs)(`td`,{className:`diff-line-new-content group relative pr-[10px] align-top`,"data-side":z[z.new],style:{backgroundColor:C},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:o.lineNumber??-1,side:z.new,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute right-[100%] z-[1] translate-x-[50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(Jd,{enableWrap:!0,diffFile:t,rawLine:o.value||``,diffLine:o.diff,plainLine:u,syntaxLine:l,enableHighlight:i})]})]}):(0,I.jsx)(`td`,{className:`diff-line-new-placeholder select-none border-l-[1px]`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},"data-side":z[z.new],colSpan:2,children:(0,I.jsx)(`span`,{children:` `})})]})},vf=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})=>{let a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e);return a?.isHidden&&o?.isHidden?null:(0,I.jsx)(_f,{index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})}),yf=({index:e,diffFile:t,lineNumber:n,oldLineExtend:r,newLineExtend:i})=>{let{useDiffContext:a}=Xd(),o=t.getSplitLeftLine(e),s=t.getSplitRightLine(e),c=a.useShallowStableSelector(e=>e.renderExtendLine);if(!c)return null;let l=r?.data&&c?.({diffFile:t,side:z.old,lineNumber:o.lineNumber??-1,data:r.data,onUpdate:t.notifyAll}),u=i?.data&&c?.({diffFile:t,side:z.new,lineNumber:s.lineNumber??-1,data:i.data,onUpdate:t.notifyAll});return(0,I.jsxs)(`tr`,{"data-line":`${n}-extend`,"data-state":`extend`,className:`diff-line diff-line-extend`,children:[l?(0,I.jsx)(`td`,{className:`diff-line-extend-old-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-extend-wrapper`,children:l})}):(0,I.jsx)(`td`,{className:`diff-line-extend-old-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2}),u?(0,I.jsx)(`td`,{className:`diff-line-extend-new-content border-l-[1px] p-0`,style:{borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-extend-wrapper`,children:u})}):(0,I.jsx)(`td`,{className:`diff-line-extend-new-placeholder select-none border-l-[1px] p-0`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2})]})},bf=({index:e,diffFile:t,lineNumber:n})=>{let{useDiffContext:r}=Xd(),i=t.getSplitLeftLine(e),a=t.getSplitRightLine(e),{oldLineExtend:o,newLineExtend:s}=r(F.useCallback(e=>({oldLineExtend:e.extendData?.oldFile?.[i?.lineNumber??-1],newLineExtend:e.extendData?.newFile?.[a?.lineNumber??-1]}),[i?.lineNumber,a?.lineNumber])),c=o?.data||s?.data,l=t.getExpandEnabled();return!c||(i?.isHidden||a?.isHidden)&&l?null:(0,I.jsx)(yf,{index:e,diffFile:t,lineNumber:n,oldLineExtend:o,newLineExtend:s})},xf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=t.getExpandEnabled()&&r&&r.splitInfo,a=r&&r.splitInfo&&r.splitInfo.endHiddenIndex-r.splitInfo.startHiddenIndex<Hs,o=r&&r.isFirst,s=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},colSpan:3,children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})})]})},Sf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=t.getExpandEnabled()&&r&&r.splitInfo,a=r&&r.splitInfo&&r.splitInfo.endHiddenIndex-r.splitInfo.startHiddenIndex<Hs,o=r&&r.isFirst,s=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content relative pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})})]})},Cf=({index:e,diffFile:t,lineNumber:n})=>{let{useDiffContext:r}=Xd(),i=r.useShallowStableSelector(e=>e.mode);return i===Id.SplitGitHub||i===Id.Split||i===Id.Unified?(0,I.jsx)(xf,{index:e,diffFile:t,lineNumber:n}):(0,I.jsx)(Sf,{index:e,diffFile:t,lineNumber:n})},wf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=r&&r.splitInfo&&r.splitInfo.startHiddenIndex<r.splitInfo.endHiddenIndex,a=r&&t._getIsPureDiffRender()&&!r.splitInfo;return!i&&!a?null:(0,I.jsx)(Cf,{index:e,diffFile:t,lineNumber:n})},Tf=({index:e,diffFile:t,lineNumber:n})=>{let{useWidget:r}=Qd(),i=r.getReadonlyState().setWidget,{useDiffContext:a}=Xd(),o=a.useShallowStableSelector(e=>e.renderWidgetLine),s=t.getSplitLeftLine(e),c=t.getSplitRightLine(e),l=r.useShallowStableSelector(e=>e.widgetSide),u=r.getReadonlyState().widgetLineNumber,d=s.lineNumber&&l===z.old&&u===s.lineNumber,f=c.lineNumber&&l===z.new&&u===c.lineNumber,p=d&&o?.({diffFile:t,side:z.old,lineNumber:s.lineNumber??-1,onClose:()=>i({})}),m=f&&o?.({diffFile:t,side:z.new,lineNumber:c.lineNumber??-1,onClose:()=>i({})});return o?(0,I.jsxs)(`tr`,{"data-line":`${n}-widget`,"data-state":`widget`,className:`diff-line diff-line-widget`,children:[p?(0,I.jsx)(`td`,{className:`diff-line-widget-old-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-widget-wrapper`,children:p})}):(0,I.jsx)(`td`,{className:`diff-line-widget-old-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2}),m?(0,I.jsx)(`td`,{className:`diff-line-widget-new-content border-l-[1px] p-0`,colSpan:2,style:{borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:(0,I.jsx)(`div`,{className:`diff-line-widget-wrapper`,children:m})}):(0,I.jsx)(`td`,{className:`diff-line-widget-new-placeholder select-none border-l-[1px] p-0`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2})]}):null},Ef=({index:e,diffFile:t,lineNumber:n})=>{let{useWidget:r}=Qd();return r.useShallowSelector(F.useCallback(n=>{let r=n.widgetLineNumber,i=n.widgetSide,a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),s=a.lineNumber&&i===z.old&&r===a.lineNumber,c=o.lineNumber&&i===z.new&&r===o.lineNumber;return s||c},[t,e]),(e,t)=>e===t)?(0,I.jsx)(Tf,{index:e,diffFile:t,lineNumber:n}):null},Df=(0,F.memo)(({diffFile:e})=>{let t=Math.max(e.splitLineLength,e.fileLineLength),{useDiffContext:n}=Xd(),r=(0,F.useRef)(null),i=(0,F.useRef)(void 0),{fontSize:a,enableAddWidget:o,enableHighlight:s}=n.useShallowStableSelector(e=>({fontSize:e.fontSize,enableAddWidget:e.enableAddWidget,enableHighlight:e.enableHighlight}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount);let c=(0,F.useMemo)(()=>({fontSize:a+`px`,fontFamily:`Menlo, Consolas, monospace`}),[a]),l=zd({text:t.toString(),font:c}),u=Math.max(40,l+20),d=Fo(e),f=e.getContentVersion(),p=t=>{if(r.current){if(!t)r.current.textContent=``;else{let n=`diff-root${e.getId()}`,i=t===z.old?z.new:z.old;r.current.textContent=`#${n} [data-side="${z[i]}"] {user-select: none} \n#${n} [data-state="extend"] {user-select: none} \n#${n} [data-state="hunk"] {user-select: none} \n#${n} [data-state="widget"] {user-select: none}`}}},m=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let r=jd(n);if(!(r&&r!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`),t=n.getAttribute(`data-side`);if(t&&i.current!==z[t]&&(i.current=z[t],p(z[t]),Od()),e){if(e===`extend`||e===`hunk`||e===`widget`){i.current!==void 0&&(i.current=void 0,p(void 0),Od());return}return}n=n.parentElement}};return(0,I.jsx)(`div`,{className:`split-diff-view split-diff-view-wrap w-full`,children:(0,I.jsxs)(`div`,{className:`diff-table-wrapper w-full`,style:{[Nd]:`${Math.round(u)}px`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:r}),(0,I.jsxs)(`table`,{className:`diff-table w-full table-fixed border-collapse border-spacing-0`,children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`diff-table-old-num-col`,width:Math.round(u)}),(0,I.jsx)(`col`,{className:`diff-table-old-content-col`}),(0,I.jsx)(`col`,{className:`diff-table-new-num-col`,width:Math.round(u)}),(0,I.jsx)(`col`,{className:`diff-table-new-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`old line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`old line content`}),(0,I.jsx)(`th`,{scope:`col`,children:`new line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`new line content`})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:m,children:[d.map(t=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(wf,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(vf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableAddWidget:!!o,enableHighlight:!!s,contentVersion:f}),(0,I.jsx)(Ef,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(bf,{index:t.index,lineNumber:t.lineNumber,diffFile:e})]},t.index)),(0,I.jsx)(wf,{index:e.splitLineLength,lineNumber:e.splitLineLength,diffFile:e})]})]})]})})});Df.displayName=`DiffSplitViewWrap`;var Of=(e,t)=>Xu(()=>{let n=_u(),r=e=>n.value=e,i=_u(t),a=e=>i.value=e,o=_u(e.diffViewMode),s=e=>o.value=e,c=_u(e.isMounted),l=e=>c.value=e,u=_u(e.diffViewWrap),d=e=>u.value=e,f=_u(e.diffViewAddWidget),p=e=>f.value=e,m=_u(e.diffViewHighlight),h=e=>m.value=e,g=_u(e.diffViewFontSize),_=e=>g.value=e,v=_u({oldFile:{...e.extendData?.oldFile},newFile:{...e.extendData?.newFile}}),y=e=>{let t=e||{},n=Object.keys(v.value.oldFile||{}),r=Object.keys(t.oldFile||{});for(let e of n)r.includes(e)||delete v.value.oldFile[e];for(let e of r)v.value.oldFile[e]=t.oldFile[e];let i=Object.keys(v.value.newFile||{}),a=Object.keys(t.newFile||{});for(let e of i)a.includes(e)||delete v.value.newFile[e];for(let e of a)v.value.newFile[e]=t.newFile[e]},b=_u(e.renderWidgetLine),x=e=>b.value=e,S=_u(e.renderExtendLine),C=e=>S.value=e,w=_u(e.onCreateUseWidgetHook),T=e=>w.value=e,E={current:e.onAddWidgetClick};return{id:i,setId:a,dom:n,setDom:r,mode:o,setMode:s,mounted:c,setMounted:l,enableWrap:u,setEnableWrap:d,enableAddWidget:f,setEnableAddWidget:p,enableHighlight:m,setEnableHighlight:h,fontSize:g,setFontSize:_,extendData:v,setExtendData:y,renderWidgetLine:b,setRenderWidgetLine:x,renderExtendLine:S,setRenderExtendLine:C,onAddWidgetClick:E,setOnAddWidgetClick:e=>E.current=e.current,onCreateUseWidgetHook:w,setOnCreateUseWidgetHook:T}}),kf=e=>Xu(()=>{let t=_u(void 0),n=_u(void 0);return{widgetSide:t,widgetLineNumber:n,setWidget:({side:r,lineNumber:i})=>{var a;let{renderWidgetLine:o}=((a=e.current)?.getReadonlyState)?.call(a)||{};typeof o==`function`&&(t.value=r,n.value=i)}}}),Af=(0,F.memo)(({diffFile:e})=>{let{useDiffContext:t}=Xd(),n=(0,F.useRef)(t);n.current=t;let{enableWrap:r,onCreateUseWidgetHook:i}=t.useShallowStableSelector(e=>({enableWrap:e.enableWrap,onCreateUseWidgetHook:e.onCreateUseWidgetHook})),a=(0,F.useMemo)(()=>kf(n),[]),o=(0,F.useMemo)(()=>({useWidget:a}),[a]);return(0,F.useEffect)(()=>{let{setWidget:e}=a.getReadonlyState();e({})},[e,a]),(0,F.useEffect)(()=>{i?.(a)},[a,i]),(0,I.jsx)(Zd.Provider,{value:o,children:r?(0,I.jsx)(Df,{diffFile:e}):(0,I.jsx)(gf,{diffFile:e})})});Af.displayName=`DiffSplitView`;var jf=({index:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,lineNumber:a,diffFile:o,setWidget:s,enableWrap:c,enableAddWidget:l,enableHighlight:u,onAddWidgetClick:d})=>(0,I.jsxs)(`tr`,{"data-line":e,"data-state":`diff`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${gd})`,backgroundColor:`var(${pd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:[l&&(0,I.jsx)(Vd,{index:e-1,lineNumber:a,diffFile:o,side:z.old,onWidgetClick:d,onOpenAddWidget:(e,t)=>s({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex`,children:[(0,I.jsx)(`span`,{"data-line-old-num":a,className:`inline-block w-[50%]`,children:a}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{className:`inline-block w-[50%]`})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:`var(${ud})`},children:(0,I.jsx)(Jd,{enableWrap:c,diffFile:o,enableHighlight:u,rawLine:n,diffLine:t,plainLine:r,syntaxLine:i})})]}),Mf=({index:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,lineNumber:a,diffFile:o,setWidget:s,enableWrap:c,enableAddWidget:l,enableHighlight:u,onAddWidgetClick:d})=>(0,I.jsxs)(`tr`,{"data-line":e,"data-state":`diff`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${gd})`,backgroundColor:`var(${fd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:[l&&(0,I.jsx)(Vd,{index:e-1,lineNumber:a,diffFile:o,side:z.new,onWidgetClick:d,onOpenAddWidget:(e,t)=>s({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex`,children:[(0,I.jsx)(`span`,{className:`inline-block w-[50%]`}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{"data-line-new-num":a,className:`inline-block w-[50%]`,children:a})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:`var(${ld})`},children:(0,I.jsx)(Jd,{enableWrap:c,diffFile:o,enableHighlight:u,rawLine:n,diffLine:t,plainLine:r,syntaxLine:i})})]}),Nf=({index:e,diffFile:t,lineNumber:n,enableWrap:r,enableAddWidget:i,enableHighlight:a})=>{let o=t.getUnifiedLine(e),{useDiffContext:s}=Xd(),c=s.getReadonlyState().onAddWidgetClick,{useWidget:l}=Qd(),u=l.getReadonlyState().setWidget,d=o.diff,f=Ha(o.diff),p=o.value||``,m=o.diff,h=o.newLineNumber,g=o.oldLineNumber,_=h?t.getNewSyntaxLine(h):g?t.getOldSyntaxLine(g):void 0,v=h?t.getNewPlainLine(h):g?t.getOldPlainLine(g):void 0;return f?o.oldLineNumber?(0,I.jsx)(jf,{index:n,enableWrap:r,diffFile:t,rawLine:p,diffLine:m,setWidget:u,plainLine:v,syntaxLine:_,enableHighlight:a,enableAddWidget:i,lineNumber:o.oldLineNumber,onAddWidgetClick:(...e)=>c.current?.call(c,...e)}):(0,I.jsx)(Mf,{index:n,enableWrap:r,rawLine:p,diffLine:m,diffFile:t,setWidget:u,plainLine:v,syntaxLine:_,enableHighlight:a,enableAddWidget:i,lineNumber:o.newLineNumber,onAddWidgetClick:(...e)=>c.current?.call(c,...e)}):(0,I.jsxs)(`tr`,{"data-line":n,"data-state":o.diff?`diff`:`plain`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${d?gd:_d})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`,backgroundColor:d?`var(${vd})`:`var(${hd})`},children:[i&&d&&(0,I.jsx)(Vd,{index:e,diffFile:t,lineNumber:o.newLineNumber??-1,side:z.new,onWidgetClick:(...e)=>c.current?.call(c,...e),onOpenAddWidget:(e,t)=>u({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex opacity-[0.5]`,children:[(0,I.jsx)(`span`,{"data-line-old-num":o.oldLineNumber,className:`inline-block w-[50%]`,children:o.oldLineNumber}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{"data-line-new-num":o.newLineNumber,className:`inline-block w-[50%]`,children:o.newLineNumber})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:d?`var(${md})`:`var(${hd})`},children:(0,I.jsx)(Jd,{enableWrap:r,diffFile:t,enableHighlight:a,rawLine:p,diffLine:m,plainLine:v,syntaxLine:_})})]})},Pf=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,enableWrap:r,enableHighlight:i,enableAddWidget:a})=>t.getUnifiedLine(e)?.isHidden?null:(0,I.jsx)(Nf,{index:e,diffFile:t,lineNumber:n,enableWrap:r,enableHighlight:i,enableAddWidget:a})),Ff=({index:e,diffFile:t,lineNumber:n,enableWrap:r,oldLineExtend:i,newLineExtend:a})=>{let{useDiffContext:o}=Xd(),s=o.useShallowStableSelector(e=>e.renderExtendLine),c=t.getUnifiedLine(e),l=tf({selector:`.unified-diff-table-wrapper`,enable:typeof s==`function`});return s?(0,I.jsx)(`tr`,{"data-line":`${n}-extend`,"data-state":`extend`,className:`diff-line diff-line-extend`,children:(0,I.jsx)(`td`,{className:`diff-line-extend-content p-0 align-top`,colSpan:2,children:(0,I.jsxs)(`div`,{className:`diff-line-extend-wrapper sticky left-0 z-[1]`,style:{width:l},children:[(r?!0:l>0)&&i?.data!==void 0&&i?.data!==null&&s?.({diffFile:t,side:z.old,lineNumber:c.oldLineNumber??-1,data:i.data,onUpdate:t.notifyAll}),(r?!0:l>0)&&a?.data!==void 0&&a?.data!==null&&s?.({diffFile:t,side:z.new,lineNumber:c.newLineNumber??-1,data:a.data,onUpdate:t.notifyAll})]})})}):null},If=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useDiffContext:i}=Xd(),a=t.getUnifiedLine(e),{oldLineExtend:o,newLineExtend:s}=i((0,F.useCallback)(e=>({oldLineExtend:e.extendData?.oldFile?.[a?.oldLineNumber??-1],newLineExtend:e.extendData?.newFile?.[a?.newLineNumber??-1]}),[a.oldLineNumber,a.newLineNumber]));return!(o?.data||s?.data)||!a||a.isHidden?null:(0,I.jsx)(Ff,{index:e,diffFile:t,lineNumber:n,enableWrap:r,oldLineExtend:o,newLineExtend:s})},Lf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getUnifiedHunkLine(e),i=t.getExpandEnabled(),{useDiffContext:a}=Xd(),o=a.useShallowStableSelector(e=>e.enableWrap),s=i&&r&&r.unifiedInfo,c=r&&r.unifiedInfo&&r.unifiedInfo.endHiddenIndex-r.unifiedInfo.startHiddenIndex<Hs,l=r&&r.isFirst,u=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:s?l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onUnifiedHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):u?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onUnifiedHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onUnifiedHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onUnifiedHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onUnifiedHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{whiteSpace:o?`pre-wrap`:`pre`,wordBreak:o?`break-all`:`initial`,color:`var(${xd})`},children:r.unifiedInfo?.plainText||r.text})})]})},Rf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getUnifiedHunkLine(e),i=r&&r.unifiedInfo&&r.unifiedInfo.startHiddenIndex<r.unifiedInfo.endHiddenIndex,a=r&&t._getIsPureDiffRender()&&!r.unifiedInfo;return!i&&!a?null:(0,I.jsx)(Lf,{index:e,diffFile:t,lineNumber:n})},zf=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useWidget:i}=Qd(),a=i.getReadonlyState().setWidget,o=t.getUnifiedLine(e),s=()=>a({}),c=i.getReadonlyState().widgetSide,l=i.getReadonlyState().widgetLineNumber,u=o.oldLineNumber&&c===z.old&&l===o.oldLineNumber,d=o.newLineNumber&&c===z.new&&l===o.newLineNumber,{useDiffContext:f}=Xd(),p=f.useShallowStableSelector(e=>e.renderWidgetLine),m=tf({selector:`.unified-diff-table-wrapper`,enable:typeof p==`function`});return p?(0,I.jsx)(`tr`,{"data-line":`${n}-widget`,"data-state":`widget`,className:`diff-line diff-line-widget`,children:(0,I.jsx)(`td`,{className:`diff-line-widget-content p-0`,colSpan:2,children:(0,I.jsxs)(`div`,{className:`diff-line-widget-wrapper sticky left-0 z-[1]`,style:{width:m},children:[(r?!0:m>0)&&u&&p?.({diffFile:t,side:z.old,lineNumber:o.oldLineNumber??-1,onClose:s}),(r?!0:m>0)&&d&&p?.({diffFile:t,side:z.new,lineNumber:o.newLineNumber??-1,onClose:s})]})})}):null},Bf=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useWidget:i}=Qd();return i.useShallowSelector(F.useCallback(n=>{let r=n.widgetLineNumber,i=n.widgetSide,a=t.getUnifiedLine(e),o=a.oldLineNumber&&i===z.old&&r===a.oldLineNumber,s=a.newLineNumber&&i===z.new&&r===a.newLineNumber;return o||s},[t,e]),(e,t)=>e===t)?(0,I.jsx)(zf,{index:e,diffFile:t,lineNumber:n,enableWrap:r}):null},Vf=(0,F.memo)(({diffFile:e})=>{let{useDiffContext:t}=Xd(),n=(0,F.useRef)(null),r=(0,F.useRef)(void 0),i=(0,F.useRef)(t);i.current=t;let a=(0,F.useMemo)(()=>kf(i),[]),o=(0,F.useMemo)(()=>({useWidget:a}),[a]),{fontSize:s,enableWrap:c,enableHighlight:l,enableAddWidget:u,onCreateUseWidgetHook:d}=t.useShallowStableSelector(e=>({fontSize:e.fontSize,enableWrap:e.enableWrap,enableHighlight:e.enableHighlight,enableAddWidget:e.enableAddWidget,onCreateUseWidgetHook:e.onCreateUseWidgetHook}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount),(0,F.useEffect)(()=>{let{setWidget:e}=a.getReadonlyState();e({})},[e,a]),(0,F.useEffect)(()=>{d?.(a)},[a,d]);let f=zd({text:Math.max(e.unifiedLineLength,e.fileLineLength).toString(),font:(0,F.useMemo)(()=>({fontSize:s+`px`,fontFamily:`Menlo, Consolas, monospace`}),[s])}),p=Math.max(20,f+5),m=Io(e),h=e.getContentVersion(),g=t=>{if(n.current){if(!t)n.current.textContent=``;else{let t=`diff-root${e.getId()}`;n.current.textContent=`#${t} [data-state="extend"] {user-select: none} \n#${t} [data-state="hunk"] {user-select: none} \n#${t} [data-state="widget"] {user-select: none}`}}},_=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let i=jd(n);if(!(i&&i!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`);if(e){if(e===`extend`||e===`hunk`||e===`widget`){r.current!==void 0&&(r.current=void 0,g(void 0),Od());return}r.current!==z.new&&(r.current=z.new,g(z.new),Od());return}n=n.parentElement}};return(0,I.jsx)(Zd.Provider,{value:o,children:(0,I.jsxs)(`div`,{className:`unified-diff-view ${c?`unified-diff-view-wrap`:`unified-diff-view-normal`} w-full`,children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:n}),(0,I.jsx)(`div`,{className:`unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,style:{[Nd]:`${Math.round(p)}px`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsxs)(`table`,{className:`unified-diff-table w-full border-collapse border-spacing-0 ${c?`table-fixed`:``}`,children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`unified-diff-table-num-col`}),(0,I.jsx)(`col`,{className:`unified-diff-table-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`line content`})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:_,children:[m.map(t=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(Rf,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(Pf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c,enableHighlight:!!l,enableAddWidget:!!u,contentVersion:h}),(0,I.jsx)(Bf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c}),(0,I.jsx)(If,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c})]},t.index)),(0,I.jsx)(Rf,{index:e.unifiedLineLength,lineNumber:e.unifiedLineLength,diffFile:e})]})]})})]})})});Vf.displayName=`DiffUnifiedView`,No.name=`@git-diff-view/react`;var Hf=(0,F.memo)(e=>{let{diffFile:t,className:n,style:r,wrapperRef:i,diffViewMode:a,diffViewWrap:o,diffViewFontSize:s,diffViewHighlight:c,renderWidgetLine:l,renderExtendLine:u,extendData:d,diffViewAddWidget:f,onAddWidgetClick:p,onCreateUseWidgetHook:m,isMounted:h}=e,g=(0,F.useMemo)(()=>t.getId(),[t]),_=(0,F.useMemo)(()=>Of(e,g),[]);(0,F.useEffect)(()=>{let{id:e,setId:t,mode:n,setMode:r,mounted:i,setMounted:v,enableAddWidget:y,setEnableAddWidget:b,enableHighlight:x,setEnableHighlight:S,enableWrap:C,setEnableWrap:w,setExtendData:T,fontSize:E,setFontSize:D,onAddWidgetClick:O,setOnAddWidgetClick:k,renderExtendLine:A,setRenderExtendLine:ee,renderWidgetLine:j,setRenderWidgetLine:M,onCreateUseWidgetHook:N,setOnCreateUseWidgetHook:te}=_.getReadonlyState();g&&g!==e&&t(g),a&&a!==n&&r(a),i!==h&&v(h),f!==y&&b(!!f),c!==x&&S(!!c),o!==C&&w(!!o),d&&T(d),s&&s!==E&&D(s),p!==O.current&&k({current:p}),m!==N&&te(m),u!==A&&ee(u),l!==j&&M(l)},[_,s,c,a,o,f,g,h,l,u,d,p,m]),(0,F.useEffect)(()=>{i?.current&&_.getReadonlyState().setDom(i?.current)},[_,i]);let v=(0,F.useMemo)(()=>({useDiffContext:_}),[_]);return(0,I.jsx)(Yd.Provider,{value:v,children:(0,I.jsx)(`div`,{className:`diff-tailwindcss-wrapper`,"data-component":`git-diff-view`,"data-theme":t._getTheme()||`light`,"data-version":`0.1.8`,"data-highlighter":t._getHighlighterName(),ref:i,children:(0,I.jsx)(`div`,{className:`diff-style-root`,style:{[Md]:s+`px`},children:(0,I.jsx)(`div`,{id:h?`diff-root${g}`:void 0,className:`diff-view-wrapper`+(n?` ${n}`:``),style:r,children:a&Id.Split?(0,I.jsx)(Af,{diffFile:t}):(0,I.jsx)(Vf,{diffFile:t})})})})})}),Uf=(0,F.forwardRef)((e,t)=>{let{registerHighlighter:n,data:r,diffViewTheme:i,diffFile:a,...o}=e,s=(0,F.useMemo)(()=>{if(a){let e=Gs.createInstance({});return e._mergeFullBundle(a._getFullBundle()),e}return r?new Gs(r?.oldFile?.fileName||``,r?.oldFile?.content||``,r?.newFile?.fileName||``,r?.newFile?.content||``,r?.hunks||[],r?.oldFile?.fileLang||``,r?.newFile?.fileLang||``):null},[r,a]),c=(0,F.useRef)(null),l=Ld();return(0,F.useEffect)(()=>{if(a&&s)return a._addClonedInstance(s),()=>{a._delClonedInstance(s)}},[s,a]),(0,F.useEffect)(()=>{s&&(s.initTheme(i),s.initRaw(),s.buildSplitDiffLines(),s.buildUnifiedDiffLines())},[s,i]),(0,F.useEffect)(()=>{s&&e.diffViewHighlight&&(n?(n.name!==s._getHighlighterName()||n.type!==s._getHighlighterType()||n.type!==`class`)&&(s.initSyntax({registerHighlighter:n}),s.notifyAll()):(!s._getIsCloned()&&s._getHighlighterName()!==Ca.name||s._getHighlighterType()!==`class`)&&(s.initSyntax(),s.notifyAll()))},[s,e.diffViewHighlight,n,i]),(0,F.useEffect)(()=>{if(!s)return;let e=()=>{var e,t;(e=c.current)==null||e.setAttribute(`data-theme`,s._getTheme()||`light`),(t=c.current)==null||t.setAttribute(`data-highlighter`,s._getHighlighterName())};return e(),s.subscribe(e)},[s,i]),(0,F.useEffect)(()=>()=>(s?.clear)?.call(s),[s]),(0,F.useImperativeHandle)(t,()=>({getDiffFileInstance:()=>s}),[s]),s?(0,I.jsx)(Hf,{...o,diffFile:s,isMounted:l,wrapperRef:c,diffViewTheme:i,diffViewMode:o.diffViewMode||Id.SplitGitHub,diffViewFontSize:o.diffViewFontSize||14},s.getId()):null});Uf.displayName=`DiffView`;var Wf=Uf,Gf=e=>{let t=(0,F.useRef)(e);return t.current=e,(0,F.useCallback)((...e)=>t.current?.call(t,...e),[])},Kf=(e,t)=>{let n=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(n.current)return e();n.current=!0},t)};(0,F.forwardRef)((e,t)=>{let{enableMultiSelect:n=!0,extendData:r,onMultiSelectComplete:i,onMultiSelectChange:a,scopeMultiSelectToHunk:o,renderWidgetLine:s,onAddWidgetClick:c,diffViewMode:l=Id.SplitGitHub,...u}=e,d=Gf(a),f=Gf(i),p=Gf(o),m=(0,F.useRef)(null),h=(0,F.useRef)(null),g=(0,F.useRef)(null),_=(0,F.useRef)(void 0),v=!(l&Id.Split),y=(0,F.useCallback)(e=>{var t;_.current=e,(t=g.current)==null||t.setPreselectedLines(e||{old:[],new:[]})},[]);Kf(()=>{y(void 0)},[e.diffViewWrap,l]);let b=(0,F.useCallback)(()=>h.current?.getDiffFileInstance()??null,[]);(0,F.useEffect)(()=>{var e;let t=m.current,r=b();if(!t||!r||!n){(e=g.current)==null||e.destroy(),g.current=null;return}let i={enabled:n,isUnifiedMode:v,selectedClassName:qs.selected,onSelectionChange:(e,t)=>{var n,r;t.isSelecting?(n=m.current)==null||n.classList.add(qs.selecting):(r=m.current)==null||r.classList.remove(qs.selecting),t.isSelecting&&_.current&&y(void 0),d?.(e,t)},onSelectionComplete:e=>{var t;if((t=m.current)==null||t.classList.remove(qs.selecting),e&&e.lines.length>0){f?.(e);let t={[e.range.side]:[e.range.startLineNumber,e.range.endLineNumber]};y(t)}else y(void 0)},scopeToHunk:p};return g.current?(g.current.updateContainer(t),g.current.updateDiffFile(r),g.current.updateOptions(i)):g.current=wc(t,r,i),()=>{var e;(e=g.current)==null||e.destroy(),g.current=null}},[n,v,p,d,f,b,y]);let x=(0,F.useMemo)(()=>{if(!r)return;let e={};if(r.oldFile){e.oldFile={};for(let[t,n]of Object.entries(r.oldFile))e.oldFile[t]={data:n.data}}if(r.newFile){e.newFile={};for(let[t,n]of Object.entries(r.newFile))e.newFile[t]={data:n.data}}return e},[r]),S=(0,F.useCallback)(({lineNumber:e,side:t,diffFile:n,onClose:r})=>{if(!s)return null;let i=t===z.old?`old`:`new`,a=_.current?.[i],o=a?Math.min(...a):e,c=a?Math.max(...a):e;return s({lineNumber:c,fromLineNumber:o,side:t,diffFile:n,onClose:r})},[s]),C=(0,F.useCallback)(()=>g.current?.getSelectionResult()??null,[]),w=(0,F.useCallback)(()=>g.current?.getState()??{isSelecting:!1,startInfo:null,currentRange:null},[]),T=(0,F.useCallback)(()=>{var e;(e=g.current)==null||e.clearSelection()},[]),E=y;return(0,F.useImperativeHandle)(t,()=>({getDiffFileInstance:b,getSelectionResult:C,getSelectionState:w,clearSelection:T,setPreselectedLines:E}),[b,C,w,T,E]),(0,I.jsx)(`div`,{ref:m,className:`diff-multiselect-wrapper`,children:(0,I.jsx)(Wf,{ref:h,...u,diffViewMode:l,extendData:x,onAddWidgetClick:(e,t)=>{var n;(n=g.current)==null||n.clearSelection();let r=_.current;if(r){let n=z[t],i=r[n],a=n===`new`?`old`:`new`,o=r[a];if(i?.length){let r=Math.max(...i);if(r===e){y({[n]:i}),c?.({lineNumber:r,fromLineNumber:Math.min(...i),side:t});return}}if(v&&o?.length){let n=Math.max(...o),r=b(),i=r?.getUnifiedLineIndexByLineNumber(e,t)||-1,s=(r?.getUnifiedLine)?.call(r,i);if(n===(t===z.old?s?.newLineNumber:s?.oldLineNumber)){y({[a]:o}),c?.({lineNumber:n,fromLineNumber:Math.min(...o),side:a===`old`?z.old:z.new});return}}y(void 0),c?.({lineNumber:e,fromLineNumber:e,side:t})}else y(void 0),c?.({lineNumber:e,fromLineNumber:e,side:t})},renderWidgetLine:s?S:void 0})})});var qf=`操作没有完成。`,Jf=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,Yf=160,Xf=/[\u3400-\u9fff]/,Zf=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,Qf=/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,$f=/timeout|timed out|etimedout/i,ep=/aborterror|aborted|the user aborted a request|operation was aborted/i,tp=/node-pty|pty unavailable|terminal unavailable/i,np=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,rp=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,ip=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,ap=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,op=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function sp(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 cp=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function lp(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>Yf?`${t.slice(0,Yf)}…`:t}function up(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${lp(t)})`}function dp(e,t){let n=sp(e);if(!n||cp.test(n))return t??Jf;if(Xf.test(n))return n;if(Zf.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(Qf.test(n))return up(`连接不上 Super Pi 服务,请稍后再试。`,n);if($f.test(n))return up(`等待服务响应超时,请稍后再试。`,n);if(ep.test(n))return up(`请求被中断,请重试。`,n);if(tp.test(n))return up(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if(np.test(n))return up(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(ap.exec(n)?.[1]??ap.exec(n)?.[2]??0);if(r===401||r===403)return up(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return up(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return up(`请求被拒绝(HTTP ${r})。`,n);if(rp.test(n))return up(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(ip.test(n))return up(`服务端出错了,请稍后再试。`,n);let i=op.exec(n)?.[1];return up(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??qf,n)}function fp(e){let t=sp(e);if(t&&!cp.test(t))return dp(e).includes(t)?void 0:t}function pp(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var mp={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`},hp={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 gp(e){let t=hp[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=pp(e);return n?mp[n]??`generic`:`generic`}var _p={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 vp({path:e,category:t,size:n=14}){let r=t??gp(e??``),i=_p[r]??_p.generic;return(0,I.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,I.jsx)(`path`,{d:e},t))})}function yp(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,css:`css`,html:`html`,md:`markdown`,py:`python`,sh:`bash`,rs:`rust`,go:`go`,yml:`yaml`,yaml:`yaml`}[e]||`plaintext`}function bp(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`?`,kind:`untracked`,slot:`index`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var xp=e=>e.path.endsWith(`/`);function Sp(){if(typeof document>`u`)return!0;let e=document.documentElement.getAttribute(`data-theme`)||`dracula`;return e!==`solarized-light`&&e!==`github-light`}var Cp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},wp=15e3,Tp=e=>new Cp(408,{error:`请求超时:${wp/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Ep(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),wp);try{let r=await fetch(e,{...t,signal:n.signal}),i;try{i=await r.json()}catch{i=void 0}if(!r.ok)throw new Cp(r.status,i??{error:`HTTP ${r.status}`});return i}catch(t){throw n.signal.aborted?Tp(e):t}finally{clearTimeout(r)}}var Dp=e=>e instanceof Cp?e:new Cp(0,{error:e instanceof Error?e.message:`读取失败`}),Op=e=>encodeURIComponent(e),kp=e=>e?`&cwd=${Op(e)}`:``,Ap=(e,t)=>`/api/git?workspaceId=${Op(e)}&op=status${kp(t)}`,jp=(e,t,n)=>`/api/git?workspaceId=${Op(e)}&op=log&limit=${t}${kp(n)}`,Mp=(e,t,n,r)=>`/api/git?workspaceId=${Op(e)}&op=diff&path=${Op(t)}${n?`&staged=1`:``}${kp(r)}`;async function Np(e,t,n={},r){return Ep(`/api/git?workspaceId=${Op(e)}&op=${Op(t)}${kp(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})}var Pp=20,Fp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},Ip=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,Lp=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},Rp=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function zp({path:e,onCancel:t,onConfirm:n}){let r=(0,F.useRef)(null),i=(0,F.useRef)(null);(0,F.useEffect)(()=>{i.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,I.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:r,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=r.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let i=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())},"data-git-confirm-dialog":`1`,children:[(0,I.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,I.jsx)(`p`,{className:`git-confirm-desc`,children:`即将丢弃以下文件的所有未暂存修改:`}),(0,I.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,I.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,I.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:i,onClick:t,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:n,children:`确认丢弃`})]})]})});return typeof document>`u`?a:(0,pa.createPortal)(a,document.body)}function Bp({children:e,onClose:t}){let n=(0,F.useRef)(null),r=(0,F.useRef)(t);return r.current=t,(0,F.useLayoutEffect)(()=>{let e=document.activeElement;n.current?.querySelector(`[data-git-diff-close]`)?.focus();let t=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r.current()),e.key!==`Tab`)return;let t=Array.from(n.current?.querySelectorAll(`button:not(:disabled),a[href],input:not(:disabled),[tabindex='0']`)??[]).filter(e=>e.getClientRects().length),i=t[0],a=t.at(-1);i?e.shiftKey&&(document.activeElement===i||document.activeElement===n.current)?(e.preventDefault(),a?.focus()):!e.shiftKey&&document.activeElement===a&&(e.preventDefault(),i.focus()):(e.preventDefault(),n.current?.focus())};return window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`keydown`,t,!0),e?.isConnected&&e.focus()}},[]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay git-diff-overlay`,"data-git-diff-overlay":!0,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsx)(`div`,{ref:n,className:`tool-dialog git-diff-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`文件差异`,tabIndex:-1,"data-git-diff-dialog":!0,children:e})}),document.body)}function Vp(e,t,n){let r=e?Ap(e,t):``,[i,a]=(0,F.useState)(),o=(0,F.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,F.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;Ep(r).then(e=>{s()&&a({scope:r,status:e,error:null})}).catch(e=>{s()&&a({scope:r,status:null,error:Dp(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,F.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,F.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?.status??null,error:l?.error??null,refresh:s,publish:c}}function Hp({workspaceId:e,conversationId:t,cwd:n=``,onOpenChanged:r,sharedGit:i}){let[a,o]=(0,F.useState)(Id.Unified),s=Sp(),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),f=i?i.status:c,p=i?i.error:u,m=i?.refresh,h=i?.publish,[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(``),[S,C]=(0,F.useState)(null),[w,T]=(0,F.useState)(``),[E,D]=(0,F.useState)(``),[O,k]=(0,F.useState)(null),[A,ee]=(0,F.useState)(null),j=(0,F.useRef)(0),M=(0,F.useCallback)((e,t)=>{j.current+=1,l(null),d(null),D(``),_(null),y(!0),x(``),C(null),m?m():Ep(Ap(e,n)).then(e=>{t()&&(l(e),d(null))}).catch(e=>{t()&&d(Dp(e))}),Ep(jp(e,Pp,n)).then(e=>{t()&&(_(e),y(!1))}).catch(e=>{t()&&(x(Dp(e).message),y(!1))})},[n,m]);(0,F.useEffect)(()=>{if(!e)return;let t=!0;return M(e,()=>t),()=>{t=!1}},[e,n,M]);let N=(0,F.useCallback)((t,r)=>{if(!e)return;let i=++j.current;C({path:t,staged:r,loading:!0,error:``,result:null}),Ep(Mp(e,t,r,n)).then(e=>{j.current===i&&C(n=>n&&n.path===t&&n.staged===r?{...n,loading:!1,result:e}:n)}).catch(e=>{j.current===i&&C(n=>n&&n.path===t&&n.staged===r?{...n,loading:!1,error:Dp(e).message}:n)})},[e,n]),te=(0,F.useCallback)(()=>{j.current+=1,C(null)},[]),ne=(0,F.useCallback)(async(t,r={})=>{if(!e)return!1;k(t),D(``);try{let i=await Np(e,t,r,n);return h?h(i):l(i),j.current+=1,C(null),y(!0),x(``),Ep(jp(e,Pp,n)).then(e=>{_(e),y(!1)}).catch(e=>{x(Dp(e).message),y(!1)}),!0}catch(e){let t=Dp(e);return D(t.body?.error||t.message||`操作失败`),!1}finally{k(null)}},[e,n,h]),re=(0,F.useCallback)(()=>{if(!A)return;let e=A;ee(null),ne(`discard`,{path:e})},[A,ne]),ie=(0,F.useCallback)(()=>{ee(null)},[]);if(!e)return(0,I.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})});let ae=f===null?null:Lp(f),oe=f===null?[]:Rp.map(e=>({...e,entries:f[e.key]})),se=S===null?``:S.loading?`加载 diff…`:S.error===``?S.result===null?``:S.result.kind===`text`?S.result.diff??``:S.result.kind===`binary`?`二进制文件不显示差异。`:`未跟踪文件暂无对照版本。`:S.error,ce=(0,F.useMemo)(()=>{if(!S?.result?.diff||S.result.kind!==`text`)return null;let e=yp((S.path.split(`.`).pop()||``).toLowerCase());try{let t=new Gs(S.path,``,S.path,``,[S.result.diff],e,e);return t.init(),t.buildUnifiedDiffLines(),t.buildSplitDiffLines(),t}catch{return null}},[S?.path,S?.result?.diff,S?.result?.kind]);return(0,I.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:[f===null&&p===null&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),p!==null&&(0,I.jsxs)(`div`,{className:`git-state-card${p.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":p.body.code??``,children:[(0,I.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:p.body.code===`not_a_repo`?`⌁`:`!`}),(0,I.jsx)(`strong`,{children:p.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,I.jsx)(`p`,{children:p.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,I.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>e&&M(e,()=>!0),children:`重新检查`})]}),f!==null&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,I.jsx)(`span`,{className:`git-branch`,"data-git-branch":`1`,title:Ip(f),children:Ip(f)}),ae!==null&&(0,I.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:ae}),(0,I.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>e&&M(e,()=>!0),children:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),(0,I.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,I.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void ne(`pull`),disabled:O!==null,children:O===`pull`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,I.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void ne(`push`),disabled:O!==null,children:O===`push`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`}),(0,I.jsx)(`button`,{type:`button`,"data-git-action":`stage-all`,onClick:()=>void ne(`stage-all`),disabled:O!==null||!f.unstaged.length&&!f.untracked.length,children:`全部暂存`})]}),E&&(0,I.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,children:E}),oe.map(e=>(0,I.jsxs)(`div`,{className:`git-group`,"data-git-group":e.key,children:[(0,I.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":e.key,children:[(0,I.jsx)(`span`,{className:`git-group-title`,children:e.title}),(0,I.jsx)(`span`,{className:`git-group-count`,"data-git-count":e.key,children:e.entries.length}),e.key===`staged`&&e.entries.length>0&&(0,I.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:O!==null,onClick:()=>void ne(`unstage-all`),children:`全部取消暂存`})]}),(0,I.jsx)(`div`,{className:`git-group-body`,children:e.entries.length===0?(0,I.jsxs)(`p`,{className:`git-group-empty`,"data-git-empty":e.key,children:[`无`,e.title,`变更。`]}):e.entries.map(t=>{let n=bp(t.xy,e.key),r=xp(t),i=S?.path===t.path&&S?.staged===(e.key===`staged`);return(0,I.jsxs)(`div`,{className:`git-file-row${i?` is-active`:``}`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":t.path,"data-git-kind":r?`dir`:`file`,title:t.path,onClick:()=>N(t.path,e.key===`staged`),children:[(0,I.jsx)(`span`,{className:`git-badge git-badge-${n.kind} git-badge-slot-${n.slot}`,"data-git-badge":n.kind,"data-git-badge-slot":n.slot,children:n.label}),r&&(0,I.jsx)(vp,{category:`folder`,size:12}),(0,I.jsx)(`span`,{className:`git-path`,children:r?`${t.name}/`:t.name}),t.path.includes(`/`)&&!r&&(0,I.jsx)(`span`,{className:`git-parent-path`,children:t.path.slice(0,t.path.lastIndexOf(`/`))})]}),(0,I.jsxs)(`span`,{className:`git-file-actions`,children:[e.key===`staged`?(0,I.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:O!==null,onClick:e=>{e.stopPropagation(),ne(`unstage`,{path:t.path})},children:`−`}):(0,I.jsx)(`button`,{type:`button`,title:`暂存`,disabled:O!==null,onClick:e=>{e.stopPropagation(),ne(`stage`,{path:t.path})},children:`+`}),e.key===`unstaged`&&(0,I.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${t.path} 的更改`,"aria-label":`丢弃更改 ${t.path}`,disabled:A!==null||O!==null,onClick:e=>{e.stopPropagation(),ee(t.path)},children:`↶`})]})]},t.path)})})]},e.key)),(0,I.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,I.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,I.jsx)(`strong`,{children:`提交更改`}),(0,I.jsxs)(`span`,{children:[f.staged.length,` 个已暂存`]})]}),(0,I.jsxs)(`label`,{children:[`提交说明`,(0,I.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`概括本次更改`,"aria-label":`提交消息`,disabled:O!==null})]}),(0,I.jsx)(`button`,{type:`button`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!f.staged.length||!w.trim()||O!==null,onClick:async()=>{await ne(`commit`,{message:w})&&T(``)},children:O===`commit`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):f.staged.length?`提交 ${f.staged.length} 个暂存文件`:`先暂存更改`})]}),S!==null&&(0,I.jsx)(Bp,{onClose:te,children:(0,I.jsxs)(`div`,{className:`git-diff-area`,"data-git-diff-area":`1`,children:[(0,I.jsxs)(`div`,{className:`git-group-head`,"data-git-diff-head":`1`,children:[(0,I.jsx)(`span`,{className:`git-path`,"data-git-diff-path":`1`,title:S.path,children:S.path}),(0,I.jsxs)(`div`,{className:`git-diff-toolbar`,children:[ce&&(0,I.jsx)(`button`,{type:`button`,className:`git-diff-mode-btn`,"data-git-diff-mode":a===Id.Unified?`unified`:`split`,title:a===Id.Unified?`切换到左右分栏视图`:`切换到内联单栏视图`,onClick:()=>o(e=>e===Id.Unified?Id.Split:Id.Unified),children:a===Id.Unified?`分栏`:`内联`}),r&&(0,I.jsx)(`button`,{type:`button`,className:`git-diff-expand-btn`,"data-git-diff-expand":`1`,title:`在主视区查看完整差异对比`,onClick:()=>{te(),r(S.path)},children:`主视区查看 ↗`}),(0,I.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-diff-close":`1`,"data-git-close":`1`,title:`关闭差异`,"aria-label":`关闭差异`,onClick:te,children:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✕`})})]})]}),(0,I.jsxs)(`div`,{className:`git-diff`,"data-git-diff":S.path,"data-git-diff-loading":S.loading?`1`:void 0,"data-git-diff-error":S.error===``?void 0:`1`,"data-git-diff-kind":S.result!==null&&!S.loading&&S.error===``?S.result.kind:void 0,children:[(0,I.jsx)(`pre`,{className:`git-diff-raw`,style:{display:`none`},children:se}),S.loading?(0,I.jsx)(`p`,{className:`rail-empty`,children:`加载 diff…`}):S.error===``?S.result===null?null:S.result.kind===`binary`?(0,I.jsx)(`p`,{className:`rail-empty`,children:`二进制文件不显示差异。`}):S.result.kind===`untracked`?(0,I.jsx)(`p`,{className:`rail-empty`,children:`未跟踪文件暂无对照版本。`}):ce?(0,I.jsx)(`div`,{className:`git-diff-view-wrapper`,children:(0,I.jsx)(Wf,{diffFile:ce,diffViewMode:a,diffViewTheme:s?`dark`:`light`,diffViewFontSize:13})}):(0,I.jsx)(`pre`,{className:`git-diff-fallback`,children:se}):(0,I.jsx)(`p`,{className:`tool-error`,title:fp(S.error),children:dp(S.error,`这个文件的差异读取失败。`)})]})]})}),(0,I.jsxs)(`div`,{className:`git-log`,"data-git-log":`1`,children:[(0,I.jsx)(`div`,{className:`git-group-head`,"data-git-log-head":`1`,children:(0,I.jsx)(`span`,{className:`git-group-title`,children:`最近提交`})}),v&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-loading":`1`,children:`读取提交记录…`}),!v&&b!==``&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-error":`1`,title:fp(b),children:dp(b,`提交记录读取失败。`)}),!v&&b===``&&g!==null&&(g.commits.length===0?(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:`暂无提交记录。`}):(0,I.jsxs)(I.Fragment,{children:[g.commits.map(e=>(0,I.jsxs)(`div`,{className:`git-log-row`,"data-git-commit":e.hash,children:[(0,I.jsx)(`div`,{className:`git-log-subject`,title:e.subject,children:e.subject}),(0,I.jsxs)(`div`,{className:`git-log-meta`,children:[(0,I.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,I.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,I.jsx)(`span`,{className:`git-log-date`,children:Fp(e.date)})]})]},e.hash)),g.truncated&&(0,I.jsxs)(`p`,{className:`rail-empty`,"data-git-log-truncated":`1`,children:[`仅显示最近 `,Pp,` 条提交。`]})]}))]}),A!==null&&(0,I.jsx)(zp,{path:A,onCancel:ie,onConfirm:re})]})]})}var Up={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`},Wp={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`},Gp=[`sessions`,`files`,`main`,`terminal`,`git`,`projects`,`tools`],Kp=`super-pi.workbench.layout.v1`,qp=e=>typeof e==`string`&&Gp.includes(e);function Jp(){let e={sides:{...Wp},order:Gp,unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1};try{let t=JSON.parse(window.localStorage.getItem(Kp)??`null`);if(!t)return e;let n={...Wp};for(let e of Gp)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(qp):[];return{sides:n,order:[...new Set([...r,...Gp])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(qp).filter(e=>e!==`sessions`):[],leftView:qp(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function Yp(e){try{window.localStorage.setItem(Kp,JSON.stringify(e))}catch{}}var Xp={sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,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`,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:`M20 4v5h-5m5 0a8 8 0 1 0 0 6`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`};function Zp({name:e}){return(0,I.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,I.jsx)(`path`,{d:Xp[e]})})}function Qp({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,children:s}){let c=t.filter(e=>n.includes(e));return(0,I.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,I.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:t.filter(e=>!n.includes(e)).map(t=>(0,I.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,title:Up[t],"aria-label":Up[t],onClick:()=>a(t),children:(0,I.jsx)(Zp,{name:t})},t))}),o&&(0,I.jsx)(`button`,{type:`button`,className:`workbench-activity-button`,"data-workbench-search":`1`,title:`搜索文件内容`,"aria-label":`搜索文件内容`,onClick:o,children:(0,I.jsx)(Zp,{name:`search`})}),c.length>0&&(0,I.jsxs)(`details`,{className:`workbench-menu workbench-more`,children:[(0,I.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,I.jsx)(Zp,{name:`more`})}),(0,I.jsx)(`div`,{className:`workbench-menu-items`,children:c.map(e=>(0,I.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),a(e)},children:[(0,I.jsx)(Zp,{name:e}),Up[e]]},e))})]}),s&&(0,I.jsx)(`div`,{className:`workbench-activity-utilities`,children:s})]})}function $p({view:e,side:t,pinned:n,onArrange:r}){let i=[[`move`,t===`left`?`移到右侧`:`移到左侧`],[`pin`,n?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];return(0,I.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,I.jsx)(`summary`,{title:`视图布局`,"aria-label":`${Up[e]}布局`,"data-workbench-panel-menu":e,children:(0,I.jsx)(Zp,{name:`more`})}),(0,I.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,I.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var em=`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'`,tm={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 nm(e){return tm[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function rm(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 nm(e)?.kind}function im(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function am(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 om=new Set([`http`,`https`,`mailto`]),sm=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},cm=/^([a-z][a-z0-9+.-]*):/i;function lm(e){let t=[...e].filter(e=>!sm(e)).join(``);if(!t)return;let n=cm.exec(t);return n?om.has(n[1].toLowerCase())?e:void 0:e}var um=/[!-/:-@[-`{-~]/,dm=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function fm(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function pm(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function mm(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=fm(e,r,"`");if(t===n)return r;r+=t-1}return-1}function hm(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
35
+ `,t[c]=!0),!o&&l&&u&&(o||=l.noTrailingNewLine!==u.noTrailingNewLine)}if(!o&&i===a)return;this._oldFileContent=i,this._newFileContent=a,R(this,zo,Mo(this._oldFileContent,this._oldFileLang,L(this,bs,`f`),this._oldFileName,this.uuid?this.uuid+`-old`:void 0),`f`),R(this,Bo,Mo(this._newFileContent,this._newFileLang,L(this,bs,`f`),this._newFileName,this.uuid?this.uuid+`-new`:void 0),`f`),R(this,Zo,e,`f`),R(this,Qo,t,`f`),R(this,ps,!0,`f`)}else if(L(this,zo,`f`)){let e=1,t=1,n=``,r=!1;for(;t<=L(this,zo,`f`).maxLineNumber;){let i=L(this,Ro,`m`,Ps).call(this,e++),a=L(this,Ro,`m`,Ns).call(this,t);i?(n+=i.text,t=i.oldLineNumber?i.oldLineNumber+1:t):(a||(n+=L(this,Ro,`m`,Fs).call(this,t)),t++),!r&&i&&a&&(r||=i.noTrailingNewLine!==a.noTrailingNewLine)}if(!r&&n===this._oldFileContent)return;this._newFileContent=n,R(this,Bo,Mo(this._newFileContent,this._newFileLang,L(this,bs,`f`),this._newFileName,this.uuid?this.uuid+`-new`:void 0),`f`)}else if(L(this,Bo,`f`)){let e=1,t=1,n=``,r=!1;for(;t<=L(this,Bo,`f`).maxLineNumber;){let i=L(this,Ro,`m`,Ns).call(this,e++),a=L(this,Ro,`m`,Ps).call(this,t);i?(n+=i.text,t=i.newLineNumber?i.newLineNumber+1:t):(a||(n+=L(this,Ro,`m`,Is).call(this,t)),t++),!r&&a&&i&&(r||=a.noTrailingNewLine!==i.noTrailingNewLine)}if(!r&&n===this._newFileContent)return;this._oldFileContent=n,R(this,zo,Mo(this._oldFileContent,this._oldFileLang,L(this,bs,`f`),this._oldFileName,this.uuid?this.uuid+`-old`:void 0),`f`)}L(this,Ro,`m`,Ds).call(this)},ks=function(){var e;if(!L(this,Vo,`f`)?.length)return;R(this,fs,(e=L(this,fs,`f`),e++,e),`f`);let t=e=>L(this,Ro,`m`,Is).call(this,e),n=e=>L(this,Ro,`m`,Fs).call(this,e),r=e=>L(this,Ro,`m`,Rs).call(this,e),i=e=>L(this,Ro,`m`,Ls).call(this,e);R(this,Ho,[],`f`),this.additionLength=0,this.deletionLength=0;let a=[];L(this,Vo,`f`).forEach(e=>{e.hunks.forEach(e=>{let o=[],s=[];e.lines.forEach(e=>{e.type===Ba.Add?(o.push(e),this.additionLength++):e.type===Ba.Delete?(s.push(e),this.deletionLength++):(fo(o,s,{diffFile:this,getAdditionRaw:t,getDeletionRaw:n,getAdditionSyntax:r,getDeletionSyntax:i}),o=[],s=[]),a.push(e)}),fo(o,s,{diffFile:this,getAdditionRaw:t,getDeletionRaw:n,getAdditionSyntax:r,getDeletionSyntax:i})})});let o=null;R(this,Ho,a.map((e,t)=>{let n=e;if(n.index=t,n.isFirst=t===0,n.type===Ba.Hunk){let e=n.text.split(`@@`)?.[1].split(` `).filter(Boolean),t=e?.[0]||``,r=e?.[1]||``,[i,a]=t.split(`,`),[s,c]=r.split(`,`);n.hunkInfo={oldStartIndex:-Number(i),oldLength:Number(a),newStartIndex:+Number(s),newLength:Number(c),_oldStartIndex:-Number(i),_oldLength:Number(a),_newStartIndex:+Number(s),_newLength:Number(c)},o=n}else if(n.type===Ba.Context){let t=e;o&&=(t.prevHunkLine=o,null)}else o=null;return n}),`f`),R(this,Uo,{},`f`),R(this,Wo,{},`f`),L(this,Ho,`f`).forEach(e=>{e.oldLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,e.oldLineNumber),L(this,Uo,`f`)[e.oldLineNumber]=e),e.newLineNumber&&(this.diffLineLength=Math.max(this.diffLineLength,e.newLineNumber),L(this,Wo,`f`)[e.newLineNumber]=e)})},As=function(){R(this,_s,L(this,zo,`f`)?.highlighterName||L(this,Bo,`f`)?.highlighterName||L(this,_s,`f`),`f`),R(this,vs,L(this,zo,`f`)?.highlighterType||L(this,Bo,`f`)?.highlighterType||L(this,vs,`f`),`f`),L(this,zo,`f`)?.highlighterName&&R(this,Yo,L(this,zo,`f`).syntaxFile,`f`),L(this,Bo,`f`)?.highlighterName&&R(this,Xo,L(this,Bo,`f`).syntaxFile,`f`)},js=function({registerHighlighter:e}){var t,n;(t=L(this,zo,`f`))==null||t.doSyntax({registerHighlighter:e,theme:L(this,bs,`f`)}),R(this,Yo,L(this,zo,`f`)?.syntaxFile,`f`),(n=L(this,Bo,`f`))==null||n.doSyntax({registerHighlighter:e,theme:L(this,bs,`f`)}),R(this,Xo,L(this,Bo,`f`)?.syntaxFile,`f`)},Ms=function({registerHighlighter:e}={}){(!L(this,hs,`f`)||L(this,gs,`f`))&&(L(this,Ro,`m`,js).call(this,{registerHighlighter:e}),L(this,Ro,`m`,As).call(this))},Ns=function(e){if(e)return L(this,Uo,`f`)?.[e]},Ps=function(e){if(e)return L(this,Wo,`f`)?.[e]},Fs=function(e){return L(this,Go,`f`)?.[e]},Is=function(e){return L(this,Ko,`f`)?.[e]},Ls=function(e){return L(this,Yo,`f`)?.[e]},Rs=function(e){return L(this,Xo,`f`)?.[e]},zs=function(){R(this,ts,void 0,`f`),R(this,ns,void 0,`f`)},Bs=function(e){return L(this,ts,`f`)||R(this,ts,{old:Ws(L(this,$o,`f`),e=>e.lineNumber),new:Ws(L(this,es,`f`),e=>e.lineNumber)},`f`),e===z.old?L(this,ts,`f`).old:L(this,ts,`f`).new},Vs=function(e){return L(this,ns,`f`)||R(this,ns,{old:Ws(L(this,is,`f`),e=>e.oldLineNumber),new:Ws(L(this,is,`f`),e=>e.newLineNumber)},`f`),e===z.old?L(this,ns,`f`).old:L(this,ns,`f`).new};var Ks=`diff-multi-select-active`,qs={selected:Ks,selecting:`diff-multi-selecting`};function Js(e){if(!e)return null;let t=e.querySelector(`span[data-line-num]`);if(!t)return null;let n=t.getAttribute(`data-line-num`),r=parseInt(n??``,10);return n===r.toString()?isNaN(r)?null:r:null}function Ys(e){if(!e)return null;let t=e.closest(`[data-side]`);return t?t.getAttribute(`data-side`):null}function Xs(e,t=!1){if(!e||t&&e.closest(`.diff-add-widget-wrapper`))return null;let n=e.closest(`.diff-line-num`);if(!n)return null;let r=n.querySelector(`span[data-line-old-num]`),i=n.querySelector(`span[data-line-new-num]`),a=r?.getAttribute(`data-line-old-num`),o=i?.getAttribute(`data-line-new-num`),s=a?parseInt(a,10):void 0,c=o?parseInt(o,10):void 0;return s===void 0&&c===void 0?null:{old:s,new:c}}function Zs(e,t=!1){if(!e||t&&e.closest(`.diff-add-widget-wrapper`))return null;let n=null;if(!t){let t=e.closest(`.diff-line-new-content`),r=e.closest(`.diff-line-old-content`);t&&(n=t.parentElement?.querySelector(`.diff-line-new-num`)??null),r&&(n=r.parentElement?.querySelector(`.diff-line-old-num`)??null)}return n||=e.closest(`.diff-line-new-num`)||e.closest(`.diff-line-old-num`),n}function Qs(e){let t=Math.min(e.startLineNumber,e.endLineNumber),n=Math.max(e.startLineNumber,e.endLineNumber);return{...e,startLineNumber:t,endLineNumber:n}}var $s=e=>{let t=[];return e.new&&e.new.length&&t.push({side:`new`,startLineNumber:Math.min(...e.new),endLineNumber:Math.max(...e.new)}),e.old&&e.old.length&&t.push({side:`old`,startLineNumber:Math.min(...e.old),endLineNumber:Math.max(...e.old)}),t},ec=(e,t,n,r)=>{rc(t,n).forEach(t=>{var i,a;if(!t.isHide&&t.index){let o=e.filter(e=>e.getAttribute(`data-line`)===t.index.toString());o.length===2?t.isContext?o.forEach(e=>e.querySelectorAll(`td`).forEach(e=>e.classList.add(r))):o.find(e=>e.getAttribute(`data-side`)===n.side)?.querySelectorAll(`td`).forEach(e=>e.classList.add(r)):t.isContext?(i=o[0])==null||i.querySelectorAll(`td`).forEach(e=>e.classList.add(r)):(a=o[0])==null||a.querySelectorAll(`td[data-side="${n.side}"]`).forEach(e=>e.classList.add(r))}})};function tc(e,t,n,r={old:[],new:[]},i=Ks){if(!e)return;let a=`diff-root${n?.getId()}`,o=Array.from(e.querySelectorAll(`tr[data-line]`)).filter(e=>e.closest(`.diff-view-wrapper`)?.getAttribute(`id`)===a),s=$s(r),c=(t?s.concat(t):s).map(Qs);o.forEach(e=>{e.querySelectorAll(`td`).forEach(e=>e.classList.remove(i))}),c.forEach(e=>{e&&n&&ec(o,n,e,i)})}function nc(e,t,n,r={old:[],new:[]},i=Ks){if(!e)return;let a=`diff-root${n?.getId()}`,o=Array.from(e.querySelectorAll(`tr[data-line]`)).filter(e=>e.closest(`.diff-view-wrapper`)?.getAttribute(`id`)===a),s=$s(r),c=(t?s.concat(t):s).map(Qs);o.forEach(e=>{let t=e.querySelector(`.diff-line-num`),n=e.querySelector(`.diff-line-content`);if(!t||!n)return;t.classList.remove(i),n.classList.remove(i);let r=t.querySelector(`span[data-line-old-num]`),a=t.querySelector(`span[data-line-new-num]`),o=r?.getAttribute(`data-line-old-num`),s=a?.getAttribute(`data-line-new-num`),l=o?parseInt(o,10):void 0,u=s?parseInt(s,10):void 0;c.some(e=>e.side===`old`&&l&&l>=e.startLineNumber&&l<=e.endLineNumber||e.side===`new`&&u&&u>=e.startLineNumber&&u<=e.endLineNumber)&&(t.classList.add(i),n.classList.add(i))})}function rc(e,t){let n=Qs(t),r=[],{side:i,startLineNumber:a,endLineNumber:o}=n,s=i===`old`?z.old:z.new;for(let t=a;t<=o;t++){let n=e.getSplitLineByLineNumber(t,s),i=e.getSplitLineIndexByLineNumber(t,s);if(n&&n.lineNumber!==void 0){let a=n.diff?.type;r.push({index:i+1,lineNumber:n.lineNumber,value:n.value,isHide:Lo(e,t,s).split,isDelete:a===Ba.Delete,isAdd:a===Ba.Add,isContext:a===Ba.Context||a===void 0})}}return r}function ic(e,t){let n=Qs(t),r=[],{side:i,startLineNumber:a,endLineNumber:o}=n,s=i===`old`?z.old:z.new;for(let t=a;t<=o;t++){let n=e.getUnifiedLineByLineNumber(t,s),a=e.getUnifiedLineIndexByLineNumber(t,s);if(n){let o=i===`old`?n.oldLineNumber:n.newLineNumber;if(o!==void 0){let i=n.diff?.type;r.push({index:a+1,lineNumber:o,value:n.value,isHide:Lo(e,t,s).unified,isDelete:i===Ba.Delete,isAdd:i===Ba.Add,isContext:i===Ba.Context||i===void 0})}}}return r}var ac,oc,sc,cc,lc,uc,dc,fc,pc,mc,hc,gc,_c,vc,yc,bc,xc,Sc,Cc=class{constructor(e,t,n={}){ac.add(this),oc.set(this,null),sc.set(this,null),cc.set(this,void 0),lc.set(this,{isSelecting:!1,startInfo:null,currentRange:null}),uc.set(this,{old:[],new:[]}),dc.set(this,null),fc.set(this,!1),pc.set(this,()=>void 0),mc.set(this,()=>void 0),R(this,oc,e,`f`),R(this,sc,t,`f`),R(this,cc,{enabled:n.enabled??!0,onSelectionChange:n.onSelectionChange??(()=>{}),onSelectionComplete:n.onSelectionComplete??(()=>{}),scopeToHunk:n.scopeToHunk??(e=>e),selectedClassName:n.selectedClassName??Ks,isUnifiedMode:n.isUnifiedMode??!1},`f`),L(this,cc,`f`).enabled&&L(this,ac,`m`,hc).call(this);let r=null;R(this,mc,()=>{r&&clearTimeout(r),r=setTimeout(()=>L(this,ac,`m`,xc).call(this),16)},`f`),Object.defineProperty(this,"__v_skip",{value:!0})}getSelectionResult(){if(!L(this,lc,`f`).currentRange||!L(this,sc,`f`))return null;let e=Qs(L(this,lc,`f`).currentRange);return{range:e,lines:L(this,cc,`f`).isUnifiedMode?ic(L(this,sc,`f`),e):rc(L(this,sc,`f`),e)}}getState(){return{...L(this,lc,`f`)}}setPreselectedLines(e){R(this,uc,e,`f`),L(this,ac,`m`,xc).call(this)}clearSelection(){L(this,ac,`m`,Sc).call(this),L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(null,{...L(this,lc,`f`)})}updateOptions(e){let t=L(this,cc,`f`).enabled;R(this,cc,{...L(this,cc,`f`),...e},`f`),!t&&L(this,cc,`f`).enabled?L(this,ac,`m`,hc).call(this):t&&!L(this,cc,`f`).enabled&&this.destroy()}updateDiffFile(e){L(this,pc,`f`).call(this),R(this,sc,e,`f`),R(this,pc,L(this,sc,`f`).subscribe(()=>L(this,mc,`f`).call(this)),`f`),L(this,ac,`m`,xc).call(this)}updateContainer(e){this.destroy(),R(this,oc,e,`f`),R(this,fc,!1,`f`),L(this,cc,`f`).enabled&&L(this,ac,`m`,hc).call(this)}destroy(){L(this,fc,`f`)||(L(this,dc,`f`)&&L(this,oc,`f`)&&(L(this,oc,`f`).removeEventListener(`mousedown`,L(this,dc,`f`).mousedown),L(this,oc,`f`).removeEventListener(`mouseover`,L(this,dc,`f`).mouseover),document.removeEventListener(`mouseup`,L(this,dc,`f`).mouseup),R(this,dc,null,`f`)),L(this,pc,`f`).call(this),this.clearSelection(),R(this,fc,!0,`f`))}};oc=new WeakMap,sc=new WeakMap,cc=new WeakMap,lc=new WeakMap,uc=new WeakMap,dc=new WeakMap,fc=new WeakMap,pc=new WeakMap,mc=new WeakMap,ac=new WeakSet,hc=function(){if(!L(this,oc,`f`)||L(this,dc,`f`))return;let e=e=>{L(this,cc,`f`).isUnifiedMode?L(this,ac,`m`,_c).call(this,e):L(this,ac,`m`,gc).call(this,e)},t=e=>{L(this,cc,`f`).isUnifiedMode?L(this,ac,`m`,yc).call(this,e):L(this,ac,`m`,vc).call(this,e)},n=()=>{L(this,ac,`m`,bc).call(this)};R(this,dc,{mousedown:e,mouseover:t,mouseup:n},`f`),L(this,oc,`f`).addEventListener(`mousedown`,e),L(this,oc,`f`).addEventListener(`mouseover`,t),document.addEventListener(`mouseup`,n),R(this,pc,L(this,sc,`f`)?.subscribe(()=>L(this,mc,`f`).call(this))||(()=>void 0),`f`)},gc=function(e){let t=Zs(e.target,!0);if(!t)return;let n=Js(t);if(n===null)return;let r=Ys(t);if(!r)return;L(this,lc,`f`).isSelecting=!0,L(this,lc,`f`).startInfo={lineNumber:n,side:r};let i={side:r,startLineNumber:n,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(i);e&&(i=e)}L(this,lc,`f`).currentRange=i,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(i,{...L(this,lc,`f`)})},_c=function(e){let t=Xs(e.target,!0);if(!t)return;let n=t.new??t.old;if(n===void 0)return;let r=t.new===void 0?`old`:`new`;L(this,lc,`f`).isSelecting=!0,L(this,lc,`f`).startInfo={lineNumber:n,side:r};let i={side:r,startLineNumber:n,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(i);e&&(i=e)}L(this,lc,`f`).currentRange=i,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(i,{...L(this,lc,`f`)})},vc=function(e){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).startInfo)return;let t=Zs(e.target);if(!t)return;let n=Js(t);if(n===null)return;let r={side:L(this,lc,`f`).startInfo.side,startLineNumber:L(this,lc,`f`).startInfo.lineNumber,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(r);e&&(r=e)}L(this,lc,`f`).currentRange=r,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(r,{...L(this,lc,`f`)})},yc=function(e){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).startInfo)return;let t=Xs(e.target);if(!t)return;let n=t[L(this,lc,`f`).startInfo.side];if(n===void 0)return;let r={side:L(this,lc,`f`).startInfo.side,startLineNumber:L(this,lc,`f`).startInfo.lineNumber,endLineNumber:n};if(L(this,cc,`f`).scopeToHunk){let e=L(this,cc,`f`).scopeToHunk(r);e&&(r=e)}L(this,lc,`f`).currentRange=r,L(this,ac,`m`,xc).call(this),L(this,cc,`f`).onSelectionChange(r,{...L(this,lc,`f`)})},bc=function(){if(!L(this,lc,`f`).isSelecting||!L(this,lc,`f`).currentRange){L(this,ac,`m`,Sc).call(this);return}let e=Qs(L(this,lc,`f`).currentRange);L(this,lc,`f`).currentRange=e,L(this,lc,`f`).isSelecting=!1;let t=this.getSelectionResult();L(this,cc,`f`).onSelectionComplete(t)},xc=function(){L(this,cc,`f`).isUnifiedMode?nc(L(this,oc,`f`),L(this,lc,`f`).currentRange,L(this,sc,`f`),L(this,uc,`f`),L(this,cc,`f`).selectedClassName):tc(L(this,oc,`f`),L(this,lc,`f`).currentRange,L(this,sc,`f`),L(this,uc,`f`),L(this,cc,`f`).selectedClassName)},Sc=function(){R(this,lc,{isSelecting:!1,startInfo:null,currentRange:null},`f`)};function wc(e,t,n){return new Cc(e,t,n)}var Tc=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ec=o(((e,t)=>{t.exports=Tc()}))();function Dc(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var Oc={},kc=()=>{},Ac=Object.assign,jc=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},Mc=Object.prototype.hasOwnProperty,Nc=(e,t)=>Mc.call(e,t),Pc=Array.isArray,Fc=e=>Uc(e)===`[object Map]`,Ic=e=>Uc(e)===`[object Set]`,Lc=e=>typeof e==`function`,Rc=e=>typeof e==`string`,zc=e=>typeof e==`symbol`,Bc=e=>typeof e==`object`&&!!e,Vc=e=>(Bc(e)||Lc(e))&&Lc(e.then)&&Lc(e.catch),Hc=Object.prototype.toString,Uc=e=>Hc.call(e),Wc=e=>Uc(e).slice(8,-1),Gc=e=>Uc(e)===`[object Object]`,Kc=e=>Rc(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,qc=(e,t)=>!Object.is(e,t),Jc,Yc=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&Jc&&(Jc.active?(this.parent=Jc,this.index=(Jc.scopes||(Jc.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].pause()}for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}let n=this.effects.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}}run(e){if(this._active){let t=Jc;try{return Jc=this,e()}finally{Jc=t}}}on(){++this._on===1&&(this.prevScope=Jc,Jc=this)}off(){if(this._on>0&&--this._on===0){if(Jc===this)Jc=this.prevScope;else{let e=Jc;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){let e=this.scopes.slice();for(t=0,n=e.length;t<n;t++)e[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function Xc(e){return new Yc(e)}function Zc(){return Jc}var Qc,$c=new WeakSet,el=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Jc&&(Jc.active?Jc.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,$c.has(this)&&($c.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||il(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,_l(this),sl(this);let e=Qc,t=pl;Qc=this,pl=!0;try{return this.fn()}finally{cl(this),Qc=e,pl=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)dl(e);this.deps=this.depsTail=void 0,_l(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?$c.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){ll(this)&&this.run()}get dirty(){return ll(this)}},tl=0,nl,rl;function il(e,t=!1){e.flags|=8,t?(e.next=rl,rl=e):(e.next=nl,nl=e)}function al(){tl++}function ol(){if(--tl>0)return;if(rl){let e=rl;for(rl=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;nl;){let t=nl;for(nl=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function sl(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function cl(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),dl(r),fl(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function ll(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(ul(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function ul(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===vl)||(e.globalVersion=vl,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!ll(e))))return;e.flags|=2;let t=e.dep,n=Qc,r=pl;Qc=e,pl=!0;try{sl(e);let n=e.fn(e._value);(t.version===0||qc(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{Qc=n,pl=r,cl(e),e.flags&=-3}}function dl(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)dl(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function fl(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var pl=!0,ml=[];function hl(){ml.push(pl),pl=!1}function gl(){let e=ml.pop();pl=e===void 0||e}function _l(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=Qc;Qc=void 0;try{t()}finally{Qc=e}}}var vl=0,yl=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},bl=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!Qc||!pl||Qc===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==Qc)t=this.activeLink=new yl(Qc,this),Qc.deps?(t.prevDep=Qc.depsTail,Qc.depsTail.nextDep=t,Qc.depsTail=t):Qc.deps=Qc.depsTail=t,xl(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=Qc.depsTail,t.nextDep=void 0,Qc.depsTail.nextDep=t,Qc.depsTail=t,Qc.deps===t&&(Qc.deps=e)}return t}trigger(e){this.version++,vl++,this.notify(e)}notify(e){al();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{ol()}}};function xl(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)xl(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var Sl=new WeakMap,Cl=Symbol(``),wl=Symbol(``),Tl=Symbol(``);function El(e,t,n){if(pl&&Qc){let t=Sl.get(e);t||Sl.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new bl),r.map=t,r.key=n),r.track()}}function Dl(e,t,n,r,i,a){let o=Sl.get(e);if(!o){vl++;return}let s=e=>{e&&e.trigger()};if(al(),t===`clear`)o.forEach(s);else{let i=Pc(e),a=i&&Kc(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===Tl||!zc(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(Tl)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(Cl)),Fc(e)&&s(o.get(wl)));break;case`delete`:i||(s(o.get(Cl)),Fc(e)&&s(o.get(wl)));break;case`set`:Fc(e)&&s(o.get(Cl))}}ol()}function Ol(e){let t=pu(e);return t===e||(El(t,`iterate`,Tl),du(e))?t:uu(e)?lu(e)?t.map(e=>hu(mu(e))):t.map(hu):t.map(mu)}function kl(e){return El(e=pu(e),`iterate`,Tl),e}function Al(e,t){return uu(e)?hu(lu(e)?mu(t):t):mu(t)}var jl={__proto__:null,[Symbol.iterator](){return Ml(this,Symbol.iterator,e=>Al(this,e))},concat(...e){return Ol(this).concat(...e.map(e=>Pc(e)?Ol(e):e))},entries(){return Ml(this,`entries`,e=>(e[1]=Al(this,e[1]),e))},every(e,t){return Fl(this,`every`,e,t,void 0,arguments)},filter(e,t){return Fl(this,`filter`,e,t,e=>e.map(e=>Al(this,e)),arguments)},find(e,t){return Fl(this,`find`,e,t,e=>Al(this,e),arguments)},findIndex(e,t){return Fl(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return Fl(this,`findLast`,e,t,e=>Al(this,e),arguments)},findLastIndex(e,t){return Fl(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return Fl(this,`forEach`,e,t,void 0,arguments)},includes(...e){return Ll(this,`includes`,e)},indexOf(...e){return Ll(this,`indexOf`,e)},join(e){return Ol(this).join(e)},lastIndexOf(...e){return Ll(this,`lastIndexOf`,e)},map(e,t){return Fl(this,`map`,e,t,void 0,arguments)},pop(){return Rl(this,`pop`)},push(...e){return Rl(this,`push`,e)},reduce(e,...t){return Il(this,`reduce`,e,t)},reduceRight(e,...t){return Il(this,`reduceRight`,e,t)},shift(){return Rl(this,`shift`)},some(e,t){return Fl(this,`some`,e,t,void 0,arguments)},splice(...e){return Rl(this,`splice`,e)},toReversed(){return Ol(this).toReversed()},toSorted(e){return Ol(this).toSorted(e)},toSpliced(...e){return Ol(this).toSpliced(...e)},unshift(...e){return Rl(this,`unshift`,e)},values(){return Ml(this,`values`,e=>Al(this,e))}};function Ml(e,t,n){let r=kl(e),i=r[t],a=i.call(r);if(r!==e&&!du(e)){if(a[Symbol.toStringTag]===`Array Iterator`){let e=Object.create(Object.getPrototypeOf(a));return e.next=()=>Nl(a.next(),n),i!==Pl[t]&&Object.defineProperties(e,{return:{get(){let e=a.return;return typeof e==`function`?e.bind(a):e}},throw:{get(){let e=a.throw;return typeof e==`function`?e.bind(a):e}}}),e}a._next=a.next,a.next=()=>Nl(a._next(),n)}return a}function Nl(e,t){return e.done||(e.value=t(e.value)),e}var Pl=Array.prototype;function Fl(e,t,n,r,i,a){let o=kl(e),s=o!==e&&!du(e),c=o[t];if(c!==Pl[t]){let t=c.apply(e,a);return s?mu(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,Al(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function Il(e,t,n,r){let i=kl(e),a=i!==e&&!du(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=Al(e,t)),n.call(this,t,Al(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?Al(e,c):c}function Ll(e,t,n){let r=pu(e);El(r,`iterate`,Tl);let i=r[t](...n);return(i===-1||i===!1)&&fu(n[0])?(n[0]=pu(n[0]),r[t](...n)):i}function Rl(e,t,n=[]){hl(),al();let r=pu(e)[t].apply(e,n);return ol(),gl(),r}var zl=Dc(`__proto__,__v_isRef,__isVue`),Bl=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(zc));function Vl(e){zc(e)||(e=String(e));let t=pu(this);return El(t,`has`,e),t.hasOwnProperty(e)}var Hl=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?iu:ru:i?nu:tu).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=Pc(e);if(!r){let e;if(a&&(e=jl[t]))return e;if(t===`hasOwnProperty`)return Vl}let o=Reflect.get(e,t,gu(e)?e:n);if((zc(t)?Bl.has(t):zl(t))||(r||El(e,`get`,t),i))return o;if(gu(o)){let e=a&&Kc(t)?o:o.value;return r&&Bc(e)?su(e):e}return Bc(o)?r?su(o):ou(o):o}},Ul=class extends Hl{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=Pc(e)&&Kc(t);if(!this._isShallow){let e=uu(i);if(!du(n)&&!uu(n)&&(i=pu(i),n=pu(n)),!a&&gu(i)&&!gu(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:Nc(e,t),s=Reflect.set(e,t,n,gu(e)?e:r);return e===pu(r)&&s&&(o?qc(n,i)&&Dl(e,`set`,t,n,i):Dl(e,`add`,t,n)),s}deleteProperty(e,t){let n=Nc(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&Dl(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!zc(t)||!Bl.has(t))&&El(e,`has`,t),n}ownKeys(e){return El(e,`iterate`,Pc(e)?`length`:Cl),Reflect.ownKeys(e)}},Wl=class extends Hl{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Gl=new Ul,Kl=new Wl,ql=e=>e,Jl=e=>Reflect.getPrototypeOf(e);function Yl(e,t,n){return function(...r){let i=this.__v_raw,a=pu(i),o=Fc(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?ql:t?hu:mu;return!t&&El(a,`iterate`,c?wl:Cl),Ac(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function Xl(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Zl(e,t){let n={get(n){let r=this.__v_raw,i=pu(r),a=pu(n);e||(qc(n,a)&&El(i,`get`,n),El(i,`get`,a));let{has:o}=Jl(i),s=t?ql:e?hu:mu;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&El(pu(t),`iterate`,Cl),t.size},has(t){let n=this.__v_raw,r=pu(n),i=pu(t);return e||(qc(t,i)&&El(r,`has`,t),El(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=pu(a),s=t?ql:e?hu:mu;return!e&&El(o,`iterate`,Cl),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return Ac(n,e?{add:Xl(`add`),set:Xl(`set`),delete:Xl(`delete`),clear:Xl(`clear`)}:{add(e){let n=pu(this),r=Jl(n),i=pu(e),a=!t&&!du(e)&&!uu(e)?i:e;return r.has.call(n,a)||qc(e,a)&&r.has.call(n,e)||qc(i,a)&&r.has.call(n,i)||(n.add(a),Dl(n,`add`,a,a)),this},set(e,n){!t&&!du(n)&&!uu(n)&&(n=pu(n));let r=pu(this),{has:i,get:a}=Jl(r),o=i.call(r,e);o||=(e=pu(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?qc(n,s)&&Dl(r,`set`,e,n,s):Dl(r,`add`,e,n),this},delete(e){let t=pu(this),{has:n,get:r}=Jl(t),i=n.call(t,e);i||=(e=pu(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&Dl(t,`delete`,e,void 0,a),o},clear(){let e=pu(this),t=e.size!==0,n=e.clear();return t&&Dl(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Yl(r,e,t)}),n}function Ql(e,t){let n=Zl(e,t);return(r,i,a)=>i===`__v_isReactive`?!e:i===`__v_isReadonly`?e:i===`__v_isShallow`?t:i===`__v_raw`?r:Reflect.get(Nc(n,i)&&i in r?n:r,i,a)}var $l={get:Ql(!1,!1)},eu={get:Ql(!0,!1)},tu=new WeakMap,nu=new WeakMap,ru=new WeakMap,iu=new WeakMap;function au(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function ou(e){return uu(e)?e:cu(e,!1,Gl,$l,tu)}function su(e){return cu(e,!0,Kl,eu,ru)}function cu(e,t,n,r,i){if(!Bc(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=au(Wc(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function lu(e){return uu(e)?lu(e.__v_raw):!!(e&&e.__v_isReactive)}function uu(e){return!!(e&&e.__v_isReadonly)}function du(e){return!!(e&&e.__v_isShallow)}function fu(e){return e?!!e.__v_raw:!1}function pu(e){let t=e&&e.__v_raw;return t?pu(t):e}var mu=e=>Bc(e)?ou(e):e,hu=e=>Bc(e)?su(e):e;function gu(e){return e?e.__v_isRef===!0:!1}function _u(e){return vu(e,!1)}function vu(e,t){return gu(e)?e:new yu(e,t)}var yu=class{constructor(e,t){this.dep=new bl,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:pu(e),this._value=t?e:mu(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||du(e)||uu(e);e=n?e:pu(e),qc(e,t)&&(this._rawValue=e,this._value=n?e:mu(e),this.dep.trigger())}},bu={SKIP:`__v_skip`,IS_REACTIVE:`__v_isReactive`,IS_READONLY:`__v_isReadonly`,IS_SHALLOW:`__v_isShallow`,RAW:`__v_raw`,IS_REF:`__v_isRef`},xu={},Su=new WeakMap,Cu=void 0;function wu(e,t=!1,n=Cu){if(n){let t=Su.get(n);t||Su.set(n,t=[]),t.push(e)}}function Tu(e,t,n=Oc){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:du(e)||i===!1||i===0?Eu(e,1):Eu(e),u,d,f,p,m=!1,h=!1;if(gu(e)?(d=()=>e.value,m=du(e)):lu(e)?(d=()=>l(e),m=!0):Pc(e)?(h=!0,m=e.some(e=>lu(e)||du(e)),d=()=>e.map(e=>{if(gu(e))return e.value;if(lu(e))return l(e);if(Lc(e))return c?c(e,2):e()})):d=Lc(e)?t?c?()=>c(e,2):e:()=>{if(f){hl();try{f()}finally{gl()}}let t=Cu;Cu=u;try{return c?c(e,3,[p]):e(p)}finally{Cu=t}}:kc,t&&i){let e=d,t=i===!0?1/0:i;d=()=>Eu(e(),t)}let g=Zc(),_=()=>{u.stop(),g&&g.active&&jc(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{try{return e(...t)}finally{_()}}}let v=h?Array(e.length).fill(xu):xu,y=e=>{if(u.flags&1&&(u.dirty||e)){if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>qc(e,v[t])):qc(n,v))){let e=Cu;hl();try{f&&f(),Cu=u;let e=[n,v===xu?void 0:h&&v[0]===xu?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{Cu=e,gl()}}}else u.run()}};return s&&s(y),u=new el(d),u.scheduler=o?()=>o(y,!1):y,p=e=>wu(e,!1,u),f=u.onStop=()=>{let e=Su.get(u);if(e){if(c)c(e,4);else for(let t of e)t();Su.delete(u)}},t?r?y(!0):v=u.run():o?o(y.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function Eu(e,t=1/0,n){if(t<=0||!Bc(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,gu(e))Eu(e.value,t,n);else if(Pc(e))for(let r=0;r<e.length;r++)Eu(e[r],t,n);else if(Ic(e)||Fc(e))e.forEach(e=>{Eu(e,t,n)});else if(Gc(e)){for(let r in e)Eu(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Eu(e[r],t,n)}return e}var Du;(function(e){e.$$__ignore__$$=`$$__ignore__$$`,e.$$__persist__$$=`$$__persist__$$`,e.$$__subscribe__$$=`$$__subscribe__$$`,e.$$__redux_dev_tool__$$=`$$__redux_dev_tool__$$`})(Du||={});var Ou=new Set,ku=20,Au=!1,ju=0,Mu=()=>{let e=[...Ou.values()].slice(0);Ou.clear();for(let t of e)t.notify();if(Au=!1,Ou.size){if(ju++,ju>ku)throw Error(`[reactivity-store] detected an infinite update loop, pendingJobs: ${[...Ou].map(e=>e._namespace||`unknown`).join(`, `)}`);Mu()}},Nu=e=>{Ou.add(e),!Au&&(Au=!0,ju=0,Promise.resolve().then(Mu))},Pu=null;function Fu(){return Pu}var Iu=class extends el{get _isControllerEffect(){return!0}constructor(e){super(e)}},Lu=(e,t)=>()=>{if(t._isActive)try{let t=e();if(Vc(t))throw Error(`[reactivity-store] selector should be a pure function, but current is an async function`);return t}catch{return null}},Ru=class{constructor(e,t,n,r,i){this._getState=e,this._compare=t,this._lifeCycle=n,this._namespace=r,this._onUpdate=i,this._listeners=new Set,this._updateCount=0,this._isActive=!0,this.notify=()=>{var e;if(this._isActive){this._updateCount++;try{(e=this._onUpdate)==null||e.call(this)}catch{this._lifeCycle.canUpdateComponent=!1}this._listeners.forEach(e=>e())}},this._scheduler=()=>{let e=Fu();Pu=this;let t=this._effect.run();if(Pu=e,!this._isActive)return;let n=this._compare(this._state,t);this._state=t,n||this._lifeCycle.canUpdateComponent&&(this._lifeCycle.syncUpdateComponent?this.notify():Nu(this))},this.subscribe=e=>(this._listeners.add(e),()=>this._listeners.delete(e)),this.getState=()=>this._updateCount,this.getEffect=()=>this._effect,this.getSelectorState=()=>this._getStateSafe(),this.getLifeCycle=()=>this._lifeCycle,this._getStateSafe=Lu(e,this),this._effect=new Iu(this._getStateSafe),this._effect.scheduler=this._scheduler}run(){let e=Fu();Pu=this,this._state=this._effect.run(),Pu=e}stop(){this._effect.stop(),this._listeners.clear(),this._isActive=!1,this._state=null}setActive(e){this._isActive=e}},zu=()=>({onBeforeMount:[],onBeforeUpdate:[],onBeforeUnmount:[],onMounted:[],onUpdated:[],onUnmounted:[],hasHookInstall:!1,canUpdateComponent:!0,syncUpdateComponent:!1});function Bu(e,t){if(!Bc(e)||e[bu.SKIP]||(0,F.isValidElement)(e)||(t||=new Set,t.has(e)))return e;if(t.add(e),gu(e))Hu(e.value,t);else if(Pc(e))for(let n=0;n<e.length;n++)Hu(e[n],t);else if(Ic(e)||Fc(e))e.forEach(e=>{Hu(e,t)});else if(Gc(e))for(let n in e)Hu(e[n],t);return e}function Vu(e){if(!Bc(e)||e[bu.SKIP]||(0,F.isValidElement)(e))return e;if(gu(e))e.value;else if(Pc(e))for(let t=0;t<e.length;t++)e[t];else if(Ic(e)||Fc(e))e.forEach(e=>{});else if(Gc(e))for(let t in e)e[t];return e}function Hu(e,t){return Bu(e,t)}var Uu=e=>{let t=(0,F.useRef)(e);return t.current=e,(0,F.useCallback)((...e)=>t.current?.call(null,...e),[])},Wu=(e,t)=>{let n=(0,F.useRef)();return n.current=typeof e==`function`?e:null,Uu(e=>{if(n.current){let r=n.current(e);return t?Hu(r):Vu(r),r}return t?Hu(e):Vu(e),e})},Gu=e=>{let t=(0,F.useRef)(e);return(0,F.useEffect)(()=>{t.current=e},[e]),t.current},Ku=(e,t,n,r,i=!0,a=!1,o=!0,s,c=void 0)=>{let l=new Set,u=!0;s||=Du.$$__ignore__$$;let d=s===Du.$$__ignore__$$?`RStoreAnonymous`:s;d=d.startsWith(`use`)?d:`use${d.charAt(0).toUpperCase()}${d.slice(1)}`;let f=n=>{let u=n==="default"?i:n===`deep`||n===`deep-stable`,d=n==="default"?a:n===`deep-stable`||n===`shallow-stable`;function f(n,i){let a=(0,F.useRef)(),f=Wu(n,u),p=Uu(()=>{n?a.current=n(Object.assign(Object.assign({},t),c)):a.current=Object.assign(Object.assign({},t),c)}),m=Uu((e,t)=>i&&typeof i==`function`?i(e,t):!1),h=d?n:Gu(n),g=o?i:Gu(i),_=(0,F.useMemo)(()=>new Ru(()=>f(e),m,r,s,p),[]);return(0,Ec.useSyncExternalStore)(_.subscribe,_.getState,_.getState),(0,F.useMemo)(()=>{_.run(),p()},[_,p]),(0,F.useMemo)(()=>{h!==n&&(_.run(),p())},[_,h,n]),(0,F.useMemo)(()=>{g!==i&&(_.run(),p())},[_,g,i]),(0,F.useEffect)(()=>(_.setActive(!0),l.add(_),()=>{_.stop(),l.delete(_)}),[_]),a.current}return f},p=()=>{let[e,t]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(r.hasHookInstall){if(!e)r.onBeforeMount.forEach(e=>e()),r.onMounted.forEach(e=>e()),t(!0);else{let e=r.syncUpdateComponent;r.syncUpdateComponent=!0,r.canUpdateComponent=!1,r.onBeforeUpdate.forEach(e=>e()),r.canUpdateComponent=!0,r.syncUpdateComponent=e,r.onUpdated.forEach(e=>e())}}}),(0,F.useEffect)(()=>()=>{r.hasHookInstall&&(r.onBeforeUnmount.forEach(e=>e()),r.onUnmounted.forEach(e=>e()))},[r])},m=({key:t,value:n,single:r,compare:i=Object.is})=>new Promise((a,o)=>{if(r?.aborted){o(r.reason);return}let s=()=>e[t],c=({cb:e}={})=>i(pu(s()),pu(n))?(e?.(),a(),!0):!1;if(!c()){let e=Tu(s,()=>c({cb:()=>e.stop()}));r&&r.addEventListener(`abort`,()=>{e.stop(),o(r.reason)},{once:!0})}}),h=f(`default`),g=f(`deep`),_=f(`deep-stable`),v=f(`shallow`),y=f(`shallow-stable`);function b(e,t){return h(e,t)}let x=b;return x.getState=()=>pu(n),x.getLifeCycle=()=>r,x.getActions=()=>c,x.getReactiveState=()=>e,x.getReadonlyState=()=>t,x.waitingValueTo=m,x.useLifeCycle=p,x.useDeepSelector=g,x.useDeepStableSelector=_,x.useShallowSelector=v,x.useShallowStableSelector=y,x.subscribe=(t,n,i)=>{let a=new Ru(()=>{let n=t(e);return i?Vu(n):Hu(n),n},Object.is,r,Du.$$__subscribe__$$,()=>n());return a.run(),l.add(a),()=>{l.delete(a),a.stop()}},x.getIsActive=()=>u,x.clear=()=>{l.forEach(e=>e.stop()),u=!1},x},qu=e=>e.$$__state__$$?e.$$__state__$$:e,Ju=(e,t=`createStore`,n)=>{let r=qu(e());return Ku(ou(r),su(r),pu(r),n||zu())},Yu=(e,t=`createStore`,n)=>{let r=Xc(),i=r.run(()=>Ju(e,t,n));return i.scope=r,i},Xu=e=>Yu(e);function Zu(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Qu(e,t,n,r,i){if(typeof t==`function`||!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return t.set(e,n),n}var $u,ed,td,nd,rd=null,id=(e,t)=>`${e.fontFamily}-${e.fontStyle}-${e.fontSize}-${t}`,ad=(e,t)=>id(e,`0`.repeat(t.length)),od=class{constructor(){$u.add(this),ed.set(this,``),td.set(this,{})}measure(e,t){let n=ad(t||{},e);if(Zu(this,td,`f`)[n])return Zu(this,td,`f`)[n];let r=Zu(this,$u,`m`,nd).call(this);if(t){let e=`${t.fontFamily}-${t.fontStyle}-${t.fontSize}`;Zu(this,ed,`f`)!==e&&(Qu(this,ed,e),r.font=`${t.fontStyle||``} ${t.fontSize||``} ${t.fontFamily||``}`)}else r.font=``;return r.measureText(e).width}};ed=new WeakMap,td=new WeakMap,$u=new WeakSet,nd=function(){return rd||=document.createElement(`canvas`).getContext(`2d`),rd};var sd=null,cd=()=>(sd||=new od,sd),ld=`--diff-add-content--`,ud=`--diff-del-content--`,dd=`--diff-border--`,fd=`--diff-add-lineNumber--`,pd=`--diff-del-lineNumber--`,md=`--diff-plain-content--`,hd=`--diff-expand-content--`,gd=`--diff-plain-lineNumber-color--`,_d=`--diff-expand-lineNumber-color--`,vd=`--diff-plain-lineNumber--`,yd=`--diff-expand-lineNumber--`,bd=`--diff-hunk-content--`,xd=`--diff-hunk-content-color--`,Sd=`--diff-hunk-lineNumber--`,Cd=`--diff-add-widget--`,wd=`--diff-add-widget-color--`,Td=`--diff-empty-content--`,Ed=(e,t,n)=>e?`var(${ld})`:t?`var(${ud})`:n?`var(${md})`:`var(${hd})`,Dd=(e,t,n)=>e?`var(${fd})`:t?`var(${pd})`:n?`var(${vd})`:`var(${yd})`,Od=()=>{var e;(e=window.getSelection())==null||e.removeAllRanges()},kd=(e,t)=>{let n=function(n){n!==null&&n.target!==null&&(n.target===e?(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft):(e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft))};return e.onscroll||=n,t.onscroll||=n,()=>{e.onscroll=null,t.onscroll=null}},Ad=e=>{if(e){let t=e.getRootNode();return t instanceof ShadowRoot?t:e.ownerDocument}return document},jd=e=>{if(e){if(typeof e.closest==`function`){let t=e.closest(`[data-component="git-diff-view"]`),n=(t?.querySelector)?.call(t,`.diff-view-wrapper`);return(n?.getAttribute)?.call(n,`id`)}{let t=e;for(;t;){if(t.getAttribute&&t.getAttribute(`data-component`)===`git-diff-view`)return t.querySelector(`.diff-view-wrapper`)?.getAttribute(`id`);t=t.parentElement}}}},Md=`--diff-font-size--`,Nd=`--diff-aside-width--`,Pd=e=>{let t={};return(n=>{if(t[n])return t[n];let r=e(n);return t[n]=r,r})},Fd;(function(e){e[e.CRLF=1]=`CRLF`,e[e.CR=2]=`CR`,e[e.LF=3]=`LF`,e[e.NEWLINE=4]=`NEWLINE`,e[e.NORMAL=5]=`NORMAL`,e[e.NULL=6]=`NULL`})(Fd||={});var Id;(function(e){e[e.SplitGitHub=1]=`SplitGitHub`,e[e.SplitGitLab=2]=`SplitGitLab`,e[e.Split=3]=`Split`,e[e.Unified=4]=`Unified`})(Id||={});var Ld=()=>{let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{t(!0)},[]),e},Rd=typeof window<`u`?F.useLayoutEffect:F.useEffect,zd=({text:e,font:t})=>{let[n,r]=(0,F.useState)(()=>{let n=parseInt(t.fontSize||`13`),r=6;return r+=n>10?(n-10)*.6:0,r*e.length});return Rd(()=>{let n=cd().measure(e,t);r(n)},[e,t]),n},Bd=({side:e,className:t,lineNumber:n,onWidgetClick:r,onOpenAddWidget:i})=>(0,I.jsx)(`div`,{"data-add-widget":z[e],className:`diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible`+(t?` `+t:``),style:{width:`calc(var(${Md}) * 1.4)`,height:`calc(var(${Md}) * 1.4)`,top:`calc(var(${Md}) * 0.1)`},children:(0,I.jsx)(`button`,{className:`diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]`,style:{color:`var(${wd})`,backgroundColor:`var(${Cd})`},onMouseDown:t=>{t.stopPropagation(),i(n,e),r?.(n,e)},children:`+`})}),Vd=({lineNumber:e,side:t,onWidgetClick:n,onOpenAddWidget:r})=>(0,I.jsx)(`div`,{"data-add-widget":z[t],className:`diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible`,style:{width:`calc(var(${Md}) * 1.4)`,height:`calc(var(${Md}) * 1.4)`,top:`calc(var(${Md}) * 0.1)`},children:(0,I.jsx)(`button`,{className:`diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]`,style:{color:`var(${wd})`,backgroundColor:`var(${Cd})`},onMouseDown:i=>{i.stopPropagation(),r(e,t),n?.(e,t)},children:`+`})}),Hd=()=>(0,I.jsxs)(`svg`,{"aria-label":`No newline at end of file`,role:`img`,viewBox:`0 0 16 16`,version:`1.1`,fill:`currentColor`,children:[(0,I.jsx)(`path`,{d:`M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z`}),(0,I.jsx)(`path`,{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z`})]}),Ud={},Wd=e=>{if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)},Gd=Pd(e=>{if(!e)return Ud;let t={};return e.split(`;`).forEach(e=>{let[n,r]=e.split(`:`);if(!n)return;let i=Wd(n.trim());t[i]=r.trim()}),t}),Kd=({rawLine:e,diffLine:t,operator:n,plainLine:r,enableWrap:i})=>{let a=t?.changes;if(a?.hasLineChange){let r=a.newLineSymbol;if(!t?.plainTemplate&&typeof eo==`function`&&eo({diffLine:t,rawLine:e,operator:n}),t?.plainTemplate)return(0,I.jsxs)(`span`,{className:`diff-line-content-raw`,children:[(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:t.plainTemplate}}),r===Fd.NEWLINE&&(0,I.jsx)(`span`,{"data-no-newline-at-end-of-file-symbol":!0,className:i?`block !text-red-500`:`inline-block align-middle !text-red-500`,style:{width:`var(${Md})`,height:`var(${Md})`},children:(0,I.jsx)(Hd,{})})]})}return r&&!r?.template&&(r.template=ao(r.value)),r?.template?(0,I.jsx)(`span`,{className:`diff-line-content-raw`,children:(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:r.template}})}):(0,I.jsx)(`span`,{className:`diff-line-content-raw`,children:e})},qd=({rawLine:e,diffFile:t,diffLine:n,operator:r,syntaxLine:i,enableWrap:a})=>{if(!i)return(0,I.jsx)(Kd,{rawLine:e,diffLine:n,operator:r,enableWrap:a});let o=n?.changes;if(o?.hasLineChange){let e=o.newLineSymbol;if(!n?.syntaxTemplate&&typeof no==`function`&&no({diffFile:t,diffLine:n,syntaxLine:i,operator:r}),n?.syntaxTemplate)return(0,I.jsxs)(`span`,{className:`diff-line-syntax-raw`,children:[(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:n.syntaxTemplate}}),e===Fd.NEWLINE&&(0,I.jsx)(`span`,{"data-no-newline-at-end-of-file-symbol":!0,className:a?`block !text-red-500`:`inline-block align-middle !text-red-500`,style:{width:`var(${Md})`,height:`var(${Md})`},children:(0,I.jsx)(Hd,{})})]})}return i.template||=io(i),i?.template?(0,I.jsx)(`span`,{className:`diff-line-syntax-raw`,children:(0,I.jsx)(`span`,{"data-template":!0,dangerouslySetInnerHTML:{__html:i.template}})}):(0,I.jsx)(`span`,{className:`diff-line-syntax-raw`,children:(i?.nodeList)?.map(({node:e,wrapper:t},n)=>(0,I.jsx)(`span`,{"data-start":e.startIndex,"data-end":e.endIndex,className:(t?.properties?.className)?.join(` `),style:Gd(t?.properties?.style||``),children:e.value},n))})},Jd=({diffFile:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,enableWrap:a,enableHighlight:o})=>{let s=t?.type===Ba.Add,c=t?.type===Ba.Delete,l=i&&i?.nodeList?.length>150;return(0,I.jsxs)(`div`,{className:`diff-line-content-item pl-[2.0em]`,style:{whiteSpace:a?`pre-wrap`:`pre`,wordBreak:a?`break-all`:`initial`},children:[(0,I.jsx)(`span`,{"data-operator":s?`+`:c?`-`:void 0,className:`diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]`,children:s?`+`:c?`-`:` `}),o&&i&&!l?(0,I.jsx)(qd,{operator:s?`add`:c?`del`:void 0,rawLine:n,diffFile:e,diffLine:t,syntaxLine:i,enableWrap:a}):(0,I.jsx)(Kd,{operator:s?`add`:c?`del`:void 0,rawLine:n,diffLine:t,plainLine:r,enableWrap:a})]})},Yd=(0,F.createContext)(null);Yd.displayName=`DiffViewContext`;var Xd=()=>(0,F.useContext)(Yd),Zd=(0,F.createContext)(null);Zd.displayName=`DiffWidgetContext`;var Qd=()=>(0,F.useContext)(Zd),$d=({index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})=>{let o=r===z.old?t.getOldSyntaxLine:t.getNewSyntaxLine,s=r===z.old?t.getOldPlainLine:t.getNewPlainLine,c=t.getSplitLeftLine(e),l=t.getSplitRightLine(e),u=r===z.old?c:l,d=!!u?.diff,f=!!u?.lineNumber,p=Ha(u?.diff),m=u?.diff?.type===Ba.Add,h=u?.diff?.type===Ba.Delete,{useDiffContext:g}=Xd(),_=g.getReadonlyState().onAddWidgetClick,{useWidget:v}=Qd(),y=v.getReadonlyState().setWidget,b=Ed(m,h,d),x=Dd(m,h,d),S=o(u.lineNumber??-1),C=s(u.lineNumber??-1);return(0,I.jsx)(`tr`,{"data-line":n,"data-state":d||!f?`diff`:`plain`,"data-side":z[r],className:`diff-line`+(f?` group`:``),children:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-${z[r]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`,style:{backgroundColor:x,color:`var(${d?gd:_d})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:[d&&i&&(0,I.jsx)(Bd,{index:e,lineNumber:u.lineNumber??-1,side:r,diffFile:t,onWidgetClick:(...e)=>_.current?.call(_,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>y({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":u.lineNumber,style:{opacity:p?void 0:.5},children:u.lineNumber})]}),(0,I.jsx)(`td`,{className:`diff-line-${z[r]}-content pr-[10px] align-top`,style:{backgroundColor:b},children:(0,I.jsx)(Jd,{enableWrap:!1,diffFile:t,rawLine:u?.value||``,diffLine:u?.diff,plainLine:C,syntaxLine:S,enableHighlight:a})})]}):(0,I.jsx)(`td`,{className:`diff-line-${z[r]}-placeholder select-none`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`span`,{children:` `})})})},ef=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})=>(r===z.old?t.getSplitLeftLine:t.getSplitRightLine)(e)?.isHidden?null:(0,I.jsx)($d,{index:e,diffFile:t,lineNumber:n,side:r,enableAddWidget:i,enableHighlight:a})),tf=({selector:e,enable:t})=>{let[n,r]=(0,F.useState)(0),{useDiffContext:i}=Xd(),{id:a,mounted:o,dom:s}=i.useShallowStableSelector(e=>({id:e.id,mounted:e.mounted,dom:e.dom}));return(0,F.useEffect)(()=>{if(t){let t=Ad(s).querySelector(`#diff-root${a}`)?.querySelector(e);if(!t)return;let n=t,i=()=>{let e=t?.getBoundingClientRect();r(e?.width??0)};i();let o=()=>{var e,t;(e=n?.__observeCallback)==null||e.delete(i),n?.__observeCallback?.size===0&&((t=n.__observeInstance)==null||t.disconnect(),n.removeAttribute(`data-observe`),delete n.__observeCallback,delete n.__observeInstance)};if(n.__observeCallback)return n.__observeCallback.add(i),()=>o();n.__observeCallback=new Set,n.__observeCallback.add(i);let c=new ResizeObserver(()=>(n?.__observeCallback)?.forEach(e=>e()));return n.__observeInstance=c,c.observe(n),n.setAttribute(`data-observe`,`height`),()=>o()}},[e,t,a,o,s]),n},nf=({selector:e,wrapper:t,side:n,enable:r})=>{let{useDiffContext:i}=Xd(),{id:a,mounted:o,dom:s}=i.useShallowStableSelector(e=>({id:e.id,mounted:e.mounted,dom:e.dom}));(0,F.useEffect)(()=>{if(r){let r=Ad(s).querySelector(`#diff-root${a}`),i=Array.from(r?.querySelectorAll(e)||[]),o=t?Array.from(r?.querySelectorAll(t)||[]):i;if(i.length===2&&o.length===2){let e=i[0],t=i[1],r=o[0],a=o[1],s=e.getAttribute(`data-side`)===n?e:t,c=s,l=()=>{e.style.height=`auto`,t.style.height=`auto`;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=Math.max(n.height,i.height);r.style.height=o+`px`,a.style.height=o+`px`,r.setAttribute(`data-sync-height`,String(o)),a.setAttribute(`data-sync-height`,String(o))};l();let u=()=>{var e,t;(e=c?.__observeCallback)==null||e.delete(l),c?.__observeCallback?.size===0&&((t=c.__observeInstance)==null||t.disconnect(),c.removeAttribute(`data-observe`),delete c.__observeCallback,delete c.__observeInstance)};if(c.__observeCallback)return c.__observeCallback.add(l),()=>u();c.__observeCallback=new Set,c.__observeCallback.add(l);let d=new ResizeObserver(()=>(c?.__observeCallback)?.forEach(e=>e()));return c.__observeInstance=d,d.observe(s),s.setAttribute(`data-observe`,`height`),()=>u()}}},[e,r,n,a,t,o,s])},rf=({index:e,diffFile:t,oldLineExtend:n,newLineExtend:r,side:i,lineNumber:a})=>{let{useDiffContext:o}=Xd(),s=t.getSplitLeftLine(e),c=t.getSplitRightLine(e),l=o.useShallowStableSelector(e=>e.renderExtendLine),u=i===z.old?n:r,d=i===z.old?z.new:z.old,f=i===z.old?s.lineNumber:c.lineNumber,p=u?.data!==void 0&&u?.data!==null,m=n?.data!==void 0&&n?.data!==null||r?.data!==void 0&&r?.data!==null,h=m&&l?.({diffFile:t,side:i,lineNumber:f??-1,data:u?.data,onUpdate:t.notifyAll});nf({selector:`div[data-line="${a}-extend-content"]`,wrapper:`tr[data-line="${a}-extend"]`,side:z[p?i:d],enable:m&&typeof l==`function`});let g=tf({selector:i===z.old?`.old-diff-table-wrapper`:`.new-diff-table-wrapper`,enable:p&&typeof l==`function`});return l?(0,I.jsx)(`tr`,{"data-line":`${a}-extend`,"data-state":`extend`,"data-side":z[i],className:`diff-line diff-line-extend`,children:p?(0,I.jsx)(`td`,{className:`diff-line-extend-${z[i]}-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${a}-extend-content`,"data-side":z[i],className:`diff-line-extend-wrapper sticky left-0 z-[1]`,style:{width:g},children:g>0&&h})}):(0,I.jsx)(`td`,{className:`diff-line-extend-${z[i]}-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${a}-extend-content`,"data-side":z[i]})})}):null},af=({index:e,diffFile:t,side:n,lineNumber:r})=>{let{useDiffContext:i}=Xd(),a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),{oldLineExtend:s,newLineExtend:c}=i(F.useCallback(e=>({oldLineExtend:e.extendData?.oldFile?.[a?.lineNumber??-1],newLineExtend:e.extendData?.newFile?.[o?.lineNumber??-1]}),[a?.lineNumber,o?.lineNumber])),l=s?.data||c?.data,u=t.getExpandEnabled(),d=n===z.old?a:o;return!l||d.isHidden&&u?null:(0,I.jsx)(rf,{side:n,index:e,diffFile:t,lineNumber:r,oldLineExtend:s,newLineExtend:c})},of=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z`})}),sf=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z`})}),cf=({className:e})=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,height:`16`,viewBox:`0 0 16 16`,version:`1.1`,width:`16`,className:e,children:(0,I.jsx)(`path`,{d:`m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z`})}),lf=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=t.getExpandEnabled();nf({selector:`tr[data-line="${r}-hunk"]`,side:z[z.old],enable:n===z.new});let o=n===z.old,s=a&&i&&i.splitInfo,c=i&&i.splitInfo&&i.splitInfo.endHiddenIndex-i.splitInfo.startHiddenIndex<Hs,l=i&&i.isFirst,u=i&&i.isLast;return(0,I.jsx)(`tr`,{"data-line":`${r}-hunk`,"data-state":`hunk`,"data-side":z[n],className:`diff-line diff-line-hunk`,children:o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:s?l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):u?(0,I.jsx)(`button`,{className:`diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:i.splitInfo?.plainText||i.text})})]}):(0,I.jsx)(`td`,{className:`diff-line-hunk-placeholder select-none`,colSpan:2,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})})})},uf=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=t.getExpandEnabled();nf({selector:`tr[data-line="${r}-hunk"]`,side:z[z.old],enable:n===z.new});let o=a&&i&&i.splitInfo,s=i&&i.splitInfo&&i.splitInfo.endHiddenIndex-i.splitInfo.startHiddenIndex<Hs,c=i&&i.isFirst,l=i&&i.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${r}-hunk`,"data-state":`hunk`,"data-side":z[n],className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`var(${Nd})`,minWidth:`var(${Nd})`,maxWidth:`var(${Nd})`},children:o?c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:i.splitInfo?.plainText||i.text})})]})},df=({index:e,diffFile:t,side:n,lineNumber:r})=>{let{useDiffContext:i}=Xd(),a=i.useShallowStableSelector(e=>e.mode);return a===Id.SplitGitHub||a===Id.Split||a===Id.Unified?(0,I.jsx)(lf,{index:e,diffFile:t,side:n,lineNumber:r}):(0,I.jsx)(uf,{index:e,diffFile:t,side:n,lineNumber:r})},ff=({index:e,diffFile:t,side:n,lineNumber:r})=>{let i=t.getSplitHunkLine(e),a=i&&i.splitInfo&&i.splitInfo.startHiddenIndex<i.splitInfo.endHiddenIndex,o=i&&t._getIsPureDiffRender()&&!i.splitInfo;return!a&&!o?null:(0,I.jsx)(df,{index:e,diffFile:t,side:n,lineNumber:r})},pf=({index:e,side:t,diffFile:n,lineNumber:r})=>{let{useWidget:i}=Qd(),{useDiffContext:a}=Xd(),o=n.getSplitLeftLine(e),s=n.getSplitRightLine(e),c=i.useShallowStableSelector(e=>e.widgetSide),l=i.getReadonlyState().widgetLineNumber,u=i.getReadonlyState().setWidget,d=o.lineNumber&&c===z.old&&l===o.lineNumber,f=s.lineNumber&&c===z.new&&l===s.lineNumber,p=t===z.old?o:s,m=t===z.old?z.new:z.old,h=t===z.old?d:f,g=d||f,_=a.useShallowStableSelector(e=>e.renderWidgetLine),v=h&&_?.({diffFile:n,side:t,lineNumber:p.lineNumber??-1,onClose:()=>u({})});nf({selector:`div[data-line="${r}-widget-content"]`,wrapper:`tr[data-line="${r}-widget"]`,side:z[h?t:m],enable:!!g&&typeof _==`function`});let y=tf({selector:t===z.old?`.old-diff-table-wrapper`:`.new-diff-table-wrapper`,enable:!!h&&typeof _==`function`});return _?(0,I.jsx)(`tr`,{"data-line":`${r}-widget`,"data-state":`widget`,"data-side":z[t],className:`diff-line diff-line-widget`,children:h?(0,I.jsx)(`td`,{className:`diff-line-widget-${z[t]}-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${r}-widget-content`,"data-side":z[t],className:`diff-line-widget-wrapper sticky left-0 z-[1]`,style:{width:y},children:y>0&&v})}):(0,I.jsx)(`td`,{className:`diff-line-widget-${z[t]}-placeholder p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`div`,{"data-line":`${r}-widget-content`,"data-side":z[t]})})}):null},mf=({index:e,side:t,diffFile:n,lineNumber:r})=>{let{useWidget:i}=Qd();return i.useShallowSelector(F.useCallback(t=>{let r=t.widgetLineNumber,i=t.widgetSide,a=n.getSplitLeftLine(e),o=n.getSplitRightLine(e),s=a.lineNumber&&i===z.old&&r===a.lineNumber,c=o.lineNumber&&i===z.new&&r===o.lineNumber;return s||c},[n,e]),(e,t)=>e===t)?(0,I.jsx)(pf,{index:e,side:t,diffFile:n,lineNumber:r}):null},hf=({side:e,diffFile:t,enableAddWidget:n,enableHighlight:r,onMouseDown:i})=>{let a=e===z.new?`new-diff-table`:`old-diff-table`,o=Fo(t),s=t.getContentVersion();return(0,I.jsxs)(`table`,{className:a+` w-full border-collapse border-spacing-0`,"data-mode":z[e],children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`diff-table-${z[e]}-num-col`}),(0,I.jsx)(`col`,{className:`diff-table-${z[e]}-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsxs)(`th`,{scope:`col`,children:[z[e],` line number`]}),(0,I.jsxs)(`th`,{scope:`col`,children:[z[e],` line content`]})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:i,children:[o.map(i=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(ff,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t}),(0,I.jsx)(ef,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t,enableAddWidget:n,enableHighlight:r,contentVersion:s}),(0,I.jsx)(mf,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t}),(0,I.jsx)(af,{index:i.index,side:e,lineNumber:i.lineNumber,diffFile:t})]},i.index)),(0,I.jsx)(ff,{side:e,index:t.splitLineLength,lineNumber:t.splitLineLength,diffFile:t})]})]})},gf=(0,F.memo)(({diffFile:e})=>{let t=(0,F.useRef)(null),n=(0,F.useRef)(null),r=(0,F.useRef)(null),i=(0,F.useRef)(void 0),a=Math.max(e.splitLineLength,e.fileLineLength),{useDiffContext:o}=Xd(),{fontSize:s,enableAddWidget:c,enableHighlight:l}=o.useShallowStableSelector(e=>({fontSize:e.fontSize,enableAddWidget:e.enableAddWidget,enableHighlight:e.enableHighlight}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount),(0,F.useEffect)(()=>{let e=t.current,r=n.current;if(e&&r)return kd(e,r)},[]);let u=F.useMemo(()=>({fontSize:s+`px`,fontFamily:`Menlo, Consolas, monospace`}),[s]),d=zd({text:a.toString(),font:u}),f=Math.max(40,d+20),p=t=>{if(r.current){if(!t)r.current.textContent=``;else{let t=`diff-root${e.getId()}`;r.current.textContent=`#${t} [data-state="extend"] {user-select: none} \n#${t} [data-state="hunk"] {user-select: none} \n#${t} [data-state="widget"] {user-select: none}`}}},m=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let r=jd(n);if(!(r&&r!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`),t=n.getAttribute(`data-side`);if(t&&i.current!==z[t]&&(i.current=z[t],p(z[t]),Od()),e){if(e===`extend`||e===`hunk`||e===`widget`){i.current!==void 0&&(i.current=void 0,p(void 0),Od());return}return}n=n.parentElement}};return(0,I.jsxs)(`div`,{className:`split-diff-view split-diff-view-normal flex w-full basis-[50%]`,children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:r}),(0,I.jsx)(`div`,{className:`old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,ref:t,style:{[Nd]:`${Math.round(f)}px`,overscrollBehaviorX:`none`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsx)(hf,{side:z.old,diffFile:e,enableAddWidget:!!c,enableHighlight:!!l,onMouseDown:m})}),(0,I.jsx)(`div`,{className:`diff-split-line w-[1.5px]`,style:{backgroundColor:`var(${dd})`}}),(0,I.jsx)(`div`,{className:`new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,ref:n,style:{[Nd]:`${Math.round(f)}px`,overscrollBehaviorX:`none`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsx)(hf,{side:z.new,diffFile:e,enableAddWidget:!!c,enableHighlight:!!l,onMouseDown:m})})]})});gf.displayName=`DiffSplitViewNormal`;var _f=({index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})=>{let a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),s=t.getOldSyntaxLine(a?.lineNumber??-1),c=t.getOldPlainLine(a.lineNumber??-1),l=t.getNewSyntaxLine(o?.lineNumber??-1),u=t.getNewPlainLine(o.lineNumber??-1),d=!!a?.diff||!!o?.diff,f=Ha(a?.diff)||Ha(o?.diff),p=a?.diff?.type===Ba.Delete,m=o?.diff?.type===Ba.Add,{useDiffContext:h}=Xd(),g=h.getReadonlyState().onAddWidgetClick,{useWidget:_}=Qd(),v=_.getReadonlyState().setWidget,y=!!a.lineNumber,b=!!o.lineNumber,x=Ed(!1,p,d),S=Dd(!1,p,d),C=Ed(m,!1,d),w=Dd(m,!1,d);return(0,I.jsxs)(`tr`,{"data-line":n,"data-state":d?`diff`:`plain`,className:`diff-line`,children:[y?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`,"data-side":z[z.old],style:{backgroundColor:S,color:`var(${d?gd:_d})`},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:a.lineNumber??-1,side:z.old,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":a.lineNumber,style:{opacity:f?void 0:.5},children:a.lineNumber})]}),(0,I.jsxs)(`td`,{className:`diff-line-old-content group relative pr-[10px] align-top`,"data-side":z[z.old],style:{backgroundColor:x},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:a.lineNumber??-1,side:z.old,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute right-[100%] z-[1] translate-x-[50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(Jd,{enableWrap:!0,diffFile:t,rawLine:a.value||``,diffLine:a.diff,plainLine:c,syntaxLine:s,enableHighlight:i})]})]}):(0,I.jsx)(`td`,{className:`diff-line-old-placeholder select-none`,"data-side":z[z.old],style:{backgroundColor:`var(${Td})`},colSpan:2,children:(0,I.jsx)(`span`,{children:` `})}),b?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:`diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top`,"data-side":z[z.new],style:{backgroundColor:w,color:`var(${d?gd:_d})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:o.lineNumber??-1,side:z.new,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute left-[100%] z-[1] translate-x-[-50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(`span`,{"data-line-num":o.lineNumber,style:{opacity:f?void 0:.5},children:o.lineNumber})]}),(0,I.jsxs)(`td`,{className:`diff-line-new-content group relative pr-[10px] align-top`,"data-side":z[z.new],style:{backgroundColor:C},children:[d&&r&&(0,I.jsx)(Bd,{index:e,lineNumber:o.lineNumber??-1,side:z.new,diffFile:t,onWidgetClick:(...e)=>g.current?.call(g,...e),className:`absolute right-[100%] z-[1] translate-x-[50%]`,onOpenAddWidget:(e,t)=>v({lineNumber:e,side:t})}),(0,I.jsx)(Jd,{enableWrap:!0,diffFile:t,rawLine:o.value||``,diffLine:o.diff,plainLine:u,syntaxLine:l,enableHighlight:i})]})]}):(0,I.jsx)(`td`,{className:`diff-line-new-placeholder select-none border-l-[1px]`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},"data-side":z[z.new],colSpan:2,children:(0,I.jsx)(`span`,{children:` `})})]})},vf=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})=>{let a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e);return a?.isHidden&&o?.isHidden?null:(0,I.jsx)(_f,{index:e,diffFile:t,lineNumber:n,enableAddWidget:r,enableHighlight:i})}),yf=({index:e,diffFile:t,lineNumber:n,oldLineExtend:r,newLineExtend:i})=>{let{useDiffContext:a}=Xd(),o=t.getSplitLeftLine(e),s=t.getSplitRightLine(e),c=a.useShallowStableSelector(e=>e.renderExtendLine);if(!c)return null;let l=r?.data&&c?.({diffFile:t,side:z.old,lineNumber:o.lineNumber??-1,data:r.data,onUpdate:t.notifyAll}),u=i?.data&&c?.({diffFile:t,side:z.new,lineNumber:s.lineNumber??-1,data:i.data,onUpdate:t.notifyAll});return(0,I.jsxs)(`tr`,{"data-line":`${n}-extend`,"data-state":`extend`,className:`diff-line diff-line-extend`,children:[l?(0,I.jsx)(`td`,{className:`diff-line-extend-old-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-extend-wrapper`,children:l})}):(0,I.jsx)(`td`,{className:`diff-line-extend-old-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2}),u?(0,I.jsx)(`td`,{className:`diff-line-extend-new-content border-l-[1px] p-0`,style:{borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-extend-wrapper`,children:u})}):(0,I.jsx)(`td`,{className:`diff-line-extend-new-placeholder select-none border-l-[1px] p-0`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2})]})},bf=({index:e,diffFile:t,lineNumber:n})=>{let{useDiffContext:r}=Xd(),i=t.getSplitLeftLine(e),a=t.getSplitRightLine(e),{oldLineExtend:o,newLineExtend:s}=r(F.useCallback(e=>({oldLineExtend:e.extendData?.oldFile?.[i?.lineNumber??-1],newLineExtend:e.extendData?.newFile?.[a?.lineNumber??-1]}),[i?.lineNumber,a?.lineNumber])),c=o?.data||s?.data,l=t.getExpandEnabled();return!c||(i?.isHidden||a?.isHidden)&&l?null:(0,I.jsx)(yf,{index:e,diffFile:t,lineNumber:n,oldLineExtend:o,newLineExtend:s})},xf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=t.getExpandEnabled()&&r&&r.splitInfo,a=r&&r.splitInfo&&r.splitInfo.endHiddenIndex-r.splitInfo.startHiddenIndex<Hs,o=r&&r.isFirst,s=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},colSpan:3,children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})})]})},Sf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=t.getExpandEnabled()&&r&&r.splitInfo,a=r&&r.splitInfo&&r.splitInfo.endHiddenIndex-r.splitInfo.startHiddenIndex<Hs,o=r&&r.isFirst,s=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:i?o?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):s?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):a?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onSplitHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onSplitHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onSplitHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content relative pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{color:`var(${xd})`},children:r.splitInfo?.plainText||r.text})})]})},Cf=({index:e,diffFile:t,lineNumber:n})=>{let{useDiffContext:r}=Xd(),i=r.useShallowStableSelector(e=>e.mode);return i===Id.SplitGitHub||i===Id.Split||i===Id.Unified?(0,I.jsx)(xf,{index:e,diffFile:t,lineNumber:n}):(0,I.jsx)(Sf,{index:e,diffFile:t,lineNumber:n})},wf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getSplitHunkLine(e),i=r&&r.splitInfo&&r.splitInfo.startHiddenIndex<r.splitInfo.endHiddenIndex,a=r&&t._getIsPureDiffRender()&&!r.splitInfo;return!i&&!a?null:(0,I.jsx)(Cf,{index:e,diffFile:t,lineNumber:n})},Tf=({index:e,diffFile:t,lineNumber:n})=>{let{useWidget:r}=Qd(),i=r.getReadonlyState().setWidget,{useDiffContext:a}=Xd(),o=a.useShallowStableSelector(e=>e.renderWidgetLine),s=t.getSplitLeftLine(e),c=t.getSplitRightLine(e),l=r.useShallowStableSelector(e=>e.widgetSide),u=r.getReadonlyState().widgetLineNumber,d=s.lineNumber&&l===z.old&&u===s.lineNumber,f=c.lineNumber&&l===z.new&&u===c.lineNumber,p=d&&o?.({diffFile:t,side:z.old,lineNumber:s.lineNumber??-1,onClose:()=>i({})}),m=f&&o?.({diffFile:t,side:z.new,lineNumber:c.lineNumber??-1,onClose:()=>i({})});return o?(0,I.jsxs)(`tr`,{"data-line":`${n}-widget`,"data-state":`widget`,className:`diff-line diff-line-widget`,children:[p?(0,I.jsx)(`td`,{className:`diff-line-widget-old-content p-0`,colSpan:2,children:(0,I.jsx)(`div`,{className:`diff-line-widget-wrapper`,children:p})}):(0,I.jsx)(`td`,{className:`diff-line-widget-old-placeholder select-none p-0`,style:{backgroundColor:`var(${Td})`},colSpan:2}),m?(0,I.jsx)(`td`,{className:`diff-line-widget-new-content border-l-[1px] p-0`,colSpan:2,style:{borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},children:(0,I.jsx)(`div`,{className:`diff-line-widget-wrapper`,children:m})}):(0,I.jsx)(`td`,{className:`diff-line-widget-new-placeholder select-none border-l-[1px] p-0`,style:{backgroundColor:`var(${Td})`,borderLeftColor:`var(${dd})`,borderLeftStyle:`solid`},colSpan:2})]}):null},Ef=({index:e,diffFile:t,lineNumber:n})=>{let{useWidget:r}=Qd();return r.useShallowSelector(F.useCallback(n=>{let r=n.widgetLineNumber,i=n.widgetSide,a=t.getSplitLeftLine(e),o=t.getSplitRightLine(e),s=a.lineNumber&&i===z.old&&r===a.lineNumber,c=o.lineNumber&&i===z.new&&r===o.lineNumber;return s||c},[t,e]),(e,t)=>e===t)?(0,I.jsx)(Tf,{index:e,diffFile:t,lineNumber:n}):null},Df=(0,F.memo)(({diffFile:e})=>{let t=Math.max(e.splitLineLength,e.fileLineLength),{useDiffContext:n}=Xd(),r=(0,F.useRef)(null),i=(0,F.useRef)(void 0),{fontSize:a,enableAddWidget:o,enableHighlight:s}=n.useShallowStableSelector(e=>({fontSize:e.fontSize,enableAddWidget:e.enableAddWidget,enableHighlight:e.enableHighlight}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount);let c=(0,F.useMemo)(()=>({fontSize:a+`px`,fontFamily:`Menlo, Consolas, monospace`}),[a]),l=zd({text:t.toString(),font:c}),u=Math.max(40,l+20),d=Fo(e),f=e.getContentVersion(),p=t=>{if(r.current){if(!t)r.current.textContent=``;else{let n=`diff-root${e.getId()}`,i=t===z.old?z.new:z.old;r.current.textContent=`#${n} [data-side="${z[i]}"] {user-select: none} \n#${n} [data-state="extend"] {user-select: none} \n#${n} [data-state="hunk"] {user-select: none} \n#${n} [data-state="widget"] {user-select: none}`}}},m=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let r=jd(n);if(!(r&&r!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`),t=n.getAttribute(`data-side`);if(t&&i.current!==z[t]&&(i.current=z[t],p(z[t]),Od()),e){if(e===`extend`||e===`hunk`||e===`widget`){i.current!==void 0&&(i.current=void 0,p(void 0),Od());return}return}n=n.parentElement}};return(0,I.jsx)(`div`,{className:`split-diff-view split-diff-view-wrap w-full`,children:(0,I.jsxs)(`div`,{className:`diff-table-wrapper w-full`,style:{[Nd]:`${Math.round(u)}px`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:r}),(0,I.jsxs)(`table`,{className:`diff-table w-full table-fixed border-collapse border-spacing-0`,children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`diff-table-old-num-col`,width:Math.round(u)}),(0,I.jsx)(`col`,{className:`diff-table-old-content-col`}),(0,I.jsx)(`col`,{className:`diff-table-new-num-col`,width:Math.round(u)}),(0,I.jsx)(`col`,{className:`diff-table-new-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`old line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`old line content`}),(0,I.jsx)(`th`,{scope:`col`,children:`new line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`new line content`})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:m,children:[d.map(t=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(wf,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(vf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableAddWidget:!!o,enableHighlight:!!s,contentVersion:f}),(0,I.jsx)(Ef,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(bf,{index:t.index,lineNumber:t.lineNumber,diffFile:e})]},t.index)),(0,I.jsx)(wf,{index:e.splitLineLength,lineNumber:e.splitLineLength,diffFile:e})]})]})]})})});Df.displayName=`DiffSplitViewWrap`;var Of=(e,t)=>Xu(()=>{let n=_u(),r=e=>n.value=e,i=_u(t),a=e=>i.value=e,o=_u(e.diffViewMode),s=e=>o.value=e,c=_u(e.isMounted),l=e=>c.value=e,u=_u(e.diffViewWrap),d=e=>u.value=e,f=_u(e.diffViewAddWidget),p=e=>f.value=e,m=_u(e.diffViewHighlight),h=e=>m.value=e,g=_u(e.diffViewFontSize),_=e=>g.value=e,v=_u({oldFile:{...e.extendData?.oldFile},newFile:{...e.extendData?.newFile}}),y=e=>{let t=e||{},n=Object.keys(v.value.oldFile||{}),r=Object.keys(t.oldFile||{});for(let e of n)r.includes(e)||delete v.value.oldFile[e];for(let e of r)v.value.oldFile[e]=t.oldFile[e];let i=Object.keys(v.value.newFile||{}),a=Object.keys(t.newFile||{});for(let e of i)a.includes(e)||delete v.value.newFile[e];for(let e of a)v.value.newFile[e]=t.newFile[e]},b=_u(e.renderWidgetLine),x=e=>b.value=e,S=_u(e.renderExtendLine),C=e=>S.value=e,w=_u(e.onCreateUseWidgetHook),T=e=>w.value=e,E={current:e.onAddWidgetClick};return{id:i,setId:a,dom:n,setDom:r,mode:o,setMode:s,mounted:c,setMounted:l,enableWrap:u,setEnableWrap:d,enableAddWidget:f,setEnableAddWidget:p,enableHighlight:m,setEnableHighlight:h,fontSize:g,setFontSize:_,extendData:v,setExtendData:y,renderWidgetLine:b,setRenderWidgetLine:x,renderExtendLine:S,setRenderExtendLine:C,onAddWidgetClick:E,setOnAddWidgetClick:e=>E.current=e.current,onCreateUseWidgetHook:w,setOnCreateUseWidgetHook:T}}),kf=e=>Xu(()=>{let t=_u(void 0),n=_u(void 0);return{widgetSide:t,widgetLineNumber:n,setWidget:({side:r,lineNumber:i})=>{var a;let{renderWidgetLine:o}=((a=e.current)?.getReadonlyState)?.call(a)||{};typeof o==`function`&&(t.value=r,n.value=i)}}}),Af=(0,F.memo)(({diffFile:e})=>{let{useDiffContext:t}=Xd(),n=(0,F.useRef)(t);n.current=t;let{enableWrap:r,onCreateUseWidgetHook:i}=t.useShallowStableSelector(e=>({enableWrap:e.enableWrap,onCreateUseWidgetHook:e.onCreateUseWidgetHook})),a=(0,F.useMemo)(()=>kf(n),[]),o=(0,F.useMemo)(()=>({useWidget:a}),[a]);return(0,F.useEffect)(()=>{let{setWidget:e}=a.getReadonlyState();e({})},[e,a]),(0,F.useEffect)(()=>{i?.(a)},[a,i]),(0,I.jsx)(Zd.Provider,{value:o,children:r?(0,I.jsx)(Df,{diffFile:e}):(0,I.jsx)(gf,{diffFile:e})})});Af.displayName=`DiffSplitView`;var jf=({index:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,lineNumber:a,diffFile:o,setWidget:s,enableWrap:c,enableAddWidget:l,enableHighlight:u,onAddWidgetClick:d})=>(0,I.jsxs)(`tr`,{"data-line":e,"data-state":`diff`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${gd})`,backgroundColor:`var(${pd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:[l&&(0,I.jsx)(Vd,{index:e-1,lineNumber:a,diffFile:o,side:z.old,onWidgetClick:d,onOpenAddWidget:(e,t)=>s({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex`,children:[(0,I.jsx)(`span`,{"data-line-old-num":a,className:`inline-block w-[50%]`,children:a}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{className:`inline-block w-[50%]`})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:`var(${ud})`},children:(0,I.jsx)(Jd,{enableWrap:c,diffFile:o,enableHighlight:u,rawLine:n,diffLine:t,plainLine:r,syntaxLine:i})})]}),Mf=({index:e,diffLine:t,rawLine:n,plainLine:r,syntaxLine:i,lineNumber:a,diffFile:o,setWidget:s,enableWrap:c,enableAddWidget:l,enableHighlight:u,onAddWidgetClick:d})=>(0,I.jsxs)(`tr`,{"data-line":e,"data-state":`diff`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${gd})`,backgroundColor:`var(${fd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:[l&&(0,I.jsx)(Vd,{index:e-1,lineNumber:a,diffFile:o,side:z.new,onWidgetClick:d,onOpenAddWidget:(e,t)=>s({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex`,children:[(0,I.jsx)(`span`,{className:`inline-block w-[50%]`}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{"data-line-new-num":a,className:`inline-block w-[50%]`,children:a})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:`var(${ld})`},children:(0,I.jsx)(Jd,{enableWrap:c,diffFile:o,enableHighlight:u,rawLine:n,diffLine:t,plainLine:r,syntaxLine:i})})]}),Nf=({index:e,diffFile:t,lineNumber:n,enableWrap:r,enableAddWidget:i,enableHighlight:a})=>{let o=t.getUnifiedLine(e),{useDiffContext:s}=Xd(),c=s.getReadonlyState().onAddWidgetClick,{useWidget:l}=Qd(),u=l.getReadonlyState().setWidget,d=o.diff,f=Ha(o.diff),p=o.value||``,m=o.diff,h=o.newLineNumber,g=o.oldLineNumber,_=h?t.getNewSyntaxLine(h):g?t.getOldSyntaxLine(g):void 0,v=h?t.getNewPlainLine(h):g?t.getOldPlainLine(g):void 0;return f?o.oldLineNumber?(0,I.jsx)(jf,{index:n,enableWrap:r,diffFile:t,rawLine:p,diffLine:m,setWidget:u,plainLine:v,syntaxLine:_,enableHighlight:a,enableAddWidget:i,lineNumber:o.oldLineNumber,onAddWidgetClick:(...e)=>c.current?.call(c,...e)}):(0,I.jsx)(Mf,{index:n,enableWrap:r,rawLine:p,diffLine:m,diffFile:t,setWidget:u,plainLine:v,syntaxLine:_,enableHighlight:a,enableAddWidget:i,lineNumber:o.newLineNumber,onAddWidgetClick:(...e)=>c.current?.call(c,...e)}):(0,I.jsxs)(`tr`,{"data-line":n,"data-state":o.diff?`diff`:`plain`,className:`diff-line group`,children:[(0,I.jsxs)(`td`,{className:`diff-line-num sticky left-0 z-[1] w-[1%] select-none whitespace-nowrap pl-[5px] pr-[5px] text-right align-top`,style:{color:`var(${d?gd:_d})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`,backgroundColor:d?`var(${vd})`:`var(${hd})`},children:[i&&d&&(0,I.jsx)(Vd,{index:e,diffFile:t,lineNumber:o.newLineNumber??-1,side:z.new,onWidgetClick:(...e)=>c.current?.call(c,...e),onOpenAddWidget:(e,t)=>u({lineNumber:e,side:t})}),(0,I.jsxs)(`div`,{className:`flex opacity-[0.5]`,children:[(0,I.jsx)(`span`,{"data-line-old-num":o.oldLineNumber,className:`inline-block w-[50%]`,children:o.oldLineNumber}),(0,I.jsx)(`span`,{className:`w-[8px] shrink-0`}),(0,I.jsx)(`span`,{"data-line-new-num":o.newLineNumber,className:`inline-block w-[50%]`,children:o.newLineNumber})]})]}),(0,I.jsx)(`td`,{className:`diff-line-content pr-[10px] align-top`,style:{backgroundColor:d?`var(${md})`:`var(${hd})`},children:(0,I.jsx)(Jd,{enableWrap:r,diffFile:t,enableHighlight:a,rawLine:p,diffLine:m,plainLine:v,syntaxLine:_})})]})},Pf=(0,F.memo)(({index:e,diffFile:t,lineNumber:n,enableWrap:r,enableHighlight:i,enableAddWidget:a})=>t.getUnifiedLine(e)?.isHidden?null:(0,I.jsx)(Nf,{index:e,diffFile:t,lineNumber:n,enableWrap:r,enableHighlight:i,enableAddWidget:a})),Ff=({index:e,diffFile:t,lineNumber:n,enableWrap:r,oldLineExtend:i,newLineExtend:a})=>{let{useDiffContext:o}=Xd(),s=o.useShallowStableSelector(e=>e.renderExtendLine),c=t.getUnifiedLine(e),l=tf({selector:`.unified-diff-table-wrapper`,enable:typeof s==`function`});return s?(0,I.jsx)(`tr`,{"data-line":`${n}-extend`,"data-state":`extend`,className:`diff-line diff-line-extend`,children:(0,I.jsx)(`td`,{className:`diff-line-extend-content p-0 align-top`,colSpan:2,children:(0,I.jsxs)(`div`,{className:`diff-line-extend-wrapper sticky left-0 z-[1]`,style:{width:l},children:[(r?!0:l>0)&&i?.data!==void 0&&i?.data!==null&&s?.({diffFile:t,side:z.old,lineNumber:c.oldLineNumber??-1,data:i.data,onUpdate:t.notifyAll}),(r?!0:l>0)&&a?.data!==void 0&&a?.data!==null&&s?.({diffFile:t,side:z.new,lineNumber:c.newLineNumber??-1,data:a.data,onUpdate:t.notifyAll})]})})}):null},If=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useDiffContext:i}=Xd(),a=t.getUnifiedLine(e),{oldLineExtend:o,newLineExtend:s}=i((0,F.useCallback)(e=>({oldLineExtend:e.extendData?.oldFile?.[a?.oldLineNumber??-1],newLineExtend:e.extendData?.newFile?.[a?.newLineNumber??-1]}),[a.oldLineNumber,a.newLineNumber]));return!(o?.data||s?.data)||!a||a.isHidden?null:(0,I.jsx)(Ff,{index:e,diffFile:t,lineNumber:n,enableWrap:r,oldLineExtend:o,newLineExtend:s})},Lf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getUnifiedHunkLine(e),i=t.getExpandEnabled(),{useDiffContext:a}=Xd(),o=a.useShallowStableSelector(e=>e.enableWrap),s=i&&r&&r.unifiedInfo,c=r&&r.unifiedInfo&&r.unifiedInfo.endHiddenIndex-r.unifiedInfo.startHiddenIndex<Hs,l=r&&r.isFirst,u=r&&r.isLast;return(0,I.jsxs)(`tr`,{"data-line":`${n}-hunk`,"data-state":`hunk`,className:`diff-line diff-line-hunk`,children:[(0,I.jsx)(`td`,{className:`diff-line-hunk-action sticky left-0 w-[1%] select-none p-[1px]`,style:{backgroundColor:`var(${Sd})`,color:`var(${gd})`,width:`calc(var(${Nd}) * 2 + 8px)`,maxWidth:`calc(var(${Nd}) * 2 + 8px)`,minWidth:`calc(var(${Nd}) * 2 + 8px)`},children:s?l?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onUnifiedHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})}):u?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onUnifiedHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}):c?(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]`,title:`Expand All`,"data-title":`Expand All`,onClick:()=>t.onUnifiedHunkExpand(`all`,e),children:(0,I.jsx)(cf,{className:`fill-current`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Down`,"data-title":`Expand Down`,onClick:()=>t.onUnifiedHunkExpand(`down`,e),children:(0,I.jsx)(of,{className:`fill-current`})}),(0,I.jsx)(`button`,{className:`diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]`,title:`Expand Up`,"data-title":`Expand Up`,onClick:()=>t.onUnifiedHunkExpand(`up`,e),children:(0,I.jsx)(sf,{className:`fill-current`})})]}):(0,I.jsx)(`div`,{className:`min-h-[28px]`,children:` `})}),(0,I.jsx)(`td`,{className:`diff-line-hunk-content pr-[10px] align-middle`,style:{backgroundColor:`var(${bd})`},children:(0,I.jsx)(`div`,{className:`pl-[1.5em]`,style:{whiteSpace:o?`pre-wrap`:`pre`,wordBreak:o?`break-all`:`initial`,color:`var(${xd})`},children:r.unifiedInfo?.plainText||r.text})})]})},Rf=({index:e,diffFile:t,lineNumber:n})=>{let r=t.getUnifiedHunkLine(e),i=r&&r.unifiedInfo&&r.unifiedInfo.startHiddenIndex<r.unifiedInfo.endHiddenIndex,a=r&&t._getIsPureDiffRender()&&!r.unifiedInfo;return!i&&!a?null:(0,I.jsx)(Lf,{index:e,diffFile:t,lineNumber:n})},zf=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useWidget:i}=Qd(),a=i.getReadonlyState().setWidget,o=t.getUnifiedLine(e),s=()=>a({}),c=i.getReadonlyState().widgetSide,l=i.getReadonlyState().widgetLineNumber,u=o.oldLineNumber&&c===z.old&&l===o.oldLineNumber,d=o.newLineNumber&&c===z.new&&l===o.newLineNumber,{useDiffContext:f}=Xd(),p=f.useShallowStableSelector(e=>e.renderWidgetLine),m=tf({selector:`.unified-diff-table-wrapper`,enable:typeof p==`function`});return p?(0,I.jsx)(`tr`,{"data-line":`${n}-widget`,"data-state":`widget`,className:`diff-line diff-line-widget`,children:(0,I.jsx)(`td`,{className:`diff-line-widget-content p-0`,colSpan:2,children:(0,I.jsxs)(`div`,{className:`diff-line-widget-wrapper sticky left-0 z-[1]`,style:{width:m},children:[(r?!0:m>0)&&u&&p?.({diffFile:t,side:z.old,lineNumber:o.oldLineNumber??-1,onClose:s}),(r?!0:m>0)&&d&&p?.({diffFile:t,side:z.new,lineNumber:o.newLineNumber??-1,onClose:s})]})})}):null},Bf=({index:e,diffFile:t,lineNumber:n,enableWrap:r})=>{let{useWidget:i}=Qd();return i.useShallowSelector(F.useCallback(n=>{let r=n.widgetLineNumber,i=n.widgetSide,a=t.getUnifiedLine(e),o=a.oldLineNumber&&i===z.old&&r===a.oldLineNumber,s=a.newLineNumber&&i===z.new&&r===a.newLineNumber;return o||s},[t,e]),(e,t)=>e===t)?(0,I.jsx)(zf,{index:e,diffFile:t,lineNumber:n,enableWrap:r}):null},Vf=(0,F.memo)(({diffFile:e})=>{let{useDiffContext:t}=Xd(),n=(0,F.useRef)(null),r=(0,F.useRef)(void 0),i=(0,F.useRef)(t);i.current=t;let a=(0,F.useMemo)(()=>kf(i),[]),o=(0,F.useMemo)(()=>({useWidget:a}),[a]),{fontSize:s,enableWrap:c,enableHighlight:l,enableAddWidget:u,onCreateUseWidgetHook:d}=t.useShallowStableSelector(e=>({fontSize:e.fontSize,enableWrap:e.enableWrap,enableHighlight:e.enableHighlight,enableAddWidget:e.enableAddWidget,onCreateUseWidgetHook:e.onCreateUseWidgetHook}));(0,Ec.useSyncExternalStore)(e.subscribe,e.getUpdateCount,e.getUpdateCount),(0,F.useEffect)(()=>{let{setWidget:e}=a.getReadonlyState();e({})},[e,a]),(0,F.useEffect)(()=>{d?.(a)},[a,d]);let f=zd({text:Math.max(e.unifiedLineLength,e.fileLineLength).toString(),font:(0,F.useMemo)(()=>({fontSize:s+`px`,fontFamily:`Menlo, Consolas, monospace`}),[s])}),p=Math.max(20,f+5),m=Io(e),h=e.getContentVersion(),g=t=>{if(n.current){if(!t)n.current.textContent=``;else{let t=`diff-root${e.getId()}`;n.current.textContent=`#${t} [data-state="extend"] {user-select: none} \n#${t} [data-state="hunk"] {user-select: none} \n#${t} [data-state="widget"] {user-select: none}`}}},_=t=>{let n=t.target;if(n&&n instanceof HTMLElement&&n.nodeName===`BUTTON`){Od();return}let i=jd(n);if(!(i&&i!==`diff-root${e.getId()}`))for(;n&&n instanceof HTMLElement;){let e=n.getAttribute(`data-state`);if(e){if(e===`extend`||e===`hunk`||e===`widget`){r.current!==void 0&&(r.current=void 0,g(void 0),Od());return}r.current!==z.new&&(r.current=z.new,g(z.new),Od());return}n=n.parentElement}};return(0,I.jsx)(Zd.Provider,{value:o,children:(0,I.jsxs)(`div`,{className:`unified-diff-view ${c?`unified-diff-view-wrap`:`unified-diff-view-normal`} w-full`,children:[(0,I.jsx)(`style`,{"data-select-style":!0,ref:n}),(0,I.jsx)(`div`,{className:`unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden`,style:{[Nd]:`${Math.round(p)}px`,fontFamily:`Menlo, Consolas, monospace`,fontSize:`var(${Md})`},children:(0,I.jsxs)(`table`,{className:`unified-diff-table w-full border-collapse border-spacing-0 ${c?`table-fixed`:``}`,children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{className:`unified-diff-table-num-col`}),(0,I.jsx)(`col`,{className:`unified-diff-table-content-col`})]}),(0,I.jsx)(`thead`,{className:`hidden`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`line number`}),(0,I.jsx)(`th`,{scope:`col`,children:`line content`})]})}),(0,I.jsxs)(`tbody`,{className:`diff-table-body leading-[1.6]`,onMouseDownCapture:_,children:[m.map(t=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsx)(Rf,{index:t.index,lineNumber:t.lineNumber,diffFile:e}),(0,I.jsx)(Pf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c,enableHighlight:!!l,enableAddWidget:!!u,contentVersion:h}),(0,I.jsx)(Bf,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c}),(0,I.jsx)(If,{index:t.index,lineNumber:t.lineNumber,diffFile:e,enableWrap:!!c})]},t.index)),(0,I.jsx)(Rf,{index:e.unifiedLineLength,lineNumber:e.unifiedLineLength,diffFile:e})]})]})})]})})});Vf.displayName=`DiffUnifiedView`,No.name=`@git-diff-view/react`;var Hf=(0,F.memo)(e=>{let{diffFile:t,className:n,style:r,wrapperRef:i,diffViewMode:a,diffViewWrap:o,diffViewFontSize:s,diffViewHighlight:c,renderWidgetLine:l,renderExtendLine:u,extendData:d,diffViewAddWidget:f,onAddWidgetClick:p,onCreateUseWidgetHook:m,isMounted:h}=e,g=(0,F.useMemo)(()=>t.getId(),[t]),_=(0,F.useMemo)(()=>Of(e,g),[]);(0,F.useEffect)(()=>{let{id:e,setId:t,mode:n,setMode:r,mounted:i,setMounted:v,enableAddWidget:y,setEnableAddWidget:b,enableHighlight:x,setEnableHighlight:S,enableWrap:C,setEnableWrap:w,setExtendData:T,fontSize:E,setFontSize:D,onAddWidgetClick:O,setOnAddWidgetClick:k,renderExtendLine:A,setRenderExtendLine:ee,renderWidgetLine:j,setRenderWidgetLine:M,onCreateUseWidgetHook:N,setOnCreateUseWidgetHook:te}=_.getReadonlyState();g&&g!==e&&t(g),a&&a!==n&&r(a),i!==h&&v(h),f!==y&&b(!!f),c!==x&&S(!!c),o!==C&&w(!!o),d&&T(d),s&&s!==E&&D(s),p!==O.current&&k({current:p}),m!==N&&te(m),u!==A&&ee(u),l!==j&&M(l)},[_,s,c,a,o,f,g,h,l,u,d,p,m]),(0,F.useEffect)(()=>{i?.current&&_.getReadonlyState().setDom(i?.current)},[_,i]);let v=(0,F.useMemo)(()=>({useDiffContext:_}),[_]);return(0,I.jsx)(Yd.Provider,{value:v,children:(0,I.jsx)(`div`,{className:`diff-tailwindcss-wrapper`,"data-component":`git-diff-view`,"data-theme":t._getTheme()||`light`,"data-version":`0.1.8`,"data-highlighter":t._getHighlighterName(),ref:i,children:(0,I.jsx)(`div`,{className:`diff-style-root`,style:{[Md]:s+`px`},children:(0,I.jsx)(`div`,{id:h?`diff-root${g}`:void 0,className:`diff-view-wrapper`+(n?` ${n}`:``),style:r,children:a&Id.Split?(0,I.jsx)(Af,{diffFile:t}):(0,I.jsx)(Vf,{diffFile:t})})})})})}),Uf=(0,F.forwardRef)((e,t)=>{let{registerHighlighter:n,data:r,diffViewTheme:i,diffFile:a,...o}=e,s=(0,F.useMemo)(()=>{if(a){let e=Gs.createInstance({});return e._mergeFullBundle(a._getFullBundle()),e}return r?new Gs(r?.oldFile?.fileName||``,r?.oldFile?.content||``,r?.newFile?.fileName||``,r?.newFile?.content||``,r?.hunks||[],r?.oldFile?.fileLang||``,r?.newFile?.fileLang||``):null},[r,a]),c=(0,F.useRef)(null),l=Ld();return(0,F.useEffect)(()=>{if(a&&s)return a._addClonedInstance(s),()=>{a._delClonedInstance(s)}},[s,a]),(0,F.useEffect)(()=>{s&&(s.initTheme(i),s.initRaw(),s.buildSplitDiffLines(),s.buildUnifiedDiffLines())},[s,i]),(0,F.useEffect)(()=>{s&&e.diffViewHighlight&&(n?(n.name!==s._getHighlighterName()||n.type!==s._getHighlighterType()||n.type!==`class`)&&(s.initSyntax({registerHighlighter:n}),s.notifyAll()):(!s._getIsCloned()&&s._getHighlighterName()!==Ca.name||s._getHighlighterType()!==`class`)&&(s.initSyntax(),s.notifyAll()))},[s,e.diffViewHighlight,n,i]),(0,F.useEffect)(()=>{if(!s)return;let e=()=>{var e,t;(e=c.current)==null||e.setAttribute(`data-theme`,s._getTheme()||`light`),(t=c.current)==null||t.setAttribute(`data-highlighter`,s._getHighlighterName())};return e(),s.subscribe(e)},[s,i]),(0,F.useEffect)(()=>()=>(s?.clear)?.call(s),[s]),(0,F.useImperativeHandle)(t,()=>({getDiffFileInstance:()=>s}),[s]),s?(0,I.jsx)(Hf,{...o,diffFile:s,isMounted:l,wrapperRef:c,diffViewTheme:i,diffViewMode:o.diffViewMode||Id.SplitGitHub,diffViewFontSize:o.diffViewFontSize||14},s.getId()):null});Uf.displayName=`DiffView`;var Wf=Uf,Gf=e=>{let t=(0,F.useRef)(e);return t.current=e,(0,F.useCallback)((...e)=>t.current?.call(t,...e),[])},Kf=(e,t)=>{let n=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(n.current)return e();n.current=!0},t)};(0,F.forwardRef)((e,t)=>{let{enableMultiSelect:n=!0,extendData:r,onMultiSelectComplete:i,onMultiSelectChange:a,scopeMultiSelectToHunk:o,renderWidgetLine:s,onAddWidgetClick:c,diffViewMode:l=Id.SplitGitHub,...u}=e,d=Gf(a),f=Gf(i),p=Gf(o),m=(0,F.useRef)(null),h=(0,F.useRef)(null),g=(0,F.useRef)(null),_=(0,F.useRef)(void 0),v=!(l&Id.Split),y=(0,F.useCallback)(e=>{var t;_.current=e,(t=g.current)==null||t.setPreselectedLines(e||{old:[],new:[]})},[]);Kf(()=>{y(void 0)},[e.diffViewWrap,l]);let b=(0,F.useCallback)(()=>h.current?.getDiffFileInstance()??null,[]);(0,F.useEffect)(()=>{var e;let t=m.current,r=b();if(!t||!r||!n){(e=g.current)==null||e.destroy(),g.current=null;return}let i={enabled:n,isUnifiedMode:v,selectedClassName:qs.selected,onSelectionChange:(e,t)=>{var n,r;t.isSelecting?(n=m.current)==null||n.classList.add(qs.selecting):(r=m.current)==null||r.classList.remove(qs.selecting),t.isSelecting&&_.current&&y(void 0),d?.(e,t)},onSelectionComplete:e=>{var t;if((t=m.current)==null||t.classList.remove(qs.selecting),e&&e.lines.length>0){f?.(e);let t={[e.range.side]:[e.range.startLineNumber,e.range.endLineNumber]};y(t)}else y(void 0)},scopeToHunk:p};return g.current?(g.current.updateContainer(t),g.current.updateDiffFile(r),g.current.updateOptions(i)):g.current=wc(t,r,i),()=>{var e;(e=g.current)==null||e.destroy(),g.current=null}},[n,v,p,d,f,b,y]);let x=(0,F.useMemo)(()=>{if(!r)return;let e={};if(r.oldFile){e.oldFile={};for(let[t,n]of Object.entries(r.oldFile))e.oldFile[t]={data:n.data}}if(r.newFile){e.newFile={};for(let[t,n]of Object.entries(r.newFile))e.newFile[t]={data:n.data}}return e},[r]),S=(0,F.useCallback)(({lineNumber:e,side:t,diffFile:n,onClose:r})=>{if(!s)return null;let i=t===z.old?`old`:`new`,a=_.current?.[i],o=a?Math.min(...a):e,c=a?Math.max(...a):e;return s({lineNumber:c,fromLineNumber:o,side:t,diffFile:n,onClose:r})},[s]),C=(0,F.useCallback)(()=>g.current?.getSelectionResult()??null,[]),w=(0,F.useCallback)(()=>g.current?.getState()??{isSelecting:!1,startInfo:null,currentRange:null},[]),T=(0,F.useCallback)(()=>{var e;(e=g.current)==null||e.clearSelection()},[]),E=y;return(0,F.useImperativeHandle)(t,()=>({getDiffFileInstance:b,getSelectionResult:C,getSelectionState:w,clearSelection:T,setPreselectedLines:E}),[b,C,w,T,E]),(0,I.jsx)(`div`,{ref:m,className:`diff-multiselect-wrapper`,children:(0,I.jsx)(Wf,{ref:h,...u,diffViewMode:l,extendData:x,onAddWidgetClick:(e,t)=>{var n;(n=g.current)==null||n.clearSelection();let r=_.current;if(r){let n=z[t],i=r[n],a=n===`new`?`old`:`new`,o=r[a];if(i?.length){let r=Math.max(...i);if(r===e){y({[n]:i}),c?.({lineNumber:r,fromLineNumber:Math.min(...i),side:t});return}}if(v&&o?.length){let n=Math.max(...o),r=b(),i=r?.getUnifiedLineIndexByLineNumber(e,t)||-1,s=(r?.getUnifiedLine)?.call(r,i);if(n===(t===z.old?s?.newLineNumber:s?.oldLineNumber)){y({[a]:o}),c?.({lineNumber:n,fromLineNumber:Math.min(...o),side:a===`old`?z.old:z.new});return}}y(void 0),c?.({lineNumber:e,fromLineNumber:e,side:t})}else y(void 0),c?.({lineNumber:e,fromLineNumber:e,side:t})},renderWidgetLine:s?S:void 0})})});var qf=`操作没有完成。`,Jf=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,Yf=160,Xf=/[\u3400-\u9fff]/,Zf=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,Qf=/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,$f=/timeout|timed out|etimedout/i,ep=/aborterror|aborted|the user aborted a request|operation was aborted/i,tp=/node-pty|pty unavailable|terminal unavailable/i,np=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,rp=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,ip=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,ap=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,op=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function sp(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 cp=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function lp(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>Yf?`${t.slice(0,Yf)}…`:t}function up(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${lp(t)})`}function dp(e,t){let n=sp(e);if(!n||cp.test(n))return t??Jf;if(Xf.test(n))return n;if(Zf.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(Qf.test(n))return up(`连接不上 Super Pi 服务,请稍后再试。`,n);if($f.test(n))return up(`等待服务响应超时,请稍后再试。`,n);if(ep.test(n))return up(`请求被中断,请重试。`,n);if(tp.test(n))return up(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if(np.test(n))return up(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(ap.exec(n)?.[1]??ap.exec(n)?.[2]??0);if(r===401||r===403)return up(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return up(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return up(`请求被拒绝(HTTP ${r})。`,n);if(rp.test(n))return up(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(ip.test(n))return up(`服务端出错了,请稍后再试。`,n);let i=op.exec(n)?.[1];return up(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??qf,n)}function fp(e){let t=sp(e);if(t&&!cp.test(t))return dp(e).includes(t)?void 0:t}function pp(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var mp={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`},hp={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 gp(e){let t=hp[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=pp(e);return n?mp[n]??`generic`:`generic`}var _p={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 vp({path:e,category:t,size:n=14}){let r=t??gp(e??``),i=_p[r]??_p.generic;return(0,I.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,I.jsx)(`path`,{d:e},t))})}function yp(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,css:`css`,html:`html`,md:`markdown`,py:`python`,sh:`bash`,rs:`rust`,go:`go`,yml:`yaml`,yaml:`yaml`}[e]||`plaintext`}function bp(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`?`,kind:`untracked`,slot:`index`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var xp=e=>e.path.endsWith(`/`);function Sp(){if(typeof document>`u`)return!0;let e=document.documentElement.getAttribute(`data-theme`)||`dracula`;return e!==`solarized-light`&&e!==`github-light`}var Cp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},wp=15e3,Tp=e=>new Cp(408,{error:`请求超时:${wp/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Ep(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),wp);try{let r=await fetch(e,{...t,signal:n.signal}),i;try{i=await r.json()}catch{i=void 0}if(!r.ok)throw new Cp(r.status,i??{error:`HTTP ${r.status}`});return i}catch(t){throw n.signal.aborted?Tp(e):t}finally{clearTimeout(r)}}var Dp=e=>e instanceof Cp?e:new Cp(0,{error:e instanceof Error?e.message:`读取失败`}),Op=e=>encodeURIComponent(e),kp=e=>e?`&cwd=${Op(e)}`:``,Ap=(e,t)=>`/api/git?workspaceId=${Op(e)}&op=status${kp(t)}`,jp=(e,t,n)=>`/api/git?workspaceId=${Op(e)}&op=log&limit=${t}${kp(n)}`,Mp=(e,t,n,r)=>`/api/git?workspaceId=${Op(e)}&op=diff&path=${Op(t)}${n?`&staged=1`:``}${kp(r)}`;async function Np(e,t,n={},r){return Ep(`/api/git?workspaceId=${Op(e)}&op=${Op(t)}${kp(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})}var Pp=20,Fp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},Ip=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,Lp=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},Rp=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function zp({path:e,onCancel:t,onConfirm:n}){let r=(0,F.useRef)(null),i=(0,F.useRef)(null);(0,F.useEffect)(()=>{i.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,I.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:r,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=r.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let i=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())},"data-git-confirm-dialog":`1`,children:[(0,I.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,I.jsx)(`p`,{className:`git-confirm-desc`,children:`即将丢弃以下文件的所有未暂存修改:`}),(0,I.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,I.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,I.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:i,onClick:t,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:n,children:`确认丢弃`})]})]})});return typeof document>`u`?a:(0,pa.createPortal)(a,document.body)}function Bp({children:e,onClose:t}){let n=(0,F.useRef)(null),r=(0,F.useRef)(t);return r.current=t,(0,F.useLayoutEffect)(()=>{let e=document.activeElement;n.current?.querySelector(`[data-git-diff-close]`)?.focus();let t=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r.current()),e.key!==`Tab`)return;let t=Array.from(n.current?.querySelectorAll(`button:not(:disabled),a[href],input:not(:disabled),[tabindex='0']`)??[]).filter(e=>e.getClientRects().length),i=t[0],a=t.at(-1);i?e.shiftKey&&(document.activeElement===i||document.activeElement===n.current)?(e.preventDefault(),a?.focus()):!e.shiftKey&&document.activeElement===a&&(e.preventDefault(),i.focus()):(e.preventDefault(),n.current?.focus())};return window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`keydown`,t,!0),e?.isConnected&&e.focus()}},[]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay git-diff-overlay`,"data-git-diff-overlay":!0,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsx)(`div`,{ref:n,className:`tool-dialog git-diff-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`文件差异`,tabIndex:-1,"data-git-diff-dialog":!0,children:e})}),document.body)}function Vp(e,t,n){let r=e?Ap(e,t):``,[i,a]=(0,F.useState)(),o=(0,F.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,F.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;Ep(r).then(e=>{s()&&a({scope:r,status:e,error:null})}).catch(e=>{s()&&a({scope:r,status:null,error:Dp(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,F.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,F.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?.status??null,error:l?.error??null,refresh:s,publish:c}}function Hp({workspaceId:e,conversationId:t,cwd:n=``,onOpenChanged:r,sharedGit:i}){let[a,o]=(0,F.useState)(Id.Unified),s=Sp(),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),f=i?i.status:c,p=i?i.error:u,m=i?.refresh,h=i?.publish,[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(``),[S,C]=(0,F.useState)(null),[w,T]=(0,F.useState)(``),[E,D]=(0,F.useState)(``),[O,k]=(0,F.useState)(null),[A,ee]=(0,F.useState)(null),j=(0,F.useRef)(0),M=(0,F.useCallback)((e,t)=>{j.current+=1,l(null),d(null),D(``),_(null),y(!0),x(``),C(null),m?m():Ep(Ap(e,n)).then(e=>{t()&&(l(e),d(null))}).catch(e=>{t()&&d(Dp(e))}),Ep(jp(e,Pp,n)).then(e=>{t()&&(_(e),y(!1))}).catch(e=>{t()&&(x(Dp(e).message),y(!1))})},[n,m]);(0,F.useEffect)(()=>{if(!e)return;let t=!0;return M(e,()=>t),()=>{t=!1}},[e,n,M]);let N=(0,F.useCallback)((t,r)=>{if(!e)return;let i=++j.current;C({path:t,staged:r,loading:!0,error:``,result:null}),Ep(Mp(e,t,r,n)).then(e=>{j.current===i&&C(n=>n&&n.path===t&&n.staged===r?{...n,loading:!1,result:e}:n)}).catch(e=>{j.current===i&&C(n=>n&&n.path===t&&n.staged===r?{...n,loading:!1,error:Dp(e).message}:n)})},[e,n]),te=(0,F.useCallback)(()=>{j.current+=1,C(null)},[]),ne=(0,F.useCallback)(async(t,r={})=>{if(!e)return!1;k(t),D(``);try{let i=await Np(e,t,r,n);return h?h(i):l(i),j.current+=1,C(null),y(!0),x(``),Ep(jp(e,Pp,n)).then(e=>{_(e),y(!1)}).catch(e=>{x(Dp(e).message),y(!1)}),!0}catch(e){let t=Dp(e);return D(t.body?.error||t.message||`操作失败`),!1}finally{k(null)}},[e,n,h]),re=(0,F.useCallback)(()=>{if(!A)return;let e=A;ee(null),ne(`discard`,{path:e})},[A,ne]),ie=(0,F.useCallback)(()=>{ee(null)},[]);if(!e)return(0,I.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})});let ae=f===null?null:Lp(f),oe=f===null?[]:Rp.map(e=>({...e,entries:f[e.key]})),se=S===null?``:S.loading?`加载 diff…`:S.error===``?S.result===null?``:S.result.kind===`text`?S.result.diff??``:S.result.kind===`binary`?`二进制文件不显示差异。`:`未跟踪文件暂无对照版本。`:S.error,ce=(0,F.useMemo)(()=>{if(!S?.result?.diff||S.result.kind!==`text`)return null;let e=yp((S.path.split(`.`).pop()||``).toLowerCase());try{let t=new Gs(S.path,``,S.path,``,[S.result.diff],e,e);return t.init(),t.buildUnifiedDiffLines(),t.buildSplitDiffLines(),t}catch{return null}},[S?.path,S?.result?.diff,S?.result?.kind]);return(0,I.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:[f===null&&p===null&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),p!==null&&(0,I.jsxs)(`div`,{className:`git-state-card${p.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":p.body.code??``,children:[(0,I.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:p.body.code===`not_a_repo`?`⌁`:`!`}),(0,I.jsx)(`strong`,{children:p.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,I.jsx)(`p`,{children:p.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,I.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>e&&M(e,()=>!0),children:`重新检查`})]}),f!==null&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,I.jsx)(`span`,{className:`git-branch`,"data-git-branch":`1`,title:Ip(f),children:Ip(f)}),ae!==null&&(0,I.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:ae}),(0,I.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>e&&M(e,()=>!0),children:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),(0,I.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,I.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void ne(`pull`),disabled:O!==null,children:O===`pull`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,I.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void ne(`push`),disabled:O!==null,children:O===`push`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`}),(0,I.jsx)(`button`,{type:`button`,"data-git-action":`stage-all`,onClick:()=>void ne(`stage-all`),disabled:O!==null||!f.unstaged.length&&!f.untracked.length,children:`全部暂存`})]}),E&&(0,I.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,children:E}),oe.map(e=>(0,I.jsxs)(`div`,{className:`git-group`,"data-git-group":e.key,children:[(0,I.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":e.key,children:[(0,I.jsx)(`span`,{className:`git-group-title`,children:e.title}),(0,I.jsx)(`span`,{className:`git-group-count`,"data-git-count":e.key,children:e.entries.length}),e.key===`staged`&&e.entries.length>0&&(0,I.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:O!==null,onClick:()=>void ne(`unstage-all`),children:`全部取消暂存`})]}),(0,I.jsx)(`div`,{className:`git-group-body`,children:e.entries.length===0?(0,I.jsxs)(`p`,{className:`git-group-empty`,"data-git-empty":e.key,children:[`无`,e.title,`变更。`]}):e.entries.map(t=>{let n=bp(t.xy,e.key),r=xp(t),i=S?.path===t.path&&S?.staged===(e.key===`staged`);return(0,I.jsxs)(`div`,{className:`git-file-row${i?` is-active`:``}`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":t.path,"data-git-kind":r?`dir`:`file`,title:t.path,onClick:()=>N(t.path,e.key===`staged`),children:[(0,I.jsx)(`span`,{className:`git-badge git-badge-${n.kind} git-badge-slot-${n.slot}`,"data-git-badge":n.kind,"data-git-badge-slot":n.slot,children:n.label}),r&&(0,I.jsx)(vp,{category:`folder`,size:12}),(0,I.jsx)(`span`,{className:`git-path`,children:r?`${t.name}/`:t.name}),t.path.includes(`/`)&&!r&&(0,I.jsx)(`span`,{className:`git-parent-path`,children:t.path.slice(0,t.path.lastIndexOf(`/`))})]}),(0,I.jsxs)(`span`,{className:`git-file-actions`,children:[e.key===`staged`?(0,I.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:O!==null,onClick:e=>{e.stopPropagation(),ne(`unstage`,{path:t.path})},children:`−`}):(0,I.jsx)(`button`,{type:`button`,title:`暂存`,disabled:O!==null,onClick:e=>{e.stopPropagation(),ne(`stage`,{path:t.path})},children:`+`}),e.key===`unstaged`&&(0,I.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${t.path} 的更改`,"aria-label":`丢弃更改 ${t.path}`,disabled:A!==null||O!==null,onClick:e=>{e.stopPropagation(),ee(t.path)},children:`↶`})]})]},t.path)})})]},e.key)),(0,I.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,I.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,I.jsx)(`strong`,{children:`提交更改`}),(0,I.jsxs)(`span`,{children:[f.staged.length,` 个已暂存`]})]}),(0,I.jsxs)(`label`,{children:[`提交说明`,(0,I.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`概括本次更改`,"aria-label":`提交消息`,disabled:O!==null})]}),(0,I.jsx)(`button`,{type:`button`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!f.staged.length||!w.trim()||O!==null,onClick:async()=>{await ne(`commit`,{message:w})&&T(``)},children:O===`commit`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):f.staged.length?`提交 ${f.staged.length} 个暂存文件`:`先暂存更改`})]}),S!==null&&(0,I.jsx)(Bp,{onClose:te,children:(0,I.jsxs)(`div`,{className:`git-diff-area`,"data-git-diff-area":`1`,children:[(0,I.jsxs)(`div`,{className:`git-group-head`,"data-git-diff-head":`1`,children:[(0,I.jsx)(`span`,{className:`git-path`,"data-git-diff-path":`1`,title:S.path,children:S.path}),(0,I.jsxs)(`div`,{className:`git-diff-toolbar`,children:[ce&&(0,I.jsx)(`button`,{type:`button`,className:`git-diff-mode-btn`,"data-git-diff-mode":a===Id.Unified?`unified`:`split`,title:a===Id.Unified?`切换到左右分栏视图`:`切换到内联单栏视图`,onClick:()=>o(e=>e===Id.Unified?Id.Split:Id.Unified),children:a===Id.Unified?`分栏`:`内联`}),r&&(0,I.jsx)(`button`,{type:`button`,className:`git-diff-expand-btn`,"data-git-diff-expand":`1`,title:`在主视区查看完整差异对比`,onClick:()=>{te(),r(S.path)},children:`主视区查看 ↗`}),(0,I.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-diff-close":`1`,"data-git-close":`1`,title:`关闭差异`,"aria-label":`关闭差异`,onClick:te,children:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✕`})})]})]}),(0,I.jsxs)(`div`,{className:`git-diff`,"data-git-diff":S.path,"data-git-diff-loading":S.loading?`1`:void 0,"data-git-diff-error":S.error===``?void 0:`1`,"data-git-diff-kind":S.result!==null&&!S.loading&&S.error===``?S.result.kind:void 0,children:[(0,I.jsx)(`pre`,{className:`git-diff-raw`,style:{display:`none`},children:se}),S.loading?(0,I.jsx)(`p`,{className:`rail-empty`,children:`加载 diff…`}):S.error===``?S.result===null?null:S.result.kind===`binary`?(0,I.jsx)(`p`,{className:`rail-empty`,children:`二进制文件不显示差异。`}):S.result.kind===`untracked`?(0,I.jsx)(`p`,{className:`rail-empty`,children:`未跟踪文件暂无对照版本。`}):ce?(0,I.jsx)(`div`,{className:`git-diff-view-wrapper`,children:(0,I.jsx)(Wf,{diffFile:ce,diffViewMode:a,diffViewTheme:s?`dark`:`light`,diffViewFontSize:13})}):(0,I.jsx)(`pre`,{className:`git-diff-fallback`,children:se}):(0,I.jsx)(`p`,{className:`tool-error`,title:fp(S.error),children:dp(S.error,`这个文件的差异读取失败。`)})]})]})}),(0,I.jsxs)(`div`,{className:`git-log`,"data-git-log":`1`,children:[(0,I.jsx)(`div`,{className:`git-group-head`,"data-git-log-head":`1`,children:(0,I.jsx)(`span`,{className:`git-group-title`,children:`最近提交`})}),v&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-loading":`1`,children:`读取提交记录…`}),!v&&b!==``&&(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-error":`1`,title:fp(b),children:dp(b,`提交记录读取失败。`)}),!v&&b===``&&g!==null&&(g.commits.length===0?(0,I.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:`暂无提交记录。`}):(0,I.jsxs)(I.Fragment,{children:[g.commits.map(e=>(0,I.jsxs)(`div`,{className:`git-log-row`,"data-git-commit":e.hash,children:[(0,I.jsx)(`div`,{className:`git-log-subject`,title:e.subject,children:e.subject}),(0,I.jsxs)(`div`,{className:`git-log-meta`,children:[(0,I.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,I.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,I.jsx)(`span`,{className:`git-log-date`,children:Fp(e.date)})]})]},e.hash)),g.truncated&&(0,I.jsxs)(`p`,{className:`rail-empty`,"data-git-log-truncated":`1`,children:[`仅显示最近 `,Pp,` 条提交。`]})]}))]}),A!==null&&(0,I.jsx)(zp,{path:A,onCancel:ie,onConfirm:re})]})]})}var Up={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`},Wp={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`},Gp=[`sessions`,`files`,`main`,`terminal`,`git`,`projects`,`tools`],Kp=`super-pi.workbench.layout.v1`,qp=e=>typeof e==`string`&&Gp.includes(e);function Jp(){let e={sides:{...Wp},order:Gp,unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1};try{let t=JSON.parse(window.localStorage.getItem(Kp)??`null`);if(!t)return e;let n={...Wp};for(let e of Gp)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(qp):[];return{sides:n,order:[...new Set([...r,...Gp])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(qp).filter(e=>e!==`sessions`):[],leftView:qp(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function Yp(e){try{window.localStorage.setItem(Kp,JSON.stringify(e))}catch{}}var Xp={sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,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`,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:`M20 4v5h-5m5 0a8 8 0 1 0 0 6`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`};function Zp({name:e}){return(0,I.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,I.jsx)(`path`,{d:Xp[e]})})}function Qp({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,children:s}){let c=t.filter(e=>n.includes(e)),l=t.filter(e=>!n.includes(e)),[u,d]=(0,F.useState)(),f=u&&l.includes(u)?u:r&&l.includes(r)?r:l[0],p=(0,F.useRef)(new Map),m=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let e=e=>{let t=m.current;t?.open&&e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]),(0,I.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,I.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:l.map((t,n)=>(0,I.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===f?0:-1,ref:e=>{e?p.current.set(t,e):p.current.delete(t)},title:Up[t],"aria-label":Up[t],onFocus:()=>d(t),onClick:()=>a(t),onKeyDown:e=>{let t=e.key===`Home`?l[0]:e.key===`End`?l.at(-1):e.key===`ArrowDown`?l[(n+1)%l.length]:e.key===`ArrowUp`?l[(n+l.length-1)%l.length]:void 0;t&&(e.preventDefault(),p.current.get(t)?.focus())},children:(0,I.jsx)(Zp,{name:t})},t))}),o&&(0,I.jsx)(`button`,{type:`button`,className:`workbench-activity-button`,"data-workbench-search":`1`,title:`搜索文件内容`,"aria-label":`搜索文件内容`,onClick:o,children:(0,I.jsx)(Zp,{name:`search`})}),c.length>0&&(0,I.jsxs)(`details`,{className:`workbench-menu workbench-more`,ref:m,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,I.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,I.jsx)(Zp,{name:`more`})}),(0,I.jsx)(`div`,{className:`workbench-menu-items`,children:c.map(e=>(0,I.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),a(e)},children:[(0,I.jsx)(Zp,{name:e}),Up[e]]},e))})]}),s&&(0,I.jsx)(`div`,{className:`workbench-activity-utilities`,children:s})]})}function $p({view:e,side:t,pinned:n,onArrange:r}){let i=[[`move`,t===`left`?`移到右侧`:`移到左侧`],[`pin`,n?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];return(0,I.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,I.jsx)(`summary`,{title:`视图布局`,"aria-label":`${Up[e]}布局`,"data-workbench-panel-menu":e,children:(0,I.jsx)(Zp,{name:`more`})}),(0,I.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,I.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var em=`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'`,tm={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 nm(e){return tm[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function rm(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 nm(e)?.kind}function im(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function am(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 om=new Set([`http`,`https`,`mailto`]),sm=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},cm=/^([a-z][a-z0-9+.-]*):/i;function lm(e){let t=[...e].filter(e=>!sm(e)).join(``);if(!t)return;let n=cm.exec(t);return n?om.has(n[1].toLowerCase())?e:void 0:e}var um=/[!-/:-@[-`{-~]/,dm=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function fm(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function pm(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function mm(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=fm(e,r,"`");if(t===n)return r;r+=t-1}return-1}function hm(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
36
36
  `)break;if(e[i]==="`"){let t=fm(e,i,"`");if(mm(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 gm(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 _m(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 vm(e,t,n,r){for(let i=t;i<e.length;i+=1){let t=Sm(e,i);if(t)i=t.next-1;else if(e[i]===`\\`)i+=1;else if(e[i]==="`"){let t=fm(e,i,"`"),n=mm(e,i+t,t);if(n!==-1){i=n+t-1;continue}i+=t-1}else if(e[i]===r&&!(fm(e,i,r)<n.length)&&!(r===`_`&&dm(e[i-1])&&dm(e[i+1])))return i}return-1}var ym=/^<([a-z][a-z0-9+.-]*:[^<>\s]*)>/i,bm=/[\s(\[{,:;=+\/|(【「『]/,xm=/[\u2E80-\u9FFF\uF900-\uFAFF\u3000-\uFF60\uFFE0-\uFFE6]/;function Sm(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&&!bm.test(e[t-1])&&!xm.test(e[t-1]))return;let s=n===`\\`?a?`\\)`:`\\]`:i?`$$`:`$`,c=t+s.length,l=hm(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 Cm(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=Sm(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===`\\`&&um.test(e[o+1]??``))r+=e[o+1],o+=2;else if(s==="`"){let t=fm(e,o,"`"),n=mm(e,o+t,t);if(n!==-1){a({type:`code`,value:pm(e.slice(o+t,n))}),o=n+t;continue}r+="`".repeat(t),o+=t}else if(s===`<`){let t=ym.exec(e.slice(o));if(t){let e=lm(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=_m(e,i),l=c===-1?void 0:gm(e,c+1);if(l){let r=rm(l.href);if(r&&(n||r===`html`)){a({type:`artifact`,kind:r,path:l.href,label:e.slice(i,c)}),o=l.next;continue}let s=lm(l.href);if(s){a({type:`link`,href:s,...l.title===void 0?{}:{title:l.title},children:Cm(e.slice(i,c),t)}),o=l.next;continue}}r+=s,o+=1}else if(t.strikethrough!==!1&&s===`~`&&e[o+1]===`~`){let n=vm(e,o+2,`~~`,`~`);if(n>o+2){a({type:`del`,children:Cm(e.slice(o+2,n),t)}),o=n+2;continue}r+=`~~`,o+=2}else if(s===`*`||s===`_`){let n=fm(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===`_`&&dm(e[o-1])&&dm(e[o+n])?-1:vm(e,o+i.length,i,s);if(c>o+i.length){let r=Cm(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===`
37
37
  `?(/[ \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 wm=/^(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*$/,Tm=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,Em=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,Dm=/^(\s*)([-*+])(\s+)(.*)$/,Om=/^(\s*)(\d{1,9})([.)])(\s+)(.*)$/,km=/^ {0,3}>\s?(.*)$/,Am=/^ {0,3}\|?\s*:?-{1,}:?\s*(?:\|\s*:?-{1,}:?\s*)*\|?\s*$/,jm=/^\s*(\$\$(?!\$)|\\\[|\\begin\{((?:equation|align|alignat|gather|multline|flalign|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|Bmatrix|cases)\*?|aligned|alignedat|gathered|split|array|smallmatrix|dcases|rcases)\})/;function Mm(e,t){let n=jm.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&&(wm.test(l)||Tm.test(l)||l.trimStart().startsWith(`\\[`)))return;let u=c===t?n[0].length:0,d=hm(l,u,a,i&&r);for(;i&&d!==-1;){let e=l.startsWith(r,d);if(s+=e?1:-1,!s)break;d=hm(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(`
38
38
  `).trim();return f?{node:{type:`math-block`,source:i?r+o.join(`
@@ -306,8 +306,8 @@ ${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namesp
306
306
  `||c===`\r`)){if(r.length<50?r.push(i):o=!0,i=``,c!==t&&(n.push(r),r=[],c===`\r`&&e[s+1]===`
307
307
  `&&(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 nS({workspaceId:e,cwd:t,path:n,name:r,kind:i,content:a,source:o,version:s,sourceRequest:c,external:l,navigation:u}){let[d,f]=(0,F.useState)(c!==void 0),[p,m]=(0,F.useState)(),[h,g]=(0,F.useState)(!1),_=eS(`asset`,e,t,n,{v:s}),v=eS(`asset`,e,t,n,{download:`1`});(0,F.useEffect)(()=>{c!==void 0&&f(!0)},[c]),(0,F.useEffect)(()=>{g(!1)},[_]),(0,F.useEffect)(()=>{if(i!==`document`)return;let r=new AbortController;return fetch(eS(`document`,e,t,n),{signal:r.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`无法读取文档。`);m(t)}).catch(e=>{r.signal.aborted||m({error:String(e.message??e)})}),()=>r.abort()},[e,t,n,i,s]);let y=(0,F.useMemo)(()=>i===`table`&&!d?tS(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,d]);return(0,I.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,children:[(0,I.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[u,(0,I.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[o&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>f(e=>!e),children:d?`查看表格`:`编辑原文`}),(0,I.jsxs)(`a`,{href:v,download:r,children:[(0,I.jsx)(Xx,{name:`download`}),`下载`]})]})]}),l&&!d&&(0,I.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),d?o:h?(0,I.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,I.jsxs)(I.Fragment,{children:[i===`download`&&(0,I.jsx)(`p`,{children:`此文件可以下载。`}),i===`image`&&(0,I.jsx)(`img`,{src:_,alt:r,onError:()=>g(!0)}),i===`pdf`&&(0,I.jsx)(`iframe`,{src:_,title:r}),i===`audio`&&(0,I.jsx)(`audio`,{src:_,controls:!0,preload:`metadata`,onError:()=>g(!0)}),i===`video`&&(0,I.jsx)(`video`,{src:_,controls:!0,preload:`metadata`,onError:()=>g(!0)}),i===`document`&&(p?.error?(0,I.jsx)(`p`,{role:`alert`,children:p.error}):p?(0,I.jsxs)(I.Fragment,{children:[p.warnings?.map(e=>(0,I.jsx)(`p`,{children:e},e)),(0,I.jsx)(`pre`,{children:p.text||`此文档没有可显示的文字。`})]}):(0,I.jsx)(`p`,{children:`正在读取文档…`})),y&&(y.rows.length?(0,I.jsx)(`div`,{className:`workspace-file-table`,children:(0,I.jsx)(`table`,{children:(0,I.jsx)(`tbody`,{children:y.rows.map((e,t)=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,I.jsx)(`td`,{children:e},t))]},t))})})}):(0,I.jsx)(`p`,{children:`文件为空。`})),y?.clipped&&(0,I.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var rS={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 iS(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function aS(e){let t=iS(e);return Object.hasOwn(rS,t)?rS[t]:void 0}function oS(e){let t=aS(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 sS=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),cS=(e,t)=>!t||e===t||e.startsWith(`${t}/`),lS=e=>e.split(`/`).at(-1)??e;function uS(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 dS({title:e,cancel:t,children:n}){let r=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t?.isConnected&&t.focus()}},[]),(0,I.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,I.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,I.jsx)(`h2`,{children:e}),n]})})}function fS({target:e,label:t,initial:n,busy:r,error:i,depth:a,submit:o,close:s}){let c=(0,F.useRef)(null);return(0,F.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,I.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,I.jsxs)(`div`,{className:`file-inline-row`,children:[(0,I.jsx)(vp,{path:e.path,category:e.directory?`folder`:void 0}),(0,I.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,I.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,I.jsx)(Xx,{name:`right`})}),(0,I.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,I.jsx)(Xx,{name:`close`})})]}),i&&(0,I.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function pS({files:e,source:t,scopeName:n}){let[r,i]=(0,F.useState)(sS(t.path)),a=e.listings[r],o=e.loadDirectory;(0,F.useEffect)(()=>{a||o(r)},[r,a,o]);let s=a&&`entries`in a?a.entries.filter(e=>e.kind===`directory`&&!e.symlink&&!(t.directory&&cS(e.path,t.path))):[];return(0,I.jsxs)(`div`,{className:`file-move-picker`,children:[(0,I.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,I.jsxs)(`div`,{className:`file-move-location`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(sS(r)),children:`↑`}),(0,I.jsx)(`span`,{title:r||n,children:r||n})]}),(0,I.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,I.jsx)(vp,{category:`folder`}),(0,I.jsx)(`span`,{children:e.name}),(0,I.jsx)(Xx,{name:`right`})]})},e.path))}),!s.length&&(0,I.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function mS({workspaceId:e,scopeName:t,cwd:n,files:r,onOpen:i,onReference:a,onMoved:o}){let[s,c]=(0,F.useState)(),[l,u]=(0,F.useState)(),[d,f]=(0,F.useState)(),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(),y=(0,F.useRef)(null),b=(0,F.useRef)(``),x=(0,F.useRef)(void 0),S=(0,F.useRef)(void 0);(0,F.useEffect)(()=>{let e={controller:new AbortController};return S.current=e,c(void 0),u(void 0),f(void 0),v(void 0),m(!1),g(``),()=>{e.controller.abort(),S.current===e&&(S.current=void 0)}},[e,n]);let C=(t,r=``,i)=>eS(t,e??``,n,r,i);async function w(e,t){let n=await fetch(e,{...t,signal:S.current?.controller.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`操作失败(${n.status})`);return r}function T(e,t){s?.anchor.origin===t.origin&&s.target.path===e.path?c(void 0):c({target:e,anchor:t})}function E(e){c(void 0),e&&s?.anchor.origin.isConnected&&s.anchor.origin.focus({preventScroll:!0})}function D(e,t,n,i){x.current=i??s?.anchor.origin??(document.activeElement instanceof HTMLElement?document.activeElement:void 0),c(void 0),g(``),u({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 O(){u(void 0);let e=x.current;requestAnimationFrame(()=>{e?.isConnected&&e.offsetParent?e.focus({preventScroll:!0}):l?.target.path&&r.locatePath(l.target.path,l.target.directory)})}async function k(t){let a=S.current;m(!0),g(``);try{let s=await w(C(`tree`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(S.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)cS(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath(sS(s.path),!0)}u(void 0),t.action===`restore`&&f(e=>e?.filter(e=>e.id!==t.id)),t.action===`create-file`&&s.text!==!1&&i({path:s.path,name:lS(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(S.current===a){let t=e instanceof Error?e.message:String(e);g(t),l||r.setNotice(t)}}finally{S.current===a&&m(!1)}}function A(e){if(e.preventDefault(),!l||p)return;let{action:t,target:n}=l;if((t===`move`||t===`trash`)&&Object.entries(r.saves).some(([e,t])=>cS(e,n.path)&&t.state===`saving`)){g(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&cS(e.path,n.path))){g(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??lS(n.path));if(t===`move`&&!n.directory&&iS(n.path)!==iS(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){g(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?sS(n.path):n.path));l.move&&o===sS(n.path)?g(`请选择另一个文件夹。`):k({action:t,path:n.path,parent:o,name:a})}async function ee(){let e=S.current;c(void 0),g(``);try{let t=await w(C(`tree`));S.current===e&&f(t.entries)}catch(t){S.current===e&&r.setNotice(String(t.message))}}function j(e){b.current=e,E(!0),y.current?.click()}async function M(t,i,a){let o=S.current;if(!e||!o||!i.length||p)return;m(!0),g(``),v(void 0);let s=[],c=[],l=[];try{for(let e of i){if(o!==S.current)return;try{let n=a?.find(t=>t.file===e)?.etag;if(!a){let n=await w(C(`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 w(C(`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(S.current!==o)return;l[0]&&r.revealPath(l[0]),l.length&&r.invalidateTree(e,l.map(e=>n?`${n}/${e}`:e)),s.length&&v({parent:t,items:s}),r.setNotice([l.length?`已上传 ${l.length} 个文件`:``,...c].filter(Boolean).join(`。`))}finally{S.current===o&&m(!1)}}function N(e,t){c(void 0),a?.(e||`.`,t)}function te(e){E(!0),xx(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let ne=l?.action===`create-file`?`新建文件`:l?.action===`create-directory`?`新建文件夹`:l?.action===`trash`?`移到回收站`:l?.move?`移动到文件夹`:`重命名`,re={path:``,directory:!0},ie=l?.action===`create-file`||l?.action===`create-directory`,ae=l?.action===`move`&&!l.move,oe=(e,t,n)=>!l||l.target.path!==e||(t===`child`?!ie:!ae)?null:(0,I.jsx)(fS,{target:{...l.target,directory:ie?l.action===`create-directory`:l.target.directory},label:ne,initial:ae?lS(e):``,busy:p,error:h,depth:n,submit:A,close:O},`${l.action}:${e}`),se=(e,t)=>{p||e.linked||e.directory&&cS(t,e.path)||t===sS(e.path)||(Object.entries(r.saves).some(([t,n])=>cS(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):k({action:`move`,path:e.path,parent:t,name:lS(e.path)}))},ce=(0,I.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,I.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>D(`create-file`,re,!1,e.currentTarget),disabled:!e||p,children:(0,I.jsx)(Xx,{name:`file`})}),(0,I.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>D(`create-directory`,re,!1,e.currentTarget),disabled:!e||p,children:(0,I.jsx)(Xx,{name:`folder`})}),(0,I.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,I.jsx)(Xx,{name:`refresh`})}),(0,I.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,I.jsx)(Xx,{name:`collapse`})}),(0,I.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":s?.target.path===``,onClick:e=>T(re,Zx(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||p,children:(0,I.jsx)(Xx,{name:`more`})})]}),le=(e,t,n,r,i)=>(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,I.jsx)(Xx,{name:t}),(0,I.jsx)(`span`,{children:e}),i&&(0,I.jsx)(`kbd`,{children:i})]});return{controls:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,M(b.current,t)}}),s&&(0,I.jsxs)(Qx,{label:s.target.path||t,anchor:s.anchor,close:E,children:[s.target.directory&&!s.target.linked&&(0,I.jsxs)(I.Fragment,{children:[le(`新建文件`,`file`,()=>D(`create-file`,s.target),`new-file`),le(`新建文件夹`,`folder`,()=>D(`create-directory`,s.target),`new-directory`),le(`上传到此处`,`upload`,()=>j(s.target.path),`upload`),(0,I.jsx)(`div`,{role:`separator`})]}),s.target.path&&!s.target.linked&&(0,I.jsxs)(I.Fragment,{children:[le(`重命名`,`rename`,()=>D(`move`,s.target),`rename`,`F2`),le(`移动到文件夹`,`move`,()=>D(`move`,s.target,!0),`move`),(0,I.jsx)(`div`,{role:`separator`})]}),!s.target.linked&&a&&le(`引用到会话`,`reference`,()=>N(s.target.path,s.target.directory),`reference`),le(`复制相对路径`,`copy`,()=>te(s.target.path)),!s.target.directory&&!s.target.linked&&(0,I.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:C(`asset`,s.target.path,{download:`1`}),download:lS(s.target.path),onClick:()=>E(!0),children:[(0,I.jsx)(Xx,{name:`download`}),(0,I.jsx)(`span`,{children:`下载`})]}),!s.target.path&&le(`打开回收站`,`trash`,()=>void ee(),`trash-list`),!!s.target.path&&!s.target.linked&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{role:`separator`}),le(`移到回收站`,`trash`,()=>D(`trash`,s.target),`trash`,`Delete`)]})]}),l&&!ie&&!ae&&(0,I.jsx)(dS,{title:ne,cancel:()=>{p||O()},children:(0,I.jsxs)(`form`,{onSubmit:A,className:`file-explorer-form`,children:[l.action===`trash`?(0,I.jsxs)(`p`,{children:[`将「`,l.target.path,`」移到回收站?`]}):(0,I.jsx)(pS,{files:r,source:l.target,scopeName:t}),h&&(0,I.jsx)(`p`,{role:`alert`,children:h}),(0,I.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:p,onClick:O,children:`取消`}),(0,I.jsx)(`button`,{type:`submit`,disabled:p,children:l.move?`移动到此处`:ne})]})]})}),d&&(0,I.jsxs)(dS,{title:`回收站`,cancel:()=>{p||f(void 0)},children:[h&&(0,I.jsx)(`p`,{role:`alert`,children:h}),d.length?(0,I.jsx)(`ul`,{className:`file-explorer-trash`,children:d.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{children:e.path}),(0,I.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:p,onClick:()=>void k({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,I.jsx)(`p`,{children:`回收站为空。`}),(0,I.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>f(void 0),children:`关闭`})]}),_&&(0,I.jsxs)(dS,{title:`同名文件`,cancel:()=>v(void 0),children:[(0,I.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,I.jsx)(`ul`,{children:_.items.map(e=>(0,I.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,I.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${_.items.length} 个同名文件。`),v(void 0)},children:`跳过`}),(0,I.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void M(_.parent,_.items.map(e=>e.file),_.items),children:`替换`})]})]})]}),toolbar:ce,inline:oe,editing:ie||ae,busy:p,openMenu:T,showAction:D,upload:M,moveTo:se}}var hS=class extends F.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,I.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,I.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,I.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,I.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,I.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,I.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function gS(){}gS.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(_S(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 _S(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 gS;var vS=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,yS=/\S/,bS=new gS;bS.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!yS.test(e)&&!yS.test(t)},bS.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]&&vS.test(t[n])&&vS.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var xS=new gS;xS.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
308
308
  `));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 SS(e,t,n){return xS.diff(e,t,n)}var CS=new gS;CS.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var wS=new gS;wS.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function TS(e){"@babel/helpers - typeof";return TS=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},TS(e)}var ES=Object.prototype.toString,DS=new gS;DS.useLongestToken=!0,DS.tokenize=xS.tokenize,DS.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(OS(e,null,null,i),i,` `)},DS.equals=function(e,t){return gS.prototype.equals.call(DS,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function OS(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(ES.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=OS(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),TS(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]=OS(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var kS=new gS;kS.tokenize=function(e){return e.slice()},kS.join=kS.removeEmpty=function(e){return e};function AS(e,t){let n=SS(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
309
- `),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 jS(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}}function MS(e){return Array.isArray?Array.isArray(e):HS(e)===`[object Array]`}function NS(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function PS(e){return e==null?``:NS(e)}function FS(e){return typeof e==`string`}function IS(e){return typeof e==`number`}function LS(e){return e===!0||e===!1||zS(e)&&HS(e)==`[object Boolean]`}function RS(e){return typeof e==`object`}function zS(e){return RS(e)&&e!==null}function BS(e){return e!=null}function VS(e){return!e.trim().length}function HS(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var US=`Incorrect 'index' type`,WS=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,GS=e=>`Invalid value for key ${e}`,KS=e=>`Pattern length exceeds max of ${e}.`,qS=e=>`Missing ${e} property in key`,JS=e=>`Property 'weight' in key '${e}' must be a positive integer`,YS=`Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`,XS=Object.prototype.hasOwnProperty,ZS=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=QS(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function QS(e){let t=null,n=null,r=null,i=1,a=null;if(FS(e)||MS(e))r=e,t=$S(e),n=eC(e);else{if(!XS.call(e,`name`))throw Error(qS(`name`));let o=e.name;if(r=o,XS.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(JS(eC(o)));t=$S(o),n=eC(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function $S(e){return MS(e)?e:e.split(`.`)}function eC(e){return MS(e)?e.join(`.`):e}function tC(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(BS(e)){if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!BS(s))return;if(a===t.length-1&&(FS(s)||IS(s)||LS(s)||typeof s==`bigint`))n.push(o===void 0?PS(s):{v:PS(s),i:o});else if(MS(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}}};return i(e,FS(t)?t.split(`.`):t,0),r?n:n[0]}var nC={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},rC={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},iC={location:0,threshold:.6,distance:100},aC={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:tC,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},oC=Object.freeze({...rC,...nC,...iC,...aC});function sC(e){return e>=9&&e<=13||e===32||e===160}function cC(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=0,a=!1;for(let e=0;e<t.length;e++)sC(t.charCodeAt(e))?a=!1:a||=(i++,!0);if(i===0&&(i=1),n.has(i))return n.get(i);let o=Math.round(r/i**(.5*e))/r;return n.set(i,o),o},clear(){n.clear()}}}var lC=class{constructor({getFn:e=oC.getFn,fieldNormWeight:t=oC.fieldNormWeight}={}){this.norm=cC(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let e=this.docs.length;this.records=Array(e);let t=0;if(FS(this.docs[0]))for(let n=0;n<e;n++){let e=this._createStringRecord(this.docs[n],n);e&&(this.records[t++]=e)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw Error(WS);if(FS(e)){let n=this._createStringRecord(e,t);return n&&this.records.push(n),n}let n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw Error(WS);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&--this.records[t].i}removeAll(e){let t=new Set;for(let n of e)Number.isInteger(n)&&n>=0&&t.add(n);if(t.size===0)return;this.records=this.records.filter(e=>!t.has(e.i));let n=Array.from(t).sort((e,t)=>e-t);for(let e of this.records){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e.i?t=i+1:r=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!BS(e)||VS(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){let n={i:t,$:{}};for(let t=0,r=this.keys.length;t<r;t++){let r=this.keys[t],i=r.getFn?r.getFn(e):this.getFn(e,r.path);if(BS(i)){if(MS(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(BS(n)){if(FS(n)){if(!VS(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(BS(n.v)){let t=FS(n.v)?n.v:PS(n.v);if(!VS(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(FS(i)&&!VS(i)){let e={v:i,n:this.norm.get(i)};n.$[t]=e}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function uC(e,t,{getFn:n=oC.getFn,fieldNormWeight:r=oC.fieldNormWeight}={}){let i=new lC({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(QS)),i.setSources(t),i.create(),i}function dC(e,{getFn:t=oC.getFn,fieldNormWeight:n=oC.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new lC({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function fC(e=[],t=oC.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}function pC(e,t,n,{location:r=oC.location,distance:i=oC.distance,threshold:a=oC.threshold,findAllMatches:o=oC.findAllMatches,minMatchCharLength:s=oC.minMatchCharLength,includeMatches:c=oC.includeMatches,ignoreLocation:l=oC.ignoreLocation}={}){if(t.length>32)throw Error(KS(32));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=0,S=u+d,C=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=S;for(;r<i;)h(t,f+i)<=p?r=i:S=i,i=Math.floor((S-r)/2+r);S=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&C&&(b=h(t,i),b<=p)){if(p=b,m=i,x=t,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}if(g&&m>=0){let t=Math.min(d-1,m+u-1+x);for(let r=m;r<=t;r+=1)n[e[r]]&&(_[r]=1)}let w={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=fC(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function mC(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function hC(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var gC={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},_C=RegExp(`[`+Object.keys(gC).join(``)+`]`,`g`),vC=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(_C,e=>gC[e]):e=>e,yC=class{constructor(e,{location:t=oC.location,threshold:n=oC.threshold,distance:r=oC.distance,includeMatches:i=oC.includeMatches,findAllMatches:a=oC.findAllMatches,minMatchCharLength:o=oC.minMatchCharLength,isCaseSensitive:s=oC.isCaseSensitive,ignoreDiacritics:c=oC.ignoreDiacritics,ignoreLocation:l=oC.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?vC(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:mC(e),startIndex:t})},d=this.pattern.length;if(d>32){let e=0,t=d%32,n=d-t;for(;e<n;)u(this.pattern.substr(e,32),e),e+=32;if(t){let e=d-32;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?vC(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=pC(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=hC(u)),p}},bC=new Set([`fuzzy`,`include`]);function xC(e){return e.startsWith(`inverse`)}var SC=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new yC(e,{location:t.location??oC.location,threshold:t.threshold??oC.threshold,distance:t.distance??oC.distance,includeMatches:t.includeMatches??oC.includeMatches,findAllMatches:t.findAllMatches??oC.findAllMatches,minMatchCharLength:t.minMatchCharLength??oC.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??oC.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??oC.ignoreDiacritics,ignoreLocation:t.ignoreLocation??oC.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],CC=SC.length,wC=`\0`,TC=`|`;function EC(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function DC(e,t){let n=e.match(t);return n?n[1]:null}function OC(e,t={}){return e.replace(/\\\|/g,wC).split(TC).map(e=>{let n=EC(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<CC;){let e=SC[o],n=DC(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<CC;){let e=SC[o],n=DC(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}var kC=class{constructor(e,{isCaseSensitive:t=oC.isCaseSensitive,ignoreDiacritics:n=oC.ignoreDiacritics,includeMatches:r=oC.includeMatches,minMatchCharLength:i=oC.minMatchCharLength,ignoreLocation:a=oC.ignoreLocation,findAllMatches:o=oC.findAllMatches,location:s=oC.location,threshold:c=oC.threshold,distance:l=oC.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?vC(e):e,this.pattern=e,this.query=OC(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?vC(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l)a+=1,s+=d,xC(r.type)&&(c=!0),n&&(bC.has(r.type)?o.push(...u):o.push(u));else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=hC(o)),e}}return{isMatch:!1,score:1}}},AC=[];function jC(...e){AC.push(...e)}function MC(e,t){for(let n=0,r=AC.length;n<r;n+=1){let r=AC[n];if(r.condition(e,t))return new r(e,t)}return new yC(e,t)}var NC={AND:`$and`,OR:`$or`},PC={PATH:`$path`,PATTERN:`$val`},FC=e=>!!(e[NC.AND]||e[NC.OR]),IC=e=>!!e[PC.PATH],LC=e=>!MS(e)&&RS(e)&&!FC(e),RC=e=>({[NC.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function zC(e,t,{auto:n=!0}={}){let r=e=>{if(FS(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=MC(e,t)),r}let i=Object.keys(e),a=IC(e);if(!a&&i.length>1&&!FC(e))return r(RC(e));if(LC(e)){let r=a?e[PC.PATH]:i[0],o=a?e[PC.PATTERN]:e[r];if(!FS(o))throw Error(GS(r));let s={keyId:eC(r),pattern:o};return n&&(s.searcher=MC(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];MS(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return FC(e)||(e=RC(e)),r(e)}function BC(e,{ignoreFieldNorm:t=oC.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function VC(e,{ignoreFieldNorm:t=oC.ignoreFieldNorm}){e.forEach(e=>{e.score=BC(e.matches,{ignoreFieldNorm:t})})}var HC=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(this.comparator(t[e],t[n])<=0)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&this.comparator(t[i],t[r])>0&&(r=i),a<n&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function UC(e){let t=[];return e.matches.forEach(e=>{if(!BS(e.indices)||!e.indices.length)return;let n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.id),e.idx>-1&&(n.refIndex=e.idx),t.push(n)}),t}function WC(e,t,{includeMatches:n=oC.includeMatches,includeScore:r=oC.includeScore}={}){return e.map(e=>{let{idx:i}=e,a={item:t[i],refIndex:i};return n&&(a.matches=UC(e)),r&&(a.score=e.score),a})}var GC=/[\p{L}\p{M}\p{N}_]+/gu,KC=new WeakSet;function qC(e){KC.has(e)||(KC.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function JC(e){if(typeof e==`function`){let t=!1;return n=>{let r=e(n);if(!t&&(t=!0,!Array.isArray(r)||r.some(e=>typeof e!=`string`)))throw Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?`array containing non-strings`:typeof r}.`);return r}}return e instanceof RegExp?(e.global||qC(e),t=>t.match(e)||[]):e=>e.match(GC)||[]}function YC({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=JC(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=vC(n)),r(n)}}}var XC=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=YC({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new yC(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=hC(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}};function ZC(e,t,n,r){let i=r.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);let a=new Set(i),o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(let t of a)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function QC(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0)ZC(e,a,i,r);else if(o)for(let t=0;t<n;t++){let n=o[t];if(n){if(Array.isArray(n))for(let t of n)ZC(e,t.v,i,r);else ZC(e,n.v,i,r)}}}function $C(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)QC(r,i,t,n);return r}function ew(e,t,n,r){QC(e,t,n,r)}function tw(e,t){let n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);let r=e.docTermFieldHits.get(t);if(r){for(let[t,n]of r){let r=(e.df.get(t)||0)-n;r<=0?e.df.delete(t):e.df.set(t,r)}e.docTermFieldHits.delete(t)}}function nw(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)tw(e,t);let r=e=>{let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e?t=i+1:r=i}return e-t},i=n[0],a=new Map;for(let[t,n]of e.docFieldCount)a.set(t>i?r(t):t,n);e.docFieldCount=a;let o=new Map;for(let[t,n]of e.docTermFieldHits)o.set(t>i?r(t):t,n);e.docTermFieldHits=o}var rw=class{constructor(e,t,n){this.options={...oC,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new ZS(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=MC(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof lC))throw Error(US);if(this._myIndex=t||uC(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=YC({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=$C(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!BS(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=YC({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ew(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){this._invertedIndex&&nw(this._invertedIndex,n);let e=new Set(n);this._docs=this._docs.filter((t,n)=>!e.has(n)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw Error(WS);this._invertedIndex&&nw(this._invertedIndex,[e]);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(FS(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return IS(n)&&n>-1&&(e=e.slice(0,n)),e}let c=a&&IS(n)&&n>0&&FS(e),l=o,u=(e,t)=>l(e,t)||e.idx-t.idx,d;if(c){let t=new HC(n,u);FS(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),d=t.extractSorted()}else d=FS(e)?FS(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),VC(d,{ignoreFieldNorm:s}),a&&d.sort(FS(e)?u:l),IS(n)&&n>-1&&(d=d.slice(0,n));return WC(d,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=t?null:[];return a.forEach(({v:e,i:a,n:s})=>{if(!BS(e))return;let c=r.searchIn(e);if(c.isMatch){let r={score:c.score,value:e,norm:s,indices:c.indices};i&&(r.matchedMask=c.matchedMask,r.matchedTerms=c.matchedTerms,r.termCount=c.termCount);let l=[r];if(!i||this._coversAllTokens(l)){let r={item:e,idx:a,matches:l};t?(r.score=BC(r.matches,{ignoreFieldNorm:n}),t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=zC(e,this.options),n=this._normalizedKeys(),r=(e,t,i)=>{if(!(`children`in e)){let{keyId:r,searcher:a}=e,o;return r===null?(o=[],n.forEach((e,n)=>{o.push(...this._findMatches({key:e,value:t[n],searcher:a}))})):o=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(t,r),searcher:a}),o&&o.length?[{idx:i,item:t,matches:o}]:[]}let{children:a,operator:o}=e,s=[];for(let e=0,n=a.length;e<n;e+=1){let n=a[e],c=r(n,t,i);if(c.length)s.push(...c);else if(o===NC.AND)return[]}return s},i=this._myIndex.records,a=new Map,o=[];return i.forEach(({$:e,i:n})=>{if(BS(e)){let i=r(t,e,n);i.length&&(a.has(n)||(a.set(n,{idx:n,item:e,matches:[]}),o.push(a.get(n))),i.forEach(({matches:e})=>{a.get(n).matches.push(...e)}))}}),o}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=this._normalizedKeys(),s=t?null:[];return a.forEach(({$:e,i:a})=>{if(!BS(e))return;let c=[],l=!1,u=!1;if(o.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(c.push(...i),i[0].hasInverse&&(u=!0)):l=!0}),!(u&&l)&&c.length&&(!i||this._coversAllTokens(c))){let r={idx:a,item:e,matches:c};t?(r.score=BC(r.matches,{ignoreFieldNorm:n}),t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!BS(t))return[];let r=[];if(MS(t))t.forEach(({v:t,i,n:a})=>{if(!BS(t))return;let o=n.searchIn(t);if(o.isMatch){let n={score:o.score,key:e,value:t,idx:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),r.push(n)}});else{let{v:i,n:a}=t,o=n.searchIn(i);if(o.isMatch){let t={score:o.score,key:e,value:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(t.matchedMask=o.matchedMask,t.matchedTerms=o.matchedTerms,t.termCount=o.termCount),r.push(t)}}return r}_coversAllTokens(e){let t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let n=0;for(let t=0;t<e.length;t++)n|=e[t].matchedMask||0;return n===2**t-1}let n=new Set;for(let t=0;t<e.length;t++){let r=e[t].matchedTerms;if(r)for(let e of r)n.add(e)}return n.size===t}};rw.version=`7.5.0`,rw.createIndex=uC,rw.parseIndex=dC,rw.config=oC,rw.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(YS);return MC(e,{...oC,...n}).searchIn(t)},rw.parseQuery=zC,jC(kC),jC(XC),rw.use=function(...e){e.forEach(e=>jC(e))};var iw=rw,aw=`super-pi.outbox.v1.`,ow=e=>aw+JSON.stringify([e.conversationId,e.clientId]);function sw(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(aw)))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===ow(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function cw(e){try{return window.localStorage.setItem(ow(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function lw(e,t){try{window.localStorage.removeItem(ow({conversationId:e,clientId:t}))}catch{}}function uw(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId);if(!r||r.messages.some(e=>e.id===t.clientId))return e;let i=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...i?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:t.clientId,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...i?{delivery:`waiting`}:{}}]}:e)}}function dw(e,t){try{return JSON.parse(window.sessionStorage.getItem(e)??`null`)??t}catch{return t}}function fw(e,t){try{return window.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}var pw=`modulepreload`,mw=function(e){return`/`+e},hw={},gw=function(e){return e.pathname.endsWith(`.css`)},_w=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},vw=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=mw(t,n);let r=s(t),i=gw(r);return _w(hw,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`:pw,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)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})},yw=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},bw=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},xw=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function Sw(e,t,n={}){if(n.signal?.aborted)throw new bw;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 fetch(xw(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 yw(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new bw:a?new yw(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var Cw=`\0`,ww=(e,t,n)=>[e,t,n??``].join(Cw),Tw=24,Ew=new Map;function Dw(e){let t=Ew.get(e);if(t)return Ew.delete(e),Ew.set(e,t),t}function Ow(e,t){for(Ew.delete(e),Ew.set(e,t);Ew.size>Tw;){let e=Ew.keys().next();if(e.done)break;Ew.delete(e.value)}}var kw={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},Aw=`此工作区不是 Git 仓库`;function jw(e){return e&&kw[e]?{code:e,text:kw[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function Mw(e){return e instanceof yw&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:Aw}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var Nw=`${Cw}uncommitted`;function Pw(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?Nw:n.commit??`${Cw}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 Fw(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function Iw(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 Lw(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,Rw(t.date),t.summary?.trim()||`(没有提交摘要)`]}function Rw(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 zw(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 Bw(e,t,n=!1){return!t||!t.supported?!1:n||zw(e)!==t.totalLines}var Vw=new WeakMap;function Hw(e){let t=Vw.get(e);if(t)return t;let n={response:e,models:Pw(e),covered:Fw(e)};return Vw.set(e,n),n}function Uw(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Ww=`a1b2c3d · Author`;async function Gw(){let[e,t]=await Promise.all([vw(()=>import(`./dist-Dsg7Czd_.js`).then(e=>e.x),[]),vw(()=>import(`./dist-Dw8HA8Ry.js`).then(e=>e.s),__vite__mapDeps([0,1]))]),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=Lw(this.model);return e.setAttribute(`title`,t.join(`
310
- `)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Iw(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=Ww,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=Uw(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=Uw(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:Kw(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 Kw(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 Lw(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}var qw=4e3,Jw=(0,F.lazy)(()=>vw(()=>import(`./CodeMirrorEditor-XhzxZkT7.js`).then(e=>({default:e.CodeMirrorEditor})),[])),Yw=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Xw=15e3,Zw=e=>new Yw(408,{error:`请求超时:${Xw/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Qw(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Xw);try{let r=await fetch(e,{...t,signal:n.signal}),i;try{i=await r.json()}catch{i=void 0}if(!r.ok)throw new Yw(r.status,i??{error:`HTTP ${r.status}`});return i}catch(t){throw n.signal.aborted?Zw(e):t}finally{clearTimeout(r)}}var $w=e=>e instanceof Yw?e:new Yw(0,{error:e instanceof Error?e.message:`读取失败`}),eT=e=>encodeURIComponent(e),tT=e=>e?`&cwd=${eT(e)}`:``,nT=(e,t,n)=>`/api/files?workspaceId=${eT(e)}&path=${eT(t)}${tT(n)}`,rT=(e,t,n)=>`/api/file?workspaceId=${eT(e)}&path=${eT(t)}${tT(n)}`,iT=(e,t,n)=>`/api/file?workspaceId=${eT(e)}&path=${eT(t)}&meta=1${tT(n)}`,aT=(e,t,n)=>`/api/files?workspaceId=${eT(e)}&q=${eT(t)}${tT(n)}`,oT=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function sT({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:u,depth:d,linked:f,presentation:p}){let m=r[t],h=i.has(t);(0,F.useEffect)(()=>{h&&m===void 0&&o(t)},[h,t,m,o]);let g=p.inline(t,`entry`,d),_=p.inline(t,`child`,d+1);return(0,I.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":f,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,I.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":p.dropPath===t?`1`:void 0,hidden:!!g,style:{"--file-depth":d},children:[(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":h,tabIndex:-1,draggable:!f,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,I.jsx)(Xx,{name:h?`down`:`right`})}),(0,I.jsx)(vp,{category:h?`folder-open`:`folder`}),(0,I.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,I.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,I.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,I.jsx)(Xx,{name:`more`})})]}),g,h&&(0,I.jsxs)(`ul`,{className:`file-children`,children:[_&&(0,I.jsx)(`li`,{children:_}),m===void 0?(0,I.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in m?(0,I.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:fp(m.error.message),children:dp(m.error.message,`这个目录读取失败。`)}):m.entries.length===0?(0,I.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,I.jsxs)(I.Fragment,{children:[m.truncated&&(0,I.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),m.entries.map(t=>t.kind===`directory`?(0,I.jsx)(sT,{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:u,depth:d+1,presentation:p},t.path):(0,I.jsx)(cT,{entry:t,depth:d+1,openPaths:s,changedPaths:l,onOpen:u,presentation:p},t.path))]})]})]})}function cT({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`)return(0,I.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 是一个指向 workspace 之外的符号链接,不能打开`,tabIndex:-1,children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`file-name`,children:e.name}),(0,I.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=oS(e.path),u=a.currentPath===e.path,d=a.inline(e.path,`entry`,t);return(0,I.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,I.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":u?`1`:void 0,hidden:!!d,style:o,children:[(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!e.text&&!l||void 0,title:e.text||l?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":u?`true`:void 0,draggable:!e.symlink,onClick:t=>{(e.text||l)&&i(e,t.detail>1)},children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,I.jsx)(vp,{path:e.path}),(0,I.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,I.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,I.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,I.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),!e.text&&!e.document&&!l&&(0,I.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),(0,I.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,I.jsx)(Xx,{name:`more`})})]}),d]})}function lT({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:u=``,navigation:d,embedded:f=!1,onPosition:p}){let[m,h]=(0,F.useState)(!0),g=(0,F.useRef)(null),[_,v]=(0,F.useState)({}),[y,b]=(0,F.useState)(null),x=(0,F.useRef)(0),S=_[e.path]===!0&&!!l,C=l?u?`${l}:${u}`:l:``;(0,F.useEffect)(()=>{let t=++x.current;if(!S||!l){b(null);return}let n=new AbortController,i=ww(C,e.path,e.etag),a=r?void 0:Dw(i);if(a)b({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:C,note:a.supported?null:jw(a.reason)});else return b({state:`loading`,response:null,path:e.path,workspaceId:C,note:null}),Sw(l,e.path,{signal:n.signal,cwd:u}).then(n=>{t===x.current&&(r||Ow(i,n),b({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:C,note:n.supported?null:jw(n.reason)}))}).catch(n=>{if(t!==x.current||n instanceof bw)return;let r=Mw(n);b({state:r.state,response:null,path:e.path,workspaceId:C,note:r.note})}),()=>{n.abort()}},[S,l,u,C,e.path,e.etag,r]);let w=y&&y.path===e.path&&y.workspaceId===C?y:null,T=S?w?.state??`loading`:`off`,E=T===`ready`&&Bw(e.content,w?.response??null,e.dirty||r),D=[];w?.note&&D.push(w.note),T===`ready`&&w?.response?.truncated&&D.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${w.response.totalLines} 行)`}),E&&D.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let O=T===`loading`?`⌛ Blame`:T===`ready`?`✓ Blame`:T===`off`?`Blame`:`! Blame`;(0,F.useEffect)(()=>{i&&h(!1)},[e.path,i]),(0,F.useEffect)(()=>{let e=g.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
309
+ `),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 jS(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}}function MS(e){return Array.isArray?Array.isArray(e):HS(e)===`[object Array]`}function NS(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function PS(e){return e==null?``:NS(e)}function FS(e){return typeof e==`string`}function IS(e){return typeof e==`number`}function LS(e){return e===!0||e===!1||zS(e)&&HS(e)==`[object Boolean]`}function RS(e){return typeof e==`object`}function zS(e){return RS(e)&&e!==null}function BS(e){return e!=null}function VS(e){return!e.trim().length}function HS(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var US=`Incorrect 'index' type`,WS=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,GS=e=>`Invalid value for key ${e}`,KS=e=>`Pattern length exceeds max of ${e}.`,qS=e=>`Missing ${e} property in key`,JS=e=>`Property 'weight' in key '${e}' must be a positive integer`,YS=`Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`,XS=Object.prototype.hasOwnProperty,ZS=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=QS(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function QS(e){let t=null,n=null,r=null,i=1,a=null;if(FS(e)||MS(e))r=e,t=$S(e),n=eC(e);else{if(!XS.call(e,`name`))throw Error(qS(`name`));let o=e.name;if(r=o,XS.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(JS(eC(o)));t=$S(o),n=eC(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function $S(e){return MS(e)?e:e.split(`.`)}function eC(e){return MS(e)?e.join(`.`):e}function tC(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(BS(e)){if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!BS(s))return;if(a===t.length-1&&(FS(s)||IS(s)||LS(s)||typeof s==`bigint`))n.push(o===void 0?PS(s):{v:PS(s),i:o});else if(MS(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}}};return i(e,FS(t)?t.split(`.`):t,0),r?n:n[0]}var nC={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},rC={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},iC={location:0,threshold:.6,distance:100},aC={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:tC,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},oC=Object.freeze({...rC,...nC,...iC,...aC});function sC(e){return e>=9&&e<=13||e===32||e===160}function cC(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=0,a=!1;for(let e=0;e<t.length;e++)sC(t.charCodeAt(e))?a=!1:a||=(i++,!0);if(i===0&&(i=1),n.has(i))return n.get(i);let o=Math.round(r/i**(.5*e))/r;return n.set(i,o),o},clear(){n.clear()}}}var lC=class{constructor({getFn:e=oC.getFn,fieldNormWeight:t=oC.fieldNormWeight}={}){this.norm=cC(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let e=this.docs.length;this.records=Array(e);let t=0;if(FS(this.docs[0]))for(let n=0;n<e;n++){let e=this._createStringRecord(this.docs[n],n);e&&(this.records[t++]=e)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw Error(WS);if(FS(e)){let n=this._createStringRecord(e,t);return n&&this.records.push(n),n}let n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw Error(WS);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&--this.records[t].i}removeAll(e){let t=new Set;for(let n of e)Number.isInteger(n)&&n>=0&&t.add(n);if(t.size===0)return;this.records=this.records.filter(e=>!t.has(e.i));let n=Array.from(t).sort((e,t)=>e-t);for(let e of this.records){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e.i?t=i+1:r=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!BS(e)||VS(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){let n={i:t,$:{}};for(let t=0,r=this.keys.length;t<r;t++){let r=this.keys[t],i=r.getFn?r.getFn(e):this.getFn(e,r.path);if(BS(i)){if(MS(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(BS(n)){if(FS(n)){if(!VS(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(BS(n.v)){let t=FS(n.v)?n.v:PS(n.v);if(!VS(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(FS(i)&&!VS(i)){let e={v:i,n:this.norm.get(i)};n.$[t]=e}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function uC(e,t,{getFn:n=oC.getFn,fieldNormWeight:r=oC.fieldNormWeight}={}){let i=new lC({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(QS)),i.setSources(t),i.create(),i}function dC(e,{getFn:t=oC.getFn,fieldNormWeight:n=oC.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new lC({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function fC(e=[],t=oC.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}function pC(e,t,n,{location:r=oC.location,distance:i=oC.distance,threshold:a=oC.threshold,findAllMatches:o=oC.findAllMatches,minMatchCharLength:s=oC.minMatchCharLength,includeMatches:c=oC.includeMatches,ignoreLocation:l=oC.ignoreLocation}={}){if(t.length>32)throw Error(KS(32));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=0,S=u+d,C=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=S;for(;r<i;)h(t,f+i)<=p?r=i:S=i,i=Math.floor((S-r)/2+r);S=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&C&&(b=h(t,i),b<=p)){if(p=b,m=i,x=t,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}if(g&&m>=0){let t=Math.min(d-1,m+u-1+x);for(let r=m;r<=t;r+=1)n[e[r]]&&(_[r]=1)}let w={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=fC(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function mC(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function hC(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var gC={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},_C=RegExp(`[`+Object.keys(gC).join(``)+`]`,`g`),vC=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(_C,e=>gC[e]):e=>e,yC=class{constructor(e,{location:t=oC.location,threshold:n=oC.threshold,distance:r=oC.distance,includeMatches:i=oC.includeMatches,findAllMatches:a=oC.findAllMatches,minMatchCharLength:o=oC.minMatchCharLength,isCaseSensitive:s=oC.isCaseSensitive,ignoreDiacritics:c=oC.ignoreDiacritics,ignoreLocation:l=oC.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?vC(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:mC(e),startIndex:t})},d=this.pattern.length;if(d>32){let e=0,t=d%32,n=d-t;for(;e<n;)u(this.pattern.substr(e,32),e),e+=32;if(t){let e=d-32;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?vC(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=pC(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=hC(u)),p}},bC=new Set([`fuzzy`,`include`]);function xC(e){return e.startsWith(`inverse`)}var SC=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new yC(e,{location:t.location??oC.location,threshold:t.threshold??oC.threshold,distance:t.distance??oC.distance,includeMatches:t.includeMatches??oC.includeMatches,findAllMatches:t.findAllMatches??oC.findAllMatches,minMatchCharLength:t.minMatchCharLength??oC.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??oC.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??oC.ignoreDiacritics,ignoreLocation:t.ignoreLocation??oC.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],CC=SC.length,wC=`\0`,TC=`|`;function EC(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function DC(e,t){let n=e.match(t);return n?n[1]:null}function OC(e,t={}){return e.replace(/\\\|/g,wC).split(TC).map(e=>{let n=EC(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<CC;){let e=SC[o],n=DC(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<CC;){let e=SC[o],n=DC(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}var kC=class{constructor(e,{isCaseSensitive:t=oC.isCaseSensitive,ignoreDiacritics:n=oC.ignoreDiacritics,includeMatches:r=oC.includeMatches,minMatchCharLength:i=oC.minMatchCharLength,ignoreLocation:a=oC.ignoreLocation,findAllMatches:o=oC.findAllMatches,location:s=oC.location,threshold:c=oC.threshold,distance:l=oC.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?vC(e):e,this.pattern=e,this.query=OC(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?vC(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l)a+=1,s+=d,xC(r.type)&&(c=!0),n&&(bC.has(r.type)?o.push(...u):o.push(u));else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=hC(o)),e}}return{isMatch:!1,score:1}}},AC=[];function jC(...e){AC.push(...e)}function MC(e,t){for(let n=0,r=AC.length;n<r;n+=1){let r=AC[n];if(r.condition(e,t))return new r(e,t)}return new yC(e,t)}var NC={AND:`$and`,OR:`$or`},PC={PATH:`$path`,PATTERN:`$val`},FC=e=>!!(e[NC.AND]||e[NC.OR]),IC=e=>!!e[PC.PATH],LC=e=>!MS(e)&&RS(e)&&!FC(e),RC=e=>({[NC.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function zC(e,t,{auto:n=!0}={}){let r=e=>{if(FS(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=MC(e,t)),r}let i=Object.keys(e),a=IC(e);if(!a&&i.length>1&&!FC(e))return r(RC(e));if(LC(e)){let r=a?e[PC.PATH]:i[0],o=a?e[PC.PATTERN]:e[r];if(!FS(o))throw Error(GS(r));let s={keyId:eC(r),pattern:o};return n&&(s.searcher=MC(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];MS(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return FC(e)||(e=RC(e)),r(e)}function BC(e,{ignoreFieldNorm:t=oC.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function VC(e,{ignoreFieldNorm:t=oC.ignoreFieldNorm}){e.forEach(e=>{e.score=BC(e.matches,{ignoreFieldNorm:t})})}var HC=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(this.comparator(t[e],t[n])<=0)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&this.comparator(t[i],t[r])>0&&(r=i),a<n&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function UC(e){let t=[];return e.matches.forEach(e=>{if(!BS(e.indices)||!e.indices.length)return;let n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.id),e.idx>-1&&(n.refIndex=e.idx),t.push(n)}),t}function WC(e,t,{includeMatches:n=oC.includeMatches,includeScore:r=oC.includeScore}={}){return e.map(e=>{let{idx:i}=e,a={item:t[i],refIndex:i};return n&&(a.matches=UC(e)),r&&(a.score=e.score),a})}var GC=/[\p{L}\p{M}\p{N}_]+/gu,KC=new WeakSet;function qC(e){KC.has(e)||(KC.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function JC(e){if(typeof e==`function`){let t=!1;return n=>{let r=e(n);if(!t&&(t=!0,!Array.isArray(r)||r.some(e=>typeof e!=`string`)))throw Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?`array containing non-strings`:typeof r}.`);return r}}return e instanceof RegExp?(e.global||qC(e),t=>t.match(e)||[]):e=>e.match(GC)||[]}function YC({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=JC(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=vC(n)),r(n)}}}var XC=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=YC({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new yC(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=hC(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}};function ZC(e,t,n,r){let i=r.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);let a=new Set(i),o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(let t of a)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function QC(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0)ZC(e,a,i,r);else if(o)for(let t=0;t<n;t++){let n=o[t];if(n){if(Array.isArray(n))for(let t of n)ZC(e,t.v,i,r);else ZC(e,n.v,i,r)}}}function $C(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)QC(r,i,t,n);return r}function ew(e,t,n,r){QC(e,t,n,r)}function tw(e,t){let n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);let r=e.docTermFieldHits.get(t);if(r){for(let[t,n]of r){let r=(e.df.get(t)||0)-n;r<=0?e.df.delete(t):e.df.set(t,r)}e.docTermFieldHits.delete(t)}}function nw(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)tw(e,t);let r=e=>{let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e?t=i+1:r=i}return e-t},i=n[0],a=new Map;for(let[t,n]of e.docFieldCount)a.set(t>i?r(t):t,n);e.docFieldCount=a;let o=new Map;for(let[t,n]of e.docTermFieldHits)o.set(t>i?r(t):t,n);e.docTermFieldHits=o}var rw=class{constructor(e,t,n){this.options={...oC,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new ZS(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=MC(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof lC))throw Error(US);if(this._myIndex=t||uC(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=YC({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=$C(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!BS(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=YC({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ew(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){this._invertedIndex&&nw(this._invertedIndex,n);let e=new Set(n);this._docs=this._docs.filter((t,n)=>!e.has(n)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw Error(WS);this._invertedIndex&&nw(this._invertedIndex,[e]);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(FS(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return IS(n)&&n>-1&&(e=e.slice(0,n)),e}let c=a&&IS(n)&&n>0&&FS(e),l=o,u=(e,t)=>l(e,t)||e.idx-t.idx,d;if(c){let t=new HC(n,u);FS(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),d=t.extractSorted()}else d=FS(e)?FS(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),VC(d,{ignoreFieldNorm:s}),a&&d.sort(FS(e)?u:l),IS(n)&&n>-1&&(d=d.slice(0,n));return WC(d,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=t?null:[];return a.forEach(({v:e,i:a,n:s})=>{if(!BS(e))return;let c=r.searchIn(e);if(c.isMatch){let r={score:c.score,value:e,norm:s,indices:c.indices};i&&(r.matchedMask=c.matchedMask,r.matchedTerms=c.matchedTerms,r.termCount=c.termCount);let l=[r];if(!i||this._coversAllTokens(l)){let r={item:e,idx:a,matches:l};t?(r.score=BC(r.matches,{ignoreFieldNorm:n}),t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=zC(e,this.options),n=this._normalizedKeys(),r=(e,t,i)=>{if(!(`children`in e)){let{keyId:r,searcher:a}=e,o;return r===null?(o=[],n.forEach((e,n)=>{o.push(...this._findMatches({key:e,value:t[n],searcher:a}))})):o=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(t,r),searcher:a}),o&&o.length?[{idx:i,item:t,matches:o}]:[]}let{children:a,operator:o}=e,s=[];for(let e=0,n=a.length;e<n;e+=1){let n=a[e],c=r(n,t,i);if(c.length)s.push(...c);else if(o===NC.AND)return[]}return s},i=this._myIndex.records,a=new Map,o=[];return i.forEach(({$:e,i:n})=>{if(BS(e)){let i=r(t,e,n);i.length&&(a.has(n)||(a.set(n,{idx:n,item:e,matches:[]}),o.push(a.get(n))),i.forEach(({matches:e})=>{a.get(n).matches.push(...e)}))}}),o}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=this._normalizedKeys(),s=t?null:[];return a.forEach(({$:e,i:a})=>{if(!BS(e))return;let c=[],l=!1,u=!1;if(o.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(c.push(...i),i[0].hasInverse&&(u=!0)):l=!0}),!(u&&l)&&c.length&&(!i||this._coversAllTokens(c))){let r={idx:a,item:e,matches:c};t?(r.score=BC(r.matches,{ignoreFieldNorm:n}),t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!BS(t))return[];let r=[];if(MS(t))t.forEach(({v:t,i,n:a})=>{if(!BS(t))return;let o=n.searchIn(t);if(o.isMatch){let n={score:o.score,key:e,value:t,idx:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),r.push(n)}});else{let{v:i,n:a}=t,o=n.searchIn(i);if(o.isMatch){let t={score:o.score,key:e,value:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(t.matchedMask=o.matchedMask,t.matchedTerms=o.matchedTerms,t.termCount=o.termCount),r.push(t)}}return r}_coversAllTokens(e){let t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let n=0;for(let t=0;t<e.length;t++)n|=e[t].matchedMask||0;return n===2**t-1}let n=new Set;for(let t=0;t<e.length;t++){let r=e[t].matchedTerms;if(r)for(let e of r)n.add(e)}return n.size===t}};rw.version=`7.5.0`,rw.createIndex=uC,rw.parseIndex=dC,rw.config=oC,rw.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(YS);return MC(e,{...oC,...n}).searchIn(t)},rw.parseQuery=zC,jC(kC),jC(XC),rw.use=function(...e){e.forEach(e=>jC(e))};var iw=rw,aw=`super-pi.outbox.v1.`,ow=e=>aw+JSON.stringify([e.conversationId,e.clientId]);function sw(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(aw)))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===ow(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function cw(e){try{return window.localStorage.setItem(ow(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function lw(e,t){try{window.localStorage.removeItem(ow({conversationId:e,clientId:t}))}catch{}}function uw(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId);if(!r||r.messages.some(e=>e.id===t.clientId))return e;let i=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...i?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:t.clientId,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...i?{delivery:`waiting`}:{}}]}:e)}}function dw(e,t){try{return JSON.parse(window.sessionStorage.getItem(e)??`null`)??t}catch{return t}}function fw(e,t){try{return window.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}var pw=`modulepreload`,mw=function(e){return`/`+e},hw={},gw=function(e){return e.pathname.endsWith(`.css`)},_w=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},vw=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=mw(t,n);let r=s(t),i=gw(r);return _w(hw,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`:pw,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)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})},yw=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},bw=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},xw=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function Sw(e,t,n={}){if(n.signal?.aborted)throw new bw;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 fetch(xw(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 yw(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new bw:a?new yw(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var Cw=`\0`,ww=(e,t,n)=>[e,t,n??``].join(Cw),Tw=24,Ew=new Map;function Dw(e){let t=Ew.get(e);if(t)return Ew.delete(e),Ew.set(e,t),t}function Ow(e,t){for(Ew.delete(e),Ew.set(e,t);Ew.size>Tw;){let e=Ew.keys().next();if(e.done)break;Ew.delete(e.value)}}var kw={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},Aw=`此工作区不是 Git 仓库`;function jw(e){return e&&kw[e]?{code:e,text:kw[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function Mw(e){return e instanceof yw&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:Aw}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var Nw=`${Cw}uncommitted`;function Pw(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?Nw:n.commit??`${Cw}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 Fw(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function Iw(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 Lw(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,Rw(t.date),t.summary?.trim()||`(没有提交摘要)`]}function Rw(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 zw(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 Bw(e,t,n=!1){return!t||!t.supported?!1:n||zw(e)!==t.totalLines}var Vw=new WeakMap;function Hw(e){let t=Vw.get(e);if(t)return t;let n={response:e,models:Pw(e),covered:Fw(e)};return Vw.set(e,n),n}function Uw(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Ww=`a1b2c3d · Author`;async function Gw(){let[e,t]=await Promise.all([vw(()=>import(`./dist-DMSAfmmB.js`).then(e=>e.x),[]),vw(()=>import(`./dist-COPu8Vm9.js`).then(e=>e.s),__vite__mapDeps([0,1]))]),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=Lw(this.model);return e.setAttribute(`title`,t.join(`
310
+ `)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Iw(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=Ww,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=Uw(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=Uw(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:Kw(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 Kw(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 Lw(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}var qw=4e3,Jw=(0,F.lazy)(()=>vw(()=>import(`./CodeMirrorEditor-CxXNu7GH.js`).then(e=>({default:e.CodeMirrorEditor})),[])),Yw=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Xw=15e3,Zw=e=>new Yw(408,{error:`请求超时:${Xw/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Qw(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Xw);try{let r=await fetch(e,{...t,signal:n.signal}),i;try{i=await r.json()}catch{i=void 0}if(!r.ok)throw new Yw(r.status,i??{error:`HTTP ${r.status}`});return i}catch(t){throw n.signal.aborted?Zw(e):t}finally{clearTimeout(r)}}var $w=e=>e instanceof Yw?e:new Yw(0,{error:e instanceof Error?e.message:`读取失败`}),eT=e=>encodeURIComponent(e),tT=e=>e?`&cwd=${eT(e)}`:``,nT=(e,t,n)=>`/api/files?workspaceId=${eT(e)}&path=${eT(t)}${tT(n)}`,rT=(e,t,n)=>`/api/file?workspaceId=${eT(e)}&path=${eT(t)}${tT(n)}`,iT=(e,t,n)=>`/api/file?workspaceId=${eT(e)}&path=${eT(t)}&meta=1${tT(n)}`,aT=(e,t,n)=>`/api/files?workspaceId=${eT(e)}&q=${eT(t)}${tT(n)}`,oT=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function sT({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:u,depth:d,linked:f,presentation:p}){let m=r[t],h=i.has(t);(0,F.useEffect)(()=>{h&&m===void 0&&o(t)},[h,t,m,o]);let g=p.inline(t,`entry`,d),_=p.inline(t,`child`,d+1);return(0,I.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":f,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,I.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":p.dropPath===t?`1`:void 0,hidden:!!g,style:{"--file-depth":d},children:[(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":h,tabIndex:-1,draggable:!f,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,I.jsx)(Xx,{name:h?`down`:`right`})}),(0,I.jsx)(vp,{category:h?`folder-open`:`folder`}),(0,I.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,I.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,I.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,I.jsx)(Xx,{name:`more`})})]}),g,h&&(0,I.jsxs)(`ul`,{className:`file-children`,children:[_&&(0,I.jsx)(`li`,{children:_}),m===void 0?(0,I.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in m?(0,I.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:fp(m.error.message),children:dp(m.error.message,`这个目录读取失败。`)}):m.entries.length===0?(0,I.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,I.jsxs)(I.Fragment,{children:[m.truncated&&(0,I.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),m.entries.map(t=>t.kind===`directory`?(0,I.jsx)(sT,{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:u,depth:d+1,presentation:p},t.path):(0,I.jsx)(cT,{entry:t,depth:d+1,openPaths:s,changedPaths:l,onOpen:u,presentation:p},t.path))]})]})]})}function cT({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`)return(0,I.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 是一个指向 workspace 之外的符号链接,不能打开`,tabIndex:-1,children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`file-name`,children:e.name}),(0,I.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=oS(e.path),u=a.currentPath===e.path,d=a.inline(e.path,`entry`,t);return(0,I.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,I.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":u?`1`:void 0,hidden:!!d,style:o,children:[(0,I.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!e.text&&!l||void 0,title:e.text||l?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":u?`true`:void 0,draggable:!e.symlink,onClick:t=>{(e.text||l)&&i(e,t.detail>1)},children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,I.jsx)(vp,{path:e.path}),(0,I.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,I.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,I.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,I.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),!e.text&&!e.document&&!l&&(0,I.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),(0,I.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,I.jsx)(Xx,{name:`more`})})]}),d]})}function lT({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:u=``,navigation:d,embedded:f=!1,onPosition:p}){let[m,h]=(0,F.useState)(!0),g=(0,F.useRef)(null),[_,v]=(0,F.useState)({}),[y,b]=(0,F.useState)(null),x=(0,F.useRef)(0),S=_[e.path]===!0&&!!l,C=l?u?`${l}:${u}`:l:``;(0,F.useEffect)(()=>{let t=++x.current;if(!S||!l){b(null);return}let n=new AbortController,i=ww(C,e.path,e.etag),a=r?void 0:Dw(i);if(a)b({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:C,note:a.supported?null:jw(a.reason)});else return b({state:`loading`,response:null,path:e.path,workspaceId:C,note:null}),Sw(l,e.path,{signal:n.signal,cwd:u}).then(n=>{t===x.current&&(r||Ow(i,n),b({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:C,note:n.supported?null:jw(n.reason)}))}).catch(n=>{if(t!==x.current||n instanceof bw)return;let r=Mw(n);b({state:r.state,response:null,path:e.path,workspaceId:C,note:r.note})}),()=>{n.abort()}},[S,l,u,C,e.path,e.etag,r]);let w=y&&y.path===e.path&&y.workspaceId===C?y:null,T=S?w?.state??`loading`:`off`,E=T===`ready`&&Bw(e.content,w?.response??null,e.dirty||r),D=[];w?.note&&D.push(w.note),T===`ready`&&w?.response?.truncated&&D.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${w.response.totalLines} 行)`}),E&&D.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let O=T===`loading`?`⌛ Blame`:T===`ready`?`✓ Blame`:T===`off`?`Blame`:`! Blame`;(0,F.useEffect)(()=>{i&&h(!1)},[e.path,i]),(0,F.useEffect)(()=>{let e=g.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
311
311
  `).length),n=e.value.split(`
312
312
  `),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0);e.focus(),e.setSelectionRange(r,r+n[t-1].length);let a=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*a-e.clientHeight/2),e.scrollLeft=0;let o=e.previousElementSibling;o instanceof HTMLElement&&(o.scrollTop=e.scrollTop,o.scrollLeft=0)},[e.path,i,m]);let k=/\.md$/i.test(e.path);return(0,I.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,children:[(0,I.jsxs)(`div`,{className:`file-editor-head`,children:[d??(!f&&(0,I.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,I.jsxs)(`span`,{className:`file-editor-flags`,children:[k&&(0,I.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>h(e=>!e),children:m?`原文`:`预览`}),(0,I.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":T,"aria-pressed":S,"aria-label":S?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>v(t=>({...t,[e.path]:t[e.path]!==!0})),children:O}),e.dirty&&(0,I.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),(0,I.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,I.jsx)(Xx,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),D.length>0&&(0,I.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":D.map(e=>e.code).join(` `),role:`status`,children:D.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,I.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,I.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,I.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,I.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,I.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,I.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,I.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,I.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,I.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,I.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,I.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),k&&m?(0,I.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,I.jsx)(Px,{source:e.content})}):(0,I.jsx)(hS,{fallback:(t,n)=>(0,I.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,I.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,I.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,I.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,I.jsx)(`textarea`,{className:`file-textarea`,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,I.jsx)(F.Suspense,{fallback:(0,I.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,I.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,I.jsx)(Jw,{path:e.path,value:e.content,onChange:a,jumpToLine:i,onSave:o,workspaceId:l,onPosition:p,blame:S&&w&&!E?{state:w.state,response:w.response,path:w.path,workspaceId:l??``}:void 0})})})]})}function uT({line:e}){if(e.kind===`fold`)return(0,I.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,I.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,I.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,I.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,I.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,I.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,I.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function dT({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){if(t)return(0,I.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,I.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:fp(n),children:dp(n,`这个文件的差异读取失败。`)})});if(!e)return(0,I.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let o=typeof r==`string`,s=i===`buffer`&&o,c=s?e.after:e.before,l=s?r:e.after,u=s?`我未保存的修改`:e.label,d=s?`buffer`:e.baseline,f=o&&e.baseline!==`none`?(0,I.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${s?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!s,onClick:()=>a(`server`),children:`agent 的改动`}),(0,I.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${s?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":s,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(d===`none`)return(0,I.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":d,children:[(0,I.jsxs)(`div`,{className:`file-editor-head`,children:[(0,I.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,I.jsx)(`span`,{className:`file-editor-flags`,children:f})]}),(0,I.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:u})]});let p=AS(c,l),m=jS(p);return(0,I.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":d,"data-file-diff-added":p.added,"data-file-diff-removed":p.removed,children:[(0,I.jsxs)(`div`,{className:`file-editor-head`,children:[(0,I.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,I.jsxs)(`span`,{className:`file-editor-flags`,children:[f,(0,I.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:u}),(0,I.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,p.added,` / -`,p.removed]})]})]}),e.beforeUnknown&&!s&&(0,I.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!s&&(0,I.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),p.identical?(0,I.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,I.jsx)(`div`,{className:`file-diff-body`,"data-file-diff-body":`1`,children:m.lines.map((e,t)=>(0,I.jsx)(uT,{line:e},t))})]})}function fT({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,I.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,I.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,I.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||dp(e.message,`路径未知`)})]}),r===`timeout`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,I.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,Xw/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,I.jsx)(`p`,{className:`file-problem-hint`,title:fp(e.message),children:dp(e.message,`读取失败,请稍后重试。`)})]})]})}function pT(e,t=``,{navigation:n,showingFile:r=!1}={}){let i=t.trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``),a=e?i?`${e}:${i}`:e:void 0,o=(0,F.useRef)(a);o.current=a;let[s,c]=(0,F.useState)([]),l=(0,F.useRef)(s);l.current=s;let[u,d]=(0,F.useState)(),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)({}),[g,_]=(0,F.useState)({}),[v,y]=(0,F.useState)({}),[b,x]=(0,F.useState)(()=>new Set),[S,C]=(0,F.useState)(),w=(0,F.useRef)(b);w.current=b;let T=(0,F.useRef)(new Map),E=(0,F.useRef)(new Map),[D,O]=(0,F.useState)(0),[k,A]=(0,F.useState)(``),[ee,j]=(0,F.useState)(null),[M,N]=(0,F.useState)(null),[te,ne]=(0,F.useState)(!1),[re,ie]=(0,F.useState)([]),[ae,oe]=(0,F.useState)(!1),[se,ce]=(0,F.useState)([]),le=(0,F.useRef)(void 0),ue=(0,F.useRef)(-1),de=(0,F.useRef)(!1),fe=(0,F.useCallback)(e=>{le.current?le.current.buffered.push(e):!de.current||e.version<=ue.current||(ue.current=e.version,ie(t=>{let n=new Map(t.map(e=>[e.path,e]));for(let t of e.changed)n.set(t.path,t);for(let t of e.removed)n.delete(t);return[...n.values()]}),oe(e.complete),ce(e.skipped))},[]),pe=(0,F.useCallback)(()=>{let e=le.current;le.current=void 0,e?.controller.abort()},[]);(0,F.useEffect)(()=>(pe(),de.current=!1,ue.current=-1,ie([]),oe(!1),ce([]),pe),[a,pe]);let me=(0,F.useCallback)((t=!1)=>{if(!e||!a||le.current?.scopeKey===a||!t&&de.current)return;let n={workspaceId:e,scopeKey:a,controller:new AbortController,buffered:[]};le.current=n,fetch(`/api/files/index?workspaceId=${encodeURIComponent(e)}${tT(i)}`,{signal:n.controller.signal}).then(e=>{if(!e.ok)throw Error(`文件索引请求失败(${e.status})`);return e.json()}).then(e=>{if(le.current!==n)return;let t=new Map((e.changed??[]).map(e=>[e.path,e]));for(let n of e.removed??[])t.delete(n);let r=e.version??-1,i=e.complete===!0,a=e.skipped??[];for(let e of n.buffered.sort((e,t)=>e.version-t.version))if(!(e.version<=r)){for(let n of e.changed)t.set(n.path,n);for(let n of e.removed)t.delete(n);r=e.version,i=e.complete,a=e.skipped}le.current=void 0,de.current=!0,ue.current=r,ie([...t.values()]),oe(i),ce(a)}).catch(()=>{le.current===n&&(le.current=void 0)})},[e,i,a]),[he,ge]=(0,F.useState)({});(0,F.useEffect)(()=>{if(T.current=new Map,c([]),d(void 0),p(``),h({}),_({}),y({}),x(new Set),C(void 0),j(null),N(null),A(``),ne(!1),!e)return;let t=!0;return Qw(nT(e,``,i)).then(e=>{t&&y({"":e})}).catch(e=>{t&&y({"":{error:$w(e)}})}),()=>{if(t=!1,a&&o.current!==a){let e=l.current.filter(e=>e.dirty);e.length?E.current.set(a,e):E.current.delete(a),fw(`super-pi.file-drafts.v1.`+a,e),_T(a)}}},[e,i,a]);let[_e,ve]=(0,F.useState)(),[ye,be]=(0,F.useState)(void 0);(0,F.useEffect)(()=>{if(!e||!a)return;let t=!0;be(void 0),ve(void 0);let r=hT()[a]??{expanded:[],open:[]},i=dw(`super-pi.file-drafts.v1.`+a,[]),s=new Map((E.current.get(a)??i).map(e=>[e.path,e]));r.expanded.length&&x(new Set(r.expanded)),typeof r.listHeight==`number`&&j(r.listHeight);let l=new Set([...r.open,...s.keys()]);if(!l.size){ve(a);return}let u=r.active??[...s.keys()].at(-1),f=n?.current,p=()=>t&&n?.current===f;return(async()=>{let e,n=r.preview&&!s.has(r.preview)?r.preview:void 0;for(let r of l){if(r===n)continue;let i=s.get(r);i&&c(e=>e.some(e=>e.path===r)?e:[...e,i]);let l=i?.path??await Me({path:r,name:r.split(`/`).pop()??r,text:!0},{activate:!1,isCurrent:()=>t});if(!t||o.current!==a)return;r===u&&(e=l)}if(n&&p()&&(e=await Me({path:n,name:n.split(`/`).pop()??n,text:!0},{activate:!1,isCurrent:p})),e&&o.current===a&&p()){let t=e;r.preview===r.active&&c(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),d(t),be(t)}})().finally(()=>{t&&o.current===a&&ve(a)}),()=>{t=!1}},[e,i,a,n]),(0,F.useEffect)(()=>{if(!e||!a)return;let t=setTimeout(()=>{let e=hT();e[a]={open:s.map(e=>e.path),expanded:[...b],...r&&u?{active:u}:{},...r&&u&&s.some(e=>e.path===u&&e.preview)?{preview:u}:{},...ee===null?{}:{listHeight:ee}},gT(e)},400);return()=>{clearTimeout(t)}},[e,a,s,b,u,ee,r]),(0,F.useEffect)(()=>{if(!a||_e!==a)return;let e=()=>{if(o.current!==a)return;let e=l.current.filter(e=>e.dirty);return fw(`super-pi.file-drafts.v1.`+a,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&p(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[a,_e,s]);let xe=(0,F.useCallback)(async(t,n=!1)=>{if(!e)return;let r={},s=T.current;s.set(t,r);let c=()=>o.current===a&&T.current===s&&s.get(t)===r;await Qw(nT(e,t,i)+(n?`&revalidate=1`:``)).then(e=>{c()&&y(n=>({...n,[t]:e}))}).catch(e=>{c()&&y(n=>({...n,[t]:{error:$w(e)}}))}).finally(()=>{c()&&s.delete(t)})},[e,i,a]),Se=(0,F.useCallback)(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Ce=(0,F.useCallback)(t=>{if(!e)return;let n=new Set([``,...w.current]),r=t&&new Set(t.map(sS)),i=e=>!r||r.has(e)||t.some(t=>cS(e,t));y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of T.current.keys())!n.has(e)&&i(e)&&T.current.delete(e);Promise.all([...n].filter(i).map(e=>xe(e,!t&&!e))).then(()=>{o.current===a&&O(e=>e+1)})},[e,a,xe]),we=(0,F.useCallback)(()=>Ce(),[Ce]),Te=(0,F.useRef)(void 0),Ee=(0,F.useRef)(new Set);(0,F.useEffect)(()=>()=>{clearTimeout(Te.current),Te.current=void 0,Ee.current=new Set},[a]);let De=(0,F.useCallback)((t,n)=>{if(t!==e)return;let r=i?`${i}/`:``,a=n?.flatMap(e=>e.startsWith(r)?[e.slice(r.length)]:[]);if(a?.length===0){if(!n?.some(e=>cS(i,e)))return;Ee.current=null}else if(!a)Ee.current=null;else for(let e of a)Ee.current?.add(e);Te.current||=setTimeout(()=>{Te.current=void 0;let e=Ee.current;Ee.current=new Set,Ce(e?[...e]:void 0)},100)},[e,i,Ce]),Oe=(0,F.useCallback)(e=>{let t=new Set;for(let n=sS(e);n;n=sS(n))t.add(n);A(``),x(e=>new Set([...e,...t]))},[]),ke=(0,F.useCallback)((e,t)=>{Oe(t&&e?`${e}/`:e),C({path:e,directory:t})},[Oe]),Ae=(0,F.useCallback)(()=>x(new Set),[]),je=(0,F.useCallback)((e,t,n)=>{let r=n=>cS(n,e)?t+n.slice(e.length):n,i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[r(e),t]));c(t=>t.map(t=>{let i=r(t.path);if(i===t.path)return t;let a=oS(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}})),d(e=>e&&r(e)),x(e=>new Set([...e].map(r))),h(i),_(i);for(let t of T.current.keys())cS(t,e)&&T.current.delete(t);y(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!cS(t,e)))),Oe(t)},[Oe]);(0,F.useEffect)(()=>{let t=k.trim();if(!e||!t){N(null),ne(!1);return}let n=!0;ne(!0);let r=setTimeout(()=>{Qw(aT(e,t,i)).then(e=>{n&&(N(e),ne(!1))}).catch(e=>{n&&(N({mode:`search`,query:t,hits:[],total:0,indexed:!1}),ne(!1),p(`搜索失败:${e instanceof Error?e.message:`未知错误`}`))})},80);return()=>{n=!1,clearTimeout(r)}},[k,e,i,D]);let Me=(0,F.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:s}={})=>{if(!e||s&&!s())return;let u=oS(t.path);if(t.text===!1&&!u)p(`「${t.name}」可通过文件操作菜单下载。`);else{if(r&&l.current.some(e=>e.path===t.path))return d(t.path),t.path;p(``);try{let l=u&&u!==`table`?await Qw(iT(e,t.path,i)).then(e=>({path:t.path,content:``,meta:e})):await Qw(rT(e,t.path,i));return o.current!==a||s&&!s()?void 0:(c(e=>e.some(e=>e.path===l.path)?e:[...e,{path:l.path,name:t.name,content:l.content,etag:l.meta.etag,dirty:!1,...u?{view:u}:{},...n?{preview:n}:{}}]),r&&d(l.path),_(e=>({...e,[l.path]:!1})),l.path)}catch(e){o.current===a&&(!s||s())&&p(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,i,a]),Ne=(0,F.useCallback)(e=>{a&&l.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&_T(a,e),c(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===u&&d(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[u,a]),Pe=(0,F.useCallback)(e=>{c(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),Fe=(0,F.useCallback)(e=>{c(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),d(t=>t===e?void 0:t),a&&_T(a,e)},[a]),Ie=(0,F.useCallback)((e,t)=>{c(n=>n.map(n=>n.path===e&&n.content!==t?{...n,content:t,dirty:!0,preview:!1}:n))},[]);(0,F.useEffect)(()=>{if(!e||s.length===0)return;let t=!0,n=setInterval(()=>{for(let n of l.current.map(e=>e.path))Qw(iT(e,n,i)).then(e=>{if(!t)return;let r=l.current.find(e=>e.path===n);r?.view&&r.view!==`table`&&e.etag!==r.etag?c(t=>t.map(t=>t.path===n&&t.etag===r.etag?{...t,etag:e.etag}:t)):r&&e.etag!==r.etag&&_(e=>({...e,[n]:!0}))}).catch(e=>{t&&$w(e).status===404&&_(e=>({...e,[n]:!0}))})},qw);return()=>{t=!1,clearInterval(n)}},[e,i,s.length]);let Le=(0,F.useCallback)(async(t,n)=>{if(!e)return;let r=s.find(e=>e.path===t);if(!r)return;h(e=>({...e,[t]:{state:`saving`,message:``}}));let u=r.etag;if(n)try{u=(await Qw(iT(e,t,i))).etag}catch(e){o.current===a&&h(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let d=r.content;try{let n=await Qw(rT(e,t,i),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t,content:d,baseEtag:u})});if(o.current!==a)return;let r=l.current.find(e=>e.path===t),s=r!==void 0&&r.content!==d;c(e=>e.map(e=>e.path===t?{...e,etag:n.meta.etag,dirty:e.content!==d}:e)),_(e=>({...e,[t]:!1})),h(e=>({...e,[t]:{state:`saved`,message:s?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${oT(n.meta.modifiedAt)}`}}))}catch(e){if(o.current!==a)return;let n=e instanceof Yw&&e.body.code===`stale`;h(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&_(e=>({...e,[t]:!0}))}},[e,i,a,s]),Re=(0,F.useCallback)(async t=>{if(!e)return;let n=l.current.find(e=>e.path===t)?.content;try{let r=await Qw(rT(e,t,i));if(o.current!==a)return;let s=l.current.find(e=>e.path===t),u=s!==void 0&&s.content!==n;c(e=>e.map(e=>e.path===t?{...e,content:u?e.content:r.content,etag:r.meta.etag,dirty:u}:e)),_(e=>({...e,[t]:!1})),h(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){o.current===a&&h(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,i,a]),ze=s.find(e=>e.path===u),Be=(0,F.useMemo)(()=>s.map(e=>({id:e.path,label:e.name,title:e.path,closable:!0,badge:e.dirty?(0,I.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[s]),Ve=(0,F.useMemo)(()=>new Set(s.map(e=>e.path)),[s]),He=(0,F.useCallback)((e,t,n)=>{ge(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Ue=e?he[e]:void 0,We=(0,F.useMemo)(()=>{let e=Ue?.changes??[];if(!i)return e;let t=`${i}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Ue,i]),Ge=Ue?.dropped??0,Ke=(0,F.useMemo)(()=>new Set(We.map(e=>e.path)),[We]),qe=(0,F.useMemo)(()=>{let e=new Set;for(let t of We){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[We]);return{open:s,activePath:u,visiblePath:r?u:void 0,location:S,active:ze,tabItems:Be,openPaths:Ve,notice:f,setNotice:p,saves:m,external:g,restoringWorkbench:!!(a&&_e!==a),openFile:Me,setActivePath:d,closeFile:Ne,pinFile:Pe,discardPreview:Fe,updateBuffer:Ie,save:Le,reload:Re,listings:v,expanded:b,toggleDirectory:Se,loadDirectory:xe,refreshTree:we,invalidateTree:De,revealPath:Oe,locatePath:ke,collapseDirectories:Ae,movePath:je,listHeight:ee,setListHeight:j,query:k,setQuery:A,hits:M,searching:te,changed:We,changedPaths:Ke,changedDirs:qe,changedDropped:Ge,setChangedFor:He,index:re,indexComplete:ae,indexSkipped:se,requestIndex:me,cancelIndexRequest:pe,setIndex:fe,restoredActive:ye}}var mT=`super-pi.file-workbench.v1`;function hT(){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;t[n]={open:i,expanded:o,...typeof e.active==`string`?{active:e.active}:{},...a&&a===e.active?{preview:a}:{},...s?{listHeight:s}:{}}}return t}catch{return{}}}function gT(e){try{typeof window<`u`&&window.localStorage.setItem(mT,JSON.stringify(e))}catch{}}function _T(e,t){let n=hT(),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},gT(n))}function vT({height:e,onHeight:t,panelRef:n,min:r=120}){let[i,a]=(0,F.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,I.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 yT=()=>null,bT=`application/x-super-pi-workspace-file`;function xT({workspaceId:e,workspaceName:t,cwd:n=``,files:r,onOpenFile:i,onOpenChanged:a,onReference:o,onMoved:s}){let{open:c,openPaths:l,notice:u,setNotice:d,openFile:f,listings:p,expanded:m,toggleDirectory:h,loadDirectory:g,refreshTree:_,listHeight:v,setListHeight:y,query:b,setQuery:x,hits:S,searching:C,changed:w,changedPaths:T,changedDirs:E,changedDropped:D}=r,O=(0,F.useCallback)((e,t)=>{i?i(e,t):f(e)},[i,f]),k=n.split(`/`).at(-1)||t||`工作目录`,A=mS({workspaceId:e,cwd:n,scopeName:k,files:r,onOpen:O,onReference:o,onMoved:s}),[ee,j]=(0,F.useState)(),M=(0,F.useRef)(void 0),[N,te]=(0,F.useState)(!1),ne=A.editing?A.inline:yT,re=(0,F.useMemo)(()=>({currentPath:r.visiblePath,dropPath:ee,inline:ne}),[r.visiblePath,ee,ne]);(0,F.useEffect)(()=>{_();function e(){_()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[_]),(0,F.useEffect)(()=>{j(void 0),M.current=void 0,te(!1)},[e,n]);let ie=p[``],ae=b.trim(),oe=(0,F.useRef)(null),se=(0,F.useRef)(null),ce=(0,F.useRef)(void 0);function le(e){let t=se.current;t&&(ce.current&&ce.current!==e&&(ce.current.tabIndex=-1),ce.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let ue=(0,F.useRef)(void 0);(0,F.useEffect)(()=>{let{location:e}=r;if(!e||ue.current===e)return;let t=oe.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(ue.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,p,m,b]),(0,F.useEffect)(()=>{if(!ee||m.has(ee))return;let e=window.setTimeout(()=>h(ee),650);return()=>window.clearTimeout(e)},[ee,m,h]);let de=(0,F.useCallback)(e=>{let t=oe.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=uS(n);if(r&&!A.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),A.openMenu(r,Zx(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),A.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),A.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(),h(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(),h(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()}}},[h,A]),[fe,pe]=(0,F.useState)(200);(0,F.useEffect)(()=>{pe(200)},[ae,e]);let me=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(ae===``)return;let e=me.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&pe(e=>e>=(S?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[ae,S]);let he=(0,F.useMemo)(()=>{if(ae){if(C||!S)return(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(S.hits.length===0)return(0,I.jsxs)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:[`没有匹配「`,ae,`」的文件。`]});let e=S.hits.slice(0,fe),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,I.jsxs)(I.Fragment,{children:[t.map(e=>(0,I.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,I.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,I.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,I.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,I.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,I.jsxs)(`li`,{className:`file-explorer-row`,"data-file-entry":e.path,"data-file-current":r.visiblePath===e.path?`1`:void 0,children:[(0,I.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":l.has(e.path)?`1`:`0`,onClick:()=>O({path:e.path,name:e.name,text:!0}),children:[(0,I.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,I.jsx)(vp,{path:e.path}),(0,I.jsx)(`span`,{className:`file-name`,children:e.name}),l.has(e.path)&&(0,I.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),(0,I.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,I.jsx)(Xx,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<S.hits.length&&(0,I.jsx)(`div`,{ref:me,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?ie===void 0?(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in ie?(0,I.jsx)(fT,{error:ie.error}):(0,I.jsxs)(I.Fragment,{children:[ie.truncated&&(0,I.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),ie.entries.length===0?(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,I.jsx)(`ul`,{className:`file-list`,children:ie.entries.map(t=>t.kind===`directory`?(0,I.jsx)(sT,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:p,expanded:m,toggle:h,loadDirectory:g,openPaths:l,changedDirs:E,changedPaths:T,onOpen:O,depth:0,presentation:re},t.path):(0,I.jsx)(cT,{entry:t,depth:0,openPaths:l,changedPaths:T,onOpen:O,presentation:re},t.path))})]}):(0,I.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[ae,C,S,fe,e,ie,p,m,h,g,O,l,E,T,re,r.visiblePath]),ge=e=>{let t=uS(e);if(!t?.linked)return t?t.directory?t.path:sS(t.path):``},_e=(e,t)=>e!==sS(t.path)&&!(t.directory&&cS(e,t.path));return(0,F.useLayoutEffect)(()=>{let e=se.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=ce.current;le(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[he,A.editing]),(0,I.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":c.length,"data-files-changed-count":w.length,ref:oe,onKeyDown:de,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=uS(t??null);t&&n&&!A.busy&&A.openMenu(n,Zx(t))},onContextMenu:e=>{let t=uS(e.target),n=e.target instanceof Element?e.target.closest(`.file-row, [data-explorer-action]`):void 0;t&&n&&!A.busy&&(e.preventDefault(),A.openMenu(t,{x:e.clientX,y:e.clientY,origin:n}))},onDragStart:e=>{let t=uS(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||A.busy||ae||(M.current=t,e.dataTransfer.setData(bT,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{M.current=void 0,j(void 0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&j(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=M.current&&t.dataTransfer.types.includes(bT)?M.current:void 0;if(!e||A.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`,j(a?i:void 0)},onDrop:t=>{j(void 0);let n=t.dataTransfer.types.includes(bT)?M.current:void 0;if(M.current=void 0,!e||A.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ge(t.target);if(r===void 0){d(`请选择工作区里的普通文件夹。`);return}if(n){_e(r,n)&&A.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?A.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?A.upload(r,Array.from(t.dataTransfer.files)):d(`请选择要上传的文件。`)},children:[(0,I.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":ee===``?`1`:void 0,children:[(0,I.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:k,children:[(0,I.jsx)(vp,{category:`folder-open`}),(0,I.jsx)(`span`,{children:k})]}),A.toolbar]}),(0,I.jsxs)(`div`,{className:`files-search`,children:[(0,I.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,I.jsx)(Xx,{name:`search`})}),(0,I.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:b,placeholder:`按文件名筛选`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),x(``))},onChange:e=>x(e.target.value)}),(0,I.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath,onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,I.jsx)(Xx,{name:`locate`})})]}),A.controls,ae&&S&&!C&&(0,I.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,I.jsx)(`b`,{children:S.total.toLocaleString(`zh-CN`)}),` 个结果`,S.indexed===!1&&(0,I.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`})]}),u&&(0,I.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:u}),A.busy&&(0,I.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,I.jsx)(`div`,{className:`files-tree`,ref:se,"data-file-tree":ae?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&le(e.target)},style:v===null?void 0:{height:`${v}px`,flex:`0 0 auto`},children:(0,I.jsxs)(`div`,{className:`files-tree-body`,children:[A.inline(``,`child`,0),he]})}),(0,I.jsx)(vT,{height:v,onHeight:y,panelRef:oe}),(0,I.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":N,onClick:()=>te(e=>!e),children:[(0,I.jsx)(Xx,{name:N?`down`:`right`}),(0,I.jsx)(Xx,{name:`changes`}),(0,I.jsx)(`span`,{children:`改动`}),(0,I.jsx)(`span`,{className:`files-change-count`,children:w.length})]}),N&&(0,I.jsxs)(`div`,{className:`files-change-list`,children:[D>0&&(0,I.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,D,` 个改动没有记录(超过保留上限)。`]}),!w.length&&(0,I.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,I.jsx)(`ul`,{className:`file-list`,children:w.map(e=>(0,I.jsx)(`li`,{children:(0,I.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,I.jsx)(vp,{path:e.path}),(0,I.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,I.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,I.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function ST({workspaceId:e,cwd:t=``,onOpen:n,onClose:r}){let[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0),m=(0,F.useRef)(null),h=(0,F.useRef)(null);(0,F.useEffect)(()=>{m.current?.focus()},[]),(0,F.useEffect)(()=>{h.current?.scrollIntoView({block:`nearest`})},[f]),(0,F.useEffect)(()=>{let n=i.trim();if(s(null),l(``),p(0),!e||!n){d(!1);return}let r=!0;d(!0);let a=setTimeout(()=>{Qw(`/api/files/search?workspaceId=${eT(e)}&q=${eT(n)}${tT(t)}`).then(e=>{r&&(s(e),d(!1))}).catch(e=>{r&&(l(dp(e,`搜索没有完成`)),d(!1))})},220);return()=>{r=!1,clearTimeout(a)}},[i,e,t]);let g=e=>{e&&(n(e),r())},_=o?.truncated||o?.complete===!1,v={index:`索引未完整`,size:`文件超过 512KB`,depth:`目录超过 12 层`,time:`搜索超过 10 秒`,results:`达到 500 条上限`,output:`SDK 输出达到上限`,line:`长行已截断`,unreadable:`部分文件无法读取`};return(0,I.jsx)(`div`,{className:`quick-open-backdrop`,"data-content-search":`1`,role:`presentation`,onMouseDown:r,children:(0,I.jsxs)(`div`,{className:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":`内容搜索`,onMouseDown:e=>e.stopPropagation(),children:[(0,I.jsx)(`input`,{ref:m,className:`quick-open-input`,"data-content-search-input":`1`,value:i,maxLength:256,placeholder:`内容搜索(区分大小写,按字面匹配)`,"aria-label":`内容搜索`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),r()):e.key===`ArrowDown`?(e.preventDefault(),p(e=>Math.min(e+1,Math.max(0,(o?.hits.length??0)-1)))):e.key===`ArrowUp`?(e.preventDefault(),p(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),g(o?.hits[f]))}}),(0,I.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":c?`error`:u?`searching`:_?`partial`:`complete`,children:[c?`✕ 搜索失败:`+c:u?`… 搜索中`:e?_?`⚠ 结果不完整`:o?`✓ 搜索完成`:`○ 输入要搜索的内容`:`○ 请先选择工作区`,o?` · ${o.hits.length} 条命中`:``,` · Esc 关闭`]}),_&&(0,I.jsxs)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:[`⚠ 结果不完整:`,o?.reasons.map(e=>v[e]??e).join(`;`)]}),o&&o.skipped.length>0&&(0,I.jsxs)(`details`,{className:`quick-open-status`,"data-content-search-skipped":`1`,children:[(0,I.jsxs)(`summary`,{children:[`↷ 已跳过 `,o.skipped.length,` 个文件或目录`]}),(0,I.jsx)(`p`,{className:`content-search-skipped-paths`,children:o.skipped.join(`
313
313
  `)})]}),o&&!u&&o.hits.length===0&&(0,I.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`○ 没有匹配的行`}),(0,I.jsx)(`ul`,{className:`quick-open-results content-search-results`,role:`listbox`,children:o?.hits.map((e,t)=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{ref:t===f?h:void 0,type:`button`,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${f===t?` quick-open-result-active`:``}`,"aria-selected":f===t,onMouseEnter:()=>p(t),onClick:()=>g(e),children:[(0,I.jsxs)(`span`,{children:[e.path,`:`,e.line]}),(0,I.jsx)(`small`,{title:e.text,children:e.text})]})},`${e.path}:${e.line}`))})]})})}function CT({entries:e,complete:t,skipped:n,onOpen:r,onClose:i}){let[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(0),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>e.filter(e=>e.kind===`file`&&(e.text!==!1||oS(e.path))),[e]),d=(0,F.useMemo)(()=>a.trim()?new iw(u,{keys:[`path`],threshold:.38,ignoreLocation:!0}).search(a).slice(0,20).map(e=>e.item):u.slice(0,20),[u,a]);(0,F.useEffect)(()=>{l.current?.focus(),c(0)},[a]);let f=(0,F.useCallback)(e=>{e&&(r({path:e.path,name:e.path.split(`/`).pop()??e.path,text:e.text}),i())},[r,i]);return(0,I.jsx)(`div`,{className:`quick-open-backdrop`,"data-quick-open":`1`,role:`presentation`,onMouseDown:i,children:(0,I.jsxs)(`div`,{className:`quick-open`,role:`dialog`,"aria-modal":`true`,"aria-label":`快速打开`,onMouseDown:e=>e.stopPropagation(),children:[(0,I.jsx)(`input`,{ref:l,className:`quick-open-input`,"data-quick-open-input":`1`,value:a,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),i()):e.key===`ArrowDown`?(e.preventDefault(),c(e=>Math.min(e+1,Math.max(0,d.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),c(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),f(d[s]))}}),(0,I.jsxs)(`p`,{className:`quick-open-status`,"data-quick-open-status":t?`complete`:`partial`,children:[t?`✓ 索引完整`:`⚠ 索引不完整`,` · `,u.length,` 个文件 · Esc 关闭`]}),n.length>0&&(0,I.jsxs)(`p`,{className:`quick-open-status`,"data-quick-open-skipped":`1`,title:n.join(`, `),children:[`↷ 已跳过:`,n.join(`, `)]}),(0,I.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:d.map((e,t)=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"data-quick-open-result":e.path,className:t===s?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===s,onMouseEnter:()=>c(t),onClick:()=>f(e),children:[(0,I.jsx)(`span`,{children:e.path.split(`/`).pop()}),(0,I.jsx)(`small`,{children:e.path})]})},e.path))})]})})}function wT(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 TT(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 ET(e,t,n=88,r=200){let[i,a]=(0,F.useState)(()=>wT(e,0,n,r)),[o,s]=(0,F.useState)(null),c=(0,F.useCallback)(()=>{let i=wT(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,F.useRef)(t);(0,F.useLayoutEffect)(()=>{t<=0||l.current!==t&&(l.current=t,c())},[t,c]);let u=(0,F.useRef)(null);return(0,F.useLayoutEffect)(()=>{let t=u.current;u.current=e,t!==null&&e>t&&c()},[e,c]),{layout:i,frozen:o!==null&&o.count!==e,recompute:c}}function DT({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:u}){let d=(0,F.useRef)(null),[f,p]=(0,F.useState)(0),{layout:m,frozen:h,recompute:g}=ET(e.length,f,o,s);(0,F.useLayoutEffect)(()=>{let e=d.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.clientWidth;t>0&&p(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let _=TT(e,m.perRow),v=(e,t)=>t===void 0?{}:{[`data-${c}-${e}`]:t},y=e.filter(e=>e.kind===`file`).length,b=e.filter(e=>e.kind===`session`||!e.kind).length,x=t=>({[`data-${t}-strip`]:`1`,...h?{[`data-${t}-frozen`]:`1`}:{},[`data-${t}-count`]:t===`file-tab`?y:t===`session-tab`?b:e.length,[`data-${t}-min`]:o,[`data-${t}-max`]:s,[`data-${t}-per-row`]:m.perRow,[`data-${t}-width`]:Math.round(m.width*100)/100}),S=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&g()},C=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&g()};(0,F.useEffect)(()=>{if(!h)return;let e=d.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||g()};return document.addEventListener(`mousemove`,t,!0),()=>document.removeEventListener(`mousemove`,t,!0)},[h,g]);let w=[`${c}-strip`,`workspace-tab-strip`,`session-tab-strip`,`file-tab-strip`,u].filter(Boolean).join(` `);return(0,I.jsx)(`div`,{ref:d,className:w,role:`tablist`,"aria-label":a??`工作区标签页`,...v(`strip`,`1`),...x(`workspace-tab`),...x(`session-tab`),...x(`file-tab`),style:{"--tab-w":`${m.width}px`},onMouseEnter:S,onMouseLeave:C,children:_.map((a,o)=>(0,I.jsx)(`div`,{className:`${c}-row workspace-tab-row session-tab-row file-tab-row`,role:`presentation`,...v(`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,I.jsxs)(`div`,{role:`tab`,id:`${l}-${a.id}`,"aria-selected":o,"aria-controls":`${l}-panel-${a.id}`,tabIndex:o?0:-1,className:p,...v(`id`,d),...v(`index`,f),...o?v(`active`,`1`):{},...v(`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:m.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,I.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,I.jsx)(`span`,{className:`${c}-label workspace-tab-label ${u?`${u}-tab-label`:``}`,...v(`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,I.jsx)(`button`,{type:`button`,className:`${c}-close workspace-tab-close ${u?`${u}-tab-close`:``}`,...v(`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 OT={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},kT={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},AT={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},jT={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function MT(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 NT(e){let t=e.status===`running`,[n,r]=(0,F.useState)(0);(0,F.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 PT({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,I.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,I.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:AT[e.status]}),(0,I.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,I.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,I.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,I.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,I.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:OT[e.status]}),e.status===`failed`&&r?.error&&(0,I.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:fp(r.error),children:dp(r.error,`这一步没有完成。`)})]})}function FT({nodes:e,steps:t,names:n}){return(0,I.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,I.jsx)(PT,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,I.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,I.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,I.jsx)(`strong`,{children:`循环`}),(0,I.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,I.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,I.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,I.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,I.jsx)(FT,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,I.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,I.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,I.jsx)(`strong`,{children:`逐项执行`}),(0,I.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,I.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,I.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,I.jsx)(FT,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function IT({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=NT(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,I.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,I.jsxs)(`div`,{className:`workflow-head`,children:[(0,I.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,I.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,I.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,I.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:kT[e.status]??`未知状态`}),(0,I.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:jT[e.onFailure]??e.onFailure}),a!==void 0&&(0,I.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,MT(a)]}),i&&(0,I.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,I.jsx)(FT,{nodes:e.nodes,steps:e.steps,names:t}):(0,I.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,I.jsx)(PT,{step:e,names:t},e.index))})]})}var LT=[{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 RT({onClose:e}){let[t,n]=(0,F.useState)(`agents`);(0,F.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!t.defaultPrevented&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let r=LT.find(e=>e.id===t)??LT[0];return(0,I.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,I.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,I.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,I.jsxs)(`div`,{className:`help-head-title`,children:[(0,I.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,I.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,I.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,I.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,I.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),LT.map(e=>(0,I.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,I.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,I.jsx)(`span`,{children:e.label})]},e.id))]}),(0,I.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,I.jsxs)(`div`,{className:`help-panel-header`,children:[(0,I.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,I.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,I.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,I.jsx)(VT,{}),r.id===`workspace`&&(0,I.jsx)(HT,{}),r.id===`subagents`&&(0,I.jsx)(WT,{}),r.id===`model-policy`&&(0,I.jsx)(UT,{}),r.id===`memory`&&(0,I.jsx)(zT,{}),r.id===`knowledge`&&(0,I.jsx)(BT,{}),r.id===`feishu`&&(0,I.jsx)(GT,{}),r.id===`tools`&&(0,I.jsx)(KT,{}),r.id===`cli`&&(0,I.jsx)(qT,{}),r.id===`themes`&&(0,I.jsx)(JT,{})]}),(0,I.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,I.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function zT(){return(0,I.jsxs)(`div`,{className:`help-section-group`,children:[(0,I.jsxs)(`div`,{className:`help-card highlight`,children:[(0,I.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,I.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,I.jsx)(`code`,{children:`memory`}),` 和 `,(0,I.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,I.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,I.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`权限与审批`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,I.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,I.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function BT(){return(0,I.jsxs)(`div`,{className:`help-section-group`,children:[(0,I.jsxs)(`div`,{className:`help-card highlight`,children:[(0,I.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,I.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`怎么用`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,I.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,I.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,I.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,I.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,I.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`语义检索是内置的`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,I.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,I.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,I.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`它不知道的事`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,I.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,I.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,I.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,I.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function VT(){return(0,I.jsxs)(`div`,{className:`help-section-group`,children:[(0,I.jsxs)(`div`,{className:`help-card highlight`,children:[(0,I.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,I.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,I.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,I.jsxs)(`ul`,{className:`help-list`,children:[(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,I.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,I.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,I.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,I.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,I.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,I.jsxs)(`div`,{className:`help-card`,children:[(0,I.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,I.jsxs)(`div`,{className:`help-steps`,children:[(0,I.jsxs)(`div`,{className:`help-step`,children:[(0,I.jsx)(`span`,{className:`step-num`,children:`1`}),(0,I.jsxs)(`div`,{className:`step-body`,children:[(0,I.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,I.jsxs)(`p`,{children:[`在 `,(0,I.jsx)(`code`,{children:`agents/`}),` 或 `,(0,I.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,I.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,I.jsxs)(`div`,{className:`help-step`,children:[(0,I.jsx)(`span`,{className:`step-num`,children:`2`}),(0,I.jsxs)(`div`,{className:`step-body`,children:[(0,I.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,I.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,I.jsx)(`pre`,{className:`help-code-block`,children:(0,I.jsx)(`code`,{children:`---
@@ -357,7 +357,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
357
357
 
358
358
  工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
359
359
 
360
- 如需本地计算,声明 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、访问地址、文件清单和验证结果。`);d(e),window.setTimeout(()=>d(!1),1800)};(0,F.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let oe=(0,F.useMemo)(()=>[...t.map(e=>({id:e.id,name:e.name,glyph:e.glyph})),...n.map(e=>({id:e.id,name:e.name,glyph:bI(e)}))],[t,n]);(0,F.useEffect)(()=>{if(!j)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),M(void 0);return}if(LI(e.key)||KI(e.target))return;e.preventDefault(),e.stopPropagation();let t=j;if(M(void 0),e.key===`Delete`||e.key===`Backspace`){fL.clearShortcut(t),te(void 0);return}let n=RI(e);if(!n){te(`没有认出这个按键,换一个试试。`);return}let i=WI(n);if(!i.ok){te(i.reason);return}let a=XI(r,n,t);if(a){let e=oe.find(e=>e.id===a)?.name;te(e?`这个组合键已经被「${e}」占用了,换一个键。`:`这个组合键已经被另一个工具占用了,换一个键。`)}else fL.setShortcut(t,n),te(void 0)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[j,r,oe]);let se=e=>{ie(aL(e,window.innerWidth,window.innerHeight))},ce=e=>{iL(e)},le=()=>{ie(void 0),iL(void 0)},ue=(0,F.useRef)(!1),de=n.map(e=>e.slug).filter(e=>typeof e==`string`),fe=e=>{p(void 0),h(void 0),k(void 0),D({tool:e,name:SL({slug:e.slug??`tool`})})},pe=async(e,t)=>{p(void 0),h(void 0),k(void 0);let n=CL(t);if(!n.ok)k(n.reason);else try{let t=await fetch(`/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),h(r.skipped?.length?`已导出「${e.name}」,但有 ${r.skipped.length} 个文件没有包含:${r.skipped.join(`、`)}。`:`已导出「${e.name}」。`)}catch(e){p(`导出失败:${dp(e)}`)}finally{D(void 0)}},me=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;p(void 0),h(void 0),x(void 0);let n=yL(await t.text(),t.name);n.ok?(_({filename:t.name,bundle:n.bundle,unnamedFormat:n.unnamedFormat}),y(de.includes(n.bundle.slug)?xL(n.bundle.slug,de):n.bundle.slug),C(n.bundle.files[0]?.path)):p(n.reason)},he=()=>{_(void 0),y(``),x(void 0),C(void 0)},ge=async()=>{if(!g)return;x(void 0);let e=bL(v);if(!e.ok)x(e.reason);else if(de.includes(e.slug))x(`本机已经有 slug「${e.slug}」的工具,换一个名字再导入。`);else{T(!0);try{let t=await fetch(`/api/tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(OL(g.bundle,e.slug))}),n=await t.json();if(!t.ok||!n.id)throw Error(n.error??`HTTP ${t.status}`);await pL(),h(`已导入「${g.bundle.name}」,它现在出现在工具栏里,所有工作区都能用。`),he()}catch(e){p(`导入失败:${dp(e)}`)}finally{T(!1)}}};(0,F.useEffect)(()=>{E&&ee.current?.scrollIntoView({block:`center`})},[E]);let _e=()=>{let e=lE(i);e.ok?t.length>=32?l(`工具最多 32 个,先删掉一个再加。`):(fL.setTools([...t,{id:pE(`link`,t.map(e=>e.id)),kind:`link`,name:o.trim()||xz(e.url),glyph:`↗`,url:e.url}]),a(``),s(``),l(void 0)):l(e.reason)},ve=re?{width:`${re.width}px`,height:`${re.height}px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 32px)`}:void 0;return(0,pa.createPortal)((0,I.jsxs)(`div`,{className:`tool-overlay`,"data-tool-settings-overlay":`1`,onPointerDown:()=>{ue.current=!1},onClick:t=>{ue.current?ue.current=!1:t.target===t.currentTarget&&e()},children:[(0,I.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-settings-title`,"data-tool-settings":`1`,ref:ne,style:ve,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsx)(`h2`,{className:`tool-dialog-title`,id:`tool-settings-title`,children:`⚙ 工具设置`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-settings-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭工具设置`,onClick:e,children:`✕`})]}),(0,I.jsx)(`div`,{className:`tool-dialog-body`,children:g?(0,I.jsx)(bz,{pending:g,slugDraft:v,slugError:b,preview:S,busy:w,onSlugChange:e=>{y(e),x(void 0)},onPreviewChange:C,onCancel:he,onConfirm:()=>void ge()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`tool-prompt-card`,children:[(0,I.jsx)(`strong`,{children:`给 Agent 开发新工具`}),(0,I.jsx)(`p`,{className:`tool-hint`,children:`工具会挂载到 Super Pi 的统一 HTTP 服务,不需要再启动独立服务器。`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-development-prompt":`1`,onClick:()=>void ae(),children:u?`已复制`:`复制工具开发 Prompt`})]}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`从预置列表添加`})}),(0,I.jsx)(`div`,{className:`tool-presets`,"data-tool-presets":rE.length,children:rE.map(e=>{let n=t.some(t=>t.kind===e.kind);return(0,I.jsxs)(`div`,{className:`tool-preset`,"data-tool-preset":e.kind,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.blurb})]}),(0,I.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:()=>fL.setTools(mE(t,e.kind)),children:n?`已添加`:`添加`})]},e.kind)})}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`添加网址工具`})}),(0,I.jsx)(`p`,{className:`tool-hint`,children:`填一个网址,它会变成一个图标;点开后在弹窗里用按钮在新标签页打开。网址只接受 http / https / mailto。`}),(0,I.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,I.jsx)(`input`,{className:`tool-input`,"data-tool-url-name":`1`,value:o,maxLength:40,placeholder:`名称(可留空,默认用域名)`,"aria-label":`工具名称(可选)`,onChange:e=>s(e.target.value)}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-url-add":`1`,disabled:!i.trim(),onClick:_e,children:`添加网址工具`}),c&&(0,I.jsx)(`p`,{className:`tool-error`,"data-tool-error":`1`,role:`alert`,children:c}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-scope-note":`1`,children:[`能自定义到哪:从上面挑预置工具,或自己填一个网址。`,(0,I.jsx)(`b`,{children:`没有开放「写一段脚本来执行」这一档`}),`——它在浏览器里等同于任意代码执行,会拿着本应用的权限跑。计算器是手写的算术解析器,不含 eval,也认不出变量名。`]}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`快捷键`})}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-shortcut-hint":`1`,children:[`给每个工具绑一个组合键,按下就直接打开它,不用先找到右侧栏。`,(0,I.jsx)(`b`,{children:`弹窗打开时快捷键不生效`}),`——模态弹窗期间键盘归它自己,关掉之后再按。`]}),(0,I.jsx)(`div`,{className:`tool-shortcuts`,"data-tool-shortcut-count":oe.length,children:oe.map(e=>(0,I.jsxs)(`div`,{className:`tool-shortcut-row`,"data-tool-shortcut-row":e.id,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:r[e.id]?`按 ${BI(r[e.id])} 打开`:`还没有快捷键`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-shortcut-set`,"data-tool-shortcut-set":e.id,"data-tool-shortcut-capturing":j===e.id?`1`:void 0,"aria-pressed":j===e.id,title:j===e.id?`按下想用的组合键(Esc 取消,Delete 清除)`:`点一下,然后按下想用的组合键`,onClick:()=>{te(void 0),M(j===e.id?void 0:e.id)},children:j===e.id?`按下组合键…`:r[e.id]?BI(r[e.id]):`未设置`}),r[e.id]&&(0,I.jsx)(`button`,{type:`button`,className:`tool-shortcut-clear`,"data-tool-shortcut-clear":e.id,title:`清除${e.name}的快捷键`,"aria-label":`清除${e.name}的快捷键`,onClick:()=>{fL.clearShortcut(e.id),te(void 0),M(void 0)},children:`清除`})]},e.id))}),N&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-shortcut-error":`1`,children:N}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsxs)(`h2`,{className:`rail-section-title`,children:[`已安装的全局工具(`,n.length,`)`]})}),n.length===0?(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-mounted-empty":`1`,children:`还没有通过 tool_register 注册的工具。上面复制那段 Prompt,让 Agent 写一个。`}):(0,I.jsx)(`div`,{className:`tool-presets`,"data-tool-mounted-list":n.length,children:n.map(e=>{let t=EL(e.environmentState);return(0,I.jsxs)(`div`,{className:`tool-share-row`,"data-tool-share-row":e.id,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:bI(e)}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.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,I.jsx)(`small`,{"data-tool-model":`1`,children:`⚠ 会调用模型`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export":e.id,title:`导出${e.name},得到一个可以发给别人导入的文件`,"aria-label":`导出${e.name}`,onClick:()=>fe(e),children:`导出`})]},e.id)})}),E&&(0,I.jsxs)(`div`,{className:`tool-share-review`,ref:ee,"data-tool-export-name":`1`,children:[(0,I.jsxs)(`h3`,{className:`tool-share-title`,children:[`导出「`,E.tool.name,`」`]}),(0,I.jsxs)(`label`,{className:`tool-hint`,children:[`文件名(发给别人的就是这个文件)`,(0,I.jsx)(`input`,{className:`tool-input`,value:E.name,"aria-label":`导出文件名`,"data-tool-export-input":`1`,onChange:e=>D({...E,name:e.target.value})})]}),O&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-export-name-error":`1`,children:O}),(0,I.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export-cancel":`1`,onClick:()=>{D(void 0),k(void 0)},children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-export-confirm":`1`,onClick:()=>void pe(E.tool,E.name),children:`导出`})]})]}),m&&(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-share-notice":`1`,children:m}),f&&(0,I.jsx)(`p`,{className:`tool-error`,"data-tool-share-error":`1`,role:`alert`,children:f}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`从文件导入`})}),(0,I.jsxs)(`p`,{className:`tool-hint`,children:[`收到别人分享的工具文件(`,(0,I.jsx)(`code`,{children:hL}),`)?导入后它出现在工具栏里,所有工作区都能用。`,(0,I.jsx)(`b`,{children:`导入前会先给你看这个包里有什么。`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-pick":`1`,onClick:()=>A.current?.click(),children:`选择文件…`}),(0,I.jsx)(`input`,{ref:A,type:`file`,accept:`.json,application/json`,style:{display:`none`},"data-tool-import-input":`1`,onChange:e=>void me(e)})]})})]}),(0,I.jsx)(vz,{targetRef:ne,onResize:se,onCommit:ce,onDragEnd:()=>{ue.current=!0},onReset:le})]}),document.body)}var _z=18;function vz({targetRef:e,onResize:t,onCommit:n,onDragEnd:r,onReset:i}){let[a,o]=(0,F.useState)(),s=(0,F.useRef)(void 0);return(0,F.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{let e=t.getBoundingClientRect();o({left:e.right-_z,top:e.bottom-_z})};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,I.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=aL({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??QI.width,l=o?.height??QI.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=aL({width:c,height:l},window.innerWidth,window.innerHeight);s.current=u,t(u),n(u)},onClick:e=>e.stopPropagation()})}function yz(){let{tools:e,mountedTools:t,openToolId:n,settingsOpen:r,shortcuts:i}=dL(),a=e.find(e=>e.id===n),o=t.find(e=>e.id===n);return(0,F.useEffect)(()=>{let n=n=>{if(!r&&!document.querySelector(`[aria-modal="true"]`)&&!(n.isComposing||n.defaultPrevented)){for(let[r,a]of Object.entries(i))if(qI(a,n)&&(e.some(e=>e.id===r)||t.some(e=>e.id===r))){n.preventDefault(),fL.openTool(r);return}}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[i,e,t,r]),(0,F.useEffect)(()=>{pL();let e=()=>{pL()};return window.addEventListener(`super-pi-tools-updated`,e),()=>window.removeEventListener(`super-pi-tools-updated`,e)},[]),(0,F.useEffect)(()=>{fL.persistTools()},[]),(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsx)(gz,{onClose:()=>fL.closeSettings()}),a&&(0,I.jsx)(Sz,{tool:a,onClose:()=>fL.closeTool()}),o&&(0,I.jsx)(Az,{tool:o,onClose:()=>fL.closeTool()})]})}function bz({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=TL(l),f=wL(l),p=l.files.find(e=>e.path===r)??l.files[0];return(0,I.jsxs)(`div`,{className:`tool-share-review`,"data-tool-import-review":`1`,children:[(0,I.jsx)(`h3`,{className:`tool-share-title`,"data-tool-import-name":`1`,children:l.name}),l.description&&(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-import-desc":`1`,children:l.description}),e.unnamedFormat&&(0,I.jsx)(`p`,{className:`tool-import-note`,"data-tool-import-unbranded":`1`,children:`这个文件没有 Super Pi 的工具标记,已按内容形状读取——粘出来的 tool_register 参数也认。`}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-import-files":`1`,children:[l.files.length,` 个文件 · 共 `,DL(u)]}),(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-import-paths":`1`,children:l.files.map(e=>e.path).join(` · `)}),l.script&&(0,I.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-script":l.script.path,children:[(0,I.jsxs)(`b`,{children:[`⚠ 含 Python 脚本 `,l.script.path]}),(0,I.jsx)(`br`,{}),`导入后运行这个工具时,这段代码会在本机上执行,权限和你自己的 Python 一样(能读你的文件、能联网)。 可以先展开下面的文件列表把它读完。`]}),(0,I.jsxs)(`p`,{className:d.tone===`warn`?`tool-import-warn`:`tool-import-note`,"data-tool-import-env":d.tone,children:[(0,I.jsxs)(`b`,{children:[d.tone===`warn`?`⚠ `:`✓ `,d.text]}),l.environment?.fingerprint?.python&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`br`,{}),`导出方环境:Python `,l.environment.fingerprint.python,` · `,l.environment.fingerprint.platform||`未知平台`,`。版本对不上时会标出来,但不会拦住你运行。`]})]}),f&&(0,I.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-model":`1`,children:[(0,I.jsx)(`b`,{children:`⚠ 这个工具可以调用模型`}),(0,I.jsx)(`br`,{}),f.text,`。模型由 Super Pi 通过 Pi 调用(凭据和模型选择都在 Super Pi 这边),工具只拿到文字。`]}),(0,I.jsxs)(`details`,{className:`tool-import-files`,"data-tool-import-filebox":l.files.length,children:[(0,I.jsxs)(`summary`,{children:[`查看文件(`,l.files.length,`)`]}),(0,I.jsx)(`div`,{className:`tool-share-tabs`,children:l.files.map(e=>(0,I.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,I.jsx)(`pre`,{className:`tool-import-code`,"data-tool-import-code":p?.path,children:p?.content??``})]}),(0,I.jsxs)(`label`,{className:`tool-hint`,"data-tool-import-slug":`1`,children:[`导入后的 slug(工具的短名字,也是它在磁盘上的目录名)`,(0,I.jsx)(`input`,{className:`tool-input`,value:t,"aria-label":`导入后的 slug`,onChange:e=>a(e.target.value)})]}),n&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-import-slug-error":`1`,children:n}),(0,I.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-import-cancel":`1`,onClick:s,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-confirm":`1`,disabled:i,onClick:c,children:i?`导入中…`:`导入`})]})]})}function xz(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 Sz({tool:e,onClose:t}){return(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay`,"data-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-dialog-title`,"data-tool-dialog":e.id,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsxs)(`h2`,{className:`tool-dialog-title`,id:`tool-dialog-title`,children:[(0,I.jsx)(vI,{className:`tool-dialog-glyph`,glyph:e.glyph}),e.name]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭${e.name}`,onClick:t,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`tool-dialog-body`,children:[e.kind===`calculator`&&(0,I.jsx)(wz,{}),e.kind===`timestamp`&&(0,I.jsx)(Tz,{}),e.kind===`link`&&(0,I.jsx)(Ez,{tool:e})]})]})}),document.body)}function Cz({image:e,onClose:t}){return(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`lightbox-overlay`,"data-lightbox-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`lightbox-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`lightbox-title`,"data-lightbox-dialog":`1`,children:[(0,I.jsxs)(`div`,{className:`lightbox-head`,children:[(0,I.jsx)(`h2`,{className:`lightbox-title`,id:`lightbox-title`,children:e.name||`图片大图`}),(0,I.jsx)(`button`,{type:`button`,className:`lightbox-close`,"data-lightbox-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭大图`,onClick:t,children:`✕`})]}),(0,I.jsx)(`div`,{className:`lightbox-body`,children:(0,I.jsx)(`img`,{src:e.url,alt:e.name||`图片大图`,className:`lightbox-image`})})]})}),document.body)}function wz(){let[e,t]=(0,F.useState)(`12 * (3 + 4)`),n=OE(e),r=e=>{t(t=>t+e)};return(0,I.jsxs)(`div`,{className:`tool-calc`,"data-tool-calc":`1`,children:[(0,I.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,I.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,I.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,I.jsx)(`p`,{className:`tool-calc-result`,"data-calc-result":`1`,"data-calc-value":String(n.value),children:kE(n.value)}):(0,I.jsx)(`p`,{className:`tool-calc-error`,"data-calc-error":`1`,role:`alert`,children:n.reason})]})}function Tz(){let[e,t]=(0,F.useState)(``),n=AE(e),r=n.ok?ME(n.ms):null;return(0,I.jsxs)(`div`,{className:`tool-stamp`,"data-tool-stamp":`1`,children:[(0,I.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,I.jsxs)(`dl`,{className:`tool-stamp-out`,"data-stamp-result":`1`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`本地时间`}),(0,I.jsx)(`dd`,{"data-stamp-local":`1`,children:r.local})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`ISO(UTC)`}),(0,I.jsx)(`dd`,{"data-stamp-iso":`1`,children:r.iso})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`秒`}),(0,I.jsx)(`dd`,{"data-stamp-seconds":`1`,children:r.seconds})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`毫秒`}),(0,I.jsx)(`dd`,{"data-stamp-ms":`1`,children:r.milliseconds})]})]}):(0,I.jsx)(`p`,{className:`tool-stamp-error`,"data-stamp-error":`1`,role:`alert`,children:n.ok?`这个日期无法显示。`:n.reason})]})}function Ez({tool:e}){let[t,n]=(0,F.useState)(!1),r=async()=>{let e=await xx(`请为 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,I.jsxs)(`div`,{className:`tool-link`,"data-tool-link":e.id,children:[(0,I.jsx)(`p`,{className:`tool-hint`,children:`这是旧版外部网页链接;新工具由 Super Pi 统一托管,并可选绑定受控 Python 脚本。`}),(0,I.jsx)(`code`,{className:`tool-link-url`,"data-tool-link-url":e.id,children:e.url}),(0,I.jsxs)(`div`,{className:`tool-link-actions`,children:[(0,I.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,I.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,I.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 Dz=`(max-width: 1100px)`,Oz=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function kz(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 Az({tool:e,onClose:t}){(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let n=(0,F.useMemo)(()=>kz(e.id),[e.id]);return(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay`,"data-mounted-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`tool-dialog`,"data-mounted-tool-dialog":e.id,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsxs)(`h2`,{className:`tool-dialog-title`,children:[(0,I.jsx)(vI,{className:`tool-dialog-glyph`,glyph:bI(e)}),e.name]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,onClick:t,children:`✕`})]}),(0,I.jsx)(`div`,{className:`tool-dialog-body`,children:(0,I.jsx)(`iframe`,{className:`tool-link-frame`,src:`/tools/${encodeURIComponent(e.id)}/#super-pi-owner=${n}`,title:e.name,sandbox:`allow-forms allow-modals allow-popups allow-scripts`,referrerPolicy:`no-referrer`})})]})}),document.body)}function jz(e,t,n){let r=Math.max(0,Math.round(n)-480),i=Oz(520,180,Math.max(180,r-240)),a=Oz(Math.round(e),180,i),o=Oz(640,240,Math.max(240,r-a));return{sidebar:a,rail:Oz(Math.round(t),240,o),sidebarMin:180,sidebarMax:i,railMin:240,railMax:o,sumCap:r}}var Mz=`super-pi.rail-widths.v1`,Nz=`super-pi.reader-state.v1`,Pz=`super-pi.folded-groups.v1`;function Fz(){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 Iz(e){try{typeof window<`u`&&window.localStorage.setItem(Pz,JSON.stringify(e))}catch{}}var Lz=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!==``):[]},Rz=6,zz=400,Bz=32,Vz=48,Hz=e=>{e.dataset.programmaticScroll=`true`,window.setTimeout(()=>{delete e.dataset.programmaticScroll},0)};function Uz(e,t,n=!1,r=!1){let i=e.scrollHeight-e.clientHeight-e.scrollTop,a=n?!1:r?!0:t.followTail?i<=Vz:i<=Bz,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 Wz(){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 Gz(e){try{typeof window<`u`&&window.localStorage.setItem(Nz,JSON.stringify(e))}catch{}}var Kz=`super-pi.session-tabs.v1`;function qz(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function Jz(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 Yz(){try{if(typeof window>`u`)return{ids:[]};let e=JSON.parse(window.sessionStorage.getItem(`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;return{ids:n,activeId:a,previewId:i===a?i:void 0,touched:r,emptied:n.length===0&&(t.emptied===!0||!!i)}}catch{return{ids:[]}}}function Xz(e,t){try{if(typeof window>`u`)return;let{ids:n,previewId:r,touched:i,emptied:a}=e;window.sessionStorage.setItem(Kz,JSON.stringify({ids:n,...t&&n.includes(t)?{activeId:t}:{},...r&&n.includes(r)?{previewId:r}:{},...i.size?{touched:[...i]}:{},...a?{emptied:a}:{}}))}catch{}}function Zz(){try{if(typeof window>`u`)return{};let e=window.localStorage.getItem(Mz);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 Qz(e){try{if(typeof window>`u`)return;window.localStorage.setItem(Mz,JSON.stringify(e))}catch{}}function $z({side:e,width:t,min:n,max:r,label:i,onWidth:a}){let[o,s]=(0,F.useState)(!1),c=e=>e.shiftKey?64:16;return(0,I.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(Oz(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(Oz(e===`left`?t-o:t+o,n,r))):i.key===`ArrowRight`?(i.preventDefault(),a(Oz(e===`left`?t+o:t-o,n,r))):i.key===`Home`?(i.preventDefault(),a(n)):i.key===`End`&&(i.preventDefault(),a(r))}})}var eB=`super-pi.composer-height.v1`,tB=148,nB=.55,rB=()=>Math.max(tB,Math.round((typeof window>`u`?800:window.innerHeight)*nB)),iB=e=>{let t=Number.isFinite(e)?e:tB;return Math.round(Math.min(rB(),Math.max(tB,t)))},aB=()=>{try{let e=window.localStorage.getItem(eB);return e===null?tB:iB(Number(e))}catch{return tB}};function oB({height:e,onHeight:t}){let[n,r]=(0,F.useState)(!1),i=e=>e.shiftKey?64:16,a=rB();return(0,I.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":tB,"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=iB(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(iB(e+r))):n.key===`ArrowDown`?(n.preventDefault(),t(iB(e-r))):n.key===`Home`?(n.preventDefault(),t(tB)):n.key===`End`?(n.preventDefault(),t(a)):n.key===`PageUp`?(n.preventDefault(),t(iB(e+96))):n.key===`PageDown`&&(n.preventDefault(),t(iB(e-96)))}})}function sB(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 e[0]}function cB(){let[e,t]=(0,F.useState)(zL),n=(0,F.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return _e(n,t)})},[]),[r,i]=(0,F.useState)(()=>sw().map(e=>{let t=new Date().toISOString();return{id:e.clientId,key:`send:${e.conversationId}:${e.clientId}`,retry:!0,command:{...e},apply:n=>uw(n,e,t),accepted:t=>!!t.conversations.find(t=>t.id===e.conversationId)?.messages.some(t=>t.id===e.clientId)}})),a=(0,F.useRef)(r),o=(0,F.useRef)(null);o.current||=Wz();let s=(0,F.useRef)(null);s.current||=Yz();let c=s.current,l=r.reduce((e,t)=>t.apply(e),e),[u,d]=(0,F.useState)(s.current.activeId??o.current.activeId),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(),[g,_]=(0,F.useState)(()=>Fz().workspaces??{}),[v,y]=(0,F.useState)(o.current.workspaceId),[b,x]=(0,F.useState)(()=>({ids:c.ids,previewId:c.previewId,touched:new Set(c.touched??[]),emptied:c.emptied})),S=b.ids,C=b.previewId,w=(0,F.useRef)(0),T=b.emptied===!0,[E,D]=(0,F.useState)(!1),[O,k]=(0,F.useState)(!1),[A,ee]=(0,F.useState)(),j=(0,F.useRef)(null),M=(0,F.useRef)(void 0),N=(0,F.useRef)(o.current.conversations),te=(0,F.useRef)(S);te.current=S;let ne=(0,F.useRef)(o.current.readAt??{}),[re,ie]=(0,F.useState)(0),ae=(0,F.useRef)(null),oe=(0,F.useRef)(null),se=(0,F.useRef)(void 0),ce=(0,F.useRef)(!1),le=(0,F.useRef)(!0),[ue,de]=(0,F.useState)({followTail:!0,scrollTop:0}),fe=(0,F.useRef)(!1),pe=(0,F.useRef)(new Map),me=(0,F.useRef)(void 0),he=(0,F.useRef)([]),ge=(0,F.useRef)(void 0),_e=(0,F.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:GL(t.thinkingBlocks,e.thinkingBlocks)}})}})}},[]),ve=(0,F.useCallback)(()=>{if(ge.current!==void 0&&(cancelAnimationFrame(ge.current),ge.current=void 0),!he.current.length)return;let e=he.current;he.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)}n(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=WL(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}})}))},[]),ye=(0,F.useCallback)(e=>{let t=he.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),ge.current===void 0&&(ge.current=requestAnimationFrame(ve))},[ve]),be=(0,F.useCallback)(e=>{me.current=e},[]),[xe,Se]=(0,F.useState)(()=>Fz().archived??{});(0,F.useEffect)(()=>{Iz({workspaces:g,archived:xe})},[g,xe]);let[Ce,we]=(0,F.useState)(()=>DI());(0,F.useEffect)(()=>{OI(Ce)},[Ce]);let[Te,Ee]=(0,F.useState)(),De=(0,F.useRef)(0),Oe=(0,F.useRef)(``),ke=(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=()=>Ee(e=>e&&e.dropRootId===u&&e.dropAfter===d?e:{workspaceId:t,conversationId:n,dropRootId:u,dropAfter:d}),m=()=>{s||(s=!0,l=Lz(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)<Rz)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);we(e=>({...e,[t]:TI(r,n,i)})),De.current=Date.now(),Oe.current=n}Ee(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,zz))},[Ae,je]=(0,F.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage.getItem(`super-pi.user-nickname`)??``}catch{return``}}),Me=e=>{let t=e.slice(0,24);je(t);try{window.localStorage.setItem(`super-pi.user-nickname`,t)}catch{}},Ne=Ae.trim()||`你`,[Pe,Fe]=(0,F.useState)(),[Ie,Le]=(0,F.useState)([]),[Re,ze]=(0,F.useState)([]),[Be,Ve]=(0,F.useState)(),[He,Ue]=(0,F.useState)(),[We,Ge]=(0,F.useState)([]),[Ke,qe]=(0,F.useState)([]),[Je,Ye]=(0,F.useState)(),[Xe,Ze]=(0,F.useState)(),[Qe,$e]=(0,F.useState)(),[et,tt]=(0,F.useState)(`idle`),nt=(0,F.useMemo)(()=>Ie.filter(e=>e.request.blocking),[Ie]),[rt,it]=(0,F.useState)(!1),[at,ot]=(0,F.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1100px)`).matches),[st,ct]=(0,F.useState)(`chat`),[lt,ut]=(0,F.useState)(!1),dt=(0,F.useCallback)(()=>{ct(`chat`),window.matchMedia(`(max-width: 700px)`).matches&&ot(!0)},[]),[ft,pt]=(0,F.useState)(!1),[mt,ht]=(0,F.useState)(()=>typeof window>`u`?1440:window.innerWidth);(0,F.useEffect)(()=>{let e=()=>ht(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let[gt,_t]=(0,F.useState)(Jp);(0,F.useEffect)(()=>Yp(gt),[gt]);let[vt,yt]=(0,F.useState)(Zz),bt=jz(vt.sidebar??270,vt.rail??320,mt>1100?mt-80:mt);(0,F.useEffect)(()=>{Qz({sidebar:vt.sidebar??270,rail:vt.rail??320})},[vt.sidebar,vt.rail]);let xt=e=>yt(t=>({...t,sidebar:e})),St=e=>yt(t=>({...t,rail:e})),[Ct,wt]=(0,F.useState)(null);(0,F.useEffect)(()=>{wt(aB())},[]),(0,F.useEffect)(()=>{Ct!==null&&document.documentElement.style.setProperty(`--composer-height`,`${Ct}px`)},[Ct]);let Tt=e=>{let t=iB(e);wt(t);try{window.localStorage.setItem(eB,String(t))}catch{}};(0,F.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(Dz),t=e=>{e.matches&&ot(!0)};return e.addEventListener(`change`,t),e.matches&&ot(!0),()=>e.removeEventListener(`change`,t)},[]);let Et=mt<=1100;(0,F.useEffect)(()=>{if(!Et||at)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(),ot(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Et,at]);let[Dt,Ot]=(0,F.useState)({}),[kt,At]=(0,F.useState)({}),[jt,Mt]=(0,F.useState)({}),[Nt,Pt]=(0,F.useState)(),[Ft,It]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{It(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>{let t=l.conversations.find(t=>t.id===e);return t?XR(t):!1}));return t.size===e.size?e:t})},[l.conversations]);let[Lt,Rt]=(0,F.useState)(),[zt,Bt]=(0,F.useState)(),Vt=(0,F.useRef)(new Map),[Ht,Ut]=(0,F.useState)(()=>dw(`super-pi.composer-drafts.v1`,{})),Wt=(0,F.useRef)(Ht),Gt=(0,F.useRef)(!1);Wt.current=Ht,(0,F.useEffect)(()=>{let e=()=>{let e=Object.entries(Wt.current).filter(([e,t])=>!e.startsWith(`pending:`)&&(t.text||t.images.length||t.attachments.length)).map(([e,t])=>[e,{...t,uploading:0}]),t=fw(`super-pi.composer-drafts.v1`,Object.fromEntries(e));!t&&e.length&&!Gt.current&&Ai(`浏览器无法保存聊天草稿,刷新前请先保留这段内容。`,`warning`),Gt.current=!t&&e.length>0},t=window.setTimeout(e,250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[Ht]);let Kt=(0,F.useRef)(new Set),[qt,Jt]=(0,F.useState)([]),[Yt,Xt]=(0,F.useState)([]),[Zt,Qt]=(0,F.useState)(),[$t,en]=(0,F.useState)(!1),tn=(0,F.useRef)(null),nn=(0,F.useRef)(!1),rn=(0,F.useRef)(0),an=(0,F.useRef)([]),on=(0,F.useRef)(void 0),sn=(0,F.useRef)(!1),cn=(0,F.useRef)(new Set),ln=(0,F.useRef)(new Set),un=(0,F.useRef)(new Map),dn=(0,F.useRef)(new Map),[fn,pn]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{let e=window.setInterval(()=>pn(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let mn=(0,F.useMemo)(()=>l.conversations.filter(e=>!e.archivedAt),[l.conversations]),hn=(0,F.useMemo)(()=>e.conversations.filter(e=>!e.archivedAt),[e.conversations]),gn=(0,F.useMemo)(()=>new Set(l.collapsedConversationIds??[]),[l.collapsedConversationIds]),P=(0,F.useMemo)(()=>{let e=mn.find(e=>e.id===u);if(e)return e;if(!T)return sB(mn,l.workspaces,v)},[T,u,mn,v,l.workspaces]),_n=(0,F.useMemo)(()=>P?{workspaceId:P.workspaceId,conversationId:P.id,onImageOpen:Qt}:void 0,[P?.workspaceId,P?.id]),[vn,yn]=(0,F.useState)(`queue`),bn=!!(P&&XR(P));(0,F.useEffect)(()=>{yn(`queue`)},[P?.id,bn]);let[xn,Sn]=(0,F.useState)([]),Cn=(0,F.useMemo)(()=>ML(P?.parentConversationId,P?.parentConversationId?l.conversations.find(e=>e.id===P.parentConversationId):void 0),[P,l.conversations]),wn=!!(P&&l.unlockedChildConversationIds?.includes(P.id)),Tn=Cn&&!wn,En=(0,F.useMemo)(()=>(l.conversations||[]).filter(e=>e.parentConversationId===P?.id),[l.conversations,P?.id]),Dn=(0,F.useMemo)(()=>(l.conversations||[]).find(e=>e.id===P?.parentConversationId),[l.conversations,P?.parentConversationId]),On=(0,F.useMemo)(()=>P?PL({conversation:P,parent:Dn,directChildren:En,isTopLevelUnread:!1}):null,[P,Dn,En]),kn=ae.current;if(kn){let e=kn.dataset.messageScrollContainer;e&&P?.id&&e!==P?.id&&kn.querySelector(`[data-transcript-key]`)&&(N.current[e]=Uz(kn,N.current[e]??{followTail:!0,scrollTop:0}))}le.current=P?.messagesLoaded!==!1,(0,F.useEffect)(()=>{if(!E||T||u&&hn.some(e=>e.id===u)||u&&a.current.some(e=>e.temporaryId===u))return;let e=sB(mn,l.workspaces,v);d(e?.id),e&&x(t=>t.emptied||t.ids.length===0||t.ids.includes(e.id)?t:{...t,ids:[...t.ids,e.id]})},[T,u,hn,mn,E,v,l.workspaces]),(0,F.useEffect)(()=>{h(void 0)},[u,v]);let An=(0,F.useMemo)(()=>l.workspaces.find(e=>e.id===v)??l.workspaces[0],[l.workspaces,v]),[jn,Mn]=(0,F.useState)(``);(0,F.useEffect)(()=>{Mn(``)},[An?.id]);let Nn=(0,F.useRef)(v);Nn.current=v,(0,F.useEffect)(()=>{P&&y(P.workspaceId)},[P?.id]),(0,F.useEffect)(()=>{on.current=u},[u]),(0,F.useEffect)(()=>{se.current=P?.id},[P?.id]),(0,F.useEffect)(()=>{let e=P?.id;if(!e)return;let t=l.conversations.find(t=>t.id===e);if(!t)return;let n=ne.current[e];ne.current[e]=t.updatedAt,n!==t.updatedAt&&ie(e=>e+1),Gz({activeId:on.current,workspaceId:P?.workspaceId??v,conversations:N.current,readAt:ne.current})},[P?.id,l.conversations]),(0,F.useEffect)(()=>{f&&u&&Gz({activeId:u,workspaceId:P?.workspaceId??v,conversations:N.current,readAt:ne.current})},[u,P?.workspaceId,f,v]),(0,F.useEffect)(()=>{let e=ae.current;if(!e||!P?.id||P.messagesLoaded===!1)return;let t=P.id;fe.current=!1;let n=N.current[t]??{followTail:!0,scrollTop:0};N.current[t]=n,de(n);let r=requestAnimationFrame(()=>{if(ae.current!==e)ce.current=!1;else{if(n.followTail)Hz(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}ce.current=!1}});return()=>cancelAnimationFrame(r)},[P?.id,P?.messagesLoaded]),(0,F.useLayoutEffect)(()=>{ce.current=!0},[P?.id,P?.messagesLoaded]);let Pn=(0,F.useCallback)((e,t=!1,n=!1)=>{let r=se.current;if(!r||ce.current||!le.current)return;let i=Uz(e,N.current[r]??{followTail:!0,scrollTop:0},t,n);fe.current=!i.followTail,N.current[r]=i,de(i),Gz({activeId:r,workspaceId:Nn.current,conversations:N.current,readAt:ne.current})},[]),Fn=Ht[P?.id??``]??{text:``,images:[],attachments:[],uploading:0},In=Fn.text,Ln=Fn.images,Rn=Fn.attachments,zn=Fn.uploading,Bn=(e,t)=>Ut(n=>({...n,[e]:t(n[e]??{text:``,images:[],attachments:[],uploading:0})})),Vn=e=>Bn(P?.id??``,t=>({...t,text:e})),Hn=e=>Bn(P?.id??``,t=>({...t,attachments:t.attachments.some(t=>t.kind===e.kind&&t.id===e.id)?t.attachments:[...t.attachments,e]})),Un=(e,t)=>Bn(P?.id??``,n=>({...n,attachments:n.attachments.filter(n=>n.kind!==e||n.id!==t)})),[Wn,Gn]=(0,F.useState)({visible:!1,query:``,rect:null}),Kn=JSON.stringify([P?.id,P?.workspaceId,P?.cwd??``]),[qn,Jn]=(0,F.useState)(),Yn=(0,F.useRef)(null),[Xn,Zn]=(0,F.useState)(),Qn=(0,F.useRef)(void 0),$n=(0,F.useRef)(``),er=!Tn&&qn?.scope===Kn?qn:void 0,tr=e=>{let t=!nn.current&&!Tn&&P?qx(e.value,e.selectionStart,e.selectionEnd):void 0,n=JSON.stringify([Kn,t]);return!t||$n.current===n?(Jn(void 0),!1):(Jn({scope:Kn,token:t,rect:e.getBoundingClientRect()}),Gn({visible:!1,query:``,rect:null}),!0)},nr=()=>{$n.current=JSON.stringify([Kn,er?.token]),Jn(void 0)};(0,F.useEffect)(()=>{Jn(void 0),$n.current=``},[Kn]),(0,F.useLayoutEffect)(()=>{let e=Qn.current;Qn.current=void 0,e?.scope===Kn&&e.text===In&&(oe.current?.focus(),oe.current?.setSelectionRange(e.caret,e.caret))},[In,Kn]),(0,F.useEffect)(()=>{let e=()=>{let e=oe.current;e&&Jn(t=>t?{...t,rect:e.getBoundingClientRect()}:void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let rr=e=>Bn(P?.id??``,t=>({...t,images:typeof e==`function`?e(t.images):e})),ir=S.length>0?S:T?[]:P?[P.id]:[],ar=(0,F.useMemo)(()=>ir.map(e=>mn.find(t=>t.id===e)).filter(e=>e!==void 0),[ir,mn]),or=ar.filter(e=>e.id!==C).at(-1)?.id,sr=ar.some(e=>e.id===P?.id);(0,F.useEffect)(()=>{if(!E)return;let e=new Set(mn.map(e=>e.id));x(t=>{let n=t.ids.filter(t=>e.has(t)),r=t.previewId&&e.has(t.previewId)?t.previewId:void 0;return n.length===t.ids.length&&r===t.previewId?t:{...t,ids:n,previewId:r}})},[E,mn]),(0,F.useEffect)(()=>{Xz(b,u)},[u,b]);let cr=(0,F.useCallback)(e=>{e&&x(t=>{if(t.touched.has(e))return t;let n=t.previewId===e?void 0:t.previewId;return{...t,previewId:n,touched:qz(t.touched,e)}})},[]),lr=(0,F.useCallback)(e=>{w.current++,d(e);let t=mn.find(t=>t.id===e)?.workspaceId;t&&y(t),fr(`session`),x(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&&P?.id&&P.id!==e?[P.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}})},[P,mn]),ur=(0,F.useCallback)(e=>{e&&(cr(e),lr(e))},[cr,lr]),[dr,fr]=(0,F.useState)(`session`),pr=P?.workspaceId??v,mr=P?.cwd??``,hr=pT(pr,mr,{navigation:w,showingFile:dr===`file`}),gr=Vp(pr,mr,f&&E),_r=(0,F.useRef)(gr.refresh);_r.current=gr.refresh;let vr=(0,F.useRef)(hr.setChangedFor),yr=(0,F.useRef)(hr.setIndex),br=(0,F.useRef)(hr.invalidateTree);br.current=hr.invalidateTree;let xr=(0,F.useRef)(pr);xr.current=pr;let Sr=(0,F.useRef)(mr);Sr.current=mr,(0,F.useEffect)(()=>{vr.current=hr.setChangedFor},[hr.setChangedFor]),(0,F.useEffect)(()=>{yr.current=hr.setIndex},[hr.setIndex]);let[Cr]=(0,F.useState)(KR),[wr,Tr]=(0,F.useState)(Cr.tab),[Er,Dr]=(0,F.useState)(Cr.byConversation),Or=(P?.id?Er[P.id]:void 0)??wr;(0,F.useEffect)(()=>{try{window.sessionStorage.setItem(GR,JSON.stringify({tab:wr,byConversation:Er}))}catch{}},[wr,Er]);let kr=(0,F.useCallback)(e=>{Tr(e),P?.id&&Dr(t=>({...t,[P.id]:e}))},[P?.id]),Ar=gt.order.filter(e=>gt.sides[e]===`left`),jr=gt.order.filter(e=>e!==`sessions`&&gt.sides[e]===`right`),Mr=Ar.includes(gt.leftView)?gt.leftView:`sessions`,Nr=jr.includes(Or)?Or:jr[0],Pr=gt.rightClosed||!Nr,Fr=Et||!gt.leftClosed&&Mr===`sessions`,Ir=(e,t=!1)=>{Et?e===`sessions`?(dt(),pt(!0)):(kr(e),ot(!1),mt<=700&&ct(`rail`)):gt.sides[e]===`left`?_t(n=>({...n,leftView:e,leftClosed:t&&!n.leftClosed&&Mr===e})):e!==`sessions`&&(kr(e),_t(n=>({...n,rightClosed:t&&!n.rightClosed&&Nr===e})))},Lr=(e,t)=>{let n=gt.sides[e];if(t===`move`){let t=n===`left`?`right`:`left`;_t(n=>({...n,sides:{...n.sides,[e]:t},...t===`left`?{leftView:e,leftClosed:!1}:{rightClosed:!1}})),t===`right`&&kr(e)}else _t(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}})},[Rr,zr]=(0,F.useState)(!1),Br=(0,F.useRef)(void 0),Vr=(0,F.useRef)(``);(0,F.useEffect)(()=>{zr(!1),M.current?.readyState===WebSocket.OPEN&&M.current.send(JSON.stringify({type:`files.index.subscribe`}))},[pr,mr]);let[Hr,Ur]=(0,F.useState)(!1),[Wr,Gr]=(0,F.useState)(),[Kr,qr]=(0,F.useState)(),[Jr,Yr]=(0,F.useState)({paths:[]}),Xr=Jr.paths,Zr=(0,F.useCallback)(()=>{!sr&&or?lr(or):fr(`session`)},[sr,or,lr]);(0,F.useEffect)(()=>{dr===`file`&&!hr.active&&Zr()},[dr,hr.active,Zr]),(0,F.useEffect)(()=>{dr===`diff`&&!Kr&&Zr()},[dr,Kr,Zr]);let Qr=(0,F.useRef)(`${pr??``}:${mr}`);(0,F.useEffect)(()=>{let e=`${pr??``}:${mr}`;Qr.current!==e&&(Qr.current=e,Yr({paths:[]}),qr(void 0),fr(`session`))},[pr,mr]);let $r=(0,F.useCallback)(e=>{w.current++,Yr(t=>t.paths.includes(e)?t:{paths:t.previewPath?t.paths.map(n=>n===t.previewPath?e:n):[...t.paths,e],previewPath:e}),qr(e),fr(`diff`),dt(),Tr(`files`)},[dt]),[ei,ti]=(0,F.useState)({diff:null,loading:!1,error:``}),[ni,ri]=(0,F.useState)(`server`);(0,F.useEffect)(()=>{if(dr!==`diff`||!Kr||!pr)return;let e=!0;return ti({diff:null,loading:!0,error:``}),fetch(`/api/files/diff?workspaceId=${encodeURIComponent(pr)}&path=${encodeURIComponent(Kr)}${mr?`&cwd=${encodeURIComponent(mr)}`:``}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(t=>{e&&ti({diff:t,loading:!1,error:``})}).catch(t=>{e&&ti({diff:null,loading:!1,error:t instanceof Error?t.message:`读取差异失败`})}),()=>{e=!1}},[dr,Kr,pr,mr]);let ii=(0,F.useMemo)(()=>{if(!Kr)return;let e=hr.open.find(e=>e.path===Kr);return e&&e.dirty?e.content:void 0},[Kr,hr.open]),ai=(0,F.useCallback)(e=>{w.current++,hr.setActivePath(e),fr(`file`),Tr(`files`)},[hr.setActivePath]),oi=(0,F.useCallback)(async(e,t,n=!1)=>{let r=++w.current,i=()=>w.current===r,a=await hr.openFile(e,{preview:!n,isCurrent:i});a&&i()&&(n&&hr.pinFile(a),Gr(t?{workspaceId:pr,path:a,line:t,request:r}:void 0),fr(`file`),dt())},[hr.openFile,hr.pinFile,pr,dt]),si=(0,F.useCallback)((e,t)=>{oi(e,void 0,t)},[oi]),ci=P&&!Tn?(e,t)=>{let n=In&&!/\s$/u.test(In)?`${In} `:In,r=Jx(n,{start:n.length,end:n.length,query:``},{path:e,kind:t?`directory`:`file`});Qn.current={scope:Kn,...r},cr(P.id),lr(P.id),dt(),Vn(r.text)}:void 0,li=(e,t)=>{w.current+=1,Yr(t=>({paths:t.paths.filter(t=>!cS(t,e)),previewPath:t.previewPath&&!cS(t.previewPath,e)?t.previewPath:void 0})),Kr&&cS(Kr,e)&&qr(void 0),Gr(n=>n&&cS(n.path,e)?{...n,path:t+n.path.slice(e.length)}:n)};(0,F.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()===`f`?(e.preventDefault(),Ur(!0)):(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`p`&&(e.preventDefault(),Br.current=pr,Vr.current=mr,zr(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[pr,mr]);let ui=(0,F.useMemo)(()=>ar.map(e=>({id:`session:${e.id}`,rawId:e.id,kind:`session`,label:e.title,title:e.title,closable:!0,preview:C===e.id,badge:(0,I.jsx)(rz,{state:tz(e,$R(e,nt),ne.current[e.id],l.conversations)})})),[ar,nt,l.conversations,re,C]),di=(0,F.useMemo)(()=>hr.open.map(e=>({id:`file:${e.path}`,rawId:e.path,kind:`file`,label:e.name,title:e.path,closable:!0,preview:e.preview,badge:e.dirty?(0,I.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[hr.open]),fi=(0,F.useMemo)(()=>Xr.map(e=>({id:`diff:${e}`,rawId:e,kind:`diff`,label:e.split(/[\\/]/).pop()||e,title:`${e}(改动)`,closable:!0,preview:Jr.previewPath===e,icon:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`±`})})),[Xr,Jr.previewPath]),pi=(0,F.useMemo)(()=>[...ui,...di,...fi],[ui,di,fi]),mi=dr===`file`&&hr.activePath?`file:${hr.activePath}`:dr===`diff`&&Kr?`diff:${Kr}`:sr&&P?.id?`session:${P.id}`:void 0,hi=(0,F.useRef)(void 0);(0,F.useLayoutEffect)(()=>{if(hi.current!==hr.restoredActive&&(hi.current=hr.restoredActive,hr.restoredActive&&hr.restoredActive===hr.activePath&&dr!==`file`)){fr(`file`);return}E&&C&&mi!==`session:${C}`&&mn.some(e=>e.id===C)&&x(e=>{if(e.previewId!==C)return e;let t=e.ids.filter(e=>e!==C);return{...e,ids:t,previewId:void 0,emptied:t.length===0}});for(let e of hr.open)e.preview&&mi!==`file:${e.path}`&&hr.discardPreview(e.path);let e=Jr.previewPath;e&&mi!==`diff:${e}`&&Yr(t=>t.previewPath===e?{paths:t.paths.filter(t=>t!==e)}:t),E&&dr===`session`&&P?.id===u&&!sr&&!hr.restoringWorkbench&&or&&lr(or)},[mi,E,C,hr.open,hr.activePath,hr.restoredActive,hr.discardPreview,Jr.previewPath,dr,P?.id,u,sr,hr.restoringWorkbench,or,lr,mn]);let gi=(0,F.useCallback)(e=>{if(e.startsWith(`file:`)){let t=e.slice(5);ai(t)}else if(e.startsWith(`diff:`)){w.current++;let t=e.slice(5);qr(t),fr(`diff`)}else if(e.startsWith(`session:`)){let t=e.slice(8);lr(t)}},[ai,lr]),_i=(0,F.useCallback)(e=>{if(e.startsWith(`session:`))ur(e.slice(8));else if(e.startsWith(`file:`))hr.pinFile(e.slice(5));else if(e.startsWith(`diff:`)){let t=e.slice(5);Yr(e=>e.previewPath===t?{paths:e.paths}:e)}},[ur,hr.pinFile]),vi=(0,F.useCallback)(e=>{let t=ir.indexOf(e);if(t<0)return;let n=ir.filter(t=>t!==e);if(x(t=>({...t,ids:t.ids.filter(t=>t!==e),previewId:t.previewId===e?void 0:t.previewId,emptied:n.length===0||t.emptied})),P?.id!==e||dr!==`session`)return;w.current++;let r=n[Math.min(t,n.length-1)];if(r)d(r);else if(hr.open.length>0){let e=hr.activePath&&hr.open.some(e=>e.path===hr.activePath)?hr.activePath:hr.open[0].path;hr.setActivePath(e),fr(`file`)}else Xr.length>0?(qr(Xr[0]),fr(`diff`)):d(void 0)},[ir,P,hr,Xr,dr]),yi=(0,F.useCallback)(e=>{if(e.startsWith(`file:`)){let t=e.slice(5);hr.closeFile(t),dr===`file`&&hr.activePath===t&&hr.open.length<=1&&w.current++}else if(e.startsWith(`diff:`)){let t=e.slice(5);Yr(e=>({paths:e.paths.filter(e=>e!==t),previewPath:e.previewPath===t?void 0:e.previewPath})),dr===`diff`&&Kr===t&&(w.current++,qr(void 0),Zr())}else if(e.startsWith(`session:`)){let t=e.slice(8);vi(t)}},[hr,vi,Kr,dr,Zr]),bi=hr.active,xi=JSON.stringify([pr,mr,bi?.path]),[Si,Ci]=(0,F.useState)(),wi=(0,F.useCallback)(e=>{Ci(t=>e?{scope:xi,position:e}:t?.scope===xi?void 0:t)},[xi]),Ti=Si?.scope===xi?Si.position:void 0,Ei=l.workspaces.find(e=>e.id===pr),Di=bi&&(0,I.jsx)($x,{root:mr.split(`/`).at(-1)||Ei?.name||`工作目录`,path:bi.path,reveal:(e,t)=>{Ir(`files`),hr.locatePath(e,t)}}),Oi=bi&&(!bi.view||bi.view===`table`)?(0,I.jsx)(lT,{file:bi,state:hr.saves[bi.path]?.state??`idle`,message:hr.saves[bi.path]?.message??``,external:hr.external[bi.path]===!0,jumpToLine:Wr&&Wr.workspaceId===pr&&Wr.path===bi.path?Wr:void 0,onChange:e=>hr.updateBuffer(bi.path,e),onSave:()=>void hr.save(bi.path,!1),onReload:()=>void hr.reload(bi.path),onOverwrite:()=>void hr.save(bi.path,!0),workspaceId:pr,cwd:mr,navigation:bi.view?void 0:Di,embedded:!!bi.view,onPosition:wi}):void 0,ki=P?.id;(0,F.useEffect)(()=>{ki&&!ki.startsWith(`pending:`)&&Vi({type:`conversation.select`,conversationId:ki})},[ki]);let Ai=(e,t=`info`)=>{if(!e)return;let n=++rn.current;ze(r=>[...r,{key:n,text:e,kind:t}]),an.current.push(window.setTimeout(()=>ze(e=>e.filter(e=>e.key!==n)),7e3))},ji=(0,F.useRef)(null),Mi=(0,F.useRef)({deadline:0,busy:!1,serverWasAway:!1,mode:`update`}),Ni=()=>{ji.current!==null&&(window.clearInterval(ji.current),ji.current=null)},Pi=(e,t)=>{Ni(),it(!1),tt(`idle`),Ai(e,t)},Fi=async()=>{let e=Mi.current;if(!e.busy){if(Date.now()>e.deadline)Pi(`更新等待超时(30 分钟),请检查服务日志`,`error`);else{e.busy=!0;try{let t=await fetch(`/api/update-check`);if(!t.ok){Pi(`更新已结束`,`info`);return}let n=await t.json();if(n.updating===!0){it(!0);return}let r=n.lastUpdate;if(r?.ok===!1){Pi(`更新失败(退出码 ${r.code??`未知`}),可以再试一次`,`error`);return}if(e.mode===`restart`){(e.serverWasAway||n.needsRestart===!1)&&Pi(`服务已重启…`,`info`);return}if(r?.ok===!0){Pi(`更新完成,服务正在重启…`,`info`);return}Pi(e.serverWasAway?`更新完成,服务已重启…`:`更新已结束`,`info`)}catch{e.serverWasAway=!0,it(!0)}finally{e.busy=!1}}}},Ii=(e=`update`)=>{Ni(),Mi.current={deadline:Date.now()+18e5,busy:!1,serverWasAway:!1,mode:e},it(!0),ji.current=window.setInterval(()=>{Fi()},2e3)};(0,F.useEffect)(()=>()=>Ni(),[]),(0,F.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/api/update-check`);if(!t.ok)return;let n=await t.json();!e&&n.updating===!0&&Ii()}catch{}})(),()=>{e=!0}},[]),(0,F.useEffect)(()=>{let e=P?.id,t=P?.agentNotice;e&&t&&!cn.current.has(e)&&(cn.current.add(e),Ai(t,`info`))},[P?.id,P?.agentNotice]);let Li=(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},Ri=(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},zi=(e,t)=>{if(t.method===`notify`)Ai(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;Le(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===on.current&&Vn(t.text??``)},Bi=(e,t,n)=>{Le(n=>n.filter(n=>!(n.conversationId===e&&n.request.blocking&&n.request.requestId===t)));let r=vR[n];r&&Ai(r,`warning`)};(0,F.useEffect)(()=>{let e=!1,t=0,r,s=()=>{if(e)return;let c=location.protocol===`https:`?`wss`:`ws`,l=new WebSocket(`${c}://${location.host}/ws?state=focused${on.current?`&conversationId=${encodeURIComponent(on.current)}`:``}`);M.current=l,l.onopen=()=>{if(!e){t=0,p(!0),l.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),l.send(JSON.stringify({type:`catalog.fetch`,conversationId:on.current})),Nn.current&&l.send(JSON.stringify({type:`prompt.catalog.fetch`,workspaceId:Nn.current})),l.send(JSON.stringify({type:`catalog.fetchAll`})),l.send(JSON.stringify({type:`agent.catalog.fetch`})),l.send(JSON.stringify({type:`subagent.catalog.fetch`}));for(let e of a.current)e.retry&&e.command&&l.send(JSON.stringify({...e.command,operationRequestId:e.id}))}},l.onclose=n=>{if(e)return;sn.current=!1;let o=SI(a.current);for(let e of o.failed)e.onFailure?.();if(a.current=o.retry,i(o.retry),p(!1),t===0){let e=n.reason?.trim()?`${n.reason.trim()}(code ${n.code})`:`code ${n.code}`;console.error(`[Super Pi Error] websocket closed:`,n.code,n.reason),Ai(`与 Super Pi 服务的连接断开,正在重连。(${e})`,`error`)}r=window.setTimeout(s,Math.min(rR,nR*2**t++))},l.onmessage=({data:t})=>{if(e)return;let r=JSON.parse(t);if(r.type!==`message.delta`&&r.type!==`message.thinking`&&ve(),r.type===`message.accepted`){lw(r.conversationId,r.clientId);for(let e of a.current)e.command?.conversationId===r.conversationId&&e.command?.clientId===r.clientId&&(e.receipt=!0)}else if(r.type===`exec.output`){let e=pe.current.get(r.sessionId)??``;pe.current.set(r.sessionId,(r.replace?r.data:e+r.data).slice(-512e3)),pe.current.size>64&&pe.current.delete(pe.current.keys().next().value),window.dispatchEvent(new CustomEvent(`super-pi-exec-output`,{detail:r}))}else if(r.type===`run.stopping`)It(e=>{let t=new Set(e);return t.add(r.conversationId),t});else if(r.type===`exec.exit`)(r.stdout||r.stderr)&&pe.current.set(r.sessionId,`${r.stdout}${r.stderr}`);else if(r.type.startsWith(`terminal.`))me.current?.(r);else if(r.type===`conversation.autoRename.result`){let e=Vt.current.get(r.conversationId);e&&(Vt.current.delete(r.conversationId),r.ok?e.resolve(r.title):e.reject(Error(r.error)))}else if(r.type===`message.thinking`)ye(r);else if(r.type===`state`){ve(),sn.current=!1;let e=on.current,t=!!(e&&ln.current.has(e)),s=!(!e||r.state.conversations.some(t=>t.id===e)),c=t&&s&&e&&un.current.has(e)?{...r.state,conversations:[un.current.get(e),...r.state.conversations]}:r.state;e&&!s&&(ln.current.delete(e),un.current.delete(e)),a.current=a.current.filter(e=>!e.accepted?.(c)||c.sendReceipts&&e.retry&&!e.receipt?!0:(e.retry&&typeof e.command?.conversationId==`string`&&typeof e.command.clientId==`string`&&lw(e.command.conversationId,e.command.clientId),!1)),i(a.current),It(e=>{let t=new Set(e);for(let e of[...t]){let n=c.conversations.find(t=>t.id===e);(!n||n.status!==`running`&&n.status!==`waiting`)&&t.delete(e)}return t}),c.extensionUi&&Le(c.extensionUi),c.stoppingConversationIds&&It(new Set(c.stoppingConversationIds)),n(c),D(!0),p(!0),y(e=>{if(e&&(c.workspaces.some(t=>t.id===e)||a.current.some(t=>t.temporaryId===e)))return e;let t=o.current?.workspaceId;return t&&c.workspaces.some(e=>e.id===t)?t:c.workspaces[0]?.id})}else if(r.type===`message.delta`)ye(r);else if(r.type===`queue.withdrawn`){Sn(e=>[...e.filter(e=>e.conversationId!==r.conversationId).slice(-9),{id:`withdrawn_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,conversationId:r.conversationId,actor:r.actor,withdrawn:r.withdrawn}]);let e=r.withdrawn.slice(0,2).map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,24)}」`).join(`、`),t=r.actor===`agent`?`上级 Agent 已撤回`:`已撤回`;Ai(`${t} ${r.withdrawn.length} 条排队消息:${e}${r.withdrawn.length>2?`…`:``}`,`info`)}else if(r.type===`message.revert.result`)R(void 0),Pt(void 0),r.ok||(console.error(`[Super Pi Error] revert failed:`,r.message),h(r.message));else if(r.type===`operation.result`){let e=a.current.find(e=>e.id===r.requestId),t=e?.retry?e.command:void 0;if(t&&lw(t.conversationId,t.clientId),a.current=a.current.filter(e=>e.id!==r.requestId),i(a.current),e?.temporaryId){let t=e.temporaryId;if(r.ok&&r.entityId){let e=r.entityId,i=dn.current.get(t);if(i&&un.current.set(e,{...i,id:e}),ln.current.add(e),i){let t={...i,id:e};n(n=>n.conversations.some(t=>t.id===e)?n:{...n,conversations:[t,...n.conversations]})}Ut(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.attachments.length?r.attachments:i.attachments,uploading:r.uploading+i.uploading}:r,delete a[t],a}),dn.current.delete(t)}d(n=>n===t?r.ok?r.entityId:e.previousActiveId:n),x(e=>Jz(e,t,r.ok&&r.entityId?r.entityId:void 0)),y(e=>e===t?r.ok?r.entityId:void 0:e)}if(!r.ok){if(console.error(`[Super Pi Error] operation failed:`,r.message),!e?.receipt){if(e?.onFailure)e.onFailure(r.message);else if(t){let e=t.images??[],n=t.attachments??[];Jt(i=>[...i,{id:t.clientId,conversationId:t.conversationId,content:t.content,images:e,attachments:n,reason:r.message}]),Bn(t.conversationId,r=>r.text||r.images.length||r.attachments.length?r:{...r,text:t.content,images:e,attachments:n})}}let n=r.message??`操作失败`;h(n),e?.onFailure||Ai(dp(n),`error`)}}else r.type===`tools.updated`?window.dispatchEvent(new Event(`super-pi-tools-updated`)):r.type===`files.changed`?(vr.current(r.workspaceId,r.changes,r.dropped),r.workspaceId===xr.current&&_r.current()):r.type===`files.invalidated`?(br.current(r.workspaceId,r.paths),r.workspaceId===xr.current&&_r.current()):r.type===`files.index`?r.workspaceId===xr.current&&(r.cwd??``)===Sr.current&&yr.current(r):r.type===`error`?(console.error(`[Super Pi Error]`,r.message),h(r.message),Ai(dp(r.message),`error`),sn.current&&=!1):r.type===`extension.ui`?zi(r.conversationId,r.request):r.type===`extension.ui.closed`?Bi(r.conversationId,r.requestId,r.reason):r.type===`model.catalog`?(!r.conversationId||r.conversationId===on.current)&&Ve(r.catalog):r.type===`model.catalog.all`?Ue(r.catalog):r.type===`providers.list`?(Ge(r.providers),qe(r.apis)):r.type===`agent.catalog`?Ye(r.catalog):r.type===`prompt.catalog`?Fe(r.catalog):r.type===`subagent.catalog`?Ze(r.catalog):r.type===`server.version`?($e(r.version),r.version.needsRestart&&Ai(`检测到 Super Pi 代码已更新(v${r.version.runningVersion} → v${r.version.diskVersion}),请执行 /super_pi restart 重启服务生效`,`warning`)):r.type===`subagent.event`?n(e=>({...e,subagentRuns:Li(e.subagentRuns??[],r.run)})):r.type===`workflow.event`?n(e=>({...e,workflows:Ri(e.workflows??[],r.workflow)})):r.type===`message.tools`?n(e=>({...e,conversations:e.conversations.map(e=>e.id===r.conversationId?{...e,messages:e.messages.map(e=>e.id===r.messageId?{...e,toolCalls:r.toolCalls}:e)}:e)})):r.type===`conversation.fork.result`&&(ko(e=>e===r.conversationId?void 0:e),Ai(r.ok?`已从「${r.title}」分叉出新会话,放在侧边栏最上面;没有切换过去。${r.messagesCopied?`复制了 ${r.messagesCopied} 条消息。`:`原会话还没有消息,只复制了会话本身。`}`:`分叉失败:${dp(r.message)}`,r.ok?`info`:`error`))}};return s(),()=>{e=!0,ve(),window.clearTimeout(r);for(let e of an.current)window.clearTimeout(e);M.current?.close()}},[ye,ve]);let Vi=(0,F.useCallback)(e=>M.current?.readyState===WebSocket.OPEN&&(M.current.send(JSON.stringify(e)),!0),[]);(0,F.useEffect)(()=>{if(!f)return;let e=P?.id;e?.startsWith(`pending:`)||Vi({type:`state.subscribe`,...e?{conversationId:e}:{}})},[P?.id,f,Vi]),(0,F.useEffect)(()=>{if(f&&Rr&&pr&&Br.current===pr&&Vr.current===mr)return Vi({type:`files.index.subscribe`,workspaceId:pr,...mr?{cwd:mr}:{}}),hr.requestIndex(!0),()=>{Vi({type:`files.index.subscribe`}),hr.cancelIndexRequest()}},[f,Rr,pr,mr,Vi,hr.requestIndex,hr.cancelIndexRequest]);let Hi=(e,t,n,r,o,s,c)=>{let l=M.current?.readyState===WebSocket.OPEN,u=xI(e);if(a.current.some(e=>e.key===t)||!l&&!u)return!1;if(u&&!cw(e))return Ai(`浏览器无法保存待发消息,正文仍在输入框。`,`error`),!1;let d=fE(),f={id:d,key:t,apply:n,temporaryId:r,previousActiveId:on.current,onFailure:o,accepted:s,...c?{expiresAt:Date.now()+c}:{},...u?{retry:!0,command:e}:{}};return a.current=[...a.current,f],i(a.current),l&&M.current.send(JSON.stringify({...e,operationRequestId:d})),!0},Ui=(e,t)=>{Vi({type:`conversation.childLock`,conversationId:e,unlocked:t})||Ai(t?`连接断开,这个子会话没有解锁,请重试`:`连接断开,这个子会话没有上锁,请重试`,`error`)},Wi=e=>{if(!e)return;let t=`message_${fE()}`;Hi({type:`message.send`,conversationId:e,content:sR,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,F.useEffect)(()=>{let e=r.flatMap(e=>e.expiresAt?[e.expiresAt]:[]);if(!e.length)return;let t=window.setTimeout(()=>{let e=a.current.filter(e=>e.expiresAt&&e.expiresAt<=Date.now());if(e.length){a.current=a.current.filter(t=>!e.includes(t)),i(a.current);for(let t of e)t.onFailure?.(`打断请求超时,尚未确认是否开始回答;请检查会话状态后重试`)}},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[r]);let Gi=(e,t)=>n=>({...n,conversations:n.conversations.map(n=>n.id===e?{...n,...t}:n)}),Ki=(e,t)=>n=>({...n,workspaces:n.workspaces.map(n=>n.id===e?{...n,...t}:n)}),qi=P?.id.startsWith(`pending:`)===!0,Ji=!!(P&&XR(P)&&(Ft.has(P.id)||r.some(e=>e.key===`stop:${P.id}`))),Yi=P?.messagesLoaded===!1||r.some(e=>e.key.startsWith(`send:${P?.id}:`)||e.key===`configuration:${P?.id}`||e.temporaryId===P?.id||e.key===`archive:${P?.id}`),Xi=(e,t,n,r,i)=>{e&&M.current?.send(JSON.stringify({type:`question.answer`,conversationId:e,messageId:t,callIndex:n,answers:r,cancelled:i}))},Zi=(e,t,n)=>(cr(e),Hi({type:`extension.ui.answer`,conversationId:e,requestId:t,...n},`answer:${e}:${t}`,e=>e)),Qi=P?.model??Be?.defaultModel,$i=P?.thinkingLevel??Be?.defaultThinkingLevel,ea=$i&&Be?.levels.includes($i)?$i:void 0,ta=Be?.source===`pi`,na=Be?.models.find(e=>e.provider===Qi?.provider&&e.modelId===Qi?.modelId),ra=!!na?.imageInput,ia=(e,t)=>!e||!t?e:{...e,models:e.models.filter(e=>(l.modelFilterRules??[]).every(n=>{try{return!new RegExp(n.workspacePattern,`i`).test(t.name)||new RegExp(n.modelPattern,`i`).test(e.label)||new RegExp(n.modelPattern,`i`).test(`${e.provider}/${e.modelId}`)}catch{return!0}}))},aa=!!P?.messages?.some(e=>e.images&&e.images.length>0),oa=ia(Be,l.workspaces.find(e=>e.id===P?.workspaceId))?.models??[],sa=(aa?oa.filter(e=>e.imageInput):oa).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,kL(e.contextWindow)?`${kL(e.contextWindow)} 上下文`:``,AL(e.maxTokens)?`${AL(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:fR(e),selected:Qi?.provider===e.provider&&Qi.modelId===e.modelId})),ca=(Be?.levels??[]).map(e=>({key:e,label:e,selected:e===$i})),la=e=>{if(!P)return;let[t,n]=e.split(`/`);t&&n&&(cr(P.id),Hi({type:`conversation.model`,conversationId:P.id,provider:t,modelId:n},`configuration:${P.id}`,Gi(P.id,{model:Be?.models.find(e=>e.provider===t&&e.modelId===n)??{provider:t,modelId:n,label:n}})))},ua=e=>{P&&(cr(P.id),Hi({type:`conversation.thinking`,conversationId:P.id,level:e},`configuration:${P.id}`,Gi(P.id,{thinkingLevel:e})))},da=Je?.agents.find(e=>e.id===P?.agentId),fa=[{key:HR,label:`跟随 Pi 默认`,detail:`不使用任何 agent 角色`,selected:!P?.agentId},...(Je?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:P?.agentId===e.id}))],pa=da?.model,ma=!!(pa&&P?.model&&P.model.provider===pa.provider&&P.model.modelId===pa.modelId);da?.thinkingLevel&&(P?.thinkingLevel,da.thinkingLevel);let ha=e=>{if(P){let t=Je?.agents.find(t=>t.id===e);Hi({type:`conversation.agent`,conversationId:P.id,agentId:e===HR?null:e},`configuration:${P.id}`,Gi(P.id,{agentId:t?.id,...t?.model?{model:{...t.model,label:t.model.modelId}}:{},...t?.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}}))}},ga=nt.filter(e=>e.conversationId===P?.id),_a=Ie.filter(e=>e.conversationId===P?.id).map(e=>e.request),va=new Map(_a.filter(e=>e.method===`setStatus`).map(e=>[e.statusKey??``,e.statusText??``])),ya=new Map(_a.filter(e=>e.method===`setWidget`).map(e=>[e.widgetKey??``,{lines:e.widgetLines??[],placement:e.widgetPlacement??`aboveEditor`}])),ba=_a.find(e=>e.method===`setTitle`)?.title,xa=(0,F.useMemo)(()=>(l.subagentRuns??[]).filter(e=>e.conversationId===P?.id),[l.subagentRuns,P?.id]),Sa=(0,F.useMemo)(()=>(l.workflows??[]).filter(e=>e.conversationId===P?.id),[l.workflows,P?.id]),Ca=(0,F.useMemo)(()=>new Map(Sa.map(e=>[e.id,e])),[Sa]),wa=(0,F.useMemo)(()=>new Map((Xe?.agents??[]).map(e=>[e.id,e.name])),[Xe]),Ta=(0,F.useMemo)(()=>new Map((P?.messages??[]).map(e=>[e.id,e])),[P?.messages]),Ea=(0,F.useMemo)(()=>new Map(xa.map(e=>[e.id,e])),[xa]),Da=(0,F.useMemo)(()=>{let e=new Map;for(let t of xa)t.originMessageId!==void 0&&t.originCallRow!==void 0&&e.set(`${t.originMessageId}:${t.originCallRow}`,t);return e},[xa]),Oa=(0,F.useMemo)(()=>{if(!P||!sr)return[];let e=Nt?.conversationId===P.id?(()=>{let e=P.messages.find(e=>e.id===Nt.messageId);if(e)return{index:P.messages.indexOf(e),at:Date.parse(e.createdAt)||0,...Nt.kind===`withdraw`?{inclusive:!0}:{inclusive:!1}}})():void 0,t=[];return P.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}`})}),xa.forEach((n,r)=>{n.originMessageId&&n.originCallRow!==void 0&&P?.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}`})}),Sa.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}`})}),t.sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)},[P,xa,Sa,Nt]),ka=(0,F.useMemo)(()=>{for(let e=Oa.length-1;e>=0;--e){let t=Oa[e];if(t.startsWith(`m:`)&&Ta.get(t.slice(2))?.role===`user`)return t.slice(2)}},[Oa,Ta]);(0,F.useEffect)(()=>{let e=ae.current;if(!e||!P?.id)return;let t=()=>{!fe.current&&N.current[P.id]?.followTail&&(Hz(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()},[P?.id,P?.messages,xa,Sa,sr,Oa]);let Aa=e=>Ot(t=>({...t,[e]:!t[e]})),ja=(e,t)=>At(n=>({...n,[`${e}:${t}`]:!n[`${e}:${t}`]})),Ma=(e,t)=>Mt(n=>({...n,[`${e}:${t}`]:n[`${e}:${t}`]!==!1})),[Na,Pa]=(0,F.useState)({}),Fa=e=>Pa(t=>({...t,[e]:t[e]!==!0})),Ia=e=>{Hi({type:`subagent.stop`,runId:e},`stop:${e}`,e=>e)||Ai(`连接断开,无法停止子智能体,请重试`,`error`)},La=e=>{Hi({type:`workflow.stop`,workflowId:e},`stop:${e}`,e=>e)||Ai(`连接断开,无法停止编排,请重试`,`error`)},Ra=e=>[...ya].filter(([,t])=>t.placement===e).map(([e,t])=>{let n=t.lines;return(0,I.jsxs)(`div`,{className:`extui-widget`,"data-widget-key":e,"data-widget-lines":n.length,children:[n.slice(0,yR).map((e,t)=>(0,I.jsx)(`div`,{children:e},`${t}:${e}`)),n.length>yR&&(0,I.jsx)(`div`,{children:`… (widget truncated)`})]},e)}),za=(e,t)=>{let n=`pending:${fE()}`,r={id:n,name:e,path:t,updatedAt:new Date().toISOString()};Hi({type:`workspace.create`,name:e,path:t},`create-workspace`,e=>({...e,workspaces:[...e.workspaces,r]}),n)&&(w.current++,y(n),d(void 0),k(!1))},[Ba,Va]=(0,F.useState)(),Ha=(e,t)=>Va(n=>n?.kind===e&&n.id===t?n:{kind:e,id:t}),Ua=()=>Va(void 0),Wa=(e,t)=>Ba?.kind===e&&Ba.id===t,Ga=(e,t,n)=>!t.startsWith(`pending:`)&&(e===`conversation`&&cr(t),Hi(e===`workspace`?{type:`workspace.rename`,workspaceId:t,name:n}:{type:`conversation.rename`,conversationId:t,name:n},`rename:${t}`,e===`workspace`?Ki(t,{name:n}):Gi(t,{title:n}))?(sn.current=!0,Ua(),!0):(Ai(`连接断开,改名未保存,请重试`,`error`),!1)),Ka=async e=>{if(e.startsWith(`pending:`)){Ai(`这个会话还在创建中,稍后再试`,`warning`);return}if(Vt.current.has(e))return;Ai(`正在根据对话内容生成标题…`,`info`);let t=new Promise((t,n)=>{Vt.current.set(e,{resolve:t,reject:n}),window.setTimeout(()=>{Vt.current.delete(e)&&n(Error(`模型在 30 秒内没有返回标题`))},32e3)});if(!Vi({type:`conversation.autoRename`,conversationId:e}))Vt.current.delete(e),Ai(`连接断开,无法生成标题`,`error`);else try{let n=await t;Ga(`conversation`,e,n),Ai(`已重命名为「${n}」`,`info`)}catch(e){Ai(`重命名失败:${dp(e)}`,`error`)}},qa=e=>{if(e.id.startsWith(`pending:`))return;let t=l.conversations.filter(t=>t.workspaceId===e.id).length;window.confirm(`从列表移除工作区「${e.name}」?${t?`其中的 ${t} 条会话会保留,`:``}重新添加同一个目录即可恢复,不会删除任何会话。`)&&(Ya(void 0),Hi({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)})))},[Ja,Ya]=(0,F.useState)(),Xa=Ja?l.workspaces.find(e=>e.id===Ja):void 0,{theme:Za,setTheme:Qa}=KE(),[$a,eo]=(0,F.useState)(!1),[to,no]=(0,F.useState)(!1),ro=(e,t,n,r)=>{e.startsWith(`pending:`)||(Hi({type:`workspace.settings`,workspaceId:e,model:n?{provider:n.provider,modelId:n.modelId}:null,thinkingLevel:r??null,agentId:t??null},`defaults:${e}`,Ki(e,{defaultModel:n,defaultThinkingLevel:r,defaultAgentId:t}))?Ya(void 0):Ai(`连接断开,设置未保存,请重试`,`error`))},io=(e,t=``)=>{if(e.startsWith(`pending:`))return;if(a.current.some(t=>t.key===`defaults:${e}`)){Ai(`工作区设置正在保存,请稍后再新建会话`,`warning`);return}let n=`pending:${fE()}`,r={id:n,workspaceId:e,title:`新会话`,status:`idle`,updatedAt:new Date().toISOString(),messages:[],...t?{cwd:t}:{}};dn.current.set(n,r),Hi({type:`conversation.create`,workspaceId:e,...t?{cwd:t}:{}},`create-session:${e}:${n}`,e=>({...e,conversations:[r,...e.conversations]}),n)?(w.current++,y(e),d(n),fr(`session`),x(e=>({...e,ids:[...e.ids.filter(e=>e!==n),n],touched:qz(e.touched,n)}))):(dn.current.delete(n),Ai(`连接断开,会话未创建,请重试`,`error`))},ao=e=>{if(e.startsWith(`pending:`))return;let t=l.conversations.find(t=>t.id===e);if(!t||t.archivedAt||t.parentConversationId&&l.conversations.some(e=>e.id===t.parentConversationId))return;let n=eR(l.conversations,e),r=n.filter(e=>!e.archivedAt),i=r.length-1,a=n.length-r.length,o=IL(l.pendingUserDecisionsByConversation,n.map(e=>e.id)),s=LL({title:t.title,activeCount:r.length,activeDescendants:i,alreadyArchived:a,pendingDecisions:o});if(RL({activeDescendants:i,pendingDecisions:o})&&!window.confirm(s))return;let c=new Date().toISOString(),u=new Set(r.map(e=>e.id));Hi({type:`conversation.archive`,conversationId:e},`archive:${e}`,e=>({...e,conversations:e.conversations.map(e=>u.has(e.id)&&!e.archivedAt?{...e,archivedAt:c}:e)}))},oo=(e,t)=>Hi({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}),so=e=>{let t=l.conversations.find(t=>t.id===e);if(!t?.archivedAt||(t.parentConversationId?l.conversations.find(e=>e.id===t.parentConversationId):void 0)?.archivedAt)return;let n=new Set(eR(l.conversations,e).filter(e=>e.archivedAt).map(e=>e.id));Hi({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})}))},co=async e=>{if(!P){Ai(`请先选择或创建会话`,`error`);return}if(!ra){Ai(`当前模型不支持图片输入`,`error`);return}let t=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],n=e.filter(e=>t.includes(e.type)?e.size>5242880?(Ai(`图片「${e.name}」超过 5MB 上限`,`error`),!1):!0:(Ai(`不支持的文件格式「${e.name}」,仅支持 PNG/JPEG/GIF/WebP`,`error`),!1));if(n.length===0)return;let r=P.id;Bn(r,e=>({...e,uploading:e.uploading+n.length}));let i=n.map(e=>({id:fE(),conversationId:r,name:e.name,url:URL.createObjectURL(e)}));Xt(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 fetch(`/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`)){Ai(`服务器未返回 JSON 响应,请刷新或重启服务`,`error`);continue}if(i.ok){let e=await i.json();if(Kt.current.has(n.id))continue;Xt(e=>e.filter(e=>e.id!==n.id)),URL.revokeObjectURL(n.url),Bn(r,t=>({...t,images:[...t.images,{id:e.id,name:e.name,mimeType:e.mimeType,bytes:e.bytes}]}))}else{let e=await i.json().catch(()=>({error:`上传失败`}));Ai(dp(e.error,`上传失败(HTTP ${i.status})`),`error`)}}catch(e){Ai(`上传失败:${dp(e,`网络或服务暂时不可用`)}`,`error`)}finally{Xt(e=>e.map(e=>e.id===n.id?{...e,failed:!0}:e)),Bn(r,e=>({...e,uploading:Math.max(0,e.uploading-1)}))}}},lo=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(!ra){Ai(`当前模型不支持图片输入`,`error`);return}e.preventDefault(),co(n)}},uo=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),en(!0))},fo=e=>{e.currentTarget.contains(e.relatedTarget)||en(!1)},po=e=>{en(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>e.type.startsWith(`image/`));if(t.length>0){if(e.preventDefault(),!ra){Ai(`当前模型不支持图片输入`,`error`);return}co(t)}},mo=t=>{if(t.preventDefault(),!P)return;if(Tn){Ai(jL,`warning`);return}if(Yi){Ai(qi?`会话正在创建,请稍候再发送`:P.messagesLoaded===!1?`正在加载会话,请稍候再发送`:`正在保存配置,请稍候再发送`,`info`);return}if(!In.trim()&&Ln.length===0)return;if(Ln.length>0&&!ra){Ai(`当前模型不支持图片输入,请移除图片或切换至支持图文的模型`,`error`);return}if(zn>0){Ai(`图片正在上传中,请稍候…`,`info`);return}let n=`message_${fE()}`,r=P.id,i=In,a=Ln,o=Rn;cr(r),e.stoppingConversationIds||It(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t});let s=jR({conversationId:r,content:i,clientId:n,images:a,attachments:Rn,inFlight:XR(P),deliveryMode:vn}),c=new Date().toISOString();Hi(s,`send:${r}:${n}`,e=>uw(e,s,c),n,e=>{Jt(t=>[...t,{id:n,conversationId:r,content:i,images:a,attachments:o,reason:e}]),Bn(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===n))&&Bn(P.id,e=>({...e,text:``,images:[]}))},ho=(0,F.useMemo)(()=>(P?.messages??[]).filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),[P?.messages]),go=e=>{Hi({type:`message.cancel`,conversationId:P?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===P?.id?{...t,messages:t.messages.filter(t=>t.id!==e)}:t)}))||Ai(`连接断开,撤回没有生效,请重试`,`error`)},_o=e=>{if(!P?.id||!e.length)return;let t=new Set(e),n=`queue-many:${P.id}:${e.join(`,`)}`;Hi({type:`message.cancelMany`,conversationId:P.id,messageIds:e},n,e=>({...e,conversations:e.conversations.map(e=>e.id===P.id?{...e,messages:e.messages.filter(e=>!t.has(e.id))}:e)}),void 0,e=>Ai(e??`撤回所选消息失败,请重试`,`error`),t=>{let n=t.conversations.find(e=>e.id===P.id);return!!(n&&e.every(e=>!n.messages.some(t=>t.id===e&&t.delivery)))})||Ai(`连接断开,批量撤回没有生效,请重试`,`error`)},vo=e=>{Hi({type:`message.steer`,conversationId:P?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===P?.id?{...t,messages:VL(t.messages,e,0)}:t)}),void 0,void 0,t=>t.conversations.find(e=>e.id===P?.id)?.messages.find(t=>t.id===e)?.delivery===`sending`)||Ai(`连接断开,插到最前没有生效,请重试`,`error`)},yo=e=>{let t=P?.id;t&&(M.current?.readyState===WebSocket.OPEN?Hi({type:`message.interrupt`,conversationId:t,messageId:e},`interrupt:${t}:${e}`,e=>e,void 0,e=>Ai(e??`打断失败,请重试`,`error`),n=>{let r=n.conversations.find(e=>e.id===t)?.messages.find(t=>t.id===e);return!(!r||r.delivery)},3e4)||Ai(`正在打断,请稍候`,`info`):Ai(`连接断开,打断没有生效,请重试`,`error`))},bo=e=>{Hi({type:`message.sendQueued`,conversationId:P?.id??``,messageId:e},`send-queued:${e}`,e=>e,void 0,void 0,t=>!t.conversations.find(e=>e.id===P?.id)?.messages.find(t=>t.id===e)?.delivery)||Ai(`连接断开,发送没有生效,请重试`,`error`)},xo=(e,t)=>{Hi({type:`message.edit`,conversationId:P?.id??``,messageId:e,content:t},`edit:${e}`,n=>({...n,conversations:n.conversations.map(n=>n.id===P?.id?{...n,messages:n.messages.map(n=>n.id===e?{...n,content:t}:n)}:n)}))||Ai(`连接断开,修改没有生效,请重试`,`error`)},[L,R]=(0,F.useState)(),So=(e,t=!1)=>{if(!P||P.messagesLoaded===!1||L)return;let n=P.messages.find(t=>t.id===e);n&&(n&&Ut(e=>{let t=e[P.id]??{text:``,images:[],attachments:[],uploading:0};return t.text.trim()||t.images.length||t.attachments.length?e:{...e,[P.id]:{...t,text:n.content,images:n.images??[]}}}),Pt({conversationId:P.id,messageId:e,kind:t?`withdraw`:`revert`})),Vi({type:`message.revert`,conversationId:P.id,messageId:e,withdraw:t})?R(e):(Pt(void 0),Ai(`连接断开,回退未执行,请重试`,`error`))},[Co,wo]=(0,F.useState)(),To=(0,F.useRef)(void 0),Eo=(0,F.useRef)(0),Do=async(e,t)=>{let n=++Eo.current,r=await xx(t);n===Eo.current&&(clearTimeout(To.current),wo({id:e,kind:r?`copied`:`error`}),r||Ai(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中这条消息的文字复制`,`error`),To.current=setTimeout(()=>wo(void 0),2e3))};(0,F.useEffect)(()=>()=>{Eo.current+=1,clearTimeout(To.current)},[]);let[Oo,ko]=(0,F.useState)(),Ao=e=>{Oo||e.startsWith(`pending:`)||(cr(e),Vi({type:`conversation.fork`,conversationId:e})?ko(e):Ai(`连接断开,分叉没有执行,请重试`,`error`))},jo=new Map;for(let e of l.scheduledTasks??[])e.conversationId&&!jo.has(e.conversationId)&&jo.set(e.conversationId,e);let Mo=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-theme-open":`1`,title:`设置`,"aria-haspopup":`dialog`,"aria-expanded":$a,onClick:()=>{eo(!0),Vi({type:`catalog.fetchAll`}),Vi({type:`providers.fetch`})},children:[(0,I.jsx)(Zp,{name:`settings`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:`设置`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-help-open":`1`,title:`使用指南`,"aria-haspopup":`dialog`,"aria-expanded":to,onClick:()=>no(!0),children:[(0,I.jsx)(Zp,{name:`help`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:`使用指南`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,title:`检查 Super Pi 更新`,disabled:et!==`idle`||rt,onClick:async()=>{tt(`updating`);let e=!1;try{let t=await fetch(`/api/update-check`);if(!t.ok)throw Error(`check failed`);let n=await t.json();if(n.updating===!0)e=!0,it(!0),Ii(),Ai(`更新正在进行中,请等待它结束`,`info`);else if(n.needsRestart)Ai(`当前代码已更新,正在重启服务…`,`info`);else if(n.updateAvailable){if(!window.confirm(`发现新版本 v${n.latestVersion??``},是否立即更新并重启 Super Pi?`))Ai(`已取消更新`,`info`);else{if(!(await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({version:n.latestVersion})})).ok)throw Error(`update failed`);e=!0,Ai(`正在更新到 v${n.latestVersion} 并重启…`,`info`),Ii()}}else Ai(`当前已是最新版本`,`info`)}catch{Ai(`检查更新失败,请检查网络或服务日志`,`error`)}finally{e||tt(`idle`)}},children:[(0,I.jsx)(Zp,{name:`update`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:rt?`正在更新…`:et===`updating`?`正在检查更新…`:`检查更新`})]}),Qe?.needsRestart&&(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger restart-needed-trigger`,disabled:et!==`idle`||rt,title:`代码已更新:当前运行 v${Qe.runningVersion},磁盘版本 v${Qe.diskVersion}。点击复制重启命令 /super_pi restart`,onClick:async()=>{tt(`updating`);try{if(!(await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({restartOnly:!0})})).ok)throw Error(`update failed`);Ai(`正在重启 Super Pi 服务…`,`info`),Ii(`restart`)}catch{tt(`idle`),Ai(`更新启动失败,请检查服务日志`,`error`)}},children:[(0,I.jsx)(Zp,{name:`update`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:rt||et===`updating`?`正在更新并重启…`:`更新并重启服务`})]})]}),No={onOpenSession:e=>{lr(e),dt()},todos:l.todosByConversation?.[P?.id??``]??[],tasks:dz(P,l.backgroundTasks??[]),messages:P?.messages??[],execOutputs:pe.current,scheduledTasks:(l.scheduledTasks??[]).filter(e=>e.workspaceId===pr),scheduledCatalog:ia(Be,Ei),scheduledAgents:Je,notify:Ai,serverTimeZone:l.serverTimeZone,workspaceId:pr,workspaceLabel:Ei?.path,workspaceName:Ei?.name,conversationId:P?.id,cwd:mr,connected:f&&E&&!P?.id.startsWith(`pending:`),files:hr,onOpenFile:si,onOpenChanged:$r,onFileReference:ci,onFilesMoved:li,onSelectTab:kr,sendCommand:Vi,registerTerminalSink:be,terminalShell:l.terminalShell,sharedGit:gr},Po=gr.status?.detached?`游离 HEAD`:gr.status?.branch,z=gr.status&&new Set([...gr.status.staged,...gr.status.unstaged,...gr.status.untracked].map(e=>e.path)).size,Fo=gr.status&&(gr.status.ahead||gr.status.behind)?[gr.status.ahead?`↑`+gr.status.ahead:``,gr.status.behind?`↓`+gr.status.behind:``].filter(Boolean).join(` `):``,Io=()=>_t(e=>({...e,rightClosed:!0})),Lo=()=>_t(e=>({...e,leftClosed:!0})),Ro=Et?at:Pr;return(0,I.jsxs)(`main`,{className:`shell workbench-shell${Ro?` shell-rail-collapsed`:``} mobile-panel-${st}${ft?` mobile-drawer-open`:``}`,"data-rail-collapsed":Ro,"data-workbench-left-closed":!Et&&gt.leftClosed,"data-selected-workspace":v??``,style:{"--sidebar-width":`${bt.sidebar}px`,"--rail-col":Ro?void 0:`${bt.rail}px`},children:[!Et&&(0,I.jsx)(Qp,{side:`left`,views:Ar,unpinned:gt.unpinned,active:gt.leftClosed?void 0:Mr,onSelect:e=>Ir(e,!0),onSearch:()=>Ur(!0),children:Mo}),(0,I.jsxs)(`aside`,{className:`workbench-sessions`,id:`workbench-sessions`,"data-workbench-session-view":Fr?`shown`:`hidden`,children:[(0,I.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,I.jsx)(`button`,{className:`workspace-new`,onClick:()=>k(!0),children:`+ 添加工作区`}),P&&sr&&pi.length===1&&(0,I.jsx)(`button`,{type:`button`,className:`mobile-close-session`,onClick:()=>{vi(P.id),pt(!1)},children:`关闭当前标签`})]}),(0,I.jsx)(`div`,{className:`label label-desktop`,children:`工作区`}),(0,I.jsx)(`div`,{className:`label label-phone`,children:`会话`}),(0,I.jsx)(`nav`,{"aria-label":`工作区与会话`,children:l.workspaces.map(e=>{let t=l.conversations.filter(t=>t.workspaceId===e.id),n=t.filter(e=>!e.archivedAt),r=kI(n,gn,{manualRoots:Ce[e.id]}),i=r.filter(e=>e.depth===0).map(e=>e.conversation.id),a=t.filter(e=>e.archivedAt),o=kI(a,new Set),s=g[e.id]??!1,c=xe[e.id]??!0;return(0,I.jsxs)(`section`,{className:`workspace-group`,"data-workspace-group":e.id,"data-current-workspace":v===e.id,children:[(0,I.jsx)(`div`,{className:`workspace-header`,children:Wa(`workspace`,e.id)?(0,I.jsx)(BR,{initial:e.name,label:`重命名工作区 ${e.name}`,onCommit:t=>Ga(`workspace`,e.id,t),onClose:Ua}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`workspace-toggle`,"aria-expanded":!s,"aria-label":e.name,title:e.path,onContextMenu:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect();Rt({workspace:e,x:t.clientX||n.left+24,y:t.clientY||n.top+n.height})},onClick:()=>{let t=mn.find(t=>t.workspaceId===e.id)?.id;t&&t!==P?.id?lr(t):(y(e.id),t||(w.current++,d(void 0))),_(t=>({...t,[e.id]:!s}))},children:[(0,I.jsx)(`span`,{className:`chevron chevron-folder`,"aria-hidden":`true`,children:s?`▸`:`▾`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{onDoubleClick:()=>Ha(`workspace`,e.id),children:e.name}),(0,I.jsx)(`small`,{children:e.path})]})]}),(0,I.jsx)(`button`,{className:`workspace-add`,title:`在此工作区新建会话`,onClick:t=>{j.current=t.currentTarget,ee({workspaceId:e.id})},children:`+`}),(0,I.jsx)(`button`,{className:`workspace-settings`,title:`工作区设置(默认智能体 / 模型 / 思考强度)`,"aria-label":`工作区设置 ${e.name}`,onClick:()=>Ya(e.id),children:`⚙`})]})}),!s&&(r.length?r.map(({conversation:t,depth:r,childCount:a,isLastSibling:o})=>(0,I.jsxs)(`div`,{className:`conversation-row`,style:{"--tree-depth":r},"data-session-root":r===0?t.id:void 0,"data-session-dragging":Te?.conversationId===t.id?`true`:void 0,"data-session-drop":Te?.dropRootId===t.id?Te.dropAfter?`after`:`before`:void 0,onPointerDown:r===0?n=>ke(n,e.id,t.id,i):void 0,children:[a>0?(0,I.jsxs)(`button`,{type:`button`,className:`conversation-tree-toggle`,"data-tree-toggle":t.id,"aria-expanded":!gn.has(t.id),title:gn.has(t.id)?`展开 ${a} 个子会话`:`折叠 ${a} 个子会话`,"aria-label":gn.has(t.id)?`展开会话 ${t.title} 的 ${a} 个子会话`:`折叠会话 ${t.title} 的 ${a} 个子会话`,onClick:()=>oo(t.id,!gn.has(t.id)),children:[(0,I.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:gn.has(t.id)?`▸`:`▾`}),(0,I.jsx)(`small`,{children:a})]}):(0,I.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),Wa(`conversation`,t.id)?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(BR,{initial:t.title,label:`重命名会话 ${t.title}`,onCommit:e=>Ga(`conversation`,t.id,e),onClose:Ua}),(0,I.jsx)(`small`,{className:`conversation-time`,children:$L(t.updatedAt,fn)})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`conversation ${P?.id===t.id?`selected`:``}`,"data-conversation":t.id,"aria-current":P?.id===t.id?`true`:void 0,"data-tree-child":r>0?`true`:void 0,"data-tree-last":r>0&&o?`true`:void 0,title:r>0?`${t.title}(由「${n.find(e=>e.id===t.parentConversationId)?.title??`已不存在的会话`}」创建)`:t.title,"aria-label":`打开会话 ${t.title}${az(t,jo.get(t.id))}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.getBoundingClientRect();Bt({conversation:t,x:e.clientX||n.left+24,y:e.clientY||n.top+n.height})},onClick:()=>{t.id===Oe.current&&Date.now()-De.current<300||(lr(t.id),y(e.id),pt(!1))},onDoubleClick:()=>{ur(t.id)},children:[(0,I.jsx)(`i`,{className:`conversation-mark`,children:(0,I.jsx)(rz,{state:tz(t,$R(t,nt),ne.current[t.id],l.conversations)})}),(0,I.jsx)(`span`,{"data-conversation-title":t.id,onDoubleClick:e=>{e.stopPropagation(),Ha(`conversation`,t.id)},style:{flex:`0 1 auto`,minWidth:`3.5em`},children:t.title}),(0,I.jsx)(`span`,{className:`conversation-title-gap`,"aria-hidden":`true`,style:{marginLeft:`-8px`}}),nz(tz(t,$R(t,nt),ne.current[t.id],l.conversations),ez(t,l.conversations,ne.current[t.id])),iz(t,jo.get(t.id)),(0,I.jsx)(`small`,{children:$L(t.updatedAt,fn)})]}),(0,I.jsx)(`button`,{type:`button`,className:`conversation-fork`,"data-fork-conversation":t.id,"data-fork-state":Oo===t.id?`pending`:`idle`,disabled:!!Oo,title:`从此会话分叉出一个新会话`,"aria-label":`从会话 ${t.title} 分叉出一个新会话`,onClick:()=>Ao(t.id),children:`⑂`}),!(t.parentConversationId&&l.conversations.some(e=>e.id===t.parentConversationId))&&(0,I.jsx)(`button`,{className:`conversation-archive`,"data-archive-conversation":t.id,title:`归档整棵会话树`,"aria-label":`归档会话 ${t.title}`,onClick:()=>ao(t.id),children:`×`})]})]},t.id)):(0,I.jsx)(`div`,{className:`conversation-empty`,children:`暂无会话`})),!s&&a.length>0&&(0,I.jsxs)(`div`,{className:`archived-group`,"data-archived-count":a.length,children:[(0,I.jsxs)(`button`,{className:`archived-toggle`,title:c?`展开已归档会话`:`收起已归档会话`,"aria-expanded":!c,onClick:()=>Se(t=>({...t,[e.id]:!c})),children:[(0,I.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:c?`▸`:`▾`}),(0,I.jsxs)(`span`,{className:`archived-label`,children:[`已归档 (`,a.length,`)`]})]}),!c&&o.map(({conversation:e,depth:t,isLastSibling:n})=>{let r=eR(a,e.id).length-1,i=!!(e.parentConversationId&&l.conversations.some(t=>t.id===e.parentConversationId&&t.archivedAt));return(0,I.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,I.jsx)(`i`,{className:`conversation-mark`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{"data-archived-title":e.id,children:e.title}),iz(e,jo.get(e.id)),(0,I.jsx)(`small`,{children:tR(e.archivedAt)}),!i&&(0,I.jsx)(`button`,{className:`conversation-restore`,"data-restore-conversation":e.id,title:r?`恢复这个会话和它的 ${r} 个子孙会话`:`恢复为正常会话`,"aria-label":r?`恢复会话 ${e.title} 及其 ${r} 个子孙会话`:`恢复会话 ${e.title}`,onClick:()=>so(e.id),children:`↑`})]},e.id)})]}),!s&&(()=>{let t=l.warmSessions?.filter(t=>t.workspaceId===e.id)??[];return t.length?(0,I.jsxs)(`details`,{className:`archived-group`,"data-warm-sessions":e.id,children:[(0,I.jsx)(`summary`,{className:`archived-toggle`,children:(0,I.jsxs)(`span`,{className:`archived-label`,children:[`预热会话 (`,t.length,`)`]})}),t.map(e=>(0,I.jsxs)(`div`,{className:`conversation-archived`,"data-warm-session":e.id,children:[(0,I.jsx)(`span`,{title:e.title,children:e.title}),(0,I.jsx)(`button`,{type:`button`,className:`conversation-restore`,"aria-label":`移除预热会话 ${e.title}`,onClick:()=>{window.confirm(`移除预热会话「${e.title}」?`)&&!Vi({type:`conversation.warm.delete`,conversationId:e.id})&&Ai(`连接断开,未移除预热会话`,`error`)},children:`×`})]},e.id))]}):null})()]},e.id)})}),Et&&(0,I.jsx)(`footer`,{className:`workbench-mobile-utilities`,children:Mo})]}),!Et&&!gt.leftClosed&&Mr!==`sessions`&&(0,I.jsx)(mz,{...No,side:`left`,activeTab:Mr,collapsed:!1,onToggle:Lo,pinned:!gt.unpinned.includes(Mr),onArrange:Lr}),(Et||!gt.leftClosed)&&(0,I.jsx)($z,{side:`left`,width:bt.sidebar,min:bt.sidebarMin,max:bt.sidebarMax,label:`调整左侧栏宽度`,onWidth:xt}),(0,I.jsxs)(`section`,{className:`chat`,"data-main-view":dr,"data-main-view-kind":dr,children:[pi.length>0&&(0,I.jsx)(`div`,{className:`chat-tab-strip`,"data-chat-tab-strip":`1`,"data-session-count":ar.length,"data-file-count":hr.open.length,children:(0,I.jsx)(DT,{tabs:pi,prefix:`workspace-tab`,ariaLabel:`工作区标签页`,activeId:mi,onSelect:gi,onClose:yi,onActivate:_i,minWidth:120,maxWidth:320})}),(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`button`,{type:`button`,className:`mobile-drawer-toggle`,"data-mobile-drawer-toggle":`1`,"aria-label":`打开会话列表`,title:`会话列表`,"aria-expanded":ft,onClick:()=>pt(!0),children:`☰`}),(0,I.jsxs)(`div`,{className:`chat-head`,children:[(0,I.jsx)(`h1`,{children:P?.title??`准备开始`}),va.size>0?[...va].map(([e,t])=>(0,I.jsx)(`p`,{"data-role":`run-status`,"data-status-key":e,children:`扩展状态:${e?`${e} · `:``}${t}`},e)):(0,I.jsx)(`p`,{"data-role":`run-status`,children:P?.status===`running`?`Agent 正在工作`:P?.status===`awaiting_background`?`后台任务运行中`:`Pi runtime · Web 控制台`})]}),(0,I.jsxs)(`span`,{className:`chat-view chat-view-${dr}`,"data-main-view-indicator":dr,"data-main-view-kind":dr,title:dr===`file`?`中间主画面正在显示文件 ${hr.active?.path??``}`:dr===`diff`?`中间主画面正在显示 ${Kr??``} 的改动`:`中间主画面正在显示这个会话的消息流`,children:[(0,I.jsx)(`span`,{className:`chat-view-label`,children:`主区显示`}),(0,I.jsx)(`span`,{className:`chat-view-kind`,children:dr===`file`?`文件`:dr===`diff`?`改动`:`会话`}),dr===`file`&&hr.active&&(0,I.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":hr.active.name,children:hr.active.name}),dr===`diff`&&Kr&&(0,I.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":Kr,children:Kr})]}),(0,I.jsx)(`div`,{className:`badge`,"data-conversation-status":P?.status??`idle`,...On?{"data-reporting-status":On}:{},children:On===`awaiting_decision`?`等上面拍板`:XR(P)?YR[P?.status??`idle`]:On===`awaiting_subordinates`?`等待下级`:On===`pending_report`?`待汇报`:YR[P?.status??`idle`]}),(0,I.jsx)(`button`,{type:`button`,className:`mobile-tools-toggle`,"data-mobile-nav":`rail`,onClick:()=>{ct(`rail`),ot(!1)},children:`工具`})]}),m&&(0,I.jsxs)(`div`,{className:`error`,role:`alert`,"data-global-error":!0,children:[(0,I.jsx)(`span`,{title:fp(m),children:dp(m)}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`关闭错误提示`,title:`关闭错误提示`,onClick:()=>h(void 0),children:`×`})]}),P?.error&&(0,I.jsx)(`div`,{className:`error`,"data-role":`conversation-error`,title:fp(P.error),children:dp(P.error)}),P?.warning&&(0,I.jsxs)(`div`,{className:`warning`,role:`status`,"data-role":`conversation-warning`,title:fp(P.warning),children:[(0,I.jsx)(`span`,{children:P.warning}),(0,I.jsx)(`button`,{type:`button`,"data-role":`conversation-warning-continue`,title:`让模型接着把被截断的部分写完`,onClick:()=>Wi(P?.id??``),children:`继续写完`})]}),P?.modelNotice&&(0,I.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-model-notice`,children:P.modelNotice}),P?.agentNotice&&(0,I.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-agent-notice`,children:P.agentNotice}),ba&&(0,I.jsxs)(`div`,{className:`extui-title-note`,children:[`扩展建议标题:`,ba]}),Re.length>0&&(0,I.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,"data-toast-count":Re.length,children:Re.map(e=>(0,I.jsx)(`div`,{className:`toast toast-${e.kind}`,"data-toast-kind":e.kind,children:e.text},e.key))}),dr===`file`?(0,I.jsx)(`div`,{className:`chat-file-view`,"data-main-file-view":bi?.path,"data-file-view-kind":`editor`,children:bi?.view&&pr?(0,I.jsx)(nS,{workspaceId:pr,cwd:mr,path:bi.path,name:bi.name,kind:bi.view,content:bi.content,version:bi.etag,source:Oi,external:hr.external[bi.path],navigation:Di,sourceRequest:Wr?.path===bi.path&&Wr.workspaceId===pr?Wr.request:void 0},`${pr}:${mr}:${bi.path}`):Oi??(0,I.jsx)(`p`,{className:`rail-empty`,"data-main-file-empty":`1`,children:`没有选中的文件。`})}):dr===`diff`?(0,I.jsx)(`div`,{className:`chat-file-view`,"data-main-diff-view":Kr??``,"data-file-view-kind":`diff`,children:(0,I.jsx)(dT,{diff:ei.diff,loading:ei.loading,error:ei.error,bufferContent:ii,mode:ni,onMode:ri})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`messages`,ref:ae,"data-message-scroll-container":P?.id??``,onWheel:e=>{e.deltaY<0&&N.current[P?.id??``]?.followTail&&(fe.current=!0,Pn(e.currentTarget,!0))},onScroll:e=>{let t=e.currentTarget;t.dataset.programmaticScroll===`true`?delete t.dataset.programmaticScroll:Pn(t)},children:[(!P||!sr)&&(0,I.jsxs)(`div`,{className:`empty`,children:[(0,I.jsx)(`div`,{className:`orb`,children:`π`}),(0,I.jsx)(`h2`,{children:`开始一个新会话`}),l.workspaces.length===0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:`先创建一个工作区,再开始会话。`}),(0,I.jsx)(`button`,{onClick:()=>k(!0),children:`+ 新建工作区`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:l.workspaces.length===1&&An?`在「${An.name}」中创建会话,即可向 Super Pi 发送任务。`:`选择工作区即可开始会话,向 Super Pi 发送任务。`}),l.workspaces.length>1&&(0,I.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,I.jsx)(`label`,{htmlFor:`empty-workspace-choice`,children:`工作区:`}),(0,I.jsxs)(`select`,{id:`empty-workspace-choice`,"aria-label":`选择工作区`,value:An?.id,onChange:e=>{e.target.value===`__new__`?k(!0):y(e.target.value)},children:[l.workspaces.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,I.jsx)(`option`,{value:`__new__`,children:`+ 新建工作区…`})]})]}),An&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(hR,{workspaceId:An.id,value:jn,onChange:Mn}),(0,I.jsx)(`button`,{onClick:()=>io(An.id,jn),children:`新建会话`})]}),(0,I.jsx)(`span`,{className:`empty-secondary-action`,role:`button`,tabIndex:0,onClick:()=>k(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),k(!0))},children:`+ 新建工作区`})]})]}),P?.messagesLoaded===!1&&(0,I.jsx)(`p`,{role:`status`,"data-conversation-loading":`1`,children:`正在加载会话…`}),Oa.map(e=>{if(e.startsWith(`m:`)){let t=Ta.get(e.slice(2));if(!t)return null;let n=t.id===ka,i=t.role===`user`&&P?.status!==`running`&&P?.status!==`waiting`&&L!==t.id,a=i&&n&&!t.id.startsWith(`pending:`),o=i&&!n&&!!t.piEntryId,s=t.content?(0,I.jsx)(Px,{source:t.content,media:_n}):(0,I.jsx)(`span`,{className:`typing`,children:`正在思考`});if(t.source===`session-reminder`)return(0,I.jsx)(`article`,{className:`message message-reminder`,"data-transcript-key":e,"data-message-reminder":t.id,children:(0,I.jsxs)(`details`,{children:[(0,I.jsxs)(`summary`,{className:`reminder-header`,children:[(0,I.jsxs)(`span`,{className:`reminder-label`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,I.jsx)(`time`,{dateTime:t.createdAt,children:KL(t.createdAt)})]}),(0,I.jsx)(`div`,{className:`content`,children:s})]})},e);let c=t.toolCalls??[],l=Co?.id===t.id?Co.kind:void 0;if(t.role===`user`){let n=t.content||(t.images?.length?`[图片]`:``);return(0,I.jsxs)(`article`,{className:`message user`,"data-transcript-key":e,children:[(0,I.jsxs)(`div`,{className:`message-body`,children:[(0,I.jsxs)(`div`,{className:`bubble`,children:[(0,I.jsxs)(`div`,{className:`meta`,children:[Ne,(0,I.jsx)(`time`,{children:KL(t.createdAt)})]}),t.images&&t.images.length>0&&(0,I.jsx)(`div`,{className:`message-images`,"data-message-images":`1`,children:t.images.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`message-image-btn`,"data-message-image-id":e.id,onClick:()=>Qt({url:`/api/upload/${encodeURIComponent(P?.id??``)}/${encodeURIComponent(e.id)}`,name:e.name,bytes:e.bytes}),title:e.name?`查看大图:${e.name}`:`查看大图`,children:(0,I.jsx)(`img`,{src:`/api/upload/${encodeURIComponent(P?.id??``)}/${encodeURIComponent(e.id)}`,alt:e.name||`图片`,className:`message-image-thumb`,loading:`lazy`})},e.id))}),(0,I.jsx)(`div`,{className:`content`,children:s})]}),t.attachments&&t.attachments.length>0&&(0,I.jsx)(`div`,{className:`message-attachments`,"data-message-attachments":`1`,children:t.attachments.map(e=>{let n=`att:${t.id}:${e.kind}:${e.id}`,r=kt[n]??!1;return(0,I.jsxs)(`div`,{className:`message-attachment`,"data-message-attachment":e.kind,children:[(0,I.jsxs)(`button`,{type:`button`,className:`message-attachment-head`,"data-message-attachment-toggle":e.id,"aria-expanded":r,onClick:()=>At(e=>({...e,[n]:!r})),children:[(0,I.jsx)(`span`,{className:`message-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,I.jsx)(`span`,{className:`message-attachment-label`,children:`技能`}),(0,I.jsx)(`span`,{className:`message-attachment-name`,title:e.name,children:e.name}),(0,I.jsx)(`span`,{className:`message-attachment-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`})]}),r&&(0,I.jsx)(`pre`,{className:`message-attachment-body`,"data-message-attachment-body":e.id,children:e.content})]},n)})}),(0,I.jsxs)(`div`,{className:`message-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":l,"aria-label":`复制这条消息:${n}`,onClick:()=>Do(t.id,n),children:l===`copied`?`已复制`:l===`error`?`复制失败`:`复制`}),a&&(0,I.jsx)(`button`,{type:`button`,className:`message-revert`,"data-withdraw-message":t.id,title:`撤回并编辑:删除这条消息并将文字恢复到输入框继续编辑`,onClick:()=>So(t.id,!0),children:`撤回`}),o&&(0,I.jsx)(`button`,{type:`button`,className:`message-revert`,"data-revert-message":t.id,title:`回退到这里:删除后续全部内容(Pi 的记录和这里的历史一起清掉,不会新建会话,也不动任何代码文件)`,onClick:()=>So(t.id),children:`回退`})]})]}),(0,I.jsx)(`div`,{className:`avatar`,title:Ne,children:Ne})]},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(`
360
+ 如需本地计算,声明 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、访问地址、文件清单和验证结果。`);d(e),window.setTimeout(()=>d(!1),1800)};(0,F.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let oe=(0,F.useMemo)(()=>[...t.map(e=>({id:e.id,name:e.name,glyph:e.glyph})),...n.map(e=>({id:e.id,name:e.name,glyph:bI(e)}))],[t,n]);(0,F.useEffect)(()=>{if(!j)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),M(void 0);return}if(LI(e.key)||KI(e.target))return;e.preventDefault(),e.stopPropagation();let t=j;if(M(void 0),e.key===`Delete`||e.key===`Backspace`){fL.clearShortcut(t),te(void 0);return}let n=RI(e);if(!n){te(`没有认出这个按键,换一个试试。`);return}let i=WI(n);if(!i.ok){te(i.reason);return}let a=XI(r,n,t);if(a){let e=oe.find(e=>e.id===a)?.name;te(e?`这个组合键已经被「${e}」占用了,换一个键。`:`这个组合键已经被另一个工具占用了,换一个键。`)}else fL.setShortcut(t,n),te(void 0)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[j,r,oe]);let se=e=>{ie(aL(e,window.innerWidth,window.innerHeight))},ce=e=>{iL(e)},le=()=>{ie(void 0),iL(void 0)},ue=(0,F.useRef)(!1),de=n.map(e=>e.slug).filter(e=>typeof e==`string`),fe=e=>{p(void 0),h(void 0),k(void 0),D({tool:e,name:SL({slug:e.slug??`tool`})})},pe=async(e,t)=>{p(void 0),h(void 0),k(void 0);let n=CL(t);if(!n.ok)k(n.reason);else try{let t=await fetch(`/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),h(r.skipped?.length?`已导出「${e.name}」,但有 ${r.skipped.length} 个文件没有包含:${r.skipped.join(`、`)}。`:`已导出「${e.name}」。`)}catch(e){p(`导出失败:${dp(e)}`)}finally{D(void 0)}},me=async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;p(void 0),h(void 0),x(void 0);let n=yL(await t.text(),t.name);n.ok?(_({filename:t.name,bundle:n.bundle,unnamedFormat:n.unnamedFormat}),y(de.includes(n.bundle.slug)?xL(n.bundle.slug,de):n.bundle.slug),C(n.bundle.files[0]?.path)):p(n.reason)},he=()=>{_(void 0),y(``),x(void 0),C(void 0)},ge=async()=>{if(!g)return;x(void 0);let e=bL(v);if(!e.ok)x(e.reason);else if(de.includes(e.slug))x(`本机已经有 slug「${e.slug}」的工具,换一个名字再导入。`);else{T(!0);try{let t=await fetch(`/api/tools`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(OL(g.bundle,e.slug))}),n=await t.json();if(!t.ok||!n.id)throw Error(n.error??`HTTP ${t.status}`);await pL(),h(`已导入「${g.bundle.name}」,它现在出现在工具栏里,所有工作区都能用。`),he()}catch(e){p(`导入失败:${dp(e)}`)}finally{T(!1)}}};(0,F.useEffect)(()=>{E&&ee.current?.scrollIntoView({block:`center`})},[E]);let _e=()=>{let e=lE(i);e.ok?t.length>=32?l(`工具最多 32 个,先删掉一个再加。`):(fL.setTools([...t,{id:pE(`link`,t.map(e=>e.id)),kind:`link`,name:o.trim()||xz(e.url),glyph:`↗`,url:e.url}]),a(``),s(``),l(void 0)):l(e.reason)},ve=re?{width:`${re.width}px`,height:`${re.height}px`,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 32px)`}:void 0;return(0,pa.createPortal)((0,I.jsxs)(`div`,{className:`tool-overlay`,"data-tool-settings-overlay":`1`,onPointerDown:()=>{ue.current=!1},onClick:t=>{ue.current?ue.current=!1:t.target===t.currentTarget&&e()},children:[(0,I.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-settings-title`,"data-tool-settings":`1`,ref:ne,style:ve,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsx)(`h2`,{className:`tool-dialog-title`,id:`tool-settings-title`,children:`⚙ 工具设置`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-settings-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭工具设置`,onClick:e,children:`✕`})]}),(0,I.jsx)(`div`,{className:`tool-dialog-body`,children:g?(0,I.jsx)(bz,{pending:g,slugDraft:v,slugError:b,preview:S,busy:w,onSlugChange:e=>{y(e),x(void 0)},onPreviewChange:C,onCancel:he,onConfirm:()=>void ge()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`tool-prompt-card`,children:[(0,I.jsx)(`strong`,{children:`给 Agent 开发新工具`}),(0,I.jsx)(`p`,{className:`tool-hint`,children:`工具会挂载到 Super Pi 的统一 HTTP 服务,不需要再启动独立服务器。`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-link-copy-prompt`,"data-tool-development-prompt":`1`,onClick:()=>void ae(),children:u?`已复制`:`复制工具开发 Prompt`})]}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`从预置列表添加`})}),(0,I.jsx)(`div`,{className:`tool-presets`,"data-tool-presets":rE.length,children:rE.map(e=>{let n=t.some(t=>t.kind===e.kind);return(0,I.jsxs)(`div`,{className:`tool-preset`,"data-tool-preset":e.kind,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.blurb})]}),(0,I.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:()=>fL.setTools(mE(t,e.kind)),children:n?`已添加`:`添加`})]},e.kind)})}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`添加网址工具`})}),(0,I.jsx)(`p`,{className:`tool-hint`,children:`填一个网址,它会变成一个图标;点开后在弹窗里用按钮在新标签页打开。网址只接受 http / https / mailto。`}),(0,I.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,I.jsx)(`input`,{className:`tool-input`,"data-tool-url-name":`1`,value:o,maxLength:40,placeholder:`名称(可留空,默认用域名)`,"aria-label":`工具名称(可选)`,onChange:e=>s(e.target.value)}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-url-add":`1`,disabled:!i.trim(),onClick:_e,children:`添加网址工具`}),c&&(0,I.jsx)(`p`,{className:`tool-error`,"data-tool-error":`1`,role:`alert`,children:c}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-scope-note":`1`,children:[`能自定义到哪:从上面挑预置工具,或自己填一个网址。`,(0,I.jsx)(`b`,{children:`没有开放「写一段脚本来执行」这一档`}),`——它在浏览器里等同于任意代码执行,会拿着本应用的权限跑。计算器是手写的算术解析器,不含 eval,也认不出变量名。`]}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`快捷键`})}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-shortcut-hint":`1`,children:[`给每个工具绑一个组合键,按下就直接打开它,不用先找到右侧栏。`,(0,I.jsx)(`b`,{children:`弹窗打开时快捷键不生效`}),`——模态弹窗期间键盘归它自己,关掉之后再按。`]}),(0,I.jsx)(`div`,{className:`tool-shortcuts`,"data-tool-shortcut-count":oe.length,children:oe.map(e=>(0,I.jsxs)(`div`,{className:`tool-shortcut-row`,"data-tool-shortcut-row":e.id,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:e.glyph}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:r[e.id]?`按 ${BI(r[e.id])} 打开`:`还没有快捷键`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-shortcut-set`,"data-tool-shortcut-set":e.id,"data-tool-shortcut-capturing":j===e.id?`1`:void 0,"aria-pressed":j===e.id,title:j===e.id?`按下想用的组合键(Esc 取消,Delete 清除)`:`点一下,然后按下想用的组合键`,onClick:()=>{te(void 0),M(j===e.id?void 0:e.id)},children:j===e.id?`按下组合键…`:r[e.id]?BI(r[e.id]):`未设置`}),r[e.id]&&(0,I.jsx)(`button`,{type:`button`,className:`tool-shortcut-clear`,"data-tool-shortcut-clear":e.id,title:`清除${e.name}的快捷键`,"aria-label":`清除${e.name}的快捷键`,onClick:()=>{fL.clearShortcut(e.id),te(void 0),M(void 0)},children:`清除`})]},e.id))}),N&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-shortcut-error":`1`,children:N}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsxs)(`h2`,{className:`rail-section-title`,children:[`已安装的全局工具(`,n.length,`)`]})}),n.length===0?(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-mounted-empty":`1`,children:`还没有通过 tool_register 注册的工具。上面复制那段 Prompt,让 Agent 写一个。`}):(0,I.jsx)(`div`,{className:`tool-presets`,"data-tool-mounted-list":n.length,children:n.map(e=>{let t=EL(e.environmentState);return(0,I.jsxs)(`div`,{className:`tool-share-row`,"data-tool-share-row":e.id,children:[(0,I.jsx)(vI,{className:`tool-preset-glyph`,glyph:bI(e)}),(0,I.jsxs)(`span`,{className:`tool-preset-text`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.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,I.jsx)(`small`,{"data-tool-model":`1`,children:`⚠ 会调用模型`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export":e.id,title:`导出${e.name},得到一个可以发给别人导入的文件`,"aria-label":`导出${e.name}`,onClick:()=>fe(e),children:`导出`})]},e.id)})}),E&&(0,I.jsxs)(`div`,{className:`tool-share-review`,ref:ee,"data-tool-export-name":`1`,children:[(0,I.jsxs)(`h3`,{className:`tool-share-title`,children:[`导出「`,E.tool.name,`」`]}),(0,I.jsxs)(`label`,{className:`tool-hint`,children:[`文件名(发给别人的就是这个文件)`,(0,I.jsx)(`input`,{className:`tool-input`,value:E.name,"aria-label":`导出文件名`,"data-tool-export-input":`1`,onChange:e=>D({...E,name:e.target.value})})]}),O&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-export-name-error":`1`,children:O}),(0,I.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-export-cancel":`1`,onClick:()=>{D(void 0),k(void 0)},children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-export-confirm":`1`,onClick:()=>void pe(E.tool,E.name),children:`导出`})]})]}),m&&(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-share-notice":`1`,children:m}),f&&(0,I.jsx)(`p`,{className:`tool-error`,"data-tool-share-error":`1`,role:`alert`,children:f}),(0,I.jsx)(`div`,{className:`rail-section-head`,children:(0,I.jsx)(`h2`,{className:`rail-section-title`,children:`从文件导入`})}),(0,I.jsxs)(`p`,{className:`tool-hint`,children:[`收到别人分享的工具文件(`,(0,I.jsx)(`code`,{children:hL}),`)?导入后它出现在工具栏里,所有工作区都能用。`,(0,I.jsx)(`b`,{children:`导入前会先给你看这个包里有什么。`})]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-pick":`1`,onClick:()=>A.current?.click(),children:`选择文件…`}),(0,I.jsx)(`input`,{ref:A,type:`file`,accept:`.json,application/json`,style:{display:`none`},"data-tool-import-input":`1`,onChange:e=>void me(e)})]})})]}),(0,I.jsx)(vz,{targetRef:ne,onResize:se,onCommit:ce,onDragEnd:()=>{ue.current=!0},onReset:le})]}),document.body)}var _z=18;function vz({targetRef:e,onResize:t,onCommit:n,onDragEnd:r,onReset:i}){let[a,o]=(0,F.useState)(),s=(0,F.useRef)(void 0);return(0,F.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{let e=t.getBoundingClientRect();o({left:e.right-_z,top:e.bottom-_z})};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,I.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=aL({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??QI.width,l=o?.height??QI.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=aL({width:c,height:l},window.innerWidth,window.innerHeight);s.current=u,t(u),n(u)},onClick:e=>e.stopPropagation()})}function yz(){let{tools:e,mountedTools:t,openToolId:n,settingsOpen:r,shortcuts:i}=dL(),a=e.find(e=>e.id===n),o=t.find(e=>e.id===n);return(0,F.useEffect)(()=>{let n=n=>{if(!r&&!document.querySelector(`[aria-modal="true"]`)&&!(n.isComposing||n.defaultPrevented)){for(let[r,a]of Object.entries(i))if(qI(a,n)&&(e.some(e=>e.id===r)||t.some(e=>e.id===r))){n.preventDefault(),fL.openTool(r);return}}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[i,e,t,r]),(0,F.useEffect)(()=>{pL();let e=()=>{pL()};return window.addEventListener(`super-pi-tools-updated`,e),()=>window.removeEventListener(`super-pi-tools-updated`,e)},[]),(0,F.useEffect)(()=>{fL.persistTools()},[]),(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsx)(gz,{onClose:()=>fL.closeSettings()}),a&&(0,I.jsx)(Sz,{tool:a,onClose:()=>fL.closeTool()}),o&&(0,I.jsx)(Az,{tool:o,onClose:()=>fL.closeTool()})]})}function bz({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=TL(l),f=wL(l),p=l.files.find(e=>e.path===r)??l.files[0];return(0,I.jsxs)(`div`,{className:`tool-share-review`,"data-tool-import-review":`1`,children:[(0,I.jsx)(`h3`,{className:`tool-share-title`,"data-tool-import-name":`1`,children:l.name}),l.description&&(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-import-desc":`1`,children:l.description}),e.unnamedFormat&&(0,I.jsx)(`p`,{className:`tool-import-note`,"data-tool-import-unbranded":`1`,children:`这个文件没有 Super Pi 的工具标记,已按内容形状读取——粘出来的 tool_register 参数也认。`}),(0,I.jsxs)(`p`,{className:`tool-hint`,"data-tool-import-files":`1`,children:[l.files.length,` 个文件 · 共 `,DL(u)]}),(0,I.jsx)(`p`,{className:`tool-hint`,"data-tool-import-paths":`1`,children:l.files.map(e=>e.path).join(` · `)}),l.script&&(0,I.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-script":l.script.path,children:[(0,I.jsxs)(`b`,{children:[`⚠ 含 Python 脚本 `,l.script.path]}),(0,I.jsx)(`br`,{}),`导入后运行这个工具时,这段代码会在本机上执行,权限和你自己的 Python 一样(能读你的文件、能联网)。 可以先展开下面的文件列表把它读完。`]}),(0,I.jsxs)(`p`,{className:d.tone===`warn`?`tool-import-warn`:`tool-import-note`,"data-tool-import-env":d.tone,children:[(0,I.jsxs)(`b`,{children:[d.tone===`warn`?`⚠ `:`✓ `,d.text]}),l.environment?.fingerprint?.python&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`br`,{}),`导出方环境:Python `,l.environment.fingerprint.python,` · `,l.environment.fingerprint.platform||`未知平台`,`。版本对不上时会标出来,但不会拦住你运行。`]})]}),f&&(0,I.jsxs)(`p`,{className:`tool-import-warn`,"data-tool-import-model":`1`,children:[(0,I.jsx)(`b`,{children:`⚠ 这个工具可以调用模型`}),(0,I.jsx)(`br`,{}),f.text,`。模型由 Super Pi 通过 Pi 调用(凭据和模型选择都在 Super Pi 这边),工具只拿到文字。`]}),(0,I.jsxs)(`details`,{className:`tool-import-files`,"data-tool-import-filebox":l.files.length,children:[(0,I.jsxs)(`summary`,{children:[`查看文件(`,l.files.length,`)`]}),(0,I.jsx)(`div`,{className:`tool-share-tabs`,children:l.files.map(e=>(0,I.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,I.jsx)(`pre`,{className:`tool-import-code`,"data-tool-import-code":p?.path,children:p?.content??``})]}),(0,I.jsxs)(`label`,{className:`tool-hint`,"data-tool-import-slug":`1`,children:[`导入后的 slug(工具的短名字,也是它在磁盘上的目录名)`,(0,I.jsx)(`input`,{className:`tool-input`,value:t,"aria-label":`导入后的 slug`,onChange:e=>a(e.target.value)})]}),n&&(0,I.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-import-slug-error":`1`,children:n}),(0,I.jsxs)(`div`,{className:`tool-share-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`tool-preset-add`,"data-tool-import-cancel":`1`,onClick:s,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,className:`tool-url-add`,"data-tool-import-confirm":`1`,disabled:i,onClick:c,children:i?`导入中…`:`导入`})]})]})}function xz(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 Sz({tool:e,onClose:t}){return(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay`,"data-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tool-dialog-title`,"data-tool-dialog":e.id,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsxs)(`h2`,{className:`tool-dialog-title`,id:`tool-dialog-title`,children:[(0,I.jsx)(vI,{className:`tool-dialog-glyph`,glyph:e.glyph}),e.name]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-tool-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭${e.name}`,onClick:t,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`tool-dialog-body`,children:[e.kind===`calculator`&&(0,I.jsx)(wz,{}),e.kind===`timestamp`&&(0,I.jsx)(Tz,{}),e.kind===`link`&&(0,I.jsx)(Ez,{tool:e})]})]})}),document.body)}function Cz({image:e,onClose:t}){return(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,pa.createPortal)((0,I.jsx)(`div`,{className:`lightbox-overlay`,"data-lightbox-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`lightbox-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`lightbox-title`,"data-lightbox-dialog":`1`,children:[(0,I.jsxs)(`div`,{className:`lightbox-head`,children:[(0,I.jsx)(`h2`,{className:`lightbox-title`,id:`lightbox-title`,children:e.name||`图片大图`}),(0,I.jsx)(`button`,{type:`button`,className:`lightbox-close`,"data-lightbox-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭大图`,onClick:t,children:`✕`})]}),(0,I.jsx)(`div`,{className:`lightbox-body`,children:(0,I.jsx)(`img`,{src:e.url,alt:e.name||`图片大图`,className:`lightbox-image`})})]})}),document.body)}function wz(){let[e,t]=(0,F.useState)(`12 * (3 + 4)`),n=OE(e),r=e=>{t(t=>t+e)};return(0,I.jsxs)(`div`,{className:`tool-calc`,"data-tool-calc":`1`,children:[(0,I.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,I.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,I.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,I.jsx)(`p`,{className:`tool-calc-result`,"data-calc-result":`1`,"data-calc-value":String(n.value),children:kE(n.value)}):(0,I.jsx)(`p`,{className:`tool-calc-error`,"data-calc-error":`1`,role:`alert`,children:n.reason})]})}function Tz(){let[e,t]=(0,F.useState)(``),n=AE(e),r=n.ok?ME(n.ms):null;return(0,I.jsxs)(`div`,{className:`tool-stamp`,"data-tool-stamp":`1`,children:[(0,I.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,I.jsxs)(`dl`,{className:`tool-stamp-out`,"data-stamp-result":`1`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`本地时间`}),(0,I.jsx)(`dd`,{"data-stamp-local":`1`,children:r.local})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`ISO(UTC)`}),(0,I.jsx)(`dd`,{"data-stamp-iso":`1`,children:r.iso})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`秒`}),(0,I.jsx)(`dd`,{"data-stamp-seconds":`1`,children:r.seconds})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`毫秒`}),(0,I.jsx)(`dd`,{"data-stamp-ms":`1`,children:r.milliseconds})]})]}):(0,I.jsx)(`p`,{className:`tool-stamp-error`,"data-stamp-error":`1`,role:`alert`,children:n.ok?`这个日期无法显示。`:n.reason})]})}function Ez({tool:e}){let[t,n]=(0,F.useState)(!1),r=async()=>{let e=await xx(`请为 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,I.jsxs)(`div`,{className:`tool-link`,"data-tool-link":e.id,children:[(0,I.jsx)(`p`,{className:`tool-hint`,children:`这是旧版外部网页链接;新工具由 Super Pi 统一托管,并可选绑定受控 Python 脚本。`}),(0,I.jsx)(`code`,{className:`tool-link-url`,"data-tool-link-url":e.id,children:e.url}),(0,I.jsxs)(`div`,{className:`tool-link-actions`,children:[(0,I.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,I.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,I.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 Dz=`(max-width: 1100px)`,Oz=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function kz(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 Az({tool:e,onClose:t}){(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let n=(0,F.useMemo)(()=>kz(e.id),[e.id]);return(0,pa.createPortal)((0,I.jsx)(`div`,{className:`tool-overlay`,"data-mounted-tool-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,I.jsxs)(`div`,{className:`tool-dialog`,"data-mounted-tool-dialog":e.id,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,I.jsxs)(`h2`,{className:`tool-dialog-title`,children:[(0,I.jsx)(vI,{className:`tool-dialog-glyph`,glyph:bI(e)}),e.name]}),(0,I.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,onClick:t,children:`✕`})]}),(0,I.jsx)(`div`,{className:`tool-dialog-body`,children:(0,I.jsx)(`iframe`,{className:`tool-link-frame`,src:`/tools/${encodeURIComponent(e.id)}/#super-pi-owner=${n}`,title:e.name,sandbox:`allow-forms allow-modals allow-popups allow-scripts`,referrerPolicy:`no-referrer`})})]})}),document.body)}function jz(e,t,n){let r=Math.max(0,Math.round(n)-480),i=Oz(520,180,Math.max(180,r-240)),a=Oz(Math.round(e),180,i),o=Oz(640,240,Math.max(240,r-a));return{sidebar:a,rail:Oz(Math.round(t),240,o),sidebarMin:180,sidebarMax:i,railMin:240,railMax:o,sumCap:r}}var Mz=`super-pi.rail-widths.v1`,Nz=`super-pi.reader-state.v1`,Pz=`super-pi.folded-groups.v1`;function Fz(){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 Iz(e){try{typeof window<`u`&&window.localStorage.setItem(Pz,JSON.stringify(e))}catch{}}var Lz=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!==``):[]},Rz=6,zz=400,Bz=32,Vz=48,Hz=e=>{e.dataset.programmaticScroll=`true`,window.setTimeout(()=>{delete e.dataset.programmaticScroll},0)};function Uz(e,t,n=!1,r=!1){let i=e.scrollHeight-e.clientHeight-e.scrollTop,a=n?!1:r?!0:t.followTail?i<=Vz:i<=Bz,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 Wz(){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 Gz(e){try{typeof window<`u`&&window.localStorage.setItem(Nz,JSON.stringify(e))}catch{}}var Kz=`super-pi.session-tabs.v1`;function qz(e,t){if(!t||e.has(t))return e;let n=new Set(e);return n.add(t),n}function Jz(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 Yz(){try{if(typeof window>`u`)return{ids:[]};let e=JSON.parse(window.sessionStorage.getItem(`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;return{ids:n,activeId:a,previewId:i===a?i:void 0,touched:r,emptied:n.length===0&&(t.emptied===!0||!!i)}}catch{return{ids:[]}}}function Xz(e,t){try{if(typeof window>`u`)return;let{ids:n,previewId:r,touched:i,emptied:a}=e;window.sessionStorage.setItem(Kz,JSON.stringify({ids:n,...t&&n.includes(t)?{activeId:t}:{},...r&&n.includes(r)?{previewId:r}:{},...i.size?{touched:[...i]}:{},...a?{emptied:a}:{}}))}catch{}}function Zz(){try{if(typeof window>`u`)return{};let e=window.localStorage.getItem(Mz);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 Qz(e){try{if(typeof window>`u`)return;window.localStorage.setItem(Mz,JSON.stringify(e))}catch{}}function $z({side:e,width:t,min:n,max:r,label:i,onWidth:a}){let[o,s]=(0,F.useState)(!1),c=e=>e.shiftKey?64:16;return(0,I.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(Oz(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(Oz(e===`left`?t-o:t+o,n,r))):i.key===`ArrowRight`?(i.preventDefault(),a(Oz(e===`left`?t+o:t-o,n,r))):i.key===`Home`?(i.preventDefault(),a(n)):i.key===`End`&&(i.preventDefault(),a(r))}})}var eB=`super-pi.composer-height.v1`,tB=148,nB=.55,rB=()=>Math.max(tB,Math.round((typeof window>`u`?800:window.innerHeight)*nB)),iB=e=>{let t=Number.isFinite(e)?e:tB;return Math.round(Math.min(rB(),Math.max(tB,t)))},aB=()=>{try{let e=window.localStorage.getItem(eB);return e===null?tB:iB(Number(e))}catch{return tB}};function oB({height:e,onHeight:t}){let[n,r]=(0,F.useState)(!1),i=e=>e.shiftKey?64:16,a=rB();return(0,I.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":tB,"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=iB(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(iB(e+r))):n.key===`ArrowDown`?(n.preventDefault(),t(iB(e-r))):n.key===`Home`?(n.preventDefault(),t(tB)):n.key===`End`?(n.preventDefault(),t(a)):n.key===`PageUp`?(n.preventDefault(),t(iB(e+96))):n.key===`PageDown`&&(n.preventDefault(),t(iB(e-96)))}})}function sB(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 e[0]}function cB(){let[e,t]=(0,F.useState)(zL),n=(0,F.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return _e(n,t)})},[]),[r,i]=(0,F.useState)(()=>sw().map(e=>{let t=new Date().toISOString();return{id:e.clientId,key:`send:${e.conversationId}:${e.clientId}`,retry:!0,command:{...e},apply:n=>uw(n,e,t),accepted:t=>!!t.conversations.find(t=>t.id===e.conversationId)?.messages.some(t=>t.id===e.clientId)}})),a=(0,F.useRef)(r),o=(0,F.useRef)(null);o.current||=Wz();let s=(0,F.useRef)(null);s.current||=Yz();let c=s.current,l=r.reduce((e,t)=>t.apply(e),e),[u,d]=(0,F.useState)(s.current.activeId??o.current.activeId),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(),[g,_]=(0,F.useState)(()=>Fz().workspaces??{}),[v,y]=(0,F.useState)(o.current.workspaceId),[b,x]=(0,F.useState)(()=>({ids:c.ids,previewId:c.previewId,touched:new Set(c.touched??[]),emptied:c.emptied})),S=b.ids,C=b.previewId,w=(0,F.useRef)(0),T=b.emptied===!0,[E,D]=(0,F.useState)(!1),[O,k]=(0,F.useState)(!1),[A,ee]=(0,F.useState)(),j=(0,F.useRef)(null),M=(0,F.useRef)(void 0),N=(0,F.useRef)(o.current.conversations),te=(0,F.useRef)(S);te.current=S;let ne=(0,F.useRef)(o.current.readAt??{}),[re,ie]=(0,F.useState)(0),ae=(0,F.useRef)(null),oe=(0,F.useRef)(null),se=(0,F.useRef)(void 0),ce=(0,F.useRef)(!1),le=(0,F.useRef)(!0),[ue,de]=(0,F.useState)({followTail:!0,scrollTop:0}),fe=(0,F.useRef)(!1),pe=(0,F.useRef)(new Map),me=(0,F.useRef)(void 0),he=(0,F.useRef)([]),ge=(0,F.useRef)(void 0),_e=(0,F.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:GL(t.thinkingBlocks,e.thinkingBlocks)}})}})}},[]),ve=(0,F.useCallback)(()=>{if(ge.current!==void 0&&(cancelAnimationFrame(ge.current),ge.current=void 0),!he.current.length)return;let e=he.current;he.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)}n(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=WL(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}})}))},[]),ye=(0,F.useCallback)(e=>{let t=he.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),ge.current===void 0&&(ge.current=requestAnimationFrame(ve))},[ve]),be=(0,F.useCallback)(e=>{me.current=e},[]),[xe,Se]=(0,F.useState)(()=>Fz().archived??{});(0,F.useEffect)(()=>{Iz({workspaces:g,archived:xe})},[g,xe]);let[Ce,we]=(0,F.useState)(()=>DI());(0,F.useEffect)(()=>{OI(Ce)},[Ce]);let[Te,Ee]=(0,F.useState)(),De=(0,F.useRef)(0),Oe=(0,F.useRef)(``),ke=(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=()=>Ee(e=>e&&e.dropRootId===u&&e.dropAfter===d?e:{workspaceId:t,conversationId:n,dropRootId:u,dropAfter:d}),m=()=>{s||(s=!0,l=Lz(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)<Rz)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);we(e=>({...e,[t]:TI(r,n,i)})),De.current=Date.now(),Oe.current=n}Ee(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,zz))},[Ae,je]=(0,F.useState)(()=>{if(typeof window>`u`)return``;try{return window.localStorage.getItem(`super-pi.user-nickname`)??``}catch{return``}}),Me=e=>{let t=e.slice(0,24);je(t);try{window.localStorage.setItem(`super-pi.user-nickname`,t)}catch{}},Ne=Ae.trim()||`你`,[Pe,Fe]=(0,F.useState)(),[Ie,Le]=(0,F.useState)([]),[Re,ze]=(0,F.useState)([]),[Be,Ve]=(0,F.useState)(),[He,Ue]=(0,F.useState)(),[We,Ge]=(0,F.useState)([]),[Ke,qe]=(0,F.useState)([]),[Je,Ye]=(0,F.useState)(),[Xe,Ze]=(0,F.useState)(),[Qe,$e]=(0,F.useState)(),[et,tt]=(0,F.useState)(`idle`),nt=(0,F.useMemo)(()=>Ie.filter(e=>e.request.blocking),[Ie]),[rt,it]=(0,F.useState)(!1),[at,ot]=(0,F.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1100px)`).matches),[st,ct]=(0,F.useState)(`chat`),[lt,ut]=(0,F.useState)(!1),dt=(0,F.useCallback)(()=>{ct(`chat`),window.matchMedia(`(max-width: 700px)`).matches&&ot(!0)},[]),[ft,pt]=(0,F.useState)(!1),[mt,ht]=(0,F.useState)(()=>typeof window>`u`?1440:window.innerWidth);(0,F.useEffect)(()=>{let e=()=>ht(window.innerWidth);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]);let[gt,_t]=(0,F.useState)(Jp);(0,F.useEffect)(()=>Yp(gt),[gt]);let[vt,yt]=(0,F.useState)(Zz),bt=jz(vt.sidebar??270,vt.rail??320,mt>1100?mt-80:mt);(0,F.useEffect)(()=>{Qz({sidebar:vt.sidebar??270,rail:vt.rail??320})},[vt.sidebar,vt.rail]);let xt=e=>yt(t=>({...t,sidebar:e})),St=e=>yt(t=>({...t,rail:e})),[Ct,wt]=(0,F.useState)(null);(0,F.useEffect)(()=>{wt(aB())},[]),(0,F.useEffect)(()=>{Ct!==null&&document.documentElement.style.setProperty(`--composer-height`,`${Ct}px`)},[Ct]);let Tt=e=>{let t=iB(e);wt(t);try{window.localStorage.setItem(eB,String(t))}catch{}};(0,F.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(Dz),t=e=>{e.matches&&ot(!0)};return e.addEventListener(`change`,t),e.matches&&ot(!0),()=>e.removeEventListener(`change`,t)},[]);let Et=mt<=1100;(0,F.useEffect)(()=>{if(!Et||at)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(),ot(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Et,at]);let[Dt,Ot]=(0,F.useState)({}),[kt,At]=(0,F.useState)({}),[jt,Mt]=(0,F.useState)({}),[Nt,Pt]=(0,F.useState)(),[Ft,It]=(0,F.useState)(()=>new Set);(0,F.useEffect)(()=>{It(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>{let t=l.conversations.find(t=>t.id===e);return t?XR(t):!1}));return t.size===e.size?e:t})},[l.conversations]);let[Lt,Rt]=(0,F.useState)(),[zt,Bt]=(0,F.useState)(),Vt=(0,F.useRef)(new Map),[Ht,Ut]=(0,F.useState)(()=>dw(`super-pi.composer-drafts.v1`,{})),Wt=(0,F.useRef)(Ht),Gt=(0,F.useRef)(!1);Wt.current=Ht,(0,F.useEffect)(()=>{let e=()=>{let e=Object.entries(Wt.current).filter(([e,t])=>!e.startsWith(`pending:`)&&(t.text||t.images.length||t.attachments.length)).map(([e,t])=>[e,{...t,uploading:0}]),t=fw(`super-pi.composer-drafts.v1`,Object.fromEntries(e));!t&&e.length&&!Gt.current&&Ai(`浏览器无法保存聊天草稿,刷新前请先保留这段内容。`,`warning`),Gt.current=!t&&e.length>0},t=window.setTimeout(e,250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[Ht]);let Kt=(0,F.useRef)(new Set),[qt,Jt]=(0,F.useState)([]),[Yt,Xt]=(0,F.useState)([]),[Zt,Qt]=(0,F.useState)(),[$t,en]=(0,F.useState)(!1),tn=(0,F.useRef)(null),nn=(0,F.useRef)(!1),rn=(0,F.useRef)(0),an=(0,F.useRef)([]),on=(0,F.useRef)(void 0),sn=(0,F.useRef)(!1),cn=(0,F.useRef)(new Set),ln=(0,F.useRef)(new Set),un=(0,F.useRef)(new Map),dn=(0,F.useRef)(new Map),[fn,pn]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{let e=window.setInterval(()=>pn(Date.now()),3e4);return()=>window.clearInterval(e)},[]);let mn=(0,F.useMemo)(()=>l.conversations.filter(e=>!e.archivedAt),[l.conversations]),hn=(0,F.useMemo)(()=>e.conversations.filter(e=>!e.archivedAt),[e.conversations]),gn=(0,F.useMemo)(()=>new Set(l.collapsedConversationIds??[]),[l.collapsedConversationIds]),P=(0,F.useMemo)(()=>{let e=mn.find(e=>e.id===u);if(e)return e;if(!T)return sB(mn,l.workspaces,v)},[T,u,mn,v,l.workspaces]),_n=(0,F.useMemo)(()=>P?{workspaceId:P.workspaceId,conversationId:P.id,onImageOpen:Qt}:void 0,[P?.workspaceId,P?.id]),[vn,yn]=(0,F.useState)(`queue`),bn=!!(P&&XR(P));(0,F.useEffect)(()=>{yn(`queue`)},[P?.id,bn]);let[xn,Sn]=(0,F.useState)([]),Cn=(0,F.useMemo)(()=>ML(P?.parentConversationId,P?.parentConversationId?l.conversations.find(e=>e.id===P.parentConversationId):void 0),[P,l.conversations]),wn=!!(P&&l.unlockedChildConversationIds?.includes(P.id)),Tn=Cn&&!wn,En=(0,F.useMemo)(()=>(l.conversations||[]).filter(e=>e.parentConversationId===P?.id),[l.conversations,P?.id]),Dn=(0,F.useMemo)(()=>(l.conversations||[]).find(e=>e.id===P?.parentConversationId),[l.conversations,P?.parentConversationId]),On=(0,F.useMemo)(()=>P?PL({conversation:P,parent:Dn,directChildren:En,isTopLevelUnread:!1}):null,[P,Dn,En]),kn=ae.current;if(kn){let e=kn.dataset.messageScrollContainer;e&&P?.id&&e!==P?.id&&kn.querySelector(`[data-transcript-key]`)&&(N.current[e]=Uz(kn,N.current[e]??{followTail:!0,scrollTop:0}))}le.current=P?.messagesLoaded!==!1,(0,F.useEffect)(()=>{if(!E||T||u&&hn.some(e=>e.id===u)||u&&a.current.some(e=>e.temporaryId===u))return;let e=sB(mn,l.workspaces,v);d(e?.id),e&&x(t=>t.emptied||t.ids.length===0||t.ids.includes(e.id)?t:{...t,ids:[...t.ids,e.id]})},[T,u,hn,mn,E,v,l.workspaces]),(0,F.useEffect)(()=>{h(void 0)},[u,v]);let An=(0,F.useMemo)(()=>l.workspaces.find(e=>e.id===v)??l.workspaces[0],[l.workspaces,v]),[jn,Mn]=(0,F.useState)(``);(0,F.useEffect)(()=>{Mn(``)},[An?.id]);let Nn=(0,F.useRef)(v);Nn.current=v,(0,F.useEffect)(()=>{P&&y(P.workspaceId)},[P?.id]),(0,F.useEffect)(()=>{on.current=u},[u]),(0,F.useEffect)(()=>{se.current=P?.id},[P?.id]),(0,F.useEffect)(()=>{let e=P?.id;if(!e)return;let t=l.conversations.find(t=>t.id===e);if(!t)return;let n=ne.current[e];ne.current[e]=t.updatedAt,n!==t.updatedAt&&ie(e=>e+1),Gz({activeId:on.current,workspaceId:P?.workspaceId??v,conversations:N.current,readAt:ne.current})},[P?.id,l.conversations]),(0,F.useEffect)(()=>{f&&u&&Gz({activeId:u,workspaceId:P?.workspaceId??v,conversations:N.current,readAt:ne.current})},[u,P?.workspaceId,f,v]),(0,F.useEffect)(()=>{let e=ae.current;if(!e||!P?.id||P.messagesLoaded===!1)return;let t=P.id;fe.current=!1;let n=N.current[t]??{followTail:!0,scrollTop:0};N.current[t]=n,de(n);let r=requestAnimationFrame(()=>{if(ae.current!==e)ce.current=!1;else{if(n.followTail)Hz(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}ce.current=!1}});return()=>cancelAnimationFrame(r)},[P?.id,P?.messagesLoaded]),(0,F.useLayoutEffect)(()=>{ce.current=!0},[P?.id,P?.messagesLoaded]);let Pn=(0,F.useCallback)((e,t=!1,n=!1)=>{let r=se.current;if(!r||ce.current||!le.current)return;let i=Uz(e,N.current[r]??{followTail:!0,scrollTop:0},t,n);fe.current=!i.followTail,N.current[r]=i,de(i),Gz({activeId:r,workspaceId:Nn.current,conversations:N.current,readAt:ne.current})},[]),Fn=Ht[P?.id??``]??{text:``,images:[],attachments:[],uploading:0},In=Fn.text,Ln=Fn.images,Rn=Fn.attachments,zn=Fn.uploading,Bn=(e,t)=>Ut(n=>({...n,[e]:t(n[e]??{text:``,images:[],attachments:[],uploading:0})})),Vn=e=>Bn(P?.id??``,t=>({...t,text:e})),Hn=e=>Bn(P?.id??``,t=>({...t,attachments:t.attachments.some(t=>t.kind===e.kind&&t.id===e.id)?t.attachments:[...t.attachments,e]})),Un=(e,t)=>Bn(P?.id??``,n=>({...n,attachments:n.attachments.filter(n=>n.kind!==e||n.id!==t)})),[Wn,Gn]=(0,F.useState)({visible:!1,query:``,rect:null}),Kn=JSON.stringify([P?.id,P?.workspaceId,P?.cwd??``]),[qn,Jn]=(0,F.useState)(),Yn=(0,F.useRef)(null),[Xn,Zn]=(0,F.useState)(),Qn=(0,F.useRef)(void 0),$n=(0,F.useRef)(``),er=!Tn&&qn?.scope===Kn?qn:void 0,tr=e=>{let t=!nn.current&&!Tn&&P?qx(e.value,e.selectionStart,e.selectionEnd):void 0,n=JSON.stringify([Kn,t]);return!t||$n.current===n?(Jn(void 0),!1):(Jn({scope:Kn,token:t,rect:e.getBoundingClientRect()}),Gn({visible:!1,query:``,rect:null}),!0)},nr=()=>{$n.current=JSON.stringify([Kn,er?.token]),Jn(void 0)};(0,F.useEffect)(()=>{Jn(void 0),$n.current=``},[Kn]),(0,F.useLayoutEffect)(()=>{let e=Qn.current;Qn.current=void 0,e?.scope===Kn&&e.text===In&&(oe.current?.focus(),oe.current?.setSelectionRange(e.caret,e.caret))},[In,Kn]),(0,F.useEffect)(()=>{let e=()=>{let e=oe.current;e&&Jn(t=>t?{...t,rect:e.getBoundingClientRect()}:void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let rr=e=>Bn(P?.id??``,t=>({...t,images:typeof e==`function`?e(t.images):e})),ir=S.length>0?S:T?[]:P?[P.id]:[],ar=(0,F.useMemo)(()=>ir.map(e=>mn.find(t=>t.id===e)).filter(e=>e!==void 0),[ir,mn]),or=ar.filter(e=>e.id!==C).at(-1)?.id,sr=ar.some(e=>e.id===P?.id);(0,F.useEffect)(()=>{if(!E)return;let e=new Set(mn.map(e=>e.id));x(t=>{let n=t.ids.filter(t=>e.has(t)),r=t.previewId&&e.has(t.previewId)?t.previewId:void 0;return n.length===t.ids.length&&r===t.previewId?t:{...t,ids:n,previewId:r}})},[E,mn]),(0,F.useEffect)(()=>{Xz(b,u)},[u,b]);let cr=(0,F.useCallback)(e=>{e&&x(t=>{if(t.touched.has(e))return t;let n=t.previewId===e?void 0:t.previewId;return{...t,previewId:n,touched:qz(t.touched,e)}})},[]),lr=(0,F.useCallback)(e=>{w.current++,d(e);let t=mn.find(t=>t.id===e)?.workspaceId;t&&y(t),fr(`session`),x(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&&P?.id&&P.id!==e?[P.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}})},[P,mn]),ur=(0,F.useCallback)(e=>{e&&(cr(e),lr(e))},[cr,lr]),[dr,fr]=(0,F.useState)(`session`),pr=P?.workspaceId??v,mr=P?.cwd??``,hr=pT(pr,mr,{navigation:w,showingFile:dr===`file`}),gr=Vp(pr,mr,f&&E),_r=(0,F.useRef)(gr.refresh);_r.current=gr.refresh;let vr=(0,F.useRef)(hr.setChangedFor),yr=(0,F.useRef)(hr.setIndex),br=(0,F.useRef)(hr.invalidateTree);br.current=hr.invalidateTree;let xr=(0,F.useRef)(pr);xr.current=pr;let Sr=(0,F.useRef)(mr);Sr.current=mr,(0,F.useEffect)(()=>{vr.current=hr.setChangedFor},[hr.setChangedFor]),(0,F.useEffect)(()=>{yr.current=hr.setIndex},[hr.setIndex]);let[Cr]=(0,F.useState)(KR),[wr,Tr]=(0,F.useState)(Cr.tab),[Er,Dr]=(0,F.useState)(Cr.byConversation),Or=(P?.id?Er[P.id]:void 0)??wr;(0,F.useEffect)(()=>{try{window.sessionStorage.setItem(GR,JSON.stringify({tab:wr,byConversation:Er}))}catch{}},[wr,Er]);let kr=(0,F.useCallback)(e=>{Tr(e),P?.id&&Dr(t=>({...t,[P.id]:e}))},[P?.id]),Ar=gt.order.filter(e=>gt.sides[e]===`left`),jr=gt.order.filter(e=>e!==`sessions`&&gt.sides[e]===`right`),Mr=Ar.includes(gt.leftView)?gt.leftView:`sessions`,Nr=jr.includes(Or)?Or:jr[0],Pr=gt.rightClosed||!Nr,Fr=Et||!gt.leftClosed&&Mr===`sessions`,Ir=(e,t=!1)=>{Et?e===`sessions`?(dt(),pt(!0)):(kr(e),ot(!1),mt<=700&&ct(`rail`)):gt.sides[e]===`left`?_t(n=>({...n,leftView:e,leftClosed:t&&!n.leftClosed&&Mr===e})):e!==`sessions`&&(kr(e),_t(n=>({...n,rightClosed:t&&!n.rightClosed&&Nr===e})))},Lr=(e,t)=>{let n=gt.sides[e];if(t===`move`){let t=n===`left`?`right`:`left`;_t(n=>({...n,sides:{...n.sides,[e]:t},...t===`left`?{leftView:e,leftClosed:!1}:{rightClosed:!1}})),t===`right`&&kr(e),requestAnimationFrame(()=>{(document.querySelector(`[data-workbench-view="${e}"]`)??document.querySelector(`[data-workbench-panel-menu="${e}"]`))?.focus()})}else _t(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}})},[Rr,zr]=(0,F.useState)(!1),Br=(0,F.useRef)(void 0),Vr=(0,F.useRef)(``);(0,F.useEffect)(()=>{zr(!1),M.current?.readyState===WebSocket.OPEN&&M.current.send(JSON.stringify({type:`files.index.subscribe`}))},[pr,mr]);let[Hr,Ur]=(0,F.useState)(!1),[Wr,Gr]=(0,F.useState)(),[Kr,qr]=(0,F.useState)(),[Jr,Yr]=(0,F.useState)({paths:[]}),Xr=Jr.paths,Zr=(0,F.useCallback)(()=>{!sr&&or?lr(or):fr(`session`)},[sr,or,lr]);(0,F.useEffect)(()=>{dr===`file`&&!hr.active&&Zr()},[dr,hr.active,Zr]),(0,F.useEffect)(()=>{dr===`diff`&&!Kr&&Zr()},[dr,Kr,Zr]);let Qr=(0,F.useRef)(`${pr??``}:${mr}`);(0,F.useEffect)(()=>{let e=`${pr??``}:${mr}`;Qr.current!==e&&(Qr.current=e,Yr({paths:[]}),qr(void 0),fr(`session`))},[pr,mr]);let $r=(0,F.useCallback)(e=>{w.current++,Yr(t=>t.paths.includes(e)?t:{paths:t.previewPath?t.paths.map(n=>n===t.previewPath?e:n):[...t.paths,e],previewPath:e}),qr(e),fr(`diff`),dt(),Tr(`files`)},[dt]),[ei,ti]=(0,F.useState)({diff:null,loading:!1,error:``}),[ni,ri]=(0,F.useState)(`server`);(0,F.useEffect)(()=>{if(dr!==`diff`||!Kr||!pr)return;let e=!0;return ti({diff:null,loading:!0,error:``}),fetch(`/api/files/diff?workspaceId=${encodeURIComponent(pr)}&path=${encodeURIComponent(Kr)}${mr?`&cwd=${encodeURIComponent(mr)}`:``}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(t=>{e&&ti({diff:t,loading:!1,error:``})}).catch(t=>{e&&ti({diff:null,loading:!1,error:t instanceof Error?t.message:`读取差异失败`})}),()=>{e=!1}},[dr,Kr,pr,mr]);let ii=(0,F.useMemo)(()=>{if(!Kr)return;let e=hr.open.find(e=>e.path===Kr);return e&&e.dirty?e.content:void 0},[Kr,hr.open]),ai=(0,F.useCallback)(e=>{w.current++,hr.setActivePath(e),fr(`file`),Tr(`files`)},[hr.setActivePath]),oi=(0,F.useCallback)(async(e,t,n=!1)=>{let r=++w.current,i=()=>w.current===r,a=await hr.openFile(e,{preview:!n,isCurrent:i});a&&i()&&(n&&hr.pinFile(a),Gr(t?{workspaceId:pr,path:a,line:t,request:r}:void 0),fr(`file`),dt())},[hr.openFile,hr.pinFile,pr,dt]),si=(0,F.useCallback)((e,t)=>{oi(e,void 0,t)},[oi]),ci=P&&!Tn?(e,t)=>{let n=In&&!/\s$/u.test(In)?`${In} `:In,r=Jx(n,{start:n.length,end:n.length,query:``},{path:e,kind:t?`directory`:`file`});Qn.current={scope:Kn,...r},cr(P.id),lr(P.id),dt(),Vn(r.text)}:void 0,li=(e,t)=>{w.current+=1,Yr(t=>({paths:t.paths.filter(t=>!cS(t,e)),previewPath:t.previewPath&&!cS(t.previewPath,e)?t.previewPath:void 0})),Kr&&cS(Kr,e)&&qr(void 0),Gr(n=>n&&cS(n.path,e)?{...n,path:t+n.path.slice(e.length)}:n)};(0,F.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()===`f`?(e.preventDefault(),Ur(!0)):(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`p`&&(e.preventDefault(),Br.current=pr,Vr.current=mr,zr(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[pr,mr]);let ui=(0,F.useMemo)(()=>ar.map(e=>({id:`session:${e.id}`,rawId:e.id,kind:`session`,label:e.title,title:e.title,closable:!0,preview:C===e.id,badge:(0,I.jsx)(rz,{state:tz(e,$R(e,nt),ne.current[e.id],l.conversations)})})),[ar,nt,l.conversations,re,C]),di=(0,F.useMemo)(()=>hr.open.map(e=>({id:`file:${e.path}`,rawId:e.path,kind:`file`,label:e.name,title:e.path,closable:!0,preview:e.preview,badge:e.dirty?(0,I.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[hr.open]),fi=(0,F.useMemo)(()=>Xr.map(e=>({id:`diff:${e}`,rawId:e,kind:`diff`,label:e.split(/[\\/]/).pop()||e,title:`${e}(改动)`,closable:!0,preview:Jr.previewPath===e,icon:(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`±`})})),[Xr,Jr.previewPath]),pi=(0,F.useMemo)(()=>[...ui,...di,...fi],[ui,di,fi]),mi=dr===`file`&&hr.activePath?`file:${hr.activePath}`:dr===`diff`&&Kr?`diff:${Kr}`:sr&&P?.id?`session:${P.id}`:void 0,hi=(0,F.useRef)(void 0);(0,F.useLayoutEffect)(()=>{if(hi.current!==hr.restoredActive&&(hi.current=hr.restoredActive,hr.restoredActive&&hr.restoredActive===hr.activePath&&dr!==`file`)){fr(`file`);return}E&&C&&mi!==`session:${C}`&&mn.some(e=>e.id===C)&&x(e=>{if(e.previewId!==C)return e;let t=e.ids.filter(e=>e!==C);return{...e,ids:t,previewId:void 0,emptied:t.length===0}});for(let e of hr.open)e.preview&&mi!==`file:${e.path}`&&hr.discardPreview(e.path);let e=Jr.previewPath;e&&mi!==`diff:${e}`&&Yr(t=>t.previewPath===e?{paths:t.paths.filter(t=>t!==e)}:t),E&&dr===`session`&&P?.id===u&&!sr&&!hr.restoringWorkbench&&or&&lr(or)},[mi,E,C,hr.open,hr.activePath,hr.restoredActive,hr.discardPreview,Jr.previewPath,dr,P?.id,u,sr,hr.restoringWorkbench,or,lr,mn]);let gi=(0,F.useCallback)(e=>{if(e.startsWith(`file:`)){let t=e.slice(5);ai(t)}else if(e.startsWith(`diff:`)){w.current++;let t=e.slice(5);qr(t),fr(`diff`)}else if(e.startsWith(`session:`)){let t=e.slice(8);lr(t)}},[ai,lr]),_i=(0,F.useCallback)(e=>{if(e.startsWith(`session:`))ur(e.slice(8));else if(e.startsWith(`file:`))hr.pinFile(e.slice(5));else if(e.startsWith(`diff:`)){let t=e.slice(5);Yr(e=>e.previewPath===t?{paths:e.paths}:e)}},[ur,hr.pinFile]),vi=(0,F.useCallback)(e=>{let t=ir.indexOf(e);if(t<0)return;let n=ir.filter(t=>t!==e);if(x(t=>({...t,ids:t.ids.filter(t=>t!==e),previewId:t.previewId===e?void 0:t.previewId,emptied:n.length===0||t.emptied})),P?.id!==e||dr!==`session`)return;w.current++;let r=n[Math.min(t,n.length-1)];if(r)d(r);else if(hr.open.length>0){let e=hr.activePath&&hr.open.some(e=>e.path===hr.activePath)?hr.activePath:hr.open[0].path;hr.setActivePath(e),fr(`file`)}else Xr.length>0?(qr(Xr[0]),fr(`diff`)):d(void 0)},[ir,P,hr,Xr,dr]),yi=(0,F.useCallback)(e=>{if(e.startsWith(`file:`)){let t=e.slice(5);hr.closeFile(t),dr===`file`&&hr.activePath===t&&hr.open.length<=1&&w.current++}else if(e.startsWith(`diff:`)){let t=e.slice(5);Yr(e=>({paths:e.paths.filter(e=>e!==t),previewPath:e.previewPath===t?void 0:e.previewPath})),dr===`diff`&&Kr===t&&(w.current++,qr(void 0),Zr())}else if(e.startsWith(`session:`)){let t=e.slice(8);vi(t)}},[hr,vi,Kr,dr,Zr]),bi=hr.active,xi=JSON.stringify([pr,mr,bi?.path]),[Si,Ci]=(0,F.useState)(),wi=(0,F.useCallback)(e=>{Ci(t=>e?{scope:xi,position:e}:t?.scope===xi?void 0:t)},[xi]),Ti=Si?.scope===xi?Si.position:void 0,Ei=l.workspaces.find(e=>e.id===pr),Di=bi&&(0,I.jsx)($x,{root:mr.split(`/`).at(-1)||Ei?.name||`工作目录`,path:bi.path,reveal:(e,t)=>{Ir(`files`),hr.locatePath(e,t)}}),Oi=bi&&(!bi.view||bi.view===`table`)?(0,I.jsx)(lT,{file:bi,state:hr.saves[bi.path]?.state??`idle`,message:hr.saves[bi.path]?.message??``,external:hr.external[bi.path]===!0,jumpToLine:Wr&&Wr.workspaceId===pr&&Wr.path===bi.path?Wr:void 0,onChange:e=>hr.updateBuffer(bi.path,e),onSave:()=>void hr.save(bi.path,!1),onReload:()=>void hr.reload(bi.path),onOverwrite:()=>void hr.save(bi.path,!0),workspaceId:pr,cwd:mr,navigation:bi.view?void 0:Di,embedded:!!bi.view,onPosition:wi}):void 0,ki=P?.id;(0,F.useEffect)(()=>{ki&&!ki.startsWith(`pending:`)&&Vi({type:`conversation.select`,conversationId:ki})},[ki]);let Ai=(e,t=`info`)=>{if(!e)return;let n=++rn.current;ze(r=>[...r,{key:n,text:e,kind:t}]),an.current.push(window.setTimeout(()=>ze(e=>e.filter(e=>e.key!==n)),7e3))},ji=(0,F.useRef)(null),Mi=(0,F.useRef)({deadline:0,busy:!1,serverWasAway:!1,mode:`update`}),Ni=()=>{ji.current!==null&&(window.clearInterval(ji.current),ji.current=null)},Pi=(e,t)=>{Ni(),it(!1),tt(`idle`),Ai(e,t)},Fi=async()=>{let e=Mi.current;if(!e.busy){if(Date.now()>e.deadline)Pi(`更新等待超时(30 分钟),请检查服务日志`,`error`);else{e.busy=!0;try{let t=await fetch(`/api/update-check`);if(!t.ok){Pi(`更新已结束`,`info`);return}let n=await t.json();if(n.updating===!0){it(!0);return}let r=n.lastUpdate;if(r?.ok===!1){Pi(`更新失败(退出码 ${r.code??`未知`}),可以再试一次`,`error`);return}if(e.mode===`restart`){(e.serverWasAway||n.needsRestart===!1)&&Pi(`服务已重启…`,`info`);return}if(r?.ok===!0){Pi(`更新完成,服务正在重启…`,`info`);return}Pi(e.serverWasAway?`更新完成,服务已重启…`:`更新已结束`,`info`)}catch{e.serverWasAway=!0,it(!0)}finally{e.busy=!1}}}},Ii=(e=`update`)=>{Ni(),Mi.current={deadline:Date.now()+18e5,busy:!1,serverWasAway:!1,mode:e},it(!0),ji.current=window.setInterval(()=>{Fi()},2e3)};(0,F.useEffect)(()=>()=>Ni(),[]),(0,F.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/api/update-check`);if(!t.ok)return;let n=await t.json();!e&&n.updating===!0&&Ii()}catch{}})(),()=>{e=!0}},[]),(0,F.useEffect)(()=>{let e=P?.id,t=P?.agentNotice;e&&t&&!cn.current.has(e)&&(cn.current.add(e),Ai(t,`info`))},[P?.id,P?.agentNotice]);let Li=(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},Ri=(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},zi=(e,t)=>{if(t.method===`notify`)Ai(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;Le(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===on.current&&Vn(t.text??``)},Bi=(e,t,n)=>{Le(n=>n.filter(n=>!(n.conversationId===e&&n.request.blocking&&n.request.requestId===t)));let r=vR[n];r&&Ai(r,`warning`)};(0,F.useEffect)(()=>{let e=!1,t=0,r,s=()=>{if(e)return;let c=location.protocol===`https:`?`wss`:`ws`,l=new WebSocket(`${c}://${location.host}/ws?state=focused${on.current?`&conversationId=${encodeURIComponent(on.current)}`:``}`);M.current=l,l.onopen=()=>{if(!e){t=0,p(!0),l.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),l.send(JSON.stringify({type:`catalog.fetch`,conversationId:on.current})),Nn.current&&l.send(JSON.stringify({type:`prompt.catalog.fetch`,workspaceId:Nn.current})),l.send(JSON.stringify({type:`catalog.fetchAll`})),l.send(JSON.stringify({type:`agent.catalog.fetch`})),l.send(JSON.stringify({type:`subagent.catalog.fetch`}));for(let e of a.current)e.retry&&e.command&&l.send(JSON.stringify({...e.command,operationRequestId:e.id}))}},l.onclose=n=>{if(e)return;sn.current=!1;let o=SI(a.current);for(let e of o.failed)e.onFailure?.();if(a.current=o.retry,i(o.retry),p(!1),t===0){let e=n.reason?.trim()?`${n.reason.trim()}(code ${n.code})`:`code ${n.code}`;console.error(`[Super Pi Error] websocket closed:`,n.code,n.reason),Ai(`与 Super Pi 服务的连接断开,正在重连。(${e})`,`error`)}r=window.setTimeout(s,Math.min(rR,nR*2**t++))},l.onmessage=({data:t})=>{if(e)return;let r=JSON.parse(t);if(r.type!==`message.delta`&&r.type!==`message.thinking`&&ve(),r.type===`message.accepted`){lw(r.conversationId,r.clientId);for(let e of a.current)e.command?.conversationId===r.conversationId&&e.command?.clientId===r.clientId&&(e.receipt=!0)}else if(r.type===`exec.output`){let e=pe.current.get(r.sessionId)??``;pe.current.set(r.sessionId,(r.replace?r.data:e+r.data).slice(-512e3)),pe.current.size>64&&pe.current.delete(pe.current.keys().next().value),window.dispatchEvent(new CustomEvent(`super-pi-exec-output`,{detail:r}))}else if(r.type===`run.stopping`)It(e=>{let t=new Set(e);return t.add(r.conversationId),t});else if(r.type===`exec.exit`)(r.stdout||r.stderr)&&pe.current.set(r.sessionId,`${r.stdout}${r.stderr}`);else if(r.type.startsWith(`terminal.`))me.current?.(r);else if(r.type===`conversation.autoRename.result`){let e=Vt.current.get(r.conversationId);e&&(Vt.current.delete(r.conversationId),r.ok?e.resolve(r.title):e.reject(Error(r.error)))}else if(r.type===`message.thinking`)ye(r);else if(r.type===`state`){ve(),sn.current=!1;let e=on.current,t=!!(e&&ln.current.has(e)),s=!(!e||r.state.conversations.some(t=>t.id===e)),c=t&&s&&e&&un.current.has(e)?{...r.state,conversations:[un.current.get(e),...r.state.conversations]}:r.state;e&&!s&&(ln.current.delete(e),un.current.delete(e)),a.current=a.current.filter(e=>!e.accepted?.(c)||c.sendReceipts&&e.retry&&!e.receipt?!0:(e.retry&&typeof e.command?.conversationId==`string`&&typeof e.command.clientId==`string`&&lw(e.command.conversationId,e.command.clientId),!1)),i(a.current),It(e=>{let t=new Set(e);for(let e of[...t]){let n=c.conversations.find(t=>t.id===e);(!n||n.status!==`running`&&n.status!==`waiting`)&&t.delete(e)}return t}),c.extensionUi&&Le(c.extensionUi),c.stoppingConversationIds&&It(new Set(c.stoppingConversationIds)),n(c),D(!0),p(!0),y(e=>{if(e&&(c.workspaces.some(t=>t.id===e)||a.current.some(t=>t.temporaryId===e)))return e;let t=o.current?.workspaceId;return t&&c.workspaces.some(e=>e.id===t)?t:c.workspaces[0]?.id})}else if(r.type===`message.delta`)ye(r);else if(r.type===`queue.withdrawn`){Sn(e=>[...e.filter(e=>e.conversationId!==r.conversationId).slice(-9),{id:`withdrawn_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,conversationId:r.conversationId,actor:r.actor,withdrawn:r.withdrawn}]);let e=r.withdrawn.slice(0,2).map(e=>`「${e.content.replace(/\s+/g,` `).trim().slice(0,24)}」`).join(`、`),t=r.actor===`agent`?`上级 Agent 已撤回`:`已撤回`;Ai(`${t} ${r.withdrawn.length} 条排队消息:${e}${r.withdrawn.length>2?`…`:``}`,`info`)}else if(r.type===`message.revert.result`)R(void 0),Pt(void 0),r.ok||(console.error(`[Super Pi Error] revert failed:`,r.message),h(r.message));else if(r.type===`operation.result`){let e=a.current.find(e=>e.id===r.requestId),t=e?.retry?e.command:void 0;if(t&&lw(t.conversationId,t.clientId),a.current=a.current.filter(e=>e.id!==r.requestId),i(a.current),e?.temporaryId){let t=e.temporaryId;if(r.ok&&r.entityId){let e=r.entityId,i=dn.current.get(t);if(i&&un.current.set(e,{...i,id:e}),ln.current.add(e),i){let t={...i,id:e};n(n=>n.conversations.some(t=>t.id===e)?n:{...n,conversations:[t,...n.conversations]})}Ut(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.attachments.length?r.attachments:i.attachments,uploading:r.uploading+i.uploading}:r,delete a[t],a}),dn.current.delete(t)}d(n=>n===t?r.ok?r.entityId:e.previousActiveId:n),x(e=>Jz(e,t,r.ok&&r.entityId?r.entityId:void 0)),y(e=>e===t?r.ok?r.entityId:void 0:e)}if(!r.ok){if(console.error(`[Super Pi Error] operation failed:`,r.message),!e?.receipt){if(e?.onFailure)e.onFailure(r.message);else if(t){let e=t.images??[],n=t.attachments??[];Jt(i=>[...i,{id:t.clientId,conversationId:t.conversationId,content:t.content,images:e,attachments:n,reason:r.message}]),Bn(t.conversationId,r=>r.text||r.images.length||r.attachments.length?r:{...r,text:t.content,images:e,attachments:n})}}let n=r.message??`操作失败`;h(n),e?.onFailure||Ai(dp(n),`error`)}}else r.type===`tools.updated`?window.dispatchEvent(new Event(`super-pi-tools-updated`)):r.type===`files.changed`?(vr.current(r.workspaceId,r.changes,r.dropped),r.workspaceId===xr.current&&_r.current()):r.type===`files.invalidated`?(br.current(r.workspaceId,r.paths),r.workspaceId===xr.current&&_r.current()):r.type===`files.index`?r.workspaceId===xr.current&&(r.cwd??``)===Sr.current&&yr.current(r):r.type===`error`?(console.error(`[Super Pi Error]`,r.message),h(r.message),Ai(dp(r.message),`error`),sn.current&&=!1):r.type===`extension.ui`?zi(r.conversationId,r.request):r.type===`extension.ui.closed`?Bi(r.conversationId,r.requestId,r.reason):r.type===`model.catalog`?(!r.conversationId||r.conversationId===on.current)&&Ve(r.catalog):r.type===`model.catalog.all`?Ue(r.catalog):r.type===`providers.list`?(Ge(r.providers),qe(r.apis)):r.type===`agent.catalog`?Ye(r.catalog):r.type===`prompt.catalog`?Fe(r.catalog):r.type===`subagent.catalog`?Ze(r.catalog):r.type===`server.version`?($e(r.version),r.version.needsRestart&&Ai(`检测到 Super Pi 代码已更新(v${r.version.runningVersion} → v${r.version.diskVersion}),请执行 /super_pi restart 重启服务生效`,`warning`)):r.type===`subagent.event`?n(e=>({...e,subagentRuns:Li(e.subagentRuns??[],r.run)})):r.type===`workflow.event`?n(e=>({...e,workflows:Ri(e.workflows??[],r.workflow)})):r.type===`message.tools`?n(e=>({...e,conversations:e.conversations.map(e=>e.id===r.conversationId?{...e,messages:e.messages.map(e=>e.id===r.messageId?{...e,toolCalls:r.toolCalls}:e)}:e)})):r.type===`conversation.fork.result`&&(ko(e=>e===r.conversationId?void 0:e),Ai(r.ok?`已从「${r.title}」分叉出新会话,放在侧边栏最上面;没有切换过去。${r.messagesCopied?`复制了 ${r.messagesCopied} 条消息。`:`原会话还没有消息,只复制了会话本身。`}`:`分叉失败:${dp(r.message)}`,r.ok?`info`:`error`))}};return s(),()=>{e=!0,ve(),window.clearTimeout(r);for(let e of an.current)window.clearTimeout(e);M.current?.close()}},[ye,ve]);let Vi=(0,F.useCallback)(e=>M.current?.readyState===WebSocket.OPEN&&(M.current.send(JSON.stringify(e)),!0),[]);(0,F.useEffect)(()=>{if(!f)return;let e=P?.id;e?.startsWith(`pending:`)||Vi({type:`state.subscribe`,...e?{conversationId:e}:{}})},[P?.id,f,Vi]),(0,F.useEffect)(()=>{if(f&&Rr&&pr&&Br.current===pr&&Vr.current===mr)return Vi({type:`files.index.subscribe`,workspaceId:pr,...mr?{cwd:mr}:{}}),hr.requestIndex(!0),()=>{Vi({type:`files.index.subscribe`}),hr.cancelIndexRequest()}},[f,Rr,pr,mr,Vi,hr.requestIndex,hr.cancelIndexRequest]);let Hi=(e,t,n,r,o,s,c)=>{let l=M.current?.readyState===WebSocket.OPEN,u=xI(e);if(a.current.some(e=>e.key===t)||!l&&!u)return!1;if(u&&!cw(e))return Ai(`浏览器无法保存待发消息,正文仍在输入框。`,`error`),!1;let d=fE(),f={id:d,key:t,apply:n,temporaryId:r,previousActiveId:on.current,onFailure:o,accepted:s,...c?{expiresAt:Date.now()+c}:{},...u?{retry:!0,command:e}:{}};return a.current=[...a.current,f],i(a.current),l&&M.current.send(JSON.stringify({...e,operationRequestId:d})),!0},Ui=(e,t)=>{Vi({type:`conversation.childLock`,conversationId:e,unlocked:t})||Ai(t?`连接断开,这个子会话没有解锁,请重试`:`连接断开,这个子会话没有上锁,请重试`,`error`)},Wi=e=>{if(!e)return;let t=`message_${fE()}`;Hi({type:`message.send`,conversationId:e,content:sR,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,F.useEffect)(()=>{let e=r.flatMap(e=>e.expiresAt?[e.expiresAt]:[]);if(!e.length)return;let t=window.setTimeout(()=>{let e=a.current.filter(e=>e.expiresAt&&e.expiresAt<=Date.now());if(e.length){a.current=a.current.filter(t=>!e.includes(t)),i(a.current);for(let t of e)t.onFailure?.(`打断请求超时,尚未确认是否开始回答;请检查会话状态后重试`)}},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[r]);let Gi=(e,t)=>n=>({...n,conversations:n.conversations.map(n=>n.id===e?{...n,...t}:n)}),Ki=(e,t)=>n=>({...n,workspaces:n.workspaces.map(n=>n.id===e?{...n,...t}:n)}),qi=P?.id.startsWith(`pending:`)===!0,Ji=!!(P&&XR(P)&&(Ft.has(P.id)||r.some(e=>e.key===`stop:${P.id}`))),Yi=P?.messagesLoaded===!1||r.some(e=>e.key.startsWith(`send:${P?.id}:`)||e.key===`configuration:${P?.id}`||e.temporaryId===P?.id||e.key===`archive:${P?.id}`),Xi=(e,t,n,r,i)=>{e&&M.current?.send(JSON.stringify({type:`question.answer`,conversationId:e,messageId:t,callIndex:n,answers:r,cancelled:i}))},Zi=(e,t,n)=>(cr(e),Hi({type:`extension.ui.answer`,conversationId:e,requestId:t,...n},`answer:${e}:${t}`,e=>e)),Qi=P?.model??Be?.defaultModel,$i=P?.thinkingLevel??Be?.defaultThinkingLevel,ea=$i&&Be?.levels.includes($i)?$i:void 0,ta=Be?.source===`pi`,na=Be?.models.find(e=>e.provider===Qi?.provider&&e.modelId===Qi?.modelId),ra=!!na?.imageInput,ia=(e,t)=>!e||!t?e:{...e,models:e.models.filter(e=>(l.modelFilterRules??[]).every(n=>{try{return!new RegExp(n.workspacePattern,`i`).test(t.name)||new RegExp(n.modelPattern,`i`).test(e.label)||new RegExp(n.modelPattern,`i`).test(`${e.provider}/${e.modelId}`)}catch{return!0}}))},aa=!!P?.messages?.some(e=>e.images&&e.images.length>0),oa=ia(Be,l.workspaces.find(e=>e.id===P?.workspaceId))?.models??[],sa=(aa?oa.filter(e=>e.imageInput):oa).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,kL(e.contextWindow)?`${kL(e.contextWindow)} 上下文`:``,AL(e.maxTokens)?`${AL(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:fR(e),selected:Qi?.provider===e.provider&&Qi.modelId===e.modelId})),ca=(Be?.levels??[]).map(e=>({key:e,label:e,selected:e===$i})),la=e=>{if(!P)return;let[t,n]=e.split(`/`);t&&n&&(cr(P.id),Hi({type:`conversation.model`,conversationId:P.id,provider:t,modelId:n},`configuration:${P.id}`,Gi(P.id,{model:Be?.models.find(e=>e.provider===t&&e.modelId===n)??{provider:t,modelId:n,label:n}})))},ua=e=>{P&&(cr(P.id),Hi({type:`conversation.thinking`,conversationId:P.id,level:e},`configuration:${P.id}`,Gi(P.id,{thinkingLevel:e})))},da=Je?.agents.find(e=>e.id===P?.agentId),fa=[{key:HR,label:`跟随 Pi 默认`,detail:`不使用任何 agent 角色`,selected:!P?.agentId},...(Je?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:P?.agentId===e.id}))],pa=da?.model,ma=!!(pa&&P?.model&&P.model.provider===pa.provider&&P.model.modelId===pa.modelId);da?.thinkingLevel&&(P?.thinkingLevel,da.thinkingLevel);let ha=e=>{if(P){let t=Je?.agents.find(t=>t.id===e);Hi({type:`conversation.agent`,conversationId:P.id,agentId:e===HR?null:e},`configuration:${P.id}`,Gi(P.id,{agentId:t?.id,...t?.model?{model:{...t.model,label:t.model.modelId}}:{},...t?.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}}))}},ga=nt.filter(e=>e.conversationId===P?.id),_a=Ie.filter(e=>e.conversationId===P?.id).map(e=>e.request),va=new Map(_a.filter(e=>e.method===`setStatus`).map(e=>[e.statusKey??``,e.statusText??``])),ya=new Map(_a.filter(e=>e.method===`setWidget`).map(e=>[e.widgetKey??``,{lines:e.widgetLines??[],placement:e.widgetPlacement??`aboveEditor`}])),ba=_a.find(e=>e.method===`setTitle`)?.title,xa=(0,F.useMemo)(()=>(l.subagentRuns??[]).filter(e=>e.conversationId===P?.id),[l.subagentRuns,P?.id]),Sa=(0,F.useMemo)(()=>(l.workflows??[]).filter(e=>e.conversationId===P?.id),[l.workflows,P?.id]),Ca=(0,F.useMemo)(()=>new Map(Sa.map(e=>[e.id,e])),[Sa]),wa=(0,F.useMemo)(()=>new Map((Xe?.agents??[]).map(e=>[e.id,e.name])),[Xe]),Ta=(0,F.useMemo)(()=>new Map((P?.messages??[]).map(e=>[e.id,e])),[P?.messages]),Ea=(0,F.useMemo)(()=>new Map(xa.map(e=>[e.id,e])),[xa]),Da=(0,F.useMemo)(()=>{let e=new Map;for(let t of xa)t.originMessageId!==void 0&&t.originCallRow!==void 0&&e.set(`${t.originMessageId}:${t.originCallRow}`,t);return e},[xa]),Oa=(0,F.useMemo)(()=>{if(!P||!sr)return[];let e=Nt?.conversationId===P.id?(()=>{let e=P.messages.find(e=>e.id===Nt.messageId);if(e)return{index:P.messages.indexOf(e),at:Date.parse(e.createdAt)||0,...Nt.kind===`withdraw`?{inclusive:!0}:{inclusive:!1}}})():void 0,t=[];return P.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}`})}),xa.forEach((n,r)=>{n.originMessageId&&n.originCallRow!==void 0&&P?.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}`})}),Sa.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}`})}),t.sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)},[P,xa,Sa,Nt]),ka=(0,F.useMemo)(()=>{for(let e=Oa.length-1;e>=0;--e){let t=Oa[e];if(t.startsWith(`m:`)&&Ta.get(t.slice(2))?.role===`user`)return t.slice(2)}},[Oa,Ta]);(0,F.useEffect)(()=>{let e=ae.current;if(!e||!P?.id)return;let t=()=>{!fe.current&&N.current[P.id]?.followTail&&(Hz(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()},[P?.id,P?.messages,xa,Sa,sr,Oa]);let Aa=e=>Ot(t=>({...t,[e]:!t[e]})),ja=(e,t)=>At(n=>({...n,[`${e}:${t}`]:!n[`${e}:${t}`]})),Ma=(e,t)=>Mt(n=>({...n,[`${e}:${t}`]:n[`${e}:${t}`]!==!1})),[Na,Pa]=(0,F.useState)({}),Fa=e=>Pa(t=>({...t,[e]:t[e]!==!0})),Ia=e=>{Hi({type:`subagent.stop`,runId:e},`stop:${e}`,e=>e)||Ai(`连接断开,无法停止子智能体,请重试`,`error`)},La=e=>{Hi({type:`workflow.stop`,workflowId:e},`stop:${e}`,e=>e)||Ai(`连接断开,无法停止编排,请重试`,`error`)},Ra=e=>[...ya].filter(([,t])=>t.placement===e).map(([e,t])=>{let n=t.lines;return(0,I.jsxs)(`div`,{className:`extui-widget`,"data-widget-key":e,"data-widget-lines":n.length,children:[n.slice(0,yR).map((e,t)=>(0,I.jsx)(`div`,{children:e},`${t}:${e}`)),n.length>yR&&(0,I.jsx)(`div`,{children:`… (widget truncated)`})]},e)}),za=(e,t)=>{let n=`pending:${fE()}`,r={id:n,name:e,path:t,updatedAt:new Date().toISOString()};Hi({type:`workspace.create`,name:e,path:t},`create-workspace`,e=>({...e,workspaces:[...e.workspaces,r]}),n)&&(w.current++,y(n),d(void 0),k(!1))},[Ba,Va]=(0,F.useState)(),Ha=(e,t)=>Va(n=>n?.kind===e&&n.id===t?n:{kind:e,id:t}),Ua=()=>Va(void 0),Wa=(e,t)=>Ba?.kind===e&&Ba.id===t,Ga=(e,t,n)=>!t.startsWith(`pending:`)&&(e===`conversation`&&cr(t),Hi(e===`workspace`?{type:`workspace.rename`,workspaceId:t,name:n}:{type:`conversation.rename`,conversationId:t,name:n},`rename:${t}`,e===`workspace`?Ki(t,{name:n}):Gi(t,{title:n}))?(sn.current=!0,Ua(),!0):(Ai(`连接断开,改名未保存,请重试`,`error`),!1)),Ka=async e=>{if(e.startsWith(`pending:`)){Ai(`这个会话还在创建中,稍后再试`,`warning`);return}if(Vt.current.has(e))return;Ai(`正在根据对话内容生成标题…`,`info`);let t=new Promise((t,n)=>{Vt.current.set(e,{resolve:t,reject:n}),window.setTimeout(()=>{Vt.current.delete(e)&&n(Error(`模型在 30 秒内没有返回标题`))},32e3)});if(!Vi({type:`conversation.autoRename`,conversationId:e}))Vt.current.delete(e),Ai(`连接断开,无法生成标题`,`error`);else try{let n=await t;Ga(`conversation`,e,n),Ai(`已重命名为「${n}」`,`info`)}catch(e){Ai(`重命名失败:${dp(e)}`,`error`)}},qa=e=>{if(e.id.startsWith(`pending:`))return;let t=l.conversations.filter(t=>t.workspaceId===e.id).length;window.confirm(`从列表移除工作区「${e.name}」?${t?`其中的 ${t} 条会话会保留,`:``}重新添加同一个目录即可恢复,不会删除任何会话。`)&&(Ya(void 0),Hi({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)})))},[Ja,Ya]=(0,F.useState)(),Xa=Ja?l.workspaces.find(e=>e.id===Ja):void 0,{theme:Za,setTheme:Qa}=KE(),[$a,eo]=(0,F.useState)(!1),[to,no]=(0,F.useState)(!1),ro=(e,t,n,r)=>{e.startsWith(`pending:`)||(Hi({type:`workspace.settings`,workspaceId:e,model:n?{provider:n.provider,modelId:n.modelId}:null,thinkingLevel:r??null,agentId:t??null},`defaults:${e}`,Ki(e,{defaultModel:n,defaultThinkingLevel:r,defaultAgentId:t}))?Ya(void 0):Ai(`连接断开,设置未保存,请重试`,`error`))},io=(e,t=``)=>{if(e.startsWith(`pending:`))return;if(a.current.some(t=>t.key===`defaults:${e}`)){Ai(`工作区设置正在保存,请稍后再新建会话`,`warning`);return}let n=`pending:${fE()}`,r={id:n,workspaceId:e,title:`新会话`,status:`idle`,updatedAt:new Date().toISOString(),messages:[],...t?{cwd:t}:{}};dn.current.set(n,r),Hi({type:`conversation.create`,workspaceId:e,...t?{cwd:t}:{}},`create-session:${e}:${n}`,e=>({...e,conversations:[r,...e.conversations]}),n)?(w.current++,y(e),d(n),fr(`session`),x(e=>({...e,ids:[...e.ids.filter(e=>e!==n),n],touched:qz(e.touched,n)}))):(dn.current.delete(n),Ai(`连接断开,会话未创建,请重试`,`error`))},ao=e=>{if(e.startsWith(`pending:`))return;let t=l.conversations.find(t=>t.id===e);if(!t||t.archivedAt||t.parentConversationId&&l.conversations.some(e=>e.id===t.parentConversationId))return;let n=eR(l.conversations,e),r=n.filter(e=>!e.archivedAt),i=r.length-1,a=n.length-r.length,o=IL(l.pendingUserDecisionsByConversation,n.map(e=>e.id)),s=LL({title:t.title,activeCount:r.length,activeDescendants:i,alreadyArchived:a,pendingDecisions:o});if(RL({activeDescendants:i,pendingDecisions:o})&&!window.confirm(s))return;let c=new Date().toISOString(),u=new Set(r.map(e=>e.id));Hi({type:`conversation.archive`,conversationId:e},`archive:${e}`,e=>({...e,conversations:e.conversations.map(e=>u.has(e.id)&&!e.archivedAt?{...e,archivedAt:c}:e)}))},oo=(e,t)=>Hi({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}),so=e=>{let t=l.conversations.find(t=>t.id===e);if(!t?.archivedAt||(t.parentConversationId?l.conversations.find(e=>e.id===t.parentConversationId):void 0)?.archivedAt)return;let n=new Set(eR(l.conversations,e).filter(e=>e.archivedAt).map(e=>e.id));Hi({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})}))},co=async e=>{if(!P){Ai(`请先选择或创建会话`,`error`);return}if(!ra){Ai(`当前模型不支持图片输入`,`error`);return}let t=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],n=e.filter(e=>t.includes(e.type)?e.size>5242880?(Ai(`图片「${e.name}」超过 5MB 上限`,`error`),!1):!0:(Ai(`不支持的文件格式「${e.name}」,仅支持 PNG/JPEG/GIF/WebP`,`error`),!1));if(n.length===0)return;let r=P.id;Bn(r,e=>({...e,uploading:e.uploading+n.length}));let i=n.map(e=>({id:fE(),conversationId:r,name:e.name,url:URL.createObjectURL(e)}));Xt(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 fetch(`/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`)){Ai(`服务器未返回 JSON 响应,请刷新或重启服务`,`error`);continue}if(i.ok){let e=await i.json();if(Kt.current.has(n.id))continue;Xt(e=>e.filter(e=>e.id!==n.id)),URL.revokeObjectURL(n.url),Bn(r,t=>({...t,images:[...t.images,{id:e.id,name:e.name,mimeType:e.mimeType,bytes:e.bytes}]}))}else{let e=await i.json().catch(()=>({error:`上传失败`}));Ai(dp(e.error,`上传失败(HTTP ${i.status})`),`error`)}}catch(e){Ai(`上传失败:${dp(e,`网络或服务暂时不可用`)}`,`error`)}finally{Xt(e=>e.map(e=>e.id===n.id?{...e,failed:!0}:e)),Bn(r,e=>({...e,uploading:Math.max(0,e.uploading-1)}))}}},lo=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(!ra){Ai(`当前模型不支持图片输入`,`error`);return}e.preventDefault(),co(n)}},uo=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),en(!0))},fo=e=>{e.currentTarget.contains(e.relatedTarget)||en(!1)},po=e=>{en(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>e.type.startsWith(`image/`));if(t.length>0){if(e.preventDefault(),!ra){Ai(`当前模型不支持图片输入`,`error`);return}co(t)}},mo=t=>{if(t.preventDefault(),!P)return;if(Tn){Ai(jL,`warning`);return}if(Yi){Ai(qi?`会话正在创建,请稍候再发送`:P.messagesLoaded===!1?`正在加载会话,请稍候再发送`:`正在保存配置,请稍候再发送`,`info`);return}if(!In.trim()&&Ln.length===0)return;if(Ln.length>0&&!ra){Ai(`当前模型不支持图片输入,请移除图片或切换至支持图文的模型`,`error`);return}if(zn>0){Ai(`图片正在上传中,请稍候…`,`info`);return}let n=`message_${fE()}`,r=P.id,i=In,a=Ln,o=Rn;cr(r),e.stoppingConversationIds||It(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t});let s=jR({conversationId:r,content:i,clientId:n,images:a,attachments:Rn,inFlight:XR(P),deliveryMode:vn}),c=new Date().toISOString();Hi(s,`send:${r}:${n}`,e=>uw(e,s,c),n,e=>{Jt(t=>[...t,{id:n,conversationId:r,content:i,images:a,attachments:o,reason:e}]),Bn(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===n))&&Bn(P.id,e=>({...e,text:``,images:[]}))},ho=(0,F.useMemo)(()=>(P?.messages??[]).filter(e=>(e.role===`user`||e.role===`tool`)&&e.delivery),[P?.messages]),go=e=>{Hi({type:`message.cancel`,conversationId:P?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===P?.id?{...t,messages:t.messages.filter(t=>t.id!==e)}:t)}))||Ai(`连接断开,撤回没有生效,请重试`,`error`)},_o=e=>{if(!P?.id||!e.length)return;let t=new Set(e),n=`queue-many:${P.id}:${e.join(`,`)}`;Hi({type:`message.cancelMany`,conversationId:P.id,messageIds:e},n,e=>({...e,conversations:e.conversations.map(e=>e.id===P.id?{...e,messages:e.messages.filter(e=>!t.has(e.id))}:e)}),void 0,e=>Ai(e??`撤回所选消息失败,请重试`,`error`),t=>{let n=t.conversations.find(e=>e.id===P.id);return!!(n&&e.every(e=>!n.messages.some(t=>t.id===e&&t.delivery)))})||Ai(`连接断开,批量撤回没有生效,请重试`,`error`)},vo=e=>{Hi({type:`message.steer`,conversationId:P?.id??``,messageId:e},`queue:${e}`,t=>({...t,conversations:t.conversations.map(t=>t.id===P?.id?{...t,messages:VL(t.messages,e,0)}:t)}),void 0,void 0,t=>t.conversations.find(e=>e.id===P?.id)?.messages.find(t=>t.id===e)?.delivery===`sending`)||Ai(`连接断开,插到最前没有生效,请重试`,`error`)},yo=e=>{let t=P?.id;t&&(M.current?.readyState===WebSocket.OPEN?Hi({type:`message.interrupt`,conversationId:t,messageId:e},`interrupt:${t}:${e}`,e=>e,void 0,e=>Ai(e??`打断失败,请重试`,`error`),n=>{let r=n.conversations.find(e=>e.id===t)?.messages.find(t=>t.id===e);return!(!r||r.delivery)},3e4)||Ai(`正在打断,请稍候`,`info`):Ai(`连接断开,打断没有生效,请重试`,`error`))},bo=e=>{Hi({type:`message.sendQueued`,conversationId:P?.id??``,messageId:e},`send-queued:${e}`,e=>e,void 0,void 0,t=>!t.conversations.find(e=>e.id===P?.id)?.messages.find(t=>t.id===e)?.delivery)||Ai(`连接断开,发送没有生效,请重试`,`error`)},xo=(e,t)=>{Hi({type:`message.edit`,conversationId:P?.id??``,messageId:e,content:t},`edit:${e}`,n=>({...n,conversations:n.conversations.map(n=>n.id===P?.id?{...n,messages:n.messages.map(n=>n.id===e?{...n,content:t}:n)}:n)}))||Ai(`连接断开,修改没有生效,请重试`,`error`)},[L,R]=(0,F.useState)(),So=(e,t=!1)=>{if(!P||P.messagesLoaded===!1||L)return;let n=P.messages.find(t=>t.id===e);n&&(n&&Ut(e=>{let t=e[P.id]??{text:``,images:[],attachments:[],uploading:0};return t.text.trim()||t.images.length||t.attachments.length?e:{...e,[P.id]:{...t,text:n.content,images:n.images??[]}}}),Pt({conversationId:P.id,messageId:e,kind:t?`withdraw`:`revert`})),Vi({type:`message.revert`,conversationId:P.id,messageId:e,withdraw:t})?R(e):(Pt(void 0),Ai(`连接断开,回退未执行,请重试`,`error`))},[Co,wo]=(0,F.useState)(),To=(0,F.useRef)(void 0),Eo=(0,F.useRef)(0),Do=async(e,t)=>{let n=++Eo.current,r=await xx(t);n===Eo.current&&(clearTimeout(To.current),wo({id:e,kind:r?`copied`:`error`}),r||Ai(`复制失败:浏览器拒绝了剪贴板写入,可以手动选中这条消息的文字复制`,`error`),To.current=setTimeout(()=>wo(void 0),2e3))};(0,F.useEffect)(()=>()=>{Eo.current+=1,clearTimeout(To.current)},[]);let[Oo,ko]=(0,F.useState)(),Ao=e=>{Oo||e.startsWith(`pending:`)||(cr(e),Vi({type:`conversation.fork`,conversationId:e})?ko(e):Ai(`连接断开,分叉没有执行,请重试`,`error`))},jo=new Map;for(let e of l.scheduledTasks??[])e.conversationId&&!jo.has(e.conversationId)&&jo.set(e.conversationId,e);let Mo=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-theme-open":`1`,title:`设置`,"aria-haspopup":`dialog`,"aria-expanded":$a,onClick:()=>{eo(!0),Vi({type:`catalog.fetchAll`}),Vi({type:`providers.fetch`})},children:[(0,I.jsx)(Zp,{name:`settings`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:`设置`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,"data-help-open":`1`,title:`使用指南`,"aria-haspopup":`dialog`,"aria-expanded":to,onClick:()=>no(!0),children:[(0,I.jsx)(Zp,{name:`help`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:`使用指南`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger`,title:`检查 Super Pi 更新`,disabled:et!==`idle`||rt,onClick:async()=>{tt(`updating`);let e=!1;try{let t=await fetch(`/api/update-check`);if(!t.ok)throw Error(`check failed`);let n=await t.json();if(n.updating===!0)e=!0,it(!0),Ii(),Ai(`更新正在进行中,请等待它结束`,`info`);else if(n.needsRestart)Ai(`当前代码已更新,正在重启服务…`,`info`);else if(n.updateAvailable){if(!window.confirm(`发现新版本 v${n.latestVersion??``},是否立即更新并重启 Super Pi?`))Ai(`已取消更新`,`info`);else{if(!(await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({version:n.latestVersion})})).ok)throw Error(`update failed`);e=!0,Ai(`正在更新到 v${n.latestVersion} 并重启…`,`info`),Ii()}}else Ai(`当前已是最新版本`,`info`)}catch{Ai(`检查更新失败,请检查网络或服务日志`,`error`)}finally{e||tt(`idle`)}},children:[(0,I.jsx)(Zp,{name:`update`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:rt?`正在更新…`:et===`updating`?`正在检查更新…`:`检查更新`})]}),Qe?.needsRestart&&(0,I.jsxs)(`button`,{type:`button`,className:`theme-settings-trigger restart-needed-trigger`,disabled:et!==`idle`||rt,title:`代码已更新:当前运行 v${Qe.runningVersion},磁盘版本 v${Qe.diskVersion}。点击复制重启命令 /super_pi restart`,onClick:async()=>{tt(`updating`);try{if(!(await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({restartOnly:!0})})).ok)throw Error(`update failed`);Ai(`正在重启 Super Pi 服务…`,`info`),Ii(`restart`)}catch{tt(`idle`),Ai(`更新启动失败,请检查服务日志`,`error`)}},children:[(0,I.jsx)(Zp,{name:`update`}),(0,I.jsx)(`span`,{className:`workbench-action-label`,children:rt||et===`updating`?`正在更新并重启…`:`更新并重启服务`})]})]}),No={onOpenSession:e=>{lr(e),dt()},todos:l.todosByConversation?.[P?.id??``]??[],tasks:dz(P,l.backgroundTasks??[]),messages:P?.messages??[],execOutputs:pe.current,scheduledTasks:(l.scheduledTasks??[]).filter(e=>e.workspaceId===pr),scheduledCatalog:ia(Be,Ei),scheduledAgents:Je,notify:Ai,serverTimeZone:l.serverTimeZone,workspaceId:pr,workspaceLabel:Ei?.path,workspaceName:Ei?.name,conversationId:P?.id,cwd:mr,connected:f&&E&&!P?.id.startsWith(`pending:`),files:hr,onOpenFile:si,onOpenChanged:$r,onFileReference:ci,onFilesMoved:li,onSelectTab:kr,sendCommand:Vi,registerTerminalSink:be,terminalShell:l.terminalShell,sharedGit:gr},Po=gr.status?.detached?`游离 HEAD`:gr.status?.branch,z=gr.status&&new Set([...gr.status.staged,...gr.status.unstaged,...gr.status.untracked].map(e=>e.path)).size,Fo=gr.status&&(gr.status.ahead||gr.status.behind)?[gr.status.ahead?`↑`+gr.status.ahead:``,gr.status.behind?`↓`+gr.status.behind:``].filter(Boolean).join(` `):``,Io=()=>_t(e=>({...e,rightClosed:!0})),Lo=()=>_t(e=>({...e,leftClosed:!0})),Ro=Et?at:Pr;return(0,I.jsxs)(`main`,{className:`shell workbench-shell${Ro?` shell-rail-collapsed`:``} mobile-panel-${st}${ft?` mobile-drawer-open`:``}`,"data-rail-collapsed":Ro,"data-workbench-left-closed":!Et&&gt.leftClosed,"data-selected-workspace":v??``,style:{"--sidebar-width":`${bt.sidebar}px`,"--rail-col":Ro?void 0:`${bt.rail}px`},children:[!Et&&(0,I.jsx)(Qp,{side:`left`,views:Ar,unpinned:gt.unpinned,active:gt.leftClosed?void 0:Mr,onSelect:e=>Ir(e,!0),onSearch:()=>Ur(!0),children:Mo}),(0,I.jsxs)(`aside`,{className:`workbench-sessions`,id:`workbench-sessions`,"data-workbench-session-view":Fr?`shown`:`hidden`,children:[(0,I.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,I.jsx)(`button`,{className:`workspace-new`,onClick:()=>k(!0),children:`+ 添加工作区`}),P&&sr&&pi.length===1&&(0,I.jsx)(`button`,{type:`button`,className:`mobile-close-session`,onClick:()=>{vi(P.id),pt(!1)},children:`关闭当前标签`})]}),(0,I.jsx)(`div`,{className:`label label-desktop`,children:`工作区`}),(0,I.jsx)(`div`,{className:`label label-phone`,children:`会话`}),(0,I.jsx)(`nav`,{"aria-label":`工作区与会话`,children:l.workspaces.map(e=>{let t=l.conversations.filter(t=>t.workspaceId===e.id),n=t.filter(e=>!e.archivedAt),r=kI(n,gn,{manualRoots:Ce[e.id]}),i=r.filter(e=>e.depth===0).map(e=>e.conversation.id),a=t.filter(e=>e.archivedAt),o=kI(a,new Set),s=g[e.id]??!1,c=xe[e.id]??!0;return(0,I.jsxs)(`section`,{className:`workspace-group`,"data-workspace-group":e.id,"data-current-workspace":v===e.id,children:[(0,I.jsx)(`div`,{className:`workspace-header`,children:Wa(`workspace`,e.id)?(0,I.jsx)(BR,{initial:e.name,label:`重命名工作区 ${e.name}`,onCommit:t=>Ga(`workspace`,e.id,t),onClose:Ua}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`workspace-toggle`,"aria-expanded":!s,"aria-label":e.name,title:e.path,onContextMenu:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect();Rt({workspace:e,x:t.clientX||n.left+24,y:t.clientY||n.top+n.height})},onClick:()=>{let t=mn.find(t=>t.workspaceId===e.id)?.id;t&&t!==P?.id?lr(t):(y(e.id),t||(w.current++,d(void 0))),_(t=>({...t,[e.id]:!s}))},children:[(0,I.jsx)(`span`,{className:`chevron chevron-folder`,"aria-hidden":`true`,children:s?`▸`:`▾`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{onDoubleClick:()=>Ha(`workspace`,e.id),children:e.name}),(0,I.jsx)(`small`,{children:e.path})]})]}),(0,I.jsx)(`button`,{className:`workspace-add`,title:`在此工作区新建会话`,onClick:t=>{j.current=t.currentTarget,ee({workspaceId:e.id})},children:`+`}),(0,I.jsx)(`button`,{className:`workspace-settings`,title:`工作区设置(默认智能体 / 模型 / 思考强度)`,"aria-label":`工作区设置 ${e.name}`,onClick:()=>Ya(e.id),children:`⚙`})]})}),!s&&(r.length?r.map(({conversation:t,depth:r,childCount:a,isLastSibling:o})=>(0,I.jsxs)(`div`,{className:`conversation-row`,style:{"--tree-depth":r},"data-session-root":r===0?t.id:void 0,"data-session-dragging":Te?.conversationId===t.id?`true`:void 0,"data-session-drop":Te?.dropRootId===t.id?Te.dropAfter?`after`:`before`:void 0,onPointerDown:r===0?n=>ke(n,e.id,t.id,i):void 0,children:[a>0?(0,I.jsxs)(`button`,{type:`button`,className:`conversation-tree-toggle`,"data-tree-toggle":t.id,"aria-expanded":!gn.has(t.id),title:gn.has(t.id)?`展开 ${a} 个子会话`:`折叠 ${a} 个子会话`,"aria-label":gn.has(t.id)?`展开会话 ${t.title} 的 ${a} 个子会话`:`折叠会话 ${t.title} 的 ${a} 个子会话`,onClick:()=>oo(t.id,!gn.has(t.id)),children:[(0,I.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:gn.has(t.id)?`▸`:`▾`}),(0,I.jsx)(`small`,{children:a})]}):(0,I.jsx)(`span`,{className:`conversation-tree-spacer`,"aria-hidden":`true`}),Wa(`conversation`,t.id)?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(BR,{initial:t.title,label:`重命名会话 ${t.title}`,onCommit:e=>Ga(`conversation`,t.id,e),onClose:Ua}),(0,I.jsx)(`small`,{className:`conversation-time`,children:$L(t.updatedAt,fn)})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`conversation ${P?.id===t.id?`selected`:``}`,"data-conversation":t.id,"aria-current":P?.id===t.id?`true`:void 0,"data-tree-child":r>0?`true`:void 0,"data-tree-last":r>0&&o?`true`:void 0,title:r>0?`${t.title}(由「${n.find(e=>e.id===t.parentConversationId)?.title??`已不存在的会话`}」创建)`:t.title,"aria-label":`打开会话 ${t.title}${az(t,jo.get(t.id))}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.getBoundingClientRect();Bt({conversation:t,x:e.clientX||n.left+24,y:e.clientY||n.top+n.height})},onClick:()=>{t.id===Oe.current&&Date.now()-De.current<300||(lr(t.id),y(e.id),pt(!1))},onDoubleClick:()=>{ur(t.id)},children:[(0,I.jsx)(`i`,{className:`conversation-mark`,children:(0,I.jsx)(rz,{state:tz(t,$R(t,nt),ne.current[t.id],l.conversations)})}),(0,I.jsx)(`span`,{"data-conversation-title":t.id,onDoubleClick:e=>{e.stopPropagation(),Ha(`conversation`,t.id)},style:{flex:`0 1 auto`,minWidth:`3.5em`},children:t.title}),(0,I.jsx)(`span`,{className:`conversation-title-gap`,"aria-hidden":`true`,style:{marginLeft:`-8px`}}),nz(tz(t,$R(t,nt),ne.current[t.id],l.conversations),ez(t,l.conversations,ne.current[t.id])),iz(t,jo.get(t.id)),(0,I.jsx)(`small`,{children:$L(t.updatedAt,fn)})]}),(0,I.jsx)(`button`,{type:`button`,className:`conversation-fork`,"data-fork-conversation":t.id,"data-fork-state":Oo===t.id?`pending`:`idle`,disabled:!!Oo,title:`从此会话分叉出一个新会话`,"aria-label":`从会话 ${t.title} 分叉出一个新会话`,onClick:()=>Ao(t.id),children:`⑂`}),!(t.parentConversationId&&l.conversations.some(e=>e.id===t.parentConversationId))&&(0,I.jsx)(`button`,{className:`conversation-archive`,"data-archive-conversation":t.id,title:`归档整棵会话树`,"aria-label":`归档会话 ${t.title}`,onClick:()=>ao(t.id),children:`×`})]})]},t.id)):(0,I.jsx)(`div`,{className:`conversation-empty`,children:`暂无会话`})),!s&&a.length>0&&(0,I.jsxs)(`div`,{className:`archived-group`,"data-archived-count":a.length,children:[(0,I.jsxs)(`button`,{className:`archived-toggle`,title:c?`展开已归档会话`:`收起已归档会话`,"aria-expanded":!c,onClick:()=>Se(t=>({...t,[e.id]:!c})),children:[(0,I.jsx)(`span`,{className:`chevron`,"aria-hidden":`true`,children:c?`▸`:`▾`}),(0,I.jsxs)(`span`,{className:`archived-label`,children:[`已归档 (`,a.length,`)`]})]}),!c&&o.map(({conversation:e,depth:t,isLastSibling:n})=>{let r=eR(a,e.id).length-1,i=!!(e.parentConversationId&&l.conversations.some(t=>t.id===e.parentConversationId&&t.archivedAt));return(0,I.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,I.jsx)(`i`,{className:`conversation-mark`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{"data-archived-title":e.id,children:e.title}),iz(e,jo.get(e.id)),(0,I.jsx)(`small`,{children:tR(e.archivedAt)}),!i&&(0,I.jsx)(`button`,{className:`conversation-restore`,"data-restore-conversation":e.id,title:r?`恢复这个会话和它的 ${r} 个子孙会话`:`恢复为正常会话`,"aria-label":r?`恢复会话 ${e.title} 及其 ${r} 个子孙会话`:`恢复会话 ${e.title}`,onClick:()=>so(e.id),children:`↑`})]},e.id)})]}),!s&&(()=>{let t=l.warmSessions?.filter(t=>t.workspaceId===e.id)??[];return t.length?(0,I.jsxs)(`details`,{className:`archived-group`,"data-warm-sessions":e.id,children:[(0,I.jsx)(`summary`,{className:`archived-toggle`,children:(0,I.jsxs)(`span`,{className:`archived-label`,children:[`预热会话 (`,t.length,`)`]})}),t.map(e=>(0,I.jsxs)(`div`,{className:`conversation-archived`,"data-warm-session":e.id,children:[(0,I.jsx)(`span`,{title:e.title,children:e.title}),(0,I.jsx)(`button`,{type:`button`,className:`conversation-restore`,"aria-label":`移除预热会话 ${e.title}`,onClick:()=>{window.confirm(`移除预热会话「${e.title}」?`)&&!Vi({type:`conversation.warm.delete`,conversationId:e.id})&&Ai(`连接断开,未移除预热会话`,`error`)},children:`×`})]},e.id))]}):null})()]},e.id)})}),Et&&(0,I.jsx)(`footer`,{className:`workbench-mobile-utilities`,children:Mo})]}),!Et&&!gt.leftClosed&&Mr!==`sessions`&&(0,I.jsx)(mz,{...No,side:`left`,activeTab:Mr,collapsed:!1,onToggle:Lo,pinned:!gt.unpinned.includes(Mr),onArrange:Lr}),(Et||!gt.leftClosed)&&(0,I.jsx)($z,{side:`left`,width:bt.sidebar,min:bt.sidebarMin,max:bt.sidebarMax,label:`调整左侧栏宽度`,onWidth:xt}),(0,I.jsxs)(`section`,{className:`chat`,"data-main-view":dr,"data-main-view-kind":dr,children:[pi.length>0&&(0,I.jsx)(`div`,{className:`chat-tab-strip`,"data-chat-tab-strip":`1`,"data-session-count":ar.length,"data-file-count":hr.open.length,children:(0,I.jsx)(DT,{tabs:pi,prefix:`workspace-tab`,ariaLabel:`工作区标签页`,activeId:mi,onSelect:gi,onClose:yi,onActivate:_i,minWidth:120,maxWidth:320})}),(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`button`,{type:`button`,className:`mobile-drawer-toggle`,"data-mobile-drawer-toggle":`1`,"aria-label":`打开会话列表`,title:`会话列表`,"aria-expanded":ft,onClick:()=>pt(!0),children:`☰`}),(0,I.jsxs)(`div`,{className:`chat-head`,children:[(0,I.jsx)(`h1`,{children:P?.title??`准备开始`}),va.size>0?[...va].map(([e,t])=>(0,I.jsx)(`p`,{"data-role":`run-status`,"data-status-key":e,children:`扩展状态:${e?`${e} · `:``}${t}`},e)):null]}),(0,I.jsxs)(`span`,{className:`chat-view chat-view-${dr}`,"data-main-view-indicator":dr,"data-main-view-kind":dr,title:dr===`file`?`中间主画面正在显示文件 ${hr.active?.path??``}`:dr===`diff`?`中间主画面正在显示 ${Kr??``} 的改动`:`中间主画面正在显示这个会话的消息流`,children:[(0,I.jsx)(`span`,{className:`chat-view-kind`,children:dr===`file`?`文件`:dr===`diff`?`改动`:`会话`}),dr===`file`&&hr.active&&(0,I.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":hr.active.name,children:hr.active.name}),dr===`diff`&&Kr&&(0,I.jsx)(`span`,{className:`chat-view-name`,"data-main-view-name":Kr,children:Kr})]}),(0,I.jsx)(`div`,{className:`badge`,"data-workbench-header-status":On||P?.status===`failed`?`attention`:`routine`,"data-conversation-status":P?.status??`idle`,...On?{"data-reporting-status":On}:{},children:On===`awaiting_decision`?`等上面拍板`:XR(P)?YR[P?.status??`idle`]:On===`awaiting_subordinates`?`等待下级`:On===`pending_report`?`待汇报`:YR[P?.status??`idle`]}),(0,I.jsx)(`button`,{type:`button`,className:`mobile-tools-toggle`,"data-mobile-nav":`rail`,onClick:()=>{ct(`rail`),ot(!1)},children:`工具`})]}),m&&(0,I.jsxs)(`div`,{className:`error`,role:`alert`,"data-global-error":!0,children:[(0,I.jsx)(`span`,{title:fp(m),children:dp(m)}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`关闭错误提示`,title:`关闭错误提示`,onClick:()=>h(void 0),children:`×`})]}),P?.error&&(0,I.jsx)(`div`,{className:`error`,"data-role":`conversation-error`,title:fp(P.error),children:dp(P.error)}),P?.warning&&(0,I.jsxs)(`div`,{className:`warning`,role:`status`,"data-role":`conversation-warning`,title:fp(P.warning),children:[(0,I.jsx)(`span`,{children:P.warning}),(0,I.jsx)(`button`,{type:`button`,"data-role":`conversation-warning-continue`,title:`让模型接着把被截断的部分写完`,onClick:()=>Wi(P?.id??``),children:`继续写完`})]}),P?.modelNotice&&(0,I.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-model-notice`,children:P.modelNotice}),P?.agentNotice&&(0,I.jsx)(`div`,{className:`model-notice`,"data-role":`conversation-agent-notice`,children:P.agentNotice}),ba&&(0,I.jsxs)(`div`,{className:`extui-title-note`,children:[`扩展建议标题:`,ba]}),Re.length>0&&(0,I.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,"data-toast-count":Re.length,children:Re.map(e=>(0,I.jsx)(`div`,{className:`toast toast-${e.kind}`,"data-toast-kind":e.kind,children:e.text},e.key))}),dr===`file`?(0,I.jsx)(`div`,{className:`chat-file-view`,"data-main-file-view":bi?.path,"data-file-view-kind":`editor`,children:bi?.view&&pr?(0,I.jsx)(nS,{workspaceId:pr,cwd:mr,path:bi.path,name:bi.name,kind:bi.view,content:bi.content,version:bi.etag,source:Oi,external:hr.external[bi.path],navigation:Di,sourceRequest:Wr?.path===bi.path&&Wr.workspaceId===pr?Wr.request:void 0},`${pr}:${mr}:${bi.path}`):Oi??(0,I.jsx)(`p`,{className:`rail-empty`,"data-main-file-empty":`1`,children:`没有选中的文件。`})}):dr===`diff`?(0,I.jsx)(`div`,{className:`chat-file-view`,"data-main-diff-view":Kr??``,"data-file-view-kind":`diff`,children:(0,I.jsx)(dT,{diff:ei.diff,loading:ei.loading,error:ei.error,bufferContent:ii,mode:ni,onMode:ri})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`messages`,ref:ae,"data-message-scroll-container":P?.id??``,onWheel:e=>{e.deltaY<0&&N.current[P?.id??``]?.followTail&&(fe.current=!0,Pn(e.currentTarget,!0))},onScroll:e=>{let t=e.currentTarget;t.dataset.programmaticScroll===`true`?delete t.dataset.programmaticScroll:Pn(t)},children:[(!P||!sr)&&(0,I.jsxs)(`div`,{className:`empty`,children:[(0,I.jsx)(`div`,{className:`orb`,children:`π`}),(0,I.jsx)(`h2`,{children:`开始一个新会话`}),l.workspaces.length===0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:`先创建一个工作区,再开始会话。`}),(0,I.jsx)(`button`,{onClick:()=>k(!0),children:`+ 新建工作区`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:l.workspaces.length===1&&An?`在「${An.name}」中创建会话,即可向 Super Pi 发送任务。`:`选择工作区即可开始会话,向 Super Pi 发送任务。`}),l.workspaces.length>1&&(0,I.jsxs)(`div`,{className:`empty-workspace-select`,children:[(0,I.jsx)(`label`,{htmlFor:`empty-workspace-choice`,children:`工作区:`}),(0,I.jsxs)(`select`,{id:`empty-workspace-choice`,"aria-label":`选择工作区`,value:An?.id,onChange:e=>{e.target.value===`__new__`?k(!0):y(e.target.value)},children:[l.workspaces.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,I.jsx)(`option`,{value:`__new__`,children:`+ 新建工作区…`})]})]}),An&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(hR,{workspaceId:An.id,value:jn,onChange:Mn}),(0,I.jsx)(`button`,{onClick:()=>io(An.id,jn),children:`新建会话`})]}),(0,I.jsx)(`span`,{className:`empty-secondary-action`,role:`button`,tabIndex:0,onClick:()=>k(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),k(!0))},children:`+ 新建工作区`})]})]}),P?.messagesLoaded===!1&&(0,I.jsx)(`p`,{role:`status`,"data-conversation-loading":`1`,children:`正在加载会话…`}),Oa.map(e=>{if(e.startsWith(`m:`)){let t=Ta.get(e.slice(2));if(!t)return null;let n=t.id===ka,i=t.role===`user`&&P?.status!==`running`&&P?.status!==`waiting`&&L!==t.id,a=i&&n&&!t.id.startsWith(`pending:`),o=i&&!n&&!!t.piEntryId,s=t.content?(0,I.jsx)(Px,{source:t.content,media:_n}):(0,I.jsx)(`span`,{className:`typing`,children:`正在思考`});if(t.source===`session-reminder`)return(0,I.jsx)(`article`,{className:`message message-reminder`,"data-transcript-key":e,"data-message-reminder":t.id,children:(0,I.jsxs)(`details`,{children:[(0,I.jsxs)(`summary`,{className:`reminder-header`,children:[(0,I.jsxs)(`span`,{className:`reminder-label`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,I.jsx)(`time`,{dateTime:t.createdAt,children:KL(t.createdAt)})]}),(0,I.jsx)(`div`,{className:`content`,children:s})]})},e);let c=t.toolCalls??[],l=Co?.id===t.id?Co.kind:void 0;if(t.role===`user`){let n=t.content||(t.images?.length?`[图片]`:``);return(0,I.jsxs)(`article`,{className:`message user`,"data-transcript-key":e,children:[(0,I.jsxs)(`div`,{className:`message-body`,children:[(0,I.jsxs)(`div`,{className:`bubble`,children:[(0,I.jsxs)(`div`,{className:`meta`,children:[Ne,(0,I.jsx)(`time`,{children:KL(t.createdAt)})]}),t.images&&t.images.length>0&&(0,I.jsx)(`div`,{className:`message-images`,"data-message-images":`1`,children:t.images.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`message-image-btn`,"data-message-image-id":e.id,onClick:()=>Qt({url:`/api/upload/${encodeURIComponent(P?.id??``)}/${encodeURIComponent(e.id)}`,name:e.name,bytes:e.bytes}),title:e.name?`查看大图:${e.name}`:`查看大图`,children:(0,I.jsx)(`img`,{src:`/api/upload/${encodeURIComponent(P?.id??``)}/${encodeURIComponent(e.id)}`,alt:e.name||`图片`,className:`message-image-thumb`,loading:`lazy`})},e.id))}),(0,I.jsx)(`div`,{className:`content`,children:s})]}),t.attachments&&t.attachments.length>0&&(0,I.jsx)(`div`,{className:`message-attachments`,"data-message-attachments":`1`,children:t.attachments.map(e=>{let n=`att:${t.id}:${e.kind}:${e.id}`,r=kt[n]??!1;return(0,I.jsxs)(`div`,{className:`message-attachment`,"data-message-attachment":e.kind,children:[(0,I.jsxs)(`button`,{type:`button`,className:`message-attachment-head`,"data-message-attachment-toggle":e.id,"aria-expanded":r,onClick:()=>At(e=>({...e,[n]:!r})),children:[(0,I.jsx)(`span`,{className:`message-attachment-glyph`,"aria-hidden":`true`,children:`▤`}),(0,I.jsx)(`span`,{className:`message-attachment-label`,children:`技能`}),(0,I.jsx)(`span`,{className:`message-attachment-name`,title:e.name,children:e.name}),(0,I.jsx)(`span`,{className:`message-attachment-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`})]}),r&&(0,I.jsx)(`pre`,{className:`message-attachment-body`,"data-message-attachment-body":e.id,children:e.content})]},n)})}),(0,I.jsxs)(`div`,{className:`message-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":l,"aria-label":`复制这条消息:${n}`,onClick:()=>Do(t.id,n),children:l===`copied`?`已复制`:l===`error`?`复制失败`:`复制`}),a&&(0,I.jsx)(`button`,{type:`button`,className:`message-revert`,"data-withdraw-message":t.id,title:`撤回并编辑:删除这条消息并将文字恢复到输入框继续编辑`,onClick:()=>So(t.id,!0),children:`撤回`}),o&&(0,I.jsx)(`button`,{type:`button`,className:`message-revert`,"data-revert-message":t.id,title:`回退到这里:删除后续全部内容(Pi 的记录和这里的历史一起清掉,不会新建会话,也不动任何代码文件)`,onClick:()=>So(t.id),children:`回退`})]})]}),(0,I.jsx)(`div`,{className:`avatar`,title:Ne,children:Ne})]},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(`
361
361
  `).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=(()=>{let e=/<result_file>([\s\S]*?)<\/result_file>/.exec(t.content);return e&&e[1].trim()?e[1].trim():void 0})(),s=(()=>{let e=/<task id="([^"]+)"/.exec(t.content);return e?e[1]:void 0})(),c=!!(s&&mn.some(e=>e.id===s)),l=`tool:${t.id}`,u=kt[l]??!1,d=n?`后台回传`:`智能体下发`;return(0,I.jsx)(`article`,{className:`message tool${n?``:` tool-order`}`,"data-transcript-key":e,"data-tool-state":i,"data-tool-kind":n?`delivery`:`order`,children:(0,I.jsxs)(`div`,{className:`message-body`,children:[(0,I.jsxs)(`div`,{className:`bg-result-head`,"data-bg-result-head":t.id,children:[(0,I.jsxs)(`button`,{type:`button`,className:`bg-result-toggle`,"data-bg-result-toggle":t.id,"aria-expanded":u,title:u?`折叠${d}`:`展开${d}`,onClick:()=>At(e=>({...e,[l]:!u})),children:[(0,I.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:i===`error`?`✕`:n?`↩`:`↓`}),(0,I.jsx)(`span`,{className:`bg-result-label`,children:d}),(0,I.jsx)(`span`,{className:`bg-result-summary`,title:r,children:r}),!u&&(0,I.jsx)(`span`,{className:`bg-result-preview`,"data-bg-result-preview":t.id,title:`展开查看完整输出`,children:a.split(`
362
362
  `).slice(-1)[0]}),(0,I.jsx)(`span`,{className:`bg-result-chevron`,"aria-hidden":`true`,children:u?`▾`:`▸`})]}),(o||c&&s)&&(0,I.jsxs)(`div`,{className:`bg-result-actions`,"data-bg-result-actions":t.id,children:[o&&(0,I.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-file-link":o,title:`在主区域打开产物文件:${o}`,onClick:e=>{e.stopPropagation();let t=o.split(/[/\\]/).pop()||o;oi({path:o,name:t,text:!0}).catch(e=>{console.warn(`打开产物文件失败:`,e)})},children:[(0,I.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`📄`}),(0,I.jsx)(`span`,{children:`查看产物文件`})]}),c&&s&&(0,I.jsxs)(`button`,{type:`button`,className:`bg-result-action`,"data-result-session-link":s,title:`跳转到子会话:${s}`,onClick:e=>{e.stopPropagation(),lr(s)},children:[(0,I.jsx)(`span`,{className:`bg-result-action-glyph`,"aria-hidden":`true`,children:`↗`}),(0,I.jsx)(`span`,{children:`跳转到子会话`})]})]})]}),u&&(0,I.jsx)(`div`,{className:`bg-result-body`,"data-bg-result-body":t.id,children:(0,I.jsx)(`pre`,{className:`bg-result-pre`,"data-bg-result-pre":t.id,children:a})})]})},e)}let u=t.thinking?.trim()?t.thinking:``,d=t.thinkingBlocks?.length?t.thinkingBlocks:u?[{at:0,text:u}]:[],f=(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<u.length||t.thinkingActive)?-1:d.findIndex((t,n)=>(e.at??0)>=t.at&&(d[n+1]===void 0||(e.at??0)<d[n+1].at)):e.thinkingBlock??-1,m=e=>c.map((e,t)=>({call:e,index:t})).filter(({call:t})=>p(t)===e),h=[],g=[...d.map((e,t)=>({at:e.at,order:d.slice(0,t).reduce((e,t)=>e+t.text.length,0)*2+1,segment:{blockIndex:t}})),...c.map((e,t)=>({at:f(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=Da.get(e);if(t)return(0,I.jsx)(`div`,{className:`call-anchored-run`,"data-call-anchored-run":t.id,"data-call-anchored-site":e,children:(0,I.jsx)(AR,{run:t,name:wa.get(t.agentId)??``,expanded:!!Dt[t.id],onToggle:()=>Aa(t.id),onStop:()=>Ia(t.id),stopping:r.some(e=>e.key===`stop:${t.id}`)})})},y=e=>e.call.question?(0,I.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,I.jsx)(LR,{question:e.call.question,index:e.index,expanded:`${t.id}:${e.index}`in jt?!!jt[`${t.id}:${e.index}`]:!0,onToggle:()=>Ma(t.id,e.index),onAnswer:(n,r)=>Xi(P?.id??``,t.id,e.index,n,r)})},`c${e.index}`):(0,I.jsx)(`div`,{className:`call-blocks`,"data-call-block-index":e.index,children:(0,I.jsx)(DR,{call:e.call,index:e.index,expanded:`${t.id}:${e.index}`in kt&&!!kt[`${t.id}:${e.index}`],onToggle:()=>ja(t.id,e.index),backgroundOutput:e.call.backgroundTask&&(0,I.jsx)(ER,{task:e.call.backgroundTask,execOutputs:pe.current,expanded:`${t.id}:${e.index}`in kt&&!!kt[`${t.id}:${e.index}`]}),runCard:v(`${t.id}:${e.index}`)})},`c${e.index}`),b=e=>{let n=d[e],r=d.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,I.jsx)(`div`,{className:`content thinking-text`,children:(0,I.jsx)(Px,{source:n.text.slice(i,e),media:_n})},`t${o}`)),a.push(y({call:t,index:o})),i=e}i<n.text.length&&a.push((0,I.jsx)(`div`,{className:`content thinking-text`,children:(0,I.jsx)(Px,{source:n.text.slice(i),media:_n})},`tail`));let o=m(e).filter(e=>e.call.status===void 0),s=o.find(e=>e.call.question?.status===`pending`);return(0,I.jsx)(kR,{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(`
363
363
  `).map(e=>e.trim()).find(Boolean)??``,expanded:Na[`${t.id}:${e}`]===!0,onToggle:()=>Fa(`${t.id}:${e}`),children:a},`${t.id}:thinking:${e}`)};return(0,I.jsxs)(`article`,{className:`message assistant`,"data-transcript-key":e,children:[(0,I.jsx)(`div`,{className:`avatar`,children:`π`}),(0,I.jsxs)(`div`,{className:`message-body`,children:[(0,I.jsxs)(`div`,{className:`meta`,children:[t.agentIdentity?.name??`Super Pi`,(0,I.jsx)(`time`,{children:KL(t.createdAt)})]}),h.length===0&&(P?.status===`running`||P?.status===`waiting`)?(0,I.jsx)(`div`,{className:`content`,children:(0,I.jsx)(`span`,{className:`typing`,children:`正在思考`})}):h.map((e,t)=>`blockIndex`in e?b(e.blockIndex):`text`in e?e.text?(0,I.jsx)(`div`,{className:`content`,children:(0,I.jsx)(Px,{source:e.text,media:_n})},`t${t}`):null:y(e)),t.content.trim()&&(0,I.jsx)(`div`,{className:`message-actions`,children:(0,I.jsx)(`button`,{type:`button`,className:`message-copy`,"data-copy-message":t.id,"data-copy-state":l,"aria-label":`复制智能体回复`,onClick:()=>void Do(t.id,t.content),children:(0,I.jsx)(`span`,{"aria-live":`polite`,children:l===`copied`?`已复制`:l===`error`?`复制失败`:`复制`})})})]})]},e)}if(e.startsWith(`w:`)){let t=Ca.get(e.slice(2));return t?(0,I.jsxs)(`div`,{"data-transcript-key":e,children:[r.some(e=>e.key===`stop:${t.id}`)&&(0,I.jsx)(`span`,{children:`停止中…`}),(0,I.jsx)(IT,{workflow:t,names:wa,stopping:r.some(e=>e.key===`stop:${t.id}`),onStop:()=>La(t.id)},e)]},e):null}let t=Ea.get(e.slice(2));return t?(0,I.jsxs)(`div`,{"data-transcript-key":e,children:[r.some(e=>e.key===`stop:${t.id}`)&&(0,I.jsx)(`span`,{children:`停止中…`}),(0,I.jsx)(AR,{run:t,stopping:r.some(e=>e.key===`stop:${t.id}`),name:wa.get(t.agentId)??``,expanded:!!Dt[t.id],onToggle:()=>Aa(t.id),onStop:()=>Ia(t.id)},e)]},e):null})]}),(0,I.jsx)(NR,{messages:ho,pendingInterrupts:r.filter(e=>e.key.startsWith(`interrupt:${P?.id}:`)).map(e=>e.key.slice(`interrupt:${P?.id}:`.length)),running:P?.status===`running`,onSteer:vo,onInterrupt:yo,onSend:bo,onCancel:go,onCancelMany:_o,onEdit:xo}),(0,I.jsxs)(`div`,{className:`stream-tail`,"data-stream-tail":`1`,"data-follow-tail":ue.followTail?`true`:`false`,children:[Ct!==null&&(0,I.jsx)(oB,{height:Ct,onHeight:Tt}),(0,I.jsx)(`span`,{className:`stream-tail-status`,"data-run-status":P?.status??`idle`,"data-stream-state":f?Ji?`stopping`:P&&$R(P,nt)?`question`:P?.status===`waiting`?`waiting`:P?.status===`running`?`streaming`:P?.status===`awaiting_background`||ho.length?`waiting`:P?.status===`failed`?`failed`:On===`awaiting_decision`?`awaiting_decision`:On===`awaiting_subordinates`?`awaiting_subordinates`:On===`pending_report`?`pending_report`:`ready`:`waiting`,children:f?qi?`正在创建会话…`:Ji?`正在停止…`:P&&$R(P,nt)?`等你回答 · Agent 在等你的回复`:P?.messagesLoaded===!1?`正在加载会话…`:P?.status===`waiting`?`等待 LLM 返回`:P?.status===`running`?`Streaming · 正在生成`:P?.status===`awaiting_background`?`等待后台任务 · 任务在后台运行中`:ho.length?`Waiting · 消息排队中`:P?.status===`failed`?`运行失败`:P?.status===`stopped`?`已停止`:On===`awaiting_decision`?`等待上级处理例外…`:On===`awaiting_subordinates`?`等待下级汇报…`:On===`pending_report`?`已完成,待向父会话汇报`:`就绪`:`连接中 / 等待连接`}),!ue.followTail&&(0,I.jsx)(`button`,{type:`button`,className:`stream-tail-jump`,"data-jump-to-bottom":`1`,onClick:()=>{let e=ae.current;e&&(Hz(e),e.scrollTop=e.scrollHeight,Pn(e,!1,!0))},children:`↓ 跳到底部`}),(0,I.jsx)(`span`,{className:`stream-tail-mode`,"data-follow-tail":ue.followTail?`true`:`false`,children:ue.followTail?`贴底`:`自由浏览`})]}),(ga.length>0||[...ya.values()].some(e=>e.placement===`aboveEditor`))&&(0,I.jsxs)(`div`,{className:`extui`,"data-extui-count":ga.length,children:[ga.map(e=>(0,I.jsx)(zR,{request:e.request,pending:r.some(t=>t.key===`answer:${e.conversationId}:${e.request.requestId}`),onAnswer:t=>Zi(e.conversationId,e.request.requestId,t)},e.request.requestId)),Ra(`aboveEditor`)]}),(0,I.jsxs)(`form`,{onSubmit:mo,onPaste:lo,onDragOver:uo,onDragLeave:fo,onDrop:po,className:$t?`composer-dropzone-active`:void 0,children:[(0,I.jsxs)(`div`,{className:`composer-input`,"data-composer-input":`1`,children:[(0,I.jsx)(`textarea`,{ref:oe,value:In,onCompositionStart:()=>{nn.current=!0,Jn(void 0)},onCompositionEnd:e=>{nn.current=!1,$n.current=``,tr(e.currentTarget)},onSelect:e=>{e.currentTarget===document.activeElement&&tr(e.currentTarget)},"aria-autocomplete":er?`list`:void 0,"aria-controls":er?`file-mention-menu`:void 0,"aria-activedescendant":er?Xn:void 0,onChange:e=>{Vn(e.target.value),e.target.value!==In&&cr(P?.id??``);let t=e.target.value;if($n.current=``,tr(e.currentTarget))return;let n=e.target.selectionStart??t.length,r=t.slice(0,n),i=r.lastIndexOf(`/`),a=r.slice(i+1),o=i>0?r[i-1]:``;i>=0&&(i===0||/\s/.test(o))&&/^[\w:-]*$/u.test(a)?Gn({visible:!0,query:a,rect:e.currentTarget.getBoundingClientRect()}):Gn({visible:!1,query:``,rect:null})},placeholder:P?ra?`描述你要完成的任务(支持粘贴/拖放图片)…`:`描述你要完成的任务…`:`先创建会话`,disabled:!P,readOnly:Tn,"aria-describedby":Tn?`child-session-lock-reason`:void 0,onKeyDown:e=>{if(!(nn.current||BL(e))&&!(er&&Yn.current?.handleKey(e))){if(Wn.visible){if(e.key===`Escape`){e.preventDefault(),Gn({visible:!1,query:``,rect:null});return}if([`ArrowDown`,`ArrowUp`,`Enter`].includes(e.key)){e.preventDefault();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}}),Tn&&(0,I.jsxs)(`div`,{className:`composer-lock`,"data-child-session-lock":`1`,role:`note`,"aria-labelledby":`child-session-lock-title`,children:[(0,I.jsx)(`span`,{className:`composer-lock-glyph`,"data-child-session-lock-glyph":`1`,"aria-hidden":`true`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`30`,height:`30`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,focusable:`false`,children:[(0,I.jsx)(`rect`,{x:`4`,y:`10`,width:`16`,height:`11`,rx:`2.5`}),(0,I.jsx)(`path`,{d:`M8 10V7a4 4 0 0 1 8 0v3`}),(0,I.jsx)(`path`,{d:`M12 14.5v2.5`})]})}),(0,I.jsxs)(`span`,{className:`composer-lock-text`,children:[(0,I.jsx)(`span`,{className:`composer-lock-title`,"data-child-session-lock-title":`1`,id:`child-session-lock-title`,children:`子会话输入框已上锁`}),(0,I.jsx)(`span`,{className:`composer-lock-reason`,"data-child-session-lock-reason":`1`,id:`child-session-lock-reason`,children:`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`})]}),(0,I.jsx)(`button`,{type:`button`,className:`composer-lock-action`,"data-child-session-unlock":`1`,onClick:()=>Ui(P?.id??``,!0),children:`临时解锁`})]})]}),er&&P?.workspaceId&&(0,I.jsx)(Kx,{ref:Yn,workspaceId:P.workspaceId,cwd:P.cwd??``,query:er.token.query,anchor:er.rect,onClose:nr,onActive:Zn,onChoose:e=>{let t=oe.current,n=t?.value??In,r=t?qx(n,t.selectionStart,t.selectionEnd):void 0;if(!r||r.start!==er.token.start||r.query!==er.token.query){nr();return}let i=Jx(n,r,e);Qn.current={scope:Kn,...i},Vn(i.text),Jn(void 0)}},Kn),!er&&Wn.visible&&Wn.rect&&(0,I.jsx)(Gx,{query:Wn.query,anchorRect:Wn.rect,workspaceId:P?.workspaceId,promptCatalog:Pe,command:Vi,onSelect:e=>{if(e.id.startsWith(`skill:`)){let t=e.id.slice(6),n=document.querySelector(`[data-selected-workspace]`)?.dataset.selectedWorkspace??P?.workspaceId,r=new URLSearchParams({name:t,...n?{workspaceId:n}:{}});fetch(`/api/skills/read?${r.toString()}`).then(async n=>{if(!n.ok){Ai(`读取技能失败`,`error`);return}let r=await n.json();typeof r.content==`string`&&Hn({kind:`skill`,id:r.id??e.id,name:r.name??t,content:r.content})}).catch(()=>Ai(`读取技能失败`,`error`))}let t=oe.current?.selectionStart??In.length,n=In.slice(0,t),r=n.lastIndexOf(`/`),i=Ux(e,Wn.query),a=`${n.slice(0,r)}/${i} ${In.slice(t)}`;Vn(a),Gn({visible:!1,query:``,rect:null})},onClose:()=>Gn({visible:!1,query:``,rect:null})}),xn.filter(e=>e.conversationId===P?.id).map(e=>(0,I.jsxs)(`div`,{className:`composer-notice queue-withdrawn-notice`,"data-queue-withdrawn-notice":`1`,role:`status`,children:[(0,I.jsx)(`span`,{className:`composer-notice-mark`,"aria-hidden":`true`,children:`↺`}),(0,I.jsxs)(`div`,{className:`composer-notice-body`,children:[(0,I.jsx)(`p`,{className:`composer-notice-title`,children:e.actor===`agent`?`上级 Agent 已撤回 ${e.withdrawn.length} 条排队消息(不会再被回答)`:`已撤回 ${e.withdrawn.length} 条排队消息(不会再被回答)`}),(0,I.jsx)(`p`,{className:`composer-notice-text`,title:e.withdrawn.map(e=>e.content).join(`