nterminal 1.2.75 → 1.2.77

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 (85) hide show
  1. package/.env.example +3 -0
  2. package/README.md +1 -1
  3. package/dist/client/assets/MarkdownPreview-D5NthhhG.js +1 -0
  4. package/dist/client/assets/{TranscriptMarkdownBody-B-RKybd7.js → TranscriptMarkdownBody-BkGu6YVq.js} +1 -1
  5. package/dist/client/assets/index-B3_mYQzf.css +1 -0
  6. package/dist/client/assets/{index-CH_JmAuw.js → index-Bgqck-vt.js} +1 -1
  7. package/dist/client/assets/index-gSePR0Ob.js +57 -0
  8. package/dist/client/index.html +2 -2
  9. package/dist/scripts/onboarding.js +106 -41
  10. package/dist/scripts/onboarding.js.map +1 -1
  11. package/dist/server/agent/agentProxy.d.ts +2 -2
  12. package/dist/server/agent/agentProxy.js.map +1 -1
  13. package/dist/server/agent/agentWebSocketProxy.d.ts +2 -2
  14. package/dist/server/agent/agentWebSocketProxy.js.map +1 -1
  15. package/dist/server/agent/outboundAgentClient.d.ts +21 -0
  16. package/dist/server/agent/outboundAgentClient.js +237 -0
  17. package/dist/server/agent/outboundAgentClient.js.map +1 -0
  18. package/dist/server/agent/outboundAgentRegistry.d.ts +25 -0
  19. package/dist/server/agent/outboundAgentRegistry.js +190 -0
  20. package/dist/server/agent/outboundAgentRegistry.js.map +1 -0
  21. package/dist/server/agent/socketWebSocketRelay.d.ts +6 -0
  22. package/dist/server/agent/socketWebSocketRelay.js +107 -0
  23. package/dist/server/agent/socketWebSocketRelay.js.map +1 -0
  24. package/dist/server/auth/authService.js +4 -1
  25. package/dist/server/auth/authService.js.map +1 -1
  26. package/dist/server/code/codeServerManager.d.ts +7 -1
  27. package/dist/server/code/codeServerManager.js +95 -38
  28. package/dist/server/code/codeServerManager.js.map +1 -1
  29. package/dist/server/config.d.ts +3 -0
  30. package/dist/server/config.js +33 -0
  31. package/dist/server/config.js.map +1 -1
  32. package/dist/server/http.d.ts +1 -0
  33. package/dist/server/http.js +18 -2
  34. package/dist/server/http.js.map +1 -1
  35. package/dist/server/index.js +21 -2
  36. package/dist/server/index.js.map +1 -1
  37. package/dist/server/notifications/agentCompletionMonitor.d.ts +4 -1
  38. package/dist/server/notifications/agentCompletionMonitor.js +23 -4
  39. package/dist/server/notifications/agentCompletionMonitor.js.map +1 -1
  40. package/dist/server/notifications/completionNotificationRouter.d.ts +2 -1
  41. package/dist/server/notifications/completionNotificationRouter.js +4 -2
  42. package/dist/server/notifications/completionNotificationRouter.js.map +1 -1
  43. package/dist/server/notifications/pushNotificationService.d.ts +20 -2
  44. package/dist/server/notifications/pushNotificationService.js +129 -14
  45. package/dist/server/notifications/pushNotificationService.js.map +1 -1
  46. package/dist/server/routes/agentLinkRoutes.d.ts +9 -0
  47. package/dist/server/routes/agentLinkRoutes.js +129 -0
  48. package/dist/server/routes/agentLinkRoutes.js.map +1 -0
  49. package/dist/server/routes/agentManagementRoutes.d.ts +2 -0
  50. package/dist/server/routes/agentManagementRoutes.js +147 -101
  51. package/dist/server/routes/agentManagementRoutes.js.map +1 -1
  52. package/dist/server/routes/codeServerRoutes.js +28 -31
  53. package/dist/server/routes/codeServerRoutes.js.map +1 -1
  54. package/dist/server/routes/httpProxyBody.d.ts +10 -0
  55. package/dist/server/routes/httpProxyBody.js +73 -0
  56. package/dist/server/routes/httpProxyBody.js.map +1 -0
  57. package/dist/server/routes/pushNotificationRoutes.js +31 -2
  58. package/dist/server/routes/pushNotificationRoutes.js.map +1 -1
  59. package/dist/server/runtimeState.js +9 -0
  60. package/dist/server/runtimeState.js.map +1 -1
  61. package/dist/server/storage/fileStore.d.ts +2 -1
  62. package/dist/server/storage/fileStore.js +7 -1
  63. package/dist/server/storage/fileStore.js.map +1 -1
  64. package/dist/server/terminal/TerminalManager.d.ts +2 -1
  65. package/dist/server/terminal/TerminalManager.js +27 -7
  66. package/dist/server/terminal/TerminalManager.js.map +1 -1
  67. package/dist/server/terminal/agentTranscriptStatus.d.ts +2 -2
  68. package/dist/server/terminal/agentTranscriptStatus.js +224 -38
  69. package/dist/server/terminal/agentTranscriptStatus.js.map +1 -1
  70. package/dist/server/update/packageUpdate.d.ts +1 -0
  71. package/dist/server/update/packageUpdate.js +34 -2
  72. package/dist/server/update/packageUpdate.js.map +1 -1
  73. package/dist/shared/agentLinkProtocol.d.ts +26 -0
  74. package/dist/shared/agentLinkProtocol.js +49 -0
  75. package/dist/shared/agentLinkProtocol.js.map +1 -0
  76. package/dist/shared/protocol.d.ts +18 -3
  77. package/dist/shared/protocol.js.map +1 -1
  78. package/dist/shared/types.d.ts +3 -1
  79. package/docs/configuration.md +3 -0
  80. package/docs/onboarding.md +9 -12
  81. package/package.json +1 -1
  82. package/scripts/nterminalctl +21 -0
  83. package/dist/client/assets/MarkdownPreview-CStdB1d5.js +0 -1
  84. package/dist/client/assets/index-DwmyYdjx.css +0 -1
  85. package/dist/client/assets/index-idJa2lVq.js +0 -57
@@ -1,57 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CStdB1d5.js","assets/index-CH_JmAuw.js","assets/TranscriptMarkdownBody-B-RKybd7.js"])))=>i.map(i=>d[i]);
2
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();function Zk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Up={exports:{}},ic={};var _S;function Qk(){if(_S)return ic;_S=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,l,c){var d=null;if(c!==void 0&&(d=""+c),l.key!==void 0&&(d=""+l.key),"key"in l){c={};for(var m in l)m!=="key"&&(c[m]=l[m])}else c=l;return l=c.ref,{$$typeof:e,type:s,key:d,ref:l!==void 0?l:null,props:c}}return ic.Fragment=t,ic.jsx=n,ic.jsxs=n,ic}var vS;function Jk(){return vS||(vS=1,Up.exports=Qk()),Up.exports}var p=Jk(),Kp={exports:{}},tt={};var bS;function eE(){if(bS)return tt;bS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function x(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,B={};function L(M,X,ue){this.props=M,this.context=X,this.refs=B,this.updater=ue||C}L.prototype.isReactComponent={},L.prototype.setState=function(M,X){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,X,"setState")},L.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function O(){}O.prototype=L.prototype;function Y(M,X,ue){this.props=M,this.context=X,this.refs=B,this.updater=ue||C}var U=Y.prototype=new O;U.constructor=Y,D(U,L.prototype),U.isPureReactComponent=!0;var Z=Array.isArray;function W(){}var re={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function ye(M,X,ue){var be=ue.ref;return{$$typeof:e,type:M,key:X,ref:be!==void 0?be:null,props:ue}}function Ee(M,X){return ye(M.type,X,M.props)}function ne(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function q(M){var X={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ue){return X[ue]})}var Q=/\/+/g;function K(M,X){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):X.toString(36)}function se(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(W,W):(M.status="pending",M.then(function(X){M.status==="pending"&&(M.status="fulfilled",M.value=X)},function(X){M.status==="pending"&&(M.status="rejected",M.reason=X)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function A(M,X,ue,be,ve){var xe=typeof M;(xe==="undefined"||xe==="boolean")&&(M=null);var Re=!1;if(M===null)Re=!0;else switch(xe){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(M.$$typeof){case e:case t:Re=!0;break;case y:return Re=M._init,A(Re(M._payload),X,ue,be,ve)}}if(Re)return ve=ve(M),Re=be===""?"."+K(M,0):be,Z(ve)?(ue="",Re!=null&&(ue=Re.replace(Q,"$&/")+"/"),A(ve,X,ue,"",function(Pe){return Pe})):ve!=null&&(ne(ve)&&(ve=Ee(ve,ue+(ve.key==null||M&&M.key===ve.key?"":(""+ve.key).replace(Q,"$&/")+"/")+Re)),X.push(ve)),1;Re=0;var Me=be===""?".":be+":";if(Z(M))for(var ze=0;ze<M.length;ze++)be=M[ze],xe=Me+K(be,ze),Re+=A(be,X,ue,xe,ve);else if(ze=x(M),typeof ze=="function")for(M=ze.call(M),ze=0;!(be=M.next()).done;)be=be.value,xe=Me+K(be,ze++),Re+=A(be,X,ue,xe,ve);else if(xe==="object"){if(typeof M.then=="function")return A(se(M),X,ue,be,ve);throw X=String(M),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return Re}function R(M,X,ue){if(M==null)return M;var be=[],ve=0;return A(M,be,"","",function(xe){return X.call(ue,xe,ve++)}),be}function P(M){if(M._status===-1){var X=M._result;X=X(),X.then(function(ue){(M._status===0||M._status===-1)&&(M._status=1,M._result=ue)},function(ue){(M._status===0||M._status===-1)&&(M._status=2,M._result=ue)}),M._status===-1&&(M._status=0,M._result=X)}if(M._status===1)return M._result.default;throw M._result}var ie=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ge={map:R,forEach:function(M,X,ue){R(M,function(){X.apply(this,arguments)},ue)},count:function(M){var X=0;return R(M,function(){X++}),X},toArray:function(M){return R(M,function(X){return X})||[]},only:function(M){if(!ne(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return tt.Activity=b,tt.Children=ge,tt.Component=L,tt.Fragment=n,tt.Profiler=l,tt.PureComponent=Y,tt.StrictMode=s,tt.Suspense=g,tt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=re,tt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return re.H.useMemoCache(M)}},tt.cache=function(M){return function(){return M.apply(null,arguments)}},tt.cacheSignal=function(){return null},tt.cloneElement=function(M,X,ue){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var be=D({},M.props),ve=M.key;if(X!=null)for(xe in X.key!==void 0&&(ve=""+X.key),X)!ee.call(X,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&X.ref===void 0||(be[xe]=X[xe]);var xe=arguments.length-2;if(xe===1)be.children=ue;else if(1<xe){for(var Re=Array(xe),Me=0;Me<xe;Me++)Re[Me]=arguments[Me+2];be.children=Re}return ye(M.type,ve,be)},tt.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},tt.createElement=function(M,X,ue){var be,ve={},xe=null;if(X!=null)for(be in X.key!==void 0&&(xe=""+X.key),X)ee.call(X,be)&&be!=="key"&&be!=="__self"&&be!=="__source"&&(ve[be]=X[be]);var Re=arguments.length-2;if(Re===1)ve.children=ue;else if(1<Re){for(var Me=Array(Re),ze=0;ze<Re;ze++)Me[ze]=arguments[ze+2];ve.children=Me}if(M&&M.defaultProps)for(be in Re=M.defaultProps,Re)ve[be]===void 0&&(ve[be]=Re[be]);return ye(M,xe,ve)},tt.createRef=function(){return{current:null}},tt.forwardRef=function(M){return{$$typeof:m,render:M}},tt.isValidElement=ne,tt.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:P}},tt.memo=function(M,X){return{$$typeof:f,type:M,compare:X===void 0?null:X}},tt.startTransition=function(M){var X=re.T,ue={};re.T=ue;try{var be=M(),ve=re.S;ve!==null&&ve(ue,be),typeof be=="object"&&be!==null&&typeof be.then=="function"&&be.then(W,ie)}catch(xe){ie(xe)}finally{X!==null&&ue.types!==null&&(X.types=ue.types),re.T=X}},tt.unstable_useCacheRefresh=function(){return re.H.useCacheRefresh()},tt.use=function(M){return re.H.use(M)},tt.useActionState=function(M,X,ue){return re.H.useActionState(M,X,ue)},tt.useCallback=function(M,X){return re.H.useCallback(M,X)},tt.useContext=function(M){return re.H.useContext(M)},tt.useDebugValue=function(){},tt.useDeferredValue=function(M,X){return re.H.useDeferredValue(M,X)},tt.useEffect=function(M,X){return re.H.useEffect(M,X)},tt.useEffectEvent=function(M){return re.H.useEffectEvent(M)},tt.useId=function(){return re.H.useId()},tt.useImperativeHandle=function(M,X,ue){return re.H.useImperativeHandle(M,X,ue)},tt.useInsertionEffect=function(M,X){return re.H.useInsertionEffect(M,X)},tt.useLayoutEffect=function(M,X){return re.H.useLayoutEffect(M,X)},tt.useMemo=function(M,X){return re.H.useMemo(M,X)},tt.useOptimistic=function(M,X){return re.H.useOptimistic(M,X)},tt.useReducer=function(M,X,ue){return re.H.useReducer(M,X,ue)},tt.useRef=function(M){return re.H.useRef(M)},tt.useState=function(M){return re.H.useState(M)},tt.useSyncExternalStore=function(M,X,ue){return re.H.useSyncExternalStore(M,X,ue)},tt.useTransition=function(){return re.H.useTransition()},tt.version="19.2.6",tt}var yS;function o_(){return yS||(yS=1,Kp.exports=eE()),Kp.exports}var _=o_();const Ai=Zk(_);var Wp={exports:{}},nc={},Fp={exports:{}},qp={};var SS;function tE(){return SS||(SS=1,(function(e){function t(A,R){var P=A.length;A.push(R);e:for(;0<P;){var ie=P-1>>>1,ge=A[ie];if(0<l(ge,R))A[ie]=R,A[P]=ge,P=ie;else break e}}function n(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var R=A[0],P=A.pop();if(P!==R){A[0]=P;e:for(var ie=0,ge=A.length,M=ge>>>1;ie<M;){var X=2*(ie+1)-1,ue=A[X],be=X+1,ve=A[be];if(0>l(ue,P))be<ge&&0>l(ve,ue)?(A[ie]=ve,A[be]=P,ie=be):(A[ie]=ue,A[X]=P,ie=X);else if(be<ge&&0>l(ve,P))A[ie]=ve,A[be]=P,ie=be;else break e}}return R}function l(A,R){var P=A.sortIndex-R.sortIndex;return P!==0?P:A.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var g=[],f=[],y=1,b=null,w=3,x=!1,C=!1,D=!1,B=!1,L=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function U(A){for(var R=n(f);R!==null;){if(R.callback===null)s(f);else if(R.startTime<=A)s(f),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(f)}}function Z(A){if(D=!1,U(A),!C)if(n(g)!==null)C=!0,W||(W=!0,q());else{var R=n(f);R!==null&&se(Z,R.startTime-A)}}var W=!1,re=-1,ee=5,ye=-1;function Ee(){return B?!0:!(e.unstable_now()-ye<ee)}function ne(){if(B=!1,W){var A=e.unstable_now();ye=A;var R=!0;try{e:{C=!1,D&&(D=!1,O(re),re=-1),x=!0;var P=w;try{t:{for(U(A),b=n(g);b!==null&&!(b.expirationTime>A&&Ee());){var ie=b.callback;if(typeof ie=="function"){b.callback=null,w=b.priorityLevel;var ge=ie(b.expirationTime<=A);if(A=e.unstable_now(),typeof ge=="function"){b.callback=ge,U(A),R=!0;break t}b===n(g)&&s(g),U(A)}else s(g);b=n(g)}if(b!==null)R=!0;else{var M=n(f);M!==null&&se(Z,M.startTime-A),R=!1}}break e}finally{b=null,w=P,x=!1}R=void 0}}finally{R?q():W=!1}}}var q;if(typeof Y=="function")q=function(){Y(ne)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,K=Q.port2;Q.port1.onmessage=ne,q=function(){K.postMessage(null)}}else q=function(){L(ne,0)};function se(A,R){re=L(function(){A(e.unstable_now())},R)}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(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ee=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(A){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var P=w;w=R;try{return A()}finally{w=P}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(A,R){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var P=w;w=A;try{return R()}finally{w=P}},e.unstable_scheduleCallback=function(A,R,P){var ie=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?ie+P:ie):P=ie,A){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=P+ge,A={id:y++,callback:R,priorityLevel:A,startTime:P,expirationTime:ge,sortIndex:-1},P>ie?(A.sortIndex=P,t(f,A),n(g)===null&&A===n(f)&&(D?(O(re),re=-1):D=!0,se(Z,P-ie))):(A.sortIndex=ge,t(g,A),C||x||(C=!0,W||(W=!0,q()))),A},e.unstable_shouldYield=Ee,e.unstable_wrapCallback=function(A){var R=w;return function(){var P=w;w=R;try{return A.apply(this,arguments)}finally{w=P}}}})(qp)),qp}var wS;function iE(){return wS||(wS=1,Fp.exports=tE()),Fp.exports}var $p={exports:{}},rn={};var CS;function nE(){if(CS)return rn;CS=1;var e=o_();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(g,f,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:b==null?null:""+b,children:g,containerInfo:f,implementation:y}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,rn.createPortal=function(g,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,y)},rn.flushSync=function(g){var f=d.T,y=s.p;try{if(d.T=null,s.p=2,g)return g()}finally{d.T=f,s.p=y,s.d.f()}},rn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},rn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},rn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin),w=typeof f.integrity=="string"?f.integrity:void 0,x=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;y==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:x}):y==="script"&&s.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},rn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var y=m(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},rn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin);s.d.L(g,y,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},rn.preloadModule=function(g,f){if(typeof g=="string")if(f){var y=m(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},rn.requestFormReset=function(g){s.d.r(g)},rn.unstable_batchedUpdates=function(g,f){return g(f)},rn.useFormState=function(g,f,y){return d.H.useFormState(g,f,y)},rn.useFormStatus=function(){return d.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var xS;function zw(){if(xS)return $p.exports;xS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$p.exports=nE(),$p.exports}var kS;function rE(){if(kS)return nc;kS=1;var e=iE(),t=o_(),n=zw();function s(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function d(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function m(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var r=i.alternate;if(!r){if(r=c(i),r===null)throw Error(s(188));return r!==i?null:i}for(var a=i,o=r;;){var u=a.return;if(u===null)break;var h=u.alternate;if(h===null){if(o=u.return,o!==null){a=o;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===a)return g(u),i;if(h===o)return g(u),r;h=h.sibling}throw Error(s(188))}if(a.return!==o.return)a=u,o=h;else{for(var v=!1,k=u.child;k;){if(k===a){v=!0,a=u,o=h;break}if(k===o){v=!0,o=u,a=h;break}k=k.sibling}if(!v){for(k=h.child;k;){if(k===a){v=!0,a=h,o=u;break}if(k===o){v=!0,o=h,a=u;break}k=k.sibling}if(!v)throw Error(s(189))}}if(a.alternate!==o)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:r}function y(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=y(i),r!==null)return r;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),re=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),ye=Symbol.for("react.activity"),Ee=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function q(i){return i===null||typeof i!="object"?null:(i=ne&&i[ne]||i["@@iterator"],typeof i=="function"?i:null)}var Q=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Q?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case L:return"Profiler";case B:return"StrictMode";case Z:return"Suspense";case W:return"SuspenseList";case ye:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case C:return"Portal";case Y:return i.displayName||"Context";case O:return(i._context.displayName||"Context")+".Consumer";case U:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case re:return r=i.displayName||null,r!==null?r:K(i.type)||"Memo";case ee:r=i._payload,i=i._init;try{return K(i(r))}catch{}}return null}var se=Array.isArray,A=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},ie=[],ge=-1;function M(i){return{current:i}}function X(i){0>ge||(i.current=ie[ge],ie[ge]=null,ge--)}function ue(i,r){ge++,ie[ge]=i.current,i.current=r}var be=M(null),ve=M(null),xe=M(null),Re=M(null);function Me(i,r){switch(ue(xe,r),ue(ve,i),ue(be,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?Hy(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=Hy(r),i=Uy(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}X(be),ue(be,i)}function ze(){X(be),X(ve),X(xe)}function Pe(i){i.memoizedState!==null&&ue(Re,i);var r=be.current,a=Uy(r,i.type);r!==a&&(ue(ve,i),ue(be,a))}function ce(i){ve.current===i&&(X(be),X(ve)),Re.current===i&&(X(Re),Qo._currentValue=P)}var _e,Se;function Ae(i){if(_e===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);_e=r&&r[1]||"",Se=-1<a.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+_e+i+Se}var Ue=!1;function Be(i,r){if(!i||Ue)return"";Ue=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(te){var G=te}Reflect.construct(i,[],fe)}else{try{fe.call()}catch(te){G=te}i.call(fe.prototype)}}else{try{throw Error()}catch(te){G=te}(fe=i())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(te){if(te&&G&&typeof te.stack=="string")return[te.stack,G.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=o.DetermineComponentFrameRoot(),v=h[0],k=h[1];if(v&&k){var N=v.split(`
5
- `),V=k.split(`
6
- `);for(u=o=0;o<N.length&&!N[o].includes("DetermineComponentFrameRoot");)o++;for(;u<V.length&&!V[u].includes("DetermineComponentFrameRoot");)u++;if(o===N.length||u===V.length)for(o=N.length-1,u=V.length-1;1<=o&&0<=u&&N[o]!==V[u];)u--;for(;1<=o&&0<=u;o--,u--)if(N[o]!==V[u]){if(o!==1||u!==1)do if(o--,u--,0>u||N[o]!==V[u]){var oe=`
7
- `+N[o].replace(" at new "," at ");return i.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",i.displayName)),oe}while(1<=o&&0<=u);break}}}finally{Ue=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ae(a):""}function ae(i,r){switch(i.tag){case 26:case 27:case 5:return Ae(i.type);case 16:return Ae("Lazy");case 13:return i.child!==r&&r!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return Be(i.type,!1);case 11:return Be(i.type.render,!1);case 1:return Be(i.type,!0);case 31:return Ae("Activity");default:return""}}function Te(i){try{var r="",a=null;do r+=ae(i,a),a=i,i=i.return;while(i);return r}catch(o){return`
8
- Error generating stack: `+o.message+`
9
- `+o.stack}}var we=Object.prototype.hasOwnProperty,Le=e.unstable_scheduleCallback,Ve=e.unstable_cancelCallback,Je=e.unstable_shouldYield,ct=e.unstable_requestPaint,wt=e.unstable_now,qi=e.unstable_getCurrentPriorityLevel,Oi=e.unstable_ImmediatePriority,ii=e.unstable_UserBlockingPriority,le=e.unstable_NormalPriority,je=e.unstable_LowPriority,Ze=e.unstable_IdlePriority,Ge=e.log,It=e.unstable_setDisableYieldValue,Ct=null,xt=null;function Ht(i){if(typeof Ge=="function"&&It(i),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(Ct,i)}catch{}}var F=Math.clz32?Math.clz32:vi,We=Math.log,gt=Math.LN2;function vi(i){return i>>>=0,i===0?32:31-(We(i)/gt|0)|0}var Tn=256,ni=262144,_t=4194304;function kt(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Pt(i,r,a){var o=i.pendingLanes;if(o===0)return 0;var u=0,h=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var k=o&134217727;return k!==0?(o=k&~h,o!==0?u=kt(o):(v&=k,v!==0?u=kt(v):a||(a=k&~i,a!==0&&(u=kt(a))))):(k=o&~h,k!==0?u=kt(k):v!==0?u=kt(v):a||(a=o&~i,a!==0&&(u=kt(a)))),u===0?0:r!==0&&r!==u&&(r&h)===0&&(h=u&-u,a=r&-r,h>=a||h===32&&(a&4194048)!==0)?r:u}function Rt(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function Ut(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ri(){var i=_t;return _t<<=1,(_t&62914560)===0&&(_t=4194304),i}function hi(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function Zt(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function qt(i,r,a,o,u,h){var v=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var k=i.entanglements,N=i.expirationTimes,V=i.hiddenUpdates;for(a=v&~a;0<a;){var oe=31-F(a),fe=1<<oe;k[oe]=0,N[oe]=-1;var G=V[oe];if(G!==null)for(V[oe]=null,oe=0;oe<G.length;oe++){var te=G[oe];te!==null&&(te.lane&=-536870913)}a&=~fe}o!==0&&Qi(i,o,0),h!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=h&~(v&~r))}function Qi(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var o=31-F(r);i.entangledLanes|=r,i.entanglements[o]=i.entanglements[o]|1073741824|a&261930}function si(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var o=31-F(a),u=1<<o;u&r|i[o]&r&&(i[o]|=r),a&=~u}}function Ti(i,r){var a=r&-r;return a=(a&42)!==0?1:Ji(a),(a&(i.suspendedLanes|r))!==0?0:a}function Ji(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function hn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function ji(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:uS(i.type))}function Dn(i,r){var a=R.p;try{return R.p=i,r()}finally{R.p=a}}var bi=Math.random().toString(36).slice(2),fi="__reactFiber$"+bi,$t="__reactProps$"+bi,hr="__reactContainer$"+bi,ys="__reactEvents$"+bi,Qt="__reactListeners$"+bi,fr="__reactHandles$"+bi,$i="__reactResources$"+bi,pr="__reactMarker$"+bi;function Hr(i){delete i[fi],delete i[$t],delete i[ys],delete i[Qt],delete i[fr]}function fn(i){var r=i[fi];if(r)return r;for(var a=i.parentNode;a;){if(r=a[hr]||a[fi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=Yy(i);i!==null;){if(a=i[fi])return a;i=Yy(i)}return r}i=a,a=i.parentNode}return null}function qn(i){if(i=i[fi]||i[hr]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function xr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function $n(i){var r=i[$i];return r||(r=i[$i]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Vt(i){i[pr]=!0}var Ur=new Set,en={};function pn(i,r){mr(i,r),mr(i+"Capture",r)}function mr(i,r){for(en[i]=r,i=0;i<r.length;i++)Ur.add(r[i])}var Kr=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),_a={},Wr={};function mo(i){return we.call(Wr,i)?!0:we.call(_a,i)?!1:Kr.test(i)?Wr[i]=!0:(_a[i]=!0,!1)}function mn(i,r,a){if(mo(r))if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var o=r.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+a)}}function Fr(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function gn(i,r,a,o){if(o===null)i.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(r,a,""+o)}}function ai(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ol(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function va(i,r,a){var o=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,h=o.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return u.call(this)},set:function(v){a=""+v,h.call(this,v)}}),Object.defineProperty(i,r,{enumerable:o.enumerable}),{getValue:function(){return a},setValue:function(v){a=""+v},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Ss(i){if(!i._valueTracker){var r=ol(i)?"checked":"value";i._valueTracker=va(i,r,""+i[r])}}function qr(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),o="";return i&&(o=ol(i)?i.checked?"true":"false":i.value),i=o,i!==a?(r.setValue(i),!0):!1}function ws(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var Rn=/[\n"\\]/g;function tn(i){return i.replace(Rn,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Xe(i,r,a,o,u,h,v,k){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+ai(r)):i.value!==""+ai(r)&&(i.value=""+ai(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?kr(i,v,ai(r)):a!=null?kr(i,v,ai(a)):o!=null&&i.removeAttribute("value"),u==null&&h!=null&&(i.defaultChecked=!!h),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?i.name=""+ai(k):i.removeAttribute("name")}function Cs(i,r,a,o,u,h,v,k){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),r!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||r!=null)){Ss(i);return}a=a!=null?""+ai(a):"",r=r!=null?""+ai(r):a,k||r===i.value||(i.value=r),i.defaultValue=r}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,i.checked=k?i.checked:!!o,i.defaultChecked=!!o,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),Ss(i)}function kr(i,r,a){r==="number"&&ws(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Vn(i,r,a,o){if(i=i.options,r){r={};for(var u=0;u<a.length;u++)r["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=r.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&o&&(i[a].defaultSelected=!0)}else{for(a=""+ai(a),r=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,o&&(i[u].defaultSelected=!0);return}r!==null||i[u].disabled||(r=i[u])}r!==null&&(r.selected=!0)}}function $r(i,r,a){if(r!=null&&(r=""+ai(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+ai(a):""}function xs(i,r,a,o){if(r==null){if(o!=null){if(a!=null)throw Error(s(92));if(se(o)){if(1<o.length)throw Error(s(93));o=o[0]}a=o}a==null&&(a=""),r=a}a=ai(r),i.defaultValue=a,o=i.textContent,o===a&&o!==""&&o!==null&&(i.value=o),Ss(i)}function _n(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var Mn=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ba(i,r,a){var o=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?o?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":o?i.setProperty(r,a):typeof a!="number"||a===0||Mn.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function cl(i,r,a){if(r!=null&&typeof r!="object")throw Error(s(62));if(i=i.style,a!=null){for(var o in a)!a.hasOwnProperty(o)||r!=null&&r.hasOwnProperty(o)||(o.indexOf("--")===0?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="");for(var u in r)o=r[u],r.hasOwnProperty(u)&&a[u]!==o&&ba(i,u,o)}else for(var h in r)r.hasOwnProperty(h)&&ba(i,h,r[h])}function ks(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ya=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),go=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Vr(i){return go.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function vn(){}var Nn=null;function Es(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var zi=null,An=null;function Sa(i){var r=qn(i);if(r&&(i=r.stateNode)){var a=i[$t]||null;e:switch(i=r.stateNode,r.type){case"input":if(Xe(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+tn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var o=a[r];if(o!==i&&o.form===i.form){var u=o[$t]||null;if(!u)throw Error(s(90));Xe(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(r=0;r<a.length;r++)o=a[r],o.form===i.form&&qr(o)}break e;case"textarea":$r(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&Vn(i,!!a.multiple,r,!1)}}}var wa=!1;function Ca(i,r,a){if(wa)return i(r,a);wa=!0;try{var o=i(r);return o}finally{if(wa=!1,(zi!==null||An!==null)&&(Zu(),zi&&(r=zi,i=An,An=zi=null,Sa(r),i)))for(r=0;r<i.length;r++)Sa(i[r])}}function Er(i,r){var a=i.stateNode;if(a===null)return null;var o=a[$t]||null;if(o===null)return null;a=o[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(i=i.type,o=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!o;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,r,typeof a));return a}var Ln=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xa=!1;if(Ln)try{var Yr={};Object.defineProperty(Yr,"passive",{get:function(){xa=!0}}),window.addEventListener("test",Yr,Yr),window.removeEventListener("test",Yr,Yr)}catch{xa=!1}var ln=null,ka=null,Ts=null;function gr(){if(Ts)return Ts;var i,r=ka,a=r.length,o,u="value"in ln?ln.value:ln.textContent,h=u.length;for(i=0;i<a&&r[i]===u[i];i++);var v=a-i;for(o=1;o<=v&&r[a-o]===u[h-o];o++);return Ts=u.slice(i,1<o?1-o:void 0)}function Bn(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Tr(){return!0}function Et(){return!1}function pi(i){function r(a,o,u,h,v){this._reactName=a,this._targetInst=u,this.type=o,this.nativeEvent=h,this.target=v,this.currentTarget=null;for(var k in i)i.hasOwnProperty(k)&&(a=i[k],this[k]=a?a(h):h[k]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Tr:Et,this.isPropagationStopped=Et,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Tr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Tr)},persist:function(){},isPersistent:Tr}),r}var Yn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},S=pi(Yn),T=b({},Yn,{view:0,detail:0}),j=pi(T),J,pe,de,Ce=b({},T,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bo,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==de&&(de&&i.type==="mousemove"?(J=i.screenX-de.screenX,pe=i.screenY-de.screenY):pe=J=0,de=i),J)},movementY:function(i){return"movementY"in i?i.movementY:pe}}),$e=pi(Ce),it=b({},Ce,{dataTransfer:0}),li=pi(it),Jt=b({},T,{relatedTarget:0}),Xr=pi(Jt),Ph=b({},Yn,{animationName:0,elapsedTime:0,pseudoElement:0}),nu=pi(Ph),_o=b({},Yn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),vo=pi(_o),ul=b({},Yn,{data:0}),ru=pi(ul),su={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ih={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},au={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hh(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=au[i])?!!r[i]:!1}function bo(){return Hh}var Uh=b({},T,{key:function(i){if(i.key){var r=su[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Bn(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Ih[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bo,charCode:function(i){return i.type==="keypress"?Bn(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Bn(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),dl=pi(Uh),hl=b({},Ce,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),yo=pi(hl),lu=b({},T,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bo}),Kh=pi(lu),ou=b({},Yn,{propertyName:0,elapsedTime:0,pseudoElement:0}),cu=pi(ou),uu=b({},Ce,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Wh=pi(uu),du=b({},Yn,{newState:0,oldState:0}),Gr=pi(du),Fh=[9,13,27,32],So=Ln&&"CompositionEvent"in window,Ds=null;Ln&&"documentMode"in document&&(Ds=document.documentMode);var qh=Ln&&"TextEvent"in window&&!Ds,hu=Ln&&(!So||Ds&&8<Ds&&11>=Ds),_r=" ",wo=!1;function fu(i,r){switch(i){case"keyup":return Fh.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pu(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Rs=!1;function Dr(i,r){switch(i){case"compositionend":return pu(r);case"keypress":return r.which!==32?null:(wo=!0,_r);case"textInput":return i=r.data,i===_r&&wo?null:i;default:return null}}function $h(i,r){if(Rs)return i==="compositionend"||!So&&fu(i,r)?(i=gr(),Ts=ka=ln=null,Rs=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return hu&&r.locale!=="ko"?null:r.data;default:return null}}var Vh={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function fl(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Vh[i.type]:r==="textarea"}function mu(i,r,a,o){zi?An?An.push(o):An=[o]:zi=o,r=rd(r,"onChange"),0<r.length&&(a=new S("onChange","change",null,a,o),i.push({event:a,listeners:r}))}var Ms=null,E=null;function I(i){By(i,0)}function Ne(i){var r=xr(i);if(qr(r))return i}function Ke(i,r){if(i==="change")return r}var Fe=!1;if(Ln){var rt;if(Ln){var ht="oninput"in document;if(!ht){var Ot=document.createElement("div");Ot.setAttribute("oninput","return;"),ht=typeof Ot.oninput=="function"}rt=ht}else rt=!1;Fe=rt&&(!document.documentMode||9<document.documentMode)}function vt(){Ms&&(Ms.detachEvent("onpropertychange",Yt),E=Ms=null)}function Yt(i){if(i.propertyName==="value"&&Ne(E)){var r=[];mu(r,E,i,Es(i)),Ca(I,r)}}function Xn(i,r,a){i==="focusin"?(vt(),Ms=r,E=a,Ms.attachEvent("onpropertychange",Yt)):i==="focusout"&&vt()}function bn(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ne(E)}function gu(i,r){if(i==="click")return Ne(r)}function Yh(i,r){if(i==="input"||i==="change")return Ne(r)}function Rr(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var nn=typeof Object.is=="function"?Object.is:Rr;function Ns(i,r){if(nn(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),o=Object.keys(r);if(a.length!==o.length)return!1;for(o=0;o<a.length;o++){var u=a[o];if(!we.call(r,u)||!nn(i[u],r[u]))return!1}return!0}function rv(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function sv(i,r){var a=rv(i);i=0;for(var o;a;){if(a.nodeType===3){if(o=i+a.textContent.length,i<=r&&o>=r)return{node:a,offset:r-i};i=o}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=rv(a)}}function av(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?av(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function lv(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=ws(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=ws(i.document)}return r}function Xh(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Mx=Ln&&"documentMode"in document&&11>=document.documentMode,pl=null,Gh=null,Co=null,Zh=!1;function ov(i,r,a){var o=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Zh||pl==null||pl!==ws(o)||(o=pl,"selectionStart"in o&&Xh(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Co&&Ns(Co,o)||(Co=o,o=rd(Gh,"onSelect"),0<o.length&&(r=new S("onSelect","select",null,r,a),i.push({event:r,listeners:o}),r.target=pl)))}function Ea(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var ml={animationend:Ea("Animation","AnimationEnd"),animationiteration:Ea("Animation","AnimationIteration"),animationstart:Ea("Animation","AnimationStart"),transitionrun:Ea("Transition","TransitionRun"),transitionstart:Ea("Transition","TransitionStart"),transitioncancel:Ea("Transition","TransitionCancel"),transitionend:Ea("Transition","TransitionEnd")},Qh={},cv={};Ln&&(cv=document.createElement("div").style,"AnimationEvent"in window||(delete ml.animationend.animation,delete ml.animationiteration.animation,delete ml.animationstart.animation),"TransitionEvent"in window||delete ml.transitionend.transition);function Ta(i){if(Qh[i])return Qh[i];if(!ml[i])return i;var r=ml[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in cv)return Qh[i]=r[a];return i}var uv=Ta("animationend"),dv=Ta("animationiteration"),hv=Ta("animationstart"),Nx=Ta("transitionrun"),Ax=Ta("transitionstart"),Lx=Ta("transitioncancel"),fv=Ta("transitionend"),pv=new Map,Jh="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Jh.push("scrollEnd");function vr(i,r){pv.set(i,r),pn(r,[i])}var _u=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Gn=[],gl=0,ef=0;function vu(){for(var i=gl,r=ef=gl=0;r<i;){var a=Gn[r];Gn[r++]=null;var o=Gn[r];Gn[r++]=null;var u=Gn[r];Gn[r++]=null;var h=Gn[r];if(Gn[r++]=null,o!==null&&u!==null){var v=o.pending;v===null?u.next=u:(u.next=v.next,v.next=u),o.pending=u}h!==0&&mv(a,u,h)}}function bu(i,r,a,o){Gn[gl++]=i,Gn[gl++]=r,Gn[gl++]=a,Gn[gl++]=o,ef|=o,i.lanes|=o,i=i.alternate,i!==null&&(i.lanes|=o)}function tf(i,r,a,o){return bu(i,r,a,o),yu(i)}function Da(i,r){return bu(i,null,null,r),yu(i)}function mv(i,r,a){i.lanes|=a;var o=i.alternate;o!==null&&(o.lanes|=a);for(var u=!1,h=i.return;h!==null;)h.childLanes|=a,o=h.alternate,o!==null&&(o.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(u=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,u&&r!==null&&(u=31-F(a),i=h.hiddenUpdates,o=i[u],o===null?i[u]=[r]:o.push(r),r.lane=a|536870912),h):null}function yu(i){if(50<qo)throw qo=0,dp=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var _l={};function Bx(i,r,a,o){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function On(i,r,a,o){return new Bx(i,r,a,o)}function nf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Zr(i,r){var a=i.alternate;return a===null?(a=On(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function gv(i,r){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,r=a.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function Su(i,r,a,o,u,h){var v=0;if(o=i,typeof i=="function")nf(i)&&(v=1);else if(typeof i=="string")v=Ik(i,a,be.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ye:return i=On(31,a,r,u),i.elementType=ye,i.lanes=h,i;case D:return Ra(a.children,u,h,r);case B:v=8,u|=24;break;case L:return i=On(12,a,r,u|2),i.elementType=L,i.lanes=h,i;case Z:return i=On(13,a,r,u),i.elementType=Z,i.lanes=h,i;case W:return i=On(19,a,r,u),i.elementType=W,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:v=10;break e;case O:v=9;break e;case U:v=11;break e;case re:v=14;break e;case ee:v=16,o=null;break e}v=29,a=Error(s(130,i===null?"null":typeof i,"")),o=null}return r=On(v,a,r,u),r.elementType=i,r.type=o,r.lanes=h,r}function Ra(i,r,a,o){return i=On(7,i,o,r),i.lanes=a,i}function rf(i,r,a){return i=On(6,i,null,r),i.lanes=a,i}function _v(i){var r=On(18,null,null,0);return r.stateNode=i,r}function sf(i,r,a){return r=On(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var vv=new WeakMap;function Zn(i,r){if(typeof i=="object"&&i!==null){var a=vv.get(i);return a!==void 0?a:(r={value:i,source:r,stack:Te(r)},vv.set(i,r),r)}return{value:i,source:r,stack:Te(r)}}var vl=[],bl=0,wu=null,xo=0,Qn=[],Jn=0,As=null,Mr=1,Nr="";function Qr(i,r){vl[bl++]=xo,vl[bl++]=wu,wu=i,xo=r}function bv(i,r,a){Qn[Jn++]=Mr,Qn[Jn++]=Nr,Qn[Jn++]=As,As=i;var o=Mr;i=Nr;var u=32-F(o)-1;o&=~(1<<u),a+=1;var h=32-F(r)+u;if(30<h){var v=u-u%5;h=(o&(1<<v)-1).toString(32),o>>=v,u-=v,Mr=1<<32-F(r)+u|a<<u|o,Nr=h+i}else Mr=1<<h|a<<u|o,Nr=i}function af(i){i.return!==null&&(Qr(i,1),bv(i,1,0))}function lf(i){for(;i===wu;)wu=vl[--bl],vl[bl]=null,xo=vl[--bl],vl[bl]=null;for(;i===As;)As=Qn[--Jn],Qn[Jn]=null,Nr=Qn[--Jn],Qn[Jn]=null,Mr=Qn[--Jn],Qn[Jn]=null}function yv(i,r){Qn[Jn++]=Mr,Qn[Jn++]=Nr,Qn[Jn++]=As,Mr=r.id,Nr=r.overflow,As=i}var Vi=null,Kt=null,mt=!1,Ls=null,er=!1,of=Error(s(519));function Bs(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ko(Zn(r,i)),of}function Sv(i){var r=i.stateNode,a=i.type,o=i.memoizedProps;switch(r[fi]=i,r[$t]=o,a){case"dialog":dt("cancel",r),dt("close",r);break;case"iframe":case"object":case"embed":dt("load",r);break;case"video":case"audio":for(a=0;a<Vo.length;a++)dt(Vo[a],r);break;case"source":dt("error",r);break;case"img":case"image":case"link":dt("error",r),dt("load",r);break;case"details":dt("toggle",r);break;case"input":dt("invalid",r),Cs(r,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":dt("invalid",r);break;case"textarea":dt("invalid",r),xs(r,o.value,o.defaultValue,o.children)}a=o.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||o.suppressHydrationWarning===!0||Py(r.textContent,a)?(o.popover!=null&&(dt("beforetoggle",r),dt("toggle",r)),o.onScroll!=null&&dt("scroll",r),o.onScrollEnd!=null&&dt("scrollend",r),o.onClick!=null&&(r.onclick=vn),r=!0):r=!1,r||Bs(i,!0)}function wv(i){for(Vi=i.return;Vi;)switch(Vi.tag){case 5:case 31:case 13:er=!1;return;case 27:case 3:er=!0;return;default:Vi=Vi.return}}function yl(i){if(i!==Vi)return!1;if(!mt)return wv(i),mt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Ep(i.type,i.memoizedProps)),a=!a),a&&Kt&&Bs(i),wv(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Kt=Vy(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Kt=Vy(i)}else r===27?(r=Kt,Ys(i.type)?(i=Np,Np=null,Kt=i):Kt=r):Kt=Vi?ir(i.stateNode.nextSibling):null;return!0}function Ma(){Kt=Vi=null,mt=!1}function cf(){var i=Ls;return i!==null&&(Cn===null?Cn=i:Cn.push.apply(Cn,i),Ls=null),i}function ko(i){Ls===null?Ls=[i]:Ls.push(i)}var uf=M(null),Na=null,Jr=null;function Os(i,r,a){ue(uf,r._currentValue),r._currentValue=a}function es(i){i._currentValue=uf.current,X(uf)}function df(i,r,a){for(;i!==null;){var o=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,o!==null&&(o.childLanes|=r)):o!==null&&(o.childLanes&r)!==r&&(o.childLanes|=r),i===a)break;i=i.return}}function hf(i,r,a,o){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var h=u.dependencies;if(h!==null){var v=u.child;h=h.firstContext;e:for(;h!==null;){var k=h;h=u;for(var N=0;N<r.length;N++)if(k.context===r[N]){h.lanes|=a,k=h.alternate,k!==null&&(k.lanes|=a),df(h.return,a,i),o||(v=null);break e}h=k.next}}else if(u.tag===18){if(v=u.return,v===null)throw Error(s(341));v.lanes|=a,h=v.alternate,h!==null&&(h.lanes|=a),df(v,a,i),v=null}else v=u.child;if(v!==null)v.return=u;else for(v=u;v!==null;){if(v===i){v=null;break}if(u=v.sibling,u!==null){u.return=v.return,v=u;break}v=v.return}u=v}}function Sl(i,r,a,o){i=null;for(var u=r,h=!1;u!==null;){if(!h){if((u.flags&524288)!==0)h=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var v=u.alternate;if(v===null)throw Error(s(387));if(v=v.memoizedProps,v!==null){var k=u.type;nn(u.pendingProps.value,v.value)||(i!==null?i.push(k):i=[k])}}else if(u===Re.current){if(v=u.alternate,v===null)throw Error(s(387));v.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(Qo):i=[Qo])}u=u.return}i!==null&&hf(r,i,a,o),r.flags|=262144}function Cu(i){for(i=i.firstContext;i!==null;){if(!nn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Aa(i){Na=i,Jr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Yi(i){return Cv(Na,i)}function xu(i,r){return Na===null&&Aa(i),Cv(i,r)}function Cv(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Jr===null){if(i===null)throw Error(s(308));Jr=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Jr=Jr.next=r;return a}var Ox=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(a,o){i.push(o)}};this.abort=function(){r.aborted=!0,i.forEach(function(a){return a()})}},jx=e.unstable_scheduleCallback,zx=e.unstable_NormalPriority,yi={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ff(){return{controller:new Ox,data:new Map,refCount:0}}function Eo(i){i.refCount--,i.refCount===0&&jx(zx,function(){i.controller.abort()})}var To=null,pf=0,wl=0,Cl=null;function Px(i,r){if(To===null){var a=To=[];pf=0,wl=_p(),Cl={status:"pending",value:void 0,then:function(o){a.push(o)}}}return pf++,r.then(xv,xv),r}function xv(){if(--pf===0&&To!==null){Cl!==null&&(Cl.status="fulfilled");var i=To;To=null,wl=0,Cl=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function Ix(i,r){var a=[],o={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){o.status="fulfilled",o.value=r;for(var u=0;u<a.length;u++)(0,a[u])(r)},function(u){for(o.status="rejected",o.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),o}var kv=A.S;A.S=function(i,r){oy=wt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Px(i,r),kv!==null&&kv(i,r)};var La=M(null);function mf(){var i=La.current;return i!==null?i:jt.pooledCache}function ku(i,r){r===null?ue(La,La.current):ue(La,r.pool)}function Ev(){var i=mf();return i===null?null:{parent:yi._currentValue,pool:i}}var xl=Error(s(460)),gf=Error(s(474)),Eu=Error(s(542)),Tu={then:function(){}};function Tv(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Dv(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(vn,vn),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,Mv(i),i;default:if(typeof r.status=="string")r.then(vn,vn);else{if(i=jt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=r,i.status="pending",i.then(function(o){if(r.status==="pending"){var u=r;u.status="fulfilled",u.value=o}},function(o){if(r.status==="pending"){var u=r;u.status="rejected",u.reason=o}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,Mv(i),i}throw Oa=r,xl}}function Ba(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Oa=a,xl):a}}var Oa=null;function Rv(){if(Oa===null)throw Error(s(459));var i=Oa;return Oa=null,i}function Mv(i){if(i===xl||i===Eu)throw Error(s(483))}var kl=null,Do=0;function Du(i){var r=Do;return Do+=1,kl===null&&(kl=[]),Dv(kl,i,r)}function Ro(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Ru(i,r){throw r.$$typeof===w?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function Nv(i){function r(H,z){if(i){var $=H.deletions;$===null?(H.deletions=[z],H.flags|=16):$.push(z)}}function a(H,z){if(!i)return null;for(;z!==null;)r(H,z),z=z.sibling;return null}function o(H){for(var z=new Map;H!==null;)H.key!==null?z.set(H.key,H):z.set(H.index,H),H=H.sibling;return z}function u(H,z){return H=Zr(H,z),H.index=0,H.sibling=null,H}function h(H,z,$){return H.index=$,i?($=H.alternate,$!==null?($=$.index,$<z?(H.flags|=67108866,z):$):(H.flags|=67108866,z)):(H.flags|=1048576,z)}function v(H){return i&&H.alternate===null&&(H.flags|=67108866),H}function k(H,z,$,he){return z===null||z.tag!==6?(z=rf($,H.mode,he),z.return=H,z):(z=u(z,$),z.return=H,z)}function N(H,z,$,he){var qe=$.type;return qe===D?oe(H,z,$.props.children,he,$.key):z!==null&&(z.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===ee&&Ba(qe)===z.type)?(z=u(z,$.props),Ro(z,$),z.return=H,z):(z=Su($.type,$.key,$.props,null,H.mode,he),Ro(z,$),z.return=H,z)}function V(H,z,$,he){return z===null||z.tag!==4||z.stateNode.containerInfo!==$.containerInfo||z.stateNode.implementation!==$.implementation?(z=sf($,H.mode,he),z.return=H,z):(z=u(z,$.children||[]),z.return=H,z)}function oe(H,z,$,he,qe){return z===null||z.tag!==7?(z=Ra($,H.mode,he,qe),z.return=H,z):(z=u(z,$),z.return=H,z)}function fe(H,z,$){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=rf(""+z,H.mode,$),z.return=H,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case x:return $=Su(z.type,z.key,z.props,null,H.mode,$),Ro($,z),$.return=H,$;case C:return z=sf(z,H.mode,$),z.return=H,z;case ee:return z=Ba(z),fe(H,z,$)}if(se(z)||q(z))return z=Ra(z,H.mode,$,null),z.return=H,z;if(typeof z.then=="function")return fe(H,Du(z),$);if(z.$$typeof===Y)return fe(H,xu(H,z),$);Ru(H,z)}return null}function G(H,z,$,he){var qe=z!==null?z.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return qe!==null?null:k(H,z,""+$,he);if(typeof $=="object"&&$!==null){switch($.$$typeof){case x:return $.key===qe?N(H,z,$,he):null;case C:return $.key===qe?V(H,z,$,he):null;case ee:return $=Ba($),G(H,z,$,he)}if(se($)||q($))return qe!==null?null:oe(H,z,$,he,null);if(typeof $.then=="function")return G(H,z,Du($),he);if($.$$typeof===Y)return G(H,z,xu(H,$),he);Ru(H,$)}return null}function te(H,z,$,he,qe){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return H=H.get($)||null,k(z,H,""+he,qe);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case x:return H=H.get(he.key===null?$:he.key)||null,N(z,H,he,qe);case C:return H=H.get(he.key===null?$:he.key)||null,V(z,H,he,qe);case ee:return he=Ba(he),te(H,z,$,he,qe)}if(se(he)||q(he))return H=H.get($)||null,oe(z,H,he,qe,null);if(typeof he.then=="function")return te(H,z,$,Du(he),qe);if(he.$$typeof===Y)return te(H,z,$,xu(z,he),qe);Ru(z,he)}return null}function Ie(H,z,$,he){for(var qe=null,bt=null,He=z,st=z=0,pt=null;He!==null&&st<$.length;st++){He.index>st?(pt=He,He=null):pt=He.sibling;var yt=G(H,He,$[st],he);if(yt===null){He===null&&(He=pt);break}i&&He&&yt.alternate===null&&r(H,He),z=h(yt,z,st),bt===null?qe=yt:bt.sibling=yt,bt=yt,He=pt}if(st===$.length)return a(H,He),mt&&Qr(H,st),qe;if(He===null){for(;st<$.length;st++)He=fe(H,$[st],he),He!==null&&(z=h(He,z,st),bt===null?qe=He:bt.sibling=He,bt=He);return mt&&Qr(H,st),qe}for(He=o(He);st<$.length;st++)pt=te(He,H,st,$[st],he),pt!==null&&(i&&pt.alternate!==null&&He.delete(pt.key===null?st:pt.key),z=h(pt,z,st),bt===null?qe=pt:bt.sibling=pt,bt=pt);return i&&He.forEach(function(Js){return r(H,Js)}),mt&&Qr(H,st),qe}function Ye(H,z,$,he){if($==null)throw Error(s(151));for(var qe=null,bt=null,He=z,st=z=0,pt=null,yt=$.next();He!==null&&!yt.done;st++,yt=$.next()){He.index>st?(pt=He,He=null):pt=He.sibling;var Js=G(H,He,yt.value,he);if(Js===null){He===null&&(He=pt);break}i&&He&&Js.alternate===null&&r(H,He),z=h(Js,z,st),bt===null?qe=Js:bt.sibling=Js,bt=Js,He=pt}if(yt.done)return a(H,He),mt&&Qr(H,st),qe;if(He===null){for(;!yt.done;st++,yt=$.next())yt=fe(H,yt.value,he),yt!==null&&(z=h(yt,z,st),bt===null?qe=yt:bt.sibling=yt,bt=yt);return mt&&Qr(H,st),qe}for(He=o(He);!yt.done;st++,yt=$.next())yt=te(He,H,st,yt.value,he),yt!==null&&(i&&yt.alternate!==null&&He.delete(yt.key===null?st:yt.key),z=h(yt,z,st),bt===null?qe=yt:bt.sibling=yt,bt=yt);return i&&He.forEach(function(Gk){return r(H,Gk)}),mt&&Qr(H,st),qe}function At(H,z,$,he){if(typeof $=="object"&&$!==null&&$.type===D&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case x:e:{for(var qe=$.key;z!==null;){if(z.key===qe){if(qe=$.type,qe===D){if(z.tag===7){a(H,z.sibling),he=u(z,$.props.children),he.return=H,H=he;break e}}else if(z.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===ee&&Ba(qe)===z.type){a(H,z.sibling),he=u(z,$.props),Ro(he,$),he.return=H,H=he;break e}a(H,z);break}else r(H,z);z=z.sibling}$.type===D?(he=Ra($.props.children,H.mode,he,$.key),he.return=H,H=he):(he=Su($.type,$.key,$.props,null,H.mode,he),Ro(he,$),he.return=H,H=he)}return v(H);case C:e:{for(qe=$.key;z!==null;){if(z.key===qe)if(z.tag===4&&z.stateNode.containerInfo===$.containerInfo&&z.stateNode.implementation===$.implementation){a(H,z.sibling),he=u(z,$.children||[]),he.return=H,H=he;break e}else{a(H,z);break}else r(H,z);z=z.sibling}he=sf($,H.mode,he),he.return=H,H=he}return v(H);case ee:return $=Ba($),At(H,z,$,he)}if(se($))return Ie(H,z,$,he);if(q($)){if(qe=q($),typeof qe!="function")throw Error(s(150));return $=qe.call($),Ye(H,z,$,he)}if(typeof $.then=="function")return At(H,z,Du($),he);if($.$$typeof===Y)return At(H,z,xu(H,$),he);Ru(H,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,z!==null&&z.tag===6?(a(H,z.sibling),he=u(z,$),he.return=H,H=he):(a(H,z),he=rf($,H.mode,he),he.return=H,H=he),v(H)):a(H,z)}return function(H,z,$,he){try{Do=0;var qe=At(H,z,$,he);return kl=null,qe}catch(He){if(He===xl||He===Eu)throw He;var bt=On(29,He,null,H.mode);return bt.lanes=he,bt.return=H,bt}}}var ja=Nv(!0),Av=Nv(!1),js=!1;function _f(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vf(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function zs(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Ps(i,r,a){var o=i.updateQueue;if(o===null)return null;if(o=o.shared,(St&2)!==0){var u=o.pending;return u===null?r.next=r:(r.next=u.next,u.next=r),o.pending=r,r=yu(i),mv(i,null,a),r}return bu(i,o,r,a),yu(i)}function Mo(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,si(i,a)}}function bf(i,r){var a=i.updateQueue,o=i.alternate;if(o!==null&&(o=o.updateQueue,a===o)){var u=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var v={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?u=h=v:h=h.next=v,a=a.next}while(a!==null);h===null?u=h=r:h=h.next=r}else u=h=r;a={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:o.shared,callbacks:o.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}var yf=!1;function No(){if(yf){var i=Cl;if(i!==null)throw i}}function Ao(i,r,a,o){yf=!1;var u=i.updateQueue;js=!1;var h=u.firstBaseUpdate,v=u.lastBaseUpdate,k=u.shared.pending;if(k!==null){u.shared.pending=null;var N=k,V=N.next;N.next=null,v===null?h=V:v.next=V,v=N;var oe=i.alternate;oe!==null&&(oe=oe.updateQueue,k=oe.lastBaseUpdate,k!==v&&(k===null?oe.firstBaseUpdate=V:k.next=V,oe.lastBaseUpdate=N))}if(h!==null){var fe=u.baseState;v=0,oe=V=N=null,k=h;do{var G=k.lane&-536870913,te=G!==k.lane;if(te?(ft&G)===G:(o&G)===G){G!==0&&G===wl&&(yf=!0),oe!==null&&(oe=oe.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var Ie=i,Ye=k;G=r;var At=a;switch(Ye.tag){case 1:if(Ie=Ye.payload,typeof Ie=="function"){fe=Ie.call(At,fe,G);break e}fe=Ie;break e;case 3:Ie.flags=Ie.flags&-65537|128;case 0:if(Ie=Ye.payload,G=typeof Ie=="function"?Ie.call(At,fe,G):Ie,G==null)break e;fe=b({},fe,G);break e;case 2:js=!0}}G=k.callback,G!==null&&(i.flags|=64,te&&(i.flags|=8192),te=u.callbacks,te===null?u.callbacks=[G]:te.push(G))}else te={lane:G,tag:k.tag,payload:k.payload,callback:k.callback,next:null},oe===null?(V=oe=te,N=fe):oe=oe.next=te,v|=G;if(k=k.next,k===null){if(k=u.shared.pending,k===null)break;te=k,k=te.next,te.next=null,u.lastBaseUpdate=te,u.shared.pending=null}}while(!0);oe===null&&(N=fe),u.baseState=N,u.firstBaseUpdate=V,u.lastBaseUpdate=oe,h===null&&(u.shared.lanes=0),Ws|=v,i.lanes=v,i.memoizedState=fe}}function Lv(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function Bv(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Lv(a[i],r)}var El=M(null),Mu=M(0);function Ov(i,r){i=cs,ue(Mu,i),ue(El,r),cs=i|r.baseLanes}function Sf(){ue(Mu,cs),ue(El,El.current)}function wf(){cs=Mu.current,X(El),X(Mu)}var jn=M(null),tr=null;function Is(i){var r=i.alternate;ue(mi,mi.current&1),ue(jn,i),tr===null&&(r===null||El.current!==null||r.memoizedState!==null)&&(tr=i)}function Cf(i){ue(mi,mi.current),ue(jn,i),tr===null&&(tr=i)}function jv(i){i.tag===22?(ue(mi,mi.current),ue(jn,i),tr===null&&(tr=i)):Hs()}function Hs(){ue(mi,mi.current),ue(jn,jn.current)}function zn(i){X(jn),tr===i&&(tr=null),X(mi)}var mi=M(0);function Nu(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Rp(a)||Mp(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ts=0,nt=null,Mt=null,Si=null,Au=!1,Tl=!1,za=!1,Lu=0,Lo=0,Dl=null,Hx=0;function oi(){throw Error(s(321))}function xf(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!nn(i[a],r[a]))return!1;return!0}function kf(i,r,a,o,u,h){return ts=h,nt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,A.H=i===null||i.memoizedState===null?bb:Hf,za=!1,h=a(o,u),za=!1,Tl&&(h=Pv(r,a,o,u)),zv(i),h}function zv(i){A.H=jo;var r=Mt!==null&&Mt.next!==null;if(ts=0,Si=Mt=nt=null,Au=!1,Lo=0,Dl=null,r)throw Error(s(300));i===null||wi||(i=i.dependencies,i!==null&&Cu(i)&&(wi=!0))}function Pv(i,r,a,o){nt=i;var u=0;do{if(Tl&&(Dl=null),Lo=0,Tl=!1,25<=u)throw Error(s(301));if(u+=1,Si=Mt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}A.H=yb,h=r(a,o)}while(Tl);return h}function Ux(){var i=A.H,r=i.useState()[0];return r=typeof r.then=="function"?Bo(r):r,i=i.useState()[0],(Mt!==null?Mt.memoizedState:null)!==i&&(nt.flags|=1024),r}function Ef(){var i=Lu!==0;return Lu=0,i}function Tf(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function Df(i){if(Au){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}Au=!1}ts=0,Si=Mt=nt=null,Tl=!1,Lo=Lu=0,Dl=null}function on(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Si===null?nt.memoizedState=Si=i:Si=Si.next=i,Si}function gi(){if(Mt===null){var i=nt.alternate;i=i!==null?i.memoizedState:null}else i=Mt.next;var r=Si===null?nt.memoizedState:Si.next;if(r!==null)Si=r,Mt=i;else{if(i===null)throw nt.alternate===null?Error(s(467)):Error(s(310));Mt=i,i={memoizedState:Mt.memoizedState,baseState:Mt.baseState,baseQueue:Mt.baseQueue,queue:Mt.queue,next:null},Si===null?nt.memoizedState=Si=i:Si=Si.next=i}return Si}function Bu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bo(i){var r=Lo;return Lo+=1,Dl===null&&(Dl=[]),i=Dv(Dl,i,r),r=nt,(Si===null?r.memoizedState:Si.next)===null&&(r=r.alternate,A.H=r===null||r.memoizedState===null?bb:Hf),i}function Ou(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Bo(i);if(i.$$typeof===Y)return Yi(i)}throw Error(s(438,String(i)))}function Rf(i){var r=null,a=nt.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var o=nt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(r={data:o.data.map(function(u){return u.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=Bu(),nt.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(i),o=0;o<i;o++)a[o]=Ee;return r.index++,a}function is(i,r){return typeof r=="function"?r(i):r}function ju(i){var r=gi();return Mf(r,Mt,i)}function Mf(i,r,a){var o=i.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=a;var u=i.baseQueue,h=o.pending;if(h!==null){if(u!==null){var v=u.next;u.next=h.next,h.next=v}r.baseQueue=u=h,o.pending=null}if(h=i.baseState,u===null)i.memoizedState=h;else{r=u.next;var k=v=null,N=null,V=r,oe=!1;do{var fe=V.lane&-536870913;if(fe!==V.lane?(ft&fe)===fe:(ts&fe)===fe){var G=V.revertLane;if(G===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),fe===wl&&(oe=!0);else if((ts&G)===G){V=V.next,G===wl&&(oe=!0);continue}else fe={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(k=N=fe,v=h):N=N.next=fe,nt.lanes|=G,Ws|=G;fe=V.action,za&&a(h,fe),h=V.hasEagerState?V.eagerState:a(h,fe)}else G={lane:fe,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(k=N=G,v=h):N=N.next=G,nt.lanes|=fe,Ws|=fe;V=V.next}while(V!==null&&V!==r);if(N===null?v=h:N.next=k,!nn(h,i.memoizedState)&&(wi=!0,oe&&(a=Cl,a!==null)))throw a;i.memoizedState=h,i.baseState=v,i.baseQueue=N,o.lastRenderedState=h}return u===null&&(o.lanes=0),[i.memoizedState,o.dispatch]}function Nf(i){var r=gi(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var o=a.dispatch,u=a.pending,h=r.memoizedState;if(u!==null){a.pending=null;var v=u=u.next;do h=i(h,v.action),v=v.next;while(v!==u);nn(h,r.memoizedState)||(wi=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),a.lastRenderedState=h}return[h,o]}function Iv(i,r,a){var o=nt,u=gi(),h=mt;if(h){if(a===void 0)throw Error(s(407));a=a()}else a=r();var v=!nn((Mt||u).memoizedState,a);if(v&&(u.memoizedState=a,wi=!0),u=u.queue,Bf(Kv.bind(null,o,u,i),[i]),u.getSnapshot!==r||v||Si!==null&&Si.memoizedState.tag&1){if(o.flags|=2048,Rl(9,{destroy:void 0},Uv.bind(null,o,u,a,r),null),jt===null)throw Error(s(349));h||(ts&127)!==0||Hv(o,r,a)}return a}function Hv(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=nt.updateQueue,r===null?(r=Bu(),nt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function Uv(i,r,a,o){r.value=a,r.getSnapshot=o,Wv(r)&&Fv(i)}function Kv(i,r,a){return a(function(){Wv(r)&&Fv(i)})}function Wv(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!nn(i,a)}catch{return!0}}function Fv(i){var r=Da(i,2);r!==null&&xn(r,i,2)}function Af(i){var r=on();if(typeof i=="function"){var a=i;if(i=a(),za){Ht(!0);try{a()}finally{Ht(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:i},r}function qv(i,r,a,o){return i.baseState=a,Mf(i,Mt,typeof o=="function"?o:is)}function Kx(i,r,a,o,u){if(Iu(i))throw Error(s(485));if(i=r.action,i!==null){var h={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){h.listeners.push(v)}};A.T!==null?a(!0):h.isTransition=!1,o(h),a=r.pending,a===null?(h.next=r.pending=h,$v(r,h)):(h.next=a.next,r.pending=a.next=h)}}function $v(i,r){var a=r.action,o=r.payload,u=i.state;if(r.isTransition){var h=A.T,v={};A.T=v;try{var k=a(u,o),N=A.S;N!==null&&N(v,k),Vv(i,r,k)}catch(V){Lf(i,r,V)}finally{h!==null&&v.types!==null&&(h.types=v.types),A.T=h}}else try{h=a(u,o),Vv(i,r,h)}catch(V){Lf(i,r,V)}}function Vv(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(o){Yv(i,r,o)},function(o){return Lf(i,r,o)}):Yv(i,r,a)}function Yv(i,r,a){r.status="fulfilled",r.value=a,Xv(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,$v(i,a)))}function Lf(i,r,a){var o=i.pending;if(i.pending=null,o!==null){o=o.next;do r.status="rejected",r.reason=a,Xv(r),r=r.next;while(r!==o)}i.action=null}function Xv(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function Gv(i,r){return r}function Zv(i,r){if(mt){var a=jt.formState;if(a!==null){e:{var o=nt;if(mt){if(Kt){t:{for(var u=Kt,h=er;u.nodeType!==8;){if(!h){u=null;break t}if(u=ir(u.nextSibling),u===null){u=null;break t}}h=u.data,u=h==="F!"||h==="F"?u:null}if(u){Kt=ir(u.nextSibling),o=u.data==="F!";break e}}Bs(o)}o=!1}o&&(r=a[0])}}return a=on(),a.memoizedState=a.baseState=r,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gv,lastRenderedState:r},a.queue=o,a=gb.bind(null,nt,o),o.dispatch=a,o=Af(!1),h=If.bind(null,nt,!1,o.queue),o=on(),u={state:r,dispatch:null,action:i,pending:null},o.queue=u,a=Kx.bind(null,nt,u,h,a),u.dispatch=a,o.memoizedState=i,[r,a,!1]}function Qv(i){var r=gi();return Jv(r,Mt,i)}function Jv(i,r,a){if(r=Mf(i,r,Gv)[0],i=ju(is)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var o=Bo(r)}catch(v){throw v===xl?Eu:v}else o=r;r=gi();var u=r.queue,h=u.dispatch;return a!==r.memoizedState&&(nt.flags|=2048,Rl(9,{destroy:void 0},Wx.bind(null,u,a),null)),[o,h,i]}function Wx(i,r){i.action=r}function eb(i){var r=gi(),a=Mt;if(a!==null)return Jv(r,a,i);gi(),r=r.memoizedState,a=gi();var o=a.queue.dispatch;return a.memoizedState=i,[r,o,!1]}function Rl(i,r,a,o){return i={tag:i,create:a,deps:o,inst:r,next:null},r=nt.updateQueue,r===null&&(r=Bu(),nt.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=i.next=i:(o=a.next,a.next=i,i.next=o,r.lastEffect=i),i}function tb(){return gi().memoizedState}function zu(i,r,a,o){var u=on();nt.flags|=i,u.memoizedState=Rl(1|r,{destroy:void 0},a,o===void 0?null:o)}function Pu(i,r,a,o){var u=gi();o=o===void 0?null:o;var h=u.memoizedState.inst;Mt!==null&&o!==null&&xf(o,Mt.memoizedState.deps)?u.memoizedState=Rl(r,h,a,o):(nt.flags|=i,u.memoizedState=Rl(1|r,h,a,o))}function ib(i,r){zu(8390656,8,i,r)}function Bf(i,r){Pu(2048,8,i,r)}function Fx(i){nt.flags|=4;var r=nt.updateQueue;if(r===null)r=Bu(),nt.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function nb(i){var r=gi().memoizedState;return Fx({ref:r,nextImpl:i}),function(){if((St&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function rb(i,r){return Pu(4,2,i,r)}function sb(i,r){return Pu(4,4,i,r)}function ab(i,r){if(typeof r=="function"){i=i();var a=r(i);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function lb(i,r,a){a=a!=null?a.concat([i]):null,Pu(4,4,ab.bind(null,r,i),a)}function Of(){}function ob(i,r){var a=gi();r=r===void 0?null:r;var o=a.memoizedState;return r!==null&&xf(r,o[1])?o[0]:(a.memoizedState=[i,r],i)}function cb(i,r){var a=gi();r=r===void 0?null:r;var o=a.memoizedState;if(r!==null&&xf(r,o[1]))return o[0];if(o=i(),za){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[o,r],o}function jf(i,r,a){return a===void 0||(ts&1073741824)!==0&&(ft&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=uy(),nt.lanes|=i,Ws|=i,a)}function ub(i,r,a,o){return nn(a,r)?a:El.current!==null?(i=jf(i,a,o),nn(i,r)||(wi=!0),i):(ts&42)===0||(ts&1073741824)!==0&&(ft&261930)===0?(wi=!0,i.memoizedState=a):(i=uy(),nt.lanes|=i,Ws|=i,r)}function db(i,r,a,o,u){var h=R.p;R.p=h!==0&&8>h?h:8;var v=A.T,k={};A.T=k,If(i,!1,r,a);try{var N=u(),V=A.S;if(V!==null&&V(k,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var oe=Ix(N,o);Oo(i,r,oe,Hn(i))}else Oo(i,r,o,Hn(i))}catch(fe){Oo(i,r,{then:function(){},status:"rejected",reason:fe},Hn())}finally{R.p=h,v!==null&&k.types!==null&&(v.types=k.types),A.T=v}}function qx(){}function zf(i,r,a,o){if(i.tag!==5)throw Error(s(476));var u=hb(i).queue;db(i,u,r,P,a===null?qx:function(){return fb(i),a(o)})}function hb(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:P},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function fb(i){var r=hb(i);r.next===null&&(r=i.alternate.memoizedState),Oo(i,r.next.queue,{},Hn())}function Pf(){return Yi(Qo)}function pb(){return gi().memoizedState}function mb(){return gi().memoizedState}function $x(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=Hn();i=zs(a);var o=Ps(r,i,a);o!==null&&(xn(o,r,a),Mo(o,r,a)),r={cache:ff()},i.payload=r;return}r=r.return}}function Vx(i,r,a){var o=Hn();a={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Iu(i)?_b(r,a):(a=tf(i,r,a,o),a!==null&&(xn(a,i,o),vb(a,r,o)))}function gb(i,r,a){var o=Hn();Oo(i,r,a,o)}function Oo(i,r,a,o){var u={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Iu(i))_b(r,u);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var v=r.lastRenderedState,k=h(v,a);if(u.hasEagerState=!0,u.eagerState=k,nn(k,v))return bu(i,r,u,0),jt===null&&vu(),!1}catch{}if(a=tf(i,r,u,o),a!==null)return xn(a,i,o),vb(a,r,o),!0}return!1}function If(i,r,a,o){if(o={lane:2,revertLane:_p(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Iu(i)){if(r)throw Error(s(479))}else r=tf(i,a,o,2),r!==null&&xn(r,i,2)}function Iu(i){var r=i.alternate;return i===nt||r!==null&&r===nt}function _b(i,r){Tl=Au=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function vb(i,r,a){if((a&4194048)!==0){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,si(i,a)}}var jo={readContext:Yi,use:Ou,useCallback:oi,useContext:oi,useEffect:oi,useImperativeHandle:oi,useLayoutEffect:oi,useInsertionEffect:oi,useMemo:oi,useReducer:oi,useRef:oi,useState:oi,useDebugValue:oi,useDeferredValue:oi,useTransition:oi,useSyncExternalStore:oi,useId:oi,useHostTransitionStatus:oi,useFormState:oi,useActionState:oi,useOptimistic:oi,useMemoCache:oi,useCacheRefresh:oi};jo.useEffectEvent=oi;var bb={readContext:Yi,use:Ou,useCallback:function(i,r){return on().memoizedState=[i,r===void 0?null:r],i},useContext:Yi,useEffect:ib,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,zu(4194308,4,ab.bind(null,r,i),a)},useLayoutEffect:function(i,r){return zu(4194308,4,i,r)},useInsertionEffect:function(i,r){zu(4,2,i,r)},useMemo:function(i,r){var a=on();r=r===void 0?null:r;var o=i();if(za){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[o,r],o},useReducer:function(i,r,a){var o=on();if(a!==void 0){var u=a(r);if(za){Ht(!0);try{a(r)}finally{Ht(!1)}}}else u=r;return o.memoizedState=o.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},o.queue=i,i=i.dispatch=Vx.bind(null,nt,i),[o.memoizedState,i]},useRef:function(i){var r=on();return i={current:i},r.memoizedState=i},useState:function(i){i=Af(i);var r=i.queue,a=gb.bind(null,nt,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:Of,useDeferredValue:function(i,r){var a=on();return jf(a,i,r)},useTransition:function(){var i=Af(!1);return i=db.bind(null,nt,i.queue,!0,!1),on().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var o=nt,u=on();if(mt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),jt===null)throw Error(s(349));(ft&127)!==0||Hv(o,r,a)}u.memoizedState=a;var h={value:a,getSnapshot:r};return u.queue=h,ib(Kv.bind(null,o,h,i),[i]),o.flags|=2048,Rl(9,{destroy:void 0},Uv.bind(null,o,h,a,r),null),a},useId:function(){var i=on(),r=jt.identifierPrefix;if(mt){var a=Nr,o=Mr;a=(o&~(1<<32-F(o)-1)).toString(32)+a,r="_"+r+"R_"+a,a=Lu++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=Hx++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:Pf,useFormState:Zv,useActionState:Zv,useOptimistic:function(i){var r=on();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=If.bind(null,nt,!0,a),a.dispatch=r,[i,r]},useMemoCache:Rf,useCacheRefresh:function(){return on().memoizedState=$x.bind(null,nt)},useEffectEvent:function(i){var r=on(),a={impl:i};return r.memoizedState=a,function(){if((St&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Hf={readContext:Yi,use:Ou,useCallback:ob,useContext:Yi,useEffect:Bf,useImperativeHandle:lb,useInsertionEffect:rb,useLayoutEffect:sb,useMemo:cb,useReducer:ju,useRef:tb,useState:function(){return ju(is)},useDebugValue:Of,useDeferredValue:function(i,r){var a=gi();return ub(a,Mt.memoizedState,i,r)},useTransition:function(){var i=ju(is)[0],r=gi().memoizedState;return[typeof i=="boolean"?i:Bo(i),r]},useSyncExternalStore:Iv,useId:pb,useHostTransitionStatus:Pf,useFormState:Qv,useActionState:Qv,useOptimistic:function(i,r){var a=gi();return qv(a,Mt,i,r)},useMemoCache:Rf,useCacheRefresh:mb};Hf.useEffectEvent=nb;var yb={readContext:Yi,use:Ou,useCallback:ob,useContext:Yi,useEffect:Bf,useImperativeHandle:lb,useInsertionEffect:rb,useLayoutEffect:sb,useMemo:cb,useReducer:Nf,useRef:tb,useState:function(){return Nf(is)},useDebugValue:Of,useDeferredValue:function(i,r){var a=gi();return Mt===null?jf(a,i,r):ub(a,Mt.memoizedState,i,r)},useTransition:function(){var i=Nf(is)[0],r=gi().memoizedState;return[typeof i=="boolean"?i:Bo(i),r]},useSyncExternalStore:Iv,useId:pb,useHostTransitionStatus:Pf,useFormState:eb,useActionState:eb,useOptimistic:function(i,r){var a=gi();return Mt!==null?qv(a,Mt,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Rf,useCacheRefresh:mb};yb.useEffectEvent=nb;function Uf(i,r,a,o){r=i.memoizedState,a=a(o,r),a=a==null?r:b({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Kf={enqueueSetState:function(i,r,a){i=i._reactInternals;var o=Hn(),u=zs(o);u.payload=r,a!=null&&(u.callback=a),r=Ps(i,u,o),r!==null&&(xn(r,i,o),Mo(r,i,o))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var o=Hn(),u=zs(o);u.tag=1,u.payload=r,a!=null&&(u.callback=a),r=Ps(i,u,o),r!==null&&(xn(r,i,o),Mo(r,i,o))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Hn(),o=zs(a);o.tag=2,r!=null&&(o.callback=r),r=Ps(i,o,a),r!==null&&(xn(r,i,a),Mo(r,i,a))}};function Sb(i,r,a,o,u,h,v){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(o,h,v):r.prototype&&r.prototype.isPureReactComponent?!Ns(a,o)||!Ns(u,h):!0}function wb(i,r,a,o){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,o),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,o),r.state!==i&&Kf.enqueueReplaceState(r,r.state,null)}function Pa(i,r){var a=r;if("ref"in r){a={};for(var o in r)o!=="ref"&&(a[o]=r[o])}if(i=i.defaultProps){a===r&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Cb(i){_u(i)}function xb(i){console.error(i)}function kb(i){_u(i)}function Hu(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(o){setTimeout(function(){throw o})}}function Eb(i,r,a){try{var o=i.onCaughtError;o(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Wf(i,r,a){return a=zs(a),a.tag=3,a.payload={element:null},a.callback=function(){Hu(i,r)},a}function Tb(i){return i=zs(i),i.tag=3,i}function Db(i,r,a,o){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var h=o.value;i.payload=function(){return u(h)},i.callback=function(){Eb(r,a,o)}}var v=a.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(i.callback=function(){Eb(r,a,o),typeof u!="function"&&(Fs===null?Fs=new Set([this]):Fs.add(this));var k=o.stack;this.componentDidCatch(o.value,{componentStack:k!==null?k:""})})}function Yx(i,r,a,o,u){if(a.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(r=a.alternate,r!==null&&Sl(r,a,u,!0),a=jn.current,a!==null){switch(a.tag){case 31:case 13:return tr===null?Qu():a.alternate===null&&ci===0&&(ci=3),a.flags&=-257,a.flags|=65536,a.lanes=u,o===Tu?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([o]):r.add(o),pp(i,o,u)),!1;case 22:return a.flags|=65536,o===Tu?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([o])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([o]):a.add(o)),pp(i,o,u)),!1}throw Error(s(435,a.tag))}return pp(i,o,u),Qu(),!1}if(mt)return r=jn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=u,o!==of&&(i=Error(s(422),{cause:o}),ko(Zn(i,a)))):(o!==of&&(r=Error(s(423),{cause:o}),ko(Zn(r,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,o=Zn(o,a),u=Wf(i.stateNode,o,u),bf(i,u),ci!==4&&(ci=2)),!1;var h=Error(s(520),{cause:o});if(h=Zn(h,a),Fo===null?Fo=[h]:Fo.push(h),ci!==4&&(ci=2),r===null)return!0;o=Zn(o,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Wf(a.stateNode,o,i),bf(a,i),!1;case 1:if(r=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(Fs===null||!Fs.has(h))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Tb(u),Db(u,i,a,o),bf(a,u),!1}a=a.return}while(a!==null);return!1}var Ff=Error(s(461)),wi=!1;function Xi(i,r,a,o){r.child=i===null?Av(r,null,a,o):ja(r,i.child,a,o)}function Rb(i,r,a,o,u){a=a.render;var h=r.ref;if("ref"in o){var v={};for(var k in o)k!=="ref"&&(v[k]=o[k])}else v=o;return Aa(r),o=kf(i,r,a,v,h,u),k=Ef(),i!==null&&!wi?(Tf(i,r,u),ns(i,r,u)):(mt&&k&&af(r),r.flags|=1,Xi(i,r,o,u),r.child)}function Mb(i,r,a,o,u){if(i===null){var h=a.type;return typeof h=="function"&&!nf(h)&&h.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=h,Nb(i,r,h,o,u)):(i=Su(a.type,null,o,r,r.mode,u),i.ref=r.ref,i.return=r,r.child=i)}if(h=i.child,!Qf(i,u)){var v=h.memoizedProps;if(a=a.compare,a=a!==null?a:Ns,a(v,o)&&i.ref===r.ref)return ns(i,r,u)}return r.flags|=1,i=Zr(h,o),i.ref=r.ref,i.return=r,r.child=i}function Nb(i,r,a,o,u){if(i!==null){var h=i.memoizedProps;if(Ns(h,o)&&i.ref===r.ref)if(wi=!1,r.pendingProps=o=h,Qf(i,u))(i.flags&131072)!==0&&(wi=!0);else return r.lanes=i.lanes,ns(i,r,u)}return qf(i,r,a,o,u)}function Ab(i,r,a,o){var u=o.children,h=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((r.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(o=r.child=i.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~h}else o=0,r.child=null;return Lb(i,r,h,a,o)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&ku(r,h!==null?h.cachePool:null),h!==null?Ov(r,h):Sf(),jv(r);else return o=r.lanes=536870912,Lb(i,r,h!==null?h.baseLanes|a:a,a,o)}else h!==null?(ku(r,h.cachePool),Ov(r,h),Hs(),r.memoizedState=null):(i!==null&&ku(r,null),Sf(),Hs());return Xi(i,r,u,a),r.child}function zo(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Lb(i,r,a,o,u){var h=mf();return h=h===null?null:{parent:yi._currentValue,pool:h},r.memoizedState={baseLanes:a,cachePool:h},i!==null&&ku(r,null),Sf(),jv(r),i!==null&&Sl(i,r,o,!0),r.childLanes=u,null}function Uu(i,r){return r=Wu({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function Bb(i,r,a){return ja(r,i.child,null,a),i=Uu(r,r.pendingProps),i.flags|=2,zn(r),r.memoizedState=null,i}function Xx(i,r,a){var o=r.pendingProps,u=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(mt){if(o.mode==="hidden")return i=Uu(r,o),r.lanes=536870912,zo(null,i);if(Cf(r),(i=Kt)?(i=$y(i,er),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:As!==null?{id:Mr,overflow:Nr}:null,retryLane:536870912,hydrationErrors:null},a=_v(i),a.return=r,r.child=a,Vi=r,Kt=null)):i=null,i===null)throw Bs(r);return r.lanes=536870912,null}return Uu(r,o)}var h=i.memoizedState;if(h!==null){var v=h.dehydrated;if(Cf(r),u)if(r.flags&256)r.flags&=-257,r=Bb(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(wi||Sl(i,r,a,!1),u=(a&i.childLanes)!==0,wi||u){if(o=jt,o!==null&&(v=Ti(o,a),v!==0&&v!==h.retryLane))throw h.retryLane=v,Da(i,v),xn(o,i,v),Ff;Qu(),r=Bb(i,r,a)}else i=h.treeContext,Kt=ir(v.nextSibling),Vi=r,mt=!0,Ls=null,er=!1,i!==null&&yv(r,i),r=Uu(r,o),r.flags|=4096;return r}return i=Zr(i.child,{mode:o.mode,children:o.children}),i.ref=r.ref,r.child=i,i.return=r,i}function Ku(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function qf(i,r,a,o,u){return Aa(r),a=kf(i,r,a,o,void 0,u),o=Ef(),i!==null&&!wi?(Tf(i,r,u),ns(i,r,u)):(mt&&o&&af(r),r.flags|=1,Xi(i,r,a,u),r.child)}function Ob(i,r,a,o,u,h){return Aa(r),r.updateQueue=null,a=Pv(r,o,a,u),zv(i),o=Ef(),i!==null&&!wi?(Tf(i,r,h),ns(i,r,h)):(mt&&o&&af(r),r.flags|=1,Xi(i,r,a,h),r.child)}function jb(i,r,a,o,u){if(Aa(r),r.stateNode===null){var h=_l,v=a.contextType;typeof v=="object"&&v!==null&&(h=Yi(v)),h=new a(o,h),r.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Kf,r.stateNode=h,h._reactInternals=r,h=r.stateNode,h.props=o,h.state=r.memoizedState,h.refs={},_f(r),v=a.contextType,h.context=typeof v=="object"&&v!==null?Yi(v):_l,h.state=r.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(Uf(r,a,v,o),h.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(v=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),v!==h.state&&Kf.enqueueReplaceState(h,h.state,null),Ao(r,o,h,u),No(),h.state=r.memoizedState),typeof h.componentDidMount=="function"&&(r.flags|=4194308),o=!0}else if(i===null){h=r.stateNode;var k=r.memoizedProps,N=Pa(a,k);h.props=N;var V=h.context,oe=a.contextType;v=_l,typeof oe=="object"&&oe!==null&&(v=Yi(oe));var fe=a.getDerivedStateFromProps;oe=typeof fe=="function"||typeof h.getSnapshotBeforeUpdate=="function",k=r.pendingProps!==k,oe||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(k||V!==v)&&wb(r,h,o,v),js=!1;var G=r.memoizedState;h.state=G,Ao(r,o,h,u),No(),V=r.memoizedState,k||G!==V||js?(typeof fe=="function"&&(Uf(r,a,fe,o),V=r.memoizedState),(N=js||Sb(r,a,N,o,G,V,v))?(oe||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(r.flags|=4194308)):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=o,r.memoizedState=V),h.props=o,h.state=V,h.context=v,o=N):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),o=!1)}else{h=r.stateNode,vf(i,r),v=r.memoizedProps,oe=Pa(a,v),h.props=oe,fe=r.pendingProps,G=h.context,V=a.contextType,N=_l,typeof V=="object"&&V!==null&&(N=Yi(V)),k=a.getDerivedStateFromProps,(V=typeof k=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(v!==fe||G!==N)&&wb(r,h,o,N),js=!1,G=r.memoizedState,h.state=G,Ao(r,o,h,u),No();var te=r.memoizedState;v!==fe||G!==te||js||i!==null&&i.dependencies!==null&&Cu(i.dependencies)?(typeof k=="function"&&(Uf(r,a,k,o),te=r.memoizedState),(oe=js||Sb(r,a,oe,o,G,te,N)||i!==null&&i.dependencies!==null&&Cu(i.dependencies))?(V||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,te,N),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,te,N)),typeof h.componentDidUpdate=="function"&&(r.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof h.componentDidUpdate!="function"||v===i.memoizedProps&&G===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||v===i.memoizedProps&&G===i.memoizedState||(r.flags|=1024),r.memoizedProps=o,r.memoizedState=te),h.props=o,h.state=te,h.context=N,o=oe):(typeof h.componentDidUpdate!="function"||v===i.memoizedProps&&G===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||v===i.memoizedProps&&G===i.memoizedState||(r.flags|=1024),o=!1)}return h=o,Ku(i,r),o=(r.flags&128)!==0,h||o?(h=r.stateNode,a=o&&typeof a.getDerivedStateFromError!="function"?null:h.render(),r.flags|=1,i!==null&&o?(r.child=ja(r,i.child,null,u),r.child=ja(r,null,a,u)):Xi(i,r,a,u),r.memoizedState=h.state,i=r.child):i=ns(i,r,u),i}function zb(i,r,a,o){return Ma(),r.flags|=256,Xi(i,r,a,o),r.child}var $f={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vf(i){return{baseLanes:i,cachePool:Ev()}}function Yf(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=In),i}function Pb(i,r,a){var o=r.pendingProps,u=!1,h=(r.flags&128)!==0,v;if((v=h)||(v=i!==null&&i.memoizedState===null?!1:(mi.current&2)!==0),v&&(u=!0,r.flags&=-129),v=(r.flags&32)!==0,r.flags&=-33,i===null){if(mt){if(u?Is(r):Hs(),(i=Kt)?(i=$y(i,er),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:As!==null?{id:Mr,overflow:Nr}:null,retryLane:536870912,hydrationErrors:null},a=_v(i),a.return=r,r.child=a,Vi=r,Kt=null)):i=null,i===null)throw Bs(r);return Mp(i)?r.lanes=32:r.lanes=536870912,null}var k=o.children;return o=o.fallback,u?(Hs(),u=r.mode,k=Wu({mode:"hidden",children:k},u),o=Ra(o,u,a,null),k.return=r,o.return=r,k.sibling=o,r.child=k,o=r.child,o.memoizedState=Vf(a),o.childLanes=Yf(i,v,a),r.memoizedState=$f,zo(null,o)):(Is(r),Xf(r,k))}var N=i.memoizedState;if(N!==null&&(k=N.dehydrated,k!==null)){if(h)r.flags&256?(Is(r),r.flags&=-257,r=Gf(i,r,a)):r.memoizedState!==null?(Hs(),r.child=i.child,r.flags|=128,r=null):(Hs(),k=o.fallback,u=r.mode,o=Wu({mode:"visible",children:o.children},u),k=Ra(k,u,a,null),k.flags|=2,o.return=r,k.return=r,o.sibling=k,r.child=o,ja(r,i.child,null,a),o=r.child,o.memoizedState=Vf(a),o.childLanes=Yf(i,v,a),r.memoizedState=$f,r=zo(null,o));else if(Is(r),Mp(k)){if(v=k.nextSibling&&k.nextSibling.dataset,v)var V=v.dgst;v=V,o=Error(s(419)),o.stack="",o.digest=v,ko({value:o,source:null,stack:null}),r=Gf(i,r,a)}else if(wi||Sl(i,r,a,!1),v=(a&i.childLanes)!==0,wi||v){if(v=jt,v!==null&&(o=Ti(v,a),o!==0&&o!==N.retryLane))throw N.retryLane=o,Da(i,o),xn(v,i,o),Ff;Rp(k)||Qu(),r=Gf(i,r,a)}else Rp(k)?(r.flags|=192,r.child=i.child,r=null):(i=N.treeContext,Kt=ir(k.nextSibling),Vi=r,mt=!0,Ls=null,er=!1,i!==null&&yv(r,i),r=Xf(r,o.children),r.flags|=4096);return r}return u?(Hs(),k=o.fallback,u=r.mode,N=i.child,V=N.sibling,o=Zr(N,{mode:"hidden",children:o.children}),o.subtreeFlags=N.subtreeFlags&65011712,V!==null?k=Zr(V,k):(k=Ra(k,u,a,null),k.flags|=2),k.return=r,o.return=r,o.sibling=k,r.child=o,zo(null,o),o=r.child,k=i.child.memoizedState,k===null?k=Vf(a):(u=k.cachePool,u!==null?(N=yi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=Ev(),k={baseLanes:k.baseLanes|a,cachePool:u}),o.memoizedState=k,o.childLanes=Yf(i,v,a),r.memoizedState=$f,zo(i.child,o)):(Is(r),a=i.child,i=a.sibling,a=Zr(a,{mode:"visible",children:o.children}),a.return=r,a.sibling=null,i!==null&&(v=r.deletions,v===null?(r.deletions=[i],r.flags|=16):v.push(i)),r.child=a,r.memoizedState=null,a)}function Xf(i,r){return r=Wu({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function Wu(i,r){return i=On(22,i,null,r),i.lanes=0,i}function Gf(i,r,a){return ja(r,i.child,null,a),i=Xf(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function Ib(i,r,a){i.lanes|=r;var o=i.alternate;o!==null&&(o.lanes|=r),df(i.return,r,a)}function Zf(i,r,a,o,u,h){var v=i.memoizedState;v===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:o,tail:a,tailMode:u,treeForkCount:h}:(v.isBackwards=r,v.rendering=null,v.renderingStartTime=0,v.last=o,v.tail=a,v.tailMode=u,v.treeForkCount=h)}function Hb(i,r,a){var o=r.pendingProps,u=o.revealOrder,h=o.tail;o=o.children;var v=mi.current,k=(v&2)!==0;if(k?(v=v&1|2,r.flags|=128):v&=1,ue(mi,v),Xi(i,r,o,a),o=mt?xo:0,!k&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Ib(i,a,r);else if(i.tag===19)Ib(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=r.child,u=null;a!==null;)i=a.alternate,i!==null&&Nu(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=r.child,r.child=null):(u=a.sibling,a.sibling=null),Zf(r,!1,u,a,h,o);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=r.child,r.child=null;u!==null;){if(i=u.alternate,i!==null&&Nu(i)===null){r.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Zf(r,!0,a,null,h,o);break;case"together":Zf(r,!1,null,null,void 0,o);break;default:r.memoizedState=null}return r.child}function ns(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Ws|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(Sl(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=Zr(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Zr(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function Qf(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&Cu(i)))}function Gx(i,r,a){switch(r.tag){case 3:Me(r,r.stateNode.containerInfo),Os(r,yi,i.memoizedState.cache),Ma();break;case 27:case 5:Pe(r);break;case 4:Me(r,r.stateNode.containerInfo);break;case 10:Os(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Cf(r),null;break;case 13:var o=r.memoizedState;if(o!==null)return o.dehydrated!==null?(Is(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Pb(i,r,a):(Is(r),i=ns(i,r,a),i!==null?i.sibling:null);Is(r);break;case 19:var u=(i.flags&128)!==0;if(o=(a&r.childLanes)!==0,o||(Sl(i,r,a,!1),o=(a&r.childLanes)!==0),u){if(o)return Hb(i,r,a);r.flags|=128}if(u=r.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ue(mi,mi.current),o)break;return null;case 22:return r.lanes=0,Ab(i,r,a,r.pendingProps);case 24:Os(r,yi,i.memoizedState.cache)}return ns(i,r,a)}function Ub(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)wi=!0;else{if(!Qf(i,a)&&(r.flags&128)===0)return wi=!1,Gx(i,r,a);wi=(i.flags&131072)!==0}else wi=!1,mt&&(r.flags&1048576)!==0&&bv(r,xo,r.index);switch(r.lanes=0,r.tag){case 16:e:{var o=r.pendingProps;if(i=Ba(r.elementType),r.type=i,typeof i=="function")nf(i)?(o=Pa(i,o),r.tag=1,r=jb(null,r,i,o,a)):(r.tag=0,r=qf(null,r,i,o,a));else{if(i!=null){var u=i.$$typeof;if(u===U){r.tag=11,r=Rb(null,r,i,o,a);break e}else if(u===re){r.tag=14,r=Mb(null,r,i,o,a);break e}}throw r=K(i)||i,Error(s(306,r,""))}}return r;case 0:return qf(i,r,r.type,r.pendingProps,a);case 1:return o=r.type,u=Pa(o,r.pendingProps),jb(i,r,o,u,a);case 3:e:{if(Me(r,r.stateNode.containerInfo),i===null)throw Error(s(387));o=r.pendingProps;var h=r.memoizedState;u=h.element,vf(i,r),Ao(r,o,null,a);var v=r.memoizedState;if(o=v.cache,Os(r,yi,o),o!==h.cache&&hf(r,[yi],a,!0),No(),o=v.element,h.isDehydrated)if(h={element:o,isDehydrated:!1,cache:v.cache},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){r=zb(i,r,o,a);break e}else if(o!==u){u=Zn(Error(s(424)),r),ko(u),r=zb(i,r,o,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Kt=ir(i.firstChild),Vi=r,mt=!0,Ls=null,er=!0,a=Av(r,null,o,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Ma(),o===u){r=ns(i,r,a);break e}Xi(i,r,o,a)}r=r.child}return r;case 26:return Ku(i,r),i===null?(a=Qy(r.type,null,r.pendingProps,null))?r.memoizedState=a:mt||(a=r.type,i=r.pendingProps,o=sd(xe.current).createElement(a),o[fi]=r,o[$t]=i,Gi(o,a,i),Vt(o),r.stateNode=o):r.memoizedState=Qy(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Pe(r),i===null&&mt&&(o=r.stateNode=Xy(r.type,r.pendingProps,xe.current),Vi=r,er=!0,u=Kt,Ys(r.type)?(Np=u,Kt=ir(o.firstChild)):Kt=u),Xi(i,r,r.pendingProps.children,a),Ku(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&mt&&((u=o=Kt)&&(o=Ek(o,r.type,r.pendingProps,er),o!==null?(r.stateNode=o,Vi=r,Kt=ir(o.firstChild),er=!1,u=!0):u=!1),u||Bs(r)),Pe(r),u=r.type,h=r.pendingProps,v=i!==null?i.memoizedProps:null,o=h.children,Ep(u,h)?o=null:v!==null&&Ep(u,v)&&(r.flags|=32),r.memoizedState!==null&&(u=kf(i,r,Ux,null,null,a),Qo._currentValue=u),Ku(i,r),Xi(i,r,o,a),r.child;case 6:return i===null&&mt&&((i=a=Kt)&&(a=Tk(a,r.pendingProps,er),a!==null?(r.stateNode=a,Vi=r,Kt=null,i=!0):i=!1),i||Bs(r)),null;case 13:return Pb(i,r,a);case 4:return Me(r,r.stateNode.containerInfo),o=r.pendingProps,i===null?r.child=ja(r,null,o,a):Xi(i,r,o,a),r.child;case 11:return Rb(i,r,r.type,r.pendingProps,a);case 7:return Xi(i,r,r.pendingProps,a),r.child;case 8:return Xi(i,r,r.pendingProps.children,a),r.child;case 12:return Xi(i,r,r.pendingProps.children,a),r.child;case 10:return o=r.pendingProps,Os(r,r.type,o.value),Xi(i,r,o.children,a),r.child;case 9:return u=r.type._context,o=r.pendingProps.children,Aa(r),u=Yi(u),o=o(u),r.flags|=1,Xi(i,r,o,a),r.child;case 14:return Mb(i,r,r.type,r.pendingProps,a);case 15:return Nb(i,r,r.type,r.pendingProps,a);case 19:return Hb(i,r,a);case 31:return Xx(i,r,a);case 22:return Ab(i,r,a,r.pendingProps);case 24:return Aa(r),o=Yi(yi),i===null?(u=mf(),u===null&&(u=jt,h=ff(),u.pooledCache=h,h.refCount++,h!==null&&(u.pooledCacheLanes|=a),u=h),r.memoizedState={parent:o,cache:u},_f(r),Os(r,yi,u)):((i.lanes&a)!==0&&(vf(i,r),Ao(r,null,null,a),No()),u=i.memoizedState,h=r.memoizedState,u.parent!==o?(u={parent:o,cache:o},r.memoizedState=u,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=u),Os(r,yi,o)):(o=h.cache,Os(r,yi,o),o!==u.cache&&hf(r,[yi],a,!0))),Xi(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function rs(i){i.flags|=4}function Jf(i,r,a,o,u){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(py())i.flags|=8192;else throw Oa=Tu,gf}else i.flags&=-16777217}function Kb(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!nS(r))if(py())i.flags|=8192;else throw Oa=Tu,gf}function Fu(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?ri():536870912,i.lanes|=r,Ll|=r)}function Po(i,r){if(!mt)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:o.sibling=null}}function Wt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,o=0;if(r)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=o,i.childLanes=a,r}function Zx(i,r,a){var o=r.pendingProps;switch(lf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wt(r),null;case 1:return Wt(r),null;case 3:return a=r.stateNode,o=null,i!==null&&(o=i.memoizedState.cache),r.memoizedState.cache!==o&&(r.flags|=2048),es(yi),ze(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(yl(r)?rs(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,cf())),Wt(r),null;case 26:var u=r.type,h=r.memoizedState;return i===null?(rs(r),h!==null?(Wt(r),Kb(r,h)):(Wt(r),Jf(r,u,null,o,a))):h?h!==i.memoizedState?(rs(r),Wt(r),Kb(r,h)):(Wt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==o&&rs(r),Wt(r),Jf(r,u,i,o,a)),null;case 27:if(ce(r),a=xe.current,u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&rs(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}i=be.current,yl(r)?Sv(r):(i=Xy(u,o,a),r.stateNode=i,rs(r))}return Wt(r),null;case 5:if(ce(r),u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&rs(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}if(h=be.current,yl(r))Sv(r);else{var v=sd(xe.current);switch(h){case 1:h=v.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:h=v.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":h=v.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":h=v.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":h=v.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof o.is=="string"?v.createElement("select",{is:o.is}):v.createElement("select"),o.multiple?h.multiple=!0:o.size&&(h.size=o.size);break;default:h=typeof o.is=="string"?v.createElement(u,{is:o.is}):v.createElement(u)}}h[fi]=r,h[$t]=o;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)h.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=h;e:switch(Gi(h,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&rs(r)}}return Wt(r),Jf(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==o&&rs(r);else{if(typeof o!="string"&&r.stateNode===null)throw Error(s(166));if(i=xe.current,yl(r)){if(i=r.stateNode,a=r.memoizedProps,o=null,u=Vi,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}i[fi]=r,i=!!(i.nodeValue===a||o!==null&&o.suppressHydrationWarning===!0||Py(i.nodeValue,a)),i||Bs(r,!0)}else i=sd(i).createTextNode(o),i[fi]=r,r.stateNode=i}return Wt(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(o=yl(r),a!==null){if(i===null){if(!o)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[fi]=r}else Ma(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),i=!1}else a=cf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(zn(r),r):(zn(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Wt(r),null;case 13:if(o=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=yl(r),o!==null&&o.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=r.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[fi]=r}else Ma(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),u=!1}else u=cf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return r.flags&256?(zn(r),r):(zn(r),null)}return zn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=o!==null,i=i!==null&&i.memoizedState!==null,a&&(o=r.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),h=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),h!==u&&(o.flags|=2048)),a!==i&&a&&(r.child.flags|=8192),Fu(r,r.updateQueue),Wt(r),null);case 4:return ze(),i===null&&Sp(r.stateNode.containerInfo),Wt(r),null;case 10:return es(r.type),Wt(r),null;case 19:if(X(mi),o=r.memoizedState,o===null)return Wt(r),null;if(u=(r.flags&128)!==0,h=o.rendering,h===null)if(u)Po(o,!1);else{if(ci!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(h=Nu(i),h!==null){for(r.flags|=128,Po(o,!1),i=h.updateQueue,r.updateQueue=i,Fu(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)gv(a,i),a=a.sibling;return ue(mi,mi.current&1|2),mt&&Qr(r,o.treeForkCount),r.child}i=i.sibling}o.tail!==null&&wt()>Xu&&(r.flags|=128,u=!0,Po(o,!1),r.lanes=4194304)}else{if(!u)if(i=Nu(h),i!==null){if(r.flags|=128,u=!0,i=i.updateQueue,r.updateQueue=i,Fu(r,i),Po(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!mt)return Wt(r),null}else 2*wt()-o.renderingStartTime>Xu&&a!==536870912&&(r.flags|=128,u=!0,Po(o,!1),r.lanes=4194304);o.isBackwards?(h.sibling=r.child,r.child=h):(i=o.last,i!==null?i.sibling=h:r.child=h,o.last=h)}return o.tail!==null?(i=o.tail,o.rendering=i,o.tail=i.sibling,o.renderingStartTime=wt(),i.sibling=null,a=mi.current,ue(mi,u?a&1|2:a&1),mt&&Qr(r,o.treeForkCount),i):(Wt(r),null);case 22:case 23:return zn(r),wf(),o=r.memoizedState!==null,i!==null?i.memoizedState!==null!==o&&(r.flags|=8192):o&&(r.flags|=8192),o?(a&536870912)!==0&&(r.flags&128)===0&&(Wt(r),r.subtreeFlags&6&&(r.flags|=8192)):Wt(r),a=r.updateQueue,a!==null&&Fu(r,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048),i!==null&&X(La),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),es(yi),Wt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function Qx(i,r){switch(lf(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return es(yi),ze(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return ce(r),null;case 31:if(r.memoizedState!==null){if(zn(r),r.alternate===null)throw Error(s(340));Ma()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(zn(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Ma()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return X(mi),null;case 4:return ze(),null;case 10:return es(r.type),null;case 22:case 23:return zn(r),wf(),i!==null&&X(La),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return es(yi),null;case 25:return null;default:return null}}function Wb(i,r){switch(lf(r),r.tag){case 3:es(yi),ze();break;case 26:case 27:case 5:ce(r);break;case 4:ze();break;case 31:r.memoizedState!==null&&zn(r);break;case 13:zn(r);break;case 19:X(mi);break;case 10:es(r.type);break;case 22:case 23:zn(r),wf(),i!==null&&X(La);break;case 24:es(yi)}}function Io(i,r){try{var a=r.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&i)===i){o=void 0;var h=a.create,v=a.inst;o=h(),v.destroy=o}a=a.next}while(a!==u)}}catch(k){Dt(r,r.return,k)}}function Us(i,r,a){try{var o=r.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var h=u.next;o=h;do{if((o.tag&i)===i){var v=o.inst,k=v.destroy;if(k!==void 0){v.destroy=void 0,u=r;var N=a,V=k;try{V()}catch(oe){Dt(u,N,oe)}}}o=o.next}while(o!==h)}}catch(oe){Dt(r,r.return,oe)}}function Fb(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{Bv(r,a)}catch(o){Dt(i,i.return,o)}}}function qb(i,r,a){a.props=Pa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(o){Dt(i,r,o)}}function Ho(i,r){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var o=i.stateNode;break;case 30:o=i.stateNode;break;default:o=i.stateNode}typeof a=="function"?i.refCleanup=a(o):a.current=o}}catch(u){Dt(i,r,u)}}function Ar(i,r){var a=i.ref,o=i.refCleanup;if(a!==null)if(typeof o=="function")try{o()}catch(u){Dt(i,r,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){Dt(i,r,u)}else a.current=null}function $b(i){var r=i.type,a=i.memoizedProps,o=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&o.focus();break e;case"img":a.src?o.src=a.src:a.srcSet&&(o.srcset=a.srcSet)}}catch(u){Dt(i,i.return,u)}}function ep(i,r,a){try{var o=i.stateNode;yk(o,i.type,a,r),o[$t]=r}catch(u){Dt(i,i.return,u)}}function Vb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ys(i.type)||i.tag===4}function tp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Vb(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function ip(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(i),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=vn));else if(o!==4&&(o===27&&Ys(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(ip(i,r,a),i=i.sibling;i!==null;)ip(i,r,a),i=i.sibling}function qu(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(o!==4&&(o===27&&Ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(qu(i,r,a),i=i.sibling;i!==null;)qu(i,r,a),i=i.sibling}function Yb(i){var r=i.stateNode,a=i.memoizedProps;try{for(var o=i.type,u=r.attributes;u.length;)r.removeAttributeNode(u[0]);Gi(r,o,a),r[fi]=i,r[$t]=a}catch(h){Dt(i,i.return,h)}}var ss=!1,Ci=!1,np=!1,Xb=typeof WeakSet=="function"?WeakSet:Set,Pi=null;function Jx(i,r){if(i=i.containerInfo,xp=hd,i=lv(i),Xh(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var o=a.getSelection&&a.getSelection();if(o&&o.rangeCount!==0){a=o.anchorNode;var u=o.anchorOffset,h=o.focusNode;o=o.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var v=0,k=-1,N=-1,V=0,oe=0,fe=i,G=null;t:for(;;){for(var te;fe!==a||u!==0&&fe.nodeType!==3||(k=v+u),fe!==h||o!==0&&fe.nodeType!==3||(N=v+o),fe.nodeType===3&&(v+=fe.nodeValue.length),(te=fe.firstChild)!==null;)G=fe,fe=te;for(;;){if(fe===i)break t;if(G===a&&++V===u&&(k=v),G===h&&++oe===o&&(N=v),(te=fe.nextSibling)!==null)break;fe=G,G=fe.parentNode}fe=te}a=k===-1||N===-1?null:{start:k,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(kp={focusedElem:i,selectionRange:a},hd=!1,Pi=r;Pi!==null;)if(r=Pi,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Pi=i;else for(;Pi!==null;){switch(r=Pi,h=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=r,u=h.memoizedProps,h=h.memoizedState,o=a.stateNode;try{var Ie=Pa(a.type,u);i=o.getSnapshotBeforeUpdate(Ie,h),o.__reactInternalSnapshotBeforeUpdate=i}catch(Ye){Dt(a,a.return,Ye)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)Dp(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Dp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=r.sibling,i!==null){i.return=r.return,Pi=i;break}Pi=r.return}}function Gb(i,r,a){var o=a.flags;switch(a.tag){case 0:case 11:case 15:ls(i,a),o&4&&Io(5,a);break;case 1:if(ls(i,a),o&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(v){Dt(a,a.return,v)}else{var u=Pa(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(u,r,i.__reactInternalSnapshotBeforeUpdate)}catch(v){Dt(a,a.return,v)}}o&64&&Fb(a),o&512&&Ho(a,a.return);break;case 3:if(ls(i,a),o&64&&(i=a.updateQueue,i!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{Bv(i,r)}catch(v){Dt(a,a.return,v)}}break;case 27:r===null&&o&4&&Yb(a);case 26:case 5:ls(i,a),r===null&&o&4&&$b(a),o&512&&Ho(a,a.return);break;case 12:ls(i,a);break;case 31:ls(i,a),o&4&&Jb(i,a);break;case 13:ls(i,a),o&4&&ey(i,a),o&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=ok.bind(null,a),Dk(i,a))));break;case 22:if(o=a.memoizedState!==null||ss,!o){r=r!==null&&r.memoizedState!==null||Ci,u=ss;var h=Ci;ss=o,(Ci=r)&&!h?os(i,a,(a.subtreeFlags&8772)!==0):ls(i,a),ss=u,Ci=h}break;case 30:break;default:ls(i,a)}}function Zb(i){var r=i.alternate;r!==null&&(i.alternate=null,Zb(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Hr(r)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Xt=null,yn=!1;function as(i,r,a){for(a=a.child;a!==null;)Qb(i,r,a),a=a.sibling}function Qb(i,r,a){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(Ct,a)}catch{}switch(a.tag){case 26:Ci||Ar(a,r),as(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ci||Ar(a,r);var o=Xt,u=yn;Ys(a.type)&&(Xt=a.stateNode,yn=!1),as(i,r,a),Xo(a.stateNode),Xt=o,yn=u;break;case 5:Ci||Ar(a,r);case 6:if(o=Xt,u=yn,Xt=null,as(i,r,a),Xt=o,yn=u,Xt!==null)if(yn)try{(Xt.nodeType===9?Xt.body:Xt.nodeName==="HTML"?Xt.ownerDocument.body:Xt).removeChild(a.stateNode)}catch(h){Dt(a,r,h)}else try{Xt.removeChild(a.stateNode)}catch(h){Dt(a,r,h)}break;case 18:Xt!==null&&(yn?(i=Xt,Fy(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),Ul(i)):Fy(Xt,a.stateNode));break;case 4:o=Xt,u=yn,Xt=a.stateNode.containerInfo,yn=!0,as(i,r,a),Xt=o,yn=u;break;case 0:case 11:case 14:case 15:Us(2,a,r),Ci||Us(4,a,r),as(i,r,a);break;case 1:Ci||(Ar(a,r),o=a.stateNode,typeof o.componentWillUnmount=="function"&&qb(a,r,o)),as(i,r,a);break;case 21:as(i,r,a);break;case 22:Ci=(o=Ci)||a.memoizedState!==null,as(i,r,a),Ci=o;break;default:as(i,r,a)}}function Jb(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Ul(i)}catch(a){Dt(r,r.return,a)}}}function ey(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Ul(i)}catch(a){Dt(r,r.return,a)}}function ek(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new Xb),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new Xb),r;default:throw Error(s(435,i.tag))}}function $u(i,r){var a=ek(i);r.forEach(function(o){if(!a.has(o)){a.add(o);var u=ck.bind(null,i,o);o.then(u,u)}})}function Sn(i,r){var a=r.deletions;if(a!==null)for(var o=0;o<a.length;o++){var u=a[o],h=i,v=r,k=v;e:for(;k!==null;){switch(k.tag){case 27:if(Ys(k.type)){Xt=k.stateNode,yn=!1;break e}break;case 5:Xt=k.stateNode,yn=!1;break e;case 3:case 4:Xt=k.stateNode.containerInfo,yn=!0;break e}k=k.return}if(Xt===null)throw Error(s(160));Qb(h,v,u),Xt=null,yn=!1,h=u.alternate,h!==null&&(h.return=null),u.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ty(r,i),r=r.sibling}var br=null;function ty(i,r){var a=i.alternate,o=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Sn(r,i),wn(i),o&4&&(Us(3,i,i.return),Io(3,i),Us(5,i,i.return));break;case 1:Sn(r,i),wn(i),o&512&&(Ci||a===null||Ar(a,a.return)),o&64&&ss&&(i=i.updateQueue,i!==null&&(o=i.callbacks,o!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?o:a.concat(o))));break;case 26:var u=br;if(Sn(r,i),wn(i),o&512&&(Ci||a===null||Ar(a,a.return)),o&4){var h=a!==null?a.memoizedState:null;if(o=i.memoizedState,a===null)if(o===null)if(i.stateNode===null){e:{o=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":h=u.getElementsByTagName("title")[0],(!h||h[pr]||h[fi]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=u.createElement(o),u.head.insertBefore(h,u.querySelector("head > title"))),Gi(h,o,a),h[fi]=i,Vt(h),o=h;break e;case"link":var v=tS("link","href",u).get(o+(a.href||""));if(v){for(var k=0;k<v.length;k++)if(h=v[k],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){v.splice(k,1);break t}}h=u.createElement(o),Gi(h,o,a),u.head.appendChild(h);break;case"meta":if(v=tS("meta","content",u).get(o+(a.content||""))){for(k=0;k<v.length;k++)if(h=v[k],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){v.splice(k,1);break t}}h=u.createElement(o),Gi(h,o,a),u.head.appendChild(h);break;default:throw Error(s(468,o))}h[fi]=i,Vt(h),o=h}i.stateNode=o}else iS(u,i.type,i.stateNode);else i.stateNode=eS(u,o,i.memoizedProps);else h!==o?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,o===null?iS(u,i.type,i.stateNode):eS(u,o,i.memoizedProps)):o===null&&i.stateNode!==null&&ep(i,i.memoizedProps,a.memoizedProps)}break;case 27:Sn(r,i),wn(i),o&512&&(Ci||a===null||Ar(a,a.return)),a!==null&&o&4&&ep(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Sn(r,i),wn(i),o&512&&(Ci||a===null||Ar(a,a.return)),i.flags&32){u=i.stateNode;try{_n(u,"")}catch(Ie){Dt(i,i.return,Ie)}}o&4&&i.stateNode!=null&&(u=i.memoizedProps,ep(i,u,a!==null?a.memoizedProps:u)),o&1024&&(np=!0);break;case 6:if(Sn(r,i),wn(i),o&4){if(i.stateNode===null)throw Error(s(162));o=i.memoizedProps,a=i.stateNode;try{a.nodeValue=o}catch(Ie){Dt(i,i.return,Ie)}}break;case 3:if(od=null,u=br,br=ad(r.containerInfo),Sn(r,i),br=u,wn(i),o&4&&a!==null&&a.memoizedState.isDehydrated)try{Ul(r.containerInfo)}catch(Ie){Dt(i,i.return,Ie)}np&&(np=!1,iy(i));break;case 4:o=br,br=ad(i.stateNode.containerInfo),Sn(r,i),wn(i),br=o;break;case 12:Sn(r,i),wn(i);break;case 31:Sn(r,i),wn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,$u(i,o)));break;case 13:Sn(r,i),wn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Yu=wt()),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,$u(i,o)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,V=ss,oe=Ci;if(ss=V||u,Ci=oe||N,Sn(r,i),Ci=oe,ss=V,wn(i),o&8192)e:for(r=i.stateNode,r._visibility=u?r._visibility&-2:r._visibility|1,u&&(a===null||N||ss||Ci||Ia(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){N=a=r;try{if(h=N.stateNode,u)v=h.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{k=N.stateNode;var fe=N.memoizedProps.style,G=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;k.style.display=G==null||typeof G=="boolean"?"":(""+G).trim()}}catch(Ie){Dt(N,N.return,Ie)}}}else if(r.tag===6){if(a===null){N=r;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Ie){Dt(N,N.return,Ie)}}}else if(r.tag===18){if(a===null){N=r;try{var te=N.stateNode;u?qy(te,!0):qy(N.stateNode,!1)}catch(Ie){Dt(N,N.return,Ie)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}o&4&&(o=i.updateQueue,o!==null&&(a=o.retryQueue,a!==null&&(o.retryQueue=null,$u(i,a))));break;case 19:Sn(r,i),wn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,$u(i,o)));break;case 30:break;case 21:break;default:Sn(r,i),wn(i)}}function wn(i){var r=i.flags;if(r&2){try{for(var a,o=i.return;o!==null;){if(Vb(o)){a=o;break}o=o.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,h=tp(i);qu(i,h,u);break;case 5:var v=a.stateNode;a.flags&32&&(_n(v,""),a.flags&=-33);var k=tp(i);qu(i,k,v);break;case 3:case 4:var N=a.stateNode.containerInfo,V=tp(i);ip(i,V,N);break;default:throw Error(s(161))}}catch(oe){Dt(i,i.return,oe)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function iy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;iy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function ls(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Gb(i,r.alternate,r),r=r.sibling}function Ia(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Us(4,r,r.return),Ia(r);break;case 1:Ar(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&qb(r,r.return,a),Ia(r);break;case 27:Xo(r.stateNode);case 26:case 5:Ar(r,r.return),Ia(r);break;case 22:r.memoizedState===null&&Ia(r);break;case 30:Ia(r);break;default:Ia(r)}i=i.sibling}}function os(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var o=r.alternate,u=i,h=r,v=h.flags;switch(h.tag){case 0:case 11:case 15:os(u,h,a),Io(4,h);break;case 1:if(os(u,h,a),o=h,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(V){Dt(o,o.return,V)}if(o=h,u=o.updateQueue,u!==null){var k=o.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)Lv(N[u],k)}catch(V){Dt(o,o.return,V)}}a&&v&64&&Fb(h),Ho(h,h.return);break;case 27:Yb(h);case 26:case 5:os(u,h,a),a&&o===null&&v&4&&$b(h),Ho(h,h.return);break;case 12:os(u,h,a);break;case 31:os(u,h,a),a&&v&4&&Jb(u,h);break;case 13:os(u,h,a),a&&v&4&&ey(u,h);break;case 22:h.memoizedState===null&&os(u,h,a),Ho(h,h.return);break;case 30:break;default:os(u,h,a)}r=r.sibling}}function rp(i,r){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Eo(a))}function sp(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Eo(i))}function yr(i,r,a,o){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)ny(i,r,a,o),r=r.sibling}function ny(i,r,a,o){var u=r.flags;switch(r.tag){case 0:case 11:case 15:yr(i,r,a,o),u&2048&&Io(9,r);break;case 1:yr(i,r,a,o);break;case 3:yr(i,r,a,o),u&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Eo(i)));break;case 12:if(u&2048){yr(i,r,a,o),i=r.stateNode;try{var h=r.memoizedProps,v=h.id,k=h.onPostCommit;typeof k=="function"&&k(v,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){Dt(r,r.return,N)}}else yr(i,r,a,o);break;case 31:yr(i,r,a,o);break;case 13:yr(i,r,a,o);break;case 23:break;case 22:h=r.stateNode,v=r.alternate,r.memoizedState!==null?h._visibility&2?yr(i,r,a,o):Uo(i,r):h._visibility&2?yr(i,r,a,o):(h._visibility|=2,Ml(i,r,a,o,(r.subtreeFlags&10256)!==0||!1)),u&2048&&rp(v,r);break;case 24:yr(i,r,a,o),u&2048&&sp(r.alternate,r);break;default:yr(i,r,a,o)}}function Ml(i,r,a,o,u){for(u=u&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var h=i,v=r,k=a,N=o,V=v.flags;switch(v.tag){case 0:case 11:case 15:Ml(h,v,k,N,u),Io(8,v);break;case 23:break;case 22:var oe=v.stateNode;v.memoizedState!==null?oe._visibility&2?Ml(h,v,k,N,u):Uo(h,v):(oe._visibility|=2,Ml(h,v,k,N,u)),u&&V&2048&&rp(v.alternate,v);break;case 24:Ml(h,v,k,N,u),u&&V&2048&&sp(v.alternate,v);break;default:Ml(h,v,k,N,u)}r=r.sibling}}function Uo(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=i,o=r,u=o.flags;switch(o.tag){case 22:Uo(a,o),u&2048&&rp(o.alternate,o);break;case 24:Uo(a,o),u&2048&&sp(o.alternate,o);break;default:Uo(a,o)}r=r.sibling}}var Ko=8192;function Nl(i,r,a){if(i.subtreeFlags&Ko)for(i=i.child;i!==null;)ry(i,r,a),i=i.sibling}function ry(i,r,a){switch(i.tag){case 26:Nl(i,r,a),i.flags&Ko&&i.memoizedState!==null&&Hk(a,br,i.memoizedState,i.memoizedProps);break;case 5:Nl(i,r,a);break;case 3:case 4:var o=br;br=ad(i.stateNode.containerInfo),Nl(i,r,a),br=o;break;case 22:i.memoizedState===null&&(o=i.alternate,o!==null&&o.memoizedState!==null?(o=Ko,Ko=16777216,Nl(i,r,a),Ko=o):Nl(i,r,a));break;default:Nl(i,r,a)}}function sy(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function Wo(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Pi=o,ly(o,i)}sy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)ay(i),i=i.sibling}function ay(i){switch(i.tag){case 0:case 11:case 15:Wo(i),i.flags&2048&&Us(9,i,i.return);break;case 3:Wo(i);break;case 12:Wo(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,Vu(i)):Wo(i);break;default:Wo(i)}}function Vu(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Pi=o,ly(o,i)}sy(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Us(8,r,r.return),Vu(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Vu(r));break;default:Vu(r)}i=i.sibling}}function ly(i,r){for(;Pi!==null;){var a=Pi;switch(a.tag){case 0:case 11:case 15:Us(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var o=a.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Eo(a.memoizedState.cache)}if(o=a.child,o!==null)o.return=a,Pi=o;else e:for(a=i;Pi!==null;){o=Pi;var u=o.sibling,h=o.return;if(Zb(o),o===a){Pi=null;break e}if(u!==null){u.return=h,Pi=u;break e}Pi=h}}}var tk={getCacheForType:function(i){var r=Yi(yi),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Yi(yi).controller.signal}},ik=typeof WeakMap=="function"?WeakMap:Map,St=0,jt=null,ut=null,ft=0,Tt=0,Pn=null,Ks=!1,Al=!1,ap=!1,cs=0,ci=0,Ws=0,Ha=0,lp=0,In=0,Ll=0,Fo=null,Cn=null,op=!1,Yu=0,oy=0,Xu=1/0,Gu=null,Fs=null,Di=0,qs=null,Bl=null,us=0,cp=0,up=null,cy=null,qo=0,dp=null;function Hn(){return(St&2)!==0&&ft!==0?ft&-ft:A.T!==null?_p():ji()}function uy(){if(In===0)if((ft&536870912)===0||mt){var i=ni;ni<<=1,(ni&3932160)===0&&(ni=262144),In=i}else In=536870912;return i=jn.current,i!==null&&(i.flags|=32),In}function xn(i,r,a){(i===jt&&(Tt===2||Tt===9)||i.cancelPendingCommit!==null)&&(Ol(i,0),$s(i,ft,In,!1)),Zt(i,a),((St&2)===0||i!==jt)&&(i===jt&&((St&2)===0&&(Ha|=a),ci===4&&$s(i,ft,In,!1)),Lr(i))}function dy(i,r,a){if((St&6)!==0)throw Error(s(327));var o=!a&&(r&127)===0&&(r&i.expiredLanes)===0||Rt(i,r),u=o?sk(i,r):fp(i,r,!0),h=o;do{if(u===0){Al&&!o&&$s(i,r,0,!1);break}else{if(a=i.current.alternate,h&&!nk(a)){u=fp(i,r,!1),h=!1;continue}if(u===2){if(h=r,i.errorRecoveryDisabledLanes&h)var v=0;else v=i.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){r=v;e:{var k=i;u=Fo;var N=k.current.memoizedState.isDehydrated;if(N&&(Ol(k,v).flags|=256),v=fp(k,v,!1),v!==2){if(ap&&!N){k.errorRecoveryDisabledLanes|=h,Ha|=h,u=4;break e}h=Cn,Cn=u,h!==null&&(Cn===null?Cn=h:Cn.push.apply(Cn,h))}u=v}if(h=!1,u!==2)continue}}if(u===1){Ol(i,0),$s(i,r,0,!0);break}e:{switch(o=i,h=u,h){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:$s(o,r,In,!Ks);break e;case 2:Cn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(u=Yu+300-wt(),10<u)){if($s(o,r,In,!Ks),Pt(o,0,!0)!==0)break e;us=r,o.timeoutHandle=Ky(hy.bind(null,o,a,Cn,Gu,op,r,In,Ha,Ll,Ks,h,"Throttled",-0,0),u);break e}hy(o,a,Cn,Gu,op,r,In,Ha,Ll,Ks,h,null,-0,0)}}break}while(!0);Lr(i)}function hy(i,r,a,o,u,h,v,k,N,V,oe,fe,G,te){if(i.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:vn},ry(r,h,fe);var Ie=(h&62914560)===h?Yu-wt():(h&4194048)===h?oy-wt():0;if(Ie=Uk(fe,Ie),Ie!==null){us=h,i.cancelPendingCommit=Ie(yy.bind(null,i,r,h,a,o,u,v,k,N,oe,fe,null,G,te)),$s(i,h,v,!V);return}}yy(i,r,h,a,o,u,v,k,N)}function nk(i){for(var r=i;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var o=0;o<a.length;o++){var u=a[o],h=u.getSnapshot;u=u.value;try{if(!nn(h(),u))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function $s(i,r,a,o){r&=~lp,r&=~Ha,i.suspendedLanes|=r,i.pingedLanes&=~r,o&&(i.warmLanes|=r),o=i.expirationTimes;for(var u=r;0<u;){var h=31-F(u),v=1<<h;o[h]=-1,u&=~v}a!==0&&Qi(i,a,r)}function Zu(){return(St&6)===0?($o(0),!1):!0}function hp(){if(ut!==null){if(Tt===0)var i=ut.return;else i=ut,Jr=Na=null,Df(i),kl=null,Do=0,i=ut;for(;i!==null;)Wb(i.alternate,i),i=i.return;ut=null}}function Ol(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Ck(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),us=0,hp(),jt=i,ut=a=Zr(i.current,null),ft=r,Tt=0,Pn=null,Ks=!1,Al=Rt(i,r),ap=!1,Ll=In=lp=Ha=Ws=ci=0,Cn=Fo=null,op=!1,(r&8)!==0&&(r|=r&32);var o=i.entangledLanes;if(o!==0)for(i=i.entanglements,o&=r;0<o;){var u=31-F(o),h=1<<u;r|=i[u],o&=~h}return cs=r,vu(),a}function fy(i,r){nt=null,A.H=jo,r===xl||r===Eu?(r=Rv(),Tt=3):r===gf?(r=Rv(),Tt=4):Tt=r===Ff?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Pn=r,ut===null&&(ci=1,Hu(i,Zn(r,i.current)))}function py(){var i=jn.current;return i===null?!0:(ft&4194048)===ft?tr===null:(ft&62914560)===ft||(ft&536870912)!==0?i===tr:!1}function my(){var i=A.H;return A.H=jo,i===null?jo:i}function gy(){var i=A.A;return A.A=tk,i}function Qu(){ci=4,Ks||(ft&4194048)!==ft&&jn.current!==null||(Al=!0),(Ws&134217727)===0&&(Ha&134217727)===0||jt===null||$s(jt,ft,In,!1)}function fp(i,r,a){var o=St;St|=2;var u=my(),h=gy();(jt!==i||ft!==r)&&(Gu=null,Ol(i,r)),r=!1;var v=ci;e:do try{if(Tt!==0&&ut!==null){var k=ut,N=Pn;switch(Tt){case 8:hp(),v=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(r=!0);var V=Tt;if(Tt=0,Pn=null,jl(i,k,N,V),a&&Al){v=0;break e}break;default:V=Tt,Tt=0,Pn=null,jl(i,k,N,V)}}rk(),v=ci;break}catch(oe){fy(i,oe)}while(!0);return r&&i.shellSuspendCounter++,Jr=Na=null,St=o,A.H=u,A.A=h,ut===null&&(jt=null,ft=0,vu()),v}function rk(){for(;ut!==null;)_y(ut)}function sk(i,r){var a=St;St|=2;var o=my(),u=gy();jt!==i||ft!==r?(Gu=null,Xu=wt()+500,Ol(i,r)):Al=Rt(i,r);e:do try{if(Tt!==0&&ut!==null){r=ut;var h=Pn;t:switch(Tt){case 1:Tt=0,Pn=null,jl(i,r,h,1);break;case 2:case 9:if(Tv(h)){Tt=0,Pn=null,vy(r);break}r=function(){Tt!==2&&Tt!==9||jt!==i||(Tt=7),Lr(i)},h.then(r,r);break e;case 3:Tt=7;break e;case 4:Tt=5;break e;case 7:Tv(h)?(Tt=0,Pn=null,vy(r)):(Tt=0,Pn=null,jl(i,r,h,7));break;case 5:var v=null;switch(ut.tag){case 26:v=ut.memoizedState;case 5:case 27:var k=ut;if(v?nS(v):k.stateNode.complete){Tt=0,Pn=null;var N=k.sibling;if(N!==null)ut=N;else{var V=k.return;V!==null?(ut=V,Ju(V)):ut=null}break t}}Tt=0,Pn=null,jl(i,r,h,5);break;case 6:Tt=0,Pn=null,jl(i,r,h,6);break;case 8:hp(),ci=6;break e;default:throw Error(s(462))}}ak();break}catch(oe){fy(i,oe)}while(!0);return Jr=Na=null,A.H=o,A.A=u,St=a,ut!==null?0:(jt=null,ft=0,vu(),ci)}function ak(){for(;ut!==null&&!Je();)_y(ut)}function _y(i){var r=Ub(i.alternate,i,cs);i.memoizedProps=i.pendingProps,r===null?Ju(i):ut=r}function vy(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=Ob(a,r,r.pendingProps,r.type,void 0,ft);break;case 11:r=Ob(a,r,r.pendingProps,r.type.render,r.ref,ft);break;case 5:Df(r);default:Wb(a,r),r=ut=gv(r,cs),r=Ub(a,r,cs)}i.memoizedProps=i.pendingProps,r===null?Ju(i):ut=r}function jl(i,r,a,o){Jr=Na=null,Df(r),kl=null,Do=0;var u=r.return;try{if(Yx(i,u,r,a,ft)){ci=1,Hu(i,Zn(a,i.current)),ut=null;return}}catch(h){if(u!==null)throw ut=u,h;ci=1,Hu(i,Zn(a,i.current)),ut=null;return}r.flags&32768?(mt||o===1?i=!0:Al||(ft&536870912)!==0?i=!1:(Ks=i=!0,(o===2||o===9||o===3||o===6)&&(o=jn.current,o!==null&&o.tag===13&&(o.flags|=16384))),by(r,i)):Ju(r)}function Ju(i){var r=i;do{if((r.flags&32768)!==0){by(r,Ks);return}i=r.return;var a=Zx(r.alternate,r,cs);if(a!==null){ut=a;return}if(r=r.sibling,r!==null){ut=r;return}ut=r=i}while(r!==null);ci===0&&(ci=5)}function by(i,r){do{var a=Qx(i.alternate,i);if(a!==null){a.flags&=32767,ut=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){ut=i;return}ut=i=a}while(i!==null);ci=6,ut=null}function yy(i,r,a,o,u,h,v,k,N){i.cancelPendingCommit=null;do ed();while(Di!==0);if((St&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(h=r.lanes|r.childLanes,h|=ef,qt(i,a,h,v,k,N),i===jt&&(ut=jt=null,ft=0),Bl=r,qs=i,us=a,cp=h,up=u,cy=o,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,uk(le,function(){return ky(),null})):(i.callbackNode=null,i.callbackPriority=0),o=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||o){o=A.T,A.T=null,u=R.p,R.p=2,v=St,St|=4;try{Jx(i,r,a)}finally{St=v,R.p=u,A.T=o}}Di=1,Sy(),wy(),Cy()}}function Sy(){if(Di===1){Di=0;var i=qs,r=Bl,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=A.T,A.T=null;var o=R.p;R.p=2;var u=St;St|=4;try{ty(r,i);var h=kp,v=lv(i.containerInfo),k=h.focusedElem,N=h.selectionRange;if(v!==k&&k&&k.ownerDocument&&av(k.ownerDocument.documentElement,k)){if(N!==null&&Xh(k)){var V=N.start,oe=N.end;if(oe===void 0&&(oe=V),"selectionStart"in k)k.selectionStart=V,k.selectionEnd=Math.min(oe,k.value.length);else{var fe=k.ownerDocument||document,G=fe&&fe.defaultView||window;if(G.getSelection){var te=G.getSelection(),Ie=k.textContent.length,Ye=Math.min(N.start,Ie),At=N.end===void 0?Ye:Math.min(N.end,Ie);!te.extend&&Ye>At&&(v=At,At=Ye,Ye=v);var H=sv(k,Ye),z=sv(k,At);if(H&&z&&(te.rangeCount!==1||te.anchorNode!==H.node||te.anchorOffset!==H.offset||te.focusNode!==z.node||te.focusOffset!==z.offset)){var $=fe.createRange();$.setStart(H.node,H.offset),te.removeAllRanges(),Ye>At?(te.addRange($),te.extend(z.node,z.offset)):($.setEnd(z.node,z.offset),te.addRange($))}}}}for(fe=[],te=k;te=te.parentNode;)te.nodeType===1&&fe.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k<fe.length;k++){var he=fe[k];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}hd=!!xp,kp=xp=null}finally{St=u,R.p=o,A.T=a}}i.current=r,Di=2}}function wy(){if(Di===2){Di=0;var i=qs,r=Bl,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=A.T,A.T=null;var o=R.p;R.p=2;var u=St;St|=4;try{Gb(i,r.alternate,r)}finally{St=u,R.p=o,A.T=a}}Di=3}}function Cy(){if(Di===4||Di===3){Di=0,ct();var i=qs,r=Bl,a=us,o=cy;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Di=5:(Di=0,Bl=qs=null,xy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(Fs=null),hn(a),r=r.stateNode,xt&&typeof xt.onCommitFiberRoot=="function")try{xt.onCommitFiberRoot(Ct,r,void 0,(r.current.flags&128)===128)}catch{}if(o!==null){r=A.T,u=R.p,R.p=2,A.T=null;try{for(var h=i.onRecoverableError,v=0;v<o.length;v++){var k=o[v];h(k.value,{componentStack:k.stack})}}finally{A.T=r,R.p=u}}(us&3)!==0&&ed(),Lr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===dp?qo++:(qo=0,dp=i):qo=0,$o(0)}}function xy(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Eo(r)))}function ed(){return Sy(),wy(),Cy(),ky()}function ky(){if(Di!==5)return!1;var i=qs,r=cp;cp=0;var a=hn(us),o=A.T,u=R.p;try{R.p=32>a?32:a,A.T=null,a=up,up=null;var h=qs,v=us;if(Di=0,Bl=qs=null,us=0,(St&6)!==0)throw Error(s(331));var k=St;if(St|=4,ay(h.current),ny(h,h.current,v,a),St=k,$o(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(Ct,h)}catch{}return!0}finally{R.p=u,A.T=o,xy(i,r)}}function Ey(i,r,a){r=Zn(a,r),r=Wf(i.stateNode,r,2),i=Ps(i,r,2),i!==null&&(Zt(i,2),Lr(i))}function Dt(i,r,a){if(i.tag===3)Ey(i,i,a);else for(;r!==null;){if(r.tag===3){Ey(r,i,a);break}else if(r.tag===1){var o=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Fs===null||!Fs.has(o))){i=Zn(a,i),a=Tb(2),o=Ps(r,a,2),o!==null&&(Db(a,o,r,i),Zt(o,2),Lr(o));break}}r=r.return}}function pp(i,r,a){var o=i.pingCache;if(o===null){o=i.pingCache=new ik;var u=new Set;o.set(r,u)}else u=o.get(r),u===void 0&&(u=new Set,o.set(r,u));u.has(a)||(ap=!0,u.add(a),i=lk.bind(null,i,r,a),r.then(i,i))}function lk(i,r,a){var o=i.pingCache;o!==null&&o.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,jt===i&&(ft&a)===a&&(ci===4||ci===3&&(ft&62914560)===ft&&300>wt()-Yu?(St&2)===0&&Ol(i,0):lp|=a,Ll===ft&&(Ll=0)),Lr(i)}function Ty(i,r){r===0&&(r=ri()),i=Da(i,r),i!==null&&(Zt(i,r),Lr(i))}function ok(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Ty(i,a)}function ck(i,r){var a=0;switch(i.tag){case 31:case 13:var o=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:o=i.stateNode;break;case 22:o=i.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(r),Ty(i,a)}function uk(i,r){return Le(i,r)}var td=null,zl=null,mp=!1,id=!1,gp=!1,Vs=0;function Lr(i){i!==zl&&i.next===null&&(zl===null?td=zl=i:zl=zl.next=i),id=!0,mp||(mp=!0,hk())}function $o(i,r){if(!gp&&id){gp=!0;do for(var a=!1,o=td;o!==null;){if(i!==0){var u=o.pendingLanes;if(u===0)var h=0;else{var v=o.suspendedLanes,k=o.pingedLanes;h=(1<<31-F(42|i)+1)-1,h&=u&~(v&~k),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,Ny(o,h))}else h=ft,h=Pt(o,o===jt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||Rt(o,h)||(a=!0,Ny(o,h));o=o.next}while(a);gp=!1}}function dk(){Dy()}function Dy(){id=mp=!1;var i=0;Vs!==0&&wk()&&(i=Vs);for(var r=wt(),a=null,o=td;o!==null;){var u=o.next,h=Ry(o,r);h===0?(o.next=null,a===null?td=u:a.next=u,u===null&&(zl=a)):(a=o,(i!==0||(h&3)!==0)&&(id=!0)),o=u}Di!==0&&Di!==5||$o(i),Vs!==0&&(Vs=0)}function Ry(i,r){for(var a=i.suspendedLanes,o=i.pingedLanes,u=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var v=31-F(h),k=1<<v,N=u[v];N===-1?((k&a)===0||(k&o)!==0)&&(u[v]=Ut(k,r)):N<=r&&(i.expiredLanes|=k),h&=~k}if(r=jt,a=ft,a=Pt(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o=i.callbackNode,a===0||i===r&&(Tt===2||Tt===9)||i.cancelPendingCommit!==null)return o!==null&&o!==null&&Ve(o),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Rt(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(o!==null&&Ve(o),hn(a)){case 2:case 8:a=ii;break;case 32:a=le;break;case 268435456:a=Ze;break;default:a=le}return o=My.bind(null,i),a=Le(a,o),i.callbackPriority=r,i.callbackNode=a,r}return o!==null&&o!==null&&Ve(o),i.callbackPriority=2,i.callbackNode=null,2}function My(i,r){if(Di!==0&&Di!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(ed()&&i.callbackNode!==a)return null;var o=ft;return o=Pt(i,i===jt?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o===0?null:(dy(i,o,r),Ry(i,wt()),i.callbackNode!=null&&i.callbackNode===a?My.bind(null,i):null)}function Ny(i,r){if(ed())return null;dy(i,r,!0)}function hk(){xk(function(){(St&6)!==0?Le(Oi,dk):Dy()})}function _p(){if(Vs===0){var i=wl;i===0&&(i=Tn,Tn<<=1,(Tn&261888)===0&&(Tn=256)),Vs=i}return Vs}function Ay(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Vr(""+i)}function Ly(i,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,i.id&&a.setAttribute("form",i.id),r.parentNode.insertBefore(a,r),i=new FormData(i),a.parentNode.removeChild(a),i}function fk(i,r,a,o,u){if(r==="submit"&&a&&a.stateNode===u){var h=Ay((u[$t]||null).action),v=o.submitter;v&&(r=(r=v[$t]||null)?Ay(r.formAction):v.getAttribute("formAction"),r!==null&&(h=r,v=null));var k=new S("action","action",null,o,u);i.push({event:k,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Vs!==0){var N=v?Ly(u,v):new FormData(u);zf(a,{pending:!0,data:N,method:u.method,action:h},null,N)}}else typeof h=="function"&&(k.preventDefault(),N=v?Ly(u,v):new FormData(u),zf(a,{pending:!0,data:N,method:u.method,action:h},h,N))},currentTarget:u}]})}}for(var vp=0;vp<Jh.length;vp++){var bp=Jh[vp],pk=bp.toLowerCase(),mk=bp[0].toUpperCase()+bp.slice(1);vr(pk,"on"+mk)}vr(uv,"onAnimationEnd"),vr(dv,"onAnimationIteration"),vr(hv,"onAnimationStart"),vr("dblclick","onDoubleClick"),vr("focusin","onFocus"),vr("focusout","onBlur"),vr(Nx,"onTransitionRun"),vr(Ax,"onTransitionStart"),vr(Lx,"onTransitionCancel"),vr(fv,"onTransitionEnd"),mr("onMouseEnter",["mouseout","mouseover"]),mr("onMouseLeave",["mouseout","mouseover"]),mr("onPointerEnter",["pointerout","pointerover"]),mr("onPointerLeave",["pointerout","pointerover"]),pn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),pn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),pn("onBeforeInput",["compositionend","keypress","textInput","paste"]),pn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),pn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),pn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),gk=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Vo));function By(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var o=i[a],u=o.event;o=o.listeners;e:{var h=void 0;if(r)for(var v=o.length-1;0<=v;v--){var k=o[v],N=k.instance,V=k.currentTarget;if(k=k.listener,N!==h&&u.isPropagationStopped())break e;h=k,u.currentTarget=V;try{h(u)}catch(oe){_u(oe)}u.currentTarget=null,h=N}else for(v=0;v<o.length;v++){if(k=o[v],N=k.instance,V=k.currentTarget,k=k.listener,N!==h&&u.isPropagationStopped())break e;h=k,u.currentTarget=V;try{h(u)}catch(oe){_u(oe)}u.currentTarget=null,h=N}}}}function dt(i,r){var a=r[ys];a===void 0&&(a=r[ys]=new Set);var o=i+"__bubble";a.has(o)||(Oy(r,i,2,!1),a.add(o))}function yp(i,r,a){var o=0;r&&(o|=4),Oy(a,i,o,r)}var nd="_reactListening"+Math.random().toString(36).slice(2);function Sp(i){if(!i[nd]){i[nd]=!0,Ur.forEach(function(a){a!=="selectionchange"&&(gk.has(a)||yp(a,!1,i),yp(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[nd]||(r[nd]=!0,yp("selectionchange",!1,r))}}function Oy(i,r,a,o){switch(uS(r)){case 2:var u=Fk;break;case 8:u=qk;break;default:u=jp}a=u.bind(null,r,a,i),u=void 0,!xa||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(u=!0),o?u!==void 0?i.addEventListener(r,a,{capture:!0,passive:u}):i.addEventListener(r,a,!0):u!==void 0?i.addEventListener(r,a,{passive:u}):i.addEventListener(r,a,!1)}function wp(i,r,a,o,u){var h=o;if((r&1)===0&&(r&2)===0&&o!==null)e:for(;;){if(o===null)return;var v=o.tag;if(v===3||v===4){var k=o.stateNode.containerInfo;if(k===u)break;if(v===4)for(v=o.return;v!==null;){var N=v.tag;if((N===3||N===4)&&v.stateNode.containerInfo===u)return;v=v.return}for(;k!==null;){if(v=fn(k),v===null)return;if(N=v.tag,N===5||N===6||N===26||N===27){o=h=v;continue e}k=k.parentNode}}o=o.return}Ca(function(){var V=h,oe=Es(a),fe=[];e:{var G=pv.get(i);if(G!==void 0){var te=S,Ie=i;switch(i){case"keypress":if(Bn(a)===0)break e;case"keydown":case"keyup":te=dl;break;case"focusin":Ie="focus",te=Xr;break;case"focusout":Ie="blur",te=Xr;break;case"beforeblur":case"afterblur":te=Xr;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":te=$e;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":te=li;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":te=Kh;break;case uv:case dv:case hv:te=nu;break;case fv:te=cu;break;case"scroll":case"scrollend":te=j;break;case"wheel":te=Wh;break;case"copy":case"cut":case"paste":te=vo;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":te=yo;break;case"toggle":case"beforetoggle":te=Gr}var Ye=(r&4)!==0,At=!Ye&&(i==="scroll"||i==="scrollend"),H=Ye?G!==null?G+"Capture":null:G;Ye=[];for(var z=V,$;z!==null;){var he=z;if($=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||$===null||H===null||(he=Er(z,H),he!=null&&Ye.push(Yo(z,he,$))),At)break;z=z.return}0<Ye.length&&(G=new te(G,Ie,null,a,oe),fe.push({event:G,listeners:Ye}))}}if((r&7)===0){e:{if(G=i==="mouseover"||i==="pointerover",te=i==="mouseout"||i==="pointerout",G&&a!==Nn&&(Ie=a.relatedTarget||a.fromElement)&&(fn(Ie)||Ie[hr]))break e;if((te||G)&&(G=oe.window===oe?oe:(G=oe.ownerDocument)?G.defaultView||G.parentWindow:window,te?(Ie=a.relatedTarget||a.toElement,te=V,Ie=Ie?fn(Ie):null,Ie!==null&&(At=c(Ie),Ye=Ie.tag,Ie!==At||Ye!==5&&Ye!==27&&Ye!==6)&&(Ie=null)):(te=null,Ie=V),te!==Ie)){if(Ye=$e,he="onMouseLeave",H="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(Ye=yo,he="onPointerLeave",H="onPointerEnter",z="pointer"),At=te==null?G:xr(te),$=Ie==null?G:xr(Ie),G=new Ye(he,z+"leave",te,a,oe),G.target=At,G.relatedTarget=$,he=null,fn(oe)===V&&(Ye=new Ye(H,z+"enter",Ie,a,oe),Ye.target=$,Ye.relatedTarget=At,he=Ye),At=he,te&&Ie)t:{for(Ye=_k,H=te,z=Ie,$=0,he=H;he;he=Ye(he))$++;he=0;for(var qe=z;qe;qe=Ye(qe))he++;for(;0<$-he;)H=Ye(H),$--;for(;0<he-$;)z=Ye(z),he--;for(;$--;){if(H===z||z!==null&&H===z.alternate){Ye=H;break t}H=Ye(H),z=Ye(z)}Ye=null}else Ye=null;te!==null&&jy(fe,G,te,Ye,!1),Ie!==null&&At!==null&&jy(fe,At,Ie,Ye,!0)}}e:{if(G=V?xr(V):window,te=G.nodeName&&G.nodeName.toLowerCase(),te==="select"||te==="input"&&G.type==="file")var bt=Ke;else if(fl(G))if(Fe)bt=Yh;else{bt=bn;var He=Xn}else te=G.nodeName,!te||te.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?V&&ks(V.elementType)&&(bt=Ke):bt=gu;if(bt&&(bt=bt(i,V))){mu(fe,bt,a,oe);break e}He&&He(i,G,V),i==="focusout"&&V&&G.type==="number"&&V.memoizedProps.value!=null&&kr(G,"number",G.value)}switch(He=V?xr(V):window,i){case"focusin":(fl(He)||He.contentEditable==="true")&&(pl=He,Gh=V,Co=null);break;case"focusout":Co=Gh=pl=null;break;case"mousedown":Zh=!0;break;case"contextmenu":case"mouseup":case"dragend":Zh=!1,ov(fe,a,oe);break;case"selectionchange":if(Mx)break;case"keydown":case"keyup":ov(fe,a,oe)}var st;if(So)e:{switch(i){case"compositionstart":var pt="onCompositionStart";break e;case"compositionend":pt="onCompositionEnd";break e;case"compositionupdate":pt="onCompositionUpdate";break e}pt=void 0}else Rs?fu(i,a)&&(pt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(pt="onCompositionStart");pt&&(hu&&a.locale!=="ko"&&(Rs||pt!=="onCompositionStart"?pt==="onCompositionEnd"&&Rs&&(st=gr()):(ln=oe,ka="value"in ln?ln.value:ln.textContent,Rs=!0)),He=rd(V,pt),0<He.length&&(pt=new ru(pt,i,null,a,oe),fe.push({event:pt,listeners:He}),st?pt.data=st:(st=pu(a),st!==null&&(pt.data=st)))),(st=qh?Dr(i,a):$h(i,a))&&(pt=rd(V,"onBeforeInput"),0<pt.length&&(He=new ru("onBeforeInput","beforeinput",null,a,oe),fe.push({event:He,listeners:pt}),He.data=st)),fk(fe,i,V,a,oe)}By(fe,r)})}function Yo(i,r,a){return{instance:i,listener:r,currentTarget:a}}function rd(i,r){for(var a=r+"Capture",o=[];i!==null;){var u=i,h=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||h===null||(u=Er(i,a),u!=null&&o.unshift(Yo(i,u,h)),u=Er(i,r),u!=null&&o.push(Yo(i,u,h))),i.tag===3)return o;i=i.return}return[]}function _k(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function jy(i,r,a,o,u){for(var h=r._reactName,v=[];a!==null&&a!==o;){var k=a,N=k.alternate,V=k.stateNode;if(k=k.tag,N!==null&&N===o)break;k!==5&&k!==26&&k!==27||V===null||(N=V,u?(V=Er(a,h),V!=null&&v.unshift(Yo(a,V,N))):u||(V=Er(a,h),V!=null&&v.push(Yo(a,V,N)))),a=a.return}v.length!==0&&i.push({event:r,listeners:v})}var vk=/\r\n?/g,bk=/\u0000|\uFFFD/g;function zy(i){return(typeof i=="string"?i:""+i).replace(vk,`
10
- `).replace(bk,"")}function Py(i,r){return r=zy(r),zy(i)===r}function Nt(i,r,a,o,u,h){switch(a){case"children":typeof o=="string"?r==="body"||r==="textarea"&&o===""||_n(i,o):(typeof o=="number"||typeof o=="bigint")&&r!=="body"&&_n(i,""+o);break;case"className":Fr(i,"class",o);break;case"tabIndex":Fr(i,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Fr(i,a,o);break;case"style":cl(i,o,h);break;case"data":if(r!=="object"){Fr(i,"data",o);break}case"src":case"href":if(o===""&&(r!=="a"||a!=="href")){i.removeAttribute(a);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Vr(""+o),i.setAttribute(a,o);break;case"action":case"formAction":if(typeof o=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(r!=="input"&&Nt(i,r,"name",u.name,u,null),Nt(i,r,"formEncType",u.formEncType,u,null),Nt(i,r,"formMethod",u.formMethod,u,null),Nt(i,r,"formTarget",u.formTarget,u,null)):(Nt(i,r,"encType",u.encType,u,null),Nt(i,r,"method",u.method,u,null),Nt(i,r,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Vr(""+o),i.setAttribute(a,o);break;case"onClick":o!=null&&(i.onclick=vn);break;case"onScroll":o!=null&&dt("scroll",i);break;case"onScrollEnd":o!=null&&dt("scrollend",i);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":i.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){i.removeAttribute("xlink:href");break}a=Vr(""+o),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""+o):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":o===!0?i.setAttribute(a,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,o):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?i.setAttribute(a,o):i.removeAttribute(a);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?i.removeAttribute(a):i.setAttribute(a,o);break;case"popover":dt("beforetoggle",i),dt("toggle",i),mn(i,"popover",o);break;case"xlinkActuate":gn(i,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":gn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":gn(i,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":gn(i,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":gn(i,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":gn(i,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":gn(i,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":gn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":gn(i,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":mn(i,"is",o);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=ya.get(a)||a,mn(i,a,o))}}function Cp(i,r,a,o,u,h){switch(a){case"style":cl(i,o,h);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof o=="string"?_n(i,o):(typeof o=="number"||typeof o=="bigint")&&_n(i,""+o);break;case"onScroll":o!=null&&dt("scroll",i);break;case"onScrollEnd":o!=null&&dt("scrollend",i);break;case"onClick":o!=null&&(i.onclick=vn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!en.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),r=a.slice(2,u?a.length-7:void 0),h=i[$t]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(r,h,u),typeof o=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(r,o,u);break e}a in i?i[a]=o:o===!0?i.setAttribute(a,""):mn(i,a,o)}}}function Gi(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":dt("error",i),dt("load",i);var o=!1,u=!1,h;for(h in a)if(a.hasOwnProperty(h)){var v=a[h];if(v!=null)switch(h){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Nt(i,r,h,v,a,null)}}u&&Nt(i,r,"srcSet",a.srcSet,a,null),o&&Nt(i,r,"src",a.src,a,null);return;case"input":dt("invalid",i);var k=h=v=u=null,N=null,V=null;for(o in a)if(a.hasOwnProperty(o)){var oe=a[o];if(oe!=null)switch(o){case"name":u=oe;break;case"type":v=oe;break;case"checked":N=oe;break;case"defaultChecked":V=oe;break;case"value":h=oe;break;case"defaultValue":k=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(s(137,r));break;default:Nt(i,r,o,oe,a,null)}}Cs(i,h,k,N,V,v,u,!1);return;case"select":dt("invalid",i),o=v=h=null;for(u in a)if(a.hasOwnProperty(u)&&(k=a[u],k!=null))switch(u){case"value":h=k;break;case"defaultValue":v=k;break;case"multiple":o=k;default:Nt(i,r,u,k,a,null)}r=h,a=v,i.multiple=!!o,r!=null?Vn(i,!!o,r,!1):a!=null&&Vn(i,!!o,a,!0);return;case"textarea":dt("invalid",i),h=u=o=null;for(v in a)if(a.hasOwnProperty(v)&&(k=a[v],k!=null))switch(v){case"value":o=k;break;case"defaultValue":u=k;break;case"children":h=k;break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(s(91));break;default:Nt(i,r,v,k,a,null)}xs(i,o,u,h);return;case"option":for(N in a)a.hasOwnProperty(N)&&(o=a[N],o!=null)&&(N==="selected"?i.selected=o&&typeof o!="function"&&typeof o!="symbol":Nt(i,r,N,o,a,null));return;case"dialog":dt("beforetoggle",i),dt("toggle",i),dt("cancel",i),dt("close",i);break;case"iframe":case"object":dt("load",i);break;case"video":case"audio":for(o=0;o<Vo.length;o++)dt(Vo[o],i);break;case"image":dt("error",i),dt("load",i);break;case"details":dt("toggle",i);break;case"embed":case"source":case"link":dt("error",i),dt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in a)if(a.hasOwnProperty(V)&&(o=a[V],o!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Nt(i,r,V,o,a,null)}return;default:if(ks(r)){for(oe in a)a.hasOwnProperty(oe)&&(o=a[oe],o!==void 0&&Cp(i,r,oe,o,a,void 0));return}}for(k in a)a.hasOwnProperty(k)&&(o=a[k],o!=null&&Nt(i,r,k,o,a,null))}function yk(i,r,a,o){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,h=null,v=null,k=null,N=null,V=null,oe=null;for(te in a){var fe=a[te];if(a.hasOwnProperty(te)&&fe!=null)switch(te){case"checked":break;case"value":break;case"defaultValue":N=fe;default:o.hasOwnProperty(te)||Nt(i,r,te,null,o,fe)}}for(var G in o){var te=o[G];if(fe=a[G],o.hasOwnProperty(G)&&(te!=null||fe!=null))switch(G){case"type":h=te;break;case"name":u=te;break;case"checked":V=te;break;case"defaultChecked":oe=te;break;case"value":v=te;break;case"defaultValue":k=te;break;case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(s(137,r));break;default:te!==fe&&Nt(i,r,G,te,o,fe)}}Xe(i,v,k,N,V,oe,h,u);return;case"select":te=v=k=G=null;for(h in a)if(N=a[h],a.hasOwnProperty(h)&&N!=null)switch(h){case"value":break;case"multiple":te=N;default:o.hasOwnProperty(h)||Nt(i,r,h,null,o,N)}for(u in o)if(h=o[u],N=a[u],o.hasOwnProperty(u)&&(h!=null||N!=null))switch(u){case"value":G=h;break;case"defaultValue":k=h;break;case"multiple":v=h;default:h!==N&&Nt(i,r,u,h,o,N)}r=k,a=v,o=te,G!=null?Vn(i,!!a,G,!1):!!o!=!!a&&(r!=null?Vn(i,!!a,r,!0):Vn(i,!!a,a?[]:"",!1));return;case"textarea":te=G=null;for(k in a)if(u=a[k],a.hasOwnProperty(k)&&u!=null&&!o.hasOwnProperty(k))switch(k){case"value":break;case"children":break;default:Nt(i,r,k,null,o,u)}for(v in o)if(u=o[v],h=a[v],o.hasOwnProperty(v)&&(u!=null||h!=null))switch(v){case"value":G=u;break;case"defaultValue":te=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==h&&Nt(i,r,v,u,o,h)}$r(i,G,te);return;case"option":for(var Ie in a)G=a[Ie],a.hasOwnProperty(Ie)&&G!=null&&!o.hasOwnProperty(Ie)&&(Ie==="selected"?i.selected=!1:Nt(i,r,Ie,null,o,G));for(N in o)G=o[N],te=a[N],o.hasOwnProperty(N)&&G!==te&&(G!=null||te!=null)&&(N==="selected"?i.selected=G&&typeof G!="function"&&typeof G!="symbol":Nt(i,r,N,G,o,te));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ye in a)G=a[Ye],a.hasOwnProperty(Ye)&&G!=null&&!o.hasOwnProperty(Ye)&&Nt(i,r,Ye,null,o,G);for(V in o)if(G=o[V],te=a[V],o.hasOwnProperty(V)&&G!==te&&(G!=null||te!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(s(137,r));break;default:Nt(i,r,V,G,o,te)}return;default:if(ks(r)){for(var At in a)G=a[At],a.hasOwnProperty(At)&&G!==void 0&&!o.hasOwnProperty(At)&&Cp(i,r,At,void 0,o,G);for(oe in o)G=o[oe],te=a[oe],!o.hasOwnProperty(oe)||G===te||G===void 0&&te===void 0||Cp(i,r,oe,G,o,te);return}}for(var H in a)G=a[H],a.hasOwnProperty(H)&&G!=null&&!o.hasOwnProperty(H)&&Nt(i,r,H,null,o,G);for(fe in o)G=o[fe],te=a[fe],!o.hasOwnProperty(fe)||G===te||G==null&&te==null||Nt(i,r,fe,G,o,te)}function Iy(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sk(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=0,a=performance.getEntriesByType("resource"),o=0;o<a.length;o++){var u=a[o],h=u.transferSize,v=u.initiatorType,k=u.duration;if(h&&k&&Iy(v)){for(v=0,k=u.responseEnd,o+=1;o<a.length;o++){var N=a[o],V=N.startTime;if(V>k)break;var oe=N.transferSize,fe=N.initiatorType;oe&&Iy(fe)&&(N=N.responseEnd,v+=oe*(N<k?1:(k-V)/(N-V)))}if(--o,r+=8*(h+v)/(u.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var xp=null,kp=null;function sd(i){return i.nodeType===9?i:i.ownerDocument}function Hy(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Uy(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function Ep(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Tp=null;function wk(){var i=window.event;return i&&i.type==="popstate"?i===Tp?!1:(Tp=i,!0):(Tp=null,!1)}var Ky=typeof setTimeout=="function"?setTimeout:void 0,Ck=typeof clearTimeout=="function"?clearTimeout:void 0,Wy=typeof Promise=="function"?Promise:void 0,xk=typeof queueMicrotask=="function"?queueMicrotask:typeof Wy<"u"?function(i){return Wy.resolve(null).then(i).catch(kk)}:Ky;function kk(i){setTimeout(function(){throw i})}function Ys(i){return i==="head"}function Fy(i,r){var a=r,o=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(o===0){i.removeChild(u),Ul(r);return}o--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")o++;else if(a==="html")Xo(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Xo(a);for(var h=a.firstChild;h;){var v=h.nextSibling,k=h.nodeName;h[pr]||k==="SCRIPT"||k==="STYLE"||k==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=v}}else a==="body"&&Xo(i.ownerDocument.body);a=u}while(a);Ul(r)}function qy(i,r){var a=i;i=0;do{var o=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),o&&o.nodeType===8)if(a=o.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=o}while(a)}function Dp(i){var r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Dp(a),Hr(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Ek(i,r,a,o){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!o&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(o){if(!i[pr])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var h=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=ir(i.nextSibling),i===null)break}return null}function Tk(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ir(i.nextSibling),i===null))return null;return i}function $y(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=ir(i.nextSibling),i===null))return null;return i}function Rp(i){return i.data==="$?"||i.data==="$~"}function Mp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Dk(i,r){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||a.readyState!=="loading")r();else{var o=function(){r(),a.removeEventListener("DOMContentLoaded",o)};a.addEventListener("DOMContentLoaded",o),i._reactRetry=o}}function ir(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var Np=null;function Vy(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return ir(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function Yy(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return i;r--}else a!=="/$"&&a!=="/&"||r++}i=i.previousSibling}return null}function Xy(i,r,a){switch(r=sd(a),i){case"html":if(i=r.documentElement,!i)throw Error(s(452));return i;case"head":if(i=r.head,!i)throw Error(s(453));return i;case"body":if(i=r.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function Xo(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Hr(i)}var nr=new Map,Gy=new Set;function ad(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var ds=R.d;R.d={f:Rk,r:Mk,D:Nk,C:Ak,L:Lk,m:Bk,X:jk,S:Ok,M:zk};function Rk(){var i=ds.f(),r=Zu();return i||r}function Mk(i){var r=qn(i);r!==null&&r.tag===5&&r.type==="form"?fb(r):ds.r(i)}var Pl=typeof document>"u"?null:document;function Zy(i,r,a){var o=Pl;if(o&&typeof r=="string"&&r){var u=tn(r);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),Gy.has(u)||(Gy.add(u),i={rel:i,crossOrigin:a,href:r},o.querySelector(u)===null&&(r=o.createElement("link"),Gi(r,"link",i),Vt(r),o.head.appendChild(r)))}}function Nk(i){ds.D(i),Zy("dns-prefetch",i,null)}function Ak(i,r){ds.C(i,r),Zy("preconnect",i,r)}function Lk(i,r,a){ds.L(i,r,a);var o=Pl;if(o&&i&&r){var u='link[rel="preload"][as="'+tn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+tn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+tn(a.imageSizes)+'"]')):u+='[href="'+tn(i)+'"]';var h=u;switch(r){case"style":h=Il(i);break;case"script":h=Hl(i)}nr.has(h)||(i=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),nr.set(h,i),o.querySelector(u)!==null||r==="style"&&o.querySelector(Go(h))||r==="script"&&o.querySelector(Zo(h))||(r=o.createElement("link"),Gi(r,"link",i),Vt(r),o.head.appendChild(r)))}}function Bk(i,r){ds.m(i,r);var a=Pl;if(a&&i){var o=r&&typeof r.as=="string"?r.as:"script",u='link[rel="modulepreload"][as="'+tn(o)+'"][href="'+tn(i)+'"]',h=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Hl(i)}if(!nr.has(h)&&(i=b({rel:"modulepreload",href:i},r),nr.set(h,i),a.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Zo(h)))return}o=a.createElement("link"),Gi(o,"link",i),Vt(o),a.head.appendChild(o)}}}function Ok(i,r,a){ds.S(i,r,a);var o=Pl;if(o&&i){var u=$n(o).hoistableStyles,h=Il(i);r=r||"default";var v=u.get(h);if(!v){var k={loading:0,preload:null};if(v=o.querySelector(Go(h)))k.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":r},a),(a=nr.get(h))&&Ap(i,a);var N=v=o.createElement("link");Vt(N),Gi(N,"link",i),N._p=new Promise(function(V,oe){N.onload=V,N.onerror=oe}),N.addEventListener("load",function(){k.loading|=1}),N.addEventListener("error",function(){k.loading|=2}),k.loading|=4,ld(v,r,o)}v={type:"stylesheet",instance:v,count:1,state:k},u.set(h,v)}}}function jk(i,r){ds.X(i,r);var a=Pl;if(a&&i){var o=$n(a).hoistableScripts,u=Hl(i),h=o.get(u);h||(h=a.querySelector(Zo(u)),h||(i=b({src:i,async:!0},r),(r=nr.get(u))&&Lp(i,r),h=a.createElement("script"),Vt(h),Gi(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(u,h))}}function zk(i,r){ds.M(i,r);var a=Pl;if(a&&i){var o=$n(a).hoistableScripts,u=Hl(i),h=o.get(u);h||(h=a.querySelector(Zo(u)),h||(i=b({src:i,async:!0,type:"module"},r),(r=nr.get(u))&&Lp(i,r),h=a.createElement("script"),Vt(h),Gi(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(u,h))}}function Qy(i,r,a,o){var u=(u=xe.current)?ad(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Il(a.href),a=$n(u).hoistableStyles,o=a.get(r),o||(o={type:"style",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Il(a.href);var h=$n(u).hoistableStyles,v=h.get(i);if(v||(u=u.ownerDocument||u,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,v),(h=u.querySelector(Go(i)))&&!h._p&&(v.instance=h,v.state.loading=5),nr.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},nr.set(i,a),h||Pk(u,i,a,v.state))),r&&o===null)throw Error(s(528,""));return v}if(r&&o!==null)throw Error(s(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Hl(a),a=$n(u).hoistableScripts,o=a.get(r),o||(o={type:"script",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Il(i){return'href="'+tn(i)+'"'}function Go(i){return'link[rel="stylesheet"]['+i+"]"}function Jy(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function Pk(i,r,a,o){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?o.loading=1:(r=i.createElement("link"),o.preload=r,r.addEventListener("load",function(){return o.loading|=1}),r.addEventListener("error",function(){return o.loading|=2}),Gi(r,"link",a),Vt(r),i.head.appendChild(r))}function Hl(i){return'[src="'+tn(i)+'"]'}function Zo(i){return"script[async]"+i}function eS(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var o=i.querySelector('style[data-href~="'+tn(a.href)+'"]');if(o)return r.instance=o,Vt(o),o;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return o=(i.ownerDocument||i).createElement("style"),Vt(o),Gi(o,"style",u),ld(o,a.precedence,i),r.instance=o;case"stylesheet":u=Il(a.href);var h=i.querySelector(Go(u));if(h)return r.state.loading|=4,r.instance=h,Vt(h),h;o=Jy(a),(u=nr.get(u))&&Ap(o,u),h=(i.ownerDocument||i).createElement("link"),Vt(h);var v=h;return v._p=new Promise(function(k,N){v.onload=k,v.onerror=N}),Gi(h,"link",o),r.state.loading|=4,ld(h,a.precedence,i),r.instance=h;case"script":return h=Hl(a.src),(u=i.querySelector(Zo(h)))?(r.instance=u,Vt(u),u):(o=a,(u=nr.get(h))&&(o=b({},a),Lp(o,u)),i=i.ownerDocument||i,u=i.createElement("script"),Vt(u),Gi(u,"link",o),i.head.appendChild(u),r.instance=u);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(o=r.instance,r.state.loading|=4,ld(o,a.precedence,i));return r.instance}function ld(i,r,a){for(var o=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,h=u,v=0;v<o.length;v++){var k=o[v];if(k.dataset.precedence===r)h=k;else if(h!==u)break}h?h.parentNode.insertBefore(i,h.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function Ap(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Lp(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var od=null;function tS(i,r,a){if(od===null){var o=new Map,u=od=new Map;u.set(a,o)}else u=od,o=u.get(a),o||(o=new Map,u.set(a,o));if(o.has(i))return o;for(o.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var h=a[u];if(!(h[pr]||h[fi]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var v=h.getAttribute(r)||"";v=i+v;var k=o.get(v);k?k.push(h):o.set(v,[h])}}return o}function iS(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function Ik(i,r,a){if(a===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(i=r.disabled,typeof r.precedence=="string"&&i==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function nS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Hk(i,r,a,o){if(a.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=Il(o.href),h=r.querySelector(Go(u));if(h){r=h._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=cd.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=h,Vt(h);return}h=r.ownerDocument||r,o=Jy(o),(u=nr.get(u))&&Ap(o,u),h=h.createElement("link"),Vt(h);var v=h;v._p=new Promise(function(k,N){v.onload=k,v.onerror=N}),Gi(h,"link",o),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=cd.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Bp=0;function Uk(i,r){return i.stylesheets&&i.count===0&&dd(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var o=setTimeout(function(){if(i.stylesheets&&dd(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+r);0<i.imgBytes&&Bp===0&&(Bp=62500*Sk());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&dd(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>Bp?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function cd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)dd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ud=null;function dd(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ud=new Map,r.forEach(Kk,i),ud=null,cd.call(i))}function Kk(i,r){if(!(r.state.loading&4)){var a=ud.get(i);if(a)var o=a.get(null);else{a=new Map,ud.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<u.length;h++){var v=u[h];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(a.set(v.dataset.precedence,v),o=v)}o&&a.set(null,o)}u=r.instance,v=u.getAttribute("data-precedence"),h=a.get(v)||o,h===o&&a.set(null,u),a.set(v,u),this.count++,o=cd.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),h?h.parentNode.insertBefore(u,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),r.state.loading|=4}}var Qo={$$typeof:Y,Provider:null,Consumer:null,_currentValue:P,_currentValue2:P,_threadCount:0};function Wk(i,r,a,o,u,h,v,k,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hi(0),this.hiddenUpdates=hi(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=h,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function rS(i,r,a,o,u,h,v,k,N,V,oe,fe){return i=new Wk(i,r,a,v,N,V,oe,fe,k),r=1,h===!0&&(r|=24),h=On(3,null,null,r),i.current=h,h.stateNode=i,r=ff(),r.refCount++,i.pooledCache=r,r.refCount++,h.memoizedState={element:o,isDehydrated:a,cache:r},_f(h),i}function sS(i){return i?(i=_l,i):_l}function aS(i,r,a,o,u,h){u=sS(u),o.context===null?o.context=u:o.pendingContext=u,o=zs(r),o.payload={element:a},h=h===void 0?null:h,h!==null&&(o.callback=h),a=Ps(i,o,r),a!==null&&(xn(a,i,r),Mo(a,i,r))}function lS(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Op(i,r){lS(i,r),(i=i.alternate)&&lS(i,r)}function oS(i){if(i.tag===13||i.tag===31){var r=Da(i,67108864);r!==null&&xn(r,i,67108864),Op(i,67108864)}}function cS(i){if(i.tag===13||i.tag===31){var r=Hn();r=Ji(r);var a=Da(i,r);a!==null&&xn(a,i,r),Op(i,r)}}var hd=!0;function Fk(i,r,a,o){var u=A.T;A.T=null;var h=R.p;try{R.p=2,jp(i,r,a,o)}finally{R.p=h,A.T=u}}function qk(i,r,a,o){var u=A.T;A.T=null;var h=R.p;try{R.p=8,jp(i,r,a,o)}finally{R.p=h,A.T=u}}function jp(i,r,a,o){if(hd){var u=zp(o);if(u===null)wp(i,r,o,fd,a),dS(i,o);else if(Vk(u,i,r,a,o))o.stopPropagation();else if(dS(i,o),r&4&&-1<$k.indexOf(i)){for(;u!==null;){var h=qn(u);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var v=kt(h.pendingLanes);if(v!==0){var k=h;for(k.pendingLanes|=2,k.entangledLanes|=2;v;){var N=1<<31-F(v);k.entanglements[1]|=N,v&=~N}Lr(h),(St&6)===0&&(Xu=wt()+500,$o(0))}}break;case 31:case 13:k=Da(h,2),k!==null&&xn(k,h,2),Zu(),Op(h,2)}if(h=zp(o),h===null&&wp(i,r,o,fd,a),h===u)break;u=h}u!==null&&o.stopPropagation()}else wp(i,r,o,null,a)}}function zp(i){return i=Es(i),Pp(i)}var fd=null;function Pp(i){if(fd=null,i=fn(i),i!==null){var r=c(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=d(r),i!==null)return i;i=null}else if(a===31){if(i=m(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return fd=i,null}function uS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(qi()){case Oi:return 2;case ii:return 8;case le:case je:return 32;case Ze:return 268435456;default:return 32}default:return 32}}var Ip=!1,Xs=null,Gs=null,Zs=null,Jo=new Map,ec=new Map,Qs=[],$k="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function dS(i,r){switch(i){case"focusin":case"focusout":Xs=null;break;case"dragenter":case"dragleave":Gs=null;break;case"mouseover":case"mouseout":Zs=null;break;case"pointerover":case"pointerout":Jo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ec.delete(r.pointerId)}}function tc(i,r,a,o,u,h){return i===null||i.nativeEvent!==h?(i={blockedOn:r,domEventName:a,eventSystemFlags:o,nativeEvent:h,targetContainers:[u]},r!==null&&(r=qn(r),r!==null&&oS(r)),i):(i.eventSystemFlags|=o,r=i.targetContainers,u!==null&&r.indexOf(u)===-1&&r.push(u),i)}function Vk(i,r,a,o,u){switch(r){case"focusin":return Xs=tc(Xs,i,r,a,o,u),!0;case"dragenter":return Gs=tc(Gs,i,r,a,o,u),!0;case"mouseover":return Zs=tc(Zs,i,r,a,o,u),!0;case"pointerover":var h=u.pointerId;return Jo.set(h,tc(Jo.get(h)||null,i,r,a,o,u)),!0;case"gotpointercapture":return h=u.pointerId,ec.set(h,tc(ec.get(h)||null,i,r,a,o,u)),!0}return!1}function hS(i){var r=fn(i.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=d(a),r!==null){i.blockedOn=r,Dn(i.priority,function(){cS(a)});return}}else if(r===31){if(r=m(a),r!==null){i.blockedOn=r,Dn(i.priority,function(){cS(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function pd(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=zp(i.nativeEvent);if(a===null){a=i.nativeEvent;var o=new a.constructor(a.type,a);Nn=o,a.target.dispatchEvent(o),Nn=null}else return r=qn(a),r!==null&&oS(r),i.blockedOn=a,!1;r.shift()}return!0}function fS(i,r,a){pd(i)&&a.delete(r)}function Yk(){Ip=!1,Xs!==null&&pd(Xs)&&(Xs=null),Gs!==null&&pd(Gs)&&(Gs=null),Zs!==null&&pd(Zs)&&(Zs=null),Jo.forEach(fS),ec.forEach(fS)}function md(i,r){i.blockedOn===r&&(i.blockedOn=null,Ip||(Ip=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Yk)))}var gd=null;function pS(i){gd!==i&&(gd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){gd===i&&(gd=null);for(var r=0;r<i.length;r+=3){var a=i[r],o=i[r+1],u=i[r+2];if(typeof o!="function"){if(Pp(o||a)===null)continue;break}var h=qn(a);h!==null&&(i.splice(r,3),r-=3,zf(h,{pending:!0,data:u,method:a.method,action:o},o,u))}}))}function Ul(i){function r(N){return md(N,i)}Xs!==null&&md(Xs,i),Gs!==null&&md(Gs,i),Zs!==null&&md(Zs,i),Jo.forEach(r),ec.forEach(r);for(var a=0;a<Qs.length;a++){var o=Qs[a];o.blockedOn===i&&(o.blockedOn=null)}for(;0<Qs.length&&(a=Qs[0],a.blockedOn===null);)hS(a),a.blockedOn===null&&Qs.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(o=0;o<a.length;o+=3){var u=a[o],h=a[o+1],v=u[$t]||null;if(typeof h=="function")v||pS(a);else if(v){var k=null;if(h&&h.hasAttribute("formAction")){if(u=h,v=h[$t]||null)k=v.formAction;else if(Pp(u)!==null)continue}else k=v.action;typeof k=="function"?a[o+1]=k:(a.splice(o,3),o-=3),pS(a)}}}function mS(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(v){return u=v})},focusReset:"manual",scroll:"manual"})}function r(){u!==null&&(u(),u=null),o||setTimeout(a,20)}function a(){if(!o&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){o=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),u!==null&&(u(),u=null)}}}function Hp(i){this._internalRoot=i}_d.prototype.render=Hp.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,o=Hn();aS(a,o,i,r,null,null)},_d.prototype.unmount=Hp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;aS(i.current,2,null,i,null,null),Zu(),r[hr]=null}};function _d(i){this._internalRoot=i}_d.prototype.unstable_scheduleHydration=function(i){if(i){var r=ji();i={blockedOn:null,target:i,priority:r};for(var a=0;a<Qs.length&&r!==0&&r<Qs[a].priority;a++);Qs.splice(a,0,i),a===0&&hS(i)}};var gS=t.version;if(gS!=="19.2.6")throw Error(s(527,gS,"19.2.6"));R.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(r),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var Xk={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var vd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!vd.isDisabled&&vd.supportsFiber)try{Ct=vd.inject(Xk),xt=vd}catch{}}return nc.createRoot=function(i,r){if(!l(i))throw Error(s(299));var a=!1,o="",u=Cb,h=xb,v=kb;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(o=r.identifierPrefix),r.onUncaughtError!==void 0&&(u=r.onUncaughtError),r.onCaughtError!==void 0&&(h=r.onCaughtError),r.onRecoverableError!==void 0&&(v=r.onRecoverableError)),r=rS(i,1,!1,null,null,a,o,null,u,h,v,mS),i[hr]=r.current,Sp(i),new Hp(r)},nc.hydrateRoot=function(i,r,a){if(!l(i))throw Error(s(299));var o=!1,u="",h=Cb,v=xb,k=kb,N=null;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(v=a.onCaughtError),a.onRecoverableError!==void 0&&(k=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),r=rS(i,1,!0,r,a??null,o,u,N,h,v,k,mS),r.context=sS(null),a=r.current,o=Hn(),o=Ji(o),u=zs(o),u.callback=null,Ps(a,u,o),a=o,r.current.lanes=a,Zt(r,a),Lr(r),i[hr]=r.current,Sp(i),new _d(r)},nc.version="19.2.6",nc}var ES;function sE(){if(ES)return Wp.exports;ES=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wp.exports=rE(),Wp.exports}var aE=sE();class or extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function _h(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${oa(t)}`),setupPassword:t=>De(e,"/api/auth/password",et("POST",t)),login:t=>De(e,"/api/auth/login",et("POST",t)),reauth:t=>De(e,"/api/auth/reauth",et("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",et("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",et("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await ql(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",et("POST",t)),removeNetwork:async t=>{await ql(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",et("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",et("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,et("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",et("PATCH",{name:t})),removeAgent:async t=>{await ql(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${oa(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",et("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",et("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",et("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",et("POST",t)),listFiles:t=>De(e,"/api/files/list",et("POST",t)),readFile:t=>De(e,"/api/files/read",et("POST",t)),writeFile:t=>De(e,"/api/files/write",et("POST",t)),createFileEntry:t=>De(e,"/api/files/create",et("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",et("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",et("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",et("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",et("POST",t)),previewFile:t=>Pw(e,"/api/files/preview",et("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",et("POST",t)),closeTerminal:async t=>{await ql(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,et("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${oa(n)}`),getTerminalTranscriptHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${oa(n)}`),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",et("PUT",t)),deleteNotificationAsset:async t=>{await ql(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:t=>De(e,`/api/push-notifications/status${t?oa({clientId:t}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",et("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",et("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",et("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",et("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",et("POST",t))}}function eo(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(s={})=>De(t,n("terminals"),et("POST",s)),closeTerminal:async s=>{await ql(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,l)=>De(t,n(`terminals/${encodeURIComponent(s)}`),et("PATCH",{title:l})),getTerminalHistory:(s,l={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${oa(l)}`),getTerminalTranscriptHistory:(s,l={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${oa(l)}`),getTerminalTranscriptSource:s=>De(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:s=>De(t,n("terminal-layout"),et("PUT",s)),createFileRoot:s=>De(t,n("files/root"),et("POST",s)),listFiles:s=>De(t,n("files/list"),et("POST",s)),readFile:s=>De(t,n("files/read"),et("POST",s)),writeFile:s=>De(t,n("files/write"),et("POST",s)),createFileEntry:s=>De(t,n("files/create"),et("POST",s)),moveFileEntry:s=>De(t,n("files/move"),et("POST",s)),previewDeleteFileEntry:s=>De(t,n("files/delete-preview"),et("POST",s)),deleteFileEntry:s=>De(t,n("files/delete"),et("POST",s)),openFileInTerminal:s=>De(t,n("files/open"),et("POST",s)),previewFile:s=>Pw(t,n("files/preview"),et("POST",s)),getCodeServerStatus:(s={})=>De(t,`${n("code-server/status")}${oa(s)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>De(t,n("code-server/open"),et("POST",s)),stopCodeServer:(s={})=>De(t,n("code-server/stop"),et("POST",s)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,l=window.location.href)=>lE(n(`terminals/${encodeURIComponent(s)}/ws`),l)}}function lE(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function et(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function oa(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function De(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await c_(s);try{return await s.json()}catch{throw new or(s.status,"invalid_json_response")}}async function ql(e,t,n){const s=await e(t,n);await c_(s)}async function Pw(e,t,n){const s=await e(t,n);return await c_(s),s.blob()}async function c_(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),s=typeof n.error=="string"?n.error:n.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new or(e.status,t)}const u_="nterminal.theme.id",Iw="nterminal.theme.accent",Tm="nterminal:theme",Xd=[{id:"midnight",label:"Midnight",description:"Current dark terminal look with aqua focus.",mode:"dark",tokens:{bg:"#0a0d10",bg2:"#0d1216",bgSidebar:"#08090b",line:"#1a2128",line2:"#2a3340",fg:"#e2e8ee",fg2:"#8896a3",fg3:"#54616d",fg4:"#3f4a54",accent:"#5eead4",accentSoft:"rgba(94, 234, 212, 0.10)",accentGlow:"rgba(94, 234, 212, 0.55)",onAccent:"#062423",ok:"#34d399",danger:"#f87171",onDanger:"#190607",dangerSoft:"rgba(248, 113, 113, 0.08)",dangerLine:"rgba(248, 113, 113, 0.30)",warning:"#fbbf24",warningSoft:"rgba(247, 217, 119, 0.075)",warningGlow:"rgba(245, 158, 11, 0.55)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.35)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(10, 13, 16, 0.86)",floatingBgStrong:"rgba(10, 13, 16, 0.96)",floatingBgHover:"rgba(15, 23, 27, 0.94)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.015)",scrollbarThumb:"rgba(148, 163, 184, 0.50)",scrollbarThumbHover:"rgba(148, 163, 184, 0.70)",transcriptUser:"#f7d977",transcriptAssistant:"#5eead4",transcriptTool:"#9aa7b4",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f7d977",transcriptOnSearch:"#121417",qrBg:"#ffffff"},xterm:{background:"#0a0d10",foreground:"#e2e8ee",cursor:"#5eead4",selectionBackground:"#1f3f45"}},{id:"daylight",label:"Daylight",description:"Light workspace with dark terminal contrast.",mode:"light",tokens:{bg:"#f7f9fc",bg2:"#ffffff",bgSidebar:"#eef2f7",line:"#dbe3ec",line2:"#c3cedb",fg:"#17212b",fg2:"#526170",fg3:"#7b8794",fg4:"#a1acb8",accent:"#0f8f83",accentSoft:"rgba(15, 143, 131, 0.11)",accentGlow:"rgba(15, 143, 131, 0.24)",onAccent:"#021918",ok:"#16835c",danger:"#c03545",onDanger:"#fff7f8",dangerSoft:"rgba(192, 53, 69, 0.10)",dangerLine:"rgba(192, 53, 69, 0.30)",warning:"#b7791f",warningSoft:"rgba(183, 121, 31, 0.12)",warningGlow:"rgba(183, 121, 31, 0.26)",scrim:"rgba(15, 23, 42, 0.34)",scrimSoft:"rgba(15, 23, 42, 0.20)",shadow:"rgba(15, 23, 42, 0.18)",shadowStrong:"rgba(15, 23, 42, 0.28)",floatingBg:"rgba(255, 255, 255, 0.92)",floatingBgStrong:"rgba(255, 255, 255, 0.98)",floatingBgHover:"rgba(239, 246, 249, 0.96)",subtleFill:"rgba(15, 23, 42, 0.025)",hoverFill:"rgba(15, 23, 42, 0.035)",scrollbarThumb:"rgba(82, 97, 112, 0.38)",scrollbarThumbHover:"rgba(82, 97, 112, 0.58)",transcriptUser:"#8b3f75",transcriptAssistant:"#0f8f83",transcriptTool:"#66717d",transcriptCommand:"#0b6fa4",transcriptCode:"#075985",transcriptSearch:"#f0c14b",transcriptOnSearch:"#1f1a10",qrBg:"#ffffff"},xterm:{background:"#ffffff",foreground:"#17212b",cursor:"#0f8f83",selectionBackground:"#cdeee9",...TS({foreground:"#17212b",foregroundMuted:"#526170",line:"#dbe3ec",red:"#b4232f",green:"#16794f",yellow:"#9a6700",blue:"#0b6fa4",magenta:"#8f3f85",cyan:"#0f766e"})}},{id:"signal-red",label:"Signal",description:"Dark control-room surface with red alerts.",mode:"dark",tokens:{bg:"#100d0f",bg2:"#171113",bgSidebar:"#0b080a",line:"#2a1b20",line2:"#452b32",fg:"#f1e7e9",fg2:"#a58d93",fg3:"#765f66",fg4:"#55434a",accent:"#ff2a3d",accentSoft:"rgba(255, 42, 61, 0.12)",accentGlow:"rgba(255, 42, 61, 0.52)",onAccent:"#210407",ok:"#34d399",danger:"#ff4d5f",onDanger:"#210407",dangerSoft:"rgba(255, 77, 95, 0.10)",dangerLine:"rgba(255, 77, 95, 0.32)",warning:"#fbbf24",warningSoft:"rgba(251, 191, 36, 0.10)",warningGlow:"rgba(245, 158, 11, 0.50)",scrim:"rgba(0, 0, 0, 0.58)",scrimSoft:"rgba(0, 0, 0, 0.30)",shadow:"rgba(0, 0, 0, 0.36)",shadowStrong:"rgba(0, 0, 0, 0.52)",floatingBg:"rgba(16, 13, 15, 0.88)",floatingBgStrong:"rgba(16, 13, 15, 0.96)",floatingBgHover:"rgba(25, 16, 19, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(165, 141, 147, 0.45)",scrollbarThumbHover:"rgba(165, 141, 147, 0.65)",transcriptUser:"#f8d36f",transcriptAssistant:"#ff2a3d",transcriptTool:"#ad9ca2",transcriptCommand:"#ff9ca6",transcriptCode:"#ffd1d6",transcriptSearch:"#f8d36f",transcriptOnSearch:"#1b0e10",qrBg:"#ffffff"},xterm:{background:"#100d0f",foreground:"#f1e7e9",cursor:"#ff2a3d",selectionBackground:"#4a1b22"}},{id:"graphite",label:"Graphite",description:"Neutral dark theme with blue command focus.",mode:"dark",tokens:{bg:"#101214",bg2:"#171a1d",bgSidebar:"#0c0e10",line:"#262b30",line2:"#39414a",fg:"#eceff3",fg2:"#9aa4af",fg3:"#6c7680",fg4:"#4d5660",accent:"#7dd3fc",accentSoft:"rgba(125, 211, 252, 0.11)",accentGlow:"rgba(125, 211, 252, 0.38)",onAccent:"#071c26",ok:"#4ade80",danger:"#fb7185",onDanger:"#26070d",dangerSoft:"rgba(251, 113, 133, 0.09)",dangerLine:"rgba(251, 113, 133, 0.30)",warning:"#facc15",warningSoft:"rgba(250, 204, 21, 0.09)",warningGlow:"rgba(250, 204, 21, 0.42)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.34)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(16, 18, 20, 0.88)",floatingBgStrong:"rgba(16, 18, 20, 0.96)",floatingBgHover:"rgba(22, 28, 33, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(154, 164, 175, 0.45)",scrollbarThumbHover:"rgba(154, 164, 175, 0.65)",transcriptUser:"#f2d675",transcriptAssistant:"#7dd3fc",transcriptTool:"#aab4bf",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f2d675",transcriptOnSearch:"#141513",qrBg:"#ffffff"},xterm:{background:"#101214",foreground:"#eceff3",cursor:"#7dd3fc",selectionBackground:"#263d4b"}},{id:"paper",label:"Paper",description:"Warm light surface with restrained amber accent.",mode:"light",tokens:{bg:"#fbfaf7",bg2:"#ffffff",bgSidebar:"#f2f0ea",line:"#e2ddd4",line2:"#cbc3b6",fg:"#25211d",fg2:"#62584e",fg3:"#8d8275",fg4:"#afa69b",accent:"#a35d00",accentSoft:"rgba(163, 93, 0, 0.11)",accentGlow:"rgba(163, 93, 0, 0.24)",onAccent:"#fffaf2",ok:"#26744d",danger:"#b23a48",onDanger:"#fff8f8",dangerSoft:"rgba(178, 58, 72, 0.10)",dangerLine:"rgba(178, 58, 72, 0.30)",warning:"#a35d00",warningSoft:"rgba(163, 93, 0, 0.12)",warningGlow:"rgba(163, 93, 0, 0.26)",scrim:"rgba(37, 33, 29, 0.32)",scrimSoft:"rgba(37, 33, 29, 0.18)",shadow:"rgba(37, 33, 29, 0.18)",shadowStrong:"rgba(37, 33, 29, 0.28)",floatingBg:"rgba(255, 253, 249, 0.92)",floatingBgStrong:"rgba(255, 253, 249, 0.98)",floatingBgHover:"rgba(250, 247, 240, 0.96)",subtleFill:"rgba(37, 33, 29, 0.025)",hoverFill:"rgba(37, 33, 29, 0.035)",scrollbarThumb:"rgba(98, 88, 78, 0.35)",scrollbarThumbHover:"rgba(98, 88, 78, 0.55)",transcriptUser:"#7b3f8c",transcriptAssistant:"#a35d00",transcriptTool:"#776d63",transcriptCommand:"#176a94",transcriptCode:"#6f4b00",transcriptSearch:"#e9c46a",transcriptOnSearch:"#241b0a",qrBg:"#ffffff"},xterm:{background:"#fffdf9",foreground:"#25211d",cursor:"#a35d00",selectionBackground:"#f2dfc5",...TS({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],to="midnight";function vh(e){return Xd.some(t=>t.id===e)?e:to}function d_(e){return Xd.find(t=>t.id===e)??Xd[0]}function ha(){if(typeof window>"u")return to;try{const e=window.localStorage.getItem(u_);return e?vh(e):hE(window.localStorage.getItem(Iw))}catch{return to}}function oE(e){const t=vh(e);if(typeof window<"u"){try{window.localStorage.setItem(u_,t)}catch{}h_(t),window.dispatchEvent(new CustomEvent(Tm,{detail:t}))}return t}function h_(e=ha()){if(typeof document>"u")return;const t=d_(vh(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),at(n,"--nt-bg",t.tokens.bg),at(n,"--nt-bg-2",t.tokens.bg2),at(n,"--nt-bg-sidebar",t.tokens.bgSidebar),at(n,"--nt-line",t.tokens.line),at(n,"--nt-line-2",t.tokens.line2),at(n,"--nt-fg",t.tokens.fg),at(n,"--nt-fg-2",t.tokens.fg2),at(n,"--nt-fg-3",t.tokens.fg3),at(n,"--nt-fg-4",t.tokens.fg4),at(n,"--nt-accent",t.tokens.accent),at(n,"--nt-accent-soft",t.tokens.accentSoft),at(n,"--nt-accent-glow",t.tokens.accentGlow),at(n,"--nt-on-accent",t.tokens.onAccent),at(n,"--nt-ok",t.tokens.ok),at(n,"--nt-danger",t.tokens.danger),at(n,"--nt-on-danger",t.tokens.onDanger),at(n,"--nt-danger-soft",t.tokens.dangerSoft),at(n,"--nt-danger-line",t.tokens.dangerLine),at(n,"--nt-warning",t.tokens.warning),at(n,"--nt-warn",t.tokens.warning),at(n,"--nt-warning-soft",t.tokens.warningSoft),at(n,"--nt-warning-glow",t.tokens.warningGlow),at(n,"--nt-scrim",t.tokens.scrim),at(n,"--nt-scrim-soft",t.tokens.scrimSoft),at(n,"--nt-shadow",t.tokens.shadow),at(n,"--nt-shadow-strong",t.tokens.shadowStrong),at(n,"--nt-floating-bg",t.tokens.floatingBg),at(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),at(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),at(n,"--nt-subtle-fill",t.tokens.subtleFill),at(n,"--nt-hover-fill",t.tokens.hoverFill),at(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),at(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),at(n,"--nt-transcript-user",t.tokens.transcriptUser),at(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),at(n,"--nt-transcript-tool",t.tokens.transcriptTool),at(n,"--nt-transcript-command",t.tokens.transcriptCommand),at(n,"--nt-transcript-code",t.tokens.transcriptCode),at(n,"--nt-transcript-search",t.tokens.transcriptSearch),at(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),at(n,"--nt-qr-bg",t.tokens.qrBg)}function cE(e=ha()){return d_(vh(e)).xterm}function f_(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===u_||n.key===Iw)&&(h_(ha()),e())};return window.addEventListener(Tm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Tm,e),window.removeEventListener("storage",t)}}function at(e,t,n){e.style.setProperty(t,n)}function TS(e){const t=uE(237);return t[215]=e.foreground,t[221]=e.line,{black:e.foreground,red:e.red,green:e.green,yellow:e.yellow,blue:e.blue,magenta:e.magenta,cyan:e.cyan,white:e.foregroundMuted,brightBlack:e.foregroundMuted,brightRed:e.red,brightGreen:e.green,brightYellow:e.yellow,brightBlue:e.blue,brightMagenta:e.magenta,brightCyan:e.cyan,brightWhite:e.foreground,extendedAnsi:t}}function uE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(dE(n));return t}function dE(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],s=n[Math.floor(t/36)%6],l=n[Math.floor(t/6)%6],c=n[t%6];return DS(s,l,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return DS(t,t,t)}return"#000000"}function DS(e,t,n){return`#${Vp(e)}${Vp(t)}${Vp(n)}`}function Vp(e){return e.toString(16).padStart(2,"0")}function hE(e){return e==="signal-red"?"signal-red":to}function Hw(){const e=_.useSyncExternalStore(f_,ha,()=>to);return d_(e).mode==="light"?"-light":""}function Uw({size:e=22}){const t=Hw();return p.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function Kw({height:e=18}){const t=Hw(),n=Math.round(243/34*e);return p.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var pc=zw();const bh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function lo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function p_(e){return"nodeType"in e}function En(e){var t,n;return e?lo(e)?e:p_(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function m_(e){const{Document:t}=En(e);return e instanceof t}function Vc(e){return lo(e)?!1:e instanceof En(e).HTMLElement}function Ww(e){return e instanceof En(e).SVGElement}function oo(e){return e?lo(e)?e.document:p_(e)?m_(e)?e:Vc(e)||Ww(e)?e.ownerDocument:document:document:document}const fa=bh?_.useLayoutEffect:_.useEffect;function g_(e){const t=_.useRef(e);return fa(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,s=new Array(n),l=0;l<n;l++)s[l]=arguments[l];return t.current==null?void 0:t.current(...s)},[])}function fE(){const e=_.useRef(null),t=_.useCallback((s,l)=>{e.current=setInterval(s,l)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Lc(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return fa(()=>{n.current!==e&&(n.current=e)},t),n}function Yc(e,t){const n=_.useRef();return _.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function Gd(e){const t=g_(e),n=_.useRef(null),s=_.useCallback(l=>{l!==n.current&&t?.(l,n.current),n.current=l},[]);return[n,s]}function Dm(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let Yp={};function yh(e,t){return _.useMemo(()=>{if(t)return t;const n=Yp[e]==null?0:Yp[e]+1;return Yp[e]=n,e+"-"+n},[e,t])}function Fw(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),l=1;l<n;l++)s[l-1]=arguments[l];return s.reduce((c,d)=>{const m=Object.entries(d);for(const[g,f]of m){const y=c[g];y!=null&&(c[g]=y+e*f)}return c},{...t})}}const Ql=Fw(1),Zd=Fw(-1);function pE(e){return"clientX"in e&&"clientY"in e}function qw(e){if(!e)return!1;const{KeyboardEvent:t}=En(e.target);return t&&e instanceof t}function mE(e){if(!e)return!1;const{TouchEvent:t}=En(e.target);return t&&e instanceof t}function Rm(e){if(mE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return pE(e)?{x:e.clientX,y:e.clientY}:null}const Mm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Mm.Translate.toString(e),Mm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),RS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function gE(e){return e.matches(RS)?e:e.querySelector(RS)}const _E={display:"none"};function vE(e){let{id:t,value:n}=e;return Ai.createElement("div",{id:t,style:_E},n)}function bE(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;const l={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ai.createElement("div",{id:t,style:l,role:"status","aria-live":s,"aria-atomic":!0},n)}function yE(){const[e,t]=_.useState("");return{announce:_.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const $w=_.createContext(null);function SE(e){const t=_.useContext($w);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function wE(){const[e]=_.useState(()=>new Set),t=_.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[_.useCallback(s=>{let{type:l,event:c}=s;e.forEach(d=>{var m;return(m=d[l])==null?void 0:m.call(d,c)})},[e]),t]}const CE={draggable:`
11
- To pick up a draggable item, press the space bar.
12
- While dragging, use the arrow keys to move the item.
13
- Press space again to drop the item in its new position, or press escape to cancel.
14
- `},xE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function kE(e){let{announcements:t=xE,container:n,hiddenTextDescribedById:s,screenReaderInstructions:l=CE}=e;const{announce:c,announcement:d}=yE(),m=yh("DndLiveRegion"),[g,f]=_.useState(!1);if(_.useEffect(()=>{f(!0)},[]),SE(_.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:x}=b;t.onDragMove&&c(t.onDragMove({active:w,over:x}))},onDragOver(b){let{active:w,over:x}=b;c(t.onDragOver({active:w,over:x}))},onDragEnd(b){let{active:w,over:x}=b;c(t.onDragEnd({active:w,over:x}))},onDragCancel(b){let{active:w,over:x}=b;c(t.onDragCancel({active:w,over:x}))}}),[c,t])),!g)return null;const y=Ai.createElement(Ai.Fragment,null,Ai.createElement(vE,{id:s,value:l.draggable}),Ai.createElement(bE,{id:m,announcement:d}));return n?pc.createPortal(y,n):y}var Ni;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ni||(Ni={}));function Qd(){}function MS(e,t){return _.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function EE(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const wr=Object.freeze({x:0,y:0});function TE(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function DE(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function RE(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),l=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=l-s,m=c-n;if(s<l&&n<c){const g=t.width*t.height,f=e.width*e.height,y=d*m,b=y/(g+f-y);return Number(b.toFixed(4))}return 0}const ME=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const l=[];for(const c of s){const{id:d}=c,m=n.get(d);if(m){const g=RE(m,t);g>0&&l.push({id:d,data:{droppableContainer:c,value:g}})}}return l.sort(TE)};function NE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Vw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:wr}function AE(e){return function(n){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];return l.reduce((d,m)=>({...d,top:d.top+e*m.y,bottom:d.bottom+e*m.y,left:d.left+e*m.x,right:d.right+e*m.x}),{...n})}}const LE=AE(1);function BE(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function OE(e,t,n){const s=BE(t);if(!s)return e;const{scaleX:l,scaleY:c,x:d,y:m}=s,g=e.left-d-(1-l)*parseFloat(n),f=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=l?e.width/l:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:f,right:g+y,bottom:f+b,left:g}}const jE={ignoreTransform:!1};function Xc(e,t){t===void 0&&(t=jE);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:y}=En(e).getComputedStyle(e);f&&(n=OE(n,f,y))}const{top:s,left:l,width:c,height:d,bottom:m,right:g}=n;return{top:s,left:l,width:c,height:d,bottom:m,right:g}}function NS(e){return Xc(e,{ignoreTransform:!0})}function zE(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function PE(e,t){return t===void 0&&(t=En(e).getComputedStyle(e)),t.position==="fixed"}function IE(e,t){t===void 0&&(t=En(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=t[l];return typeof c=="string"?n.test(c):!1})}function __(e,t){const n=[];function s(l){if(t!=null&&n.length>=t||!l)return n;if(m_(l)&&l.scrollingElement!=null&&!n.includes(l.scrollingElement))return n.push(l.scrollingElement),n;if(!Vc(l)||Ww(l)||n.includes(l))return n;const c=En(e).getComputedStyle(l);return l!==e&&IE(l,c)&&n.push(l),PE(l,c)?n:s(l.parentNode)}return e?s(e):n}function Yw(e){const[t]=__(e,1);return t??null}function Xp(e){return!bh||!e?null:lo(e)?e:p_(e)?m_(e)||e===oo(e).scrollingElement?window:Vc(e)?e:null:null}function Xw(e){return lo(e)?e.scrollX:e.scrollLeft}function Gw(e){return lo(e)?e.scrollY:e.scrollTop}function Nm(e){return{x:Xw(e),y:Gw(e)}}var Hi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Hi||(Hi={}));function Zw(e){return!bh||!e?!1:e===document.scrollingElement}function Qw(e){const t={x:0,y:0},n=Zw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},l=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=s.y,m=e.scrollLeft>=s.x;return{isTop:l,isLeft:c,isBottom:d,isRight:m,maxScroll:s,minScroll:t}}const HE={x:.2,y:.2};function UE(e,t,n,s,l){let{top:c,left:d,right:m,bottom:g}=n;s===void 0&&(s=10),l===void 0&&(l=HE);const{isTop:f,isBottom:y,isLeft:b,isRight:w}=Qw(e),x={x:0,y:0},C={x:0,y:0},D={height:t.height*l.y,width:t.width*l.x};return!f&&c<=t.top+D.height?(x.y=Hi.Backward,C.y=s*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(x.y=Hi.Forward,C.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!w&&m>=t.right-D.width?(x.x=Hi.Forward,C.x=s*Math.abs((t.right-D.width-m)/D.width)):!b&&d<=t.left+D.width&&(x.x=Hi.Backward,C.x=s*Math.abs((t.left+D.width-d)/D.width)),{direction:x,speed:C}}function KE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:s,bottom:l}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:l,width:e.clientWidth,height:e.clientHeight}}function Jw(e){return e.reduce((t,n)=>Ql(t,Nm(n)),wr)}function WE(e){return e.reduce((t,n)=>t+Xw(n),0)}function FE(e){return e.reduce((t,n)=>t+Gw(n),0)}function qE(e,t){if(t===void 0&&(t=Xc),!e)return;const{top:n,left:s,bottom:l,right:c}=t(e);Yw(e)&&(l<=0||c<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const $E=[["x",["left","right"],WE],["y",["top","bottom"],FE]];class v_{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=__(n),l=Jw(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,m]of $E)for(const g of d)Object.defineProperty(this,g,{get:()=>{const f=m(s),y=l[c]-f;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class kc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var l;(l=this.target)==null||l.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function VE(e){const{EventTarget:t}=En(e);return e instanceof t?e:oo(e)}function Gp(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var ar;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ar||(ar={}));function AS(e){e.preventDefault()}function YE(e){e.stopPropagation()}var zt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(zt||(zt={}));const e1={start:[zt.Space,zt.Enter],cancel:[zt.Esc],end:[zt.Space,zt.Enter,zt.Tab]},XE=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case zt.Right:return{...n,x:n.x+25};case zt.Left:return{...n,x:n.x-25};case zt.Down:return{...n,y:n.y+25};case zt.Up:return{...n,y:n.y-25}}};class t1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new kc(oo(n)),this.windowListeners=new kc(En(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ar.Resize,this.handleCancel),this.windowListeners.add(ar.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ar.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&qE(s),n(wr)}handleKeyDown(t){if(qw(t)){const{active:n,context:s,options:l}=this.props,{keyboardCodes:c=e1,coordinateGetter:d=XE,scrollBehavior:m="smooth"}=l,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,y=f?{x:f.left,y:f.top}:wr;this.referenceCoordinates||(this.referenceCoordinates=y);const b=d(t,{active:n,context:s.current,currentCoordinates:y});if(b){const w=Zd(b,y),x={x:0,y:0},{scrollableAncestors:C}=s.current;for(const D of C){const B=t.code,{isTop:L,isRight:O,isLeft:Y,isBottom:U,maxScroll:Z,minScroll:W}=Qw(D),re=KE(D),ee={x:Math.min(B===zt.Right?re.right-re.width/2:re.right,Math.max(B===zt.Right?re.left:re.left+re.width/2,b.x)),y:Math.min(B===zt.Down?re.bottom-re.height/2:re.bottom,Math.max(B===zt.Down?re.top:re.top+re.height/2,b.y))},ye=B===zt.Right&&!O||B===zt.Left&&!Y,Ee=B===zt.Down&&!U||B===zt.Up&&!L;if(ye&&ee.x!==b.x){const ne=D.scrollLeft+w.x,q=B===zt.Right&&ne<=Z.x||B===zt.Left&&ne>=W.x;if(q&&!w.y){D.scrollTo({left:ne,behavior:m});return}q?x.x=D.scrollLeft-ne:x.x=B===zt.Right?D.scrollLeft-Z.x:D.scrollLeft-W.x,x.x&&D.scrollBy({left:-x.x,behavior:m});break}else if(Ee&&ee.y!==b.y){const ne=D.scrollTop+w.y,q=B===zt.Down&&ne<=Z.y||B===zt.Up&&ne>=W.y;if(q&&!w.x){D.scrollTo({top:ne,behavior:m});return}q?x.y=D.scrollTop-ne:x.y=B===zt.Down?D.scrollTop-Z.y:D.scrollTop-W.y,x.y&&D.scrollBy({top:-x.y,behavior:m});break}}this.handleMove(t,Ql(Zd(b,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}t1.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=e1,onActivation:l}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(s.start.includes(d)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function LS(e){return!!(e&&"distance"in e)}function BS(e){return!!(e&&"delay"in e)}class b_{constructor(t,n,s){var l;s===void 0&&(s=VE(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=oo(d),this.documentListeners=new kc(this.document),this.listeners=new kc(s),this.windowListeners=new kc(En(d)),this.initialCoordinates=(l=Rm(c))!=null?l:wr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ar.Resize,this.handleCancel),this.windowListeners.add(ar.DragStart,AS),this.windowListeners.add(ar.VisibilityChange,this.handleCancel),this.windowListeners.add(ar.ContextMenu,AS),this.documentListeners.add(ar.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(BS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(LS(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:s,onPending:l}=this.props;l(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ar.Click,YE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ar.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:l,props:c}=this,{onMove:d,options:{activationConstraint:m}}=c;if(!l)return;const g=(n=Rm(t))!=null?n:wr,f=Zd(l,g);if(!s&&m){if(LS(m)){if(m.tolerance!=null&&Gp(f,m.tolerance))return this.handleCancel();if(Gp(f,m.distance))return this.handleStart()}if(BS(m)&&Gp(f,m.tolerance))return this.handleCancel();this.handlePending(m,f);return}t.cancelable&&t.preventDefault(),d(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===zt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const GE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class i1 extends b_{constructor(t){const{event:n}=t,s=oo(n.target);super(t,GE,s)}}i1.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const ZE={move:{name:"mousemove"},end:{name:"mouseup"}};var Am;(function(e){e[e.RightClick=2]="RightClick"})(Am||(Am={}));class n1 extends b_{constructor(t){super(t,ZE,oo(t.event.target))}}n1.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===Am.RightClick?!1:(s?.({event:n}),!0)}}];const Zp={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class r1 extends b_{constructor(t){super(t,Zp)}static setup(){return window.addEventListener(Zp.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Zp.move.name,t)};function t(){}}}r1.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:l}=n;return l.length>1?!1:(s?.({event:n}),!0)}}];var Ec;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ec||(Ec={}));var Jd;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Jd||(Jd={}));function QE(e){let{acceleration:t,activator:n=Ec.Pointer,canScroll:s,draggingRect:l,enabled:c,interval:d=5,order:m=Jd.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:y,delta:b,threshold:w}=e;const x=eT({delta:b,disabled:!c}),[C,D]=fE(),B=_.useRef({x:0,y:0}),L=_.useRef({x:0,y:0}),O=_.useMemo(()=>{switch(n){case Ec.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Ec.DraggableRect:return l}},[n,l,g]),Y=_.useRef(null),U=_.useCallback(()=>{const W=Y.current;if(!W)return;const re=B.current.x*L.current.x,ee=B.current.y*L.current.y;W.scrollBy(re,ee)},[]),Z=_.useMemo(()=>m===Jd.TreeOrder?[...f].reverse():f,[m,f]);_.useEffect(()=>{if(!c||!f.length||!O){D();return}for(const W of Z){if(s?.(W)===!1)continue;const re=f.indexOf(W),ee=y[re];if(!ee)continue;const{direction:ye,speed:Ee}=UE(W,ee,O,t,w);for(const ne of["x","y"])x[ne][ye[ne]]||(Ee[ne]=0,ye[ne]=0);if(Ee.x>0||Ee.y>0){D(),Y.current=W,C(U,d),B.current=Ee,L.current=ye;return}}B.current={x:0,y:0},L.current={x:0,y:0},D()},[t,U,s,D,c,d,JSON.stringify(O),JSON.stringify(x),C,f,Z,y,JSON.stringify(w)])}const JE={x:{[Hi.Backward]:!1,[Hi.Forward]:!1},y:{[Hi.Backward]:!1,[Hi.Forward]:!1}};function eT(e){let{delta:t,disabled:n}=e;const s=Dm(t);return Yc(l=>{if(n||!s||!l)return JE;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Hi.Backward]:l.x[Hi.Backward]||c.x===-1,[Hi.Forward]:l.x[Hi.Forward]||c.x===1},y:{[Hi.Backward]:l.y[Hi.Backward]||c.y===-1,[Hi.Forward]:l.y[Hi.Forward]||c.y===1}}},[n,t,s])}function tT(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return Yc(l=>{var c;return t==null?null:(c=s??l)!=null?c:null},[s,t])}function iT(e,t){return _.useMemo(()=>e.reduce((n,s)=>{const{sensor:l}=s,c=l.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,s)}));return[...n,...c]},[]),[e,t])}var Bc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Bc||(Bc={}));var Lm;(function(e){e.Optimized="optimized"})(Lm||(Lm={}));const OS=new Map;function nT(e,t){let{dragging:n,dependencies:s,config:l}=t;const[c,d]=_.useState(null),{frequency:m,measure:g,strategy:f}=l,y=_.useRef(e),b=B(),w=Lc(b),x=_.useCallback(function(L){L===void 0&&(L=[]),!w.current&&d(O=>O===null?L:O.concat(L.filter(Y=>!O.includes(Y))))},[w]),C=_.useRef(null),D=Yc(L=>{if(b&&!n)return OS;if(!L||L===OS||y.current!==e||c!=null){const O=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){O.set(Y.id,Y.rect.current);continue}const U=Y.node.current,Z=U?new v_(g(U),U):null;Y.rect.current=Z,Z&&O.set(Y.id,Z)}return O}return L},[e,c,n,b,g]);return _.useEffect(()=>{y.current=e},[e]),_.useEffect(()=>{b||x()},[n,b]),_.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),_.useEffect(()=>{b||typeof m!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},m))},[m,b,x,...s]),{droppableRects:D,measureDroppableContainers:x,measuringScheduled:c!=null};function B(){switch(f){case Bc.Always:return!1;case Bc.BeforeDragging:return n;default:return!n}}}function s1(e,t){return Yc(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function rT(e,t){return s1(e,t)}function sT(e){let{callback:t,disabled:n}=e;const s=g_(t),l=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,n]);return _.useEffect(()=>()=>l?.disconnect(),[l]),l}function Sh(e){let{callback:t,disabled:n}=e;const s=g_(t),l=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[n]);return _.useEffect(()=>()=>l?.disconnect(),[l]),l}function aT(e){return new v_(Xc(e),e)}function jS(e,t,n){t===void 0&&(t=aT);const[s,l]=_.useState(null);function c(){l(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??n)!=null?f:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const d=sT({callback(g){if(e)for(const f of g){const{type:y,target:b}=f;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Sh({callback:c});return fa(()=>{c(),e?(m?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),d?.disconnect())},[e]),s}function lT(e){const t=s1(e);return Vw(e,t)}const zS=[];function oT(e){const t=_.useRef(e),n=Yc(s=>e?s&&s!==zS&&e&&t.current&&e.parentNode===t.current.parentNode?s:__(e):zS,[e]);return _.useEffect(()=>{t.current=e},[e]),n}function cT(e){const[t,n]=_.useState(null),s=_.useRef(e),l=_.useCallback(c=>{const d=Xp(c.target);d&&n(m=>m?(m.set(d,Nm(d)),new Map(m)):null)},[]);return _.useEffect(()=>{const c=s.current;if(e!==c){d(c);const m=e.map(g=>{const f=Xp(g);return f?(f.addEventListener("scroll",l,{passive:!0}),[f,Nm(f)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),s.current=e}return()=>{d(e),d(c)};function d(m){m.forEach(g=>{const f=Xp(g);f?.removeEventListener("scroll",l)})}},[l,e]),_.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>Ql(c,d),wr):Jw(e):wr,[e,t])}function PS(e,t){t===void 0&&(t=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},t),_.useEffect(()=>{const s=e!==wr;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?Zd(e,n.current):wr}function uT(e){_.useEffect(()=>{if(!bh)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function dT(e,t){return _.useMemo(()=>e.reduce((n,s)=>{let{eventName:l,handler:c}=s;return n[l]=d=>{c(d,t)},n},{}),[e,t])}function a1(e){return _.useMemo(()=>e?zE(e):null,[e])}const IS=[];function hT(e,t){t===void 0&&(t=Xc);const[n]=e,s=a1(n?En(n):null),[l,c]=_.useState(IS);function d(){c(()=>e.length?e.map(g=>Zw(g)?s:new v_(t(g),g)):IS)}const m=Sh({callback:d});return fa(()=>{m?.disconnect(),d(),e.forEach(g=>m?.observe(g))},[e]),l}function fT(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Vc(t)?t:e}function pT(e){let{measure:t}=e;const[n,s]=_.useState(null),l=_.useCallback(f=>{for(const{target:y}of f)if(Vc(y)){s(b=>{const w=t(y);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=Sh({callback:l}),d=_.useCallback(f=>{const y=fT(f);c?.disconnect(),y&&c?.observe(y),s(y?t(y):null)},[t,c]),[m,g]=Gd(d);return _.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const mT=[{sensor:i1,options:{}},{sensor:t1,options:{}}],gT={current:{}},jd={draggable:{measure:NS},droppable:{measure:NS,strategy:Bc.WhileDragging,frequency:Lm.Optimized},dragOverlay:{measure:Xc}};class Tc extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const _T={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Tc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jd,measureDroppableContainers:Qd,windowRect:null,measuringScheduled:!1},vT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qd,draggableNodes:new Map,over:null,measureDroppableContainers:Qd},wh=_.createContext(vT),bT=_.createContext(_T);function yT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Tc}}}function ST(e,t){switch(t.type){case Ni.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ni.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ni.DragEnd:case Ni.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ni.RegisterDroppable:{const{element:n}=t,{id:s}=n,l=new Tc(e.droppable.containers);return l.set(s,n),{...e,droppable:{...e.droppable,containers:l}}}case Ni.SetDroppableDisabled:{const{id:n,key:s,disabled:l}=t,c=e.droppable.containers.get(n);if(!c||s!==c.key)return e;const d=new Tc(e.droppable.containers);return d.set(n,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:d}}}case Ni.UnregisterDroppable:{const{id:n,key:s}=t,l=e.droppable.containers.get(n);if(!l||s!==l.key)return e;const c=new Tc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function wT(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:l}=_.useContext(wh),c=Dm(s),d=Dm(n?.id);return _.useEffect(()=>{if(!t&&!s&&c&&d!=null){if(!qw(c)||document.activeElement===c.target)return;const m=l.get(d);if(!m)return;const{activatorNode:g,node:f}=m;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const y of[g.current,f.current]){if(!y)continue;const b=gE(y);if(b){b.focus();break}}})}},[s,t,l,d,c]),null}function CT(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...s}),n):n}function xT(e){return _.useMemo(()=>({draggable:{...jd.draggable,...e?.draggable},droppable:{...jd.droppable,...e?.droppable},dragOverlay:{...jd.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function kT(e){let{activeNode:t,measure:n,initialRect:s,config:l=!0}=e;const c=_.useRef(!1),{x:d,y:m}=typeof l=="boolean"?{x:l,y:l}:l;fa(()=>{if(!d&&!m||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const y=n(f),b=Vw(y,s);if(d||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=Yw(f);w&&w.scrollBy({top:b.y,left:b.x})}},[t,d,m,s,n])}const l1=_.createContext({...wr,scaleX:1,scaleY:1});var aa;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(aa||(aa={}));const ET=_.memo(function(t){var n,s,l,c;let{id:d,accessibility:m,autoScroll:g=!0,children:f,sensors:y=mT,collisionDetection:b=ME,measuring:w,modifiers:x,...C}=t;const D=_.useReducer(ST,void 0,yT),[B,L]=D,[O,Y]=wE(),[U,Z]=_.useState(aa.Uninitialized),W=U===aa.Initialized,{draggable:{active:re,nodes:ee,translate:ye},droppable:{containers:Ee}}=B,ne=re!=null?ee.get(re):null,q=_.useRef({initial:null,translated:null}),Q=_.useMemo(()=>{var _t;return re!=null?{id:re,data:(_t=ne?.data)!=null?_t:gT,rect:q}:null},[re,ne]),K=_.useRef(null),[se,A]=_.useState(null),[R,P]=_.useState(null),ie=Lc(C,Object.values(C)),ge=yh("DndDescribedBy",d),M=_.useMemo(()=>Ee.getEnabled(),[Ee]),X=xT(w),{droppableRects:ue,measureDroppableContainers:be,measuringScheduled:ve}=nT(M,{dragging:W,dependencies:[ye.x,ye.y],config:X.droppable}),xe=tT(ee,re),Re=_.useMemo(()=>R?Rm(R):null,[R]),Me=ni(),ze=rT(xe,X.draggable.measure);kT({activeNode:re!=null?ee.get(re):null,config:Me.layoutShiftCompensation,initialRect:ze,measure:X.draggable.measure});const Pe=jS(xe,X.draggable.measure,ze),ce=jS(xe?xe.parentElement:null),_e=_.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ue,draggableNodes:ee,draggingNode:null,draggingNodeRect:null,droppableContainers:Ee,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Se=Ee.getNodeFor((n=_e.current.over)==null?void 0:n.id),Ae=pT({measure:X.dragOverlay.measure}),Ue=(s=Ae.nodeRef.current)!=null?s:xe,Be=W?(l=Ae.rect)!=null?l:Pe:null,ae=!!(Ae.nodeRef.current&&Ae.rect),Te=lT(ae?null:Pe),we=a1(Ue?En(Ue):null),Le=oT(W?Se??xe:null),Ve=hT(Le),Je=CT(x,{transform:{x:ye.x-Te.x,y:ye.y-Te.y,scaleX:1,scaleY:1},activatorEvent:R,active:Q,activeNodeRect:Pe,containerNodeRect:ce,draggingNodeRect:Be,over:_e.current.over,overlayNodeRect:Ae.rect,scrollableAncestors:Le,scrollableAncestorRects:Ve,windowRect:we}),ct=Re?Ql(Re,ye):null,wt=cT(Le),qi=PS(wt),Oi=PS(wt,[Pe]),ii=Ql(Je,qi),le=Be?LE(Be,Je):null,je=Q&&le?b({active:Q,collisionRect:le,droppableRects:ue,droppableContainers:M,pointerCoordinates:ct}):null,Ze=DE(je,"id"),[Ge,It]=_.useState(null),Ct=ae?Je:Ql(Je,Oi),xt=NE(Ct,(c=Ge?.rect)!=null?c:null,Pe),Ht=_.useRef(null),F=_.useCallback((_t,kt)=>{let{sensor:Pt,options:Rt}=kt;if(K.current==null)return;const Ut=ee.get(K.current);if(!Ut)return;const ri=_t.nativeEvent,hi=new Pt({active:K.current,activeNode:Ut,event:ri,options:Rt,context:_e,onAbort(qt){if(!ee.get(qt))return;const{onDragAbort:si}=ie.current,Ti={id:qt};si?.(Ti),O({type:"onDragAbort",event:Ti})},onPending(qt,Qi,si,Ti){if(!ee.get(qt))return;const{onDragPending:hn}=ie.current,ji={id:qt,constraint:Qi,initialCoordinates:si,offset:Ti};hn?.(ji),O({type:"onDragPending",event:ji})},onStart(qt){const Qi=K.current;if(Qi==null)return;const si=ee.get(Qi);if(!si)return;const{onDragStart:Ti}=ie.current,Ji={activatorEvent:ri,active:{id:Qi,data:si.data,rect:q}};pc.unstable_batchedUpdates(()=>{Ti?.(Ji),Z(aa.Initializing),L({type:Ni.DragStart,initialCoordinates:qt,active:Qi}),O({type:"onDragStart",event:Ji}),A(Ht.current),P(ri)})},onMove(qt){L({type:Ni.DragMove,coordinates:qt})},onEnd:Zt(Ni.DragEnd),onCancel:Zt(Ni.DragCancel)});Ht.current=hi;function Zt(qt){return async function(){const{active:si,collisions:Ti,over:Ji,scrollAdjustedTranslate:hn}=_e.current;let ji=null;if(si&&hn){const{cancelDrop:Dn}=ie.current;ji={activatorEvent:ri,active:si,collisions:Ti,delta:hn,over:Ji},qt===Ni.DragEnd&&typeof Dn=="function"&&await Promise.resolve(Dn(ji))&&(qt=Ni.DragCancel)}K.current=null,pc.unstable_batchedUpdates(()=>{L({type:qt}),Z(aa.Uninitialized),It(null),A(null),P(null),Ht.current=null;const Dn=qt===Ni.DragEnd?"onDragEnd":"onDragCancel";if(ji){const bi=ie.current[Dn];bi?.(ji),O({type:Dn,event:ji})}})}}},[ee]),We=_.useCallback((_t,kt)=>(Pt,Rt)=>{const Ut=Pt.nativeEvent,ri=ee.get(Rt);if(K.current!==null||!ri||Ut.dndKit||Ut.defaultPrevented)return;const hi={active:ri};_t(Pt,kt.options,hi)===!0&&(Ut.dndKit={capturedBy:kt.sensor},K.current=Rt,F(Pt,kt))},[ee,F]),gt=iT(y,We);uT(y),fa(()=>{Pe&&U===aa.Initializing&&Z(aa.Initialized)},[Pe,U]),_.useEffect(()=>{const{onDragMove:_t}=ie.current,{active:kt,activatorEvent:Pt,collisions:Rt,over:Ut}=_e.current;if(!kt||!Pt)return;const ri={active:kt,activatorEvent:Pt,collisions:Rt,delta:{x:ii.x,y:ii.y},over:Ut};pc.unstable_batchedUpdates(()=>{_t?.(ri),O({type:"onDragMove",event:ri})})},[ii.x,ii.y]),_.useEffect(()=>{const{active:_t,activatorEvent:kt,collisions:Pt,droppableContainers:Rt,scrollAdjustedTranslate:Ut}=_e.current;if(!_t||K.current==null||!kt||!Ut)return;const{onDragOver:ri}=ie.current,hi=Rt.get(Ze),Zt=hi&&hi.rect.current?{id:hi.id,rect:hi.rect.current,data:hi.data,disabled:hi.disabled}:null,qt={active:_t,activatorEvent:kt,collisions:Pt,delta:{x:Ut.x,y:Ut.y},over:Zt};pc.unstable_batchedUpdates(()=>{It(Zt),ri?.(qt),O({type:"onDragOver",event:qt})})},[Ze]),fa(()=>{_e.current={activatorEvent:R,active:Q,activeNode:xe,collisionRect:le,collisions:je,droppableRects:ue,draggableNodes:ee,draggingNode:Ue,draggingNodeRect:Be,droppableContainers:Ee,over:Ge,scrollableAncestors:Le,scrollAdjustedTranslate:ii},q.current={initial:Be,translated:le}},[Q,xe,je,le,ee,Ue,Be,ue,Ee,Ge,Le,ii]),QE({...Me,delta:ye,draggingRect:le,pointerCoordinates:ct,scrollableAncestors:Le,scrollableAncestorRects:Ve});const vi=_.useMemo(()=>({active:Q,activeNode:xe,activeNodeRect:Pe,activatorEvent:R,collisions:je,containerNodeRect:ce,dragOverlay:Ae,draggableNodes:ee,droppableContainers:Ee,droppableRects:ue,over:Ge,measureDroppableContainers:be,scrollableAncestors:Le,scrollableAncestorRects:Ve,measuringConfiguration:X,measuringScheduled:ve,windowRect:we}),[Q,xe,Pe,R,je,ce,Ae,ee,Ee,ue,Ge,be,Le,Ve,X,ve,we]),Tn=_.useMemo(()=>({activatorEvent:R,activators:gt,active:Q,activeNodeRect:Pe,ariaDescribedById:{draggable:ge},dispatch:L,draggableNodes:ee,over:Ge,measureDroppableContainers:be}),[R,gt,Q,Pe,L,ge,ee,Ge,be]);return Ai.createElement($w.Provider,{value:Y},Ai.createElement(wh.Provider,{value:Tn},Ai.createElement(bT.Provider,{value:vi},Ai.createElement(l1.Provider,{value:xt},f)),Ai.createElement(wT,{disabled:m?.restoreFocus===!1})),Ai.createElement(kE,{...m,hiddenTextDescribedById:ge}));function ni(){const _t=se?.autoScrollEnabled===!1,kt=typeof g=="object"?g.enabled===!1:g===!1,Pt=W&&!_t&&!kt;return typeof g=="object"?{...g,enabled:Pt}:{enabled:Pt}}}),TT=_.createContext(null),HS="button",DT="Draggable";function o1(e){let{id:t,data:n,disabled:s=!1,attributes:l}=e;const c=yh(DT),{activators:d,activatorEvent:m,active:g,activeNodeRect:f,ariaDescribedById:y,draggableNodes:b,over:w}=_.useContext(wh),{role:x=HS,roleDescription:C="draggable",tabIndex:D=0}=l??{},B=g?.id===t,L=_.useContext(B?l1:TT),[O,Y]=Gd(),[U,Z]=Gd(),W=dT(d,t),re=Lc(n);fa(()=>(b.set(t,{id:t,key:c,node:O,activatorNode:U,data:re}),()=>{const ye=b.get(t);ye&&ye.key===c&&b.delete(t)}),[b,t]);const ee=_.useMemo(()=>({role:x,tabIndex:D,"aria-disabled":s,"aria-pressed":B&&x===HS?!0:void 0,"aria-roledescription":C,"aria-describedby":y.draggable}),[s,x,D,B,C,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:f,attributes:ee,isDragging:B,listeners:s?void 0:W,node:O,over:w,setNodeRef:Y,setActivatorNodeRef:Z,transform:L}}const RT="Droppable",MT={timeout:25};function y_(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:l}=e;const c=yh(RT),{active:d,dispatch:m,over:g,measureDroppableContainers:f}=_.useContext(wh),y=_.useRef({disabled:n}),b=_.useRef(!1),w=_.useRef(null),x=_.useRef(null),{disabled:C,updateMeasurementsFor:D,timeout:B}={...MT,...l},L=Lc(D??s),O=_.useCallback(()=>{if(!b.current){b.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{f(Array.isArray(L.current)?L.current:[L.current]),x.current=null},B)},[B]),Y=Sh({callback:O,disabled:C||!d}),U=_.useCallback((ee,ye)=>{Y&&(ye&&(Y.unobserve(ye),b.current=!1),ee&&Y.observe(ee))},[Y]),[Z,W]=Gd(U),re=Lc(t);return _.useEffect(()=>{!Y||!Z.current||(Y.disconnect(),b.current=!1,Y.observe(Z.current))},[Z,Y]),_.useEffect(()=>(m({type:Ni.RegisterDroppable,element:{id:s,key:c,disabled:n,node:Z,rect:w,data:re}}),()=>m({type:Ni.UnregisterDroppable,key:c,id:s})),[s]),_.useEffect(()=>{n!==y.current.disabled&&(m({type:Ni.SetDroppableDisabled,id:s,key:c,disabled:n}),y.current.disabled=n)},[s,c,n,m]),{active:d,rect:w,isOver:g?.id===s,node:Z,over:g,setNodeRef:W}}const NT=128,AT=512,co=100,LT="too_many_detached_terminals",BT=64,OT=4096;function c1(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>NT)return null;const n=t.workspaces.map(jT);return n.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function u1(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const s=n.detachedTerminalIds;return Array.isArray(s)&&s.length>co}):!1}function jT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>AT)return null;const n=t.tabs.map(zT);if(n.some(l=>l===null))return null;const s=UT(t.detachedTerminalIds,co);return s===null?null:{id:t.id,title:t.title,defaultCwd:HT(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function zT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=PT(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function PT(e){if(!e||typeof e!="object")return null;let t=0;return Bm(e,1,()=>(t+=1,t<=OT))}function Bm(e,t,n){if(!e||typeof e!="object"||t>BT||!n())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const l=Bm(s.first,t+1,n),c=Bm(s.second,t+1,n);return!l||!c?null:{type:"split",direction:s.direction,ratio:IT(s.ratio),first:l,second:c}}function IT(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function HT(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function UT(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,s=[];for(const l of e)typeof l!="string"||!l||n.has(l)||(n.add(l),s.push(l));return s}const d1=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],KT="nterminal-focus",WT=/^[A-Za-z0-9_.:-]{1,128}$/;function FT(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(KT)!=="terminal"?null:Ch({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Ch(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!US(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!US(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function US(e){return typeof e=="string"&&WT.test(e)}const cr="__main__",h1="nterminal.notifications.completionEnabled",S_="nterminal.notifications.completionToastEnabled",w_="nterminal.notifications.completionToastDurationSeconds",C_="nterminal.notifications.completionToastPersistent",Om="nterminal:completion-toast-display",jm="nterminal:notification-focus",Dc=6.5,zm=2,Pm=60;function xh(){return typeof window<"u"&&"Notification"in window}function x_(){try{return window.localStorage.getItem(h1)==="true"}catch{return!1}}function KS(e){try{window.localStorage.setItem(h1,e?"true":"false")}catch{}}function el(){return{enabled:YT(),durationSeconds:VT(),persistUntilDismissed:XT()}}function qT(e){if(typeof window<"u"){try{window.localStorage.setItem(S_,e?"true":"false")}catch{}k_()}return el()}function WS(e){const t=p1(e);if(typeof window<"u"){try{window.localStorage.setItem(w_,String(t))}catch{}k_()}return el()}function $T(e){if(typeof window<"u"){try{window.localStorage.setItem(C_,e?"true":"false")}catch{}k_()}return el()}function f1(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===S_||n.key===w_||n.key===C_)&&e()};return window.addEventListener(Om,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Om,e),window.removeEventListener("storage",t)}}function Gc(){return xh()?window.Notification.permission:"unsupported"}function VT(){if(typeof window>"u")return Dc;try{const e=window.localStorage.getItem(w_);return e===null?Dc:p1(Number(e))}catch{return Dc}}function YT(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(S_)!=="false"}catch{return!0}}function XT(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(C_)==="true"}catch{return!1}}function p1(e){if(!Number.isFinite(e))return Dc;const t=Math.round(e*2)/2;return Math.max(zm,Math.min(Pm,t))}function k_(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Om))}async function m1(){if(!xh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Gc()}}function GT(e){if(!xh()||Gc()!=="granted"||!x_()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished",n=Ch({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const s=new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:n?{focus:n}:void 0,silent:!0});n&&(s.onclick=()=>{window.focus(),ZT(n)})}catch{}}function ZT(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(jm,{detail:e}))}const FS="nterminal.push.clientId",QT=2e4;function Xa(){try{const e=window.localStorage.getItem(FS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Im()}`;return window.localStorage.setItem(FS,t),t}catch{return`client-${Im()}`}}function JT(){return`page-${Im()}`}function E_(){const e=typeof window<"u"&&window.isSecureContext===!0,t=r2(),n=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone";return{supported:n,secure:e,displayMode:t,deviceKind:s2(),reason:e?t!=="standalone"?"not_standalone":n?"supported":"unsupported":"insecure"}}async function e2(e,t){const n=E_();if(!n.supported)throw new Error(n.reason);if((Gc()==="granted"?"granted":await m1())!=="granted")throw new Error("permission_denied");const l=Xa(),c=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(l),g=await c2(c,d.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:d2(d.publicKey)});await e.subscribePushNotifications({clientId:l,subscription:o2(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:a2(n.deviceKind),alwaysNotify:t})}async function t2(e){const t=Xa();let n;try{const l=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=l?.endpoint,await l?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function i2(e,t){await e.updatePushNotificationDevice({clientId:Xa(),alwaysNotify:t})}function n2(e){if(typeof window>"u")return()=>{};const t=Xa(),n=JT();let s=null,l=!1;const c=(f=!0)=>{const y=E_();e.updatePushPresence({clientId:t,pageId:n,visibilityState:l2(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:x_()&&Gc()==="granted",active:f}).catch(()=>{})},d=()=>{l||s!==null||(s=window.setInterval(()=>c(!0),QT))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),d(),()=>{l=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function r2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function s2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function a2(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function l2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function o2(e){const t=e.toJSON(),n=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!n||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:s}}}async function c2(e,t){const n=await e.pushManager.getSubscription();return n?u2(n,t)?n:(await n.unsubscribe(),null):null}function u2(e,t){const n=e.options.applicationServerKey;return n?h2(n)===t:!0}function d2(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(n),l=new ArrayBuffer(s.length),c=new Uint8Array(l);for(let d=0;d<s.length;d+=1)c[d]=s.charCodeAt(d);return l}function h2(e){const t=new Uint8Array(e);let n="";for(const s of t)n+=String.fromCharCode(s);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Im(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function f2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function p2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const qS="Local",m2=3e4,g2=2,_2=6,g1="nterminal.serverList.viewMode.v1";function v2(){try{return window.localStorage.getItem(g1)==="list"?"list":"stats"}catch{return"stats"}}function b2(e){try{window.localStorage.setItem(g1,e)}catch{}}function Fa(e,t){const n=[cr,...t.map(d=>d.id)],s=new Set(n),l=new Set,c=[];for(const d of e??[])!s.has(d)||l.has(d)||(l.add(d),c.push(d));for(const d of n)l.has(d)||c.push(d);return c}function y2(e,t){const n=new Map(e.map(s=>[s.id,s]));return Fa(t,e).flatMap(s=>{if(s===cr)return[{kind:"main",id:cr}];const l=n.get(s);return l?[{kind:"agent",id:s,agent:l}]:[]})}function $S(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function _1(e){return e===void 0?"":e==="error"?"offline":[`CPU ${ur(e.cpuPercent)} ${T_(e)}`,`MEM ${ur(e.memoryPercent)} ${_s(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${ur(e.diskPercent)} ${_s(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${ur(e.swapPercent)} ${_s(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function S2(e){if(!(e===void 0||e==="error"))return[`CPU ${ur(e.cpuPercent)} (${T_(e)})`,`RAM ${ur(e.memoryPercent)} (${_s(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${ur(e.diskPercent)} (${_s(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${ur(e.swapPercent)} (${_s(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function w2(e,t){const n=_1(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function ur(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function T_(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Hm(e.cpuPercent/100*t)}/${t} cores`}function _s(e,t){return!VS(e)||!VS(t)?"–/–":C2(e,t)}function C2(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Hm(e/s)}/${Hm(t/s)} ${n}`}function Hm(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function VS(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function bd(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function x2(e){return[{label:"CPU",percent:ur(e.cpuPercent),detail:T_(e),tone:bd(e.cpuPercent)},{label:"MEM",percent:ur(e.memoryPercent),detail:_s(e.memoryUsedBytes,e.memoryTotalBytes),tone:bd(e.memoryPercent)},{label:"DISK",percent:ur(e.diskPercent),detail:_s(e.diskUsedBytes,e.diskTotalBytes),tone:bd(e.diskPercent)},{label:"SWAP",percent:ur(e.swapPercent),detail:_s(e.swapUsedBytes,e.swapTotalBytes),tone:bd(e.swapPercent)}]}function k2({entry:e}){return e==="error"?p.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?p.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t}),p.jsx("span",{className:"server-list-stat-value",children:"–"})]}),p.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):p.jsx("span",{className:"server-list-stats server-list-stats-grid",title:S2(e),children:x2(e).map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t.label}),p.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),p.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function YS({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:l=0,onServerLabelsChange:c,renderServerChildren:d,compact:m=!1}){const[g,f]=_.useState([]),[y,b]=_.useState([cr]),[w,x]=_.useState(null),[C,D]=_.useState(null),[B,L]=_.useState(""),O=_.useRef(null),[Y,U]=_.useState(()=>v2()),[Z,W]=_.useState(null),[re,ee]=_.useState(null),[ye,Ee]=_.useState({}),ne=_.useRef({}),q=_.useRef(0),Q=_.useRef([]),K=_.useRef([cr]),se=_.useRef(null);_.useEffect(()=>{Q.current=g},[g]),_.useEffect(()=>{const ce=Fa(y,g);K.current=ce,$S(ce,y)||b(ce)},[g,y]),_.useEffect(()=>{let ce=!1;return e.listAgents().then(_e=>{ce||(f(_e.agents),b(Fa(_e.serverOrder,_e.agents)))}).catch(()=>{}),e.getMainInfo().then(_e=>{ce||x(_e.name)}).catch(()=>{}),()=>{ce=!0}},[e,l]),_.useEffect(()=>{C&&(O.current?.focus(),O.current?.select())},[C]),_.useEffect(()=>{let ce=!1;function _e(){const Ae=[{key:"__main__",load:()=>e.getMainStats()},...g.map(Be=>({key:Be.id,load:()=>e.getAgentStats(Be.id)}))],Ue=new Set(Ae.map(Be=>Be.key));for(const Be of Object.keys(ne.current))Ue.has(Be)||delete ne.current[Be];Ee(Be=>{const ae={};for(const Te of Ue)Te in Be&&(ae[Te]=Be[Te]);return ae});for(const Be of Ae)Be.load().then(ae=>{ce||(ne.current[Be.key]=0,Ee(Te=>Ue.has(Be.key)?{...Te,[Be.key]:ae}:Te))}).catch(ae=>{if(ce)return;if(ae instanceof or&&ae.status===401&&Be.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const Te=(ne.current[Be.key]??0)+1;ne.current[Be.key]=Te,Te>=g2&&Ee(we=>Ue.has(Be.key)?{...we,[Be.key]:"error"}:we)})}_e();const Se=window.setInterval(_e,m2);return()=>{ce=!0,window.clearInterval(Se)}},[e,g,s]);function A(ce){ce==="main"?(L(w??""),D({kind:"main"})):(L(ce.name),D({kind:"agent",id:ce.id}))}async function R(){if(!C)return;const ce=B.trim(),_e=C;if(D(null),_e.kind==="main"){const Se=ce||"";try{const Ae=await e.renameMain(Se);x(Ae.name)}catch{}}else{if(!ce)return;const Se=g.find(Ae=>Ae.id===_e.id)?.name;f(Ae=>Ae.map(Ue=>Ue.id===_e.id?{...Ue,name:ce}:Ue));try{await e.renameAgent(_e.id,ce)}catch{Se!==void 0&&f(Ae=>Ae.map(Ue=>Ue.id===_e.id?{...Ue,name:Se}:Ue))}}}function P(){D(null)}function ie(ce){U(ce),b2(ce)}function ge(ce,_e,Se){if(ce===_e)return;const Ae=Fa(K.current,Q.current),Ue=Ae.findIndex(Je=>Je===ce),Be=Ae.findIndex(Je=>Je===_e);if(Ue<0||Be<0)return;const ae=[...Ae],[Te]=ae.splice(Ue,1);if(!Te)return;const we=ae.findIndex(Je=>Je===_e);if(we<0)return;const Le=Se==="before"?we:we+1;if(ae.splice(Le,0,Te),$S(ae,Ae))return;const Ve=q.current+1;q.current=Ve,K.current=ae,b(ae),e.reorderAgents(ae).then(Je=>{if(q.current===Ve){Q.current=Je.agents;const ct=Fa(Je.serverOrder,Je.agents);K.current=ct,f(Je.agents),b(ct)}}).catch(async()=>{if(q.current===Ve)try{const Je=await e.listAgents();if(q.current===Ve){Q.current=Je.agents;const ct=Fa(Je.serverOrder,Je.agents);K.current=ct,f(Je.agents),b(ct)}}catch{q.current===Ve&&(K.current=Ae,b(Ae))}})}function M(ce,_e){const Se=Fa(K.current,Q.current),Ae=Se.findIndex(Be=>Be===ce),Ue=Se[Ae+_e];Ae<0||!Ue||ge(ce,Ue,_e<0?"before":"after")}function X(ce,_e){_e.pointerType==="mouse"&&_e.button!==0||(_e.stopPropagation(),se.current={sourceId:ce,pointerId:_e.pointerId,startX:_e.clientX,startY:_e.clientY,active:!1,targetId:null,placement:"after"},_e.currentTarget.setPointerCapture?.(_e.pointerId))}function ue(ce){const _e=se.current;if(!_e||_e.pointerId!==ce.pointerId)return;const Se=Math.hypot(ce.clientX-_e.startX,ce.clientY-_e.startY);if(!_e.active){if(Se<_2)return;_e.active=!0,W(_e.sourceId)}const Ue=document.elementFromPoint(ce.clientX,ce.clientY)?.closest("[data-server-id]"),Be=Ue?.dataset.serverId??null;if(!Ue||!Be||Be===_e.sourceId){_e.targetId=null,ee(null);return}const ae=Ue.getBoundingClientRect(),Te=ce.clientY<ae.top+ae.height/2?"before":"after";_e.targetId=Be,_e.placement=Te,ee({serverId:Be,placement:Te})}function be(ce){const _e=se.current;!_e||_e.pointerId!==ce.pointerId||(ce.stopPropagation(),ce.currentTarget.releasePointerCapture?.(ce.pointerId),se.current=null,W(null),ee(null),_e.active&&_e.targetId&&ge(_e.sourceId,_e.targetId,_e.placement))}function ve(ce){const _e=se.current;_e&&_e.pointerId===ce.pointerId&&ce.currentTarget.releasePointerCapture?.(ce.pointerId),se.current=null,W(null),ee(null)}const xe=w?.trim()||qS,Re=C?.kind==="main",Me=Y==="stats",ze=y2(g,y),Pe=ze.length>1;return _.useEffect(()=>{c?.([{agentId:null,label:xe},...g.map(ce=>({agentId:ce.id,label:ce.name}))])},[g,xe,c]),m?p.jsx("div",{className:"server-list server-list--compact",children:ze.map(ce=>{const _e=ce.kind==="main",Se=_e?xe:ce.agent.name,Ae=_e?cr:ce.id,Ue=ye[Ae],Be=_1(Ue);return p.jsxs("button",{type:"button",className:`server-list-chip${(_e?t===null:t===ce.id)?" server-list-chip--active":""}`,onClick:()=>n(_e?null:ce.id),"aria-label":Se,title:`${Se}${Be?` — ${Be}`:""}`,children:[p.jsx("span",{className:"server-list-chip-initial",children:p2(Se)}),p.jsx("span",{className:"server-list-chip-pip","data-status":f2(Ue)})]},ce.id)})}):p.jsxs("div",{className:`server-list server-list--${Y}`,children:[p.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="list",onClick:()=>ie("list"),title:"Show server names only",children:"List"}),p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="stats",onClick:()=>ie("stats"),title:"Show resource usage",children:"Stats"})]}),ze.map(ce=>{const _e=ce.kind==="main",Se=_e?xe:ce.agent.name,Ae=_e?cr:ce.id,Ue=_e?t===null:t===ce.id,Be=_e?Re:C?.kind==="agent"&&C.id===ce.id,ae=d?.({agentId:_e?null:ce.id,serverId:ce.id,label:Se,active:Ue}),Te=re?.serverId===ce.id&&Z!==ce.id?` server-list-section--drop-target server-list-section--drop-${re.placement}`:"";return p.jsxs("section",{className:`server-list-section${Te}`,"aria-label":`${Se} server`,children:[p.jsx("div",{className:["server-list-row",Z===ce.id?"server-list-row--dragging":"",re?.serverId===ce.id&&Z!==ce.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ce.id,children:Be?p.jsxs(p.Fragment,{children:[Pe?p.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,p.jsx("form",{className:"server-list-editor",onSubmit:we=>{we.preventDefault(),R()},children:p.jsx("input",{ref:O,"aria-label":_e?"Rename main server":`Rename ${Se}`,value:B,onChange:we=>L(we.target.value),onBlur:()=>{R()},onKeyDown:we=>{we.key==="Escape"&&(we.preventDefault(),P())},placeholder:_e?qS:void 0})})]}):p.jsxs(p.Fragment,{children:[Pe?p.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ce.id,title:"Drag to reorder","aria-label":`Reorder ${Se}`,"aria-grabbed":Z===ce.id,onPointerDown:we=>X(ce.id,we),onPointerMove:ue,onPointerUp:be,onPointerCancel:ve,onKeyDown:we=>{(we.key==="ArrowUp"||we.key==="ArrowDown")&&(we.preventDefault(),we.stopPropagation(),M(ce.id,we.key==="ArrowUp"?-1:1))},onClick:we=>we.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:`server-list-item${Ue?" server-list-item--active":""}`,onClick:()=>n(_e?null:ce.id),onDoubleClick:we=>{we.preventDefault(),A(_e?"main":{id:ce.id,name:Se})},title:w2(Se,ye[Ae]),children:[p.jsxs("span",{className:"server-list-item-header",children:[p.jsx("span",{className:"server-list-dot"}),p.jsx("span",{className:"server-list-name",title:_e?void 0:ce.agent.url,children:Se})]}),Me?p.jsx(k2,{entry:ye[Ae]}):null]})]})}),ae?p.jsx("div",{className:"server-list-children",children:ae}):null]},ce.id)})]})}function E2({api:e}){const[t,n]=_.useState([]),[s,l]=_.useState([]),[c,d]=_.useState(!1),[m,g]=_.useState(null),[f,y]=_.useState(""),[b,w]=_.useState("");async function x(){try{const[L,O,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(L.devices),l(O.networks),d(Y.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}_.useEffect(()=>{x()},[]);async function C(L){await e.revokeDevice(L),await x()}async function D(L){await e.removeNetwork(L),await x()}async function B(L){L.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:b.trim()}),y(""),w(""),await x()}catch(O){g(O instanceof Error?O.message:"Failed to add network")}}return p.jsxs(p.Fragment,{children:[m?p.jsx("p",{className:"form-error",children:m}):null,p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted devices"}),p.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?p.jsx("p",{className:"muted",children:"No trusted devices."}):p.jsx("ul",{className:"security-list",children:t.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsxs("span",{className:"security-item-label",children:[L.label,L.current?p.jsx("span",{className:"security-badge",children:"this device"}):null]}),p.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(L.id)},children:"revoke"})]},L.id))})]}),p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted networks"}),p.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?p.jsx("p",{className:"muted",children:"No trusted networks."}):p.jsx("ul",{className:"security-list",children:s.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?p.jsx("span",{className:"security-item-meta",children:L.label}):null]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(L.id)},children:"remove"})]},L.id))}),p.jsxs("form",{className:"security-add-form",onSubmit:B,children:[p.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:L=>y(L.currentTarget.value),required:!0}),p.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:L=>w(L.currentTarget.value)}),p.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Two-factor authentication"}),p.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),p.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const T2=1500,D_="nterminal.terminal.fontSize",R_="nterminal.terminal.fontFamily",Um="nterminal:terminal-font-size",Km="nterminal:terminal-font-family",Wm=11,Fm=20,Ga=14,eh=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],io="meslo";qm(io);async function Qp(e=Ga,t=io){if(typeof document>"u"||!document.fonts)return;const n=y1(t).webFontFamilies;if(n.length===0)return;const s=Promise.all(n.map(l=>document.fonts.load(`${e}px ${l}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(l=>{globalThis.setTimeout(l,T2)})])}function v1(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Ga;const n=Math.round(t);return Math.max(Wm,Math.min(Fm,n))}function b1(e){return eh.some(t=>t.id===e)?e:io}function qm(e){return y1(e).cssFamily}function y1(e){return eh.find(t=>t.id===e)??eh[0]}function $m(){if(typeof window>"u")return Ga;try{const e=window.localStorage.getItem(D_);return e?v1(e):Ga}catch{return Ga}}function Vm(){if(typeof window>"u")return io;try{return b1(window.localStorage.getItem(R_))}catch{return io}}function yd(e){const t=v1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(D_,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Um,{detail:t})),t}function D2(e){const t=b1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(R_,t)}catch{}return window.dispatchEvent(new CustomEvent(Km,{detail:t})),t}function S1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===D_&&e()};return window.addEventListener(Um,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Um,e),window.removeEventListener("storage",t)}}function w1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===R_&&e()};return window.addEventListener(Km,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Km,e),window.removeEventListener("storage",t)}}const M_="nterminal.terminal.showScrollProgress",Ym="nterminal:terminal-scroll-progress",N_="nterminal.terminal.tmuxScrollback.shell",A_="nterminal.terminal.tmuxScrollback.agent",L_="nterminal.terminal.tmuxScrollback.overrides",Oc="nterminal:terminal-tmux-scrollback",R2=200;function Xm(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(M_)!=="false"}catch{return!0}}function M2(e){if(typeof window<"u"){try{window.localStorage.setItem(M_,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Ym,{detail:e}))}return e}function C1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===M_&&e()};return window.addEventListener(Ym,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ym,e),window.removeEventListener("storage",t)}}function Gm(){return x1(N_,!0)}function N2(e){return k1(N_,e,Oc)}function Zm(){return x1(A_,!0)}function A2(e){return k1(A_,e,Oc)}function zd(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===N_||n.key===A_||n.key===L_)&&e()};return window.addEventListener(Oc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Oc,e),window.removeEventListener("storage",t)}}function Jp(e){const n=E1()[e];return typeof n=="boolean"?n:null}function L2(e,t){if(typeof window<"u"){try{const n=E1(),s=Object.entries(n).filter(([c])=>c!==e);s.push([e,t]);const l=s.slice(-R2);window.localStorage.setItem(L_,JSON.stringify(Object.fromEntries(l)))}catch{}window.dispatchEvent(new CustomEvent(Oc,{detail:{terminalId:e,enabled:t}}))}return t}function x1(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function k1(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function E1(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(L_);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,l]of Object.entries(t))typeof l=="boolean"&&(n[s]=l);return n}catch{return{}}}const B_="nterminal.shortcuts.workspace.v1",Qm="nterminal:workspace-shortcuts",jc=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],kh={"server.previous":ki("ArrowUp",{ctrlKey:!0}),"server.next":ki("ArrowDown",{ctrlKey:!0}),"tab.previous":ki("ArrowLeft",{ctrlKey:!0}),"tab.next":ki("ArrowRight",{ctrlKey:!0}),"tab.index":ki("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":ki("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":ki("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":ki("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":ki("KeyH",{altKey:!0}),"scrollback.toggle":ki("KeyS",{altKey:!0})},B2={"server.previous":ki("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":ki("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":ki("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":ki("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":ki("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":ki("Digit",{ctrlKey:!0,altKey:!0}),"split.right":ki("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":ki("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":ki("KeyH",{altKey:!0}),"scrollback.toggle":ki("KeyS",{altKey:!0})};function tl(){const e=R1(kh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(B_);if(!t)return e;const n=JSON.parse(t);for(const s of jc){const l=n[s.id];if(K2(l)){const c=M1(l,s);U2(c,B2[s.id])||(e[s.id]=c)}}}catch{return e}return e}function XS(){return JSON.stringify(tl())}function O2(e,t){const n=tl(),s=jc.find(l=>l.id===e);return s&&(n[e]=M1(t,s),O_(n)),n}function j2(e){const t=tl();return t[e]={...kh[e]},O_(t),t}function z2(){const e=R1(kh);return O_(e),e}function th(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===B_&&e()};return window.addEventListener(Qm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qm,e),window.removeEventListener("storage",t)}}function P2(e,t){const n=L1(e);return!n||F2(n)||t.indexed&&A1(e)===null||t.requiresPrimaryModifier&&!N1(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function T1(e){const t=tl();for(const n of jc){const s=t[n.id];if(!(!s||!W2(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const l=A1(e);if(l!==null)return{id:n.id,index:l};continue}if(L1(e)===s.code)return{id:n.id,index:null}}}return null}function ih(e){return D1(tl()[e])}function D1(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(q2(e.code)),t.join("+")}const I2=()=>ih("split.right"),H2=()=>ih("split.down");function ki(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function R1(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function U2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function O_(e){if(!(typeof window>"u")){try{window.localStorage.setItem(B_,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Qm))}}function M1(e,t){return t.requiresPrimaryModifier&&!N1(e)?{...kh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function N1(e){return e.ctrlKey||e.altKey||e.metaKey}function K2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function W2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function A1(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function L1(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function F2(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function q2(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const $2="Automatic update needs write access to the global npm install. Run this from a normal NTerminal runtime-user shell; only the npm install step uses sudo.";function V2(e="nterminal",t=new Date){return{reason:"permission",message:$2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function Y2(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const B1=3600*1e3,X2="local",Jm=new Set,ua=new Map;let pa={checking:!1,hasUpdates:!1,lastCheckedAt:null},j_=null,Rc=null,nh=0,sa=null;function G2(e){return Jm.add(e),()=>{Jm.delete(e)}}function GS(){return pa}function Z2(e){const t=iD();j_=e,z_(),eg(e,t);const n=()=>{if(document.visibilityState!=="visible"||!ma(e,t))return;const s=pa.lastCheckedAt;(s===null||Date.now()-s>=B1)&&eg(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),ma(e,t)&&tD()}}function Q2(e,t){ua.set(e,O1(t)),no({...pa,hasUpdates:P_(),lastCheckedAt:Date.now()})}function em(e){e===void 0?ua.clear():ua.set(e,!1),no({...pa,hasUpdates:P_()})}async function eg(e,t){if(!ma(e,t))return;if(sa&&sa.api===e&&sa.runId===t)return sa.promise;no({...pa,checking:!0});const n=J2(e,t).finally(()=>{sa?.promise===n&&(sa=null),ma(e,t)&&(no({...pa,checking:!1,lastCheckedAt:Date.now()}),eD(e,t))});return sa={api:e,runId:t,promise:n},n}async function J2(e,t){try{const n=await e.listAgents();if(!ma(e,t))return;const s=[{key:X2,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],l=new Map;if(await Promise.all(s.map(async c=>{try{const d=await c.check();l.set(c.key,O1(d))}catch{l.set(c.key,ua.get(c.key)??!1)}})),!ma(e,t))return;ua.clear();for(const[c,d]of l)ua.set(c,d);no({...pa,hasUpdates:P_()})}catch{}}function eD(e,t){ma(e,t)&&(z_(),Rc=window.setTimeout(()=>{Rc=null,ma(e,t)&&eg(e,t)},B1))}function tD(){nh+=1,z_(),j_=null,sa=null,ua.clear(),no({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function z_(){Rc!==null&&(window.clearTimeout(Rc),Rc=null)}function iD(){return nh+=1,nh}function ma(e,t){return j_===e&&nh===t}function O1(e){return e.updateAvailable===!0}function P_(){return Array.from(ua.values()).some(Boolean)}function no(e){pa=e;for(const t of Array.from(Jm))t()}const nD=e=>new Promise(t=>setTimeout(t,e));function rD({api:e,onAgentRemoved:t}){const[n,s]=_.useState([{key:"local",id:null,name:"Local (main)"}]),[l,c]=_.useState({}),[d,m]=_.useState(!1),[g,f]=_.useState(null),[y,b]=_.useState(!1),[w,x]=_.useState({});function C(R,P){c(ie=>({...ie,[R]:{...ie[R],...P}}))}function D(R,P){x(ie=>({...ie,[R]:{status:ie[R]?.status??null,busy:ie[R]?.busy??!1,error:ie[R]?.error??null,...P}}))}const B=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),L=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),O=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),Y=R=>R.id===null?e:eo(R.id);_.useEffect(()=>{let R=!1;return e.listAgents().then(P=>{if(R)return;const ie=[{key:"local",id:null,name:"Local (main)"},...P.agents.map(ge=>({key:ge.id,id:ge.id,name:ge.name}))];s(ie);for(const ge of ie)B(ge).then(M=>C(ge.key,{version:M,manualUpdate:M.manualUpdate??null})).catch(M=>C(ge.key,{error:M instanceof Error?M.message:"unreachable"})),K(ge)}).catch(()=>{}),()=>{R=!0}},[]);async function U(R){C(R.key,{busy:!0,status:"checking…",error:void 0});try{const P=await L(R);Q2(R.key,P),C(R.key,{latestVersion:P.latestVersion,updateAvailable:P.updateAvailable,status:ne(P),...P.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(P){C(R.key,{busy:!1,error:P instanceof Error?P.message:"check failed"})}}async function Z(){m(!0),await Promise.all(n.map(R=>U(R))),m(!1)}async function W(R,P){const ie=Date.now()+18e4;for(;Date.now()<ie;){await nD(3e3);try{const ge=await B(R);if(P&&ge.runningVersion!==P.runningVersion)return ge}catch{}}return null}async function re(R){let P=l[R.key]?.version;if(!P)try{P=await B(R),C(R.key,{version:P,manualUpdate:P.manualUpdate??null})}catch(M){return C(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}C(R.key,{busy:!0,status:"updating…",error:void 0});let ie;try{ie=await O(R)}catch(M){return C(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!ie.ok){const M=ie.manualUpdate??(Y2(ie.message)?V2():null);return M?(C(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(C(R.key,{busy:!1,status:void 0,error:ie.message}),"failed")}if(!ie.changed)return C(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),em(R.key),"unchanged";C(R.key,{status:"restarting…"});const ge=await W(R,P);return ge?(C(R.key,{busy:!1,version:ge,updateAvailable:!1,status:"updated",manualUpdate:ge.manualUpdate??null}),em(R.key),R.id===null&&(b(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(C(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function ee(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
15
- `)))){C(R.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ie=await e.uninstallAgent(R.id);s(ge=>ge.filter(M=>M.key!==R.key)),c(ge=>{const M={...ge};return delete M[R.key],M}),em(R.key),t?.(R.id),f(ie.message)}catch(ie){C(R.key,{busy:!1,status:void 0,error:ie instanceof Error?ie.message:"delete failed"})}}}async function ye(){m(!0),f(null);const R=n.filter(ue=>ue.id!==null),P=n.find(ue=>ue.id===null),ie=await Promise.all(R.map(ue=>re(ue))),ge=ie.filter(ue=>ue==="failed").length;let M=ie.filter(ue=>ue==="manual").length,X=null;if(P&&(X=await re(P),X==="manual"&&(M+=1),X==="updated")){ge>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),m(!1);return}ge>0&&M>0?f("Some servers failed and some need manual update. Check each marked row."):ge>0?f("Some secondary servers failed to update. Check their rows and retry."):M>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function Ee(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function ne(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function q(R){const P=R?.version;return P?`npm package v${P.runningVersion}`:""}async function Q(R,P){try{await aD(P),C(R,{copiedCommand:!0}),window.setTimeout(()=>C(R,{copiedCommand:!1}),1800)}catch(ie){C(R,{error:ie instanceof Error?ie.message:"copy failed"})}}async function K(R,P=!1){try{const ie=await Y(R).getCodeServerStatus(P?{checkLatest:!0}:void 0);D(R.key,{status:ie,error:null})}catch(ie){D(R.key,{error:ie instanceof Error?ie.message:"code-server status failed"})}}async function se(R,P){if(P==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const ie=Y(R);D(R.key,{busy:!0,error:null});try{if(P==="install"){const ge=await ie.installCodeServer();D(R.key,{status:ge.status})}else if(P==="update"){const ge=await ie.updateCodeServer();D(R.key,{status:ge.status})}else if(P==="stop")D(R.key,{status:await ie.stopCodeServer()});else{const ge=await ie.uninstallCodeServer();D(R.key,{status:ge.status})}}catch(ge){D(R.key,{error:ge instanceof Error?ge.message:"code-server action failed"})}finally{D(R.key,{busy:!1})}}const A=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return _.useEffect(()=>{const R=n.filter(ie=>w[ie.key]?.status?.job?.status==="running");if(R.length===0)return;const P=window.setInterval(()=>{for(const ie of R)K(ie)},1e3);return()=>window.clearInterval(P)},[A]),p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Servers"}),p.jsxs("div",{className:"update-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Z()},disabled:d,children:"Check for updates"}),p.jsx("button",{type:"button",onClick:()=>{ye()},disabled:d,children:"Update all"})]}),g?p.jsx("p",{className:"settings-status",children:g}):null,y?p.jsxs("div",{className:"server-reload-required",role:"status",children:[p.jsx("span",{children:"Main server update is ready."}),p.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,p.jsx("ul",{className:"security-list",children:n.map(R=>{const P=l[R.key],ie=q(P),ge=P?.manualUpdate??null,M=w[R.key]??{status:null,busy:!1,error:null},X=P?.version!==void 0&&P?.updateAvailable!==!1&&!P?.busy&&!d,ue=R.id!==null&&!P?.busy&&!d;return p.jsxs("li",{children:[p.jsxs("div",{className:"server-row-main",children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:R.name}),p.jsxs("span",{className:"security-item-meta",children:[ie?`${ie} — `:"",Ee(P)]})]}),ge?p.jsxs("div",{className:"server-manual-update",children:[p.jsx("span",{children:ge.message}),p.jsxs("div",{className:"server-manual-command",children:[p.jsx("code",{children:ge.command}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Q(R.key,ge.command)},children:P?.copiedCommand?"Copied":"Copy"})]})]}):null,p.jsx(sD,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{K(R,!0)},onInstall:()=>{se(R,"install")},onUpdate:()=>{se(R,"update")},onStop:()=>{se(R,"stop")},onUninstall:()=>{se(R,"uninstall")}})]}),p.jsxs("div",{className:"server-row-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{re(R)},disabled:!X,children:P?.busy?"…":"Update"}),R.id!==null?p.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{ee(R)},disabled:!ue,children:"Delete"}):null]})]},R.key)})})]})}function sD({status:e,busy:t,error:n,onCheck:s,onInstall:l,onUpdate:c,onStop:d,onUninstall:m}){const g=e?.job??null,f=g?.status==="running",y=e!==null,b=e?.installed===!0,w=(e?.instances.length??0)>0,x=e?.supported!==!1,C=e===null&&!n;return p.jsxs("div",{className:"server-code-addon",children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),p.jsxs("span",{className:"security-item-meta",children:[x?C?"checking...":b?`code-server v${e?.version??"unknown"}${w?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?p.jsx("p",{className:"settings-error",children:n}):null,g?p.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
16
- `):`${g.action} ${g.status}`}):null,p.jsxs("div",{className:"server-code-addon-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:t||f||!x,children:"Check"}),b?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||f||!x,children:e?.updateAvailable?"Update code-server":"Reinstall"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!w,children:"Stop"}),p.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||f,children:"Uninstall"})]}):p.jsx("button",{type:"button",className:"secondary-button",onClick:l,disabled:!y||C||t||f||!x,children:"Install code-server"})]})]})}async function aD(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Sd=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function lD({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:l}){const c=_.useMemo(()=>t??_h(),[t]),[d,m]=_.useState(()=>$m()),[g,f]=_.useState(()=>Vm()),[y,b]=_.useState(()=>Xm()),[w,x]=_.useState(()=>Gm()),[C,D]=_.useState(()=>Zm()),[B,L]=_.useState(()=>ha()),[O,Y]=_.useState(()=>tl()),[U,Z]=_.useState(null),[W,re]=_.useState(null),[ee,ye]=_.useState("appearance"),[Ee,ne]=_.useState(()=>x_()),[q,Q]=_.useState(()=>el()),[K,se]=_.useState(()=>Gc()),[A,R]=_.useState([]),[P,ie]=_.useState([]),[ge,M]=_.useState([]),[X,ue]=_.useState(5*1024*1024),[be,ve]=_.useState(!1),[xe,Re]=_.useState(null),[Me,ze]=_.useState(null),[Pe,ce]=_.useState(!1),[_e,Se]=_.useState(null),Ae=_.useRef(null),Ue=_.useRef(null),Be=_.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),ae=_.useMemo(()=>new Set(P),[P]),Te=!cD(P,ge),we=_.useMemo(()=>E_(),[]),Le=Me?.displayMode==="standalone"&&(Me.deviceKind==="mobile"||Me.deviceKind==="tablet");_.useEffect(()=>S1(()=>m($m())),[]),_.useEffect(()=>w1(()=>f(Vm())),[]),_.useEffect(()=>C1(()=>b(Xm())),[]),_.useEffect(()=>zd(()=>{x(Gm()),D(Zm())}),[]),_.useEffect(()=>f_(()=>L(ha())),[]),_.useEffect(()=>th(()=>Y(tl())),[]),_.useEffect(()=>f1(()=>Q(el())),[]),_.useEffect(()=>{if(!U)return;const F=jc.find(gt=>gt.id===U);if(!F)return;const We=gt=>{if(gt.preventDefault(),gt.stopPropagation(),gt.key==="Escape"){Z(null),re(null);return}const vi=P2(gt,F);if(!vi){re(oD(F));return}Y(O2(U,vi)),Z(null),re(null)};return window.addEventListener("keydown",We,!0),()=>window.removeEventListener("keydown",We,!0)},[U]),_.useEffect(()=>{let F=!1;return c.listNotificationAssets().then(We=>{F||ii(We)}).catch(We=>{F||Re($l(We))}),()=>{F=!0}},[c]),_.useEffect(()=>{let F=!1;return c.getPushNotificationStatus(Xa()).then(We=>{F||(ze(We.currentDevice),Se(null))}).catch(We=>{F||Se($l(We))}),()=>{F=!0}},[c]);function Ve(F){m(yd(Number(F)))}function Je(F){Q(WS(Number(F)))}function ct(F){ye(F);const We=Ue.current,gt=Be.current[F];if(!We||!gt)return;const vi=Math.max(0,ZS(gt,We)-12);typeof We.scrollTo=="function"?We.scrollTo({top:vi,behavior:"smooth"}):We.scrollTop=vi}function wt(){const F=Ue.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){ye(Sd[Sd.length-1].id);return}let We="appearance";const gt=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const vi of Sd){const Tn=Be.current[vi.id];Tn&&ZS(Tn,F)<=gt&&(We=vi.id)}ye(We)}function qi(F){Y(j2(F)),Z(null),re(null)}function Oi(){Y(z2()),Z(null),re(null)}function ii(F){const We=F.assets.filter(gt=>gt.enabled).map(gt=>gt.id);R(F.assets),ie(We),M(We),ue(F.maxFileBytes),Re(null)}async function le(){if(Ee){KS(!1),ne(!1);return}let F=K;F==="default"&&(F=await m1(),se(F)),F==="granted"&&(KS(!0),ne(!0))}async function je(){ce(!0),Se(null);try{if(Me)await t2(c),ze(null);else{await e2(c,!1);const F=await c.getPushNotificationStatus(Xa());ze(F.currentDevice)}}catch(F){Se(QS(F))}finally{ce(!1)}}async function Ze(F){ce(!0),Se(null);try{await i2(c,F);const We=await c.getPushNotificationStatus(Xa());ze(We.currentDevice)}catch(We){Se(QS(We))}finally{ce(!1)}}async function Ge(F){const We=F?.[0];if(We){if(We.size>X){Re(`File must be ${tm(X)} or smaller.`),Ct();return}if(We.type!=="video/mp4"&&We.type!=="video/webm"){Re("Upload an MP4 or WebM video."),Ct();return}ve(!0),Re(null);try{await c.uploadNotificationAsset(We),ii(await c.listNotificationAssets()),s?.()}catch(gt){Re($l(gt))}finally{ve(!1),Ct()}}}async function It(F){ve(!0),Re(null);try{await c.deleteNotificationAsset(F),ii(await c.listNotificationAssets()),s?.()}catch(We){Re($l(We))}finally{ve(!1)}}function Ct(){Ae.current&&(Ae.current.value="")}function xt(F,We){const gt=new Set(P);if(We?gt.add(F):gt.delete(F),gt.size===0){Re("Keep at least one toast video selected.");return}Re(null),ie(Array.from(gt))}async function Ht(){if(P.length===0){Re("Keep at least one toast video selected.");return}ve(!0),Re(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:P});ii(F),s?.()}catch(F){Re($l(F))}finally{ve(!1)}}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:p.jsxs("div",{className:"security-panel settings-panel",onClick:F=>F.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{children:"Settings"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),p.jsxs("div",{className:"settings-layout",children:[p.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Sd.map(F=>p.jsxs("button",{type:"button","data-active":ee===F.id?"true":"false","aria-current":ee===F.id?"true":void 0,onClick:()=>ct(F.id),children:[F.label,F.id==="servers"&&n?p.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),p.jsxs("div",{ref:Ue,className:"settings-content",onScroll:wt,children:[p.jsxs("section",{id:"settings-appearance",ref:F=>{Be.current.appearance=F},className:"security-section settings-section",children:[p.jsx("h3",{children:"Appearance"}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Theme"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),p.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Xd.map(F=>p.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":B===F.id,"data-active":B===F.id?"true":"false",onClick:()=>L(oE(F.id)),style:{"--settings-theme-bg":F.tokens.bg,"--settings-theme-bg-2":F.tokens.bg2,"--settings-theme-sidebar":F.tokens.bgSidebar,"--settings-theme-line":F.tokens.line,"--settings-theme-fg":F.tokens.fg,"--settings-theme-fg-2":F.tokens.fg2,"--settings-theme-accent":F.tokens.accent,"--settings-theme-xterm-bg":F.xterm.background,"--settings-theme-xterm-fg":F.xterm.foreground,"--settings-theme-xterm-selection":F.xterm.selectionBackground},children:[p.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[p.jsxs("span",{className:"settings-theme-preview-sidebar",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-main",children:[p.jsxs("span",{className:"settings-theme-preview-tabs",children:[p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-terminal",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})]})]}),p.jsxs("span",{className:"settings-theme-card-copy",children:[p.jsx("strong",{children:F.label}),p.jsx("small",{children:F.description})]})]},F.id))}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font size"}),p.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),p.jsx("input",{type:"range",min:Wm,max:Fm,step:1,value:d,"aria-label":"Terminal font size",onChange:F=>Ve(F.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row",children:[p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(yd(d-1)),children:"-"}),p.jsx("input",{type:"number",min:Wm,max:Fm,step:1,value:d,"aria-label":"Terminal font size value",onChange:F=>Ve(F.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(yd(d+1)),children:"+"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(yd(Ga)),children:"Reset"})]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font family"}),p.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:F=>f(D2(F.currentTarget.value)),children:eh.map(F=>p.jsx("option",{value:F.id,children:F.label},F.id))})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:y,onChange:F=>b(M2(F.currentTarget.checked))}),"Show scroll progress"]}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:w,onChange:F=>x(N2(F.currentTarget.checked))}),"Shell panes"]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:C,onChange:F=>D(A2(F.currentTarget.checked))}),"Codex/Claude panes"]})]}),p.jsxs("section",{id:"settings-shortcuts",ref:F=>{Be.current.shortcuts=F},className:"security-section settings-section",children:[p.jsxs("div",{className:"settings-section-heading",children:[p.jsx("h3",{children:"Shortcuts"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:Oi,children:"Reset all"})]}),p.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),W?p.jsx("p",{className:"settings-error",children:W}):null,p.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:jc.map(F=>{const We=U===F.id;return p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"settings-shortcut-label",children:F.label}),p.jsx("span",{className:"settings-shortcut-group",children:F.group})]}),p.jsxs("div",{className:"settings-shortcut-actions",children:[p.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":We?"true":"false",onClick:()=>{Z(F.id),re(null)},children:We?"Press keys…":D1(O[F.id])}),p.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>qi(F.id),children:"Reset"})]})]},F.id)})})]}),p.jsxs("section",{id:"settings-notifications",ref:F=>{Be.current.notifications=F},className:"security-section settings-section",children:[p.jsx("h3",{children:"Notifications"}),xh()?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:Ee&&K==="granted",onChange:()=>{le()},disabled:K==="denied"}),"System notification when page is hidden"]}),K==="denied"?p.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):p.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):p.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),p.jsxs("div",{className:"settings-subsection",children:[p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:!!Me,onChange:()=>{je()},disabled:Pe||!we.supported}),"Installed app push notifications"]}),p.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),we.supported?null:p.jsx("p",{className:"muted",children:tg(we.reason)}),Me?p.jsxs("p",{className:"muted",children:["Registered as ",Me.label,". Last active ",new Date(Me.lastActiveAt).toLocaleString(),"."]}):null,Le?p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:Me?.alwaysNotify===!0,onChange:F=>{Ze(F.currentTarget.checked)},disabled:Pe||!Me}),"Always notify this mobile device"]}):null,_e?p.jsx("p",{className:"form-error",children:_e}):null]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:q.enabled,onChange:F=>Q(qT(F.currentTarget.checked))}),"Show animated completion toast"]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Toast duration"}),p.jsx("span",{className:"settings-control-value",children:q.persistUntilDismissed?"Until closed":`${q.durationSeconds}s`}),p.jsx("input",{type:"range",min:zm,max:Pm,step:.5,value:q.durationSeconds,disabled:!q.enabled||q.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>Je(F.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[p.jsx("input",{type:"number",min:zm,max:Pm,step:.5,value:q.durationSeconds,disabled:!q.enabled||q.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>Je(F.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!q.enabled||q.persistUntilDismissed,onClick:()=>Q(WS(Dc)),children:"Reset"})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:q.persistUntilDismissed,disabled:!q.enabled,onChange:F=>Q($T(F.currentTarget.checked))}),"Keep toast until dismissed"]}),p.jsxs("div",{className:"settings-assets-header",children:[p.jsx("span",{children:"Toast videos"}),p.jsxs("span",{children:[tm(X)," max"]})]}),p.jsx("input",{ref:Ae,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{Ge(F.currentTarget.files)}}),p.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:be,onClick:()=>Ae.current?.click(),children:"Upload video"}),xe?p.jsx("p",{className:"settings-error",children:xe}):null,A.length>0?p.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:A.map(F=>p.jsxs("li",{"data-enabled":ae.has(F.id)?"true":"false",children:[p.jsxs("label",{className:"settings-asset-choice",children:[p.jsx("input",{type:"checkbox",checked:ae.has(F.id),disabled:be,"aria-label":`Use ${F.filename}`,onChange:We=>xt(F.id,We.currentTarget.checked)}),p.jsx("video",{src:F.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),p.jsxs("span",{className:"settings-asset-copy",children:[p.jsx("span",{children:F.filename}),p.jsx("small",{children:F.source==="built-in"?"Built-in":tm(F.size)})]})]}),F.source==="uploaded"?p.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:be,"aria-label":`Delete ${F.filename}`,onClick:()=>{It(F.id)},children:"x"}):null]},F.id))}):p.jsx("p",{className:"muted",children:"Built-in videos will be used."}),p.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:be||A.length===0||!Te,onClick:()=>{Ht()},children:"Save selected videos"})]}),p.jsx("div",{id:"settings-security",ref:F=>{Be.current.security=F},className:"settings-section-group",children:p.jsx(E2,{api:c})}),p.jsx("div",{id:"settings-servers",ref:F=>{Be.current.servers=F},className:"settings-section-group",children:p.jsx(rD,{api:c,...l?{onAgentRemoved:l}:{}})})]})]})]})})}function ZS(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function tm(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function $l(e){return e instanceof Error?e.message:"Request failed."}function tg(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":"This browser does not support installed app push notifications."}function QS(e){const t=$l(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?tg("not_standalone"):t==="insecure"?tg("insecure"):t}function oD(e){return e.indexed?"Press a shortcut ending in a number from 1 to 9.":e.requiresPrimaryModifier?"Use Ctrl, Alt, or Meta with another key.":"Press a complete shortcut."}function cD(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}class Ua extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function uD(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,s=e.files.map((l,c)=>({fieldName:`file${c}`,relativePath:l.relativePath,size:l.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[l,c]of e.files.entries())n.append(`file${l}`,c.file);return new Promise((l,c)=>{let d=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{d||(d=!0,m(),l(b))},f=b=>{d||(d=!0,m(),c(b))},y=()=>{t.abort(),f(new Ua(0,"Upload aborted."))};if(e.signal?.aborted){f(new Ua(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new Ua(t.status,"Invalid upload response."))}return}f(new Ua(t.status,dD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Ua(0,"Upload failed.")),t.onabort=()=>f(new Ua(0,"Upload aborted.")),t.ontimeout=()=>f(new Ua(0,"Upload timed out.")),t.send(n)})}function dD(e,t){try{const n=JSON.parse(e),s=typeof n.error=="string"?n.error:n.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const hD="modulepreload",fD=function(e){return"/"+e},JS={},I_=function(t,n,s){let l=Promise.resolve();if(n&&n.length>0){let g=function(f){return Promise.all(f.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");l=g(n.map(f=>{if(f=fD(f),f in JS)return;JS[f]=!0;const y=f.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":hD,y||(w.as="script"),w.crossOrigin="",w.href=f,m&&w.setAttribute("nonce",m),document.head.appendChild(w),y)return new Promise((x,C)=>{w.addEventListener("load",x),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return l.then(d=>{for(const m of d||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},pD=_.lazy(()=>I_(()=>import("./MarkdownPreview-CStdB1d5.js"),__vite__mapDeps([0,1])));function mD({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:l}){const[c,d]=_.useState(null),[m,g]=_.useState(""),[f,y]=_.useState({}),[b,w]=_.useState(()=>new Set),[x,C]=_.useState(null),[D,B]=_.useState({type:"empty"}),[L,O]=_.useState("idle"),[Y,U]=_.useState(null),Z=_.useRef(null),W=_.useRef(null),re=_.useRef(!1),ee=_.useRef(0),ye=_.useRef(null);ye.current===null&&t&&(ye.current=t);const Ee=ye.current,ne=s?_D(s):t?e0(t,n):null,q=c?[c.rootPath,m].filter(Boolean).join("/"):"",Q=x?.path??null;_.useEffect(()=>(re.current=!0,()=>{re.current=!1,ee.current+=1,ce()}),[]),_.useEffect(()=>{ye.current=t,W.current=null,K(ne)},[e]),_.useEffect(()=>{s&&ne!==W.current&&se(s,ne)},[s,ne]),_.useEffect(()=>{if(s||!Ee||t!==Ee)return;const ae=e0(Ee,n);ae!==W.current&&A(Ee,ae)},[Ee,t,n,s]);async function K(ae=ne){if(s){await se(s,ae);return}await A(t,ae)}async function se(ae,Te=ne){const we=_e();if(W.current=Te,ce(),d(null),g(""),y({}),w(new Set),C(null),B({type:"empty"}),U(null),!ae){O("idle");return}O("loading");try{const Le=await e.createFileRoot({path:ae});if(!Se(we))return;d({rootToken:Le.rootToken,rootPath:Le.rootPath});const Ve=await e.listFiles({rootToken:Le.rootToken,path:""});if(!Se(we))return;ie(Ve),O("idle")}catch(Le){Se(we)&&(U(hs(Le)),O("idle"))}}async function A(ae,Te=ne){const we=_e();if(W.current=Te,ce(),d(null),g(""),y({}),w(new Set),C(null),B({type:"empty"}),U(null),!ae){O("idle");return}O("loading");try{const Le=await e.createFileRoot({terminalId:ae});if(!Se(we))return;d({rootToken:Le.rootToken,rootPath:Le.rootPath});const Ve=await e.listFiles({rootToken:Le.rootToken,path:""});if(!Se(we))return;ie(Ve),O("idle")}catch(Le){if(await Ae(Le,we))return;Se(we)&&(U(hs(Le)),O("idle"))}}async function R(ae=m,Te=c){if(!Te)return;const we=_e();O("loading"),U(null);try{const Le=await e.listFiles({rootToken:Te.rootToken,path:ae});if(!Se(we))return;ie(Le),O("idle")}catch(Le){if(await Ae(Le,we))return;Se(we)&&(U(hs(Le)),O("idle"))}}async function P(){if(s){await se(s,ne);return}ye.current=t,await A(t,ne)}function ie(ae){y(Te=>({...Te,[ae.path]:vD(ae.entries)}))}async function ge(ae){if(!(!im(ae)||!c)){if(C(ae),U(null),ae.kind==="directory"){g(ae.path),Pe(),await X(ae);return}if(g(Ka(ae.path)),ae.editable){await be(ae);return}ae.previewKind!=="none"&&await xe(ae,ae.previewKind)}}async function M(ae){if(!(!im(ae)||!c)){if(C(ae),U(null),ae.kind==="directory"){g(ae.path),Pe(),await X(ae);return}if(g(Ka(ae.path)),ae.editable){await ve(ae);return}ae.previewKind!=="none"&&await xe(ae,ae.previewKind)}}async function X(ae){if(b.has(ae.path)){w(Te=>{const we=new Set(Te);return we.delete(ae.path),we});return}w(Te=>new Set(Te).add(ae.path)),await R(ae.path)}function ue(ae,Te){ae.key==="Enter"&&(ae.preventDefault(),M(Te))}async function be(ae){if(!c)return;const Te=_e();O("loading"),ce();try{const we=await e.readFile({rootToken:c.rootToken,path:ae.path});if(!Se(Te))return;B({type:"text-preview",file:ae,read:we}),O("idle")}catch(we){if(await Ae(we,Te))return;Se(Te)&&(U(hs(we)),O("idle"))}}async function ve(ae){if(!c)return;const Te=_e();O("loading");try{await l({rootToken:c.rootToken,path:ae.path,...t?{terminalId:t}:{}}),Se(Te)&&O("idle")}catch(we){if(await Ae(we,Te))return;Se(Te)&&(U(hs(we)),O("idle"))}}async function xe(ae,Te){if(!c)return;const we=_e();O("loading"),ce();try{const Le=await e.previewFile({rootToken:c.rootToken,path:ae.path});if(!Se(we))return;const Ve=URL.createObjectURL(Le);if(!Se(we)){URL.revokeObjectURL(Ve);return}Z.current=Ve,B({type:"preview",file:ae,previewKind:Te,url:Ve}),O("idle")}catch(Le){if(await Ae(Le,we))return;Se(we)&&(U(hs(Le)),O("idle"))}}async function Re(ae){if(!c)return;const Te=ae==="file"?"New file":"New folder",we=window.prompt(Te,""),Le=x?x.kind==="directory"?x.path:Ka(x.path):m,Ve=t0(we,Le);if(Ve){U(null);try{const Je=await e.createFileEntry({rootToken:c.rootToken,path:Ve,kind:ae});C(Je.entry),await R(Le)}catch(Je){if(await Ae(Je))return;U(hs(Je))}}}async function Me(){if(!c||!x)return;const ae=window.prompt("Move selected entry",x.path),Te=t0(ae,"");if(!Te||Te===x.path)return;const we=Ka(x.path),Le=Ka(Te);U(null);try{const Ve=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:x.path,destinationPath:Te});C(Ve.entry),g(Ve.entry.kind==="directory"?Ve.entry.path:Ka(Ve.entry.path)),Pe(),await R(we),Le!==we&&await R(Le)}catch(Ve){if(await Ae(Ve))return;U(hs(Ve))}}async function ze(){if(!c||!x)return;const ae=x.path,Te=Ka(ae);U(null);try{const we=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:x.path}),Le=we.descendantCount>0?` and ${we.descendantCount} nested item${we.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${we.path}${Le}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:x.path,previewToken:we.previewToken}),C(null),g(Te),w(Ve=>{const Je=new Set(Ve);for(const ct of Ve)(ct===ae||ct.startsWith(`${ae}/`))&&Je.delete(ct);return Je}),Pe(),await R(Te)}catch(we){if(await Ae(we))return;U(hs(we))}}function Pe(){ee.current+=1,ce(),B({type:"empty"})}function ce(){Z.current&&(URL.revokeObjectURL(Z.current),Z.current=null)}function _e(){return ee.current+=1,ee.current}function Se(ae){return re.current&&ae===ee.current}async function Ae(ae,Te){return bD(ae)?(Te!==void 0&&!Se(Te)||await K(ne),!0):!1}function Ue(ae,Te){const we=im(ae),Le=ae.kind==="directory"&&b.has(ae.path),Ve=f[ae.path]??[],Je={"--file-tree-depth":Te};return p.jsxs(Ai.Fragment,{children:[p.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ae.kind,"data-expanded":Le,"data-active":Q===ae.path,disabled:!we,style:Je,"aria-expanded":ae.kind==="directory"?Le:void 0,"aria-label":`${ae.kind==="directory"?"Open folder":"Open file"} ${ae.name}`,title:ae.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ge(ae)},onDoubleClick:()=>{M(ae)},onKeyDown:ct=>ue(ct,ae),children:[p.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ae.kind==="directory"?Le?"▾":"▸":""}),p.jsx("span",{className:"file-entry-name",children:ae.name}),p.jsx("small",{children:gD(ae)})]}),Le?p.jsx("div",{className:"file-tree-children",role:"group",children:Ve.map(ct=>Ue(ct,Te+1))}):null]},ae.path)}const Be=f[""]??[];return p.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[p.jsxs("header",{className:"file-explorer-header",children:[p.jsx("div",{className:"file-explorer-path",title:q,children:q||"No active pane"}),p.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[p.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{P()},children:"↻"}),p.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Re("file")},children:"+"}),p.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Re("directory")},children:"▣"})]})]}),Y?p.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,p.jsxs("div",{className:"file-explorer-layout",children:[p.jsx("div",{className:"file-tree","aria-label":q?`Files in ${q}`:"Files",children:Be.map(ae=>Ue(ae,0))}),p.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[p.jsxs("div",{className:"file-detail-header",children:[p.jsx("strong",{children:x?.name??"detail"}),p.jsxs("div",{className:"file-detail-actions",children:[p.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!x,onClick:()=>{Me()},children:"Move"}),p.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!x,onClick:()=>{ze()},children:"Delete"})]})]}),L==="loading"?p.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&L!=="loading"?p.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?p.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?p.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?p.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?p.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:p.jsx(pD,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?p.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function im(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function gD(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function e0(e,t){return`${e}\0${t??""}`}function _D(e){return`workspace\0${e}`}function vD(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Ka(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function t0(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function hs(e){return e instanceof Error?e.message:"Request failed"}function bD(e){return e instanceof or&&e.status===409&&e.message==="terminal_cwd_changed"}const yD=_.lazy(()=>I_(()=>import("./MarkdownPreview-CStdB1d5.js"),__vite__mapDeps([0,1])));function i0({api:e,editor:t,canClose:n,onClose:s}){const[l,c]=_.useState(t.read),[d,m]=_.useState(t.read.content),[g,f]=_.useState("idle"),[y,b]=_.useState(null),[w,x]=_.useState(!1),[C,D]=_.useState("edit"),B=_.useRef(t),L=_.useRef(t.read),O=_.useRef(t.read.content),Y=_.useRef(!1),U=_.useRef(!1),Z=_.useRef(0),W=d!==l.content&&g!=="saving"&&!w;_.useEffect(()=>(U.current=!0,()=>{U.current=!1,Z.current+=1}),[]),_.useEffect(()=>{Z.current+=1,Y.current=!1,B.current=t,L.current=t.read,O.current=t.read.content,c(t.read),m(t.read.content),f("idle"),b(null),x(!1),D("edit")},[t.id,t.read]),_.useEffect(()=>{B.current=t},[t]),_.useEffect(()=>{L.current=l},[l]),_.useEffect(()=>{O.current=d},[d]),_.useEffect(()=>{if(d===l.content||w)return;const ne=window.setInterval(()=>{!Y.current&&O.current!==L.current.content&&re()},1e3);return()=>window.clearInterval(ne)},[d===l.content,w,t.id]);async function re(){if(Y.current)return;const ne=O.current,q=L.current;if(ne===q.content)return;const Q=B.current,K=Z.current;Y.current=!0,f("saving"),b(null),x(!1);try{const se=await e.writeFile({rootToken:Q.rootToken,path:Q.path,content:ne,expectedVersion:q.version});if(!U.current||K!==Z.current)return;const A={...q,content:ne,version:se.version};L.current=A,c(A),f(O.current===ne?"saved":"idle")}catch(se){if(!U.current||K!==Z.current)return;if(se instanceof or&&se.status===409){x(!0),f("idle");return}b(SD(se)),f("idle")}finally{K===Z.current&&(Y.current=!1)}}const ee=g==="saving"?"saving":g==="saved"?"saved":l.language,ye=l.language==="markdown",Ee=ye&&C==="preview";return p.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[p.jsxs("header",{className:"editor-pane-header",children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("strong",{children:t.title}),p.jsx("span",{className:"terminal-pane-spacer"}),p.jsx("span",{className:"terminal-pane-state",children:ee}),p.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!W,onClick:()=>{re()},children:"Save"}),ye?p.jsx("button",{type:"button","aria-label":`${Ee?"Edit":"Preview"} ${t.title}`,onClick:()=>D(ne=>ne==="preview"?"edit":"preview"),children:Ee?"Edit":"Preview"}):null,n?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),y?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,w?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Ee?p.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:p.jsx(_.Suspense,{fallback:p.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:p.jsx(yD,{content:d})})}):p.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:ne=>{const q=ne.target.value;O.current=q,m(q),f("idle"),b(null),x(!1)}})]})}function SD(e){return e instanceof Error?e.message:"Request failed"}var wD=2,CD=1,xD=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),l=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=d.top+d.bottom,g=d.right+d.left,f=s-m,y=l-g-t;return{cols:Math.max(wD,Math.floor(y/e.css.cell.width)),rows:Math.max(CD,Math.floor(f/e.css.cell.height))}}};var j1=Object.defineProperty,kD=Object.getOwnPropertyDescriptor,ED=(e,t)=>{for(var n in t)j1(e,n,{get:t[n],enumerable:!0})},di=(e,t,n,s)=>{for(var l=s>1?void 0:s?kD(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(l=(s?d(t,n,l):d(l))||l);return s&&l&&j1(t,n,l),l},Oe=(e,t)=>(n,s)=>t(n,s,e),n0="Terminal input",ig={get:()=>n0,set:e=>n0=e},r0="Too much output to announce, navigate to rows manually to read",ng={get:()=>r0,set:e=>r0=e};function TD(e){return e.replace(/\r?\n/g,"\r")}function DD(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function RD(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function MD(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let l=e.clipboardData.getData("text/plain");z1(l,t,n,s)}}function z1(e,t,n,s){e=TD(e),e=DD(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function P1(e,t,n){let s=n.getBoundingClientRect(),l=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function s0(e,t,n,s,l){P1(e,t,n),l&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function la(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Eh(e,t=0,n=e.length){let s="";for(let l=t;l<n;++l){let c=e[l];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var ND=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=l;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,s;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[s++]=(d-55296)*1024+m-56320+65536:(t[s++]=d,t[s++]=m);continue}d!==65279&&(t[s++]=d)}return s}},AD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l,c,d,m,g=0,f=0;if(this.interim[0]){let w=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,D;for(;(D=this.interim[++C]&63)&&C<4;)x<<=6,x|=D;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=B-C;for(;f<L;){if(f>=n)return 0;if(D=e[f++],(D&192)!==128){f--,w=!0;break}else this.interim[C++]=D,x<<=6,x|=D&63}w||(B===2?x<128?f--:t[s++]=x:B===3?x<2048||x>=55296&&x<=57343||x===65279||(t[s++]=x):x<65536||x>1114111||(t[s++]=x)),this.interim.fill(0)}let y=n-4,b=f;for(;b<n;){for(;b<y&&!((l=e[b])&128)&&!((c=e[b+1])&128)&&!((d=e[b+2])&128)&&!((m=e[b+3])&128);)t[s++]=l,t[s++]=c,t[s++]=d,t[s++]=m,b+=4;if(l=e[b++],l<128)t[s++]=l;else if((l&224)===192){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(l&31)<<6|c&63,g<128){b--;continue}t[s++]=g}else if((l&240)===224){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(g=(l&15)<<12|(c&63)<<6|d&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((l&248)===240){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=d,s;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(l&7)<<18|(c&63)<<12|(d&63)<<6|m&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},I1="",ca=" ",Zc=class H1{constructor(){this.fg=0,this.bg=0,this.extended=new rh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new H1;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rh=class U1{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new U1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dr=class K1 extends Zc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rh,this.combinedData=""}static fromCharData(t){let n=new K1;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?la(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let l=t[1].charCodeAt(1);56320<=l&&l<=57343?this.content=(s-55296)*1024+l-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},a0="di$target",rg="di$dependencies",nm=new Map;function LD(e){return e[rg]||[]}function Fi(e){if(nm.has(e))return nm.get(e);let t=function(n,s,l){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");BD(t,n,l)};return t._id=e,nm.set(e,t),t}function BD(e,t,n){t[a0]===t?t[rg].push({id:e,index:n}):(t[rg]=[{id:e,index:n}],t[a0]=t)}var un=Fi("BufferService"),W1=Fi("CoreMouseService"),sl=Fi("CoreService"),OD=Fi("CharsetService"),H_=Fi("InstantiationService"),F1=Fi("LogService"),dn=Fi("OptionsService"),q1=Fi("OscLinkService"),jD=Fi("UnicodeService"),Qc=Fi("DecorationService"),sg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],l=this._optionsService.rawOptions.linkHandler,c=new dr,d=n.getTrimmedLength(),m=-1,g=-1,f=!1;for(let y=0;y<d;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else f=c.extended.urlId!==m;else g!==-1&&(f=!0);if(f||g!==-1&&y===d-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:y+(!f&&y===d-1?1:0),y:e}},x=!1;if(!l?.allowNonHttpProtocols)try{let C=new URL(b);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||s.push({text:b,range:w,activate:(C,D)=>l?l.activate(C,D,w):zD(C,D),hover:(C,D)=>l?.hover?.(C,D,w),leave:(C,D)=>l?.leave?.(C,D,w)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(s)}};sg=di([Oe(0,un),Oe(1,dn),Oe(2,q1)],sg);function zD(e,t){if(confirm(`Do you want to navigate to ${t}?
17
-
18
- WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Th=Fi("CharSizeService"),vs=Fi("CoreBrowserService"),U_=Fi("MouseService"),bs=Fi("RenderService"),PD=Fi("SelectionService"),$1=Fi("CharacterJoinerService"),uo=Fi("ThemeService"),V1=Fi("LinkProviderService"),ID=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?l0.isErrorNoTelemetry(e)?new l0(e.message+`
19
-
20
- `+e.stack):new Error(e.message+`
21
-
22
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},HD=new ID;function Pd(e){UD(e)||HD.onUnexpectedError(e)}var ag="Canceled";function UD(e){return e instanceof KD?!0:e instanceof Error&&e.name===ag&&e.message===ag}var KD=class extends Error{constructor(){super(ag),this.name=this.message}};function WD(e){return new Error(`Illegal argument: ${e}`)}var l0=class lg extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof lg)return t;let n=new lg;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},og=class Y1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Y1.prototype)}};function Un(e,t=0){return e[e.length-(1+t)]}var FD;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function s(c){return c>0}e.isGreaterThan=s;function l(c){return c===0}e.isNeitherLessOrGreaterThan=l,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(FD||={});function qD(e,t){let n=this,s=!1,l;return function(){return s||(s=!0,t||(l=e.apply(n,arguments))),l}}var X1;(e=>{function t(U){return U&&typeof U=="object"&&typeof U[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*l(U){yield U}e.single=l;function c(U){return t(U)?U:l(U)}e.wrap=c;function d(U){return U||n}e.from=d;function*m(U){for(let Z=U.length-1;Z>=0;Z--)yield U[Z]}e.reverse=m;function g(U){return!U||U[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(U){return U[Symbol.iterator]().next().value}e.first=f;function y(U,Z){let W=0;for(let re of U)if(Z(re,W++))return!0;return!1}e.some=y;function b(U,Z){for(let W of U)if(Z(W))return W}e.find=b;function*w(U,Z){for(let W of U)Z(W)&&(yield W)}e.filter=w;function*x(U,Z){let W=0;for(let re of U)yield Z(re,W++)}e.map=x;function*C(U,Z){let W=0;for(let re of U)yield*Z(re,W++)}e.flatMap=C;function*D(...U){for(let Z of U)yield*Z}e.concat=D;function B(U,Z,W){let re=W;for(let ee of U)re=Z(re,ee);return re}e.reduce=B;function*L(U,Z,W=U.length){for(Z<0&&(Z+=U.length),W<0?W+=U.length:W>U.length&&(W=U.length);Z<W;Z++)yield U[Z]}e.slice=L;function O(U,Z=Number.POSITIVE_INFINITY){let W=[];if(Z===0)return[W,U];let re=U[Symbol.iterator]();for(let ee=0;ee<Z;ee++){let ye=re.next();if(ye.done)return[W,e.empty()];W.push(ye.value)}return[W,{[Symbol.iterator](){return re}}]}e.consume=O;async function Y(U){let Z=[];for await(let W of U)Z.push(W);return Promise.resolve(Z)}e.asyncToArray=Y})(X1||={});function il(e){if(X1.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function $D(...e){return Gt(()=>il(e))}function Gt(e){return{dispose:qD(()=>{e()})}}var G1=class Z1{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{il(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Z1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};G1.DISABLE_DISPOSED_WARNING=!1;var da=G1,ot=class{constructor(){this._store=new da,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ot.None=Object.freeze({dispose(){}});var ro=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},gs=typeof window=="object"?window:globalThis,cg=class ug{constructor(t){this.element=t,this.next=ug.Undefined,this.prev=ug.Undefined}};cg.Undefined=new cg(void 0);var ei=cg,o0=class{constructor(){this._first=ei.Undefined,this._last=ei.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ei.Undefined}clear(){let e=this._first;for(;e!==ei.Undefined;){let t=e.next;e.prev=ei.Undefined,e.next=ei.Undefined,e=t}this._first=ei.Undefined,this._last=ei.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ei(e);if(this._first===ei.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ei.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ei.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ei.Undefined&&e.next!==ei.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ei.Undefined&&e.next===ei.Undefined?(this._first=ei.Undefined,this._last=ei.Undefined):e.next===ei.Undefined?(this._last=this._last.prev,this._last.next=ei.Undefined):e.prev===ei.Undefined&&(this._first=this._first.next,this._first.prev=ei.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ei.Undefined;)yield e.element,e=e.next}},VD=globalThis.performance&&typeof globalThis.performance.now=="function",YD=class Q1{static create(t){return new Q1(t)}constructor(t){this._now=VD&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Zi;(e=>{e.None=()=>ot.None;function t(q,Q){return b(q,()=>{},0,void 0,!0,void 0,Q)}e.defer=t;function n(q){return(Q,K=null,se)=>{let A=!1,R;return R=q(P=>{if(!A)return R?R.dispose():A=!0,Q.call(K,P)},null,se),A&&R.dispose(),R}}e.once=n;function s(q,Q,K){return f((se,A=null,R)=>q(P=>se.call(A,Q(P)),null,R),K)}e.map=s;function l(q,Q,K){return f((se,A=null,R)=>q(P=>{Q(P),se.call(A,P)},null,R),K)}e.forEach=l;function c(q,Q,K){return f((se,A=null,R)=>q(P=>Q(P)&&se.call(A,P),null,R),K)}e.filter=c;function d(q){return q}e.signal=d;function m(...q){return(Q,K=null,se)=>{let A=$D(...q.map(R=>R(P=>Q.call(K,P))));return y(A,se)}}e.any=m;function g(q,Q,K,se){let A=K;return s(q,R=>(A=Q(A,R),A),se)}e.reduce=g;function f(q,Q){let K,se={onWillAddFirstListener(){K=q(A.fire,A)},onDidRemoveLastListener(){K?.dispose()}},A=new ke(se);return Q?.add(A),A.event}function y(q,Q){return Q instanceof Array?Q.push(q):Q&&Q.add(q),q}function b(q,Q,K=100,se=!1,A=!1,R,P){let ie,ge,M,X=0,ue,be={leakWarningThreshold:R,onWillAddFirstListener(){ie=q(xe=>{X++,ge=Q(ge,xe),se&&!M&&(ve.fire(ge),ge=void 0),ue=()=>{let Re=ge;ge=void 0,M=void 0,(!se||X>1)&&ve.fire(Re),X=0},typeof K=="number"?(clearTimeout(M),M=setTimeout(ue,K)):M===void 0&&(M=0,queueMicrotask(ue))})},onWillRemoveListener(){A&&X>0&&ue?.()},onDidRemoveLastListener(){ue=void 0,ie.dispose()}},ve=new ke(be);return P?.add(ve),ve.event}e.debounce=b;function w(q,Q=0,K){return e.debounce(q,(se,A)=>se?(se.push(A),se):[A],Q,void 0,!0,void 0,K)}e.accumulate=w;function x(q,Q=(se,A)=>se===A,K){let se=!0,A;return c(q,R=>{let P=se||!Q(R,A);return se=!1,A=R,P},K)}e.latch=x;function C(q,Q,K){return[e.filter(q,Q,K),e.filter(q,se=>!Q(se),K)]}e.split=C;function D(q,Q=!1,K=[],se){let A=K.slice(),R=q(ge=>{A?A.push(ge):ie.fire(ge)});se&&se.add(R);let P=()=>{A?.forEach(ge=>ie.fire(ge)),A=null},ie=new ke({onWillAddFirstListener(){R||(R=q(ge=>ie.fire(ge)),se&&se.add(R))},onDidAddFirstListener(){A&&(Q?setTimeout(P):P())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return se&&se.add(ie),ie.event}e.buffer=D;function B(q,Q){return(K,se,A)=>{let R=Q(new O);return q(function(P){let ie=R.evaluate(P);ie!==L&&K.call(se,ie)},void 0,A)}}e.chain=B;let L=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(Q){return this.steps.push(Q),this}forEach(Q){return this.steps.push(K=>(Q(K),K)),this}filter(Q){return this.steps.push(K=>Q(K)?K:L),this}reduce(Q,K){let se=K;return this.steps.push(A=>(se=Q(se,A),se)),this}latch(Q=(K,se)=>K===se){let K=!0,se;return this.steps.push(A=>{let R=K||!Q(A,se);return K=!1,se=A,R?A:L}),this}evaluate(Q){for(let K of this.steps)if(Q=K(Q),Q===L)break;return Q}}function Y(q,Q,K=se=>se){let se=(...ie)=>P.fire(K(...ie)),A=()=>q.on(Q,se),R=()=>q.removeListener(Q,se),P=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return P.event}e.fromNodeEventEmitter=Y;function U(q,Q,K=se=>se){let se=(...ie)=>P.fire(K(...ie)),A=()=>q.addEventListener(Q,se),R=()=>q.removeEventListener(Q,se),P=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return P.event}e.fromDOMEventEmitter=U;function Z(q){return new Promise(Q=>n(q)(Q))}e.toPromise=Z;function W(q){let Q=new ke;return q.then(K=>{Q.fire(K)},()=>{Q.fire(void 0)}).finally(()=>{Q.dispose()}),Q.event}e.fromPromise=W;function re(q,Q){return q(K=>Q.fire(K))}e.forward=re;function ee(q,Q,K){return Q(K),q(se=>Q(se))}e.runAndSubscribe=ee;class ye{constructor(Q,K){this._observable=Q,this._counter=0,this._hasChanged=!1;let se={onWillAddFirstListener:()=>{Q.addObserver(this)},onDidRemoveLastListener:()=>{Q.removeObserver(this)}};this.emitter=new ke(se),K&&K.add(this.emitter)}beginUpdate(Q){this._counter++}handlePossibleChange(Q){}handleChange(Q,K){this._hasChanged=!0}endUpdate(Q){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(q,Q){return new ye(q,Q).emitter.event}e.fromObservable=Ee;function ne(q){return(Q,K,se)=>{let A=0,R=!1,P={beginUpdate(){A++},endUpdate(){A--,A===0&&(q.reportChanges(),R&&(R=!1,Q.call(K)))},handlePossibleChange(){},handleChange(){R=!0}};q.addObserver(P),q.reportChanges();let ie={dispose(){q.removeObserver(P)}};return se instanceof da?se.add(ie):Array.isArray(se)&&se.push(ie),ie}}e.fromObservableLight=ne})(Zi||={});var dg=class hg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${hg._idPool++}`,hg.all.add(this)}start(t){this._stopWatch=new YD,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};dg.all=new Set,dg._idPool=0;var XD=dg,GD=-1,J1=class eC{constructor(t,n,s=(eC._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let l=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,l+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,d]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(m),console.warn(c);let g=new JD(m,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,l]of this._stacks)(!t||n<l)&&(t=[s,l],n=l);return t}};J1._idPool=1;var ZD=J1,QD=class tC{constructor(t){this.value=t}static create(){let t=new Error;return new tC(t.stack??"")}print(){console.warn(this.value.split(`
23
- `).slice(2).join(`
24
- `))}},JD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},eR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},tR=0,rm=class{constructor(e){this.value=e,this.id=tR++}},iR=2,nR,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new ZD(e?.onListenerError??Pd,this._options?.leakWarningThreshold??GD):void 0,this._perfMon=this._options?._profName?new XD(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new eR(`${d}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||Pd)(g),ot.None}if(this._disposed)return ot.None;t&&(e=e.bind(t));let s=new rm(e),l;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=QD.create(),l=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof rm?(this._deliveryQueue??=new rR,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Gt(()=>{l?.(),this._removeListener(s)});return n instanceof da?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*iR<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:s&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Pd;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof rm)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},rR=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},fg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};fg.INSTANCE=new fg;var K_=fg;function sR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}K_.INSTANCE.onDidChangeZoomLevel;function aR(e){return K_.INSTANCE.getZoomFactor(e)}K_.INSTANCE.onDidChangeFullscreen;var ho=typeof navigator=="object"?navigator.userAgent:"",pg=ho.indexOf("Firefox")>=0,lR=ho.indexOf("AppleWebKit")>=0,W_=ho.indexOf("Chrome")>=0,oR=!W_&&ho.indexOf("Safari")>=0;ho.indexOf("Electron/")>=0;ho.indexOf("Android")>=0;var sm=!1;if(typeof gs.matchMedia=="function"){let e=gs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=gs.matchMedia("(display-mode: fullscreen)");sm=e.matches,sR(gs,e,({matches:n})=>{sm&&t.matches||(sm=n)})}var Yl="en",mg=!1,gg=!1,Id=!1,iC=!1,wd,Hd=Yl,c0=Yl,cR,ps,Za=globalThis,Fn;typeof Za.vscode<"u"&&typeof Za.vscode.process<"u"?Fn=Za.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Fn=process);var uR=typeof Fn?.versions?.electron=="string",dR=uR&&Fn?.type==="renderer";if(typeof Fn=="object"){mg=Fn.platform==="win32",gg=Fn.platform==="darwin",Id=Fn.platform==="linux",Id&&Fn.env.SNAP&&Fn.env.SNAP_REVISION,Fn.env.CI||Fn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,wd=Yl,Hd=Yl;let e=Fn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);wd=t.userLocale,c0=t.osLocale,Hd=t.resolvedLanguage||Yl,cR=t.languagePack?.translationsConfigFile}catch{}iC=!0}else typeof navigator=="object"&&!dR?(ps=navigator.userAgent,mg=ps.indexOf("Windows")>=0,gg=ps.indexOf("Macintosh")>=0,(ps.indexOf("Macintosh")>=0||ps.indexOf("iPad")>=0||ps.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Id=ps.indexOf("Linux")>=0,ps?.indexOf("Mobi")>=0,Hd=globalThis._VSCODE_NLS_LANGUAGE||Yl,wd=navigator.language.toLowerCase(),c0=wd):console.error("Unable to resolve platform.");var nC=mg,Pr=gg,hR=Id,u0=iC,Ir=ps,ea=Hd,fR;(e=>{function t(){return ea}e.value=t;function n(){return ea.length===2?ea==="en":ea.length>=3?ea[0]==="e"&&ea[1]==="n"&&ea[2]==="-":!1}e.isDefaultVariant=n;function s(){return ea==="en"}e.isDefault=s})(fR||={});var pR=typeof Za.postMessage=="function"&&!Za.importScripts;(()=>{if(pR){let e=[];Za.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,l=e.length;s<l;s++){let c=e[s];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),Za.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var mR=!!(Ir&&Ir.indexOf("Chrome")>=0);Ir&&Ir.indexOf("Firefox")>=0;!mR&&Ir&&Ir.indexOf("Safari")>=0;Ir&&Ir.indexOf("Edg/")>=0;Ir&&Ir.indexOf("Android")>=0;var Kl=typeof navigator=="object"?navigator:{};u0||document.queryCommandSupported&&document.queryCommandSupported("copy")||Kl&&Kl.clipboard&&Kl.clipboard.writeText,u0||Kl&&Kl.clipboard&&Kl.clipboard.readText;var F_=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},am=new F_,d0=new F_,h0=new F_,gR=new Array(230),rC;(e=>{function t(m){return am.keyCodeToStr(m)}e.toString=t;function n(m){return am.strToKeyCode(m)}e.fromString=n;function s(m){return d0.keyCodeToStr(m)}e.toUserSettingsUS=s;function l(m){return h0.keyCodeToStr(m)}e.toUserSettingsGeneral=l;function c(m){return d0.strToKeyCode(m)||h0.strToKeyCode(m)}e.fromUserSettings=c;function d(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return am.keyCodeToStr(m)}e.toElectronAccelerator=d})(rC||={});var _R=class sC{constructor(t,n,s,l,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=l,this.keyCode=c}equals(t){return t instanceof sC&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",l=this.metaKey?"1":"0";return`K${t}${n}${s}${l}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new vR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},vR=class{constructor(e){if(e.length===0)throw WD("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function bR(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return rC.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(pg)switch(t){case 59:return 85;case 60:if(hR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Pr)return 57;break}else if(lR&&(Pr&&t===93||!Pr&&t===92))return 57;return gR[t]||0}var yR=Pr?256:2048,SR=512,wR=1024,CR=Pr?2048:256,f0=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=bR(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=yR),this.altKey&&(t|=SR),this.shiftKey&&(t|=wR),this.metaKey&&(t|=CR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new _R(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},p0=new WeakMap;function xR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var kR=class{static getSameOriginWindowChain(e){let t=p0.get(e);if(!t){t=[],p0.set(e,t);let n=e,s;do s=xR(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,l=this.getSameOriginWindowChain(e);for(let c of l){let d=c.window.deref();if(n+=d?.scrollY??0,s+=d?.scrollX??0,d===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,s+=m.left}return{top:n,left:s}}},Cd=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=kR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},m0=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(W_){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,d=e.view?.devicePixelRatio||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?pg&&!Pr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")oR&&nC?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?pg&&!Pr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},aC=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),ER;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof TR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Zi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:aC})})(ER||={});var TR=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?aC:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},q_=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new og("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new og("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},DR=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new og("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Gt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},RR;(e=>{async function t(s){let l,c=await Promise.all(s.map(d=>d.then(m=>m,m=>{l||(l=m)})));if(typeof l<"u")throw l;return c}e.settled=t;function n(s){return new Promise(async(l,c)=>{try{await s(l,c)}catch(d){c(d)}})}e.withAsyncBody=n})(RR||={});var g0=class sr{static fromArray(t){return new sr(n=>{n.emitMany(t)})}static fromPromise(t){return new sr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new sr(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new sr(async n=>{await Promise.all(t.map(async s=>{for await(let l of s)n.emitOne(l)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:l=>this.emitOne(l),emitMany:l=>this.emitMany(l),reject:l=>this.reject(l)};try{await Promise.resolve(t(s)),this.resolve()}catch(l){this.reject(l)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Zi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new sr(async s=>{for await(let l of t)s.emitOne(n(l))})}map(t){return sr.map(this,t)}static filter(t,n){return new sr(async s=>{for await(let l of t)n(l)&&s.emitOne(l)})}filter(t){return sr.filter(this,t)}static coalesce(t){return sr.filter(t,n=>!!n)}coalesce(){return sr.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return sr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};g0.EMPTY=g0.fromArray([]);var{getWindow:zr,getWindowId:MR,onDidRegisterWindow:NR}=(function(){let e=new Map,t={window:gs,disposables:new da};e.set(gs.vscodeWindowId,t);let n=new ke,s=new ke,l=new ke;function c(d,m){return(typeof d=="number"?e.get(d):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:l.event,onDidUnregisterWindow:s.event,registerWindow(d){if(e.has(d.vscodeWindowId))return ot.None;let m=new da,g={window:d,disposables:m.add(new da)};return e.set(d.vscodeWindowId,g),m.add(Gt(()=>{e.delete(d.vscodeWindowId),s.fire(d)})),m.add(Qe(d,Ii.BEFORE_UNLOAD,()=>{l.fire(d)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:c,getWindow(d){let m=d;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=d;return g?.view?g.view.window:gs},getDocument(d){return zr(d).document}}})(),AR=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Qe(e,t,n,s){return new AR(e,t,n,s)}var _0=function(e,t,n,s){return Qe(e,t,n,s)},$_,LR=class extends DR{constructor(e){super(),this.defaultTarget=e&&zr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},v0=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Pd(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,l=c=>{n.set(c,!1);let d=e.get(c)??[];for(t.set(c,d),e.set(c,[]),s.set(c,!0);d.length>0;)d.sort(v0.sort),d.shift().execute();s.set(c,!1)};$_=(c,d,m=0)=>{let g=MR(c),f=new v0(d,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(f),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>l(g))),f}})();function BR(e){let t=e.getBoundingClientRect(),n=zr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ii={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},OR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=kn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=kn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=kn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=kn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=kn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=kn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=kn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=kn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=kn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=kn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=kn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=kn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=kn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=kn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function kn(e){return typeof e=="number"?`${e}px`:e}function Mc(e){return new OR(e)}var lC=class{constructor(){this._hooks=new da,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=l;let c=e;try{e.setPointerCapture(t),this._hooks.add(Gt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=zr(e)}this._hooks.add(Qe(c,Ii.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(Qe(c,Ii.POINTER_UP,d=>this.stopMonitoring(!0)))}};function jR(e,t,n){let s=null,l=null;if(typeof n.value=="function"?(s="value",l=n.value,l.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",l=n.get),!l)throw new Error("not supported");let c=`$memoize$${t}`;n[s]=function(...d){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:l.apply(this,d)}),this[c]}}var jr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(jr||={});var mc=class an extends ot{constructor(){super(),this.dispatched=!1,this.targets=new o0,this.ignoreTargets=new o0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Zi.runAndSubscribe(NR,({window:t,disposables:n})=>{n.add(Qe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Qe(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Qe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:gs,disposables:this._store}))}static addTarget(t){if(!an.isTouchDevice())return ot.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.targets.push(t);return Gt(n)}static ignoreTarget(t){if(!an.isTouchDevice())return ot.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.ignoreTargets.push(t);return Gt(n)}static isTouchDevice(){return"ontouchstart"in gs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,l=t.targetTouches.length;s<l;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let d=this.newGestureEvent(jr.Start,c.target);d.pageX=c.pageX,d.pageY=c.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),l=Object.keys(this.activeTouches).length;for(let c=0,d=n.changedTouches.length;c<d;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],f=Date.now()-g.initialTimeStamp;if(f<an.HOLD_DELAY&&Math.abs(g.initialPageX-Un(g.rollingPageX))<30&&Math.abs(g.initialPageY-Un(g.rollingPageY))<30){let y=this.newGestureEvent(jr.Tap,g.initialTarget);y.pageX=Un(g.rollingPageX),y.pageY=Un(g.rollingPageY),this.dispatchEvent(y)}else if(f>=an.HOLD_DELAY&&Math.abs(g.initialPageX-Un(g.rollingPageX))<30&&Math.abs(g.initialPageY-Un(g.rollingPageY))<30){let y=this.newGestureEvent(jr.Contextmenu,g.initialTarget);y.pageX=Un(g.rollingPageX),y.pageY=Un(g.rollingPageY),this.dispatchEvent(y)}else if(l===1){let y=Un(g.rollingPageX),b=Un(g.rollingPageY),w=Un(g.rollingTimestamps)-g.rollingTimestamps[0],x=y-g.rollingPageX[0],C=b-g.rollingPageY[0],D=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(x)/w,x>0?1:-1,y,Math.abs(C)/w,C>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(jr.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===jr.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>an.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===jr.Change||t.type===jr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let l=0,c=t.initialTarget;for(;c&&c!==s;)l++,c=c.parentElement;n.push([l,s])}n.sort((s,l)=>s[0]-l[0]);for(let[s,l]of n)l.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,l,c,d,m,g,f){this.handle=$_(t,()=>{let y=Date.now(),b=y-s,w=0,x=0,C=!0;l+=an.SCROLL_FRICTION*b,m+=an.SCROLL_FRICTION*b,l>0&&(C=!1,w=c*l*b),m>0&&(C=!1,x=g*m*b);let D=this.newGestureEvent(jr.Change);D.translationX=w,D.translationY=x,n.forEach(B=>B.dispatchEvent(D)),C||this.inertia(t,n,y,l,c,d+w,m,g,f+x)})}onTouchMove(t){let n=Date.now();for(let s=0,l=t.changedTouches.length;s<l;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],m=this.newGestureEvent(jr.Change,d.initialTarget);m.translationX=c.pageX-Un(d.rollingPageX),m.translationY=c.pageY-Un(d.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(c.pageX),d.rollingPageY.push(c.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};mc.SCROLL_FRICTION=-.005,mc.HOLD_DELAY=700,mc.CLEAR_TAP_COUNT_TIME=400,di([jR],mc,"isTouchDevice",1);var zR=mc,V_=class extends ot{onclick(e,t){this._register(Qe(e,Ii.CLICK,n=>t(new Cd(zr(e),n))))}onmousedown(e,t){this._register(Qe(e,Ii.MOUSE_DOWN,n=>t(new Cd(zr(e),n))))}onmouseover(e,t){this._register(Qe(e,Ii.MOUSE_OVER,n=>t(new Cd(zr(e),n))))}onmouseleave(e,t){this._register(Qe(e,Ii.MOUSE_LEAVE,n=>t(new Cd(zr(e),n))))}onkeydown(e,t){this._register(Qe(e,Ii.KEY_DOWN,n=>t(new f0(n))))}onkeyup(e,t){this._register(Qe(e,Ii.KEY_UP,n=>t(new f0(n))))}oninput(e,t){this._register(Qe(e,Ii.INPUT,t))}onblur(e,t){this._register(Qe(e,Ii.BLUR,t))}onfocus(e,t){this._register(Qe(e,Ii.FOCUS,t))}onchange(e,t){this._register(Qe(e,Ii.CHANGE,t))}ignoreGesture(e){return zR.ignoreTarget(e)}},b0=11,PR=class extends V_{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=b0+"px",this.domNode.style.height=b0+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new lC),this._register(_0(this.bgDomNode,Ii.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(_0(this.domNode,Ii.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new LR),this._pointerdownScheduleRepeatTimer=this._register(new q_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,zr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},IR=class _g{constructor(t,n,s,l,c,d,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,l=l|0,c=c|0,d=d|0,m=m|0),this.rawScrollLeft=l,this.rawScrollTop=m,n<0&&(n=0),l+n>s&&(l=s-n),l<0&&(l=0),c<0&&(c=0),m+c>d&&(m=d-c),m<0&&(m=0),this.width=n,this.scrollWidth=s,this.scrollLeft=l,this.height=c,this.scrollHeight=d,this.scrollTop=m}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new _g(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new _g(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,l=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:l,scrollLeftChanged:c,heightChanged:d,scrollHeightChanged:m,scrollTopChanged:g}}},HR=class extends ot{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new IR(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new S0(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=S0.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},y0=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function lm(e,t){let n=t-e;return function(s){return e+n*WR(s)}}function UR(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var S0=class vg{constructor(t,n,s,l){this.from=t,this.to=n,this.duration=l,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let l,c;return t<n?(l=t+.75*s,c=n-.75*s):(l=t-.75*s,c=n+.75*s),UR(lm(t,l),lm(c,n),.33)}return lm(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),l=this.scrollTop(n);return new y0(s,l,!1)}return new y0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return vg.start(t,n,s)}static start(t,n,s){s=s+10;let l=Date.now()-10;return new vg(t,n,l,s)}};function KR(e){return Math.pow(e,3)}function WR(e){return 1-KR(1-e)}var FR=class extends ot{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new q_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},qR=140,oC=class extends V_{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new FR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new lC),this._shouldRender=!0,this.domNode=Mc(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Qe(this.domNode.domNode,Ii.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new PR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Mc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Qe(this.slider.domNode,Ii.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);n<=l&&l<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let l=BR(this.domNode.domNode);t=e.pageX-l.left,n=e.pageY-l.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),d=Math.abs(c-n);if(nC&&d>qR){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let m=this._sliderPointerPosition(l)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(m))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},cC=class bg{constructor(t,n,s,l,c,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=l,this._scrollSize=c,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bg(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,l,c){let d=Math.max(0,s-t),m=Math.max(0,d-2*n),g=l>0&&l>s;if(!g)return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*m/l))),y=(m-f)/(l-s),b=c*y;return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=bg._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},$R=class extends oC{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new cC(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,l.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},VR=class extends oC{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new cC(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,l.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},YR=500,w0=50,XR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},yg=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,l=this._rear;do{let c=l===this._front?t:Math.pow(2,-s);if(t-=c,n+=this._memory[l].score*c,l===this._front)break;l=(this._capacity+l-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(W_){let n=zr(t.browserEvent),s=aR(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let l=null,c=new XR(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(l=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,l)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let l=Math.abs(t.deltaX),c=Math.abs(t.deltaY),d=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(l,d),1),f=Math.max(Math.min(c,m),1),y=Math.max(l,d),b=Math.max(c,m);y%g===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};yg.INSTANCE=new yg;var GR=yg,ZR=class extends V_{constructor(e,t,n){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=JR(t),this._scrollable=n,this._register(this._scrollable.onScroll(l=>{this._onWillScroll.fire(l),this._onDidScroll(l),this._onScroll.fire(l)}));let s={onMouseWheel:l=>this._onMouseWheel(l),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new VR(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new $R(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Mc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Mc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Mc(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,l=>this._onMouseOver(l)),this.onmouseleave(this._listenOnDomNode,l=>this._onMouseLeave(l)),this._hideTimeout=this._register(new q_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=il(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Pr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new m0(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=il(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new m0(n))};this._mouseWheelToDispose.push(Qe(this._listenOnDomNode,Ii.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=GR.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!Pr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(l){let f=w0*l,y=m.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let f=w0*c,y=m.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",l=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${l}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${l}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),YR)}},QR=class extends ZR{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function JR(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Pr&&(t.className+=" mac"),t}var Sg=class extends ot{constructor(e,t,n,s,l,c,d,m){super(),this._bufferService=n,this._optionsService=d,this._renderService=m,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new HR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>$_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new QR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(l.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Zi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Gt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Gt(()=>this._styleElement.remove())),this._register(Zi.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
25
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Sg=di([Oe(2,un),Oe(3,vs),Oe(4,W1),Oe(5,uo),Oe(6,dn),Oe(7,bs)],Sg);var wg=class extends ot{constructor(e,t,n,s,l){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=l,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(Gt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};wg=di([Oe(1,un),Oe(2,vs),Oe(3,Qc),Oe(4,bs)],wg);var eM=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Br={full:0,left:0,center:0,right:0},ta={full:0,left:0,center:0,right:0},rc={full:0,left:0,center:0,right:0},sh=class extends ot{constructor(e,t,n,s,l,c,d,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=l,this._optionsService=c,this._themeService=d,this._coreBrowserService=m,this._colorZoneStore=new eM,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Gt(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ta.full=this._canvas.width,ta.left=e,ta.center=t,ta.right=e,this._refreshDrawHeightConstants(),rc.full=1,rc.left=1,rc.center=1+ta.left,rc.right=1+ta.left+ta.center}_refreshDrawHeightConstants(){Br.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Br.left=t,Br.center=t,Br.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(rc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Br[e.position||"full"]/2),ta[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Br[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};sh=di([Oe(2,un),Oe(3,Qc),Oe(4,bs),Oe(5,dn),Oe(6,uo),Oe(7,vs)],sh);var me;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
26
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(me||={});var Ud;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Ud||={});var uC;(e=>e.ST=`${me.ESC}\\`)(uC||={});var Cg=class{constructor(e,t,n,s,l,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=l,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${me.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=l+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Cg=di([Oe(2,un),Oe(3,dn),Oe(4,sl),Oe(5,bs)],Cg);var Ui=0,Ki=0,Wi=0,ui=0,C0={css:"#00000000",rgba:0},Ei;(e=>{function t(l,c,d,m){return m!==void 0?`#${Wa(l)}${Wa(c)}${Wa(d)}${Wa(m)}`:`#${Wa(l)}${Wa(c)}${Wa(d)}`}e.toCss=t;function n(l,c,d,m=255){return(l<<24|c<<16|d<<8|m)>>>0}e.toRgba=n;function s(l,c,d,m){return{css:e.toCss(l,c,d,m),rgba:e.toRgba(l,c,d,m)}}e.toColor=s})(Ei||={});var Ft;(e=>{function t(g,f){if(ui=(f.rgba&255)/255,ui===1)return{css:f.css,rgba:f.rgba};let y=f.rgba>>24&255,b=f.rgba>>16&255,w=f.rgba>>8&255,x=g.rgba>>24&255,C=g.rgba>>16&255,D=g.rgba>>8&255;Ui=x+Math.round((y-x)*ui),Ki=C+Math.round((b-C)*ui),Wi=D+Math.round((w-D)*ui);let B=Ei.toCss(Ui,Ki,Wi),L=Ei.toRgba(Ui,Ki,Wi);return{css:B,rgba:L}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,f,y){let b=Kd.ensureContrastRatio(g.rgba,f.rgba,y);if(b)return Ei.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function l(g){let f=(g.rgba|255)>>>0;return[Ui,Ki,Wi]=Kd.toChannels(f),{css:Ei.toCss(Ui,Ki,Wi),rgba:f}}e.opaque=l;function c(g,f){return ui=Math.round(f*255),[Ui,Ki,Wi]=Kd.toChannels(g.rgba),{css:Ei.toCss(Ui,Ki,Wi,ui),rgba:Ei.toRgba(Ui,Ki,Wi,ui)}}e.opacity=c;function d(g,f){return ui=g.rgba&255,c(g,ui*f/255)}e.multiplyOpacity=d;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(Ft||={});var ti;(e=>{let t,n;try{let l=document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(l){if(l.match(/#[\da-f]{3,8}/i))switch(l.length){case 4:return Ui=parseInt(l.slice(1,2).repeat(2),16),Ki=parseInt(l.slice(2,3).repeat(2),16),Wi=parseInt(l.slice(3,4).repeat(2),16),Ei.toColor(Ui,Ki,Wi);case 5:return Ui=parseInt(l.slice(1,2).repeat(2),16),Ki=parseInt(l.slice(2,3).repeat(2),16),Wi=parseInt(l.slice(3,4).repeat(2),16),ui=parseInt(l.slice(4,5).repeat(2),16),Ei.toColor(Ui,Ki,Wi,ui);case 7:return{css:l,rgba:(parseInt(l.slice(1),16)<<8|255)>>>0};case 9:return{css:l,rgba:parseInt(l.slice(1),16)>>>0}}let c=l.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Ui=parseInt(c[1]),Ki=parseInt(c[2]),Wi=parseInt(c[3]),ui=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Ei.toColor(Ui,Ki,Wi,ui);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=l,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ui,Ki,Wi,ui]=t.getImageData(0,0,1,1).data,ui!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ei.toRgba(Ui,Ki,Wi,ui),css:l}}e.toColor=s})(ti||={});var cn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,l,c){let d=s/255,m=l/255,g=c/255,f=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(cn||={});var Kd;(e=>{function t(d,m){if(ui=(m&255)/255,ui===1)return m;let g=m>>24&255,f=m>>16&255,y=m>>8&255,b=d>>24&255,w=d>>16&255,x=d>>8&255;return Ui=b+Math.round((g-b)*ui),Ki=w+Math.round((f-w)*ui),Wi=x+Math.round((y-x)*ui),Ei.toRgba(Ui,Ki,Wi)}e.blend=t;function n(d,m,g){let f=cn.relativeLuminance(d>>8),y=cn.relativeLuminance(m>>8);if(fs(f,y)<g){if(y<f){let x=s(d,m,g),C=fs(f,cn.relativeLuminance(x>>8));if(C<g){let D=l(d,m,g),B=fs(f,cn.relativeLuminance(D>>8));return C>B?x:D}return x}let b=l(d,m,g),w=fs(f,cn.relativeLuminance(b>>8));if(w<g){let x=s(d,m,g),C=fs(f,cn.relativeLuminance(x>>8));return w>C?b:x}return b}}e.ensureContrastRatio=n;function s(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,w=m>>24&255,x=m>>16&255,C=m>>8&255,D=fs(cn.relativeLuminance2(w,x,C),cn.relativeLuminance2(f,y,b));for(;D<g&&(w>0||x>0||C>0);)w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),C-=Math.max(0,Math.ceil(C*.1)),D=fs(cn.relativeLuminance2(w,x,C),cn.relativeLuminance2(f,y,b));return(w<<24|x<<16|C<<8|255)>>>0}e.reduceLuminance=s;function l(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,w=m>>24&255,x=m>>16&255,C=m>>8&255,D=fs(cn.relativeLuminance2(w,x,C),cn.relativeLuminance2(f,y,b));for(;D<g&&(w<255||x<255||C<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),D=fs(cn.relativeLuminance2(w,x,C),cn.relativeLuminance2(f,y,b));return(w<<24|x<<16|C<<8|255)>>>0}e.increaseLuminance=l;function c(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=c})(Kd||={});function Wa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function fs(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var tM=class extends Zc{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ah=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new dr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),l=0,c=0,d=0,m=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(f-l>1){let y=this._getJoinedRanges(s,d,c,t,l);for(let b=0;b<y.length;b++)n.push(y[b])}l=f,d=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||ca.length}if(this._bufferService.cols-l>1){let f=this._getJoinedRanges(s,d,c,t,l);for(let y=0;y<f.length;y++)n.push(f[y])}return n}_getJoinedRanges(e,t,n,s,l){let c=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let f=0;f<g.length;f++)ah._mergeRanges(d,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(d,s,l),d}_stringRangesToCellRanges(e,t,n){let s=0,l=!1,c=0,d=e[s];if(d){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),f=t.getString(m).length||ca.length;if(g!==0){if(!l&&d[0]<=c&&(d[0]=m,l=!0),d[1]<=c){if(d[1]=m,d=e[++s],!d)break;d[0]<=c?(d[0]=m,l=!0):l=!1}c+=f}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let l=e[s];if(n){if(t[1]<=l[0])return e[s-1][1]=t[1],e;if(t[1]<=l[1])return e[s-1][1]=Math.max(t[1],l[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=l[0])return e.splice(s,0,t),e;if(t[1]<=l[1])return l[0]=Math.min(t[0],l[0]),e;t[0]<l[1]&&(l[0]=Math.min(t[0],l[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};ah=di([Oe(0,un)],ah);function iM(e){return 57508<=e&&e<=57558}function nM(e){return 9472<=e&&e<=9631}function rM(e){return iM(e)||nM(e)}function sM(){return{css:{canvas:xd(),cell:xd()},device:{canvas:xd(),cell:xd(),char:{width:0,height:0,left:0,top:0}}}}function xd(){return{width:0,height:0}}var xg=class{constructor(e,t,n,s,l,c,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=l,this._decorationService=c,this._themeService=d,this._workCell=new dr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,l,c,d,m,g,f,y){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),x=this._themeService.colors,C=e.getNoBgTrimmedLength();n&&C<c+1&&(C=c+1);let D,B=0,L="",O=0,Y=0,U=0,Z=0,W=!1,re=0,ee=!1,ye=0,Ee=0,ne=[],q=f!==-1&&y!==-1;for(let Q=0;Q<C;Q++){e.loadCell(Q,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let se=!1,A=Q>=Ee,R=Q,P=this._workCell;if(w.length>0&&Q===w[0][0]&&A){let Se=w.shift(),Ae=this._isCellInSelection(Se[0],t);for(O=Se[0]+1;O<Se[1];O++)A&&=Ae===this._isCellInSelection(O,t);A&&=!n||c<Se[0]||c>=Se[1],A?(se=!0,P=new tM(this._workCell,e.translateToString(!0,Se[0],Se[1]),Se[1]-Se[0]),R=Se[1]-1,K=P.getWidth()):Ee=Se[1]}let ie=this._isCellInSelection(Q,t),ge=n&&Q===c,M=q&&Q>=f&&Q<=y,X=!1;this._decorationService.forEachDecorationAtCell(Q,t,void 0,Se=>{X=!0});let ue=P.getChars()||ca;if(ue===" "&&(P.isUnderline()||P.isOverline())&&(ue=" "),ye=K*m-g.get(ue,P.isBold(),P.isItalic()),!D)D=this._document.createElement("span");else if(B&&(ie&&ee||!ie&&!ee&&P.bg===Y)&&(ie&&ee&&x.selectionForeground||P.fg===U)&&P.extended.ext===Z&&M===W&&ye===re&&!ge&&!se&&!X&&A){P.isInvisible()?L+=ca:L+=ue,B++;continue}else B&&(D.textContent=L),D=this._document.createElement("span"),B=0,L="";if(Y=P.bg,U=P.fg,Z=P.extended.ext,W=M,re=ye,ee=ie,se&&c>=Q&&c<=R&&(c=Q),!this._coreService.isCursorHidden&&ge&&this._coreService.isCursorInitialized){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&ne.push("xterm-cursor-blink"),ne.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline");break}}if(P.isBold()&&ne.push("xterm-bold"),P.isItalic()&&ne.push("xterm-italic"),P.isDim()&&ne.push("xterm-dim"),P.isInvisible()?L=ca:L=P.getChars()||ca,P.isUnderline()&&(ne.push(`xterm-underline-${P.extended.underlineStyle}`),L===" "&&(L=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${Zc.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let Se=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&Se<8&&(Se+=8),D.style.textDecorationColor=x.ansi[Se].css}P.isOverline()&&(ne.push("xterm-overline"),L===" "&&(L=" ")),P.isStrikethrough()&&ne.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let be=P.getFgColor(),ve=P.getFgColorMode(),xe=P.getBgColor(),Re=P.getBgColorMode(),Me=!!P.isInverse();if(Me){let Se=be;be=xe,xe=Se;let Ae=ve;ve=Re,Re=Ae}let ze,Pe,ce=!1;this._decorationService.forEachDecorationAtCell(Q,t,void 0,Se=>{Se.options.layer!=="top"&&ce||(Se.backgroundColorRGB&&(Re=50331648,xe=Se.backgroundColorRGB.rgba>>8&16777215,ze=Se.backgroundColorRGB),Se.foregroundColorRGB&&(ve=50331648,be=Se.foregroundColorRGB.rgba>>8&16777215,Pe=Se.foregroundColorRGB),ce=Se.options.layer==="top")}),!ce&&ie&&(ze=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,xe=ze.rgba>>8&16777215,Re=50331648,ce=!0,x.selectionForeground&&(ve=50331648,be=x.selectionForeground.rgba>>8&16777215,Pe=x.selectionForeground)),ce&&ne.push("xterm-decoration-top");let _e;switch(Re){case 16777216:case 33554432:_e=x.ansi[xe],ne.push(`xterm-bg-${xe}`);break;case 50331648:_e=Ei.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(D,`background-color:#${x0((xe>>>0).toString(16),"0",6)}`);break;default:Me?(_e=x.foreground,ne.push("xterm-bg-257")):_e=x.background}switch(ze||P.isDim()&&(ze=Ft.multiplyOpacity(_e,.5)),ve){case 16777216:case 33554432:P.isBold()&&be<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(be+=8),this._applyMinimumContrast(D,_e,x.ansi[be],P,ze,void 0)||ne.push(`xterm-fg-${be}`);break;case 50331648:let Se=Ei.toColor(be>>16&255,be>>8&255,be&255);this._applyMinimumContrast(D,_e,Se,P,ze,Pe)||this._addStyle(D,`color:#${x0(be.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,_e,x.foreground,P,ze,Pe)||Me&&ne.push("xterm-fg-257")}ne.length&&(D.className=ne.join(" "),ne.length=0),!ge&&!se&&!X&&A?B++:D.textContent=L,ye!==this.defaultSpacing&&(D.style.letterSpacing=`${ye}px`),b.push(D),Q=R}return D&&B&&(D.textContent=L),b}_applyMinimumContrast(e,t,n,s,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||rM(s.getCode()))return!1;let d=this._getContrastCache(s),m;if(!l&&!c&&(m=d.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);m=Ft.ensureContrastRatio(l||t,c||n,g),d.setColor((l||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};xg=di([Oe(1,$1),Oe(2,dn),Oe(3,vs),Oe(4,sl),Oe(5,Qc),Oe(6,uo)],xg);function x0(e,t,n){for(;e.length<n;)e=t+e;return e}var aM=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,s,l,c],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(l),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let l=e;t&&(l+="B"),n&&(l+="I");let c=this._holey.get(l);if(c===void 0){let d=0;t&&(d|=1),n&&(d|=2),c=this._measure(e,d),c>0&&this._holey.set(l,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},lM=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let l=e.buffers.active.ydisp,c=t[1]-l,d=n[1]-l,m=Math.max(c,0),g=Math.min(d,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=d,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function oM(){return new lM}var om="xterm-dom-renderer-owner-",rr="xterm-rows",kd="xterm-fg-",k0="xterm-bg-",sc="xterm-focus",Ed="xterm-selection",cM=1,kg=class extends ot{constructor(e,t,n,s,l,c,d,m,g,f,y,b,w,x){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=l,this._helperContainer=c,this._linkifier2=d,this._charSizeService=g,this._optionsService=f,this._bufferService=y,this._coreService=b,this._coreBrowserService=w,this._themeService=x,this._terminalClass=cM++,this._rowElements=[],this._selectionRenderModel=oM(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(rr),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ed),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=sM(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(C=>this._injectCss(C))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(xg,document),this._element.classList.add(om+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(C=>this._handleLinkHover(C))),this._register(this._linkifier2.onHideLinkUnderline(C=>this._handleLinkLeave(C))),this._register(Gt(()=>{this._element.classList.remove(om+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new aM(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${rr} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${rr} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${rr} .xterm-dim { color: ${Ft.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${rr}.${sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${rr}.${sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${rr}.${sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ed} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ed} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ed} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())t+=`${this._terminalSelector} .${kd}${c} { color: ${d.css}; }${this._terminalSelector} .${kd}${c}.xterm-dim { color: ${Ft.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${k0}${c} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${kd}257 { color: ${Ft.opaque(e.background).css}; }${this._terminalSelector} .${kd}257.xterm-dim { color: ${Ft.multiplyOpacity(Ft.opaque(e.background),.5).css}; }${this._terminalSelector} .${k0}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(sc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(sc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],d-c+1))}else{let g=s===c?e[0]:0,f=c===l?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,f));let y=d-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==d){let b=l===d?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(d,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,s=1){let l=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return c+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-c),l.style.height=`${s*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${d}px`,l}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,l=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(f);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,f,f===s,d,m,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${om}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,l,c){n<0&&(e=0),s<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),s=Math.max(Math.min(s,d),0),l=Math.min(l,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,f=Math.min(m.x,l-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=n;x<=s;++x){let C=x+m.ydisp,D=this._rowElements[x],B=m.lines.get(C);if(!D||!B)break;D.replaceChildren(...this._rowFactory.createRow(B,C,C===g,b,w,f,y,this.dimensions.css.cell.width,this._widthCache,c?x===n?e:0:-1,c?(x===s?t:l)-1:-1))}}};kg=di([Oe(7,H_),Oe(8,Th),Oe(9,dn),Oe(10,un),Oe(11,sl),Oe(12,vs),Oe(13,uo)],kg);var Eg=class extends ot{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new dM(this._optionsService))}catch{this._measureStrategy=this._register(new uM(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Eg=di([Oe(2,dn)],Eg);var dC=class extends ot{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},uM=class extends dC{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},dM=class extends dC{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},hM=class extends ot{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new fM(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Zi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Qe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Qe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},fM=class extends ot{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ro),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Gt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Qe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},pM=class extends ot{constructor(){super(),this.linkProviders=[],this._register(Gt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Y_(e,t,n){let s=n.getBoundingClientRect(),l=e.getComputedStyle(n),c=parseInt(l.getPropertyValue("padding-left")),d=parseInt(l.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-d]}function mM(e,t,n,s,l,c,d,m,g){if(!c)return;let f=Y_(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(g?d/2:0))/d),f[1]=Math.ceil(f[1]/m),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),l),f}var Tg=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,l){return mM(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,t){let n=Y_(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Tg=di([Oe(0,bs),Oe(1,Th)],Tg);var gM=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},hC={};ED(hC,{getSafariVersion:()=>vM,isChromeOS:()=>gC,isFirefox:()=>fC,isIpad:()=>bM,isIphone:()=>yM,isLegacyEdge:()=>_M,isLinux:()=>X_,isMac:()=>lh,isNode:()=>Dh,isSafari:()=>pC,isWindows:()=>mC});var Dh=typeof process<"u"&&"title"in process,Jc=Dh?"node":navigator.userAgent,eu=Dh?"node":navigator.platform,fC=Jc.includes("Firefox"),_M=Jc.includes("Edge"),pC=/^((?!chrome|android).)*safari/i.test(Jc);function vM(){if(!pC)return 0;let e=Jc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var lh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(eu),bM=eu==="iPad",yM=eu==="iPhone",mC=["Windows","Win16","Win32","WinCE"].includes(eu),X_=eu.indexOf("Linux")>=0,gC=/\bCrOS\b/.test(Jc),_C=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),l=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),l=e.timeRemaining(),n*1.5>l){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=l}this.clear()}},SM=class extends _C{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},wM=class extends _C{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oh=!Dh&&"requestIdleCallback"in window?wM:SM,CM=class{constructor(){this._queue=new oh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Dg=class extends ot{constructor(e,t,n,s,l,c,d,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=l,this._coreBrowserService=m,this._renderer=this._register(new ro),this._pausedResizeTask=new CM,this._observerDisposable=this._register(new ro),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new gM((f,y)=>this._renderRows(f,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new xM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Gt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Gt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Dg=di([Oe(2,dn),Oe(3,Th),Oe(4,sl),Oe(5,Qc),Oe(6,un),Oe(7,vs),Oe(8,uo)],Dg);var xM=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function kM(e,t,n,s){let l=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return DM(l,c,e,t,n,s)+Rh(c,t,n,s)+RM(l,c,e,t,n,s);let d;if(c===t)return d=l>e?"D":"C",Pc(Math.abs(l-e),zc(d,s));d=c>t?"D":"C";let m=Math.abs(c-t),g=TM(c>t?e:l,n)+(m-1)*n.cols+1+EM(c>t?l:e);return Pc(g,zc(d,s))}function EM(e,t){return e-1}function TM(e,t){return t.cols-e}function DM(e,t,n,s,l,c){return Rh(t,s,l,c).length===0?"":Pc(bC(e,t,e,t-nl(t,l),!1,l).length,zc("D",c))}function Rh(e,t,n,s){let l=e-nl(e,n),c=t-nl(t,n),d=Math.abs(l-c)-MM(e,t,n);return Pc(d,zc(vC(e,t),s))}function RM(e,t,n,s,l,c){let d;Rh(t,s,l,c).length>0?d=s-nl(s,l):d=t;let m=s,g=NM(e,t,n,s,l,c);return Pc(bC(e,d,n,m,g==="C",l).length,zc(g,c))}function MM(e,t,n){let s=0,l=e-nl(e,n),c=t-nl(t,n);for(let d=0;d<Math.abs(l-c);d++){let m=vC(e,t)==="A"?-1:1;n.buffer.lines.get(l+m*d)?.isWrapped&&s++}return s}function nl(e,t){let n=0,s=t.buffer.lines.get(e),l=s?.isWrapped;for(;l&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),l=s?.isWrapped;return n}function NM(e,t,n,s,l,c){let d;return Rh(n,s,l,c).length>0?d=s-nl(s,l):d=t,e<n&&d<=s||e>=n&&d<s?"C":"D"}function vC(e,t){return e>t?"A":"B"}function bC(e,t,n,s,l,c){let d=e,m=t,g="";for(;(d!==n||m!==s)&&m>=0&&m<c.buffer.lines.length;)d+=l?1:-1,l&&d>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,d),d=0,e=0,m++):!l&&d<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),d=c.cols-1,e=d,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,d)}function zc(e,t){let n=t?"O":"[";return me.ESC+n+e}function Pc(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var AM=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function E0(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var cm=50,LM=15,BM=50,OM=500,jM=" ",zM=new RegExp(jM,"g"),Rg=class extends ot{constructor(e,t,n,s,l,c,d,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=l,this._mouseService=c,this._optionsService=d,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new AM(this._bufferService),this._activeSelectionMode=0,this._register(Gt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let l=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let m=n.translateBufferLineToString(d,!0,l,c);s.push(m)}}else{let l=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=t[1]-1;c++){let d=n.lines.get(c),m=n.translateBufferLineToString(c,!0);d?.isWrapped?s[s.length-1]+=m:s.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(l=>l.replace(zM," ")).join(mC?`\r
27
- `:`
28
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),X_&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=E0(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Y_(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-cm),cm),t/=cm,t/Math.abs(t)+Math.round(t*(LM-1)))}shouldForceSelection(e){return lh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),BM)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(lh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<OM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=kM(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let l=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:l>1&&t!==s&&(n+=l-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let d=l.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,f=e[0]-m,y=0,b=0,w=0,x=0;if(d.charAt(m)===" "){for(;m>0&&d.charAt(m-1)===" ";)m--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let B=e[0],L=e[0];c.getWidth(B)===0&&(y++,B--),c.getWidth(L)===2&&(b++,L++);let O=c.getString(L).length;for(O>1&&(x+=O-1,g+=O-1);B>0&&m>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,B--):Y>1&&(w+=Y-1,m-=Y-1),m--,B--}for(;L<c.length&&g+1<d.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,L++):Y>1&&(x+=Y-1,g+=Y-1),g++,L++}}g++;let C=m+f-y+w,D=Math.min(this._bufferService.cols,g-m+y+b-w-x);if(!(!t&&d.slice(m,g).trim()==="")){if(n&&C===0&&c.getCodePoint(0)!==32){let B=l.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let O=this._bufferService.cols-L.start;C-=O,D+=O}}}if(s&&C+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=l.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(D+=L.length)}}return{start:C,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=E0(n,this._bufferService.cols)}};Rg=di([Oe(3,un),Oe(4,sl),Oe(5,U_),Oe(6,dn),Oe(7,bs),Oe(8,vs)],Rg);var T0=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},D0=class{constructor(){this._color=new T0,this._css=new T0}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ri=Object.freeze((()=>{let e=[ti.toColor("#2e3436"),ti.toColor("#cc0000"),ti.toColor("#4e9a06"),ti.toColor("#c4a000"),ti.toColor("#3465a4"),ti.toColor("#75507b"),ti.toColor("#06989a"),ti.toColor("#d3d7cf"),ti.toColor("#555753"),ti.toColor("#ef2929"),ti.toColor("#8ae234"),ti.toColor("#fce94f"),ti.toColor("#729fcf"),ti.toColor("#ad7fa8"),ti.toColor("#34e2e2"),ti.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],l=t[n/6%6|0],c=t[n%6];e.push({css:Ei.toCss(s,l,c),rgba:Ei.toRgba(s,l,c)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Ei.toCss(s,s,s),rgba:Ei.toRgba(s,s,s)})}return e})()),qa=ti.toColor("#ffffff"),gc=ti.toColor("#000000"),R0=ti.toColor("#ffffff"),M0=gc,ac={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},PM=qa,Mg=class extends ot{constructor(e){super(),this._optionsService=e,this._contrastCache=new D0,this._halfContrastCache=new D0,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:qa,background:gc,cursor:R0,cursorAccent:M0,selectionForeground:void 0,selectionBackgroundTransparent:ac,selectionBackgroundOpaque:Ft.blend(gc,ac),selectionInactiveBackgroundTransparent:ac,selectionInactiveBackgroundOpaque:Ft.blend(gc,ac),scrollbarSliderBackground:Ft.opacity(qa,.2),scrollbarSliderHoverBackground:Ft.opacity(qa,.4),scrollbarSliderActiveBackground:Ft.opacity(qa,.5),overviewRulerBorder:qa,ansi:Ri.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Lt(e.foreground,qa),t.background=Lt(e.background,gc),t.cursor=Ft.blend(t.background,Lt(e.cursor,R0)),t.cursorAccent=Ft.blend(t.background,Lt(e.cursorAccent,M0)),t.selectionBackgroundTransparent=Lt(e.selectionBackground,ac),t.selectionBackgroundOpaque=Ft.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Lt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ft.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Lt(e.selectionForeground,C0):void 0,t.selectionForeground===C0&&(t.selectionForeground=void 0),Ft.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ft.opacity(t.selectionBackgroundTransparent,.3)),Ft.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ft.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Lt(e.scrollbarSliderBackground,Ft.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Lt(e.scrollbarSliderHoverBackground,Ft.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Lt(e.scrollbarSliderActiveBackground,Ft.opacity(t.foreground,.5)),t.overviewRulerBorder=Lt(e.overviewRulerBorder,PM),t.ansi=Ri.slice(),t.ansi[0]=Lt(e.black,Ri[0]),t.ansi[1]=Lt(e.red,Ri[1]),t.ansi[2]=Lt(e.green,Ri[2]),t.ansi[3]=Lt(e.yellow,Ri[3]),t.ansi[4]=Lt(e.blue,Ri[4]),t.ansi[5]=Lt(e.magenta,Ri[5]),t.ansi[6]=Lt(e.cyan,Ri[6]),t.ansi[7]=Lt(e.white,Ri[7]),t.ansi[8]=Lt(e.brightBlack,Ri[8]),t.ansi[9]=Lt(e.brightRed,Ri[9]),t.ansi[10]=Lt(e.brightGreen,Ri[10]),t.ansi[11]=Lt(e.brightYellow,Ri[11]),t.ansi[12]=Lt(e.brightBlue,Ri[12]),t.ansi[13]=Lt(e.brightMagenta,Ri[13]),t.ansi[14]=Lt(e.brightCyan,Ri[14]),t.ansi[15]=Lt(e.brightWhite,Ri[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=Lt(e.extendedAnsi[s],Ri[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Mg=di([Oe(0,dn)],Mg);function Lt(e,t){if(e!==void 0)try{return ti.toColor(e)}catch{}return t}var IM=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},HM=class{constructor(){this._services=new IM,this._services.set(H_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=LD(e).sort((c,d)=>c.index-d.index),s=[];for(let c of n){let d=this._services.get(c.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(d)}let l=n.length>0?n[0].index:t.length;if(t.length!==l)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${l+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},UM={trace:0,debug:1,info:2,warn:3,error:4,off:5},KM="xterm.js: ",Ng=class extends ot{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=UM[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":KM)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Ng=di([Oe(0,dn)],Ng);var N0=class extends ot{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let l=t-1;l>=0;l--)this.set(e+l+n,this.get(e+l));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},lt=3,xi=Object.freeze(new Zc),Td=0,um=2,_c=class yC{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*lt);let l=n||dr.fromCharData([0,I1,1,0]);for(let c=0;c<t;++c)this.setCell(c,l);this.length=t}get(t){let n=this._data[t*lt+0],s=n&2097151;return[this._data[t*lt+1],n&2097152?this._combined[t]:s?la(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*lt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*lt+0]=t|2097152|n[2]<<22):this._data[t*lt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*lt+0]>>22}hasWidth(t){return this._data[t*lt+0]&12582912}getFg(t){return this._data[t*lt+1]}getBg(t){return this._data[t*lt+2]}hasContent(t){return this._data[t*lt+0]&4194303}getCodePoint(t){let n=this._data[t*lt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*lt+0]&2097152}getString(t){let n=this._data[t*lt+0];return n&2097152?this._combined[t]:n&2097151?la(n&2097151):""}isProtected(t){return this._data[t*lt+2]&536870912}loadCell(t,n){return Td=t*lt,n.content=this._data[Td+0],n.fg=this._data[Td+1],n.bg=this._data[Td+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*lt+0]=n.content,this._data[t*lt+1]=n.fg,this._data[t*lt+2]=n.bg}setCellFromCodepoint(t,n,s,l){l.bg&268435456&&(this._extendedAttrs[t]=l.extended),this._data[t*lt+0]=n|s<<22,this._data[t*lt+1]=l.fg,this._data[t*lt+2]=l.bg}addCodepointToCell(t,n,s){let l=this._data[t*lt+0];l&2097152?this._combined[t]+=la(n):l&2097151?(this._combined[t]=la(l&2097151)+la(n),l&=-2097152,l|=2097152):l=n|1<<22,s&&(l&=-12582913,l|=s<<22),this._data[t*lt+0]=l}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let l=new dr;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,l));for(let c=0;c<n;++c)this.setCell(t+c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let l=new dr;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,l));for(let c=this.length-n;c<this.length;++c)this.setCell(c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,l=!1){if(l){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*um<this._data.buffer.byteLength;let s=t*lt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<t;++l)this.setCell(l,n)}else{this._data=this._data.subarray(0,s);let l=Object.keys(this._combined);for(let d=0;d<l.length;d++){let m=parseInt(l[d],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let d=0;d<c.length;d++){let m=parseInt(c[d],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,s*4*um<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*um<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new yC(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303)return t+(this._data[t*lt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303||this._data[t*lt+2]&50331648)return t+(this._data[t*lt+0]>>22);return 0}copyCellsFrom(t,n,s,l,c){let d=t._data;if(c)for(let g=l-1;g>=0;g--){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=d[(n+g)*lt+f];d[(n+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<l;g++){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=d[(n+g)*lt+f];d[(n+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let f=parseInt(m[g],10);f>=n&&(this._combined[f-n+s]=t._combined[f])}}translateToString(t,n,s,l){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let c="";for(;n<s;){let d=this._data[n*lt+0],m=d&2097151,g=d&2097152?this._combined[n]:m?la(m):ca;if(c+=g,l)for(let f=0;f<g.length;++f)l.push(n);n+=d>>22||1}return l&&l.push(n),c}};function WM(e,t,n,s,l,c){let d=[];for(let m=0;m<e.length-1;m++){let g=m,f=e.get(++g);if(!f.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&f.isWrapped;)y.push(f),f=e.get(++g);if(!c&&s>=m&&s<g){m+=y.length-1;continue}let b=0,w=Ic(y,b,t),x=1,C=0;for(;x<y.length;){let B=Ic(y,x,t),L=B-C,O=n-w,Y=Math.min(L,O);y[b].copyCellsFrom(y[x],C,w,Y,!1),w+=Y,w===n&&(b++,w=0),C+=Y,C===B&&(x++,C=0),w===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,w++,1,!1),y[b-1].setCell(n-1,l))}y[b].replaceCells(w,n,l);let D=0;for(let B=y.length-1;B>0&&(B>b||y[B].getTrimmedLength()===0);B--)D++;D>0&&(d.push(m+y.length-D),d.push(D)),m+=y.length-1}return d}function FM(e,t){let n=[],s=0,l=t[s],c=0;for(let d=0;d<e.length;d++)if(l===d){let m=t[++s];e.onDeleteEmitter.fire({index:d-c,amount:m}),d+=m-1,c+=m,l=t[++s]}else n.push(d);return{layout:n,countRemoved:c}}function qM(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function $M(e,t,n){let s=[],l=e.map((g,f)=>Ic(e,f,t)).reduce((g,f)=>g+f),c=0,d=0,m=0;for(;m<l;){if(l-m<n){s.push(l-m);break}c+=n;let g=Ic(e,d,t);c>g&&(c-=g,d++);let f=e[d].getWidth(c-1)===2;f&&c--;let y=f?n-1:n;s.push(y),m+=y}return s}function Ic(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,l=e[t+1].getWidth(0)===2;return s&&l?n-1:n}var SC=class wC{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=wC._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),il(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};SC._nextId=1;var VM=SC,Bi={},$a=Bi.B;Bi[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Bi.A={"#":"£"};Bi.B=void 0;Bi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Bi.C=Bi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Bi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Bi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Bi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Bi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Bi.E=Bi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Bi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Bi.H=Bi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Bi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var A0=4294967295,L0=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xi.clone(),this.savedCharset=$a,this.markers=[],this._nullCell=dr.fromCharData([0,I1,1,0]),this._whitespaceCell=dr.fromCharData([0,ca,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new N0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rh),this._whitespaceCell}getBlankLine(e,t){return new _c(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>A0?A0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new N0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(xi),s=0,l=this._getCorrectBufferLength(t);if(l>this.lines.maxLength&&(this.lines.maxLength=l),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)s+=+this.lines.get(d).resize(e,n);let c=0;if(this._rows<t)for(let d=this._rows;d<t;d++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new _c(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new _c(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(l<this.lines.maxLength){let d=this.lines.length-l;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=l}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=WM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xi),n);if(s.length>0){let l=FM(this.lines,s);qM(this.lines,l.layout),this._reflowLargerAdjustViewport(e,t,l.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(xi),l=n;for(;l-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new _c(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(xi),l=[],c=0;for(let d=this.lines.length-1;d>=0;d--){let m=this.lines.get(d);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&d>0;)m=this.lines.get(--d),g.unshift(m);if(!n){let Y=this.ybase+this.y;if(Y>=d&&Y<d+g.length)continue}let f=g[g.length-1].getTrimmedLength(),y=$M(g,this._cols,e),b=y.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let x=[];for(let Y=0;Y<b;Y++){let U=this.getBlankLine(xi,!0);x.push(U)}x.length>0&&(l.push({start:d+g.length+c,newLines:x}),c+=x.length),g.push(...x);let C=y.length-1,D=y[C];D===0&&(C--,D=y[C]);let B=g.length-b-1,L=f;for(;B>=0;){let Y=Math.min(L,D);if(g[C]===void 0)break;if(g[C].copyCellsFrom(g[B],L-Y,D-Y,Y,!0),D-=Y,D===0&&(C--,D=y[C]),L-=Y,L===0){B--;let U=Math.max(B,0);L=Ic(g,U,this._cols)}}for(let Y=0;Y<g.length;Y++)y[Y]<e&&g[Y].setCell(y[Y],s);let O=b-w;for(;O-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(l.length>0){let d=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,f=g-1,y=0,b=l[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>f+w){for(let B=b.newLines.length-1;B>=0;B--)this.lines.set(D--,b.newLines[B]);D++,d.push({index:f+1,amount:b.newLines.length}),w+=b.newLines.length,b=l[++y]}else this.lines.set(D,m[f--]);let x=0;for(let D=d.length-1;D>=0;D--)d[D].index+=x,this.lines.onInsertEmitter.fire(d[D]),x+=d[D].amount;let C=Math.max(0,g+c-this.lines.maxLength);C>0&&this.lines.onTrimEmitter.fire(C)}}translateBufferLineToString(e,t,n=0,s){let l=this.lines.get(e);return l?l.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new VM(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},YM=class extends ot{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new L0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new L0(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},CC=2,xC=1,Ag=class extends ot{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,CC),this.rows=Math.max(e.rawOptions.rows||0,xC),this.buffers=this._register(new YM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let l=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;c===n.lines.length-1?d?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(c+1,0,s.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=c-l+1;n.lines.shiftElements(l+1,d-1,-1),n.lines.set(c,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Ag=di([Oe(0,dn)],Ag);var Wl={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:lh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},XM=["normal","bold","100","200","300","400","500","600","700","800","900"],GM=class extends ot{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...Wl};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Gt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Wl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Wl))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wl[e]),!ZM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=XM.includes(t)?t:Wl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function ZM(e){return e==="block"||e==="underline"||e==="bar"}function vc(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&vc(e[s],t-1);return n}var B0=Object.freeze({insertMode:!1}),O0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Lg=class extends ot{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=vc(B0),this.decPrivateModes=vc(O0)}reset(){this.modes=vc(B0),this.decPrivateModes=vc(O0)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Lg=di([Oe(0,un),Oe(1,F1),Oe(2,dn)],Lg);var j0={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function dm(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var hm=String.fromCharCode,z0={DEFAULT:e=>{let t=[dm(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${hm(t[0])}${hm(t[1])}${hm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${dm(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${dm(e,!0)};${e.x};${e.y}${t}`}},Bg=class extends ot{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(j0))this.addProtocol(s,j0[s]);for(let s of Object.keys(z0))this.addEncoding(s,z0[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,l=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=s+0,Math.abs(e.deltaY)<50&&(l*=.3),this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Bg=di([Oe(0,un),Oe(1,sl),Oe(2,dn)],Bg);var fm=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],QM=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Mi;function JM(e,t){let n=0,s=t.length-1,l;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(l=n+s>>1,e>t[l][1])n=l+1;else if(e<t[l][0])s=l-1;else return!0;return!1}var eN=class{constructor(){if(this.version="6",!Mi){Mi=new Uint8Array(65536),Mi.fill(1),Mi[0]=0,Mi.fill(0,1,32),Mi.fill(0,127,160),Mi.fill(2,4352,4448),Mi[9001]=2,Mi[9002]=2,Mi.fill(2,11904,42192),Mi[12351]=1,Mi.fill(2,44032,55204),Mi.fill(2,63744,64256),Mi.fill(2,65040,65050),Mi.fill(2,65072,65136),Mi.fill(2,65280,65377),Mi.fill(2,65504,65511);for(let e=0;e<fm.length;++e)Mi.fill(0,fm[e][0],fm[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Mi[e]:JM(e,QM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let l=Ya.extractWidth(t);l===0?s=!1:l>n&&(n=l)}return Ya.createPropertyValue(0,n,s)}},Ya=class Wd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new eN;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,l=t.length;for(let c=0;c<l;++c){let d=t.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=l)return n+this.wcwidth(d);let f=t.charCodeAt(c);56320<=f&&f<=57343?d=(d-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let m=this.charProperties(d,s),g=Wd.extractWidth(m);Wd.extractShouldJoin(m)&&(g-=Wd.extractWidth(s)),n+=g,s=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},tN=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function P0(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var lc=2147483647,iN=256,kC=class Og{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>iN)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Og;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let l=t[s];if(Array.isArray(l))for(let c=0;c<l.length;++c)n.addSubParam(l[c]);else n.addParam(l)}return n}clone(){let t=new Og(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,l))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>lc?lc:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>lc?lc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&(t[n]=this._subParams.slice(s,l))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,l=s[n-1];s[n-1]=~l?Math.min(l*10+t,lc):t}},oc=[],nN=class{constructor(){this._state=0,this._active=oc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oc}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=oc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||oc,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Eh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=oc,this._id=-1,this._state=0}}},Kn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Eh(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},cc=[],rN=class{constructor(){this._handlers=Object.create(null),this._active=cc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=cc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=cc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||cc,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Eh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=cc,this._ident=0}},bc=new kC;bc.addParam(0);var I0=class{constructor(e){this._handler=e,this._data="",this._params=bc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():bc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Eh(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=bc,this._data="",this._hitLimit=!1,n));return this._params=bc,this._data="",this._hitLimit=!1,t}},sN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let l=0;l<e.length;l++)this.table[t<<8|e[l]]=n<<4|s}},lr=160,aN=(function(){let e=new sN(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),s=n(32,127),l=n(0,24);l.push(25),l.push.apply(l,n(28,32));let c=n(0,14),d;e.setDefault(1,0),e.addMany(s,0,2,0);for(d in c)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(l,0,3,0),e.addMany(l,1,3,1),e.add(127,1,0,1),e.addMany(l,8,0,8),e.addMany(l,3,3,3),e.add(127,3,0,3),e.addMany(l,4,3,4),e.add(127,4,0,4),e.addMany(l,6,3,6),e.addMany(l,5,3,5),e.add(127,5,0,5),e.addMany(l,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(l,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(l,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(l,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(l,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(l,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(l,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(lr,0,2,0),e.add(lr,8,5,8),e.add(lr,6,0,6),e.add(lr,11,0,11),e.add(lr,13,13,13),e})(),lN=class extends ot{constructor(e=aN){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new kC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Gt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new nN),this._dcsParser=this._register(new rN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,l){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=l}parse(e,t,n){let s=0,l=0,c=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],d=this._oscParser.end(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(s=e[m],l=this._transitions.table[this.currentState<<8|(s<160?s:lr)],l>>4){case 2:for(let w=m+1;;++w){if(w>=t||(s=e[w])<32||s>126&&s<lr){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<lr){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<lr){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<lr){this._printHandler(e,m,w),m=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:m,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(d=g[f](this._params),d!==!0);f--)if(d instanceof Promise)return this._preserveStack(3,g,f,l,m),d;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++m<t&&(s=e[m])>47&&s<60);m--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],b=y?y.length-1:-1;for(;b>=0&&(d=y[b](),d!==!0);b--)if(d instanceof Promise)return this._preserveStack(4,y,b,l,m),d;b<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let w=m+1;;++w)if(w>=t||(s=e[w])===24||s===26||s===27||s>127&&s<lr){this._dcsParser.put(e,m,w),m=w-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,l,m),d;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=m+1;;w++)if(w>=t||(s=e[w])<32||s>127&&s<lr){this._oscParser.put(e,m,w),m=w-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,l,m),d;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},oN=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,cN=/^[\da-f]+$/;function H0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=oN.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),cN.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let l=0;l<3;++l){let c=parseInt(t.slice(n*l,n*l+n),16);s[l]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return s}}function pm(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function uN(e,t=16){let[n,s,l]=e;return`rgb:${pm(n,t)}/${pm(s,t)}/${pm(l,t)}`}var dN={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ia=131072,U0=10;function K0(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var W0=5e3,F0=0,hN=class extends ot{constructor(e,t,n,s,l,c,d,m,g=new lN){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=l,this._oscLinkService=c,this._coreMouseService=d,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ND,this._utf8Decoder=new AD,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xi.clone(),this._eraseAttrDataInternal=xi.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new jg(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:y.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:y,data:b})}),this._parser.setDcsHandlerFallback((f,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:y,payload:b})}),this._parser.setPrintHandler((f,y,b)=>this.print(f,y,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(me.BEL,()=>this.bell()),this._parser.setExecuteHandler(me.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(me.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(me.BS,()=>this.backspace()),this._parser.setExecuteHandler(me.HT,()=>this.tab()),this._parser.setExecuteHandler(me.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(me.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ud.IND,()=>this.index()),this._parser.setExecuteHandler(Ud.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ud.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Kn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Kn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Kn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Kn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Kn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Kn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Kn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Kn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Kn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Kn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Kn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Kn(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Bi)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new I0((f,y)=>this.requestStatusString(f,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),W0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${W0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,l=this._activeBuffer.y,c=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,l=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ia&&(c=this._parseStack.position+ia)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ia&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ia))),d||this._dirtyRowTracker.clearRange(),e.length>ia)for(let f=c;f<e.length;f+=ia){let y=f+ia<e.length?f+ia:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,l,b,f),this._logSlowResolvingAsync(n),n}else if(!d){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,l,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==l)&&this._onCursorMove.fire();let m=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(m,this._bufferService.rows-1)})}print(e,t,n){let s,l,c=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let w=this._parser.precedingJoinState;for(let x=t;x<n;++x){if(s=e[x],s<127&&c){let L=c[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let C=this._unicodeService.charProperties(s,w);l=Ya.extractWidth(C);let D=Ya.extractShouldJoin(C),B=D?Ya.extractWidth(w):0;if(w=C,d&&this._onA11yChar.fire(la(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+l-B>m){if(g){let L=b,O=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&b instanceof _c&&b.copyCellsFrom(L,O,0,B,!1);O<m;)L.setCellFromCodepoint(O++,0,1,y)}else if(this._activeBuffer.x=m-1,l===2)continue}if(D&&this._activeBuffer.x){let L=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-L,s,l);for(let O=l-B;--O>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(f&&(b.insertCells(this._activeBuffer.x,l-B,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,s,l,y),l>0)for(;--l;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=w,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>K0(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new I0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Kn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,l=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),l),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,l=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(l-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Ya.extractWidth(t),l=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(l),d=new Uint32Array(c.length*n),m=0;for(let f=0;f<c.length;){let y=c.codePointAt(f)||0;d[m++]=y,f+=y>65535?2:1}let g=m;for(let f=1;f<n;++f)d.copyWithin(g,0,m),g+=m;return this.print(d,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(me.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(me.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(me.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(me.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(me.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,$a),this._charsetService.setgCharset(1,$a),this._charsetService.setgCharset(2,$a),this._charsetService.setgCharset(3,$a);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let s=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:f,alt:y}=m,b=this._optionsService.rawOptions,w=(D,B)=>(d.triggerDataEvent(`${me.ESC}[${t?"":"?"}${D};${B}$y`),!0),x=D=>D?1:2,C=e.params[0];return t?C===2?w(C,4):C===4?w(C,x(d.modes.insertMode)):C===12?w(C,3):C===20?w(C,x(b.convertEol)):w(C,0):C===1?w(C,x(s.applicationCursorKeys)):C===3?w(C,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):C===6?w(C,x(s.origin)):C===7?w(C,x(s.wraparound)):C===8?w(C,3):C===9?w(C,x(l==="X10")):C===12?w(C,x(b.cursorBlink)):C===25?w(C,x(!d.isCursorHidden)):C===45?w(C,x(s.reverseWraparound)):C===66?w(C,x(s.applicationKeypad)):C===67?w(C,4):C===1e3?w(C,x(l==="VT200")):C===1002?w(C,x(l==="DRAG")):C===1003?w(C,x(l==="ANY")):C===1004?w(C,x(s.sendFocus)):C===1005?w(C,4):C===1006?w(C,x(c==="SGR")):C===1015?w(C,4):C===1016?w(C,x(c==="SGR_PIXELS")):C===1048?w(C,1):C===47||C===1047||C===1049?w(C,x(f===y)):C===2004?w(C,x(s.bracketedPasteMode)):C===2026?w(C,x(s.synchronizedOutput)):w(C,0)}_updateAttrColor(e,t,n,s,l){return t===2?(e|=50331648,e&=-16777216,e|=Zc.fromColorRGB([n,s,l])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],l=0,c=0;do{if(s[c+l]=e.params[t+c],e.hasSubParams(t+c)){let d=e.getSubParams(t+c),m=0;do s[1]===5&&(l=1),s[c+m+1+l]=d[m];while(++m<d.length&&m+c+1+l<s.length);break}if(s[1]===5&&c+l>=2||s[1]===2&&c+l>=5)break;s[1]&&(l=1)}while(++c+t<e.length&&c+l<s.length);for(let d=2;d<s.length;++d)s[d]===-1&&(s[d]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=xi.fg,e.bg=xi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let l=0;l<t;l++)n=e.params[l],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(l)?e.getSubParams(l)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=xi.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=xi.bg&16777215):n===38||n===48||n===58?l+=this._extractColor(e,l,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=xi.fg&16777215,s.bg&=-67108864,s.bg|=xi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${me.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!K0(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${me.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>U0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>U0&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),l=n.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(q0(c))if(l==="?")t.push({type:0,index:c});else{let d=H0(l);d&&t.push({type:1,index:c,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,l=n.findIndex(c=>c.startsWith("id="));return l!==-1&&(s=n[l].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let l=H0(n[s]);l&&this._onColor.fire([{type:1,index:this._specialColors[t],color:l}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let l=parseInt(n[s]);q0(l)&&t.push({type:2,index:l})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,$a),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(dN[e[0]],Bi[e[1]]||$a),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=xi.clone(),this._eraseAttrDataInternal=xi.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new dr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${me.ESC}${d}${me.ESC}\\`),!0),s=this._bufferService.buffer,l=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[l.cursorStyle]-(l.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},jg=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(F0=e,e=t,t=F0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};jg=di([Oe(0,un)],jg);function q0(e){return 0<=e&&e<256}var fN=5e7,$0=12,pN=50,mN=class extends ot{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>fN)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],l=this._action(s,t);if(l){let d=m=>performance.now()-n>=$0?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);l.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(d);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=$0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>pN&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},zg=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,s=this._getEntryIdKey(n),l=this._entriesWithId.get(s);if(l)return this.addLineToLink(l.id,t.ybase+t.y),l.id;let c=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};zg=di([Oe(0,un)],zg);var V0=!1,gN=class extends ot{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ro),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new HM,this.optionsService=this._register(new GM(e)),this._instantiationService.setService(dn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ag)),this._instantiationService.setService(un,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ng)),this._instantiationService.setService(F1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Lg)),this._instantiationService.setService(sl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Bg)),this._instantiationService.setService(W1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ya)),this._instantiationService.setService(jD,this.unicodeService),this._charsetService=this._instantiationService.createInstance(tN),this._instantiationService.setService(OD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(zg),this._instantiationService.setService(q1,this._oscLinkService),this._inputHandler=this._register(new hN(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Zi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Zi.forward(this._bufferService.onResize,this._onResize)),this._register(Zi.forward(this.coreService.onData,this._onData)),this._register(Zi.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new mN((t,n)=>this._inputHandler.parse(t,n))),this._register(Zi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!V0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),V0=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,CC),t=Math.max(t,xC),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(P0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(P0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Gt(()=>{for(let t of e)t.dispose()})}}},_N={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function vN(e,t,n,s){let l={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?l.key=me.ESC+"OA":l.key=me.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?l.key=me.ESC+"OD":l.key=me.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?l.key=me.ESC+"OC":l.key=me.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?l.key=me.ESC+"OB":l.key=me.ESC+"[B");break;case 8:l.key=e.ctrlKey?"\b":me.DEL,e.altKey&&(l.key=me.ESC+l.key);break;case 9:if(e.shiftKey){l.key=me.ESC+"[Z";break}l.key=me.HT,l.cancel=!0;break;case 13:l.key=e.altKey?me.ESC+me.CR:me.CR,l.cancel=!0;break;case 27:l.key=me.ESC,e.altKey&&(l.key=me.ESC+me.ESC),l.cancel=!0;break;case 37:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"D":t?l.key=me.ESC+"OD":l.key=me.ESC+"[D";break;case 39:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"C":t?l.key=me.ESC+"OC":l.key=me.ESC+"[C";break;case 38:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"A":t?l.key=me.ESC+"OA":l.key=me.ESC+"[A";break;case 40:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"B":t?l.key=me.ESC+"OB":l.key=me.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(l.key=me.ESC+"[2~");break;case 46:c?l.key=me.ESC+"[3;"+(c+1)+"~":l.key=me.ESC+"[3~";break;case 36:c?l.key=me.ESC+"[1;"+(c+1)+"H":t?l.key=me.ESC+"OH":l.key=me.ESC+"[H";break;case 35:c?l.key=me.ESC+"[1;"+(c+1)+"F":t?l.key=me.ESC+"OF":l.key=me.ESC+"[F";break;case 33:e.shiftKey?l.type=2:e.ctrlKey?l.key=me.ESC+"[5;"+(c+1)+"~":l.key=me.ESC+"[5~";break;case 34:e.shiftKey?l.type=3:e.ctrlKey?l.key=me.ESC+"[6;"+(c+1)+"~":l.key=me.ESC+"[6~";break;case 112:c?l.key=me.ESC+"[1;"+(c+1)+"P":l.key=me.ESC+"OP";break;case 113:c?l.key=me.ESC+"[1;"+(c+1)+"Q":l.key=me.ESC+"OQ";break;case 114:c?l.key=me.ESC+"[1;"+(c+1)+"R":l.key=me.ESC+"OR";break;case 115:c?l.key=me.ESC+"[1;"+(c+1)+"S":l.key=me.ESC+"OS";break;case 116:c?l.key=me.ESC+"[15;"+(c+1)+"~":l.key=me.ESC+"[15~";break;case 117:c?l.key=me.ESC+"[17;"+(c+1)+"~":l.key=me.ESC+"[17~";break;case 118:c?l.key=me.ESC+"[18;"+(c+1)+"~":l.key=me.ESC+"[18~";break;case 119:c?l.key=me.ESC+"[19;"+(c+1)+"~":l.key=me.ESC+"[19~";break;case 120:c?l.key=me.ESC+"[20;"+(c+1)+"~":l.key=me.ESC+"[20~";break;case 121:c?l.key=me.ESC+"[21;"+(c+1)+"~":l.key=me.ESC+"[21~";break;case 122:c?l.key=me.ESC+"[23;"+(c+1)+"~":l.key=me.ESC+"[23~";break;case 123:c?l.key=me.ESC+"[24;"+(c+1)+"~":l.key=me.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?l.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?l.key=me.NUL:e.keyCode>=51&&e.keyCode<=55?l.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?l.key=me.DEL:e.keyCode===219?l.key=me.ESC:e.keyCode===220?l.key=me.FS:e.keyCode===221&&(l.key=me.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=_N[e.keyCode]?.[e.shiftKey?1:0];if(d)l.key=me.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),l.key=me.ESC+g}else if(e.keyCode===32)l.key=me.ESC+(e.ctrlKey?me.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),l.key=me.ESC+m,l.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(l.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?l.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(l.key=me.US),e.key==="@"&&(l.key=me.NUL));break}return l}var _i=0,bN=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((l,c)=>this._getKey(l)-this._getKey(c)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<s.length;l++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[l]=e[t],t++):s[l]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(_i=this._search(t),_i===-1)||this._getKey(this._array[_i])!==t)return!1;do if(this._array[_i]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(_i),!0;while(++_i<this._array.length&&this._getKey(this._array[_i])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),t=0,n=new Array(this._array.length-e.length),s=0;for(let l=0;l<this._array.length;l++)e[t]===l?t++:n[s++]=this._array[l];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_i=this._search(e),!(_i<0||_i>=this._array.length)&&this._getKey(this._array[_i])===e))do yield this._array[_i];while(++_i<this._array.length&&this._getKey(this._array[_i])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_i=this._search(e),!(_i<0||_i>=this._array.length)&&this._getKey(this._array[_i])===e))do t(this._array[_i]);while(++_i<this._array.length&&this._getKey(this._array[_i])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,l=this._getKey(this._array[s]);if(l>e)n=s-1;else if(l<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},mm=0,Y0=0,yN=class extends ot{constructor(){super(),this._decorations=new bN(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Gt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new SN(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,l=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,l=s+(c.options.width??1),e>=s&&e<l&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,l=>{mm=l.options.x??0,Y0=mm+(l.options.width??1),e>=mm&&e<Y0&&(!n||(l.options.layer??"bottom")===n)&&s(l)})}},SN=class extends da{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ti.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ti.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},wN=1e3,CN=class{constructor(e,t=wN){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let l=s-this._lastRefreshMs,c=this._debounceThresholdMS-l;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},X0=20,ch=class extends ot{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let l=this._coreBrowserService.mainDocument;this._accessibilityContainer=l.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=l.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=l.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new CN(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
29
- `))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Qe(l,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Gt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<X0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
30
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===X0+1&&(this._liveRegion.textContent+=ng.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let l=e;l<=t;l++){let c=n.lines.get(n.ydisp+l),d=[],m=c?.translateToString(!0,void 0,void 0,d)||"",g=(n.ydisp+l+1).toString(),f=this._rowElements[l];f&&(m.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=m,this._rowColumns.set(f,d)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],l=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(l===c||e.relatedTarget!==s)return;let d,m;if(t===0?(d=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(d=this._rowElements.shift(),m=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let l=({node:m,offset:g})=>{let f=m instanceof Text?m.parentNode:m,y=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(f);if(!b)return console.warn("columns is null. Race condition?"),null;let w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++y,w=0),{row:y,column:w}},c=l(t),d=l(n);if(!(!c||!d)){if(c.row>d.row||c.row===d.row&&c.column>=d.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(d.row-c.row)*this._terminal.cols-c.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};ch=di([Oe(1,H_),Oe(2,vs),Oe(3,bs)],ch);var Pg=class extends ot{constructor(e,t,n,s,l){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=l,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Gt(()=>{il(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Qe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Qe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Qe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Qe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let l=n[s];if(l.classList.contains("xterm"))break;if(l.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,l]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):l.provideLinks(e.y,c=>{if(this._isMouseOut)return;let d=c?.map(m=>({link:m}));this._activeProviderReplies?.set(s,d),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let l=t.get(s);if(l)for(let c=0;c<l.length;c++){let d=l[c],m=d.link.range.start.y<e?0:d.link.range.start.x,g=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let f=m;f<=g;f++){if(n.has(f)){l.splice(c--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),l=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(l=!0);if(!l&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&xN(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,il(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,l=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=l&&(this._clearCurrentLink(s,l),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,l=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(l)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,l=t.y*this._bufferService.cols+t.x;return n<=l&&l<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,l){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:l}}};Pg=di([Oe(1,U_),Oe(2,bs),Oe(3,un),Oe(4,V1)],Pg);function xN(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var kN=class extends gN{constructor(e={}){super(e),this._linkifier=this._register(new ro),this.browser=hC,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ro),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(yN),this._instantiationService.setService(Qc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(pM),this._instantiationService.setService(V1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(sg)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Zi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Zi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Zi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Zi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Gt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let l=Ft.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${me.ESC}]${s};${uN(l)}${uC.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Ei.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=Ei.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ch,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,l=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*l,d=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Qe(this.element,"copy",t=>{this.hasSelection()&&RD(t,this._selectionService)}));let e=t=>MD(t,this.textarea,this.coreService,this.optionsService);this._register(Qe(this.textarea,"paste",e)),this._register(Qe(this.element,"paste",e)),fC?this._register(Qe(this.element,"mousedown",t=>{t.button===2&&s0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Qe(this.element,"contextmenu",t=>{s0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),X_&&this._register(Qe(this.element,"auxclick",t=>{t.button===1&&P1(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Qe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Qe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Qe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Qe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Qe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Qe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Qe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Qe(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ig.get()),gC||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(hM,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(vs,this._coreBrowserService),this._register(Qe(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Qe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Eg,this._document,this._helperContainer),this._instantiationService.setService(Th,this._charSizeService),this._themeService=this._instantiationService.createInstance(Mg),this._instantiationService.setService(uo,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ah),this._instantiationService.setService($1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Dg,this.rows,this.screenElement)),this._instantiationService.setService(bs,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Cg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Tg),this._instantiationService.setService(U_,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Pg,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Sg,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Rg,this.element,this.screenElement,s)),this._instantiationService.setService(PD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Zi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(wg,this.screenElement)),this._register(Qe(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ch,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(kg,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?s.mousemove||(t.addEventListener("mousemove",l.mousemove),s.mousemove=l.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",l.wheel,{passive:!1}),s.wheel=l.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Qe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Qe(t,"wheel",c=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let d=me.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){z1(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=vN(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===me.ETX||n.key===me.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(EN(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(xi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(me.ESC+"[I"):this.coreService.triggerDataEvent(me.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[6;${l};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function EN(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var TN=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},DN=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new dr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},G0=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new DN(t)}getNullCell(){return new dr}},RN=class extends ot{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new G0(this._core.buffers.normal,"normal"),this._alternate=new G0(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},MN=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},NN=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},AN=["cols","rows"],Or=0,LN=class extends ot{constructor(e){super(),this._core=this._register(new kN(e)),this._addonManager=this._register(new TN),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,l)=>{this._checkReadonlyOptions(s),this._core.options[s]=l};for(let s in this._core.options){let l={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,l)}}_checkReadonlyOptions(e){if(AN.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new MN(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new NN(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new RN(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
31
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return ig.get()},set promptLabel(e){ig.set(e)},get tooMuchOutput(){return ng.get()},set tooMuchOutput(e){ng.set(e)}}}_verifyIntegers(...e){for(Or of e)if(Or===1/0||isNaN(Or)||Or%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Or of e)if(Or&&(Or===1/0||isNaN(Or)||Or%1!==0||Or<0))throw new Error("This API only accepts positive integers")}};class BN{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():RC.has(t)?this.acceptConsonant(t):MC.has(t)?this.acceptVowel(t):PN(t)&&this.canReplacePendingWith(t)?(this.pending=Q0(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const l=this.flushPending();return this.pending={initial:t},l}if(!this.pending.final){if(NC.has(t))return this.pending.final=t,"";const l=this.flushPending();return this.pending={initial:t},l}const n=zN.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=jN.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=Z0.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const s=this.pending.final,l=J0({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},l}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=Z0.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=Q0(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=J0(this.pending);return this.pending=null,t}}const uh=44032,dh=21,Xl=28,ON=19*dh*Xl,EC=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],TC=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],DC=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],RC=G_(EC),MC=G_(TC),NC=G_(DC),jN=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),AC=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],zN=new Map(AC),Z0=new Map(AC.map(([e,t])=>[t,[e[0],e[1]]]));function G_(e){return new Map(e.map((t,n)=>[t,n]))}function PN(e){const t=e.codePointAt(0);return t!==void 0&&t>=uh&&t<uh+ON}function Q0(e){const t=e.codePointAt(0)-uh,n=Math.floor(t/(dh*Xl)),s=Math.floor(t%(dh*Xl)/Xl),l=t%Xl,c={initial:EC[n],vowel:TC[s]};return l===0?c:{...c,final:DC[l]}}function J0(e){if(!e.vowel)return e.initial;const t=RC.get(e.initial),n=MC.get(e.vowel),s=e.final?NC.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(uh+(t*dh+n)*Xl+s)}const IN=[{key:"interrupt",label:"^C",ariaLabel:"Send Interrupt"},{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function HN({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:s,onHide:l}){function c(d){d.preventDefault(),d.stopPropagation(),s()}return p.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[p.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),IN.map(d=>p.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":d.ariaLabel,onClick:()=>n(d.key),children:d.label},d.key)),p.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:l,children:"×"})]})}const UN={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function KN(e){return UN[e]}function WN(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const LC="--nterminal-viewport-height",BC="--nterminal-keyboard-inset-bottom",OC="data-nterminal-keyboard-visible",Mh="data-nterminal-compose-open",hh="nterminal:viewport-refresh",FN=120;function qN(e=window){const t=e.document.documentElement,n=e.visualViewport,s=ZN(e);function l(){Z_(e)}return l(),n?.addEventListener("resize",l),n?.addEventListener("scroll",l),s?.addEventListener("geometrychange",l),e.addEventListener("resize",l),e.addEventListener(hh,l),e.addEventListener("orientationchange",l),e.addEventListener("pageshow",l),e.document.addEventListener("visibilitychange",l),()=>{n?.removeEventListener("resize",l),n?.removeEventListener("scroll",l),s?.removeEventListener("geometrychange",l),e.removeEventListener("resize",l),e.removeEventListener(hh,l),e.removeEventListener("orientationchange",l),e.removeEventListener("pageshow",l),e.document.removeEventListener("visibilitychange",l),t.style.removeProperty(LC),t.style.removeProperty(BC),t.removeAttribute(OC)}}function Z_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=Ig(e),l=$N(e,s);return l!==null&&ew(t,LC,`${l}px`),ew(t,BC,`${n}px`),VN(t,OC,String(s)),{viewportHeight:l,keyboardInsetBottom:n,keyboardVisible:s}}function Ig(e=window){const t=YN(e);return{keyboardInsetBottom:t,keyboardVisible:t>FN}}function $N(e,t){if((e.document.documentElement.hasAttribute(Mh)||t)&&Qa(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Qa(n)?n:Qa(e.innerHeight)?e.innerHeight:null}function Qa(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ew(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function VN(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function YN(e){return Math.max(XN(e),GN(e))}function XN(e){const t=e.visualViewport?.height;if(!Qa(t)||!Qa(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function GN(e){if(!Qa(e.innerHeight))return 0;const n=jC(e)?.boundingRect?.height;return!Qa(n)||n>=e.innerHeight*.8?0:Math.round(n)}function jC(e){return e.navigator.virtualKeyboard}function ZN(e){const t=jC(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const tu=new Map,Hc=new Map,QN=Object.freeze({open:!1,text:""});function JN(e){let t=Hc.get(e);return t||(t=new Set,Hc.set(e,t)),t}function zC(e){const t=Hc.get(e);if(t)for(const n of Array.from(t))n()}function Nh(e){return tu.get(e)??QN}function eA(e,t){const n=JN(e);return n.add(t),()=>{n.delete(t)}}function tA(e,t){const n=Nh(e);n.open!==t&&(tu.set(e,{...n,open:t}),zC(e))}function iA(e,t){const n=Nh(e);n.text!==t&&(tu.set(e,{...n,text:t}),zC(e))}function Dd(e){tu.delete(e),Hc.delete(e)}function tw(){tu.clear(),Hc.clear()}const PC=120,nA="\x1B[200~",rA="\x1B[201~";function iw(e,t){const n=t.stripTrailingLineBreaks===!1?e:Q_(e),s=aA(n);return s?t.bracketedPasteMode?`${nA}${s}${rA}`:s:""}function sA(e){return e==="queue"?" ":"\r"}function Q_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function aA(e){return e.replace(/\r\n/g,`
32
- `).replace(/\r/g,`
33
- `).replace(/\n/g,"\r")}const lA=420,oA=3e3,nw=650,cA=80,uA=3,Fd=new Set;let Jl=null;function dA({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1}){const l=_.useMemo(()=>O=>eA(e,O),[e]),c=_.useMemo(()=>()=>Nh(e),[e]),d=_.useSyncExternalStore(l,c,c),{open:m,text:g}=d,f=_.useRef(null),y=_.useRef(null),b=_.useRef(null),w=_.useRef(null);_.useEffect(()=>()=>{w.current?.(),w.current=null},[]),_.useLayoutEffect(()=>{if(!(!m||!qd()))return fA(e),()=>pA(e)},[m,e]),_.useLayoutEffect(()=>{const O=f.current?.closest(".terminal-pane");if(!O)return;function Y(){O?.removeAttribute("data-compose-open"),O?.style.removeProperty("--compose-drawer-panel-height")}if(!m){Y();return}const U=y.current;O.setAttribute("data-compose-open","true");function Z(){const ye=U?.getBoundingClientRect().height??0;ye>0&&O?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ye)}px`)}Z();const W=[window.setTimeout(Z,0),window.setTimeout(Z,180),window.setTimeout(Z,260)],re=window.requestAnimationFrame?.(Z)??null,ee=typeof ResizeObserver=="function"&&U?new ResizeObserver(Z):null;return ee&&U&&ee.observe(U),()=>{for(const ye of W)window.clearTimeout(ye);re!==null&&window.cancelAnimationFrame?.(re),ee?.disconnect(),Y()}},[m]),_.useEffect(()=>{if(!m){w.current?.(),w.current=null;return}rw(b.current),L()},[m]);function x(O){tA(e,O)}function C(O){iA(e,O)}function D(){hA(f.current),x(!1),sw()}function B(O="send"){if(!(s||!g)){if(t(g,O),C(""),qd()){b.current?.blur(),sw();return}window.setTimeout(()=>b.current?.focus(),PC+20)}}function L(){qd()&&(w.current?.(),w.current=mA())}return p.jsxs("div",{ref:f,className:"compose-drawer","data-open":m?"true":"false",children:[p.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":m?"true":void 0,tabIndex:m?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>x(!0),children:[p.jsx("span",{"aria-hidden":"true",children:"▴"}),p.jsx("span",{children:"compose"}),g?p.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),p.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":m?void 0:"true",children:[p.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:m?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[p.jsx("span",{"aria-hidden":"true",children:"▾"}),p.jsx("span",{className:"compose-drawer-title",children:"compose"}),p.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),p.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),p.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:m?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:O=>C(O.target.value),onFocus:L,onKeyDown:O=>{if(O.key==="Enter"&&(O.metaKey||O.ctrlKey)){if(O.preventDefault(),O.shiftKey){n&&B("queue");return}B("send");return}O.key==="Escape"&&(O.preventDefault(),D())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),p.jsxs("div",{className:"compose-drawer-actions",children:[p.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:m?0:-1,onClick:()=>{C(""),rw(b.current),L()},disabled:!g,children:"Clear"}),n?p.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:m?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>B("queue"),disabled:s||!g,children:"Queue"}):null,p.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:m?0:-1,onClick:()=>B("send"),disabled:s||!g,children:"Send"})]})]})]})}function hA(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function rw(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function qd(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function sw(){if(!qd())return;const e=Gl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function fA(e){Jl!==null&&(window.clearTimeout(Jl),Jl=null),Fd.add(e),document.documentElement.setAttribute(Mh,"true"),Gl()}function pA(e){if(Fd.delete(e),Fd.size>0||Jl!==null){Gl();return}Jl=window.setTimeout(()=>{if(Jl=null,Fd.size>0){Gl();return}document.documentElement.removeAttribute(Mh),Gl()},lA),Gl()}function mA(){let e=!1,t=null,n=null,s=null,l=0;const c=Date.now(),d=window.visualViewport,m=gA();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function f(){e||(e=!0,g(),d?.removeEventListener("resize",b),d?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(w){if(!e){if(w<nw&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,cA)}}function b(){if(e)return;g();const w=Z_(),x=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===s?l+=1:(l=w.keyboardInsetBottom>0?1:0,s=w.keyboardInsetBottom),x>=oA||x>=nw&&l>=uA){f();return}y(x)}return d?.addEventListener("resize",b),d?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),f}function Gl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Z_()}function gA(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function _A(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(yA(d))return d.preventDefault(),d.stopPropagation(),vA(e),!1;if(bA(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(SA(d)){const m=Hg(e);return m?(d.preventDefault(),d.stopPropagation(),Ug(m),!1):!0}return wA(d)?(d.preventDefault(),d.stopPropagation(),CA(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const l=d=>{const m=Hg(e);if(m){if(d.clipboardData){d.clipboardData.setData("text/plain",m),d.preventDefault();return}d.preventDefault(),Ug(m)}},c=d=>{const m=d.clipboardData?.getData("text/plain");if(!m)return;const g=Q_(m);d.preventDefault(),d.stopImmediatePropagation(),IC(e,g,n.onPasteText)};return s.addEventListener("copy",l,!0),s.addEventListener("paste",c,!0),{dispose(){s.removeEventListener("copy",l,!0),s.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function vA(e){const t=Hg(e);t&&await Ug(t)}function bA(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function yA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function SA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function wA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function CA(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;IC(e,Q_(n),t)}catch{}}function IC(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function Hg(e){return e.hasSelection()?e.getSelection():xA(e.element??null)}function xA(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let s=0;s<t.rangeCount;s+=1){const l=t.getRangeAt(s);if(e.contains(l.commonAncestorContainer))return n}return""}async function Ug(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}kA(e)}function kA(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const EA=[4,10,11,12];function TA(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>aw(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>aw(s)),e.parser.registerCsiHandler({final:"n"},s=>DA(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>RA(s)),e.parser.registerCsiHandler({final:"t"},s=>MA(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...EA.map(s=>e.parser.registerOscHandler(s,l=>NA(l)))];return{dispose(){for(const s of n)s.dispose()}}}function aw(e){return Ah(e)===0}function DA(e){const t=Ah(e);return t===5||t===6}function RA(e){return Ah(e)===6}function MA(e){const t=Ah(e);return t===14||t===16||t===18}function NA(e){return e.split(";").some(t=>t==="?")}function Ah(e){const t=e[0];return typeof t=="number"?t:0}const rl=new Map,AA=2*1024*1024,LA=1500,BA=25e3;function OA(e,t){let n=rl.get(e);n||(n=PA(e),rl.set(e,n),Lh(n)),n.listeners.add(t);const s=c=>FA(n,c),l=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:s,detach:l}}function yc(e){const t=rl.get(e);t&&(qA(t),rl.delete(e))}function jA(e,t={}){const n=rl.get(e);if(!n)return!1;n.exited=!1,n.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(n.preserveCachedOutputOnNextSnapshot=!0),n.reconnectTimer!==null&&(window.clearTimeout(n.reconnectTimer),n.reconnectTimer=null),iu(n);const s=n.socket;return n.socket=null,Va(n,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),Lh(n),!0}function zA(){for(const e of rl.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),iu(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Va(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Lh(e)}}function gm(){for(const e of Array.from(rl.keys()))yc(e)}function PA(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function Lh(e){if(!e.reconnectEnabled)return;Va(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){Va(e,"connected");for(const n of e.pendingOut)t.send(JSON.stringify(n));e.pendingOut.length=0,e.isAlive=!0,IA(e)}}),t.addEventListener("message",n=>{if(e.socket!==t)return;const s=typeof n.data=="string"?n.data:"";if(!s)return;let l=null;try{l=JSON.parse(s)}catch{return}if(!l||typeof l.type!="string")return;if(l.type==="pong"){e.isAlive=!0;return}const c=UA(e,l);HC(e,{type:"message",message:c})}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,iu(e),n.code===1008){e.reconnectEnabled=!1,Va(e,HA(n.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){Va(e,"closed");return}Va(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Lh(e)},LA)}}),t.addEventListener("error",()=>{})}function IA(e){iu(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},BA)}function iu(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function HA(e){return e.trim().toLowerCase()==="unauthorized"}function UA(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,KA(e,t.output),_m(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+s.length,0),_m(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,_m(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function KA(e,t){const n=WA(e.output,t);if(n===0)return;const s=t.slice(n);for(const l of s)e.output.push(l),e.outputBytes+=l.length}function WA(e,t){const n=Math.min(e.length,t.length);for(let s=n;s>0;s-=1){let l=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){l=!1;break}if(l)return s}return 0}function _m(e){for(;e.outputBytes>AA&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Va(e,t){e.status!==t&&(e.status=t,HC(e,{type:"status",status:t}))}function HC(e,t){for(const n of Array.from(e.listeners))n(t)}function FA(e,t){const n=e.socket;return n&&n.readyState===WebSocket.OPEN?(n.send(JSON.stringify(t)),!0):((t.type==="input"||t.type==="cancel_scrollback")&&e.pendingOut.push(t),!1)}function qA(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),iu(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const $A=[0,50,150,350],VA=2,YA=[300,1200,2500],XA=1e3,GA=1e5,ZA="",Kg="\x1B[?1049l\x1B[?1047l\x1B[?47l",QA=new Set(["47","1047","1049"]),JA=400,eL=3,tL=3,iL=32,nL=1.42,rL=2,sL=24,aL=240,lL=60,oL=420,cL=6,uL=2,lw=[500,1500,3e3,5e3,8e3],ow=15e3,dL=1e3,cw="Do not take action. Wait for my next input.",fh=6e4,hL=fh+5*6e4,uw=fh+6e4,fL=40,Rd=240,pL=5e3,mL=Ai.lazy(()=>I_(()=>import("./TranscriptMarkdownBody-B-RKybd7.js"),__vite__mapDeps([2,1]))),Nc=new Map,Vl=new Map;function dw({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:l,refreshCwdOnEnter:c=!1,tabId:d,codeServerContext:m,onSelect:g,onClose:f,onExit:y,onSnapshot:b,onAuthClose:w}){const x=_.useSyncExternalStore(S1,$m,()=>Ga),C=_.useSyncExternalStore(w1,Vm,()=>io),D=_.useSyncExternalStore(C1,Xm,()=>!0),B=_.useSyncExternalStore(zd,Gm,()=>!0),L=_.useSyncExternalStore(zd,Zm,()=>!0),O=_.useSyncExternalStore(f_,ha,()=>to),Y=_.useSyncExternalStore(th,()=>ih("history.toggle"),()=>"Alt+H"),U=_.useSyncExternalStore(th,()=>ih("scrollback.toggle"),()=>"Alt+S"),Z=_.useRef(null),W=_.useRef(null),re=_.useRef(null),ee=_.useRef(null),ye=_.useRef({onExit:y,onSnapshot:b}),Ee=_.useRef(t.createWebSocketUrl),ne=_.useRef(w),q=_.useRef(null),Q=_.useRef(null),K=_.useRef(null),se=_.useRef(!1),A=_.useRef(new Map),R=_.useRef([]),P=_.useRef(null),ie=_.useRef(0),ge=_.useRef(!1),M=_.useRef(!1),X=_.useRef(!1),ue=_.useRef({terminalId:e.id,enabled:!1}),be=_.useRef([]),ve=_.useRef([]),xe=_.useRef(0),Re=_.useRef(!1),Me=_.useRef(null),ze=_.useRef(0),Pe=_.useRef(null),ce=_.useRef(null),_e=_.useRef(!1),Se=_.useRef(!1),Ae=_.useRef(!1),Ue=_.useRef(!1),Be=_.useRef(null),ae=_.useRef(null),Te=_.useRef(!1),we=_.useRef(!1),Le=_.useRef(!1),Ve=_.useRef(!1),Je=_.useRef(!1),ct=_.useRef(!1),wt=_.useRef(!1),qi=_.useRef(n),Oi=_.useRef(s),ii=_.useRef(c),le=_.useRef(x),je=_.useRef(C),Ze=_.useRef(!1),Ge=_.useRef(null),It=_.useRef(e.id),Ct=_.useRef(()=>{}),xt=_.useRef(null),Ht=_.useRef(null),F=_.useRef(!1),We=_.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),gt=_.useRef(0),vi=_.useRef(null),Tn=_.useRef(0),ni=_.useRef(null),_t=_.useRef(0),kt=_.useRef(!1),Pt=_.useRef(!1),Rt=_.useRef(null),[,Ut]=_.useState("connecting"),[ri,hi]=_.useState(!1),[Zt,qt]=_.useState(null),[Qi,si]=_.useState(!1),[Ti,Ji]=_.useState(null),[hn,ji]=_.useState(!1),[Dn,bi]=_.useState(!1),[fi,$t]=_.useState(!1),[hr,ys]=_.useState(!1),[Qt,fr]=_.useState(null),$i=e.agentCache&&Qt&&e.agentCache.source.provider===Qt.provider&&e.agentCache.source.sessionId===Qt.sessionId?e.agentCache:null,[pr,Hr]=_.useState(()=>Date.now()),[fn,qn]=_.useState(!1),[xr,$n]=_.useState(null),[Vt,Ur]=_.useState(!1),[en,pn]=_.useState(null),[mr,Kr]=_.useState(!1),[_a,Wr]=_.useState(!1),[mo,mn]=_.useState(null),[Fr,gn]=_.useState(null),ai=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[ol,va]=_.useState(()=>Jp(e.id)),Ss=!!Qt||Sc(e.currentCommand),qr=Qt?.provider==="claude"||qC(e.currentCommand),ws=!!Qt||Sc(e.currentCommand),Rn=e.capabilities?.tmuxScrollback===!0,Xe=Rn&&(ol??(ws?L:B)),[Cs,kr]=_.useState(!1);_.useLayoutEffect(()=>{qi.current=n},[n]),_.useLayoutEffect(()=>{Oi.current=s},[s]),_.useLayoutEffect(()=>{ii.current=c},[c]),_.useLayoutEffect(()=>{le.current=x},[x]),_.useLayoutEffect(()=>{je.current=C},[C]),_.useLayoutEffect(()=>{Ze.current=Vt},[Vt]),_.useLayoutEffect(()=>{Ge.current=Qt},[Qt]);const Vn=_.useCallback((E,I={})=>{!E&&I.preserveOnNull||fr(Ne=>Ne&&E&&Ne.provider===E.provider&&Ne.sessionId===E.sessionId?Ne:E)},[]),$r=_.useCallback(async(E={})=>{const I=await t.getTerminalTranscriptSource(e.id);return Vn(I.source,E),I.source},[Vn,t,e.id]),xs=_.useCallback(()=>{Ge.current&&(async()=>{let E=Ge.current;try{E=await $r({preserveOnNull:!0})??E}catch{}E&&(xt.current=_w(e.id,E),Ur(!0))})()},[$r,e.id]),_n=_.useCallback(async(E={})=>{const I=await fw(ai,t,E);return pn(I),I},[ai,t]),Mn=_.useCallback((E,I="info")=>{ni.current!==null&&window.clearTimeout(ni.current),gn({id:Tn.current++,message:E,tone:I}),ni.current=window.setTimeout(()=>{gn(null),ni.current=null},3200)},[]),ba=_.useCallback(()=>{const E=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Ne=m?.tabName.trim()||e.title||"Terminal",Ke=en?.instances.find(ht=>ht.cwd===e.cwd);if(Ke&&pw(Md(E,Ke.id))){Mn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Ke&&vm(Md(E,Ke.id),Ke.url)){Mn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Fe=null;const rt=()=>((!Fe||mw(Fe))&&(Fe=window.open("about:blank","_blank"),gL(Fe)),Fe);en?.installed!==!0&&rt(),Wr(!0),mn(null),(async()=>{let ht=en;if(ht?.installed||(ht=await _n({force:!0})),!ht?.installed||ht.supported===!1){Nd(Fe),Kr(!0);return}const Ot=ht.instances.find(Xn=>Xn.cwd===e.cwd);if(Ot&&(Nd(Fe),vm(Md(E,Ot.id),Ot.url))){Mn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}const vt=rt();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Ne}),targetPopup:vt}})().then(ht=>{if(!ht)return;const{response:Ot,targetPopup:vt}=ht;Wg(ai,Ot.status),pn(Ot.status);const Yt=Md(E,Ot.instance.id);if(pw(Yt)){Nd(vt),Mn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}const Xn=UC(Yt);vt&&!mw(vt)?(vt.name=Xn,vt.location.href=Ot.url,Nc.set(Yt,vt),vt.focus(),Mn("Opening VS Code...")):vm(Yt,Ot.url)?Mn("Opening VS Code..."):Mn("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ht=>{Nd(Fe),Kr(!0),mn(Ad(ht))}).finally(()=>Wr(!1))},[m?.serverName,m?.tabName,ai,en,_n,t,Mn,e.cwd,e.id,e.title]);_.useEffect(()=>{let E=!1;return fw(ai,t).then(I=>{E||pn(I)}).catch(()=>{}),()=>{E=!0}},[ai,t]),_.useEffect(()=>{if(en?.job?.status!=="running")return;const E=window.setInterval(()=>{_n({force:!0}).catch(I=>mn(Ad(I)))},1e3);return()=>window.clearInterval(E)},[en?.job?.status,_n]),_.useEffect(()=>()=>{ni.current!==null&&window.clearTimeout(ni.current)},[]),_.useLayoutEffect(()=>{Ct.current=xs},[xs]),_.useLayoutEffect(()=>{Ht.current=$i},[$i]),_.useLayoutEffect(()=>{F.current=fn},[fn]),_.useLayoutEffect(()=>{kt.current=Ss},[Ss]),_.useLayoutEffect(()=>{Pt.current=qr},[qr]),_.useLayoutEffect(()=>{const E=ue.current;M.current=Xe,X.current=Rn,ue.current={terminalId:e.id,enabled:Xe},Sw(Z.current,Xe),E.terminalId===e.id&&E.enabled&&!Xe&&Kh(),Xe||$t(!1)},[e.id,Xe,Rn]),_.useEffect(()=>{va(Jp(e.id)),ie.current=0,ge.current=!1,$t(!1),hl()},[e.id]),_.useEffect(()=>zd(()=>{va(Jp(e.id))}),[e.id]),_.useEffect(()=>()=>{du()},[]),_.useEffect(()=>{s&&n&&e.status==="running"&&(Et(),Dr("auto"))},[n,s,e.status]),_.useEffect(()=>{ye.current={onExit:y,onSnapshot:b}},[y,b]),_.useEffect(()=>{Ee.current=t.createWebSocketUrl,ne.current=w},[t,w]),_.useEffect(()=>{let E=!1,I=null,Ne=0;const Ke=qL(e.currentCommand),Fe=Sc(e.currentCommand);function rt(){I!==null&&(window.clearTimeout(I),I=null)}function ht(vt){if(E)return;let Yt;if(vt)Yt=ow;else if(Ne<lw.length){if(!Ke)return;Yt=lw[Ne++]}else{if(!Fe)return;Yt=ow}I=window.setTimeout(()=>{I=null,Ot()},Yt)}async function Ot(){try{const vt=Ge.current!==null,Yt=await $r({preserveOnNull:vt});if(E)return;!Yt&&vt&&!Ke&&(Ge.current=null,fr(null)),ht(!!Yt||vt&&Ke)}catch(vt){if(E)return;bm(vt)&&(Ge.current=null,fr(null)),ht(!1)}}return It.current!==e.id&&(It.current=e.id,Ge.current=null,fr(null)),e.status!=="running"?(Ge.current=null,fr(null),()=>{E=!0,rt()}):(Ot(),()=>{E=!0,rt()})},[t,e.currentCommand,e.id,e.status]),_.useEffect(()=>{const E=_w(e.id,Qt),I=xt.current;I!==null&&E!==null&&I!==E&&Ze.current&&Ur(!1),xt.current=E},[e.id,Qt?.provider,Qt?.sessionId]),_.useEffect(()=>{if(e.status!=="running"||!Qt){qn(!1);return}const E=window.setInterval(()=>{Hr(Date.now())},dL);return()=>{window.clearInterval(E)}},[e.status,Qt?.provider,Qt?.sessionId]),_.useEffect(()=>{const E=bL($i);We.current.key!==E&&(We.current={key:E,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[$i?.expiresAt,$i?.source?.provider,$i?.source?.sessionId]),_.useEffect(()=>{if(!fn||!$i||$i.status!=="ready")return;const E=KC($i,pr);if(E===null||E<=0)return;const I=We.current;!I.warnedFiveMinutes&&E<=hL&&E>uw&&(I.warnedFiveMinutes=!0,Gr({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!I.warnedOneMinute&&E<=uw&&E>fh&&(I.warnedOneMinute=!0,Gr({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&E<=fh&&Ds()},[fn,pr,$i,e.activity,e.agentStatus?.state,e.status]),_.useEffect(()=>{function E(I){if(!qi.current||!Oi.current||I.isComposing||I.key==="Process"||wL(I.target))return;const Ne=T1(I);if(Ne?.id==="history.toggle"&&Ge.current){I.preventDefault(),I.stopPropagation(),Ze.current?Ur(!1):Ct.current();return}if(Ne?.id==="scrollback.toggle"&&X.current){I.preventDefault(),I.stopPropagation(),uu();return}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[]),_.useEffect(()=>{const E=W.current;E&&(E.options.disableStdin=e.status==="exited"),e.status==="exited"&&Ut("closed")},[e.status]),_.useEffect(()=>{const E=W.current;E&&(E.options.fontSize=x,Qp(x,je.current).then(()=>{le.current===x&&Et()}))},[x]),_.useEffect(()=>{const E=W.current;E&&(E.options.fontFamily=qm(C),Qp(le.current,C).then(()=>{je.current===C&&Et()}))},[C]),_.useEffect(()=>{const E=W.current;E&&(E.options.theme=hw(O))},[O]),_.useEffect(()=>{const E=Z.current;if(!E)return;let I=!1,Ne=null,Ke=null,Fe=null,rt=null,ht=null,Ot=null,vt=null;q.current=null,Je.current=!1,ct.current=!1,Ue.current=!1,pi(),ks();const Yt=le.current,Xn=je.current,bn=new LN({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:qm(Xn),fontSize:Yt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:GA,theme:{...hw(ha())}}),gu=new xD;return bn.loadAddon(gu),rt=TA(bn),W.current=bn,re.current=gu,Qp(Yt,Xn).then(()=>{if(I)return;bn.open(E),Sw(E,M.current),Je.current=!0,Ne=_A(bn,{onPasteText:fu,onInterrupt:wo,shouldInterruptPlainCtrlC:()=>Pt.current}),Oi.current&&qi.current&&e.status==="running"&&Dr("auto"),Et(),ht=e3(E,bn,()=>le.current*1.2,S,Rr=>{Nn(Rr)},_o,vo,()=>M.current,lu),Ot=ZL(E,bn,S,Rr=>{Nn(Rr)},_o,vo,()=>M.current,lu);const Yh=new BN;Ke=bn.onData(Rr=>{if(wt.current){const Ns=WN(Rr);if(Ns){fl(!1),_r(Ns);return}}const nn=Yh.accept(Rr);nn&&_r(nn)}),Fe=bn.onScroll(Rr=>{if(we.current||Ve.current||Le.current){T();return}pe(),Sr(bn)&&it({scrollToBottom:!0}),S(),!M.current&&Rr<=3&&Nn()}),vt=new ResizeObserver(()=>{Ca()}),vt.observe(E),ct.current&&(Vr(),ct.current=!1,Et()),Tr()}),()=>{ou(ee.current,{updateUi:!1}),I=!0,Je.current=!1,ct.current=!1,pi(),Q.current=null,K.current=null,se.current=!1,Yn(),J(),Le.current=!1,ht?.(),Ot?.(),vt?.disconnect(),Ne?.dispose(),Ke?.dispose(),Fe?.dispose(),rt?.dispose(),bn.dispose(),W.current=null,re.current=null}},[e.id]),_.useEffect(()=>{const E=Ee.current(e.id),I=OA(E,cl);return ee.current=I.send,Ut(I.status),I.status==="connected"&&Et(),I.snapshot&&(ye.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),W.current&&(Et(),ya(I.output,I.history),Et())),()=>{ou(I.send,{updateUi:!1}),I.detach(),ee.current=null}},[e.id,e.status]);function cl(E){if(E.type==="status"){Ut(E.status),E.status==="unauthorized"&&ne.current?.({source:"terminal-ws-1008",terminalId:e.id}),E.status==="connected"&&Et();return}Sa(E.message)}function ks(E=[],I=null){be.current=[],ve.current=Ld(E),xe.current=0,Re.current=!1,Me.current=null,Le.current=!1,ze.current+=1,Pe.current=I,ce.current=null,_e.current=!1,Se.current=!1,Ae.current=!1,ct.current=!1,Rt.current=null,Be.current=null,Te.current=!1,hi(!1),qt(null),si(!1),Ji(null),ji(!1),bi(!1)}function ya(E=[],I=null){ks(E,I),go()}function go(){if(!W.current||!Je.current){ct.current=!0;return}ct.current=!1,Vr()}async function Vr(){const E=W.current;if(!E)return;const I=Bd(E,Te.current),Ne=I?ve.current.length:xe.current;await vn(E,{liveOutputLimit:Ne,scrollToBottom:I}),W.current===E&&T()}function vn(E,I={}){return new Promise(Ne=>{Le.current=!0,Re.current=!1;const Ke=ze.current+1;ze.current=Ke;const Fe=Math.max(0,Math.min(I.liveOutputLimit??ve.current.length,ve.current.length)),rt=I.historyPages??be.current,ht=()=>{if(W.current!==E||ze.current!==Ke){Ne(!1);return}try{xe.current=Fe,I.scrollToBottom&&ul(E)}finally{Le.current=!1;const vt=$e();vt?it(vt):I.applyDeferredSnapshot!==!1&&nu(),Ne(!0)}},Ot=()=>{if(W.current!==E||ze.current!==Ke){Ne(!1);return}E.clear();const vt=Ld([...rt,...ve.current.slice(0,Fe)]);if(vt.length===0){ht();return}for(let Yt=0;Yt<vt.length;Yt+=1){const Xn=vt[Yt];Yt===vt.length-1?E.write(Xn,ht):E.write(Xn)}};if(E.buffer.active.type==="alternate"){E.write(Kg,Ot);return}Ot()})}async function Nn(E=0){const I=W.current;if(Ae.current||!I)return;if(li(I)){T();return}const Ne=Pe.current;Ae.current=!0,hi(!0);const Ke=I.buffer.active.viewportY;try{let Fe=!!(Ne&&!Ne.hasMore);if(!Fe)try{const rt=await t.getTerminalHistory(e.id,{beforeLine:Ne?.startLine??0,limit:XA}),ht={startLine:rt.startLine,endLine:rt.endLine,hasMore:rt.hasMore};if(rt.output.length>0){await zi(I,rt.output,Ke,E)&&(Pe.current=ht);return}Pe.current=ht,Fe=!rt.hasMore}catch(rt){Fe=bm(rt)}if(Fe){if(li(I)){T();return}await Es(I,Ke,E)}}catch{}finally{Ae.current=!1,hi(!1)}}async function Es(E,I,Ne){if(!(_e.current||Se.current))try{const Ke=ce.current,Fe=await t.getTerminalTranscriptHistory(e.id,{...Ke?{cursor:Ke}:{},limit:JA}),rt=Fe.output.map($C);if(!Fe.source)return;if(rt.length===0){fr(Fe.source),ce.current=Fe.cursor,Se.current=!Fe.hasMore||!Fe.cursor;return}await zi(E,rt,I,Ne)&&(fr(Fe.source),ce.current=Fe.cursor,Se.current=!Fe.hasMore||!Fe.cursor)}catch(Ke){bm(Ke)&&(_e.current=!0)}}async function zi(E,I,Ne,Ke){if(li(E))return T(),!1;const Fe=[...I,...be.current],rt=XL(I);return!await vn(E,{liveOutputLimit:xe.current,scrollToBottom:!1,historyPages:Fe,applyDeferredSnapshot:!1})||W.current!==E?!1:(be.current=Fe,ru(E,Math.max(0,Ne+rt+Math.min(0,Ke))),Te.current=!Sr(E),S(),!0)}_.useEffect(()=>{const E=window.visualViewport;function I(){document.visibilityState==="visible"&&Et()}function Ne(){Et()}function Ke(){Ca()}function Fe(){Ln()}return document.addEventListener("visibilitychange",I),window.addEventListener("pageshow",Ne),window.addEventListener("resize",Ke),window.addEventListener(hh,Fe),E?.addEventListener("resize",Ke),E?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",I),window.removeEventListener("pageshow",Ne),window.removeEventListener("resize",Ke),window.removeEventListener(hh,Fe),E?.removeEventListener("resize",Ke),E?.removeEventListener("scroll",Ke)}},[e.id]);function An(){const E=Ee.current(e.id);Ue.current=!0,Rt.current=null,Ut("reconnecting"),Et(),jA(E,{preserveCachedOutputOnNextSnapshot:!0})}function Sa(E){if(E.type==="snapshot"&&E.terminal.id===e.id){ye.current.onSnapshot(E.terminal,{notifyCompletion:!1});const Ne=W.current;if(!Ne)return;Et();const Ke=Ue.current;if(Ue.current=!1,Ke){Pe.current=E.history??Pe.current,T(),Et();return}if(Jt(Ne,E.terminal)){Ph(E.output,E.history??null),T(),Et();return}ya(E.output,E.history??null),Et();return}if(E.type==="terminal_updated"&&E.terminal.id===e.id){ye.current.onSnapshot(E.terminal,{notifyCompletion:!0});return}if(E.type==="output"&&E.terminalId===e.id){const Ne=XC(E.data);if(!Ne)return;ve.current.push(Ne),W.current&&Je.current?it({scrollToBottom:!0}):ct.current=!0;return}const I=W.current;if(I){if(E.type==="exit"&&E.terminalId===e.id){ye.current.onExit(E.exitCode),Ut("closed");return}E.type==="error"&&I.writeln(`\r
34
- [nterminal] ${E.message}`)}}function wa(E=25){if(document.visibilityState==="hidden"||!Oi.current||A.current.has(E))return;const I=window.setTimeout(()=>{A.current.delete(E),!Er()&&Uh()},E);A.current.set(E,I)}function Ca(){Er()||Tr()}function Er(){const E=ln();return E&&xa(E)?(se.current=!0,K.current=E,!0):E&&Yr(E)?(se.current=!1,K.current=null,!0):((!E||!E.composeOpen&&!E.keyboardVisible)&&(se.current=!1,K.current=null),!1)}function Ln(){if(!se.current)return;const E=ln();E&&(E.composeOpen||E.keyboardVisible)||(se.current=!1,K.current=null)}function xa(E){if(!E.mobileLike||!E.composeOpen&&!E.keyboardVisible)return!1;const I=Q.current;return I?Bn(E.windowWidth,I.windowWidth)&&Bn(E.visualViewportWidth,I.visualViewportWidth)&&Bn(E.containerWidth,I.containerWidth):!1}function Yr(E){if(!E.mobileLike||E.composeOpen||E.keyboardVisible)return!1;const I=K.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:Bn(E.windowWidth,I.windowWidth)&&Bn(E.visualViewportWidth,I.visualViewportWidth)&&Bn(E.containerWidth,I.containerWidth)}function ln(){const E=Z.current;if(!E||E.isConnected===!1)return null;const I=E.getBoundingClientRect(),Ne=gr(window.innerWidth)??0,Ke=gr(window.visualViewport?.width)??Ne,Fe=gr(I.width)??gr(E.clientWidth)??Ne;if(Ne<=0||Ke<=0||Fe<=0)return null;const{keyboardVisible:rt}=Ig(),ht=document.documentElement.hasAttribute(Mh),Ot=ka()||rt;return{windowWidth:Ne,visualViewportWidth:Ke,containerWidth:Fe,composeOpen:ht,keyboardVisible:rt,mobileLike:Ot}}function ka(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Ts(){return Ig().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function gr(E){return typeof E=="number"&&Number.isFinite(E)&&E>0?E:null}function Bn(E,I){return Math.abs(E-I)<=VA}function Tr(){for(const E of $A)wa(E)}function Et(){q.current=null,Tr()}function pi(){for(const E of A.current.values())window.clearTimeout(E);A.current.clear()}function Yn(){for(const E of R.current)window.clearTimeout(E);R.current=[]}function S(){if(T(),!Be.current){si(!1);return}si(!0),J(),ae.current=window.setTimeout(()=>{ae.current=null,si(!1)},1200)}function T(){const E=W.current,I=E?GL(E):null;if(Be.current=I,qt(I),bi(!!(E&&I)),ji(!!(E&&I&&!Sr(E))),I||!E||!j()){Ji(null);return}Ji({alternate:E.buffer.active.type==="alternate"})}function j(){const E=Pe.current;return be.current.length>0||!!E?.hasMore}function J(){ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null)}function pe(){const E=W.current;E&&(Te.current=!Sr(E),T())}function de(E){Me.current=ym(Me.current,E)}function Ce(E){const I=Me.current;return Me.current=null,ym(I,E)}function $e(){const E=Me.current;return Me.current=null,E}function it(E={}){const I=W.current;if(!I||!Je.current){ct.current=!0;return}if(Le.current){de(E);return}if(Re.current){de(E);return}const Ne=Ce(E);if(!Ne.force&&!Bd(I,Te.current)){T();return}Re.current=!0;const Ke=ze.current,Fe=()=>{if(W.current!==I||ze.current!==Ke){Re.current=!1;return}if(!Ne.force&&!Bd(I,Te.current)){Re.current=!1,T();return}const rt=xe.current,ht=ve.current[rt];if(ht===void 0){Re.current=!1,Ne.scrollToBottom&&ul(I),T();const Ot=$e();Ot?it(ym(Ne,Ot)):nu();return}I.write(ht,()=>{if(W.current!==I||ze.current!==Ke){Re.current=!1;return}xe.current=rt+1,Fe()})};Fe()}function li(E){return!Sr(E)&&(Xr()||Re.current||Le.current)}function Jt(E,I){return(kt.current||Sc(I?.currentCommand))&&!Sr(E)}function Xr(){return xe.current<ve.current.length}function Ph(E,I){Rt.current={output:E,history:I,appendFromLiveOutputIndex:xe.current}}function nu(){const E=W.current,I=Rt.current;if(!E||!I||!Sr(E)||Xr()||Re.current||Le.current)return;const Ne=Ld(I.output),Ke=Ld(ve.current.slice(I.appendFromLiveOutputIndex));Rt.current=null,ya(YL(Ne,Ke),I.history),Et()}function _o(){Ve.current=!0}function vo(){pe(),Ve.current=!1;const E=W.current;E&&Sr(E)&&it({scrollToBottom:!0})}function ul(E){su(()=>ww(E))&&(Te.current=!1)}function ru(E,I){su(()=>(E.scrollToLine(I),!0))}function su(E){we.current=!0;try{return E()}finally{we.current=!1}}function Ih(){const E=W.current;if(!E)return;const I=()=>{M.current&&(cu(ee.current),$t(!1)),ww(E),Te.current=!1,T(),it({force:!0,scrollToBottom:!0}),Dr("scroll-action")};if(E.buffer.active.type==="alternate"){E.write(Kg,I);return}I()}function au(E){const I=W.current,Ne=Z.current;if(!I||!Ne)return;const Ke=Ne.getBoundingClientRect();if(Ke.height<=0)return;const Fe=Math.max(0,Math.min(1,(E-Ke.top)/Ke.height)),rt=Math.round(I.buffer.active.baseY*Fe);_o();try{I.scrollToLine(rt)}finally{vo()}Te.current=!Sr(I),T(),S(),rt<=3&&Nn()}function Hh(E){E.preventDefault(),E.stopPropagation(),E.currentTarget.setPointerCapture?.(E.pointerId),au(E.clientY)}function bo(E){(E.buttons&1)!==0&&(E.preventDefault(),E.stopPropagation(),au(E.clientY))}function Uh(){const E=W.current,I=re.current;if(!(!E||!I)&&!(document.visibilityState==="hidden"||!Oi.current||Z.current?.isConnected===!1))try{const Ne=Bd(E,Te.current),Ke=ln();I.fit(),Ke&&(Q.current=Ke),Ne&&ul(E),E.refresh(0,Math.max(0,E.rows-1)),T();const Fe={cols:E.cols,rows:E.rows},rt=q.current;if(rt&&rt.cols===Fe.cols&&rt.rows===Fe.rows)return;dl({type:"resize",terminalId:e.id,cols:Fe.cols,rows:Fe.rows})&&(q.current=Fe)}catch{}}function dl(E){const I=ee.current;return I?I(E):!1}function hl(){P.current!==null&&(window.clearTimeout(P.current),P.current=null)}function yo(){hl();const E=Math.max(-Rd,Math.min(Rd,ie.current));if(ie.current=0,E===0)return!1;const I=dl({type:"scrollback_scroll",terminalId:e.id,lines:E});return I&&(ge.current=!0,E<0&&$t(!0)),I}function lu(E){if(!M.current||E===0)return;const I=ie.current+E;ie.current=Math.max(-Rd,Math.min(Rd,I)),P.current===null&&(P.current=window.setTimeout(()=>{P.current=null,yo()},fL))}function Kh(){cu(ee.current)}function ou(E=ee.current,I={}){const Ne=ge.current;hl(),ie.current=0,ge.current=!1,I.updateUi!==!1&&$t(!1),Ne&&E?.({type:"cancel_scrollback",terminalId:e.id})}function cu(E){hl(),ie.current=0,ge.current=!1,$t(!1),E?.({type:"cancel_scrollback",terminalId:e.id})}function uu(){if(!X.current)return;const E=!M.current;va(L2(e.id,E)),hu()}function Wh(){const E=!F.current;F.current=E,qn(E),Gr({tone:E?"info":"skipped",message:E?"Cache keep-alive enabled":"Cache keep-alive off",...E?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function du(){vi.current!==null&&(window.clearTimeout(vi.current),vi.current=null)}function Gr(E,I={}){du();const Ne=gt.current+1;gt.current=Ne,$n({...E,id:Ne}),!I.sticky&&(vi.current=window.setTimeout(()=>{vi.current=null,$n(Ke=>Ke?.id===Ne?null:Ke)},12e3))}function Fh(){We.current.skipped=!0,Gr({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function So(){F.current=!1,qn(!1),Gr({tone:"skipped",message:"Cache keep-alive off"})}async function Ds(){const E=We.current;if(E.sent||E.skipped)return;const I=qh();if(E.sent=!0,I){Gr({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}_r(`${cw}\r`,{userInitiated:!1}),Gr({tone:"success",message:"Cache keep-alive sent",detail:cw})}function qh(){const E=Ht.current,I=Ge.current;return F.current?e.status!=="running"?"Pane is not running.":!E||E.status!=="ready"||!E.source||!I?"Transcript cache status is unavailable.":E.source.provider!==I.provider||E.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Uc(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Nh(e.id).text.trim()?"Compose has an unsent draft.":CL(Z.current)?"Pane input is focused.":Date.now()-_t.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function hu(){const E=W.current;E&&(ul(E),T())}function _r(E,I={}){I.userInitiated!==!1&&(_t.current=Date.now()),yo();const Ne=ge.current;ge.current=!1,Ne&&$t(!1),it({force:!0,scrollToBottom:!0}),dl({type:"input",terminalId:e.id,data:E,...Ne?{cancelScrollbackMode:!0}:{}})&&FL(E)&&Rs()}function wo(){wt.current&&fl(!1),_r(ZA)}function fu(E){const I=iw(E,{bracketedPasteMode:W.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&_r(I)}function pu(E,I){const Ne=iw(E,{bracketedPasteMode:W.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ne&&_r(Ne),window.setTimeout(()=>_r(sA(I)),PC)}function Rs(){!ii.current||!qi.current||(Yn(),R.current=YA.map(E=>{const I=window.setTimeout(()=>{R.current=R.current.filter(Ne=>Ne!==I),ii.current&&qi.current&&dl({type:"refresh_cwd",terminalId:e.id})},E);return I}))}function Dr(E="terminal-interaction"){Ze.current||Ts()&&(E==="auto"||E==="scroll-action")||W.current?.focus()}const $h=_.useCallback(()=>{Ur(!1)},[]);function Vh(){ys(E=>{const I=!E;return wt.current=I,I}),Dr("input-action")}function fl(E){wt.current=E,ys(E)}function mu(E){wt.current&&fl(!1),_r(KN(E)),Dr("input-action")}async function Ms(E="install"){Wr(!0),mn(null);try{const I=E==="update"?await t.updateCodeServer():await t.installCodeServer();Wg(ai,I.status),pn(I.status)}catch(I){mn(Ad(I))}finally{Wr(!1)}}return p.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Xe?"true":"false",onMouseDown:()=>{n||g()},children:[p.jsx(xL,{terminal:e,canClose:l,tabId:d,transcriptSource:Qt,transcriptShortcutLabel:Y,transcriptCacheStatus:$i,transcriptCacheNow:pr,cacheKeepAliveEnabled:fn,codeServerAvailable:!0,codeServerInstallState:en===null?"unknown":en.installed?"installed":"missing",codeServerBusy:_a||en?.job?.status==="running",codeServerSupported:en?.supported!==!1,scrollbackShortcutLabel:U,tmuxScrollbackSupported:Rn,tmuxScrollbackEnabled:Xe,onToggleCacheKeepAlive:Wh,onOpenCodeServer:ba,onToggleTmuxScrollback:uu,onOpenTranscript:xs,onInterrupt:wo,onReload:An,onClose:f}),p.jsx("div",{className:"xterm-container",ref:Z}),ri?p.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:p.jsx("span",{"aria-hidden":"true"})}):null,D&&!Xe&&Zt?p.jsxs("div",{className:"terminal-scroll-progress","data-active":Qi,"aria-hidden":"true",children:[Zt.current,"/",Zt.total]}):D&&!Xe&&Ti?p.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ti.alternate?"alternate":"normal","aria-hidden":"true",children:[Ti.alternate?"alt ":"","0/?"]}):null,hn||Xe&&fi?p.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),Ih()},children:"↓"}):null,Dn&&!Xe?p.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Hh,onPointerMove:bo,children:p.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Cs?p.jsx(HN,{ctrlActive:hr,onCtrl:Vh,onStandaloneKey:mu,onPreserveFocus:()=>Dr("input-action"),onHide:()=>kr(!1)}):p.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:E=>{E.stopPropagation(),Dr("input-action")},onPointerDown:E=>{E.stopPropagation(),Dr("input-action")},onClick:()=>kr(!0),children:"⌨"}):null,p.jsx(dA,{terminalId:e.id,onSubmit:pu,queueAvailable:Qt?.provider==="codex"||FC(e.currentCommand),disabled:e.status!=="running"}),p.jsx(DL,{toast:xr,onSendNow:()=>{Ds()},onSkipOnce:Fh,onTurnOff:So,onDismiss:()=>$n(null)}),Vt&&Qt?p.jsx(RL,{terminalId:e.id,serverApi:t,source:Qt,fontSize:x,onClose:$h}):null,Fr?p.jsx(EL,{notice:Fr}):null,mr?p.jsx(kL,{status:en,busy:_a,error:mo,onInstall:()=>{Ms("install")},onUpdate:()=>{Ms("update")},onOpen:ba,onRefresh:()=>{_n({checkLatest:!0}).catch(E=>mn(Ad(E)))},onClose:()=>Kr(!1)}):null]})}function hw(e){return cE(e)}async function fw(e,t,n={}){const s=n.checkLatest===!0,l=n.force===!0||s,c=Date.now(),d=Vl.get(e);if(!l&&d?.status&&c-d.fetchedAt<=pL)return d.status;if(d?.inflight&&(!s||d.inflightCheckLatest))return d.inflight;let m;return m=t.getCodeServerStatus(s?{checkLatest:!0}:void 0).then(g=>(Wg(e,g),g)).catch(g=>{const f=Vl.get(e);throw f?.inflight===m&&(f.status?Vl.set(e,{status:f.status,fetchedAt:f.fetchedAt}):Vl.delete(e)),g}),Vl.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:s}),m}function Wg(e,t){Vl.set(e,{status:t,fetchedAt:Date.now()})}function Md(e,t){return`${e}:${t}`}function UC(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function pw(e){const t=Nc.get(e);if(!t)return!1;try{return t.closed?(Nc.delete(e),!1):(t.focus(),!0)}catch{return Nc.delete(e),!1}}function vm(e,t){const n=window.open(t,UC(e));if(!n)return null;Nc.set(e,n);try{n.focus()}catch{}return n}function gL(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function mw(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Nd(e){if(e)try{e.closed||e.close()}catch{}}function _L(e,t,n){const s=vL(e,t),l=gw(s*Math.max(1,n),lL,oL);return{limit:gw(Math.ceil(l/rL),sL,aL),maxLines:l}}function vL(e,t){const n=e?.clientHeight??0;if(n<=0)return iL;const s=Math.max(10,t*nL);return Math.max(1,Math.floor(n/s))}function gw(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function bL(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function _w(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function KC(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function yL(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function SL(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const s=Math.floor(n/60),l=n%60;if(s<24&&l>0)return`${s}h ${l}m`;if(s<24)return`${s}h`;const c=Math.floor(s/24),d=s%24;return d>0?`${c}d ${d}h`:`${c}d`}function wL(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Ad(e){return e instanceof or||e instanceof Error?e.message:"Something went wrong."}function CL(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function xL({terminal:e,canClose:t,tabId:n,transcriptSource:s,transcriptShortcutLabel:l,transcriptCacheStatus:c,transcriptCacheNow:d,cacheKeepAliveEnabled:m,codeServerAvailable:g,codeServerInstallState:f,codeServerBusy:y,codeServerSupported:b,scrollbackShortcutLabel:w,tmuxScrollbackSupported:x,tmuxScrollbackEnabled:C,onToggleCacheKeepAlive:D,onOpenCodeServer:B,onToggleTmuxScrollback:L,onOpenTranscript:O,onInterrupt:Y,onReload:U,onClose:Z}){const W=o1({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),re={cursor:n?"grab":"default",opacity:W.isDragging?.5:void 0};return p.jsxs("header",{ref:W.setNodeRef,className:"terminal-pane-header",style:re,"data-dragging":W.isDragging,...W.attributes,...W.listeners,children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),p.jsx("span",{className:"terminal-pane-spacer"}),g?p.jsx("button",{type:"button",className:"terminal-pane-code","data-state":f,"data-busy":y?"true":"false",disabled:!b||y,title:f==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":f==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),B()},children:p.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,s?p.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Uc(s.provider)} transcript history`,"aria-label":`View ${Uc(s.provider)} transcript history`,onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),O()},children:[p.jsx("span",{children:"View history"}),p.jsx("kbd",{children:l})]}):null,s?p.jsx(TL,{status:c,now:d,keepAliveEnabled:m,onToggle:D}):null,e.status==="exited"?p.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,x&&e.status==="running"?p.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":C?"true":"false","aria-pressed":C,"aria-label":`Toggle tmux scrollback (${w})`,title:C?`Scroll input uses tmux scrollback (${w}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${w}).`,onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),L()},children:[C?p.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):p.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),p.jsx("kbd",{children:w})]}):null,e.status==="running"?p.jsx("button",{type:"button",className:"terminal-pane-interrupt","aria-label":`Send interrupt to ${e.title}`,title:"Send interrupt (^C)",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),Y()},children:"^C"}):null,e.status==="running"?p.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),U()},children:"↻"}):null,t?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),Z()},children:"x"}):null]})}function kL({status:e,busy:t,error:n,onInstall:s,onUpdate:l,onOpen:c,onRefresh:d,onClose:m}){const g=e?.job??null,f=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,w=e===null&&t,x=e?.updateAvailable===!0,C=y?"VS Code add-on":"Install VS Code add-on";return p.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":C,onClick:m,children:p.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsxs("div",{children:[p.jsx("h2",{children:C}),p.jsx("p",{children:w?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),p.jsxs("div",{className:"code-server-dialog-scroll",children:[p.jsxs("div",{className:"code-server-dialog-body",children:[p.jsxs("p",{children:["NTerminal installs code-server under ",p.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?p.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:p.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?p.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?p.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[p.jsxs("div",{className:"code-server-progress-heading",children:[p.jsx("span",{children:g.action}),p.jsx("strong",{children:g.status})]}),p.jsx("pre",{children:g.logs.length>0?g.logs.join(`
35
- `):"Preparing..."})]}):null]}),p.jsxs("div",{className:"code-server-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!b,children:"Check"}),y?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:l,disabled:t||f||!b,children:x?"Update":"Reinstall"}),p.jsx("button",{type:"button",onClick:c,disabled:t||f,children:"Open"})]}):p.jsx("button",{type:"button",onClick:s,disabled:t||f||!b,children:f?"Installing...":"Install"})]})]})})}function EL({notice:e}){return p.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function TL({status:e,now:t,keepAliveEnabled:n,onToggle:s}){const l=KC(e,t),c=yL(e,l),d=l===null?"?":SL(l),m=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return p.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:m,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),s()},children:[p.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),p.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),p.jsx("span",{children:d})]})}function DL({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:s,onDismiss:l}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return p.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[p.jsxs("header",{children:[p.jsx("strong",{children:e.message}),p.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:l,children:"x"})]}),e.detail?p.jsx("p",{children:e.detail}):null,c?p.jsxs("div",{className:"cache-keepalive-toast-actions",children:[p.jsx("button",{type:"button",onClick:t,children:"Send now"}),p.jsx("button",{type:"button",onClick:n,children:"Skip once"}),p.jsx("button",{type:"button",onClick:s,children:"Turn off"})]}):null]})}const RL=Ai.memo(function({terminalId:t,serverApi:n,source:s,fontSize:l,onClose:c}){const d=_.useRef(null),m=_.useRef(0),g=_.useRef(!1),f=_.useRef(!1),y=_.useRef(null),b=_.useRef(""),w=_.useRef(null),x=_.useRef(null),[C,D]=_.useState([]),[B,L]=_.useState(!1),[O,Y]=_.useState(""),[U,Z]=_.useState(-1),[W,re]=_.useState(!1),[ee,ye]=_.useState(-1),[Ee,ne]=_.useState(null),[q,Q]=_.useState(null),[K,se]=_.useState(!1),[A,R]=_.useState(!0),[P,ie]=_.useState(!1),[ge,M]=_.useState(null);_.useEffect(()=>{function le(je){je.key==="Escape"&&(je.preventDefault(),je.stopPropagation(),c())}return document.addEventListener("keydown",le,!0),()=>document.removeEventListener("keydown",le,!0)},[c]),_.useEffect(()=>{m.current+=1;const le=m.current;return g.current=!1,f.current=!0,y.current=null,w.current=null,x.current=null,D([]),Q(null),se(!1),M(null),Z(-1),ye(-1),ne(null),Le(null,"initial",le),()=>{m.current===le&&(m.current+=1)}},[n,B,s.provider,s.sessionId,t]),_.useLayoutEffect(()=>{const le=d.current;if(!le)return;if(f.current){if(A||C.length===0)return;f.current=!1;const Ze=()=>{le.scrollTop=le.scrollHeight};Ze(),window.requestAnimationFrame?.(Ze);return}const je=y.current;je!==null&&(y.current=null,le.scrollTop+=le.scrollHeight-je)},[C,A,B]);const X=Uc(s.provider),ue=yw(C,B),be=AL(ue),ve=jL(be),xe=ve.map(le=>le.key).join(""),Re=Ee?ve.find(le=>le.key===Ee)?.entryIndex??null:null,Me=O.trim().length>0,ze=OL(be,O),Pe=ze.length,ce=Pe>0?U>=0&&U<Pe?U:0:-1,_e=ce>=0?ze[ce]?.entryIndex??null:null,Se=ce>=0?ze[ce]??null:null,Ae=Me?_e:Re,Ue=Me?_e===null?null:"search":Re===null?null:"prompt",Be=ue?ue.split(`
36
- `).length-1:0,ae=ve.length>0&&ee>=0&&ee<ve.length?ee:ve.length-1,Te=Ee??(ae>=0?ve[ae]?.key??null:null),we=Me?Pe>0?`${ce+1}/${Pe} ${Pe===1?"match":"matches"} · ${Be} ${Be===1?"line":"lines"}`:`0 matches · ${Be} ${Be===1?"line":"lines"}`:ve.length>0?`${ae+1}/${ve.length} prompts · ${Be} ${Be===1?"line":"lines"}`:`0 prompts · ${Be} ${Be===1?"line":"lines"}`;_.useEffect(()=>{const le=O.trim().toLowerCase();Z(je=>!le||Pe===0?-1:b.current!==le?0:je>=0&&je<Pe?je:0),b.current=le},[O,Pe]),_.useEffect(()=>{if(Me){ne(null);return}Ee&&!ve.some(le=>le.key===Ee)&&ne(null),ye(le=>{if(ve.length===0)return x.current=null,-1;const je=x.current?ve.findIndex(Ge=>Ge.key===x.current):-1,Ze=je>=0?je:le>=0&&le<ve.length?le:ve.length-1;return x.current=ve[Ze]?.key??null,Ze})},[Ee,Me,xe]),_.useEffect(()=>{const le=w.current;if(!le||ve.length===0)return;w.current=null;const je=le.anchorKey?ve.findIndex(Ge=>Ge.key===le.anchorKey):-1,Ze=je>0?je-1:0;qi(Ze)},[xe]);async function Le(le,je,Ze=m.current){if(!g.current){g.current=!0,je==="initial"?R(!0):(ie(!0),y.current=d.current?.scrollHeight??null),M(null);try{await Ve(le,je,Ze)}catch(Ge){if(m.current!==Ze)return;M(Ge instanceof Error?Ge.message:"Failed to load transcript history.")}finally{m.current===Ze&&(g.current=!1,R(!1),ie(!1))}}}async function Ve(le,je,Ze){let Ge=le,It=0,Ct=[];const xt=je==="initial"&&s.provider!=="claude"?uL:cL;for(;m.current===Ze;){const Ht=await n.getTerminalTranscriptHistory(t,{...Ge?{cursor:Ge}:{},..._L(d.current,l,je==="initial"?eL:tL),includeTools:B});if(m.current!==Ze)return;const F=bw(Ht.output,s.provider,{includeTools:B}),We=Je(Ht,je,Ct,F);if(F&&(Ct=[F,...Ct],We))return;if(!Ht.hasMore||!Ht.cursor||It>=xt){Ct.length>0&&D(gt=>je==="older"?[...Ct,...gt]:Ct);return}Ge=Ht.cursor,It+=1}}function Je(le,je,Ze,Ge=bw(le.output,s.provider,{includeTools:B})){if(Q(le.cursor),se(!!(le.hasMore&&le.cursor)),!Ge)return!1;const It=[Ge,...Ze];return yw(It,B)?(D(Ct=>je==="older"?[...It,...Ct]:It),!0):!1}function ct(){const le=d.current;le&&(ii(),!(le.scrollTop>72||!K||!q||g.current)&&Le(q,"older"))}function wt(le){Pe!==0&&Z(je=>{const Ze=ce>=0?ce:le>0?-1:0;return((je>=0&&je<Pe?je:Ze)+le+Pe)%Pe})}function qi(le){const je=ve[le];je&&(x.current=je.key,ye(le),ne(je.key))}async function Oi(le){if(ve.length===0){le<0&&K&&q&&!g.current&&(w.current={anchorKey:null},await Le(q,"older"));return}const Ze=(ee>=0&&ee<ve.length?ee:le<0?ve.length-1:-1)+le;if(Ze>=0&&Ze<ve.length){qi(Ze);return}le<0&&Ze<0&&K&&q&&!g.current&&(w.current={anchorKey:ve[0]?.key??null},await Le(q,"older"))}function ii(){if(Me)return;const le=d.current;if(!le)return;const Ze=le.getBoundingClientRect().top+Math.min(140,Math.max(48,le.clientHeight*.28));let Ge=null;for(const It of UL(le)){const Ct=KL(It);if(Ct!==null)if(It.getBoundingClientRect().top<=Ze)Ge=Ct;else break}if(Ge!==null){const It=ve[Ge]?.key??null;x.current=It,ye(Ge),Ee&&Ee!==It&&ne(null)}}return p.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:le=>le.stopPropagation(),onMouseDown:le=>le.stopPropagation(),onClick:le=>{le.stopPropagation(),c()},children:p.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:le=>le.stopPropagation(),onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsxs("div",{className:"transcript-dialog-title",children:[p.jsxs("h2",{id:"transcript-dialog-title",children:[X," JSONL"]}),p.jsx("span",{title:s.sessionId,children:s.sessionId})]}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),p.jsxs("div",{className:"transcript-dialog-controls",children:[p.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[p.jsx("input",{type:"checkbox",checked:B,onChange:le=>L(le.currentTarget.checked)}),"Show tool output"]}),p.jsx("label",{className:"transcript-search",children:p.jsx("input",{type:"search",value:O,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:le=>Y(le.currentTarget.value),onKeyDown:le=>{le.key==="Enter"&&(le.preventDefault(),Me?wt(le.shiftKey?-1:1):Oi(le.shiftKey?-1:1))}})}),p.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":W,"aria-label":"Toggle prompt list",onClick:()=>re(le=>!le),disabled:ve.length===0,children:"List"}),p.jsxs("div",{className:"transcript-search-actions","aria-label":Me?"Search result navigation":"Prompt navigation",children:[p.jsx("button",{type:"button",onClick:()=>Me?wt(-1):void Oi(-1),disabled:Me?Pe===0:ve.length===0&&!K,"aria-label":Me?"Previous search match":"Previous user prompt",title:Me?"Previous search match":"Previous user prompt",children:"Prev"}),p.jsx("button",{type:"button",onClick:()=>Me?wt(1):void Oi(1),disabled:Me?Pe===0:ve.length===0,"aria-label":Me?"Next search match":"Next user prompt",title:Me?"Next search match":"Next user prompt",children:"Next"})]}),p.jsx("span",{className:"transcript-result-count",children:we})]}),W?p.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:ve.length>0?ve.map((le,je)=>p.jsxs("button",{type:"button",className:Te===le.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>qi(je),children:[p.jsx("span",{children:le.timestampLabel}),p.jsx("strong",{children:le.snippet})]},`${le.key}:${je}`)):p.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,p.jsxs("div",{ref:d,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:ct,children:[P?p.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!A&&K?p.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,ue?p.jsx(ML,{entries:be,searchQuery:O,activeEntryIndex:Ae,activeEntryMode:Ue,activeSearchMatch:Se,fontSize:l}):null,A?p.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!A&&!ue&&!ge?K&&q?p.jsxs("div",{className:"transcript-dialog-status",children:[B?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",p.jsx("button",{type:"button",onClick:()=>{Le(q,"older")},disabled:P,children:"Search earlier entries"})]}):p.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,ge?p.jsx("div",{className:"transcript-dialog-error",children:ge}):null]})]})})});function ML({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:l,fontSize:c}){const d=_.useRef(new Map);_.useEffect(()=>{if(n===null)return;const g=d.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((l?.entryIndex===n?f[l.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,s,l,t]);let m=-1;return p.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const y=g.kind==="user"?++m:null,b=n===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return p.jsxs("section",{ref:w=>{w?d.current.set(f,w):d.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?p.jsx("div",{className:"transcript-entry-header",children:WC(g.header,t)}):null,g.body?p.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?p.jsx(vw,{text:g.body,searchQuery:t}):p.jsx(Ai.Suspense,{fallback:p.jsx(vw,{text:g.body,searchQuery:t}),children:p.jsx(mL,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function vw({text:e,searchQuery:t}){const n=e.endsWith(`
37
- `)?e.slice(0,-1).split(`
38
- `):e.split(`
39
- `);return p.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,l)=>p.jsx("span",{className:`transcript-line transcript-line-${WL(s,l===0||n[l-1]?.trim()==="")}`,children:WC(s,t)},l))})}function WC(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),l=n.toLowerCase(),c=[];let d=0,m=s.indexOf(l);for(;m!==-1;){m>d&&c.push(e.slice(d,m));const g=m+n.length;c.push(p.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),d=g,m=s.indexOf(l,d)}return d<e.length&&c.push(e.slice(d)),c.length>0?c:e||" "}function NL(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const s=e.toLowerCase();let l=0,c=s.indexOf(n);for(;c!==-1;)l+=1,c=s.indexOf(n,c+n.length);return l}function AL(e){const t=e.endsWith(`
40
- `)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,l="plain",c=[];function d(){const m=LL(c).join(`
41
- `);(s||m)&&n.push({header:s,body:m,kind:l}),s=null,l="plain",c=[]}for(const m of t.split(`
42
- `)){const g=BL(m);g?(d(),s=m,l=g):c.push(m)}return d(),n}function LL(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function BL(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function OL(e,t){const n=[];for(let s=0;s<e.length;s+=1){const l=e[s];if(!l)continue;const c=l.header?`${l.header}
43
- ${l.body}`:l.body,d=NL(c,t);for(let m=0;m<d;m+=1)n.push({entryIndex:s,matchIndexInEntry:m})}return n}function jL(e){const t=[];for(let l=0;l<e.length;l+=1){const c=e[l];!c||c.kind!=="user"||t.push({contentKey:zL(c),entry:c,entryIndex:l})}const n=new Map,s=new Map;for(let l=t.length-1;l>=0;l-=1){const c=t[l];if(!c)continue;const d=n.get(c.contentKey)??0;n.set(c.contentKey,d+1),s.set(l,JSON.stringify([c.contentKey,d]))}return t.map((l,c)=>({entryIndex:l.entryIndex,key:s.get(c)??JSON.stringify([l.contentKey,0]),snippet:IL(l.entry.body),timestampLabel:HL(l.entry.header)}))}function zL(e){return JSON.stringify([e.header??"",e.body.length,PL(e.body)])}function PL(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function IL(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function HL(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function UL(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function KL(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function WL(e,t){const n=e.trim();if(!n)return"blank";const s=n.replace(/^\[[^\]]+\]\s+/,""),l=/^\[[^\]]+\]\s+/.test(n);return(l||t)&&/^User$/.test(s)?"user":(l||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(l||t)&&/^System$/.test(s)?"system":(l||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||YC(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function FL(e){return e.includes("\r")||e.includes(`
44
- `)}function bm(e){return e instanceof or&&e.status===404}function Sc(e){return FC(e)||qC(e)}function FC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function qC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function qL(e){if(Sc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Uc(e){return e==="codex"?"Codex":"Claude"}function bw(e,t,n={}){const s=`[nterminal] ${Uc(t)} transcript archive ends here. Live terminal screen continues below.`,l=e.join("").replace(/\r\n/g,`
45
- `).replace(/\r/g,`
46
- `).replace(s,"").replace(/\n{3,}/g,`
47
-
48
- `).trimEnd(),c=$C(l),d=n.includeTools?c:VC(c);return d?`${d}
49
- `:""}function $C(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const s=$L(n);return s?`[${s}]`:t})}function $L(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=uc(t.getMonth()+1),l=uc(t.getDate()),c=uc(t.getHours()),d=uc(t.getMinutes()),m=uc(t.getSeconds());return`${n}-${s}-${l} ${c}:${d}:${m}`}function uc(e){return e.toString().padStart(2,"0")}function yw(e,t){return e.map(n=>t?n:VC(n)).filter(Boolean).map(n=>n.endsWith(`
50
- `)?n:`${n}
51
- `).join("")}function VC(e){if(!e)return"";const t=e.split(`
52
- `),n=[];let s=!1,l=!1,c=!0;for(const d of t){const m=d.trim()==="",g=c?VL(d):null;if(g&&(s=g==="tool",l=!1),YC(d)){l=!0,c=!1;continue}if(l){m?(l=!1,s||n.push(d),c=!0):c=!1;continue}s||n.push(d),c=m}return n.join(`
53
- `).replace(/\n{3,}/g,`
54
-
55
- `).trimEnd()}function VL(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function YC(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function YL(e,t){if(t.length===0)return e;let n=0;const s=Math.min(e.length,t.length);for(let l=s;l>0;l-=1){let c=!0;for(let d=0;d<l;d+=1)if(e[e.length-l+d]!==t[d]){c=!1;break}if(c){n=l;break}}return[...e,...t.slice(n)]}function XL(e){let t=0;for(const n of e){if(!n)continue;const s=n.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function Ld(e){const t=[];for(const n of e){const s=XC(n);s&&t.push(s)}return t}function XC(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const l=n.split(";").filter(Boolean).filter(c=>!QA.has(c.split(":")[0]??""));return l.length>0?`\x1B[?${l.join(";")}${s}`:""})}function ym(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function GL(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function Sw(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function Sr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Bd(e,t){return!t||Sr(e)}function ww(e){return Sr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function ZL(e,t,n,s,l,c,d,m){const g=f=>{const y=JL(f);if(y!==0){if(d()){if(i3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),m(y);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),QL(t,y,n,s,l,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function QL(e,t,n,s,l,c){const d=()=>{l();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Kg,d);return}d()}function JL(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const s=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,s))}function e3(e,t,n,s,l,c,d,m,g){let f=null,y=0;const b={passive:!1};function w(D){f=Sm(D),y=0}function x(D){const B=Sm(D);if(B===null){f=null,y=0;return}if(f===null){f=B;return}const L=B.clientY-f.clientY;if(f=B,D.cancelable&&D.preventDefault(),L===0)return;if(t3(t)&&n3(t,B,-L)){y=0;return}y-=L/n();const O=y<0?Math.ceil(y):Math.floor(y);if(O!==0){if(y-=O,m()){g(O);return}c();try{t.scrollLines(O)}finally{d()}s(),O<0&&t.buffer.active.viewportY<=3&&l(O)}}function C(D){if(D.touches.length>0){f=Sm(D);return}f=null,y=0}return e.addEventListener("touchstart",w,b),e.addEventListener("touchmove",x,b),e.addEventListener("touchend",C),e.addEventListener("touchcancel",C),()=>{e.removeEventListener("touchstart",w,b),e.removeEventListener("touchmove",x,b),e.removeEventListener("touchend",C),e.removeEventListener("touchcancel",C)}}function Sm(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function t3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function i3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function n3(e,t,n){const s=e.element;return s?(s.dispatchEvent(r3(t,n)),!0):!1}function r3(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const l=new Event("wheel",s);return Object.defineProperties(l,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),l}function Fg({node:e,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c=!0,refreshCwdOnEnter:d=!1,tabId:m,codeServerContext:g,dropZoneActive:f=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:w=[],totalPanes:x,onSelect:C,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:Y,onAuthClose:U}){const Z=x??qg(e);if(w.length===0&&b){const ye=$g(e),Ee=ye.some(ne=>ne.key===b)?b:ye[0]?.key;if(ye.length>1&&Ee)return p.jsx("div",{className:"mobile-focused-split",children:ye.map(ne=>{const q=ne.key===Ee;if(ne.type==="editor"){const K=n[ne.editorId];return p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:K?p.jsx(i0,{api:s,editor:K,canClose:Z>1,onClose:()=>Y(ne.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ne.key)}const Q=t[ne.terminalId];return Q?p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:p.jsx(dw,{terminal:Q,serverApi:s,active:q,visible:c&&q,canClose:Z>1,refreshCwdOnEnter:d&&q,tabId:m,codeServerContext:g,onSelect:()=>C(ne.terminalId),onClose:()=>D(ne.terminalId),onExit:K=>L(ne.terminalId,K),onSnapshot:O,...U?{onAuthClose:U}:{}})},ne.key):p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ne.key)})})}if(e.type==="pane"){const ye=t[e.terminalId];if(!ye)return p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const Ee=p.jsx(dw,{terminal:ye,serverApi:s,active:e.terminalId===l,visible:c,canClose:Z>1,refreshCwdOnEnter:d&&e.terminalId===l,tabId:m,codeServerContext:g,onSelect:()=>C(e.terminalId),onClose:()=>D(e.terminalId),onExit:q=>L(e.terminalId,q),onSnapshot:O,...U?{onAuthClose:U}:{}});return f&&y!==e.terminalId?p.jsxs("div",{className:"pane-drop-host",children:[Ee,p.jsx(Od,{terminalId:e.terminalId,side:"top"}),p.jsx(Od,{terminalId:e.terminalId,side:"right"}),p.jsx(Od,{terminalId:e.terminalId,side:"bottom"}),p.jsx(Od,{terminalId:e.terminalId,side:"left"})]}):Ee}if(e.type==="editor"){const ye=n[e.editorId];return ye?p.jsx(i0,{api:s,editor:ye,canClose:Z>1,onClose:()=>Y(e.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const W=Math.max(.1,Math.min(.9,e.ratio)),re=1-W,ee=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${W}fr) 1px minmax(0, ${re}fr)`}:{gridTemplateRows:`minmax(0, ${W}fr) 1px minmax(0, ${re}fr)`};return p.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ee,children:[p.jsx("div",{className:"split-cell",children:p.jsx(Fg,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,0],totalPanes:Z,onSelect:C,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:Y,...U?{onAuthClose:U}:{}})}),p.jsx(s3,{direction:e.direction,path:w,onResize:B}),p.jsx("div",{className:"split-cell",children:p.jsx(Fg,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,1],totalPanes:Z,onSelect:C,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:Y,...U?{onAuthClose:U}:{}})})]})}function Od({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=y_({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return p.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function s3({direction:e,path:t,onResize:n}){function s(l){l.preventDefault(),l.stopPropagation();const c=l.currentTarget;c.setPointerCapture?.(l.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return p.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:p.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function qg(e){return e.type==="pane"||e.type==="editor"?1:qg(e.first)+qg(e.second)}function $g(e){return e.type==="pane"?[{key:a3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:l3(e.editorId),type:"editor",editorId:e.editorId}]:[...$g(e.first),...$g(e.second)]}function a3(e){return`terminal:${e}`}function l3(e){return`editor:${e}`}const Bh="workspace-default",o3="NTerminal";function c3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function u3(e,t){switch(t.type){case"workspace.hydrated":return Vg(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return d3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return m3(e,t.workspaceId);case"workspace.selected":return GC(e,t.workspaceId);case"workspace.renamed":return h3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return f3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return p3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return ZC(e,t.terminal);case"terminal.split":return g3(e,t.terminal,t.direction);case"terminal.updated":return T3(e,t.terminal);case"terminal.exited":return D3(e,t.terminalId,t.exitCode);case"terminal.closed":return ex(e,t.terminalId);case"terminal.detached":return R3(e,t.terminalId,t.workspaceId);case"editor.split":return _3(e,t.editorId,t.title,t.direction);case"editor.closed":return M3(e,t.editorId);case"pane.selected":return k3(e,t.terminalId);case"pane.resized":return E3(e,t.path,t.ratio);case"tab.selected":return b3(e,t.tabId);case"tab.renamed":return x3(e,t.tabId,t.title);case"tab.reordered":return J_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return y3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return QC(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return JC(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return S3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return v3(e);default:return e}}function d3(e,t){if(e.workspaces.some(s=>s.id===t.id))return GC(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Cr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function GC(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function h3(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(d=>d.id!==t||d.title===s?d:(l=!0,{...d,title:s}));return l?{...e,workspaces:c}:e}function f3(e,t,n){const s=Cr(n);let l=!1;const c=e.workspaces.map(d=>d.id!==t||d.defaultCwd===s?d:(l=!0,{...d,defaultCwd:s}));return l?{...e,workspaces:c}:e}function p3(e,t,n,s){if(t===n)return e;const l=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(l<0||c<0)return e;const d=e.workspaces.slice(),[m]=d.splice(l,1);if(!m)return e;const g=d.findIndex(b=>b.id===n);if(g<0)return e;const f=s==="before"?g:g+1,y=d.slice();return y.splice(f,0,m),C3(e.workspaces,y)?e:{...e,workspaces:y}}function m3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),s=new Set(n?ph(n):[]),l={...e.terminals};for(const m of s)delete l[m];const c=e.workspaces.filter(m=>m.id!==t),d=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:d,terminals:l}}function ZC(e,t){const n=ix(e),s=al(n)??jh(),l=lx(t);return{...n,activeWorkspaceId:s.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??Cr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...c.tabs,l],activeTabId:l.id}:ax(c,t.id))}}function g3(e,t,n){const s=al(e),l=s?Oh(s):void 0;if(!s||!l)return ZC(e,t);const c=l.activeTerminalId,d=Wc(l.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(m=>m.id===s.id?{...m,defaultCwd:m.defaultCwd??Cr(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===l.id?{...g,root:d,activeTerminalId:t.id}:g)}:ax(m,t.id))}}function _3(e,t,n,s){const l=al(e),c=l?Oh(l):void 0;if(!l||!c)return e;const d=c.activeTerminalId,m=Wc(c.root,d,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===l.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:m,activeTerminalId:d}:f)}:g)}}function v3(e){const t=al(e),n=t?Oh(t):void 0;return n?ex(e,n.activeTerminalId):e}function b3(e,t){const n=al(e);return!n||!n.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===n.id?{...s,activeTabId:t}:s)}}function J_(e,t,n){const s=e.workspaces.map(l=>{const c=l.tabs.findIndex(y=>y.id===t);if(c<0)return l;const d=l.tabs.slice(),[m]=d.splice(c,1);if(!m)return l;const g=Math.max(0,Math.min(d.length,n)),f=d.slice();return f.splice(g,0,m),w3(l.tabs,f)?l:{...l,tabs:f}});return s.every((l,c)=>l===e.workspaces[c])?e:{...e,workspaces:s}}function y3(e,t,n,s,l){if(n===s||!e.terminals[n]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(C=>C.id===t);if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b=so(y.root,n);if(!b){const C=g.tabs.filter((D,B)=>B!==f);return{...g,tabs:C}}const w={...y,root:b,activeTerminalId:Li(b)[0]??y.activeTerminalId},x=g.tabs.slice();return x[f]=w,{...g,tabs:x}});const d=l==="left"||l==="right"?"vertical":"horizontal",m=l==="left"||l==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>Li(D.root).includes(s));if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b={type:"pane",terminalId:n},w={type:"split",direction:d,ratio:.5,first:m?b:{type:"pane",terminalId:s},second:m?{type:"pane",terminalId:s}:b},x=Wc(y.root,s,w),C=g.tabs.slice();return C[f]={...y,root:x,activeTerminalId:n},{...g,tabs:C,activeTabId:y.id}}),ix({...e,workspaces:c})}function QC(e,t,n,s){let l=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const L=e.workspaces[B].tabs.findIndex(O=>O.id===t);if(L>=0){l=B,c=L;break}}if(l<0)return e;const d=e.workspaces[l],m=d.tabs[c],g=Li(m.root);if(!g.includes(n))return e;if(g.length===1)return J_(e,t,s);const f=so(m.root,n);if(!f)return e;const y={...m,root:f,activeTerminalId:Li(f)[0]??m.activeTerminalId},b=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},x=d.tabs.slice();x[c]=y;const C=Math.max(0,Math.min(x.length,s));x.splice(C,0,w);const D=e.workspaces.slice();return D[l]={...d,tabs:x,activeTabId:w.id},{...e,workspaces:D}}function JC(e,t,n,s=Number.MAX_SAFE_INTEGER){const l=nx(e.workspaces,t),c=e.workspaces.find(f=>f.id===n);if(!l||!c)return e;if(l.workspace.id===n)return s===Number.MAX_SAFE_INTEGER?e:J_(e,t,s);const d=Li(l.tab.root),m=d.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===l.workspace.id)return ll({...f,tabs:f.tabs.filter(y=>y.id!==t)});if(f.id===n){const y=f.tabs.slice(),b=Math.max(0,Math.min(y.length,s));return y.splice(b,0,l.tab),{...f,defaultCwd:f.defaultCwd??Cr(m?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(w=>!d.includes(w)),tabs:y,activeTabId:l.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:n}}function S3(e,t,n,s,l=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(x=>x.id===s),d=nx(e.workspaces,t);if(!c||!d||!e.terminals[n]||!Li(d.tab.root).includes(n))return e;if(d.workspace.id===s)return QC(e,t,n,l);if(Li(d.tab.root).length===1)return JC(e,t,s,l);const g=so(d.tab.root,n);if(!g)return e;const f={...d.tab,root:g,activeTerminalId:Li(g)[0]??d.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},w=e.workspaces.map(x=>{if(x.id===d.workspace.id)return ll({...x,tabs:x.tabs.map(C=>C.id===t?f:C)});if(x.id===s){const C=x.tabs.slice(),D=Math.max(0,Math.min(C.length,l));return C.splice(D,0,b),{...x,defaultCwd:x.defaultCwd??Cr(y.cwd),detachedTerminalIds:x.detachedTerminalIds.filter(B=>B!==n),tabs:C,activeTabId:b.id}}return x});return{...e,workspaces:w,activeWorkspaceId:s}}function w3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function C3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function x3(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(d=>{let m=!1;const g=d.tabs.map(f=>f.id!==t||f.title===s?f:(l=!0,m=!0,{...f,title:s}));return m?{...d,tabs:g}:d});return l?{...e,workspaces:c}:e}function k3(e,t){const n=e.workspaces.find(l=>l.tabs.some(c=>ao(c.root,t))),s=n?.tabs.find(l=>ao(l.root,t));return!n||!s?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(l=>l.id===n.id?{...l,activeTabId:s.id,tabs:l.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:l)}}function E3(e,t,n){const s=al(e),l=s?Oh(s):void 0;if(!s||!l)return e;const c=Jg(l.root,t,ux(n));return c===l.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===s.id?{...d,tabs:d.tabs.map(m=>m.id===l.id?{...m,root:c}:m)}:d)}}function Vg(e,t,n,s){const l=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),d=new Set,m=!!(n&&n.some(b=>ox(b))||t&&t.some(b=>cx(b)));let g=N3(t,n,c,d);g.length===0&&(g=[jh()]);const f=typeof s=="string"&&g.some(b=>b.id===s)?s:g[0]?.id??null,y=f??g[0]?.id??Bh;for(const b of e)if(!d.has(b.id)){if(m)g=B3(g,y,b.id,b);else{const w=lx(b);g=j3(g,y,w,b)}d.add(b.id)}return{workspaces:g.map(b=>ll(O3(b,l))),activeWorkspaceId:f,terminals:l}}function Kc(e){return Li(e.root)}function Yg(e){return e_(e.root)}function ph(e){return ev([...e.tabs.flatMap(t=>Li(t.root)),...e.detachedTerminalIds])}function wm(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(l=>{const c=Zg(l.root);return c?[{...l,root:c}]:[]});return ll({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function T3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>ao(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function D3(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function ex(e,t){const n={...e.terminals};return delete n[t],tx(e,t,n)}function R3(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(c=>c.id===n)?n:null)??A3(e,t)?.id??L3(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Bh,l=e.workspaces.find(c=>c.id===s);return!l||!sx(l,t)?e:tx(e,t,{...e.terminals},{detachToWorkspaceId:s})}function tx(e,t,n,s={}){let l=e.workspaces.map(d=>{const m=[];for(const g of d.tabs){const f=so(g.root,t);if(!f)continue;const y=Li(f),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:f,activeTerminalId:b})}return ll({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:m})});s.detachToWorkspaceId&&n[t]&&(l=l.map(d=>d.id===s.detachToWorkspaceId?rx(d,t,n[t]):d));const c=l.some(d=>d.id===e.activeWorkspaceId);return{workspaces:l,activeWorkspaceId:c?e.activeWorkspaceId:l[0]?.id??null,terminals:n}}function M3(e,t){const n=e.workspaces.map(l=>{const c=[];for(const d of l.tabs){const m=Xg(d.root,t);if(!m)continue;const g=Li(m),f=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];f&&c.push({...d,root:m,activeTerminalId:f})}return ll({...l,tabs:c})}),s=n.some(l=>l.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function N3(e,t,n,s){if(t&&t.length>0){const l=[];for(const c of t)ox(c)&&l.push(Cw(c,n,s));if(l.length>0)return l}return[Cw({...jh(),tabs:e??[]},n,s)]}function Cw(e,t,n){const s=[];for(const c of e.tabs){if(!cx(c))continue;const d=Gg(c.root,t);if(!d)continue;const m=Li(d);for(const f of m)n.add(f);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&s.push({...c,root:d,activeTerminalId:g})}const l=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),l.push(c));return ll({...e,defaultCwd:Cr(e.defaultCwd),detachedTerminalIds:l,tabs:s})}function ix(e){return al(e)?e:{...e,workspaces:[jh()],activeWorkspaceId:Bh}}function al(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Oh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function nx(e,t){for(const n of e){const s=n.tabs.findIndex(l=>l.id===t);if(s>=0)return{workspace:n,tab:n.tabs[s],tabIndex:s}}return null}function A3(e,t){return e.workspaces.find(n=>n.tabs.some(s=>ao(s.root,t)))}function L3(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function B3(e,t,n,s){return e.map(l=>l.id===t?rx(l,n,s):l)}function rx(e,t,n){return sx(e,t)?{...e,defaultCwd:e.defaultCwd??Cr(n?.cwd),detachedTerminalIds:ev([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function sx(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<co}function ax(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function O3(e,t){if(e.defaultCwd)return e;const n=ph(e).find(l=>!!t[l]),s=n?Cr(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function jh(){return{id:Bh,title:o3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ll(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Cr(e.defaultCwd),detachedTerminalIds:ev(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function j3(e,t,n,s){const l=Li(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Cr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>!l.includes(d)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function lx(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Wc(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Wc(e.first,t,n),second:Wc(e.second,t,n)}}function so(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=so(e.first,t),s=so(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function Xg(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=Xg(e.first,t),s=Xg(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function Gg(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Gg(e.first,t),s=Gg(e.second,t);return n&&s?{...e,ratio:ux(e.ratio),first:n,second:s}:n??s}function Zg(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Zg(e.first),n=Zg(e.second);return t&&n?{...e,first:t,second:n}:t??n}function ox(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function cx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Qg(t.root)}function Qg(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&Qg(t.first)&&Qg(t.second):!1}function Jg(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[s,...l]=t;if(s===0){const c=Jg(e.first,l,n);return c===e.first?e:{...e,first:c}}if(s===1){const c=Jg(e.second,l,n);return c===e.second?e:{...e,second:c}}return e}function ux(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Cr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ev(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));return n}function ao(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:ao(e.first,t)||ao(e.second,t)}function Li(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Li(e.first),...Li(e.second)]}function e_(e){return e.type==="pane"||e.type==="editor"?1:e_(e.first)+e_(e.second)}const ga=new Map,Fc=new Map,qc=new Map,$c=new Map;function fo(e){return e??"__local__"}function z3(e){return{agentId:e,state:c3(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Bt(e){const t=fo(e);let n=ga.get(t);return n||(n=z3(e),ga.set(t,n)),n}function dx(e,t){const n=fo(e);let s=Fc.get(n);return s||(s=new Set,Fc.set(n,s)),s.add(t),()=>{s.delete(t)}}function P3(e){const t=fo(e),n=Fc.get(t);if(n)for(const s of Array.from(n))s()}function po(e,t){ga.set(fo(e),t),P3(e)}const t_=new Set;function I3(e){return t_.add(e),()=>{t_.delete(e)}}function Fl(e,t){const n=Bt(e),s=fo(e);t.type==="workspace.hydrated"&&(qc.delete(s),$c.delete(s));const l=u3(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],y=q3(s),b=$3(s);if(t.notifyCompletion===!0&&t.terminal.agentStatus)t.terminal.agentStatus.state==="working"&&b.add(t.terminal.id),t.terminal.agentStatus.state==="done"&&b.has(t.terminal.id)&&(d=Ew(l,t.terminal.id,f?.currentCommand??null),b.delete(t.terminal.id)),t.terminal.agentStatus.state==="idle"&&b.delete(t.terminal.id),y.delete(t.terminal.id);else{const w=f?.activity==="busy",x=t.terminal.activity==="busy",C=t.terminal.activity==="idle";t.notifyCompletion===!0&&x&&y.add(t.terminal.id),t.notifyCompletion===!0&&w&&C&&y.has(t.terminal.id)&&(d=Ew(l,t.terminal.id,f?.currentCommand??null)),(C||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(d){const w=hx(l,t.terminal.id);w&&(w.workspace.activeTabId!==w.tab.id||w.workspace.id!==l.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=H3(l,t.tabId)?.tab??null;else{const b=l.workspaces.find(w=>w.id===t.workspaceId);f=b?.tabs.find(w=>w.id===b.activeTabId)??null}const y=f?Li(f.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const w of y)b.delete(w);c=b}}const m=l!==n.state,g=c!==n.unreadCompletions;if((m||g)&&po(e,{...n,state:l,unreadCompletions:c}),g&&tv(),d)for(const f of Array.from(t_))f({agentId:e,...d})}function hx(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Li(s.root).includes(t))return{workspace:n,tab:s};return null}function H3(e,t){for(const n of e.workspaces){const s=n.tabs.find(l=>l.id===t);if(s)return{workspace:n,tab:s}}return null}const i_=new Set;function U3(e){return i_.add(e),()=>{i_.delete(e)}}function K3(){let e=0;for(const t of ga.values())e+=t.unreadCompletions.size;return e}function tv(){for(const e of Array.from(i_))e()}function xw(e,t){const n=Bt(e);if(!n.unreadCompletions.has(t))return;const s=new Set(n.unreadCompletions);s.delete(t),po(e,{...n,unreadCompletions:s}),tv()}function kw(e,t){const n=Bt(e);t!==n.state&&po(e,{...n,state:t})}function Cm(e,t){const n=Bt(e),s=t(n.editors);s!==n.editors&&po(e,{...n,editors:s})}function na(e,t,n){const s=Bt(e);s.loaded===t&&s.error===n||po(e,{...s,loaded:t,error:n})}function dc(e,t,n){const s=Bt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||po(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n})}function W3(e){const t=Bt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function F3(e){const t=fo(e),n=ga.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1;ga.delete(t),Fc.delete(t),qc.delete(t),$c.delete(t),s&&tv()}function xm(){for(const e of ga.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}ga.clear(),Fc.clear(),qc.clear(),$c.clear()}function q3(e){let t=qc.get(e);return t||(t=new Set,qc.set(e,t)),t}function $3(e){let t=$c.get(e);return t||(t=new Set,$c.set(e,t)),t}function Ew(e,t,n){const s=hx(e,t);return s?{terminalId:t,tabId:s.tab.id,commandName:n}:null}function n_(e,t){let n=!1,s=!1,l=null,c=!1;for(const d of Kc(e)){const m=t[d];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(s=!0,n=!0,!l&&m.currentCommand&&(l=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:l}:{state:"idle",commandName:null}:null}function iv(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function r_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function V3(e,t,n,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function Y3({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,onSelectTab:c,onCreateTab:d,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:w,onRenameTab:x,activePaneAvailable:C}){const[D,B]=_.useState(null),[L,O]=_.useState(!1),[Y,U]=_.useState(null),Z=_.useRef(null),W=e.findIndex(K=>K.id===t),re=W>=0?e[W]:e[0]??null,ee=re?n_(re,n):null,ye=re?Yg(re):0,Ee=re?r_(re,n):"No tab";_.useEffect(()=>{Z.current?.focus(),Z.current?.select()},[D?.tabId]),_.useEffect(()=>{if(!L)return;const K=se=>{se.key==="Escape"&&O(!1)};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[L]),_.useEffect(()=>{L&&e.length===0&&O(!1)},[L,e.length]);function ne(K,se){B({tabId:K,title:se})}function q(){if(!D)return;const K=D.title.trim();K&&x(D.tabId,K),B(null)}function Q(){return p.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${I2()}`,onClick:b,disabled:!C,children:p.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${H2()}`,onClick:w,disabled:!C,children:p.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return p.jsxs(p.Fragment,{children:[p.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[p.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:p.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})}),p.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Ee,onClick:()=>O(!0),disabled:e.length===0,children:[ee?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":ee.state,"aria-hidden":"true",title:iv(ee)}):null,p.jsx("span",{children:Ee}),p.jsxs("small",{children:[W>=0?W+1:0,"/",e.length||0,ye>1?` / ${ye}`:""]})]}),p.jsxs("div",{className:"terminal-tab-list",children:[e.map((K,se)=>{const A=Kc(K),R=Yg(K),P=r_(K,n),ie=K.id===t,ge=D?.tabId===K.id,M=n_(K,n),X=s?.has(K.id)??!1;return p.jsxs(Ai.Fragment,{children:[p.jsx(Tw,{index:se}),p.jsx(X3,{tab:K,active:ie,editing:ge,title:P,paneCount:R,terminalIds:A,canClose:e.length>1,editValue:ge?D.title:null,editInputRef:ge?Z:null,activity:M,unread:X,onSelect:()=>c(K.id),onBeginRename:()=>ne(K.id,P),onCloseAll:()=>g(A),onCommitRename:q,onCancelRename:()=>B(null),onRenameChange:ue=>B({tabId:K.id,title:ue})})]},K.id)}),p.jsx(Tw,{index:e.length}),p.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:d,children:"+"}),(l?.length??0)>0?p.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(K=>p.jsx(Z3,{terminal:K,onReattach:()=>f?.(K.id),onDelete:()=>U(K)},K.id))}):null]}),p.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:d,children:"+"}),C?Q():null]}),L?p.jsx(G3,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:D,editInputRef:Z,onClose:()=>O(!1),onSelectTab:K=>{c(K),O(!1)},onCreateTab:()=>{d(),O(!1)},onBeginRename:ne,onCloseTerminals:K=>{g(K),O(!1)},onCommitRename:q,onCancelRename:()=>B(null),onRenameChange:(K,se)=>B({tabId:K,title:se}),onReattachTerminal:K=>{f?.(K),O(!1)},onDeleteTerminal:K=>{U(K),O(!1)}}):null,Y?p.jsx(Q3,{terminal:Y,onCancel:()=>U(null),onConfirm:()=>{y?.(Y.id),U(null)}}):null]})}function X3({tab:e,active:t,editing:n,title:s,paneCount:l,canClose:c,editValue:d,editInputRef:m,activity:g,unread:f,onSelect:y,onBeginRename:b,onCloseAll:w,onCommitRename:x,onCancelRename:C,onRenameChange:D}){const{attributes:B,listeners:L,setNodeRef:O,transform:Y,isDragging:U}=o1({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),Z={transform:Mm.Translate.toString(Y),opacity:U?.4:void 0,zIndex:U?2:void 0};return p.jsxs("div",{ref:O,className:"terminal-tab","data-active":t,"data-dragging":U,"data-unread":f?"true":void 0,style:Z,...B,...L,children:[g?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:iv(g)}):null,n&&m&&d!==null?p.jsxs("form",{className:"terminal-tab-editor",onSubmit:W=>{W.preventDefault(),x()},children:[p.jsx("input",{ref:m,"aria-label":`Rename ${s}`,value:d,onBlur:x,onChange:W=>D(W.target.value),onKeyDown:W=>{if(W.key==="Enter"){W.preventDefault(),x();return}W.key==="Escape"&&(W.preventDefault(),C())}}),p.jsx("small",{children:l})]}):p.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:y,onDoubleClick:W=>{W.preventDefault(),b()},children:[p.jsx("span",{children:s}),p.jsxs("small",{children:[l," pane",l===1?"":"s"]})]}),c&&!n?p.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),w()},children:"x"}):null]})}function G3({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:c,editInputRef:d,onClose:m,onSelectTab:g,onCreateTab:f,onBeginRename:y,onCloseTerminals:b,onCommitRename:w,onCancelRename:x,onRenameChange:C,onReattachTerminal:D,onDeleteTerminal:B}){const L=_.useRef(null);return _.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),p.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:p.jsxs("section",{className:"mobile-tab-sheet",onClick:O=>O.stopPropagation(),children:[p.jsxs("header",{children:[p.jsxs("div",{children:[p.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),p.jsxs("small",{children:[e.length," open"]})]}),p.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[p.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),p.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((O,Y)=>{const U=Kc(O),Z=Yg(O),W=r_(O,n),re=O.id===t,ee=c?.tabId===O.id,ye=n_(O,n),Ee=s?.has(O.id)??!1;return p.jsxs("div",{ref:re?L:null,className:"mobile-tab-sheet-row","data-active":re,"data-unread":Ee?"true":void 0,children:[ee&&c?p.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ne=>{ne.preventDefault(),w()},children:p.jsx("input",{ref:d,"aria-label":`Rename ${W}`,value:c.title,onBlur:w,onChange:ne=>C(O.id,ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),w();return}ne.key==="Escape"&&(ne.preventDefault(),x())}})}):p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${W}`,onClick:()=>g(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:W}),p.jsx("small",{children:V3(O,n,Z,ye)})]}),p.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ye?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":ye.state,"aria-hidden":"true",title:iv(ye)}):null,p.jsx("span",{children:Z})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ee?p.jsx("button",{type:"button","aria-label":`Done renaming ${W}`,onClick:w,children:"Done"}):p.jsx("button",{type:"button","aria-label":`Rename ${W}`,onClick:()=>y(O.id,W),children:"Rename"}),e.length>1?p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${W}`,onClick:()=>b(U),children:"×"}):null]})]},O.id)}),(l?.length??0)>0?p.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[p.jsx("span",{children:"Detached"}),(l??[]).map(O=>{const Y=O.title||O.cwd||O.id.slice(0,8);return p.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>D(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:Y}),p.jsx("small",{children:O.cwd})]}),p.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),p.jsx("div",{className:"mobile-tab-sheet-actions",children:p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>B(O),children:"×"})})]},O.id)})]}):null]})]})})}function Tw({index:e}){const{setNodeRef:t,isOver:n}=y_({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return p.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function Z3({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),l=`${e.title||"Terminal"}
56
- ${e.cwd}
57
- (detached — click to re-open, × to delete)`;return p.jsxs("span",{className:"terminal-detached-pill",title:l,children:[p.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),p.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function Q3({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:l=>l.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:"Delete this terminal?"}),p.jsx("span",{children:s}),p.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function J3({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:l}){if(e.length===0)return null;const d=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return p.jsxs("aside",{className:`upload-toast upload-toast-${r5(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[p.jsxs("header",{className:"upload-toast-header",children:[p.jsx("strong",{children:e.length===1?$d(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),p.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),p.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>p.jsx(e5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>l(g.id)},g.id))})]})}function e5({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:l}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return p.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":$d(e),children:[p.jsxs("div",{className:"upload-queue-item-header",children:[p.jsx("strong",{children:$d(e)}),p.jsxs("div",{className:"upload-queue-actions",children:[m?p.jsx("button",{type:"button",onClick:l,children:"Cancel"}):null,d?p.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,p.jsx("button",{type:"button","aria-label":`Dismiss ${$d(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?p.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?p.jsx(t5,{toast:e}):null,c&&"message"in e&&e.message?p.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?p.jsx(i5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?p.jsx("p",{children:e.message}):null]})}function t5({toast:e}){const t=e.percent===null?s5(e.loaded):`${e.percent}%`;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"upload-progress-row",children:[p.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),p.jsx("span",{children:t})]}),p.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:p.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function i5({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),s=e.results.filter(d=>d.status==="uploaded"),l=t?3:6,c=[...n,...s].slice(0,l);return p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?p.jsx("ul",{className:"upload-result-list",children:c.map((d,m)=>p.jsx(n5,{result:d},`${d.relativePath}-${m}`))}):null,e.results.length>c.length?p.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function n5({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return p.jsxs("li",{"data-status":e.status,children:[p.jsx("span",{className:"upload-result-path",children:t}),n?p.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?p.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function $d(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function r5(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function s5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function a5({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const s=e,l=s.commandName?`${s.commandName} finished`:"Command finished";function c(m){m.stopPropagation(),n()}function d(m){m.target===m.currentTarget&&(m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),t(s)))}return p.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:d,children:[p.jsxs("header",{className:"completion-toast-header",children:[p.jsxs("div",{className:"completion-toast-copy",children:[p.jsx("strong",{children:s.tabTitle}),p.jsx("span",{children:l})]}),p.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:m=>m.stopPropagation(),children:"x"})]}),p.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const l5=Cc(0,0,1,1),ms=1e-6;function o5(e){return fx(e).map(t=>t.terminalId)}function fx(e){return wc(e,l5).sort(h5).map((t,n)=>({...t,index:n+1}))}function c5(e,t,n){const s=fx(e),l=s.find(d=>d.terminalId===t);return l?s.filter(d=>d.terminalId!==t).map(d=>d5(l,d,n)).filter(d=>d!==null).sort(f5)[0]?.entry.terminalId??null:null}function u5(e,t){return!Number.isInteger(t)||t<1?null:o5(e)[t-1]??null}function wc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=p5(e.ratio);if(e.direction==="vertical"){const l=t.left+(t.right-t.left)*n;return[...wc(e.first,Cc(t.left,t.top,l,t.bottom)),...wc(e.second,Cc(l,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...wc(e.first,Cc(t.left,t.top,t.right,s)),...wc(e.second,Cc(t.left,s,t.right,t.bottom))]}function d5(e,t,n){const s=e.bounds,l=t.bounds,c=Dw(s.left,s.right,l.left,l.right),d=Dw(s.top,s.bottom,l.top,l.bottom);switch(n){case"left":return l.centerX>=s.centerX-ms||d<=ms?null:{entry:t,primaryDistance:Math.max(0,s.left-l.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:d};case"right":return l.centerX<=s.centerX+ms||d<=ms?null:{entry:t,primaryDistance:Math.max(0,l.left-s.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:d};case"up":return l.centerY>=s.centerY-ms||c<=ms?null:{entry:t,primaryDistance:Math.max(0,s.top-l.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};case"down":return l.centerY<=s.centerY+ms||c<=ms?null:{entry:t,primaryDistance:Math.max(0,l.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};default:return null}}function h5(e,t){return Zl(e.bounds.top,t.bounds.top)||Zl(e.bounds.left,t.bounds.left)}function f5(e,t){return Zl(e.primaryDistance,t.primaryDistance)||Zl(e.perpendicularDistance,t.perpendicularDistance)||Zl(t.overlap,e.overlap)||Zl(e.entry.index,t.entry.index)}function Zl(e,t){const n=e-t;return Math.abs(n)<=ms?0:n}function Dw(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Cc(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function p5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class m5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Rw(e){return e?Array.from(e.types??[]).includes("Files")||_x(e.items).some(n=>n.kind==="file")?!0:vx(e.files).length>0:!1}async function g5(e){const t=_x(e.items).filter(n=>n.kind==="file");return t.length>0?_5(t):v5(e.files)}async function _5(e){const t=[];for(const n of e){const s=w5(n);if(s){await px(s,"",t);continue}const l=n.getAsFile();if(l){t.push({relativePath:mx(l),file:l});continue}throw new m5("Folder upload is not supported by this browser.")}return t}function v5(e){return vx(e).map(t=>({relativePath:mx(t),file:t}))}async function px(e,t,n){const s=x5(t,e.name);if(e.isFile){const d=await b5(e);n.push({relativePath:s,file:d});return}if(!e.isDirectory)return;const l=e.createReader(),c=await y5(l);for(const d of c)await px(d,s,n)}function b5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function y5(e){const t=[];for(;;){const n=await S5(e);if(n.length===0)return t;t.push(...n)}}function S5(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function mx(e){const t=e.webkitRelativePath;return gx(typeof t=="string"&&t?t:e.name)}function w5(e){const t=e.webkitGetAsEntry?.();return C5(t)?t:null}function C5(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function x5(e,t){return gx(e?`${e}/${t}`:t)}function gx(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function _x(e){return e?Array.from(e):[]}function vx(e){return e?Array.from(e):[]}const Mw="nterminal.terminalWorkspaces.v2",bx="nterminal.sidebarCollapsed.v1",k5=75,Nw=d1.map(e=>e.url),E5=d1[0].url,T5=6;function D5({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:l=null,previewMode:c=!1,onLogout:d=async()=>{},onSessionInvalid:m}){const g=_.useMemo(()=>e??_h(),[e]),f=_.useMemo(()=>t??eo(null),[t]),y=_.useMemo(()=>X5(n),[n]),b=_.useMemo(()=>S=>dx(n,S),[n]),w=_.useMemo(()=>()=>Bt(n),[n]),x=_.useSyncExternalStore(b,w,w),C=x.state,D=x.editors,B=!x.loaded,L=x.error,[O,Y]=_.useState(!1),[U,Z]=_.useState(()=>iB()),[W,re]=_.useState("servers"),[ee,ye]=_.useState(!1),Ee=_.useSyncExternalStore(G2,GS,GS);_.useSyncExternalStore(th,XS,XS);const[ne,q]=_.useState(0),[Q,K]=_.useState(null),[se,A]=_.useState(()=>[null]),[R,P]=_.useState(()=>({[cr]:"Local"})),[ie,ge]=_.useState(0),[M,X]=_.useState(()=>[n]),[ue,be]=_.useState(()=>new Set),[ve,xe]=_.useState({}),[Re,Me]=_.useState(null),ze=_.useRef(0),Pe=_.useRef(0),[ce,_e]=_.useState(null),[Se,Ae]=_.useState(null),Ue=_.useRef(null),Be=_.useRef(0),ae=_.useRef(null),Te=_.useRef(null),we=_.useRef(null),Le=_.useRef(null),Ve=_.useRef(()=>{}),[Je,ct]=_.useState(null),wt=EE(MS(n1,{activationConstraint:{distance:8}}),MS(r1,{activationConstraint:{delay:250,tolerance:5}}));_.useEffect(()=>Z2(g),[g]);function qi(S){const T=S.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){ct({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&ct({tabId:T.sourceTabId,terminalId:T.terminalId})}}function Oi(S){ct(null);const T=S.active.data.current,j=S.over?.data.current;if(!(!T||!j||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){Xe({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){Xe({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&Xe({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){Xe({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){Xe({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&Xe({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function ii(){ct(null)}const le=C.workspaces.find(S=>S.id===C.activeWorkspaceId)??C.workspaces[0],je=le?.tabs.find(S=>S.id===le.activeTabId)??le?.tabs[0],Ze=je?.activeTerminalId??null,Ge=Ze?C.terminals[Ze]:void 0,It=W5("(max-width: 760px)"),Ct=_.useMemo(()=>je?mh(je.root):[],[je]),xt=le&&je?xc(n,le.id,je.id):null,Ht=je?yx(Ct,je.activeTerminalId,xt?ve[xt]:void 0):null,F=It&&Ct.length>1,We=_.useMemo(()=>(le?.detachedTerminalIds??[]).flatMap(S=>{const T=C.terminals[S];return T?[T]:[]}),[le?.detachedTerminalIds,C.terminals]),gt=_.useMemo(()=>{const S=new Set;for(const T of le?.tabs??[])Kc(T).some(j=>x.unreadCompletions.has(j))&&S.add(T.id);return S},[le?.tabs,x.unreadCompletions]),[vi,Tn]=_.useState([]),ni=_.useRef([]),_t=_.useRef(null),[kt,Pt]=_.useState(null),[Rt,Ut]=_.useState(null),[ri,hi]=_.useState([]),[Zt,qt]=_.useState(()=>el()),Qi=_.useRef(0),si=_.useRef(n),Ti=_.useRef(Nw),Ji=_.useRef(Zt),hn=_.useRef(()=>{});hn.current=_n,Ve.current=Yr;const ji=_.useCallback(async()=>{try{const S=await g.listNotificationAssets();hi(S.assets.filter(T=>T.enabled).map(T=>T.url))}catch{hi([])}},[g]),Dn=_.useCallback(S=>{P(T=>{const j={...T};for(const J of S)j[a_(J.agentId)]=J.label;return km(T,j)?T:j})},[]);_.useEffect(()=>{X(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]);const bi=_.useCallback(S=>{const T=Bt(S),j=eo(S);for(const J of Object.keys(T.state.terminals))yc(j.createWebSocketUrl(J)),Dd(J);F3(S),X(J=>J.filter(pe=>!sn(pe,S))),be(J=>{const pe=`${Yd(S)}:`;let de=!1;const Ce=new Set;for(const $e of J){if($e.startsWith(pe)){de=!0;continue}Ce.add($e)}return de?Ce:J}),xe(J=>{const pe=`${Yd(S)}:`;let de=!1;const Ce={};for(const[$e,it]of Object.entries(J)){if($e.startsWith(pe)){de=!0;continue}Ce[$e]=it}return de?Ce:J})},[]);_.useEffect(()=>{let S=!1;return g.getMainInfo().then(T=>{if(S)return;const j=T.name?.trim()||"Local";P(J=>{const pe={...J,[cr]:j};return km(J,pe)?J:pe})}).catch(()=>{}),g.listAgents().then(T=>{if(!S){const j=T.agents.map(pe=>pe.id),J=[null,...j];P(pe=>{const de={[cr]:pe[cr]??"Local"};for(const Ce of T.agents)de[Ce.id]=Ce.name;return km(pe,de)?pe:de}),n!==null&&!j.includes(n)&&(bi(n),s?.(null)),A(J)}}).catch(()=>{}),()=>{S=!0}},[n,g,bi,s,ie]);const fi=_.useCallback(S=>{bi(S),ge(T=>T+1),sn(S,si.current)&&s?.(null)},[bi,s]);_.useEffect(()=>{A(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]),_.useEffect(()=>{si.current=n},[n]),_.useEffect(()=>{K(null)},[n]),_.useEffect(()=>{const S=ae.current;if(!S)return;if(!sn(S.agentId,n)){ae.current=null;return}if(!x.loaded||C.workspaces.length===0)return;ae.current=null;const T=S.edge==="first"?C.workspaces[0]:C.workspaces[C.workspaces.length-1];T&&T.id!==C.activeWorkspaceId&&Xe({type:"workspace.selected",workspaceId:T.id})},[n,x.loaded,C.activeWorkspaceId,C.workspaces]),_.useEffect(()=>{const S=Te.current;if(S){if(!sn(S.agentId,n)){Te.current=null;return}x.loaded&&(Te.current=null,C.workspaces.some(T=>T.id===S.workspaceId)&&Xe({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,x.loaded,C.workspaces]),_.useEffect(()=>{const S=we.current;if(S){if(!sn(S.agentId,n)){we.current=null;return}x.loaded&&(we.current=null,x.error||Qt())}},[n,x.error,x.loaded]),_.useEffect(()=>{ln()},[n,x.loaded,C]),_.useEffect(()=>{const S=()=>{const J=q5();J&&Ve.current(J)},T=J=>{const pe=$5(J.data);pe&&Ve.current(pe)},j=J=>{const pe=Ch(J.detail);pe&&Ve.current(pe)};return S(),window.addEventListener("hashchange",S),window.addEventListener(jm,j),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",S),window.removeEventListener(jm,j),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),_.useEffect(()=>{ji()},[ji]),_.useEffect(()=>f1(()=>qt(el())),[]),_.useEffect(()=>{const S=T=>{hn.current(T)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),_.useEffect(()=>{Ti.current=ri.length>0?ri:Nw},[ri]),_.useEffect(()=>{Ji.current=Zt},[Zt]),_.useEffect(()=>{if(!x.loaded||!le||!je)return;const S=xc(n,le.id,je.id);be(T=>{if(T.has(S))return T;const j=new Set(T);return j.add(S),j})},[n,x.loaded,le?.id,je?.id]),_.useEffect(()=>()=>{Ts()},[]),_.useEffect(()=>n2(g),[g]),_.useEffect(()=>I3(S=>{const T=Bt(S.agentId).state,j=T.workspaces.flatMap(Ce=>Ce.tabs).find(Ce=>Ce.id===S.tabId),J=T.terminals[S.terminalId],pe=j?.title?.trim()||J?.title||S.commandName||"terminal",de=document.visibilityState==="visible"&&sn(S.agentId,si.current)&&S.tabId===Y5(T);if(de||GT({agentId:S.agentId,tabTitle:pe,commandName:S.commandName,terminalId:S.terminalId}),!de&&document.visibilityState==="visible"&&Ji.current.enabled){const Ce=Qi.current+1;Qi.current=Ce;const $e=Ti.current;Pt({id:Ce,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:pe,commandName:S.commandName,assetSrc:$e[Math.floor(Math.random()*$e.length)]??E5})}}),[]),_.useEffect(()=>{if(!kt||Zt.persistUntilDismissed)return;const S=window.setTimeout(()=>{Pt(T=>T?.id===kt.id?null:T)},Zt.durationSeconds*1e3);return()=>window.clearTimeout(S)},[kt,Zt]),_.useEffect(()=>{nB(U),U&&hr()},[U]),_.useEffect(()=>{let S=!1;async function T(){if(!Bt(n).loaded){na(n,!1,null);try{let J=null,pe=null;try{J=G5(y)}catch(it){if(!(it instanceof gh))throw it;pe=it}const[de,Ce]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),$e=de.terminals.length>0?de.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!S){const it=Ce.layout?wx(Ce.layout):null;if(!it&&pe)throw pe;const li=it??J??{},Jt=Vg($e,void 0,li.savedWorkspaces,li.savedActiveWorkspaceId),Xr=wm(Jt);kw(n,Jt),dc(n,Ce.revision,JSON.stringify(Xr)),na(n,!0,null),!it&&J&&gr(Xr,{baseRevision:Ce.revision})}}catch(J){!S&&!tn(J)&&na(n,!0,ra(J))}}}return T(),()=>{S=!0}},[n,f,ne]);function $t(){na(n,!1,null),q(S=>S+1)}function hr(){ze.current+=1,Pe.current+=1,Me(null)}function ys(S){ze.current+=1,Pe.current+=1,Me(T=>T&&{...T,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Qt(){ze.current+=1,Pe.current+=1;const S=C.workspaces.length+1,T=pr();Me({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&Hr(T)}function fr(S){if(sn(S,n)){Qt();return}we.current={agentId:S},s?.(S)}function $i(S){if(U&&!O)return;const T=C.workspaces.find(J=>J.id===S);if(!T)return;ze.current+=1,Pe.current+=1;const j=T.defaultCwd??Ge?.cwd??"";Me({mode:"edit",workspaceId:S,title:T.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&Hr(j)}function pr(){return le?.defaultCwd??Ge?.cwd??""}async function Hr(S){const T=ze.current+1;ze.current=T;const j=S.trim();if(Me(J=>J&&{...J,cwd:S,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const J=await f.createFileRoot({path:j}),pe=await f.listFiles({rootToken:J.rootToken,path:""});if(ze.current!==T)return;Me(de=>de&&{...de,cwd:J.rootPath,browseRoot:{rootToken:J.rootToken,rootPath:J.rootPath},browseEntries:pe.entries.filter(Ce=>Ce.kind==="directory"),browseStatus:"idle",error:null})}catch(J){if(ze.current!==T)return;Me(pe=>pe&&{...pe,browseStatus:"idle",error:ra(J)})}}async function fn(){const S=Re;if(!S)return;const T=S.title.trim(),j=S.cwd.trim();if(!T||!j){Me({...S,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const J=Pe.current+1;Pe.current=J,Me({...S,submitStatus:"submitting",error:null});try{const pe=await f.createFileRoot({path:j});if(Pe.current!==J)return;if(S.mode==="create"){const de=C.workspaces.length+1;Xe({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${de}`,title:T,defaultCwd:pe.rootPath})}else S.workspaceId&&(Xe({type:"workspace.renamed",workspaceId:S.workspaceId,title:T}),Xe({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:pe.rootPath}));Me(null)}catch(pe){if(Pe.current!==J)return;Me(de=>de&&{...de,submitStatus:"idle",error:ra(pe)})}}function qn(S){Pe.current+=1,Me(S)}function xr(S,T,j){if(S===T)return;const J=C.workspaces.some(de=>de.id===S),pe=C.workspaces.some(de=>de.id===T);!J||!pe||Xe({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:T,placement:j})}function $n(S,T){const j=C.workspaces.findIndex(pe=>pe.id===S),J=C.workspaces[j+T];j<0||!J||xr(S,J.id,T<0?"before":"after")}function Vt(S,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),Ue.current={sourceId:S,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function Ur(S){const T=Ue.current;if(!T||T.pointerId!==S.pointerId)return;const j=Math.hypot(S.clientX-T.startX,S.clientY-T.startY);if(!T.active){if(j<T5)return;T.active=!0,_e(T.sourceId)}const pe=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),de=pe?.dataset.workspaceId??null;if(!pe||!de||de===T.sourceId||!C.workspaces.some(it=>it.id===de)){T.targetId=null,Ae(null);return}const Ce=pe.getBoundingClientRect(),$e=S.clientY<Ce.top+Ce.height/2?"before":"after";T.targetId=de,T.placement=$e,Ae({workspaceId:de,placement:$e})}function en(S){const T=Ue.current;!T||T.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Ue.current=null,_e(null),Ae(null),T.active&&T.targetId&&xr(T.sourceId,T.targetId,T.placement))}function pn(S){const T=Ue.current;T&&T.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Ue.current=null,_e(null),Ae(null)}async function mr(){await Rn(async()=>{const S=le?.defaultCwd?{cols:80,rows:24,cwd:le.defaultCwd}:{cols:80,rows:24},T=await f.createTerminal(S);Xe({type:"terminal.created",terminal:T.terminal})})}async function Kr(S){await Rn(async()=>{const T=Ze?{parentTerminalId:Ze,cols:80,rows:24}:le?.defaultCwd?{cols:80,rows:24,cwd:le.defaultCwd}:{cols:80,rows:24},j=await f.createTerminal(T);Xe({type:"terminal.split",terminal:j.terminal,direction:S})})}async function _a(S){let T=Ze,j=xt;const J=le?.defaultCwd?.trim();if(!T&&!J)throw new Error("No active pane is available.");const pe=await f.readFile(S);if(!T&&J){const $e=await f.createTerminal({cols:80,rows:24,cwd:J});T=$e.terminal.id,Xe({type:"terminal.created",terminal:$e.terminal})}if(T){Xe({type:"pane.selected",terminalId:T});const $e=Bt(n).state,it=$e.workspaces.find(Jt=>Jt.id===$e.activeWorkspaceId)??$e.workspaces[0],li=it?.tabs.find(Jt=>Jt.id===it.activeTabId)??it?.tabs[0];j=it&&li?xc(n,it.id,li.id):null}const de=`editor-${Date.now().toString(36)}-${W3(n)}`,Ce=tB(pe.path);Cm(n,$e=>({...$e,[de]:{id:de,title:Ce,rootToken:S.rootToken,path:pe.path,read:pe}})),j&&xe($e=>({...$e,[j]:Sx(de)})),Xe({type:"editor.split",editorId:de,title:Ce,direction:"vertical"})}function Wr(S){Cm(n,T=>{const j={...T};return delete j[S],j}),Xe({type:"editor.closed",editorId:S})}function mo(S){mn([S])}function mn(S){const T=[...new Set(S)].filter(J=>C.terminals[J]);if(T.length===0)return;const j=T.length===1?C.terminals[T[0]]?.title||C.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;K(null),Ut({terminalIds:T,label:j,workspaceId:le?.id??C.activeWorkspaceId??null})}function Fr(S,T){const j=ks(S,T);if(!j)return!1;const J=S.filter(pe=>!j.detachedTerminalIds.includes(pe));if(j.detachedTerminalIds.length+J.length>co)return K(Q5(j.detachedTerminalIds.length)),!1;K(null);for(const pe of S)Xe(j.id?{type:"terminal.detached",terminalId:pe,workspaceId:j.id}:{type:"terminal.detached",terminalId:pe});return!0}async function gn(S){await Rn(async()=>{for(const T of S)await qr(T),yc(f.createWebSocketUrl(T)),Dd(T),Xe({type:"terminal.closed",terminalId:T})})}async function ai(S){const T=C.workspaces.find(j=>j.id===S);!T||C.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Rn(async()=>{const j=ph(T),J=[];let pe=null;for(const Ce of j)try{await qr(Ce)}catch($e){J.push(ra($e)),$e instanceof or&&$e.status===401&&!f.isAgent&&(pe=$e)}finally{yc(f.createWebSocketUrl(Ce)),Dd(Ce)}const de=T.tabs.flatMap(Ce=>s_(Ce.root));if(de.length>0){const Ce=new Set(de);Cm(n,$e=>{const it={...$e};for(const li of Ce)delete it[li];return it})}if(Xe({type:"workspace.closed",workspaceId:S}),pe)throw pe;if(J.length>0)throw new Error(`Workspace was removed, but ${J.length} terminal session${J.length===1?"":"s"} may still be running. ${J[0]}`)})}async function ol(S){await Rn(async()=>{await qr(S),yc(f.createWebSocketUrl(S)),Dd(S),Xe({type:"terminal.closed",terminalId:S})})}async function va(S,T){const j=T.trim();if(!j)return;let J=null;for(const pe of C.workspaces){const de=pe.tabs.find(Ce=>Ce.id===S);if(de){J=de.activeTerminalId;break}}if(Xe({type:"tab.renamed",tabId:S,title:j}),!!J)try{const pe=await f.renameTerminal(J,j);Cs({type:"terminal.updated",terminal:pe.terminal})}catch(pe){na(n,!0,ra(pe))}}function Ss(S){const T=C.terminals[S];T&&Xe({type:"terminal.created",terminal:T})}async function qr(S){try{await f.closeTerminal(S)}catch(T){if(T instanceof or&&T.status===404)return;throw T}}async function ws(){await Rn(async()=>{await d()})}async function Rn(S){na(n,!0,null);try{await S()}catch(T){if(tn(T))return;na(n,!0,ra(T))}}function tn(S){return S instanceof or&&S.status===401&&!f.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function Xe(S){Fl(n,S);const T=Bt(n),j=T.state;if(!T.loaded||j.workspaces.length===0)return;const J=wm(j);JSON.stringify(J)!==T.lastPersistedLayoutJson&&ka(J)}function Cs(S){Fl(n,S)}function kr(S,T,j,J){const pe=xc(S,T,j);xe(de=>({...de,[pe]:J}))}function Vn(S){xt&&xe(T=>({...T,[xt]:S}))}function $r(S,T){const j=Ac(S);T?kr(n,T.workspaceId,T.tabId,j):Vn(j),Xe({type:"pane.selected",terminalId:S})}function xs(S){Vn(S.key),S.type==="terminal"&&Xe({type:"pane.selected",terminalId:S.terminalId})}function _n(S){if(ee||Rt||S.isComposing||S.key==="Process"||B5(S.target))return;const T=M5(S);if(!T)return;if(S.preventDefault(),S.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){ba(T.type==="server.next"?1:-1);return}const j=Bt(n).state,J=j.workspaces.find(Ce=>Ce.id===j.activeWorkspaceId)??j.workspaces[0],pe=J?.tabs.find(Ce=>Ce.id===J.activeTabId)??J?.tabs[0];if(T.type==="split"){if(!pe)return;Kr(T.direction);return}if(!J||!pe)return;if(T.type==="tab.previous"||T.type==="tab.next"){const Ce=L5(J.tabs,pe.id,T.type==="tab.next"?1:-1);Ce&&Xe({type:"tab.selected",tabId:Ce.id});return}if(T.type==="tab.index"){const Ce=J.tabs[T.index-1];Ce&&Xe({type:"tab.selected",tabId:Ce.id});return}const de=N5(pe.root,pe.activeTerminalId,T);de&&$r(de,{workspaceId:J.id,tabId:pe.id})}function Mn(S,T){if(!s||se.length===0)return;const j=se.findIndex(Ce=>sn(Ce,n)),pe=((j===-1?0:j)+S+se.length)%se.length,de=se[pe]??null;sn(de,n)||(T&&(ae.current={agentId:de,edge:T}),s(de))}function ba(S){const T=Bt(n).state,j=T.workspaces;if(j.length===0){Mn(S,S===1?"first":"last");return}const J=j.findIndex(Ce=>Ce.id===T.activeWorkspaceId),de=(J===-1?0:J)+S;if(de>=0&&de<j.length){Xe({type:"workspace.selected",workspaceId:j[de].id});return}Mn(S,S===1?"first":"last")}function cl(S,T){if(sn(S,n)){Xe({type:"workspace.selected",workspaceId:T});return}Te.current={agentId:S,workspaceId:T},s?.(S)}function ks(S,T){if(T)return C.workspaces.find(j=>j.id===T)??null;for(const j of S){const J=C.workspaces.find(de=>de.tabs.some(Ce=>Kc(Ce).includes(j)));if(J)return J;const pe=C.workspaces.find(de=>de.detachedTerminalIds.includes(j));if(pe)return pe}return C.workspaces.find(j=>j.id===C.activeWorkspaceId)??C.workspaces[0]??null}function ya(S){Rw(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function go(S){if(!Rw(S.dataTransfer))return;S.preventDefault();const T=J5(Bt(n).state),j=Be.current+1;if(Be.current=j,!T){Es({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Es({id:j,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Vr(j,T.id,S.dataTransfer)}async function Vr(S,T,j){try{const J=await g5(j);if(J.length===0)throw new Error("No files were found in the drop.");zi(S,{id:S,status:"queued",fileCount:J.length,message:"Queued"},{terminalId:T,files:J})}catch(J){zi(S,{id:S,status:"failed",fileCount:0,message:ra(J)},{terminalId:T})}finally{Nn()}}async function vn(S){const T=ni.current.find(de=>de.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=T.terminalId,J=T.files,pe=new AbortController;_t.current=S,zi(S,{id:S,status:"uploading",fileCount:J.length,loaded:0,total:null,percent:null},{terminalId:j,files:J,abortController:pe});try{const de=await uD({terminalId:j,files:J,signal:pe.signal,onProgress:li=>{zi(S,{id:S,status:"uploading",fileCount:J.length,loaded:li.loaded,total:li.total,percent:li.percent},{terminalId:j,files:J,abortController:pe})}}),Ce=de.failed>0?de.uploaded>0?"partial":"failed":"success",$e=de.failed>0?eB(de):void 0,it={id:S,status:Ce,fileCount:J.length,response:de};$e&&(it.message=$e),zi(S,it,{terminalId:j,files:J})}catch(de){zi(S,{id:S,status:"failed",fileCount:J.length,message:pe.signal.aborted?"Upload canceled.":ra(de)},{terminalId:j,files:J})}finally{_t.current===S&&(_t.current=null),Nn()}}function Nn(){if(_t.current!==null)return;const S=ni.current.find(T=>T.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&vn(S.id)}function Es(S){An(T=>[...T,S])}function zi(S,T,j={}){An(J=>J.map(pe=>{if(pe.id!==S)return pe;const de={...T},Ce=j.terminalId??pe.terminalId,$e=j.files??pe.files;return Ce!==void 0&&(de.terminalId=Ce),$e!==void 0&&(de.files=$e),j.abortController!==void 0&&(de.abortController=j.abortController),de}))}function An(S){const T=S(ni.current);ni.current=T,Tn(T)}function Sa(S){ni.current.find(j=>j.id===S)?.abortController?.abort(),_t.current===S&&(_t.current=null),An(j=>j.filter(J=>J.id!==S)),Nn()}function wa(){for(const S of ni.current)S.abortController?.abort();_t.current=null,An(()=>[])}function Ca(S){const T=ni.current.find(j=>j.id===S);if(T){if(T.status==="queued"){Sa(S);return}T.abortController?.abort()}}function Er(S){const T=ni.current.find(J=>J.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=Ln(T);if(j.length===0){zi(S,{id:S,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}zi(S,{id:S,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:T.terminalId,files:j}),Nn()}function Ln(S){const T=S.files??[],j="response"in S?S.response:void 0;if(!j)return T;const J=j.results.filter(Ce=>Ce.status==="failed").map(Ce=>Ce.relativePath);if(J.length===0)return[];const pe=new Map;for(const Ce of T){const $e=pe.get(Ce.relativePath)??[];$e.push(Ce),pe.set(Ce.relativePath,$e)}const de=[];for(const Ce of J){const it=pe.get(Ce)?.shift();it&&de.push(it)}return de}function xa(S){const j=Bt(S.agentId).state.workspaces.find(J=>J.tabs.some(pe=>pe.id===S.tabId));j&&kr(S.agentId,j.id,S.tabId,Ac(S.terminalId)),Fl(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),xw(S.agentId,S.terminalId),sn(S.agentId,n)||s?.(S.agentId),Pt(null)}function Yr(S){if(Le.current=S,!sn(S.agentId,n)){s?s(S.agentId):Le.current=null;return}ln()}function ln(){const S=Le.current;if(!S||!sn(S.agentId,n)||!x.loaded)return;const T=Bt(S.agentId),j=V5(T.state,S.terminalId);Le.current=null,j&&(kr(S.agentId,j.workspaceId,j.tabId,Ac(S.terminalId)),Fl(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),xw(S.agentId,S.terminalId))}function ka(S){const T=Bt(n).mutable.saveCoord;T.pendingLayoutSave=S,hc(S,y),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const j=T.pendingLayoutSave;T.pendingLayoutSave=null,j&&gr(j)},k5)}function Ts(){const S=Bt(n).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const T=S.pendingLayoutSave;S.pendingLayoutSave=null,T&&(hc(T,y),gr(T))}function gr(S,T={}){const j=Bt(n).mutable.saveCoord;j.nextPersistLayout=S,T.baseRevision!==void 0&&(j.queuedBaseRevision=T.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const J=j.nextPersistLayout,pe=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,J&&await Bn(J,pe!==void 0?{baseRevision:pe}:{})}))}async function Bn(S,T={}){const j=Bt(n),J=T.baseRevision??j.layoutRevision,pe={layout:S,...typeof J=="number"?{baseRevision:J}:{}};try{const de=await f.saveTerminalLayout(pe),Ce=de.layout??S;dc(n,de.revision,JSON.stringify(Ce)),hc(Ce,y);return}catch(de){if(de instanceof or&&de.status===400&&de.message===LT){Z5(n,y),na(n,!0,Cx());return}if(de instanceof or&&de.status===409)try{const Ce=await f.getTerminalLayout(),$e=Bt(n).mutable.saveCoord;if($e.nextPersistLayout||$e.pendingLayoutSave){const it=Ce.layout?JSON.stringify(Ce.layout):Bt(n).lastPersistedLayoutJson;dc(n,Ce.revision,it);return}if(Ce.layout){const it=Bt(n).state,li=Vg(Object.values(it.terminals),void 0,Ce.layout.workspaces,Ce.layout.activeWorkspaceId),Jt=wm(li);kw(n,li),dc(n,Ce.revision,JSON.stringify(Jt)),hc(Jt,y)}else dc(n,Ce.revision,j.lastPersistedLayoutJson);return}catch{}hc(S,y)}}const Tr=rB(l),Et=!U||O,pi=Et?W:"servers";function Yn(S){const T=S.active?x:Bt(S.agentId),j=S.active?C:T.state,J=S.active?x.loaded:T.loaded,pe=S.active?L:T.error;return p.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[p.jsxs("div",{className:"workspace-list-header",children:[p.jsx("span",{children:"Workspaces"}),p.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>fr(S.agentId),children:"+"})]}),J?pe?p.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(S.agentId),children:pe}):p.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(de=>{const Ce=S.active&&de.id===le?.id,$e=ph(de).length,it=S.active&&j.workspaces.length>1,li=Se?.workspaceId===de.id&&ce!==de.id?Se.placement:null;return p.jsxs(I5,{workspaceId:de.id,active:Ce,disabled:!S.active,reorderable:it,dragging:ce===de.id,dropPlacement:li,children:[it?p.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":de.id,title:"Drag to reorder","aria-label":`Reorder ${de.title}`,"aria-grabbed":ce===de.id,onPointerDown:Jt=>Vt(de.id,Jt),onPointerMove:Ur,onPointerUp:en,onPointerCancel:pn,onKeyDown:Jt=>{(Jt.key==="ArrowUp"||Jt.key==="ArrowDown")&&(Jt.preventDefault(),Jt.stopPropagation(),$n(de.id,Jt.key==="ArrowUp"?-1:1))},onClick:Jt=>Jt.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Ce?"page":void 0,title:de.defaultCwd??void 0,onClick:()=>cl(S.agentId,de.id),onDoubleClick:()=>{S.active&&$i(de.id)},children:[p.jsx("span",{className:"workspace-list-name",children:de.title}),p.jsxs("small",{children:[de.defaultCwd??"No folder"," · ",$e," ",$e===1?"session":"sessions"]})]}),S.active?p.jsxs("div",{className:"workspace-list-actions",children:[p.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${de.title}`,title:"Edit workspace",onClick:()=>$i(de.id),children:"..."}),p.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${de.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{ai(de.id)},children:"x"})]}):null]},de.id)})}):p.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(S.agentId),children:"Open server to load workspaces"})]})}return p.jsx(ET,{sensors:wt,onDragStart:qi,onDragEnd:Oi,onDragCancel:ii,children:p.jsxs("main",{className:"terminal-shell","data-collapsed":U,"data-sidebar-open":O,onDragOver:ya,onDrop:go,children:[p.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),p.jsxs("aside",{className:"workspace-sidebar",children:[p.jsxs("header",{className:"workspace-brand",children:[p.jsxs("div",{className:"workspace-brand-lockup",children:[Et?p.jsx(Kw,{height:20}):p.jsx(Uw,{size:24}),c&&Et?p.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),p.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":U?"Expand sidebar":"Collapse sidebar",title:U?"Expand sidebar":"Collapse sidebar",onClick:()=>Z(S=>!S),children:U?">":"<"}),p.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),p.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${pi==="files"?"files":"servers"}`,children:[Et?p.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[p.jsx("button",{type:"button",role:"tab","aria-selected":W==="servers",onClick:()=>{re("servers")},children:"Workspaces"}),p.jsx("button",{type:"button",role:"tab","aria-selected":W==="files",onClick:()=>{re("files")},children:"Files"})]}):null,pi==="servers"&&Et?p.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:p.jsx(YS,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ie,onServerLabelsChange:Dn,renderServerChildren:Yn})}):null,Et?null:p.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:p.jsx(YS,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ie,onServerLabelsChange:Dn,compact:!0})}),pi==="files"?p.jsx(mD,{api:f,activeTerminalId:Ze,activeTerminalCwd:Ge?.cwd??null,workspaceRootPath:Ze?null:le?.defaultCwd??null,onOpenFile:_a},`${n??"local"}:${le?.id??"no-workspace"}`):null]}),p.jsxs("div",{className:"workspace-sidebar-footer",children:[Et?p.jsx("span",{children:Tr}):null,p.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[p.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ye(!0),children:[p.jsx(Lw,{name:"settings"}),Ee.hasUpdates?p.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Et?p.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{ws()},children:p.jsx(Lw,{name:"logout"})}):null]})]})]}),ee?p.jsx(lD,{api:g,onClose:()=>ye(!1),updateAvailable:Ee.hasUpdates,onNotificationAssetsChanged:()=>{ji()},onAgentRemoved:fi}):null,Re?p.jsx(O5,{dialog:Re,activePaneCwd:Ge?.cwd??null,activeWorkspaceCwd:le?.defaultCwd??null,onChange:qn,onManualCwdChange:ys,onBrowse:Hr,onCancel:hr,onSubmit:()=>{fn()}}):null,p.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":F?"true":void 0,children:[p.jsx(Y3,{tabs:le?.tabs??[],activeTabId:le?.activeTabId??null,terminals:C.terminals,unreadCompletionTabIds:gt,detachedTerminals:We,onSelectTab:S=>Xe({type:"tab.selected",tabId:S}),onCreateTab:()=>{mr()},onToggleWorkspaces:()=>Y(S=>!S),onCloseTerminals:S=>mn(S),onReattachTerminal:S=>Ss(S),onDeleteTerminal:S=>{ol(S)},onSplitVertical:()=>{Kr("vertical")},onSplitHorizontal:()=>{Kr("horizontal")},onRenameTab:(S,T)=>{va(S,T)},activePaneAvailable:!!Ze}),F?p.jsx(U5,{targets:Ct,activeLeafKey:Ht,terminals:C.terminals,editors:D,onSelect:xs}):null,L?p.jsxs("div",{className:"workspace-error",role:"alert",children:[p.jsx("span",{children:L}),p.jsxs("div",{className:"workspace-error-actions",children:[p.jsx("button",{type:"button",onClick:$t,children:"Retry"}),n!==null&&s?p.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,p.jsxs("section",{className:"workspace-body","aria-busy":B,children:[B?p.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!B&&!je?p.jsx(P5,{onCreate:()=>{mr()}}):null,M.map(S=>{const T=sn(S,n);return p.jsx(R5,{agentId:S,serverName:R[a_(S)]??(S===null?"Local":"Server"),active:T,activeServerApi:T?f:void 0,visitedTabKeys:ue,refreshCwdOnEnter:T,draggingTab:T?Je:null,mobileSplitFocus:It,mobileFocusedLeafByTabKey:ve,onSelect:j=>{T&&$r(j)},onClose:j=>{T&&mo(j)},onCloseEditor:j=>{T&&Wr(j)},onResize:(j,J)=>{T&&Xe({type:"pane.resized",path:j,ratio:J})},onExit:(j,J)=>{T?Cs({type:"terminal.exited",terminalId:j,exitCode:J}):Fl(S,{type:"terminal.exited",terminalId:j,exitCode:J})},onSnapshot:(j,J)=>{const pe={type:"terminal.updated",terminal:j,notifyCompletion:J?.notifyCompletion===!0};T?Cs(pe):Fl(S,pe)},...S===null&&m?{onAuthClose:j=>m({...j,source:j?.source??"terminal-ws-1008",activeAgentId:S})}:{}},Yd(S))})]}),Rt?p.jsx(H5,{label:Rt.label,count:Rt.terminalIds.length,warning:Q,onCancel:()=>{K(null),Ut(null)},onHide:()=>{Fr(Rt.terminalIds,Rt.workspaceId)&&Ut(null)},onDelete:()=>{const S=Rt.terminalIds;K(null),Ut(null),gn(S)}}):null,p.jsx(a5,{toast:kt,onActivate:xa,onDismiss:()=>Pt(null)}),p.jsx(J3,{uploads:vi,onDismiss:Sa,onDismissAll:wa,onRetry:Er,onCancel:Ca})]})]})})}function R5({agentId:e,serverName:t,active:n,activeServerApi:s,visitedTabKeys:l,refreshCwdOnEnter:c,draggingTab:d,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:f,onClose:y,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,onAuthClose:D}){const B=_.useMemo(()=>Ee=>dx(e,Ee),[e]),L=_.useMemo(()=>()=>Bt(e),[e]),O=_.useSyncExternalStore(B,L,L),Y=_.useMemo(()=>eo(e),[e]),U=s??Y,Z=O.state,W=Z.workspaces.find(Ee=>Ee.id===Z.activeWorkspaceId)??Z.workspaces[0],re=W?.id??null,ye=(W?.tabs.find(Ee=>Ee.id===W.activeTabId)??W?.tabs[0])?.id??null;return!O.loaded||Z.workspaces.length===0?null:p.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:Z.workspaces.flatMap(Ee=>Ee.tabs.map(ne=>{const q=n&&Ee.id===re&&ne.id===ye,Q=xc(e,Ee.id,ne.id),K=mh(ne.root),se=m&&K.length>1?yx(K,ne.activeTerminalId,g[Q]):null;return!q&&!l.has(Q)?null:p.jsx("div",{className:"workspace-tab-surface","data-active":q,"aria-hidden":!q,children:p.jsx(Fg,{node:ne.root,terminals:Z.terminals,editors:O.editors,api:U,activeTerminalId:ne.activeTerminalId,visible:q,refreshCwdOnEnter:q&&c,tabId:ne.id,codeServerContext:{serverKey:a_(e),serverName:t,tabName:ne.title||Z.terminals[ne.activeTerminalId]?.title||"Terminal"},dropZoneActive:q&&d!==null,draggingTerminalId:q?d?.terminalId??null:null,mobileFocusLeafKey:se,onSelect:f,onClose:y,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,...D?{onAuthClose:D}:{}})},`${Ee.id}:${ne.id}`)}))})}function M5(e){const t=T1(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=A5(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function N5(e,t,n){switch(n.type){case"pane.direction":return c5(e,t,n.direction);case"pane.index":return u5(e,n.index);default:return null}}function A5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function L5(e,t,n){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+n+e.length)%e.length]??null}function mh(e){return e.type==="pane"?[{key:Ac(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Sx(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...mh(e.first),...mh(e.second)]}function s_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...s_(e.first),...s_(e.second)]}function yx(e,t,n){if(n&&e.some(l=>l.key===n))return n;const s=t?Ac(t):null;return s&&e.some(l=>l.key===s)?s:e[0]?.key??null}function Ac(e){return`terminal:${e}`}function Sx(e){return`editor:${e}`}function B5(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function O5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:l,onBrowse:c,onCancel:d,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(x=>x.kind==="directory"),y=e.submitStatus==="submitting";function b(x){s(C=>C&&{...C,...x})}function w(x){x&&(b({cwd:x,error:null}),c(x))}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:p.jsxs("form",{className:"security-panel workspace-dialog",onClick:x=>x.stopPropagation(),onSubmit:x=>{x.preventDefault(),y||m()},children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),p.jsxs("section",{className:"workspace-dialog-body",children:[p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Name"}),p.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:x=>b({title:x.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Default cwd"}),p.jsxs("div",{className:"workspace-dialog-path-row",children:[p.jsx("input",{value:e.cwd,disabled:y,onChange:x=>l(x.currentTarget.value),placeholder:"/home/user/project"}),p.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),p.jsxs("div",{className:"workspace-dialog-quick-actions",children:[p.jsx("button",{type:"button",onClick:()=>w(t),disabled:y||!t,children:"Use active pane"}),p.jsx("button",{type:"button",onClick:()=>w(n),disabled:y||!n,children:"Use current workspace"})]}),p.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[p.jsxs("div",{className:"workspace-dialog-browser-header",children:[p.jsx("span",{title:g,children:g||"No folder selected"}),p.jsx("button",{type:"button",onClick:()=>{c(z5(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?p.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?p.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?p.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(x=>p.jsxs("button",{type:"button","aria-label":`Choose folder ${x.name}`,disabled:y,onClick:()=>{c(j5(g,x.path))},children:[p.jsx("span",{children:x.name}),p.jsx("small",{children:x.path})]},x.path))}):null]}),e.error?p.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),p.jsxs("div",{className:"workspace-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),p.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function j5(e,t){return t?t.startsWith("/")?Vd(t):Vd(`${e||"/"}/${t}`):Vd(e)}function z5(e){const t=Vd(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Vd(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function P5({onCreate:e}){return p.jsxs("div",{className:"empty-workspace",children:[p.jsx("span",{children:"No terminal is open."}),p.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function I5({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:l=!1,dropPlacement:c=null,children:d}){const{setNodeRef:m,isOver:g}=y_({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",l?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return p.jsx("div",{ref:m,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:d})}function H5({label:e,count:t,warning:n,onCancel:s,onHide:l,onDelete:c}){return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),p.jsx("span",{children:e}),p.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?p.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:l,children:"Hide"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function U5({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:l}){const[c,d]=_.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(w=>w.key===t):-1,g=m>=0?m:0,f=e[g]??e[0],y=Aw(f,n,s);function b(w){const x=(g+w+e.length)%e.length,C=e[x];C&&l(C)}return p.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[p.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),p.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>d(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),p.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?p.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:p.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[p.jsxs("header",{children:[p.jsx("strong",{children:"Panes"}),p.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),p.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,x)=>{const C=Aw(w,n,s),D=K5(w,n,s),B=w.key===f.key;return p.jsxs("button",{type:"button","data-active":B,onClick:()=>{l(w),d(!1)},children:[p.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),p.jsxs("span",{className:"mobile-pane-sheet-copy",children:[p.jsx("strong",{children:C}),p.jsx("small",{children:D})]}),p.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function Aw(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function K5(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function W5(e){const[t,n]=_.useState(()=>F5(e));return _.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const s=window.matchMedia(e),l=()=>n(s.matches);return l(),typeof s.addEventListener=="function"?(s.addEventListener("change",l),()=>s.removeEventListener("change",l)):(s.addListener(l),()=>s.removeListener(l))},[e]),t}function F5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function q5(){if(typeof window>"u")return null;const e=FT(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function $5(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Ch(t.focus)}function V5(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Li(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function sn(e,t){return e===t}function Y5(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function Yd(e){return e??"__local__"}function xc(e,t,n){return`${Yd(e)}:${t}:${n}`}class gh extends Error{constructor(){super(Cx())}}function X5(e){return e?{workspaceKey:`${Mw}:${e}`}:{workspaceKey:Mw}}function G5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(u1(n))throw new gh;const s=c1(n);return s?wx(s):null}catch(n){if(n instanceof gh)throw n;return null}}function wx(e){if(u1(e))throw new gh;const t=c1(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function hc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function Z5(e,t){const n=Bt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function Q5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${co}. Re-open or delete hidden sessions before hiding more.`}function Cx(){return`A saved terminal layout has more than ${co} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function J5(e){const t=e.workspaces.find(l=>l.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(l=>l.id===t.activeTabId)??t?.tabs[0],s=n?e.terminals[n.activeTerminalId]:void 0;return s?.status==="running"?s:null}function eB(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function tB(e){return e.split("/").filter(Boolean).pop()??e}function iB(){try{return localStorage.getItem(bx)==="true"}catch{return!1}}function nB(e){try{localStorage.setItem(bx,e?"true":"false")}catch{}}function a_(e){return e??cr}function km(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(l=>e[l]===t[l])}function rB(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const s=Math.max(1,Math.floor(n/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function Lw({name:e}){return p.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M4 7h9"}),p.jsx("path",{d:"M17 7h3"}),p.jsx("circle",{cx:"15",cy:"7",r:"2"}),p.jsx("path",{d:"M4 12h3"}),p.jsx("path",{d:"M11 12h9"}),p.jsx("circle",{cx:"9",cy:"12",r:"2"}),p.jsx("path",{d:"M4 17h9"}),p.jsx("path",{d:"M17 17h3"}),p.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M10 6H6v12h4"}),p.jsx("path",{d:"M13 8l4 4-4 4"}),p.jsx("path",{d:"M8 12h9"})]}):null]})}function ra(e){return e instanceof Error?e.message:"Request failed"}function sB({api:e,onDone:t}){const[n,s]=_.useState(null),[l,c]=_.useState(null),[d,m]=_.useState(""),[g,f]=_.useState(!1),[y,b]=_.useState(null),[w,x]=_.useState(null);_.useEffect(()=>{let D=!1;return e.setupTotp().then(B=>{D||(s(B.qrDataUrl),c(B.secret))}).catch(B=>{D||x(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function C(D){if(D.preventDefault(),!!l){f(!0),b(null);try{await e.activateTotp({secret:l,otp:d}),t()}catch(B){b(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return w?p.jsx("p",{className:"form-error",children:w}):!n||!l?p.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):p.jsxs("div",{className:"totp-setup",children:[p.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),p.jsx("div",{className:"totp-qr-container",children:p.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),p.jsxs("details",{className:"totp-secret-details",children:[p.jsx("summary",{children:"Can't scan? Enter manually"}),p.jsx("p",{className:"totp-secret-text",children:l})]}),p.jsxs("form",{className:"auth-form",onSubmit:C,children:[p.jsxs("label",{children:["Verification code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?p.jsx("p",{className:"form-error",children:y}):null,p.jsx("button",{type:"submit",disabled:g||d.length!==6,children:"Activate 2FA"})]})]})}const xx="nterminal.clientDiagnostics.v1",kx=150,aB=24,lB=160;let Bw=!1,fc=null;function oB(){Bw||typeof window>"u"||(Bw=!0,Wn("page.load",{navigation:vB(),visibility:document.visibilityState,online:navigator.onLine,viewport:Dx(),standalone:_B()}),document.addEventListener("visibilitychange",()=>{Wn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Wn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Wn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Wn("network.online")),window.addEventListener("offline",()=>Wn("network.offline")),window.addEventListener("focus",()=>Wn("window.focus")),window.addEventListener("blur",()=>Wn("window.blur")),window.addEventListener("error",e=>{Wn("runtime.error",{message:e.message,source:bB(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Wn("runtime.unhandledrejection",{reason:yB(e.reason)})}))}function Wn(e,t={}){const n={at:new Date().toISOString(),event:zh(e,80),data:Tx({...t,visibility:t.visibility??mB(),online:t.online??gB(),viewport:t.viewport??Dx()})},s=Ex();return s.push(n),cB(s.slice(-kx)),n}function Ex(){try{const e=window.localStorage.getItem(xx);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(uB).filter(n=>n!==null).slice(-kx):[]}catch{return[]}}async function nv(e,t=fetch){if(fc)return fc;const n=Ex(),s={reason:zh(e,80),events:n},l=JSON.stringify(s);fc=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:l.length<48e3,body:l});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await fc}finally{fc=null}}function cB(e){try{window.localStorage.setItem(xx,JSON.stringify(e))}catch{}}function uB(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:zh(t.event,80),...t.data&&typeof t.data=="object"?{data:Tx(t.data)}:{}}}function Tx(e){const t={};for(const[n,s]of Object.entries(e).slice(0,aB)){const l=zh(n,64);if(!l||dB(l))continue;const c=hB(s);c!==void 0&&(t[l]=c)}return t}function dB(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function hB(e){if(typeof e=="string")return fB(e,lB);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function zh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function fB(e,t){return pB(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function pB(e){return e.replace(/https?:\/\/[^\s"'<>]+/gi,"[url]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[redacted]").replace(/\b((?:auth|authorization|cookie|password|secret|session|sessionid|session_id|token)[a-z0-9_.:-]*\s*[:=]\s*)[^\s&,;]+/gi,"$1[redacted]").replace(/\b(nterminal_session|nterminal_device)\s*=\s*[^\s;,]+/gi,"$1=[redacted]").replace(/\b[A-Za-z0-9+/_=-]{48,}\b/g,"[redacted]")}function mB(){return typeof document>"u"?void 0:document.visibilityState}function gB(){return typeof navigator>"u"?void 0:navigator.onLine}function Dx(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function _B(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function vB(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function bB(e){if(!e)return null;try{const t=new URL(e);return t.pathname.split("/").pop()||t.pathname}catch{return e.split("/").pop()??e}}function yB(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function SB(e){return{source:Em(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Em(e.terminalId)}:{},...e?.detail?{detail:Em(e.detail)}:{}}}function wB(e){return{invalidationSource:e.source}}function CB(e){Wn("auth.session_invalid.request",Rx(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),nv("session-invalid-request").catch(()=>{}))}function xB(e,t){Wn("auth.session_invalid.result",{...Rx(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),nv("session-invalid-result").catch(()=>{}))}function Rx(e){return{source:e.source,...typeof e.status=="number"?{status:e.status}:{},...e.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e.terminalId?{terminalId:e.terminalId}:{},...e.detail?{detail:e.detail}:{}}}function Em(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function kB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const l=_.useMemo(()=>e??_h(),[e]),c=_.useMemo(()=>t??eo(null),[t]),[d,m]=_.useState(null),[g,f]=_.useState(null),y=_.useRef(null),b=_.useRef("loading");_.useEffect(()=>{let L=!1;return l.getSession().then(O=>{L||(m(O),f(null))}).catch(O=>{L||(f(Ja(O)),m(null))}),()=>{L=!0}},[l]);const w=RB(d);_.useEffect(()=>{const L=b.current;Wn("auth.view",{view:w,previousView:L,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),L==="workspace"&&w!=="workspace"&&nv(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[d,w]);async function x(){const L=await l.getSession();m(L),f(null)}async function C(){gm(),xm(),tw(),f(null),m(null);try{await x()}catch(L){f(Ja(L))}}function D(L){const O=SB(L);if(CB(O),y.current)return y.current;const Y=(async()=>{f(null);try{const U=await l.getSession(wB(O));if(xB(O,U.authenticated),m(U),U.authenticated){zA();return}gm(),xm(),tw()}catch(U){f(Ja(U))}finally{y.current=null}})();return y.current=Y,Y}if(w==="workspace")return p.jsx(D5,{api:l,serverApi:c,activeAgentId:n,onSelectServer:s,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:L=>{D(L)},onLogout:async()=>{gm(),xm();const L=await l.logout();m(L)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return p.jsxs("main",{className:"auth-screen",children:[p.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[p.jsx("div",{className:"auth-grid"}),p.jsx("div",{className:"auth-glow"})]}),p.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[p.jsxs("header",{className:"auth-header",children:[p.jsxs("div",{className:"auth-brand",children:[p.jsx(Uw,{size:26}),p.jsxs("div",{children:[p.jsx(Kw,{height:17}),p.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),p.jsx("h1",{children:B[w]})]}),g?p.jsx("p",{className:"form-error",children:g}):null,w==="loading"?p.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{C()},children:"Retry"}):null,w==="setup_password"?p.jsx(EB,{api:l,onSession:L=>{m(L)}}):null,w==="setup_totp"?p.jsx(sB,{api:l,onDone:()=>{x()}}):null,w==="login"?p.jsx(TB,{api:l,session:d,onSession:m,onRefresh:x}):null,w==="reauth"?p.jsx(DB,{api:l,session:d,onSession:m,onFullLogin:()=>m(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function EB({api:e,onSession:t}){const[n,s]=_.useState(""),[l,c]=_.useState(""),[d,m]=_.useState(!1),[g,f]=_.useState(null);async function y(b){b.preventDefault(),m(!0),f(null);try{if(n!==l){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(w){f(Ja(w))}finally{m(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:y,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,value:n,onChange:b=>s(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),p.jsxs("label",{children:["Confirm password",p.jsx("input",{value:l,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?p.jsx("p",{className:"form-error",children:g}):null,p.jsx("button",{type:"submit",disabled:d||n.length<8||l.length<8,children:"Set password"})]})}function TB({api:e,session:t,onSession:n,onRefresh:s}){const[l,c]=_.useState(""),[d,m]=_.useState(""),[g,f]=_.useState(!1),[y,b]=_.useState(!1),[w,x]=_.useState(null),C=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function B(L){L.preventDefault(),b(!0),x(null);try{n(await e.login({password:l,...C?{otp:d}:{},rememberNetwork:g}))}catch(O){x(Ja(O))}finally{b(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:B,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,type:"password",value:l,onChange:L=>c(L.currentTarget.value),required:!0})]}),C?p.jsxs("label",{children:["Authenticator code",p.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:L=>m(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:g,onChange:L=>f(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?p.jsx("p",{className:"form-error",children:w}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:y||l.length===0||C&&d.length!==6,children:"Unlock"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:y,children:"Refresh"})]})]})}function DB({api:e,session:t,onSession:n,onFullLogin:s}){const l=t?.currentIpWhitelisted??!1,[c,d]=_.useState(""),[m,g]=_.useState(!1),[f,y]=_.useState(!1),[b,w]=_.useState(!1),[x,C]=_.useState(!1),[D,B]=_.useState(null),L=Ai.useCallback(async(Y,U)=>{y(!0),B(null);try{n(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:U}))}catch(Z){B(Ja(Z))}finally{y(!1)}},[e,n]);_.useEffect(()=>{if(l){let Y=!1;w(!0),C(!1),B(null);const U=window.setTimeout(()=>{Y||C(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(Z=>{Y||n(Z)}).catch(Z=>{Y||(B(Ja(Z)),C(!0))}).finally(()=>{window.clearTimeout(U),Y||w(!1)}),()=>{Y=!0,window.clearTimeout(U)}}},[e,l,n]);async function O(Y){Y.preventDefault(),await L(c,m)}return l&&b&&!x&&!D?p.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):p.jsxs("form",{className:"auth-form",onSubmit:O,children:[l&&x&&!D?p.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,p.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),p.jsxs("label",{children:["Authenticator code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>d(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:m,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?p.jsx("p",{className:"form-error",children:D}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function RB(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Ja(e){return e instanceof Error?e.message:"Request failed"}const Ow="NTerminal",l_="nterminal.activeAgentId";function MB(){const[e,t]=_.useState(()=>NB()),n=_.useMemo(()=>_h(),[]),s=_.useMemo(()=>eo(e),[e]);_.useEffect(()=>{const c=()=>{const d=K3();document.title=d>0?`(${d}) ${Ow}`:Ow};return c(),U3(c)},[]);function l(c){AB(c),t(c)}return p.jsx(kB,{api:n,activeAgentId:e,serverApi:s,onSelectServer:l})}function NB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(l_);return e&&e.trim()?e:null}catch{return null}}function AB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(l_,e);return}window.localStorage.removeItem(l_)}catch{}}const jw=["gesturestart","gesturechange","gestureend"],LB=[".workspace-list",".workspace-nav",".server-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview",".settings-content",".settings-nav",".transcript-dialog-scroll",".transcript-filter-group"].join(",");function BB(e=window){if(!jB(e))return()=>{};const t={passive:!1},n=e.document;function s(c){c.cancelable&&c.preventDefault()}function l(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!OB(c.target))&&s(c)}for(const c of jw)n.addEventListener(c,s,t);return n.addEventListener("touchmove",l,t),n.addEventListener("dblclick",s,t),()=>{for(const c of jw)n.removeEventListener(c,s,t);n.removeEventListener("touchmove",l,t),n.removeEventListener("dblclick",s,t)}}function OB(e){return e instanceof Element&&e.closest(LB)!==null}function jB(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}oB();qN();BB();h_();aE.createRoot(document.getElementById("root")).render(p.jsx(Ai.StrictMode,{children:p.jsx(MB,{})}));export{Ai as R,Zk as g,p as j};