nterminal 1.2.68 → 1.2.69

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 (46) hide show
  1. package/dist/client/assets/MarkdownPreview-DCHLz_jq.js +1 -0
  2. package/dist/client/assets/{TranscriptMarkdownBody-BunI06BW.js → TranscriptMarkdownBody-BaMp6W3l.js} +1 -1
  3. package/dist/client/assets/index-CDfP5jMv.js +55 -0
  4. package/dist/client/assets/{index-BwvExbdl.js → index-CLUAqRpO.js} +1 -1
  5. package/dist/client/assets/index-CszWmeOA.css +1 -0
  6. package/dist/client/index.html +2 -2
  7. package/dist/client/sw.js +51 -0
  8. package/dist/server/auth/authService.d.ts +1 -0
  9. package/dist/server/auth/authService.js +9 -3
  10. package/dist/server/auth/authService.js.map +1 -1
  11. package/dist/server/http.d.ts +2 -1
  12. package/dist/server/http.js +5 -0
  13. package/dist/server/http.js.map +1 -1
  14. package/dist/server/index.js +30 -2
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/server/notifications/agentCompletionMonitor.d.ts +27 -0
  17. package/dist/server/notifications/agentCompletionMonitor.js +148 -0
  18. package/dist/server/notifications/agentCompletionMonitor.js.map +1 -0
  19. package/dist/server/notifications/clientPresence.d.ts +40 -0
  20. package/dist/server/notifications/clientPresence.js +75 -0
  21. package/dist/server/notifications/clientPresence.js.map +1 -0
  22. package/dist/server/notifications/completionNotificationRouter.d.ts +28 -0
  23. package/dist/server/notifications/completionNotificationRouter.js +100 -0
  24. package/dist/server/notifications/completionNotificationRouter.js.map +1 -0
  25. package/dist/server/notifications/pushNotificationService.d.ts +80 -0
  26. package/dist/server/notifications/pushNotificationService.js +300 -0
  27. package/dist/server/notifications/pushNotificationService.js.map +1 -0
  28. package/dist/server/routes/pushNotificationRoutes.d.ts +11 -0
  29. package/dist/server/routes/pushNotificationRoutes.js +138 -0
  30. package/dist/server/routes/pushNotificationRoutes.js.map +1 -0
  31. package/dist/server/routes/terminalRoutes.d.ts +1 -0
  32. package/dist/server/routes/terminalRoutes.js +4 -1
  33. package/dist/server/routes/terminalRoutes.js.map +1 -1
  34. package/dist/server/storage/fileStore.d.ts +25 -1
  35. package/dist/server/storage/fileStore.js +65 -0
  36. package/dist/server/storage/fileStore.js.map +1 -1
  37. package/dist/server/terminal/TerminalManager.d.ts +12 -0
  38. package/dist/server/terminal/TerminalManager.js +44 -0
  39. package/dist/server/terminal/TerminalManager.js.map +1 -1
  40. package/dist/shared/protocol.d.ts +67 -0
  41. package/dist/shared/protocol.js.map +1 -1
  42. package/package.json +3 -1
  43. package/public/sw.js +51 -0
  44. package/dist/client/assets/MarkdownPreview-DOXE7Rl3.js +0 -1
  45. package/dist/client/assets/index-Br4cNNw1.css +0 -1
  46. package/dist/client/assets/index-DeiwbfGQ.js +0 -55
@@ -1,55 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-DOXE7Rl3.js","assets/index-BwvExbdl.js","assets/TranscriptMarkdownBody-BunI06BW.js"])))=>i.map(i=>d[i]);
2
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(o){if(o.ep)return;o.ep=!0;const c=r(o);fetch(o.href,c)}})();function Sk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xf={exports:{}},Mo={};var Db;function wk(){if(Db)return Mo;Db=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,o,c){var h=null;if(c!==void 0&&(h=""+c),o.key!==void 0&&(h=""+o.key),"key"in o){c={};for(var p in o)p!=="key"&&(c[p]=o[p])}else c=o;return o=c.ref,{$$typeof:e,type:s,key:h,ref:o!==void 0?o:null,props:c}}return Mo.Fragment=t,Mo.jsx=r,Mo.jsxs=r,Mo}var Rb;function Ck(){return Rb||(Rb=1,Xf.exports=wk()),Xf.exports}var m=Ck(),Gf={exports:{}},Ze={};var Mb;function xk(){if(Mb)return Ze;Mb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,L={};function A(M,Q,fe){this.props=M,this.context=Q,this.refs=L,this.updater=fe||x}A.prototype.isReactComponent={},A.prototype.setState=function(M,Q){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,Q,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function B(){}B.prototype=A.prototype;function V(M,Q,fe){this.props=M,this.context=Q,this.refs=L,this.updater=fe||x}var H=V.prototype=new B;H.constructor=V,D(H,A.prototype),H.isPureReactComponent=!0;var F=Array.isArray;function re(){}var ne={H:null,A:null,T:null,S:null},de=Object.prototype.hasOwnProperty;function ve(M,Q,fe){var me=fe.ref;return{$$typeof:e,type:M,key:Q,ref:me!==void 0?me:null,props:fe}}function U(M,Q){return ve(M.type,Q,M.props)}function K(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function W(M){var Q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(fe){return Q[fe]})}var P=/\/+/g;function j(M,Q){return typeof M=="object"&&M!==null&&M.key!=null?W(""+M.key):Q.toString(36)}function ae(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(re,re):(M.status="pending",M.then(function(Q){M.status==="pending"&&(M.status="fulfilled",M.value=Q)},function(Q){M.status==="pending"&&(M.status="rejected",M.reason=Q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function R(M,Q,fe,me,ge){var Se=typeof M;(Se==="undefined"||Se==="boolean")&&(M=null);var Ee=!1;if(M===null)Ee=!0;else switch(Se){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(M.$$typeof){case e:case t:Ee=!0;break;case b:return Ee=M._init,R(Ee(M._payload),Q,fe,me,ge)}}if(Ee)return ge=ge(M),Ee=me===""?"."+j(M,0):me,F(ge)?(fe="",Ee!=null&&(fe=Ee.replace(P,"$&/")+"/"),R(ge,Q,fe,"",function(te){return te})):ge!=null&&(K(ge)&&(ge=U(ge,fe+(ge.key==null||M&&M.key===ge.key?"":(""+ge.key).replace(P,"$&/")+"/")+Ee)),Q.push(ge)),1;Ee=0;var Ne=me===""?".":me+":";if(F(M))for(var Ue=0;Ue<M.length;Ue++)me=M[Ue],Se=Ne+j(me,Ue),Ee+=R(me,Q,fe,Se,ge);else if(Ue=w(M),typeof Ue=="function")for(M=Ue.call(M),Ue=0;!(me=M.next()).done;)me=me.value,Se=Ne+j(me,Ue++),Ee+=R(me,Q,fe,Se,ge);else if(Se==="object"){if(typeof M.then=="function")return R(ae(M),Q,fe,me,ge);throw Q=String(M),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.")}return Ee}function Y(M,Q,fe){if(M==null)return M;var me=[],ge=0;return R(M,me,"","",function(Se){return Q.call(fe,Se,ge++)}),me}function G(M){if(M._status===-1){var Q=M._result;Q=Q(),Q.then(function(fe){(M._status===0||M._status===-1)&&(M._status=1,M._result=fe)},function(fe){(M._status===0||M._status===-1)&&(M._status=2,M._result=fe)}),M._status===-1&&(M._status=0,M._result=Q)}if(M._status===1)return M._result.default;throw M._result}var Ce=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Q=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(Q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},Te={map:Y,forEach:function(M,Q,fe){Y(M,function(){Q.apply(this,arguments)},fe)},count:function(M){var Q=0;return Y(M,function(){Q++}),Q},toArray:function(M){return Y(M,function(Q){return Q})||[]},only:function(M){if(!K(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ze.Activity=y,Ze.Children=Te,Ze.Component=A,Ze.Fragment=r,Ze.Profiler=o,Ze.PureComponent=V,Ze.StrictMode=s,Ze.Suspense=g,Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ne,Ze.__COMPILER_RUNTIME={__proto__:null,c:function(M){return ne.H.useMemoCache(M)}},Ze.cache=function(M){return function(){return M.apply(null,arguments)}},Ze.cacheSignal=function(){return null},Ze.cloneElement=function(M,Q,fe){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var me=D({},M.props),ge=M.key;if(Q!=null)for(Se in Q.key!==void 0&&(ge=""+Q.key),Q)!de.call(Q,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Q.ref===void 0||(me[Se]=Q[Se]);var Se=arguments.length-2;if(Se===1)me.children=fe;else if(1<Se){for(var Ee=Array(Se),Ne=0;Ne<Se;Ne++)Ee[Ne]=arguments[Ne+2];me.children=Ee}return ve(M.type,ge,me)},Ze.createContext=function(M){return M={$$typeof:h,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Ze.createElement=function(M,Q,fe){var me,ge={},Se=null;if(Q!=null)for(me in Q.key!==void 0&&(Se=""+Q.key),Q)de.call(Q,me)&&me!=="key"&&me!=="__self"&&me!=="__source"&&(ge[me]=Q[me]);var Ee=arguments.length-2;if(Ee===1)ge.children=fe;else if(1<Ee){for(var Ne=Array(Ee),Ue=0;Ue<Ee;Ue++)Ne[Ue]=arguments[Ue+2];ge.children=Ne}if(M&&M.defaultProps)for(me in Ee=M.defaultProps,Ee)ge[me]===void 0&&(ge[me]=Ee[me]);return ve(M,Se,ge)},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(M){return{$$typeof:p,render:M}},Ze.isValidElement=K,Ze.lazy=function(M){return{$$typeof:b,_payload:{_status:-1,_result:M},_init:G}},Ze.memo=function(M,Q){return{$$typeof:f,type:M,compare:Q===void 0?null:Q}},Ze.startTransition=function(M){var Q=ne.T,fe={};ne.T=fe;try{var me=M(),ge=ne.S;ge!==null&&ge(fe,me),typeof me=="object"&&me!==null&&typeof me.then=="function"&&me.then(re,Ce)}catch(Se){Ce(Se)}finally{Q!==null&&fe.types!==null&&(Q.types=fe.types),ne.T=Q}},Ze.unstable_useCacheRefresh=function(){return ne.H.useCacheRefresh()},Ze.use=function(M){return ne.H.use(M)},Ze.useActionState=function(M,Q,fe){return ne.H.useActionState(M,Q,fe)},Ze.useCallback=function(M,Q){return ne.H.useCallback(M,Q)},Ze.useContext=function(M){return ne.H.useContext(M)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(M,Q){return ne.H.useDeferredValue(M,Q)},Ze.useEffect=function(M,Q){return ne.H.useEffect(M,Q)},Ze.useEffectEvent=function(M){return ne.H.useEffectEvent(M)},Ze.useId=function(){return ne.H.useId()},Ze.useImperativeHandle=function(M,Q,fe){return ne.H.useImperativeHandle(M,Q,fe)},Ze.useInsertionEffect=function(M,Q){return ne.H.useInsertionEffect(M,Q)},Ze.useLayoutEffect=function(M,Q){return ne.H.useLayoutEffect(M,Q)},Ze.useMemo=function(M,Q){return ne.H.useMemo(M,Q)},Ze.useOptimistic=function(M,Q){return ne.H.useOptimistic(M,Q)},Ze.useReducer=function(M,Q,fe){return ne.H.useReducer(M,Q,fe)},Ze.useRef=function(M){return ne.H.useRef(M)},Ze.useState=function(M){return ne.H.useState(M)},Ze.useSyncExternalStore=function(M,Q,fe){return ne.H.useSyncExternalStore(M,Q,fe)},Ze.useTransition=function(){return ne.H.useTransition()},Ze.version="19.2.6",Ze}var Nb;function ag(){return Nb||(Nb=1,Gf.exports=xk()),Gf.exports}var v=ag();const Ti=Sk(v);var Zf={exports:{}},No={},Qf={exports:{}},Jf={};var Ab;function kk(){return Ab||(Ab=1,(function(e){function t(R,Y){var G=R.length;R.push(Y);e:for(;0<G;){var Ce=G-1>>>1,Te=R[Ce];if(0<o(Te,Y))R[Ce]=Y,R[G]=Te,G=Ce;else break e}}function r(R){return R.length===0?null:R[0]}function s(R){if(R.length===0)return null;var Y=R[0],G=R.pop();if(G!==Y){R[0]=G;e:for(var Ce=0,Te=R.length,M=Te>>>1;Ce<M;){var Q=2*(Ce+1)-1,fe=R[Q],me=Q+1,ge=R[me];if(0>o(fe,G))me<Te&&0>o(ge,fe)?(R[Ce]=ge,R[me]=G,Ce=me):(R[Ce]=fe,R[Q]=G,Ce=Q);else if(me<Te&&0>o(ge,G))R[Ce]=ge,R[me]=G,Ce=me;else break e}}return Y}function o(R,Y){var G=R.sortIndex-Y.sortIndex;return G!==0?G:R.id-Y.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 h=Date,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],b=1,y=null,S=3,w=!1,x=!1,D=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,V=typeof setImmediate<"u"?setImmediate:null;function H(R){for(var Y=r(f);Y!==null;){if(Y.callback===null)s(f);else if(Y.startTime<=R)s(f),Y.sortIndex=Y.expirationTime,t(g,Y);else break;Y=r(f)}}function F(R){if(D=!1,H(R),!x)if(r(g)!==null)x=!0,re||(re=!0,W());else{var Y=r(f);Y!==null&&ae(F,Y.startTime-R)}}var re=!1,ne=-1,de=5,ve=-1;function U(){return L?!0:!(e.unstable_now()-ve<de)}function K(){if(L=!1,re){var R=e.unstable_now();ve=R;var Y=!0;try{e:{x=!1,D&&(D=!1,B(ne),ne=-1),w=!0;var G=S;try{t:{for(H(R),y=r(g);y!==null&&!(y.expirationTime>R&&U());){var Ce=y.callback;if(typeof Ce=="function"){y.callback=null,S=y.priorityLevel;var Te=Ce(y.expirationTime<=R);if(R=e.unstable_now(),typeof Te=="function"){y.callback=Te,H(R),Y=!0;break t}y===r(g)&&s(g),H(R)}else s(g);y=r(g)}if(y!==null)Y=!0;else{var M=r(f);M!==null&&ae(F,M.startTime-R),Y=!1}}break e}finally{y=null,S=G,w=!1}Y=void 0}}finally{Y?W():re=!1}}}var W;if(typeof V=="function")W=function(){V(K)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,j=P.port2;P.port1.onmessage=K,W=function(){j.postMessage(null)}}else W=function(){A(K,0)};function ae(R,Y){ne=A(function(){R(e.unstable_now())},Y)}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(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):de=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(R){switch(S){case 1:case 2:case 3:var Y=3;break;default:Y=S}var G=S;S=Y;try{return R()}finally{S=G}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(R,Y){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var G=S;S=R;try{return Y()}finally{S=G}},e.unstable_scheduleCallback=function(R,Y,G){var Ce=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?Ce+G:Ce):G=Ce,R){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=G+Te,R={id:b++,callback:Y,priorityLevel:R,startTime:G,expirationTime:Te,sortIndex:-1},G>Ce?(R.sortIndex=G,t(f,R),r(g)===null&&R===r(f)&&(D?(B(ne),ne=-1):D=!0,ae(F,G-Ce))):(R.sortIndex=Te,t(g,R),x||w||(x=!0,re||(re=!0,W()))),R},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(R){var Y=S;return function(){var G=S;S=Y;try{return R.apply(this,arguments)}finally{S=G}}}})(Jf)),Jf}var Lb;function Ek(){return Lb||(Lb=1,Qf.exports=kk()),Qf.exports}var ep={exports:{}},nn={};var Bb;function Tk(){if(Bb)return nn;Bb=1;var e=ag();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}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 r(){}var s={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:g,containerInfo:f,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return nn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,nn.createPortal=function(g,f){var b=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,b)},nn.flushSync=function(g){var f=h.T,b=s.p;try{if(h.T=null,s.p=2,g)return g()}finally{h.T=f,s.p=b,s.d.f()}},nn.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))},nn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},nn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:w}):b==="script"&&s.d.X(g,{crossOrigin:y,integrity:S,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},nn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:b,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)},nn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);s.d.L(g,b,{crossOrigin:y,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})}},nn.preloadModule=function(g,f){if(typeof g=="string")if(f){var b=p(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},nn.requestFormReset=function(g){s.d.r(g)},nn.unstable_batchedUpdates=function(g,f){return g(f)},nn.useFormState=function(g,f,b){return h.H.useFormState(g,f,b)},nn.useFormStatus=function(){return h.H.useHostTransitionStatus()},nn.version="19.2.6",nn}var Ob;function I0(){if(Ob)return ep.exports;Ob=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(),ep.exports=Tk(),ep.exports}var zb;function Dk(){if(zb)return No;zb=1;var e=Ek(),t=ag(),r=I0();function s(i){var n="https://react.dev/errors/"+i;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var n=i,a=i;if(i.alternate)for(;n.return;)n=n.return;else{i=n;do n=i,(n.flags&4098)!==0&&(a=n.return),i=n.return;while(i)}return n.tag===3?a:null}function h(i){if(i.tag===13){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function p(i){if(i.tag===31){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(s(188));return n!==i?null:i}for(var a=i,l=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===l)return g(u),n;d=d.sibling}throw Error(s(188))}if(a.return!==l.return)a=u,l=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,l=d;break}if(C===l){_=!0,l=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,l=u;break}if(C===l){_=!0,l=d,a=u;break}C=C.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==l)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:n}function b(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=b(i),n!==null)return n;i=i.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),V=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),de=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function W(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var P=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===P?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case F:return"Suspense";case re:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case V:return i.displayName||"Context";case B:return(i._context.displayName||"Context")+".Consumer";case H:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ne:return n=i.displayName||null,n!==null?n:j(i.type)||"Memo";case de:n=i._payload,i=i._init;try{return j(i(n))}catch{}}return null}var ae=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},Ce=[],Te=-1;function M(i){return{current:i}}function Q(i){0>Te||(i.current=Ce[Te],Ce[Te]=null,Te--)}function fe(i,n){Te++,Ce[Te]=i.current,i.current=n}var me=M(null),ge=M(null),Se=M(null),Ee=M(null);function Ne(i,n){switch(fe(Se,n),fe(ge,i),fe(me,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?Zy(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=Zy(n),i=Qy(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Q(me),fe(me,i)}function Ue(){Q(me),Q(ge),Q(Se)}function te(i){i.memoizedState!==null&&fe(Ee,i);var n=me.current,a=Qy(n,i.type);n!==a&&(fe(ge,i),fe(me,a))}function _e(i){ge.current===i&&(Q(me),Q(ge)),Ee.current===i&&(Q(Ee),Eo._currentValue=G)}var Ae,we;function Me(i){if(Ae===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Ae=n&&n[1]||"",we=-1<a.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+Ae+i+we}var Ie=!1;function We(i,n){if(!i||Ie)return"";Ie=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(ee){var X=ee}Reflect.construct(i,[],he)}else{try{he.call()}catch(ee){X=ee}i.call(he.prototype)}}else{try{throw Error()}catch(ee){X=ee}(he=i())&&typeof he.catch=="function"&&he.catch(function(){})}}catch(ee){if(ee&&X&&typeof ee.stack=="string")return[ee.stack,X.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=l.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var N=_.split(`
5
- `),$=C.split(`
6
- `);for(u=l=0;l<N.length&&!N[l].includes("DetermineComponentFrameRoot");)l++;for(;u<$.length&&!$[u].includes("DetermineComponentFrameRoot");)u++;if(l===N.length||u===$.length)for(l=N.length-1,u=$.length-1;1<=l&&0<=u&&N[l]!==$[u];)u--;for(;1<=l&&0<=u;l--,u--)if(N[l]!==$[u]){if(l!==1||u!==1)do if(l--,u--,0>u||N[l]!==$[u]){var oe=`
7
- `+N[l].replace(" at new "," at ");return i.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",i.displayName)),oe}while(1<=l&&0<=u);break}}}finally{Ie=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Me(a):""}function ie(i,n){switch(i.tag){case 26:case 27:case 5:return Me(i.type);case 16:return Me("Lazy");case 13:return i.child!==n&&n!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return We(i.type,!1);case 11:return We(i.type.render,!1);case 1:return We(i.type,!0);case 31:return Me("Activity");default:return""}}function ke(i){try{var n="",a=null;do n+=ie(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
8
- Error generating stack: `+l.message+`
9
- `+l.stack}}var De=Object.prototype.hasOwnProperty,Le=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,at=e.unstable_shouldYield,Bt=e.unstable_requestPaint,$e=e.unstable_now,St=e.unstable_getCurrentPriorityLevel,Z=e.unstable_ImmediatePriority,Ke=e.unstable_UserBlockingPriority,le=e.unstable_NormalPriority,ze=e.unstable_LowPriority,Qe=e.unstable_IdlePriority,ft=e.log,$t=e.unstable_setDisableYieldValue,Tt=null,Ot=null;function Qt(i){if(typeof ft=="function"&&$t(i),Ot&&typeof Ot.setStrictMode=="function")try{Ot.setStrictMode(Tt,i)}catch{}}var At=Math.clz32?Math.clz32:gr,Ri=Math.log,Wi=Math.LN2;function gr(i){return i>>>=0,i===0?32:31-(Ri(i)/Wi|0)|0}var Qi=256,Mi=262144,vt=4194304;function Dt(i){var n=i&42;if(n!==0)return n;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 Kt(i,n,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=l&134217727;return C!==0?(l=C&~d,l!==0?u=Dt(l):(_&=C,_!==0?u=Dt(_):a||(a=C&~i,a!==0&&(u=Dt(a))))):(C=l&~d,C!==0?u=Dt(C):_!==0?u=Dt(_):a||(a=l&~i,a!==0&&(u=Dt(a)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,a=n&-n,d>=a||d===32&&(a&4194048)!==0)?n:u}function Vt(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function Si(i,n){switch(i){case 1:case 2:case 4:case 8:case 64:return n+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 n+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=vt;return vt<<=1,(vt&62914560)===0&&(vt=4194304),i}function Lt(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function Fi(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function zt(i,n,a,l,u,d){var _=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 C=i.entanglements,N=i.expirationTimes,$=i.hiddenUpdates;for(a=_&~a;0<a;){var oe=31-At(a),he=1<<oe;C[oe]=0,N[oe]=-1;var X=$[oe];if(X!==null)for($[oe]=null,oe=0;oe<X.length;oe++){var ee=X[oe];ee!==null&&(ee.lane&=-536870913)}a&=~he}l!==0&&wt(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function wt(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-At(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function Yt(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-At(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function si(i,n){var a=n&-n;return a=(a&42)!==0?1:Ji(a),(a&(i.suspendedLanes|n))!==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 wn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Ni(){var i=Y.p;return i!==0?i:(i=window.event,i===void 0?32:Sb(i.type))}function Cn(i,n){var a=Y.p;try{return Y.p=i,n()}finally{Y.p=a}}var qi=Math.random().toString(36).slice(2),Wt="__reactFiber$"+qi,Ai="__reactProps$"+qi,ai="__reactContainer$"+qi,Nr="__reactEvents$"+qi,Ha="__reactListeners$"+qi,Wl="__reactHandles$"+qi,rs="__reactResources$"+qi,ir="__reactMarker$"+qi;function Xs(i){delete i[Wt],delete i[Ai],delete i[Nr],delete i[Ha],delete i[Wl]}function nr(i){var n=i[Wt];if(n)return n;for(var a=i.parentNode;a;){if(n=a[ai]||a[Wt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=sb(i);i!==null;){if(a=i[Wt])return a;i=sb(i)}return n}i=a,a=i.parentNode}return null}function rr(i){if(i=i[Wt]||i[ai]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function Hn(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(s(33))}function sr(i){var n=i[rs];return n||(n=i[rs]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function jt(i){i[ir]=!0}var Pa=new Set,Ia={};function ar(i,n){Pn(i,n),Pn(i+"Capture",n)}function Pn(i,n){for(Ia[i]=n,i=0;i<n.length;i++)Pa.add(n[i])}var Ua=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]*$"),Ka={},Wa={};function Fl(i){return De.call(Wa,i)?!0:De.call(Ka,i)?!1:Ua.test(i)?Wa[i]=!0:(Ka[i]=!0,!1)}function _r(i,n,a){if(Fl(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function ss(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function Li(i,n,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+l)}}function li(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function xn(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Jt(i,n,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,d=l.set;return Object.defineProperty(i,n,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,n,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function nt(i){if(!i._valueTracker){var n=xn(i)?"checked":"value";i._valueTracker=Jt(i,n,""+i[n])}}function Ar(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=xn(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function kn(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 oi=/[\n"\\]/g;function $i(i){return i.replace(oi,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function as(i,n,a,l,u,d,_,C){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),n!=null?_==="number"?(n===0&&i.value===""||i.value!=n)&&(i.value=""+li(n)):i.value!==""+li(n)&&(i.value=""+li(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?Lr(i,_,li(n)):a!=null?Lr(i,_,li(a)):l!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+li(C):i.removeAttribute("name")}function Gs(i,n,a,l,u,d,_,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),n!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){nt(i);return}a=a!=null?""+li(a):"",n=n!=null?""+li(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=C?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),nt(i)}function Lr(i,n,a){n==="number"&&kn(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function vr(i,n,a,l){if(i=i.options,n){n={};for(var u=0;u<a.length;u++)n["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=n.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+li(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function Zs(i,n,a){if(n!=null&&(n=""+li(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+li(a):""}function In(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(s(92));if(ae(l)){if(1<l.length)throw Error(s(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=li(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),nt(i)}function Un(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var ql=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 Qs(i,n,a){var l=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":l?i.setProperty(n,a):typeof a!="number"||a===0||ql.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Fa(i,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in n)l=n[u],n.hasOwnProperty(u)&&a[u]!==l&&Qs(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&Qs(i,d,n[d])}function lr(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 ls=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"]]),cn=/^[\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 un(i){return cn.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function hn(){}var os=null;function Js(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var or=null,yr=null;function qa(i){var n=rr(i);if(n&&(i=n.stateNode)){var a=i[Ai]||null;e:switch(i=n.stateNode,n.type){case"input":if(as(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+$i(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[Ai]||null;if(!u)throw Error(s(90));as(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)l=a[n],l.form===i.form&&Ar(l)}break e;case"textarea":Zs(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&vr(i,!!a.multiple,n,!1)}}}var ea=!1;function Br(i,n,a){if(ea)return i(n,a);ea=!0;try{var l=i(n);return l}finally{if(ea=!1,(or!==null||yr!==null)&&(mu(),or&&(n=or,i=yr,yr=or=null,qa(n),i)))for(n=0;n<i.length;n++)qa(i[n])}}function dn(i,n){var a=i.stateNode;if(a===null)return null;var l=a[Ai]||null;if(l===null)return null;a=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var fn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cs=!1;if(fn)try{var en={};Object.defineProperty(en,"passive",{get:function(){cs=!0}}),window.addEventListener("test",en,en),window.removeEventListener("test",en,en)}catch{cs=!1}var tn=null,us=null,k=null;function E(){if(k)return k;var i,n=us,a=n.length,l,u="value"in tn?tn.value:tn.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&n[a-l]===u[d-l];l++);return k=u.slice(i,1<l?1-l:void 0)}function z(i){var n=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&n===13&&(i=13)):i=n,i===10&&(i=13),32<=i||i===13?i:0}function se(){return!0}function ye(){return!1}function ce(i){function n(a,l,u,d,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(a=i[C],this[C]=a?a(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?se:ye,this.isPropagationStopped=ye,this}return y(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=se)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=se)},persist:function(){},isPersistent:se}),n}var be={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qe=ce(be),et=y({},be,{view:0,detail:0}),ci=ce(et),Ht,T,J,He=y({},et,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Jh,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!==J&&(J&&i.type==="mousemove"?(Ht=i.screenX-J.screenX,T=i.screenY-J.screenY):T=Ht=0,J=i),Ht)},movementY:function(i){return"movementY"in i?i.movementY:T}}),Ye=ce(He),Ge=y({},He,{dataTransfer:0}),ut=ce(Ge),fi=y({},et,{relatedTarget:0}),Bi=ce(fi),Xt=y({},be,{animationName:0,elapsedTime:0,pseudoElement:0}),wi=ce(Xt),ta=y({},be,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),En=ce(ta),Mc=y({},be,{data:0}),Nc=ce(Mc),br={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ac={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"},Lc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function NC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=Lc[i])?!!n[i]:!1}function Jh(){return NC}var AC=y({},et,{key:function(i){if(i.key){var n=br[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=z(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Ac[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Jh,charCode:function(i){return i.type==="keypress"?z(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?z(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),LC=ce(AC),BC=y({},He,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),i_=ce(BC),OC=y({},et,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Jh}),zC=ce(OC),jC=y({},be,{propertyName:0,elapsedTime:0,pseudoElement:0}),HC=ce(jC),PC=y({},He,{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}),IC=ce(PC),UC=y({},be,{newState:0,oldState:0}),KC=ce(UC),WC=[9,13,27,32],ed=fn&&"CompositionEvent"in window,$l=null;fn&&"documentMode"in document&&($l=document.documentMode);var FC=fn&&"TextEvent"in window&&!$l,n_=fn&&(!ed||$l&&8<$l&&11>=$l),r_=" ",s_=!1;function a_(i,n){switch(i){case"keyup":return WC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function l_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var $a=!1;function qC(i,n){switch(i){case"compositionend":return l_(n);case"keypress":return n.which!==32?null:(s_=!0,r_);case"textInput":return i=n.data,i===r_&&s_?null:i;default:return null}}function $C(i,n){if($a)return i==="compositionend"||!ed&&a_(i,n)?(i=E(),k=us=tn=null,$a=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return n_&&n.locale!=="ko"?null:n.data;default:return null}}var VC={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 o_(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!VC[i.type]:n==="textarea"}function c_(i,n,a,l){or?yr?yr.push(l):yr=[l]:or=l,n=wu(n,"onChange"),0<n.length&&(a=new qe("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var Vl=null,Yl=null;function YC(i){qy(i,0)}function Bc(i){var n=Hn(i);if(Ar(n))return i}function u_(i,n){if(i==="change")return n}var h_=!1;if(fn){var td;if(fn){var id="oninput"in document;if(!id){var d_=document.createElement("div");d_.setAttribute("oninput","return;"),id=typeof d_.oninput=="function"}td=id}else td=!1;h_=td&&(!document.documentMode||9<document.documentMode)}function f_(){Vl&&(Vl.detachEvent("onpropertychange",p_),Yl=Vl=null)}function p_(i){if(i.propertyName==="value"&&Bc(Yl)){var n=[];c_(n,Yl,i,Js(i)),Br(YC,n)}}function XC(i,n,a){i==="focusin"?(f_(),Vl=n,Yl=a,Vl.attachEvent("onpropertychange",p_)):i==="focusout"&&f_()}function GC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Bc(Yl)}function ZC(i,n){if(i==="click")return Bc(n)}function QC(i,n){if(i==="input"||i==="change")return Bc(n)}function JC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var Tn=typeof Object.is=="function"?Object.is:JC;function Xl(i,n){if(Tn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),l=Object.keys(n);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!De.call(n,u)||!Tn(i[u],n[u]))return!1}return!0}function m_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function g_(i,n){var a=m_(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=n&&l>=n)return{node:a,offset:n-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=m_(a)}}function __(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?__(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function v_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=kn(i.document);n instanceof i.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)i=n.contentWindow;else break;n=kn(i.document)}return n}function nd(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n&&(n==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||n==="textarea"||i.contentEditable==="true")}var ex=fn&&"documentMode"in document&&11>=document.documentMode,Va=null,rd=null,Gl=null,sd=!1;function y_(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;sd||Va==null||Va!==kn(l)||(l=Va,"selectionStart"in l&&nd(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Gl&&Xl(Gl,l)||(Gl=l,l=wu(rd,"onSelect"),0<l.length&&(n=new qe("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=Va)))}function ia(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var Ya={animationend:ia("Animation","AnimationEnd"),animationiteration:ia("Animation","AnimationIteration"),animationstart:ia("Animation","AnimationStart"),transitionrun:ia("Transition","TransitionRun"),transitionstart:ia("Transition","TransitionStart"),transitioncancel:ia("Transition","TransitionCancel"),transitionend:ia("Transition","TransitionEnd")},ad={},b_={};fn&&(b_=document.createElement("div").style,"AnimationEvent"in window||(delete Ya.animationend.animation,delete Ya.animationiteration.animation,delete Ya.animationstart.animation),"TransitionEvent"in window||delete Ya.transitionend.transition);function na(i){if(ad[i])return ad[i];if(!Ya[i])return i;var n=Ya[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in b_)return ad[i]=n[a];return i}var S_=na("animationend"),w_=na("animationiteration"),C_=na("animationstart"),tx=na("transitionrun"),ix=na("transitionstart"),nx=na("transitioncancel"),x_=na("transitionend"),k_=new Map,ld="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(" ");ld.push("scrollEnd");function cr(i,n){k_.set(i,n),ar(n,[i])}var Oc=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Kn=[],Xa=0,od=0;function zc(){for(var i=Xa,n=od=Xa=0;n<i;){var a=Kn[n];Kn[n++]=null;var l=Kn[n];Kn[n++]=null;var u=Kn[n];Kn[n++]=null;var d=Kn[n];if(Kn[n++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}d!==0&&E_(a,u,d)}}function jc(i,n,a,l){Kn[Xa++]=i,Kn[Xa++]=n,Kn[Xa++]=a,Kn[Xa++]=l,od|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function cd(i,n,a,l){return jc(i,n,a,l),Hc(i)}function ra(i,n){return jc(i,null,null,n),Hc(i)}function E_(i,n,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,l=d.alternate,l!==null&&(l.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&n!==null&&(u=31-At(a),i=d.hiddenUpdates,l=i[u],l===null?i[u]=[n]:l.push(n),n.lane=a|536870912),d):null}function Hc(i){if(50<yo)throw yo=0,yf=null,Error(s(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var Ga={};function rx(i,n,a,l){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=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Dn(i,n,a,l){return new rx(i,n,a,l)}function ud(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Or(i,n){var a=i.alternate;return a===null?(a=Dn(i.tag,n,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=n,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,n=i.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function T_(i,n){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=n,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,n=a.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),i}function Pc(i,n,a,l,u,d){var _=0;if(l=i,typeof i=="function")ud(i)&&(_=1);else if(typeof i=="string")_=ck(i,a,me.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=Dn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case D:return sa(a.children,u,d,n);case L:_=8,u|=24;break;case A:return i=Dn(12,a,n,u|2),i.elementType=A,i.lanes=d,i;case F:return i=Dn(13,a,n,u),i.elementType=F,i.lanes=d,i;case re:return i=Dn(19,a,n,u),i.elementType=re,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case V:_=10;break e;case B:_=9;break e;case H:_=11;break e;case ne:_=14;break e;case de:_=16,l=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),l=null}return n=Dn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function sa(i,n,a,l){return i=Dn(7,i,l,n),i.lanes=a,i}function hd(i,n,a){return i=Dn(6,i,null,n),i.lanes=a,i}function D_(i){var n=Dn(18,null,null,0);return n.stateNode=i,n}function dd(i,n,a){return n=Dn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var R_=new WeakMap;function Wn(i,n){if(typeof i=="object"&&i!==null){var a=R_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:ke(n)},R_.set(i,n),n)}return{value:i,source:n,stack:ke(n)}}var Za=[],Qa=0,Ic=null,Zl=0,Fn=[],qn=0,hs=null,Sr=1,wr="";function zr(i,n){Za[Qa++]=Zl,Za[Qa++]=Ic,Ic=i,Zl=n}function M_(i,n,a){Fn[qn++]=Sr,Fn[qn++]=wr,Fn[qn++]=hs,hs=i;var l=Sr;i=wr;var u=32-At(l)-1;l&=~(1<<u),a+=1;var d=32-At(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,Sr=1<<32-At(n)+u|a<<u|l,wr=d+i}else Sr=1<<d|a<<u|l,wr=i}function fd(i){i.return!==null&&(zr(i,1),M_(i,1,0))}function pd(i){for(;i===Ic;)Ic=Za[--Qa],Za[Qa]=null,Zl=Za[--Qa],Za[Qa]=null;for(;i===hs;)hs=Fn[--qn],Fn[qn]=null,wr=Fn[--qn],Fn[qn]=null,Sr=Fn[--qn],Fn[qn]=null}function N_(i,n){Fn[qn++]=Sr,Fn[qn++]=wr,Fn[qn++]=hs,Sr=n.id,wr=n.overflow,hs=i}var Vi=null,Pt=null,pt=!1,ds=null,$n=!1,md=Error(s(519));function fs(i){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ql(Wn(n,i)),md}function A_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[Wt]=i,n[Ai]=l,a){case"dialog":ot("cancel",n),ot("close",n);break;case"iframe":case"object":case"embed":ot("load",n);break;case"video":case"audio":for(a=0;a<So.length;a++)ot(So[a],n);break;case"source":ot("error",n);break;case"img":case"image":case"link":ot("error",n),ot("load",n);break;case"details":ot("toggle",n);break;case"input":ot("invalid",n),Gs(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ot("invalid",n);break;case"textarea":ot("invalid",n),In(n,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||l.suppressHydrationWarning===!0||Xy(n.textContent,a)?(l.popover!=null&&(ot("beforetoggle",n),ot("toggle",n)),l.onScroll!=null&&ot("scroll",n),l.onScrollEnd!=null&&ot("scrollend",n),l.onClick!=null&&(n.onclick=hn),n=!0):n=!1,n||fs(i,!0)}function L_(i){for(Vi=i.return;Vi;)switch(Vi.tag){case 5:case 31:case 13:$n=!1;return;case 27:case 3:$n=!0;return;default:Vi=Vi.return}}function Ja(i){if(i!==Vi)return!1;if(!pt)return L_(i),pt=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Bf(i.type,i.memoizedProps)),a=!a),a&&Pt&&fs(i),L_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Pt=rb(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Pt=rb(i)}else n===27?(n=Pt,Ts(i.type)?(i=Pf,Pf=null,Pt=i):Pt=n):Pt=Vi?Yn(i.stateNode.nextSibling):null;return!0}function aa(){Pt=Vi=null,pt=!1}function gd(){var i=ds;return i!==null&&(_n===null?_n=i:_n.push.apply(_n,i),ds=null),i}function Ql(i){ds===null?ds=[i]:ds.push(i)}var _d=M(null),la=null,jr=null;function ps(i,n,a){fe(_d,n._currentValue),n._currentValue=a}function Hr(i){i._currentValue=_d.current,Q(_d)}function vd(i,n,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),i===a)break;i=i.return}}function yd(i,n,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=u;for(var N=0;N<n.length;N++)if(C.context===n[N]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),vd(d.return,a,i),l||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),vd(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function el(i,n,a,l){i=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var C=u.type;Tn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Ee.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(Eo):i=[Eo])}u=u.return}i!==null&&yd(n,i,a,l),n.flags|=262144}function Uc(i){for(i=i.firstContext;i!==null;){if(!Tn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function oa(i){la=i,jr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Yi(i){return B_(la,i)}function Kc(i,n){return la===null&&oa(i),B_(i,n)}function B_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},jr===null){if(i===null)throw Error(s(308));jr=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else jr=jr.next=n;return a}var sx=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},ax=e.unstable_scheduleCallback,lx=e.unstable_NormalPriority,pi={$$typeof:V,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bd(){return{controller:new sx,data:new Map,refCount:0}}function Jl(i){i.refCount--,i.refCount===0&&ax(lx,function(){i.controller.abort()})}var eo=null,Sd=0,tl=0,il=null;function ox(i,n){if(eo===null){var a=eo=[];Sd=0,tl=kf(),il={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Sd++,n.then(O_,O_),n}function O_(){if(--Sd===0&&eo!==null){il!==null&&(il.status="fulfilled");var i=eo;eo=null,tl=0,il=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function cx(i,n){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var z_=R.S;R.S=function(i,n){yy=$e(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&ox(i,n),z_!==null&&z_(i,n)};var ca=M(null);function wd(){var i=ca.current;return i!==null?i:Rt.pooledCache}function Wc(i,n){n===null?fe(ca,ca.current):fe(ca,n.pool)}function j_(){var i=wd();return i===null?null:{parent:pi._currentValue,pool:i}}var nl=Error(s(460)),Cd=Error(s(474)),Fc=Error(s(542)),qc={then:function(){}};function H_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function P_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(hn,hn),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,U_(i),i;default:if(typeof n.status=="string")n.then(hn,hn);else{if(i=Rt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=n,i.status="pending",i.then(function(l){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=l}},function(l){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,U_(i),i}throw ha=n,nl}}function ua(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ha=a,nl):a}}var ha=null;function I_(){if(ha===null)throw Error(s(459));var i=ha;return ha=null,i}function U_(i){if(i===nl||i===Fc)throw Error(s(483))}var rl=null,to=0;function $c(i){var n=to;return to+=1,rl===null&&(rl=[]),P_(rl,i,n)}function io(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Vc(i,n){throw n.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(n),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function K_(i){function n(I,O){if(i){var q=I.deletions;q===null?(I.deletions=[O],I.flags|=16):q.push(O)}}function a(I,O){if(!i)return null;for(;O!==null;)n(I,O),O=O.sibling;return null}function l(I){for(var O=new Map;I!==null;)I.key!==null?O.set(I.key,I):O.set(I.index,I),I=I.sibling;return O}function u(I,O){return I=Or(I,O),I.index=0,I.sibling=null,I}function d(I,O,q){return I.index=q,i?(q=I.alternate,q!==null?(q=q.index,q<O?(I.flags|=67108866,O):q):(I.flags|=67108866,O)):(I.flags|=1048576,O)}function _(I){return i&&I.alternate===null&&(I.flags|=67108866),I}function C(I,O,q,ue){return O===null||O.tag!==6?(O=hd(q,I.mode,ue),O.return=I,O):(O=u(O,q),O.return=I,O)}function N(I,O,q,ue){var Fe=q.type;return Fe===D?oe(I,O,q.props.children,ue,q.key):O!==null&&(O.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===de&&ua(Fe)===O.type)?(O=u(O,q.props),io(O,q),O.return=I,O):(O=Pc(q.type,q.key,q.props,null,I.mode,ue),io(O,q),O.return=I,O)}function $(I,O,q,ue){return O===null||O.tag!==4||O.stateNode.containerInfo!==q.containerInfo||O.stateNode.implementation!==q.implementation?(O=dd(q,I.mode,ue),O.return=I,O):(O=u(O,q.children||[]),O.return=I,O)}function oe(I,O,q,ue,Fe){return O===null||O.tag!==7?(O=sa(q,I.mode,ue,Fe),O.return=I,O):(O=u(O,q),O.return=I,O)}function he(I,O,q){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=hd(""+O,I.mode,q),O.return=I,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case w:return q=Pc(O.type,O.key,O.props,null,I.mode,q),io(q,O),q.return=I,q;case x:return O=dd(O,I.mode,q),O.return=I,O;case de:return O=ua(O),he(I,O,q)}if(ae(O)||W(O))return O=sa(O,I.mode,q,null),O.return=I,O;if(typeof O.then=="function")return he(I,$c(O),q);if(O.$$typeof===V)return he(I,Kc(I,O),q);Vc(I,O)}return null}function X(I,O,q,ue){var Fe=O!==null?O.key:null;if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return Fe!==null?null:C(I,O,""+q,ue);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case w:return q.key===Fe?N(I,O,q,ue):null;case x:return q.key===Fe?$(I,O,q,ue):null;case de:return q=ua(q),X(I,O,q,ue)}if(ae(q)||W(q))return Fe!==null?null:oe(I,O,q,ue,null);if(typeof q.then=="function")return X(I,O,$c(q),ue);if(q.$$typeof===V)return X(I,O,Kc(I,q),ue);Vc(I,q)}return null}function ee(I,O,q,ue,Fe){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return I=I.get(q)||null,C(O,I,""+ue,Fe);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case w:return I=I.get(ue.key===null?q:ue.key)||null,N(O,I,ue,Fe);case x:return I=I.get(ue.key===null?q:ue.key)||null,$(O,I,ue,Fe);case de:return ue=ua(ue),ee(I,O,q,ue,Fe)}if(ae(ue)||W(ue))return I=I.get(q)||null,oe(O,I,ue,Fe,null);if(typeof ue.then=="function")return ee(I,O,q,$c(ue),Fe);if(ue.$$typeof===V)return ee(I,O,q,Kc(O,ue),Fe);Vc(O,ue)}return null}function Be(I,O,q,ue){for(var Fe=null,mt=null,Pe=O,tt=O=0,dt=null;Pe!==null&&tt<q.length;tt++){Pe.index>tt?(dt=Pe,Pe=null):dt=Pe.sibling;var gt=X(I,Pe,q[tt],ue);if(gt===null){Pe===null&&(Pe=dt);break}i&&Pe&&gt.alternate===null&&n(I,Pe),O=d(gt,O,tt),mt===null?Fe=gt:mt.sibling=gt,mt=gt,Pe=dt}if(tt===q.length)return a(I,Pe),pt&&zr(I,tt),Fe;if(Pe===null){for(;tt<q.length;tt++)Pe=he(I,q[tt],ue),Pe!==null&&(O=d(Pe,O,tt),mt===null?Fe=Pe:mt.sibling=Pe,mt=Pe);return pt&&zr(I,tt),Fe}for(Pe=l(Pe);tt<q.length;tt++)dt=ee(Pe,I,tt,q[tt],ue),dt!==null&&(i&&dt.alternate!==null&&Pe.delete(dt.key===null?tt:dt.key),O=d(dt,O,tt),mt===null?Fe=dt:mt.sibling=dt,mt=dt);return i&&Pe.forEach(function(As){return n(I,As)}),pt&&zr(I,tt),Fe}function Ve(I,O,q,ue){if(q==null)throw Error(s(151));for(var Fe=null,mt=null,Pe=O,tt=O=0,dt=null,gt=q.next();Pe!==null&&!gt.done;tt++,gt=q.next()){Pe.index>tt?(dt=Pe,Pe=null):dt=Pe.sibling;var As=X(I,Pe,gt.value,ue);if(As===null){Pe===null&&(Pe=dt);break}i&&Pe&&As.alternate===null&&n(I,Pe),O=d(As,O,tt),mt===null?Fe=As:mt.sibling=As,mt=As,Pe=dt}if(gt.done)return a(I,Pe),pt&&zr(I,tt),Fe;if(Pe===null){for(;!gt.done;tt++,gt=q.next())gt=he(I,gt.value,ue),gt!==null&&(O=d(gt,O,tt),mt===null?Fe=gt:mt.sibling=gt,mt=gt);return pt&&zr(I,tt),Fe}for(Pe=l(Pe);!gt.done;tt++,gt=q.next())gt=ee(Pe,I,tt,gt.value,ue),gt!==null&&(i&&gt.alternate!==null&&Pe.delete(gt.key===null?tt:gt.key),O=d(gt,O,tt),mt===null?Fe=gt:mt.sibling=gt,mt=gt);return i&&Pe.forEach(function(bk){return n(I,bk)}),pt&&zr(I,tt),Fe}function kt(I,O,q,ue){if(typeof q=="object"&&q!==null&&q.type===D&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case w:e:{for(var Fe=q.key;O!==null;){if(O.key===Fe){if(Fe=q.type,Fe===D){if(O.tag===7){a(I,O.sibling),ue=u(O,q.props.children),ue.return=I,I=ue;break e}}else if(O.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===de&&ua(Fe)===O.type){a(I,O.sibling),ue=u(O,q.props),io(ue,q),ue.return=I,I=ue;break e}a(I,O);break}else n(I,O);O=O.sibling}q.type===D?(ue=sa(q.props.children,I.mode,ue,q.key),ue.return=I,I=ue):(ue=Pc(q.type,q.key,q.props,null,I.mode,ue),io(ue,q),ue.return=I,I=ue)}return _(I);case x:e:{for(Fe=q.key;O!==null;){if(O.key===Fe)if(O.tag===4&&O.stateNode.containerInfo===q.containerInfo&&O.stateNode.implementation===q.implementation){a(I,O.sibling),ue=u(O,q.children||[]),ue.return=I,I=ue;break e}else{a(I,O);break}else n(I,O);O=O.sibling}ue=dd(q,I.mode,ue),ue.return=I,I=ue}return _(I);case de:return q=ua(q),kt(I,O,q,ue)}if(ae(q))return Be(I,O,q,ue);if(W(q)){if(Fe=W(q),typeof Fe!="function")throw Error(s(150));return q=Fe.call(q),Ve(I,O,q,ue)}if(typeof q.then=="function")return kt(I,O,$c(q),ue);if(q.$$typeof===V)return kt(I,O,Kc(I,q),ue);Vc(I,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,O!==null&&O.tag===6?(a(I,O.sibling),ue=u(O,q),ue.return=I,I=ue):(a(I,O),ue=hd(q,I.mode,ue),ue.return=I,I=ue),_(I)):a(I,O)}return function(I,O,q,ue){try{to=0;var Fe=kt(I,O,q,ue);return rl=null,Fe}catch(Pe){if(Pe===nl||Pe===Fc)throw Pe;var mt=Dn(29,Pe,null,I.mode);return mt.lanes=ue,mt.return=I,mt}}}var da=K_(!0),W_=K_(!1),ms=!1;function xd(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function kd(i,n){i=i.updateQueue,n.updateQueue===i&&(n.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function gs(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function _s(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(_t&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,n=Hc(i),E_(i,null,a),n}return jc(i,l,n,a),Hc(i)}function no(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,Yt(i,a)}}function Ed(i,n){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=n:d=d.next=n}else u=d=n;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var Td=!1;function ro(){if(Td){var i=il;if(i!==null)throw i}}function so(i,n,a,l){Td=!1;var u=i.updateQueue;ms=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var N=C,$=N.next;N.next=null,_===null?d=$:_.next=$,_=N;var oe=i.alternate;oe!==null&&(oe=oe.updateQueue,C=oe.lastBaseUpdate,C!==_&&(C===null?oe.firstBaseUpdate=$:C.next=$,oe.lastBaseUpdate=N))}if(d!==null){var he=u.baseState;_=0,oe=$=N=null,C=d;do{var X=C.lane&-536870913,ee=X!==C.lane;if(ee?(ht&X)===X:(l&X)===X){X!==0&&X===tl&&(Td=!0),oe!==null&&(oe=oe.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Be=i,Ve=C;X=n;var kt=a;switch(Ve.tag){case 1:if(Be=Ve.payload,typeof Be=="function"){he=Be.call(kt,he,X);break e}he=Be;break e;case 3:Be.flags=Be.flags&-65537|128;case 0:if(Be=Ve.payload,X=typeof Be=="function"?Be.call(kt,he,X):Be,X==null)break e;he=y({},he,X);break e;case 2:ms=!0}}X=C.callback,X!==null&&(i.flags|=64,ee&&(i.flags|=8192),ee=u.callbacks,ee===null?u.callbacks=[X]:ee.push(X))}else ee={lane:X,tag:C.tag,payload:C.payload,callback:C.callback,next:null},oe===null?($=oe=ee,N=he):oe=oe.next=ee,_|=X;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;ee=C,C=ee.next,ee.next=null,u.lastBaseUpdate=ee,u.shared.pending=null}}while(!0);oe===null&&(N=he),u.baseState=N,u.firstBaseUpdate=$,u.lastBaseUpdate=oe,d===null&&(u.shared.lanes=0),ws|=_,i.lanes=_,i.memoizedState=he}}function F_(i,n){if(typeof i!="function")throw Error(s(191,i));i.call(n)}function q_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)F_(a[i],n)}var sl=M(null),Yc=M(0);function $_(i,n){i=Vr,fe(Yc,i),fe(sl,n),Vr=i|n.baseLanes}function Dd(){fe(Yc,Vr),fe(sl,sl.current)}function Rd(){Vr=Yc.current,Q(sl),Q(Yc)}var Rn=M(null),Vn=null;function vs(i){var n=i.alternate;fe(ui,ui.current&1),fe(Rn,i),Vn===null&&(n===null||sl.current!==null||n.memoizedState!==null)&&(Vn=i)}function Md(i){fe(ui,ui.current),fe(Rn,i),Vn===null&&(Vn=i)}function V_(i){i.tag===22?(fe(ui,ui.current),fe(Rn,i),Vn===null&&(Vn=i)):ys()}function ys(){fe(ui,ui.current),fe(Rn,Rn.current)}function Mn(i){Q(Rn),Vn===i&&(Vn=null),Q(ui)}var ui=M(0);function Xc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||jf(a)||Hf(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Pr=0,Je=null,Ct=null,mi=null,Gc=!1,al=!1,fa=!1,Zc=0,ao=0,ll=null,ux=0;function ei(){throw Error(s(321))}function Nd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!Tn(i[a],n[a]))return!1;return!0}function Ad(i,n,a,l,u,d){return Pr=d,Je=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,R.H=i===null||i.memoizedState===null?Mv:Vd,fa=!1,d=a(l,u),fa=!1,al&&(d=X_(n,a,l,u)),Y_(i),d}function Y_(i){R.H=co;var n=Ct!==null&&Ct.next!==null;if(Pr=0,mi=Ct=Je=null,Gc=!1,ao=0,ll=null,n)throw Error(s(300));i===null||gi||(i=i.dependencies,i!==null&&Uc(i)&&(gi=!0))}function X_(i,n,a,l){Je=i;var u=0;do{if(al&&(ll=null),ao=0,al=!1,25<=u)throw Error(s(301));if(u+=1,mi=Ct=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}R.H=Nv,d=n(a,l)}while(al);return d}function hx(){var i=R.H,n=i.useState()[0];return n=typeof n.then=="function"?lo(n):n,i=i.useState()[0],(Ct!==null?Ct.memoizedState:null)!==i&&(Je.flags|=1024),n}function Ld(){var i=Zc!==0;return Zc=0,i}function Bd(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function Od(i){if(Gc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Gc=!1}Pr=0,mi=Ct=Je=null,al=!1,ao=Zc=0,ll=null}function sn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mi===null?Je.memoizedState=mi=i:mi=mi.next=i,mi}function hi(){if(Ct===null){var i=Je.alternate;i=i!==null?i.memoizedState:null}else i=Ct.next;var n=mi===null?Je.memoizedState:mi.next;if(n!==null)mi=n,Ct=i;else{if(i===null)throw Je.alternate===null?Error(s(467)):Error(s(310));Ct=i,i={memoizedState:Ct.memoizedState,baseState:Ct.baseState,baseQueue:Ct.baseQueue,queue:Ct.queue,next:null},mi===null?Je.memoizedState=mi=i:mi=mi.next=i}return mi}function Qc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function lo(i){var n=ao;return ao+=1,ll===null&&(ll=[]),i=P_(ll,i,n),n=Je,(mi===null?n.memoizedState:mi.next)===null&&(n=n.alternate,R.H=n===null||n.memoizedState===null?Mv:Vd),i}function Jc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return lo(i);if(i.$$typeof===V)return Yi(i)}throw Error(s(438,String(i)))}function zd(i){var n=null,a=Je.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Je.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=Qc(),Je.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),l=0;l<i;l++)a[l]=U;return n.index++,a}function Ir(i,n){return typeof n=="function"?n(i):n}function eu(i){var n=hi();return jd(n,Ct,i)}function jd(i,n,a){var l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=a;var u=i.baseQueue,d=l.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,l.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,N=null,$=n,oe=!1;do{var he=$.lane&-536870913;if(he!==$.lane?(ht&he)===he:(Pr&he)===he){var X=$.revertLane;if(X===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),he===tl&&(oe=!0);else if((Pr&X)===X){$=$.next,X===tl&&(oe=!0);continue}else he={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},N===null?(C=N=he,_=d):N=N.next=he,Je.lanes|=X,ws|=X;he=$.action,fa&&a(d,he),d=$.hasEagerState?$.eagerState:a(d,he)}else X={lane:he,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},N===null?(C=N=X,_=d):N=N.next=X,Je.lanes|=he,ws|=he;$=$.next}while($!==null&&$!==n);if(N===null?_=d:N.next=C,!Tn(d,i.memoizedState)&&(gi=!0,oe&&(a=il,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,l.lastRenderedState=d}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Hd(i){var n=hi(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,d=n.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);Tn(d,n.memoizedState)||(gi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function G_(i,n,a){var l=Je,u=hi(),d=pt;if(d){if(a===void 0)throw Error(s(407));a=a()}else a=n();var _=!Tn((Ct||u).memoizedState,a);if(_&&(u.memoizedState=a,gi=!0),u=u.queue,Ud(J_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||mi!==null&&mi.memoizedState.tag&1){if(l.flags|=2048,ol(9,{destroy:void 0},Q_.bind(null,l,u,a,n),null),Rt===null)throw Error(s(349));d||(Pr&127)!==0||Z_(l,n,a)}return a}function Z_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Je.updateQueue,n===null?(n=Qc(),Je.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function Q_(i,n,a,l){n.value=a,n.getSnapshot=l,ev(n)&&tv(i)}function J_(i,n,a){return a(function(){ev(n)&&tv(i)})}function ev(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!Tn(i,a)}catch{return!0}}function tv(i){var n=ra(i,2);n!==null&&vn(n,i,2)}function Pd(i){var n=sn();if(typeof i=="function"){var a=i;if(i=a(),fa){Qt(!0);try{a()}finally{Qt(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:i},n}function iv(i,n,a,l){return i.baseState=a,jd(i,Ct,typeof l=="function"?l:Ir)}function dx(i,n,a,l,u){if(nu(i))throw Error(s(485));if(i=n.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};R.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,nv(n,d)):(d.next=a.next,n.pending=a.next=d)}}function nv(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=R.T,_={};R.T=_;try{var C=a(u,l),N=R.S;N!==null&&N(_,C),rv(i,n,C)}catch($){Id(i,n,$)}finally{d!==null&&_.types!==null&&(d.types=_.types),R.T=d}}else try{d=a(u,l),rv(i,n,d)}catch($){Id(i,n,$)}}function rv(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){sv(i,n,l)},function(l){return Id(i,n,l)}):sv(i,n,a)}function sv(i,n,a){n.status="fulfilled",n.value=a,av(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,nv(i,a)))}function Id(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,av(n),n=n.next;while(n!==l)}i.action=null}function av(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function lv(i,n){return n}function ov(i,n){if(pt){var a=Rt.formState;if(a!==null){e:{var l=Je;if(pt){if(Pt){t:{for(var u=Pt,d=$n;u.nodeType!==8;){if(!d){u=null;break t}if(u=Yn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){Pt=Yn(u.nextSibling),l=u.data==="F!";break e}}fs(l)}l=!1}l&&(n=a[0])}}return a=sn(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lv,lastRenderedState:n},a.queue=l,a=Tv.bind(null,Je,l),l.dispatch=a,l=Pd(!1),d=$d.bind(null,Je,!1,l.queue),l=sn(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=dx.bind(null,Je,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function cv(i){var n=hi();return uv(n,Ct,i)}function uv(i,n,a){if(n=jd(i,n,lv)[0],i=eu(Ir)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=lo(n)}catch(_){throw _===nl?Fc:_}else l=n;n=hi();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Je.flags|=2048,ol(9,{destroy:void 0},fx.bind(null,u,a),null)),[l,d,i]}function fx(i,n){i.action=n}function hv(i){var n=hi(),a=Ct;if(a!==null)return uv(n,a,i);hi(),n=n.memoizedState,a=hi();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function ol(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Je.updateQueue,n===null&&(n=Qc(),Je.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,n.lastEffect=i),i}function dv(){return hi().memoizedState}function tu(i,n,a,l){var u=sn();Je.flags|=i,u.memoizedState=ol(1|n,{destroy:void 0},a,l===void 0?null:l)}function iu(i,n,a,l){var u=hi();l=l===void 0?null:l;var d=u.memoizedState.inst;Ct!==null&&l!==null&&Nd(l,Ct.memoizedState.deps)?u.memoizedState=ol(n,d,a,l):(Je.flags|=i,u.memoizedState=ol(1|n,d,a,l))}function fv(i,n){tu(8390656,8,i,n)}function Ud(i,n){iu(2048,8,i,n)}function px(i){Je.flags|=4;var n=Je.updateQueue;if(n===null)n=Qc(),Je.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function pv(i){var n=hi().memoizedState;return px({ref:n,nextImpl:i}),function(){if((_t&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function mv(i,n){return iu(4,2,i,n)}function gv(i,n){return iu(4,4,i,n)}function _v(i,n){if(typeof n=="function"){i=i();var a=n(i);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return i=i(),n.current=i,function(){n.current=null}}function vv(i,n,a){a=a!=null?a.concat([i]):null,iu(4,4,_v.bind(null,n,i),a)}function Kd(){}function yv(i,n){var a=hi();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&Nd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function bv(i,n){var a=hi();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&Nd(n,l[1]))return l[0];if(l=i(),fa){Qt(!0);try{i()}finally{Qt(!1)}}return a.memoizedState=[l,n],l}function Wd(i,n,a){return a===void 0||(Pr&1073741824)!==0&&(ht&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=Sy(),Je.lanes|=i,ws|=i,a)}function Sv(i,n,a,l){return Tn(a,n)?a:sl.current!==null?(i=Wd(i,a,l),Tn(i,n)||(gi=!0),i):(Pr&42)===0||(Pr&1073741824)!==0&&(ht&261930)===0?(gi=!0,i.memoizedState=a):(i=Sy(),Je.lanes|=i,ws|=i,n)}function wv(i,n,a,l,u){var d=Y.p;Y.p=d!==0&&8>d?d:8;var _=R.T,C={};R.T=C,$d(i,!1,n,a);try{var N=u(),$=R.S;if($!==null&&$(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var oe=cx(N,l);oo(i,n,oe,Ln(i))}else oo(i,n,l,Ln(i))}catch(he){oo(i,n,{then:function(){},status:"rejected",reason:he},Ln())}finally{Y.p=d,_!==null&&C.types!==null&&(_.types=C.types),R.T=_}}function mx(){}function Fd(i,n,a,l){if(i.tag!==5)throw Error(s(476));var u=Cv(i).queue;wv(i,u,n,G,a===null?mx:function(){return xv(i),a(l)})}function Cv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:G},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function xv(i){var n=Cv(i);n.next===null&&(n=i.alternate.memoizedState),oo(i,n.next.queue,{},Ln())}function qd(){return Yi(Eo)}function kv(){return hi().memoizedState}function Ev(){return hi().memoizedState}function gx(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Ln();i=gs(a);var l=_s(n,i,a);l!==null&&(vn(l,n,a),no(l,n,a)),n={cache:bd()},i.payload=n;return}n=n.return}}function _x(i,n,a){var l=Ln();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},nu(i)?Dv(n,a):(a=cd(i,n,a,l),a!==null&&(vn(a,i,l),Rv(a,n,l)))}function Tv(i,n,a){var l=Ln();oo(i,n,a,l)}function oo(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(nu(i))Dv(n,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var _=n.lastRenderedState,C=d(_,a);if(u.hasEagerState=!0,u.eagerState=C,Tn(C,_))return jc(i,n,u,0),Rt===null&&zc(),!1}catch{}if(a=cd(i,n,u,l),a!==null)return vn(a,i,l),Rv(a,n,l),!0}return!1}function $d(i,n,a,l){if(l={lane:2,revertLane:kf(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},nu(i)){if(n)throw Error(s(479))}else n=cd(i,a,l,2),n!==null&&vn(n,i,2)}function nu(i){var n=i.alternate;return i===Je||n!==null&&n===Je}function Dv(i,n){al=Gc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function Rv(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,Yt(i,a)}}var co={readContext:Yi,use:Jc,useCallback:ei,useContext:ei,useEffect:ei,useImperativeHandle:ei,useLayoutEffect:ei,useInsertionEffect:ei,useMemo:ei,useReducer:ei,useRef:ei,useState:ei,useDebugValue:ei,useDeferredValue:ei,useTransition:ei,useSyncExternalStore:ei,useId:ei,useHostTransitionStatus:ei,useFormState:ei,useActionState:ei,useOptimistic:ei,useMemoCache:ei,useCacheRefresh:ei};co.useEffectEvent=ei;var Mv={readContext:Yi,use:Jc,useCallback:function(i,n){return sn().memoizedState=[i,n===void 0?null:n],i},useContext:Yi,useEffect:fv,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,tu(4194308,4,_v.bind(null,n,i),a)},useLayoutEffect:function(i,n){return tu(4194308,4,i,n)},useInsertionEffect:function(i,n){tu(4,2,i,n)},useMemo:function(i,n){var a=sn();n=n===void 0?null:n;var l=i();if(fa){Qt(!0);try{i()}finally{Qt(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=sn();if(a!==void 0){var u=a(n);if(fa){Qt(!0);try{a(n)}finally{Qt(!1)}}}else u=n;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=_x.bind(null,Je,i),[l.memoizedState,i]},useRef:function(i){var n=sn();return i={current:i},n.memoizedState=i},useState:function(i){i=Pd(i);var n=i.queue,a=Tv.bind(null,Je,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:Kd,useDeferredValue:function(i,n){var a=sn();return Wd(a,i,n)},useTransition:function(){var i=Pd(!1);return i=wv.bind(null,Je,i.queue,!0,!1),sn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Je,u=sn();if(pt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),Rt===null)throw Error(s(349));(ht&127)!==0||Z_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,fv(J_.bind(null,l,d,i),[i]),l.flags|=2048,ol(9,{destroy:void 0},Q_.bind(null,l,d,a,n),null),a},useId:function(){var i=sn(),n=Rt.identifierPrefix;if(pt){var a=wr,l=Sr;a=(l&~(1<<32-At(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Zc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=ux++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:qd,useFormState:ov,useActionState:ov,useOptimistic:function(i){var n=sn();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=$d.bind(null,Je,!0,a),a.dispatch=n,[i,n]},useMemoCache:zd,useCacheRefresh:function(){return sn().memoizedState=gx.bind(null,Je)},useEffectEvent:function(i){var n=sn(),a={impl:i};return n.memoizedState=a,function(){if((_t&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Vd={readContext:Yi,use:Jc,useCallback:yv,useContext:Yi,useEffect:Ud,useImperativeHandle:vv,useInsertionEffect:mv,useLayoutEffect:gv,useMemo:bv,useReducer:eu,useRef:dv,useState:function(){return eu(Ir)},useDebugValue:Kd,useDeferredValue:function(i,n){var a=hi();return Sv(a,Ct.memoizedState,i,n)},useTransition:function(){var i=eu(Ir)[0],n=hi().memoizedState;return[typeof i=="boolean"?i:lo(i),n]},useSyncExternalStore:G_,useId:kv,useHostTransitionStatus:qd,useFormState:cv,useActionState:cv,useOptimistic:function(i,n){var a=hi();return iv(a,Ct,i,n)},useMemoCache:zd,useCacheRefresh:Ev};Vd.useEffectEvent=pv;var Nv={readContext:Yi,use:Jc,useCallback:yv,useContext:Yi,useEffect:Ud,useImperativeHandle:vv,useInsertionEffect:mv,useLayoutEffect:gv,useMemo:bv,useReducer:Hd,useRef:dv,useState:function(){return Hd(Ir)},useDebugValue:Kd,useDeferredValue:function(i,n){var a=hi();return Ct===null?Wd(a,i,n):Sv(a,Ct.memoizedState,i,n)},useTransition:function(){var i=Hd(Ir)[0],n=hi().memoizedState;return[typeof i=="boolean"?i:lo(i),n]},useSyncExternalStore:G_,useId:kv,useHostTransitionStatus:qd,useFormState:hv,useActionState:hv,useOptimistic:function(i,n){var a=hi();return Ct!==null?iv(a,Ct,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:zd,useCacheRefresh:Ev};Nv.useEffectEvent=pv;function Yd(i,n,a,l){n=i.memoizedState,a=a(l,n),a=a==null?n:y({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Xd={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=Ln(),u=gs(l);u.payload=n,a!=null&&(u.callback=a),n=_s(i,u,l),n!==null&&(vn(n,i,l),no(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=Ln(),u=gs(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=_s(i,u,l),n!==null&&(vn(n,i,l),no(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Ln(),l=gs(a);l.tag=2,n!=null&&(l.callback=n),n=_s(i,l,a),n!==null&&(vn(n,i,a),no(n,i,a))}};function Av(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!Xl(a,l)||!Xl(u,d):!0}function Lv(i,n,a,l){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,l),n.state!==i&&Xd.enqueueReplaceState(n,n.state,null)}function pa(i,n){var a=n;if("ref"in n){a={};for(var l in n)l!=="ref"&&(a[l]=n[l])}if(i=i.defaultProps){a===n&&(a=y({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Bv(i){Oc(i)}function Ov(i){console.error(i)}function zv(i){Oc(i)}function ru(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function jv(i,n,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Gd(i,n,a){return a=gs(a),a.tag=3,a.payload={element:null},a.callback=function(){ru(i,n)},a}function Hv(i){return i=gs(i),i.tag=3,i}function Pv(i,n,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=l.value;i.payload=function(){return u(d)},i.callback=function(){jv(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){jv(n,a,l),typeof u!="function"&&(Cs===null?Cs=new Set([this]):Cs.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function vx(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&el(n,a,u,!0),a=Rn.current,a!==null){switch(a.tag){case 31:case 13:return Vn===null?gu():a.alternate===null&&ti===0&&(ti=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===qc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([l]):n.add(l),wf(i,l,u)),!1;case 22:return a.flags|=65536,l===qc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([l]):a.add(l)),wf(i,l,u)),!1}throw Error(s(435,a.tag))}return wf(i,l,u),gu(),!1}if(pt)return n=Rn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==md&&(i=Error(s(422),{cause:l}),Ql(Wn(i,a)))):(l!==md&&(n=Error(s(423),{cause:l}),Ql(Wn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=Wn(l,a),u=Gd(i.stateNode,l,u),Ed(i,u),ti!==4&&(ti=2)),!1;var d=Error(s(520),{cause:l});if(d=Wn(d,a),vo===null?vo=[d]:vo.push(d),ti!==4&&(ti=2),n===null)return!0;l=Wn(l,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Gd(a.stateNode,l,i),Ed(a,i),!1;case 1:if(n=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(Cs===null||!Cs.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Hv(u),Pv(u,i,a,l),Ed(a,u),!1}a=a.return}while(a!==null);return!1}var Zd=Error(s(461)),gi=!1;function Xi(i,n,a,l){n.child=i===null?W_(n,null,a,l):da(n,i.child,a,l)}function Iv(i,n,a,l,u){a=a.render;var d=n.ref;if("ref"in l){var _={};for(var C in l)C!=="ref"&&(_[C]=l[C])}else _=l;return oa(n),l=Ad(i,n,a,_,d,u),C=Ld(),i!==null&&!gi?(Bd(i,n,u),Ur(i,n,u)):(pt&&C&&fd(n),n.flags|=1,Xi(i,n,l,u),n.child)}function Uv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!ud(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Kv(i,n,d,l,u)):(i=Pc(a.type,null,l,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!af(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:Xl,a(_,l)&&i.ref===n.ref)return Ur(i,n,u)}return n.flags|=1,i=Or(d,l),i.ref=n.ref,i.return=n,n.child=i}function Kv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(Xl(d,l)&&i.ref===n.ref)if(gi=!1,n.pendingProps=l=d,af(i,u))(i.flags&131072)!==0&&(gi=!0);else return n.lanes=i.lanes,Ur(i,n,u)}return Qd(i,n,a,l,u)}function Wv(i,n,a,l){var u=l.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(l=n.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~d}else l=0,n.child=null;return Fv(i,n,d,a,l)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Wc(n,d!==null?d.cachePool:null),d!==null?$_(n,d):Dd(),V_(n);else return l=n.lanes=536870912,Fv(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Wc(n,d.cachePool),$_(n,d),ys(),n.memoizedState=null):(i!==null&&Wc(n,null),Dd(),ys());return Xi(i,n,u,a),n.child}function uo(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Fv(i,n,a,l,u){var d=wd();return d=d===null?null:{parent:pi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Wc(n,null),Dd(),V_(n),i!==null&&el(i,n,l,!0),n.childLanes=u,null}function su(i,n){return n=lu({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function qv(i,n,a){return da(n,i.child,null,a),i=su(n,n.pendingProps),i.flags|=2,Mn(n),n.memoizedState=null,i}function yx(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(pt){if(l.mode==="hidden")return i=su(n,l),n.lanes=536870912,uo(null,i);if(Md(n),(i=Pt)?(i=nb(i,$n),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:hs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},a=D_(i),a.return=n,n.child=a,Vi=n,Pt=null)):i=null,i===null)throw fs(n);return n.lanes=536870912,null}return su(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(Md(n),u)if(n.flags&256)n.flags&=-257,n=qv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(s(558));else if(gi||el(i,n,a,!1),u=(a&i.childLanes)!==0,gi||u){if(l=Rt,l!==null&&(_=si(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,ra(i,_),vn(l,i,_),Zd;gu(),n=qv(i,n,a)}else i=d.treeContext,Pt=Yn(_.nextSibling),Vi=n,pt=!0,ds=null,$n=!1,i!==null&&N_(n,i),n=su(n,l),n.flags|=4096;return n}return i=Or(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function au(i,n){var a=n.ref;if(a===null)i!==null&&i.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function Qd(i,n,a,l,u){return oa(n),a=Ad(i,n,a,l,void 0,u),l=Ld(),i!==null&&!gi?(Bd(i,n,u),Ur(i,n,u)):(pt&&l&&fd(n),n.flags|=1,Xi(i,n,a,u),n.child)}function $v(i,n,a,l,u,d){return oa(n),n.updateQueue=null,a=X_(n,l,a,u),Y_(i),l=Ld(),i!==null&&!gi?(Bd(i,n,d),Ur(i,n,d)):(pt&&l&&fd(n),n.flags|=1,Xi(i,n,a,d),n.child)}function Vv(i,n,a,l,u){if(oa(n),n.stateNode===null){var d=Ga,_=a.contextType;typeof _=="object"&&_!==null&&(d=Yi(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Xd,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},xd(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Yi(_):Ga,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Yd(n,a,_,l),d.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&Xd.enqueueReplaceState(d,d.state,null),so(n,l,d,u),ro(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,N=pa(a,C);d.props=N;var $=d.context,oe=a.contextType;_=Ga,typeof oe=="object"&&oe!==null&&(_=Yi(oe));var he=a.getDerivedStateFromProps;oe=typeof he=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,oe||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||$!==_)&&Lv(n,d,l,_),ms=!1;var X=n.memoizedState;d.state=X,so(n,l,d,u),ro(),$=n.memoizedState,C||X!==$||ms?(typeof he=="function"&&(Yd(n,a,he,l),$=n.memoizedState),(N=ms||Av(n,a,N,l,X,$,_))?(oe||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=$),d.props=l,d.state=$,d.context=_,l=N):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,kd(i,n),_=n.memoizedProps,oe=pa(a,_),d.props=oe,he=n.pendingProps,X=d.context,$=a.contextType,N=Ga,typeof $=="object"&&$!==null&&(N=Yi($)),C=a.getDerivedStateFromProps,($=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==he||X!==N)&&Lv(n,d,l,N),ms=!1,X=n.memoizedState,d.state=X,so(n,l,d,u),ro();var ee=n.memoizedState;_!==he||X!==ee||ms||i!==null&&i.dependencies!==null&&Uc(i.dependencies)?(typeof C=="function"&&(Yd(n,a,C,l),ee=n.memoizedState),(oe=ms||Av(n,a,oe,l,X,ee,N)||i!==null&&i.dependencies!==null&&Uc(i.dependencies))?($||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,ee,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,ee,N)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=ee),d.props=l,d.state=ee,d.context=N,l=oe):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,au(i,n),l=(n.flags&128)!==0,d||l?(d=n.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&l?(n.child=da(n,i.child,null,u),n.child=da(n,null,a,u)):Xi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Ur(i,n,u),i}function Yv(i,n,a,l){return aa(),n.flags|=256,Xi(i,n,a,l),n.child}var Jd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ef(i){return{baseLanes:i,cachePool:j_()}}function tf(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=An),i}function Xv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(ui.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(pt){if(u?vs(n):ys(),(i=Pt)?(i=nb(i,$n),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:hs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},a=D_(i),a.return=n,n.child=a,Vi=n,Pt=null)):i=null,i===null)throw fs(n);return Hf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(ys(),u=n.mode,C=lu({mode:"hidden",children:C},u),l=sa(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=ef(a),l.childLanes=tf(i,_,a),n.memoizedState=Jd,uo(null,l)):(vs(n),nf(n,C))}var N=i.memoizedState;if(N!==null&&(C=N.dehydrated,C!==null)){if(d)n.flags&256?(vs(n),n.flags&=-257,n=rf(i,n,a)):n.memoizedState!==null?(ys(),n.child=i.child,n.flags|=128,n=null):(ys(),C=l.fallback,u=n.mode,l=lu({mode:"visible",children:l.children},u),C=sa(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,da(n,i.child,null,a),l=n.child,l.memoizedState=ef(a),l.childLanes=tf(i,_,a),n.memoizedState=Jd,n=uo(null,l));else if(vs(n),Hf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var $=_.dgst;_=$,l=Error(s(419)),l.stack="",l.digest=_,Ql({value:l,source:null,stack:null}),n=rf(i,n,a)}else if(gi||el(i,n,a,!1),_=(a&i.childLanes)!==0,gi||_){if(_=Rt,_!==null&&(l=si(_,a),l!==0&&l!==N.retryLane))throw N.retryLane=l,ra(i,l),vn(_,i,l),Zd;jf(C)||gu(),n=rf(i,n,a)}else jf(C)?(n.flags|=192,n.child=i.child,n=null):(i=N.treeContext,Pt=Yn(C.nextSibling),Vi=n,pt=!0,ds=null,$n=!1,i!==null&&N_(n,i),n=nf(n,l.children),n.flags|=4096);return n}return u?(ys(),C=l.fallback,u=n.mode,N=i.child,$=N.sibling,l=Or(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,$!==null?C=Or($,C):(C=sa(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,uo(null,l),l=n.child,C=i.child.memoizedState,C===null?C=ef(a):(u=C.cachePool,u!==null?(N=pi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=j_(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=tf(i,_,a),n.memoizedState=Jd,uo(i.child,l)):(vs(n),a=i.child,i=a.sibling,a=Or(a,{mode:"visible",children:l.children}),a.return=n,a.sibling=null,i!==null&&(_=n.deletions,_===null?(n.deletions=[i],n.flags|=16):_.push(i)),n.child=a,n.memoizedState=null,a)}function nf(i,n){return n=lu({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function lu(i,n){return i=Dn(22,i,null,n),i.lanes=0,i}function rf(i,n,a){return da(n,i.child,null,a),i=nf(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Gv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),vd(i.return,n,a)}function sf(i,n,a,l,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function Zv(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=ui.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,fe(ui,_),Xi(i,n,l,a),l=pt?Zl:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Gv(i,a,n);else if(i.tag===19)Gv(i,a,n);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break e;for(;i.sibling===null;){if(i.return===null||i.return===n)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=n.child,u=null;a!==null;)i=a.alternate,i!==null&&Xc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),sf(n,!1,u,a,d,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Xc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}sf(n,!0,a,null,d,l);break;case"together":sf(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Ur(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),ws|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(el(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(s(153));if(n.child!==null){for(i=n.child,a=Or(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Or(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function af(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Uc(i)))}function bx(i,n,a){switch(n.tag){case 3:Ne(n,n.stateNode.containerInfo),ps(n,pi,i.memoizedState.cache),aa();break;case 27:case 5:te(n);break;case 4:Ne(n,n.stateNode.containerInfo);break;case 10:ps(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Md(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(vs(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Xv(i,n,a):(vs(n),i=Ur(i,n,a),i!==null?i.sibling:null);vs(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(el(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Zv(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),fe(ui,ui.current),l)break;return null;case 22:return n.lanes=0,Wv(i,n,a,n.pendingProps);case 24:ps(n,pi,i.memoizedState.cache)}return Ur(i,n,a)}function Qv(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)gi=!0;else{if(!af(i,a)&&(n.flags&128)===0)return gi=!1,bx(i,n,a);gi=(i.flags&131072)!==0}else gi=!1,pt&&(n.flags&1048576)!==0&&M_(n,Zl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=ua(n.elementType),n.type=i,typeof i=="function")ud(i)?(l=pa(i,l),n.tag=1,n=Vv(null,n,i,l,a)):(n.tag=0,n=Qd(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===H){n.tag=11,n=Iv(null,n,i,l,a);break e}else if(u===ne){n.tag=14,n=Uv(null,n,i,l,a);break e}}throw n=j(i)||i,Error(s(306,n,""))}}return n;case 0:return Qd(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=pa(l,n.pendingProps),Vv(i,n,l,u,a);case 3:e:{if(Ne(n,n.stateNode.containerInfo),i===null)throw Error(s(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,kd(i,n),so(n,l,null,a);var _=n.memoizedState;if(l=_.cache,ps(n,pi,l),l!==d.cache&&yd(n,[pi],a,!0),ro(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Yv(i,n,l,a);break e}else if(l!==u){u=Wn(Error(s(424)),n),Ql(u),n=Yv(i,n,l,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Pt=Yn(i.firstChild),Vi=n,pt=!0,ds=null,$n=!0,a=W_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(aa(),l===u){n=Ur(i,n,a);break e}Xi(i,n,l,a)}n=n.child}return n;case 26:return au(i,n),i===null?(a=cb(n.type,null,n.pendingProps,null))?n.memoizedState=a:pt||(a=n.type,i=n.pendingProps,l=Cu(Se.current).createElement(a),l[Wt]=n,l[Ai]=i,Gi(l,a,i),jt(l),n.stateNode=l):n.memoizedState=cb(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return te(n),i===null&&pt&&(l=n.stateNode=ab(n.type,n.pendingProps,Se.current),Vi=n,$n=!0,u=Pt,Ts(n.type)?(Pf=u,Pt=Yn(l.firstChild)):Pt=u),Xi(i,n,n.pendingProps.children,a),au(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&pt&&((u=l=Pt)&&(l=Gx(l,n.type,n.pendingProps,$n),l!==null?(n.stateNode=l,Vi=n,Pt=Yn(l.firstChild),$n=!1,u=!0):u=!1),u||fs(n)),te(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,Bf(u,d)?l=null:_!==null&&Bf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=Ad(i,n,hx,null,null,a),Eo._currentValue=u),au(i,n),Xi(i,n,l,a),n.child;case 6:return i===null&&pt&&((i=a=Pt)&&(a=Zx(a,n.pendingProps,$n),a!==null?(n.stateNode=a,Vi=n,Pt=null,i=!0):i=!1),i||fs(n)),null;case 13:return Xv(i,n,a);case 4:return Ne(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=da(n,null,l,a):Xi(i,n,l,a),n.child;case 11:return Iv(i,n,n.type,n.pendingProps,a);case 7:return Xi(i,n,n.pendingProps,a),n.child;case 8:return Xi(i,n,n.pendingProps.children,a),n.child;case 12:return Xi(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,ps(n,n.type,l.value),Xi(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,oa(n),u=Yi(u),l=l(u),n.flags|=1,Xi(i,n,l,a),n.child;case 14:return Uv(i,n,n.type,n.pendingProps,a);case 15:return Kv(i,n,n.type,n.pendingProps,a);case 19:return Zv(i,n,a);case 31:return yx(i,n,a);case 22:return Wv(i,n,a,n.pendingProps);case 24:return oa(n),l=Yi(pi),i===null?(u=wd(),u===null&&(u=Rt,d=bd(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},xd(n),ps(n,pi,u)):((i.lanes&a)!==0&&(kd(i,n),so(n,null,null,a),ro()),u=i.memoizedState,d=n.memoizedState,u.parent!==l?(u={parent:l,cache:l},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),ps(n,pi,l)):(l=d.cache,ps(n,pi,l),l!==u.cache&&yd(n,[pi],a,!0))),Xi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function Kr(i){i.flags|=4}function lf(i,n,a,l,u){if((n=(i.mode&32)!==0)&&(n=!1),n){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(ky())i.flags|=8192;else throw ha=qc,Cd}else i.flags&=-16777217}function Jv(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!pb(n))if(ky())i.flags|=8192;else throw ha=qc,Cd}function ou(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?ri():536870912,i.lanes|=n,dl|=n)}function ho(i,n){if(!pt)switch(i.tailMode){case"hidden":n=i.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function It(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,n}function Sx(i,n,a){var l=n.pendingProps;switch(pd(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(n),null;case 1:return It(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Hr(pi),Ue(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ja(n)?Kr(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,gd())),It(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(Kr(n),d!==null?(It(n),Jv(n,d)):(It(n),lf(n,u,null,l,a))):d?d!==i.memoizedState?(Kr(n),It(n),Jv(n,d)):(It(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&Kr(n),It(n),lf(n,u,i,l,a)),null;case 27:if(_e(n),a=Se.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Kr(n);else{if(!l){if(n.stateNode===null)throw Error(s(166));return It(n),null}i=me.current,Ja(n)?A_(n):(i=ab(u,l,a),n.stateNode=i,Kr(n))}return It(n),null;case 5:if(_e(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Kr(n);else{if(!l){if(n.stateNode===null)throw Error(s(166));return It(n),null}if(d=me.current,Ja(n))A_(n);else{var _=Cu(Se.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?d.multiple=!0:l.size&&(d.size=l.size);break;default:d=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}d[Wt]=n,d[Ai]=l;e:for(_=n.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===n)break e;for(;_.sibling===null;){if(_.return===null||_.return===n)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}n.stateNode=d;e:switch(Gi(d,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Kr(n)}}return It(n),lf(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&Kr(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(s(166));if(i=Se.current,Ja(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Vi,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[Wt]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Xy(i.nodeValue,a)),i||fs(n,!0)}else i=Cu(i).createTextNode(l),i[Wt]=n,n.stateNode=i}return It(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Ja(n),a!==null){if(i===null){if(!l)throw Error(s(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[Wt]=n}else aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;It(n),i=!1}else a=gd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(Mn(n),n):(Mn(n),null);if((n.flags&128)!==0)throw Error(s(558))}return It(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Ja(n),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[Wt]=n}else aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;It(n),u=!1}else u=gd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(Mn(n),n):(Mn(n),null)}return Mn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=n.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==u&&(l.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),ou(n,n.updateQueue),It(n),null);case 4:return Ue(),i===null&&Rf(n.stateNode.containerInfo),It(n),null;case 10:return Hr(n.type),It(n),null;case 19:if(Q(ui),l=n.memoizedState,l===null)return It(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)ho(l,!1);else{if(ti!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Xc(i),d!==null){for(n.flags|=128,ho(l,!1),i=d.updateQueue,n.updateQueue=i,ou(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)T_(a,i),a=a.sibling;return fe(ui,ui.current&1|2),pt&&zr(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&$e()>fu&&(n.flags|=128,u=!0,ho(l,!1),n.lanes=4194304)}else{if(!u)if(i=Xc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,ou(n,i),ho(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!pt)return It(n),null}else 2*$e()-l.renderingStartTime>fu&&a!==536870912&&(n.flags|=128,u=!0,ho(l,!1),n.lanes=4194304);l.isBackwards?(d.sibling=n.child,n.child=d):(i=l.last,i!==null?i.sibling=d:n.child=d,l.last=d)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=$e(),i.sibling=null,a=ui.current,fe(ui,u?a&1|2:a&1),pt&&zr(n,l.treeForkCount),i):(It(n),null);case 22:case 23:return Mn(n),Rd(),l=n.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(a&536870912)!==0&&(n.flags&128)===0&&(It(n),n.subtreeFlags&6&&(n.flags|=8192)):It(n),a=n.updateQueue,a!==null&&ou(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==a&&(n.flags|=2048),i!==null&&Q(ca),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Hr(pi),It(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function wx(i,n){switch(pd(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Hr(pi),Ue(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Mn(n),n.alternate===null)throw Error(s(340));aa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(Mn(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(s(340));aa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return Q(ui),null;case 4:return Ue(),null;case 10:return Hr(n.type),null;case 22:case 23:return Mn(n),Rd(),i!==null&&Q(ca),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Hr(pi),null;case 25:return null;default:return null}}function ey(i,n){switch(pd(n),n.tag){case 3:Hr(pi),Ue();break;case 26:case 27:case 5:_e(n);break;case 4:Ue();break;case 31:n.memoizedState!==null&&Mn(n);break;case 13:Mn(n);break;case 19:Q(ui);break;case 10:Hr(n.type);break;case 22:case 23:Mn(n),Rd(),i!==null&&Q(ca);break;case 24:Hr(pi)}}function fo(i,n){try{var a=n.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var d=a.create,_=a.inst;l=d(),_.destroy=l}a=a.next}while(a!==u)}}catch(C){bt(n,n.return,C)}}function bs(i,n,a){try{var l=n.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){var _=l.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var N=a,$=C;try{$()}catch(oe){bt(u,N,oe)}}}l=l.next}while(l!==d)}}catch(oe){bt(n,n.return,oe)}}function ty(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{q_(n,a)}catch(l){bt(i,i.return,l)}}}function iy(i,n,a){a.props=pa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){bt(i,n,l)}}function po(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){bt(i,n,u)}}function Cr(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){bt(i,n,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){bt(i,n,u)}else a.current=null}function ny(i){var n=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){bt(i,i.return,u)}}function of(i,n,a){try{var l=i.stateNode;Fx(l,i.type,a,n),l[Ai]=n}catch(u){bt(i,i.return,u)}}function ry(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ts(i.type)||i.tag===4}function cf(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||ry(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&&Ts(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 uf(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(i),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=hn));else if(l!==4&&(l===27&&Ts(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(uf(i,n,a),i=i.sibling;i!==null;)uf(i,n,a),i=i.sibling}function cu(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(l!==4&&(l===27&&Ts(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(cu(i,n,a),i=i.sibling;i!==null;)cu(i,n,a),i=i.sibling}function sy(i){var n=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Gi(n,l,a),n[Wt]=i,n[Ai]=a}catch(d){bt(i,i.return,d)}}var Wr=!1,_i=!1,hf=!1,ay=typeof WeakSet=="function"?WeakSet:Set,Oi=null;function Cx(i,n){if(i=i.containerInfo,Af=Mu,i=v_(i),nd(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,d=l.focusNode;l=l.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,N=-1,$=0,oe=0,he=i,X=null;t:for(;;){for(var ee;he!==a||u!==0&&he.nodeType!==3||(C=_+u),he!==d||l!==0&&he.nodeType!==3||(N=_+l),he.nodeType===3&&(_+=he.nodeValue.length),(ee=he.firstChild)!==null;)X=he,he=ee;for(;;){if(he===i)break t;if(X===a&&++$===u&&(C=_),X===d&&++oe===l&&(N=_),(ee=he.nextSibling)!==null)break;he=X,X=he.parentNode}he=ee}a=C===-1||N===-1?null:{start:C,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(Lf={focusedElem:i,selectionRange:a},Mu=!1,Oi=n;Oi!==null;)if(n=Oi,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Oi=i;else for(;Oi!==null;){switch(n=Oi,d=n.alternate,i=n.flags,n.tag){case 0:if((i&4)!==0&&(i=n.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&&d!==null){i=void 0,a=n,u=d.memoizedProps,d=d.memoizedState,l=a.stateNode;try{var Be=pa(a.type,u);i=l.getSnapshotBeforeUpdate(Be,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(Ve){bt(a,a.return,Ve)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)zf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":zf(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=n.sibling,i!==null){i.return=n.return,Oi=i;break}Oi=n.return}}function ly(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:qr(i,a),l&4&&fo(5,a);break;case 1:if(qr(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){bt(a,a.return,_)}else{var u=pa(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){bt(a,a.return,_)}}l&64&&ty(a),l&512&&po(a,a.return);break;case 3:if(qr(i,a),l&64&&(i=a.updateQueue,i!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{q_(i,n)}catch(_){bt(a,a.return,_)}}break;case 27:n===null&&l&4&&sy(a);case 26:case 5:qr(i,a),n===null&&l&4&&ny(a),l&512&&po(a,a.return);break;case 12:qr(i,a);break;case 31:qr(i,a),l&4&&uy(i,a);break;case 13:qr(i,a),l&4&&hy(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Ax.bind(null,a),Qx(i,a))));break;case 22:if(l=a.memoizedState!==null||Wr,!l){n=n!==null&&n.memoizedState!==null||_i,u=Wr;var d=_i;Wr=l,(_i=n)&&!d?$r(i,a,(a.subtreeFlags&8772)!==0):qr(i,a),Wr=u,_i=d}break;case 30:break;default:qr(i,a)}}function oy(i){var n=i.alternate;n!==null&&(i.alternate=null,oy(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&Xs(n)),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 Ft=null,pn=!1;function Fr(i,n,a){for(a=a.child;a!==null;)cy(i,n,a),a=a.sibling}function cy(i,n,a){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Tt,a)}catch{}switch(a.tag){case 26:_i||Cr(a,n),Fr(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:_i||Cr(a,n);var l=Ft,u=pn;Ts(a.type)&&(Ft=a.stateNode,pn=!1),Fr(i,n,a),Co(a.stateNode),Ft=l,pn=u;break;case 5:_i||Cr(a,n);case 6:if(l=Ft,u=pn,Ft=null,Fr(i,n,a),Ft=l,pn=u,Ft!==null)if(pn)try{(Ft.nodeType===9?Ft.body:Ft.nodeName==="HTML"?Ft.ownerDocument.body:Ft).removeChild(a.stateNode)}catch(d){bt(a,n,d)}else try{Ft.removeChild(a.stateNode)}catch(d){bt(a,n,d)}break;case 18:Ft!==null&&(pn?(i=Ft,tb(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),bl(i)):tb(Ft,a.stateNode));break;case 4:l=Ft,u=pn,Ft=a.stateNode.containerInfo,pn=!0,Fr(i,n,a),Ft=l,pn=u;break;case 0:case 11:case 14:case 15:bs(2,a,n),_i||bs(4,a,n),Fr(i,n,a);break;case 1:_i||(Cr(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&iy(a,n,l)),Fr(i,n,a);break;case 21:Fr(i,n,a);break;case 22:_i=(l=_i)||a.memoizedState!==null,Fr(i,n,a),_i=l;break;default:Fr(i,n,a)}}function uy(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{bl(i)}catch(a){bt(n,n.return,a)}}}function hy(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{bl(i)}catch(a){bt(n,n.return,a)}}function xx(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new ay),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new ay),n;default:throw Error(s(435,i.tag))}}function uu(i,n){var a=xx(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=Lx.bind(null,i,l);l.then(u,u)}})}function mn(i,n){var a=n.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(Ts(C.type)){Ft=C.stateNode,pn=!1;break e}break;case 5:Ft=C.stateNode,pn=!1;break e;case 3:case 4:Ft=C.stateNode.containerInfo,pn=!0;break e}C=C.return}if(Ft===null)throw Error(s(160));cy(d,_,u),Ft=null,pn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)dy(n,i),n=n.sibling}var ur=null;function dy(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:mn(n,i),gn(i),l&4&&(bs(3,i,i.return),fo(3,i),bs(5,i,i.return));break;case 1:mn(n,i),gn(i),l&512&&(_i||a===null||Cr(a,a.return)),l&64&&Wr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=ur;if(mn(n,i),gn(i),l&512&&(_i||a===null||Cr(a,a.return)),l&4){var d=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":d=u.getElementsByTagName("title")[0],(!d||d[ir]||d[Wt]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(l),u.head.insertBefore(d,u.querySelector("head > title"))),Gi(d,l,a),d[Wt]=i,jt(d),l=d;break e;case"link":var _=db("link","href",u).get(l+(a.href||""));if(_){for(var C=0;C<_.length;C++)if(d=_[C],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(C,1);break t}}d=u.createElement(l),Gi(d,l,a),u.head.appendChild(d);break;case"meta":if(_=db("meta","content",u).get(l+(a.content||""))){for(C=0;C<_.length;C++)if(d=_[C],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(C,1);break t}}d=u.createElement(l),Gi(d,l,a),u.head.appendChild(d);break;default:throw Error(s(468,l))}d[Wt]=i,jt(d),l=d}i.stateNode=l}else fb(u,i.type,i.stateNode);else i.stateNode=hb(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?fb(u,i.type,i.stateNode):hb(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&of(i,i.memoizedProps,a.memoizedProps)}break;case 27:mn(n,i),gn(i),l&512&&(_i||a===null||Cr(a,a.return)),a!==null&&l&4&&of(i,i.memoizedProps,a.memoizedProps);break;case 5:if(mn(n,i),gn(i),l&512&&(_i||a===null||Cr(a,a.return)),i.flags&32){u=i.stateNode;try{Un(u,"")}catch(Be){bt(i,i.return,Be)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,of(i,u,a!==null?a.memoizedProps:u)),l&1024&&(hf=!0);break;case 6:if(mn(n,i),gn(i),l&4){if(i.stateNode===null)throw Error(s(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Be){bt(i,i.return,Be)}}break;case 3:if(Eu=null,u=ur,ur=xu(n.containerInfo),mn(n,i),ur=u,gn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{bl(n.containerInfo)}catch(Be){bt(i,i.return,Be)}hf&&(hf=!1,fy(i));break;case 4:l=ur,ur=xu(i.stateNode.containerInfo),mn(n,i),gn(i),ur=l;break;case 12:mn(n,i),gn(i);break;case 31:mn(n,i),gn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,uu(i,l)));break;case 13:mn(n,i),gn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(du=$e()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,uu(i,l)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,$=Wr,oe=_i;if(Wr=$||u,_i=oe||N,mn(n,i),_i=oe,Wr=$,gn(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||N||Wr||_i||ma(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){N=a=n;try{if(d=N.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=N.stateNode;var he=N.memoizedProps.style,X=he!=null&&he.hasOwnProperty("display")?he.display:null;C.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(Be){bt(N,N.return,Be)}}}else if(n.tag===6){if(a===null){N=n;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Be){bt(N,N.return,Be)}}}else if(n.tag===18){if(a===null){N=n;try{var ee=N.stateNode;u?ib(ee,!0):ib(N.stateNode,!1)}catch(Be){bt(N,N.return,Be)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===i)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,uu(i,a))));break;case 19:mn(n,i),gn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,uu(i,l)));break;case 30:break;case 21:break;default:mn(n,i),gn(i)}}function gn(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(ry(l)){a=l;break}l=l.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,d=cf(i);cu(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(Un(_,""),a.flags&=-33);var C=cf(i);cu(i,C,_);break;case 3:case 4:var N=a.stateNode.containerInfo,$=cf(i);uf(i,$,N);break;default:throw Error(s(161))}}catch(oe){bt(i,i.return,oe)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function fy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;fy(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function qr(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)ly(i,n.alternate,n),n=n.sibling}function ma(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:bs(4,n,n.return),ma(n);break;case 1:Cr(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&iy(n,n.return,a),ma(n);break;case 27:Co(n.stateNode);case 26:case 5:Cr(n,n.return),ma(n);break;case 22:n.memoizedState===null&&ma(n);break;case 30:ma(n);break;default:ma(n)}i=i.sibling}}function $r(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:$r(u,d,a),fo(4,d);break;case 1:if($r(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch($){bt(l,l.return,$)}if(l=d,u=l.updateQueue,u!==null){var C=l.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)F_(N[u],C)}catch($){bt(l,l.return,$)}}a&&_&64&&ty(d),po(d,d.return);break;case 27:sy(d);case 26:case 5:$r(u,d,a),a&&l===null&&_&4&&ny(d),po(d,d.return);break;case 12:$r(u,d,a);break;case 31:$r(u,d,a),a&&_&4&&uy(u,d);break;case 13:$r(u,d,a),a&&_&4&&hy(u,d);break;case 22:d.memoizedState===null&&$r(u,d,a),po(d,d.return);break;case 30:break;default:$r(u,d,a)}n=n.sibling}}function df(i,n){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Jl(a))}function ff(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Jl(i))}function hr(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)py(i,n,a,l),n=n.sibling}function py(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:hr(i,n,a,l),u&2048&&fo(9,n);break;case 1:hr(i,n,a,l);break;case 3:hr(i,n,a,l),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Jl(i)));break;case 12:if(u&2048){hr(i,n,a,l),i=n.stateNode;try{var d=n.memoizedProps,_=d.id,C=d.onPostCommit;typeof C=="function"&&C(_,n.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){bt(n,n.return,N)}}else hr(i,n,a,l);break;case 31:hr(i,n,a,l);break;case 13:hr(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?hr(i,n,a,l):mo(i,n):d._visibility&2?hr(i,n,a,l):(d._visibility|=2,cl(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&df(_,n);break;case 24:hr(i,n,a,l),u&2048&&ff(n.alternate,n);break;default:hr(i,n,a,l)}}function cl(i,n,a,l,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,N=l,$=_.flags;switch(_.tag){case 0:case 11:case 15:cl(d,_,C,N,u),fo(8,_);break;case 23:break;case 22:var oe=_.stateNode;_.memoizedState!==null?oe._visibility&2?cl(d,_,C,N,u):mo(d,_):(oe._visibility|=2,cl(d,_,C,N,u)),u&&$&2048&&df(_.alternate,_);break;case 24:cl(d,_,C,N,u),u&&$&2048&&ff(_.alternate,_);break;default:cl(d,_,C,N,u)}n=n.sibling}}function mo(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,l=n,u=l.flags;switch(l.tag){case 22:mo(a,l),u&2048&&df(l.alternate,l);break;case 24:mo(a,l),u&2048&&ff(l.alternate,l);break;default:mo(a,l)}n=n.sibling}}var go=8192;function ul(i,n,a){if(i.subtreeFlags&go)for(i=i.child;i!==null;)my(i,n,a),i=i.sibling}function my(i,n,a){switch(i.tag){case 26:ul(i,n,a),i.flags&go&&i.memoizedState!==null&&uk(a,ur,i.memoizedState,i.memoizedProps);break;case 5:ul(i,n,a);break;case 3:case 4:var l=ur;ur=xu(i.stateNode.containerInfo),ul(i,n,a),ur=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=go,go=16777216,ul(i,n,a),go=l):ul(i,n,a));break;default:ul(i,n,a)}}function gy(i){var n=i.alternate;if(n!==null&&(i=n.child,i!==null)){n.child=null;do n=i.sibling,i.sibling=null,i=n;while(i!==null)}}function _o(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Oi=l,vy(l,i)}gy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)_y(i),i=i.sibling}function _y(i){switch(i.tag){case 0:case 11:case 15:_o(i),i.flags&2048&&bs(9,i,i.return);break;case 3:_o(i);break;case 12:_o(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,hu(i)):_o(i);break;default:_o(i)}}function hu(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Oi=l,vy(l,i)}gy(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:bs(8,n,n.return),hu(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,hu(n));break;default:hu(n)}i=i.sibling}}function vy(i,n){for(;Oi!==null;){var a=Oi;switch(a.tag){case 0:case 11:case 15:bs(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Jl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Oi=l;else e:for(a=i;Oi!==null;){l=Oi;var u=l.sibling,d=l.return;if(oy(l),l===a){Oi=null;break e}if(u!==null){u.return=d,Oi=u;break e}Oi=d}}}var kx={getCacheForType:function(i){var n=Yi(pi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Yi(pi).controller.signal}},Ex=typeof WeakMap=="function"?WeakMap:Map,_t=0,Rt=null,lt=null,ht=0,yt=0,Nn=null,Ss=!1,hl=!1,pf=!1,Vr=0,ti=0,ws=0,ga=0,mf=0,An=0,dl=0,vo=null,_n=null,gf=!1,du=0,yy=0,fu=1/0,pu=null,Cs=null,Ci=0,xs=null,fl=null,Yr=0,_f=0,vf=null,by=null,yo=0,yf=null;function Ln(){return(_t&2)!==0&&ht!==0?ht&-ht:R.T!==null?kf():Ni()}function Sy(){if(An===0)if((ht&536870912)===0||pt){var i=Mi;Mi<<=1,(Mi&3932160)===0&&(Mi=262144),An=i}else An=536870912;return i=Rn.current,i!==null&&(i.flags|=32),An}function vn(i,n,a){(i===Rt&&(yt===2||yt===9)||i.cancelPendingCommit!==null)&&(pl(i,0),ks(i,ht,An,!1)),Fi(i,a),((_t&2)===0||i!==Rt)&&(i===Rt&&((_t&2)===0&&(ga|=a),ti===4&&ks(i,ht,An,!1)),xr(i))}function wy(i,n,a){if((_t&6)!==0)throw Error(s(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Vt(i,n),u=l?Rx(i,n):Sf(i,n,!0),d=l;do{if(u===0){hl&&!l&&ks(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!Tx(a)){u=Sf(i,n,!1),d=!1;continue}if(u===2){if(d=n,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){n=_;e:{var C=i;u=vo;var N=C.current.memoizedState.isDehydrated;if(N&&(pl(C,_).flags|=256),_=Sf(C,_,!1),_!==2){if(pf&&!N){C.errorRecoveryDisabledLanes|=d,ga|=d,u=4;break e}d=_n,_n=u,d!==null&&(_n===null?_n=d:_n.push.apply(_n,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){pl(i,0),ks(i,n,0,!0);break}e:{switch(l=i,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:ks(l,n,An,!Ss);break e;case 2:_n=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(u=du+300-$e(),10<u)){if(ks(l,n,An,!Ss),Kt(l,0,!0)!==0)break e;Yr=n,l.timeoutHandle=Jy(Cy.bind(null,l,a,_n,pu,gf,n,An,ga,dl,Ss,d,"Throttled",-0,0),u);break e}Cy(l,a,_n,pu,gf,n,An,ga,dl,Ss,d,null,-0,0)}}break}while(!0);xr(i)}function Cy(i,n,a,l,u,d,_,C,N,$,oe,he,X,ee){if(i.timeoutHandle=-1,he=n.subtreeFlags,he&8192||(he&16785408)===16785408){he={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:hn},my(n,d,he);var Be=(d&62914560)===d?du-$e():(d&4194048)===d?yy-$e():0;if(Be=hk(he,Be),Be!==null){Yr=d,i.cancelPendingCommit=Be(Ny.bind(null,i,n,d,a,l,u,_,C,N,oe,he,null,X,ee)),ks(i,d,_,!$);return}}Ny(i,n,d,a,l,u,_,C,N)}function Tx(i){for(var n=i;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],d=u.getSnapshot;u=u.value;try{if(!Tn(d(),u))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function ks(i,n,a,l){n&=~mf,n&=~ga,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-At(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&wt(i,a,n)}function mu(){return(_t&6)===0?(bo(0),!1):!0}function bf(){if(lt!==null){if(yt===0)var i=lt.return;else i=lt,jr=la=null,Od(i),rl=null,to=0,i=lt;for(;i!==null;)ey(i.alternate,i),i=i.return;lt=null}}function pl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Vx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Yr=0,bf(),Rt=i,lt=a=Or(i.current,null),ht=n,yt=0,Nn=null,Ss=!1,hl=Vt(i,n),pf=!1,dl=An=mf=ga=ws=ti=0,_n=vo=null,gf=!1,(n&8)!==0&&(n|=n&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=n;0<l;){var u=31-At(l),d=1<<u;n|=i[u],l&=~d}return Vr=n,zc(),a}function xy(i,n){Je=null,R.H=co,n===nl||n===Fc?(n=I_(),yt=3):n===Cd?(n=I_(),yt=4):yt=n===Zd?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Nn=n,lt===null&&(ti=1,ru(i,Wn(n,i.current)))}function ky(){var i=Rn.current;return i===null?!0:(ht&4194048)===ht?Vn===null:(ht&62914560)===ht||(ht&536870912)!==0?i===Vn:!1}function Ey(){var i=R.H;return R.H=co,i===null?co:i}function Ty(){var i=R.A;return R.A=kx,i}function gu(){ti=4,Ss||(ht&4194048)!==ht&&Rn.current!==null||(hl=!0),(ws&134217727)===0&&(ga&134217727)===0||Rt===null||ks(Rt,ht,An,!1)}function Sf(i,n,a){var l=_t;_t|=2;var u=Ey(),d=Ty();(Rt!==i||ht!==n)&&(pu=null,pl(i,n)),n=!1;var _=ti;e:do try{if(yt!==0&&lt!==null){var C=lt,N=Nn;switch(yt){case 8:bf(),_=6;break e;case 3:case 2:case 9:case 6:Rn.current===null&&(n=!0);var $=yt;if(yt=0,Nn=null,ml(i,C,N,$),a&&hl){_=0;break e}break;default:$=yt,yt=0,Nn=null,ml(i,C,N,$)}}Dx(),_=ti;break}catch(oe){xy(i,oe)}while(!0);return n&&i.shellSuspendCounter++,jr=la=null,_t=l,R.H=u,R.A=d,lt===null&&(Rt=null,ht=0,zc()),_}function Dx(){for(;lt!==null;)Dy(lt)}function Rx(i,n){var a=_t;_t|=2;var l=Ey(),u=Ty();Rt!==i||ht!==n?(pu=null,fu=$e()+500,pl(i,n)):hl=Vt(i,n);e:do try{if(yt!==0&&lt!==null){n=lt;var d=Nn;t:switch(yt){case 1:yt=0,Nn=null,ml(i,n,d,1);break;case 2:case 9:if(H_(d)){yt=0,Nn=null,Ry(n);break}n=function(){yt!==2&&yt!==9||Rt!==i||(yt=7),xr(i)},d.then(n,n);break e;case 3:yt=7;break e;case 4:yt=5;break e;case 7:H_(d)?(yt=0,Nn=null,Ry(n)):(yt=0,Nn=null,ml(i,n,d,7));break;case 5:var _=null;switch(lt.tag){case 26:_=lt.memoizedState;case 5:case 27:var C=lt;if(_?pb(_):C.stateNode.complete){yt=0,Nn=null;var N=C.sibling;if(N!==null)lt=N;else{var $=C.return;$!==null?(lt=$,_u($)):lt=null}break t}}yt=0,Nn=null,ml(i,n,d,5);break;case 6:yt=0,Nn=null,ml(i,n,d,6);break;case 8:bf(),ti=6;break e;default:throw Error(s(462))}}Mx();break}catch(oe){xy(i,oe)}while(!0);return jr=la=null,R.H=l,R.A=u,_t=a,lt!==null?0:(Rt=null,ht=0,zc(),ti)}function Mx(){for(;lt!==null&&!at();)Dy(lt)}function Dy(i){var n=Qv(i.alternate,i,Vr);i.memoizedProps=i.pendingProps,n===null?_u(i):lt=n}function Ry(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=$v(a,n,n.pendingProps,n.type,void 0,ht);break;case 11:n=$v(a,n,n.pendingProps,n.type.render,n.ref,ht);break;case 5:Od(n);default:ey(a,n),n=lt=T_(n,Vr),n=Qv(a,n,Vr)}i.memoizedProps=i.pendingProps,n===null?_u(i):lt=n}function ml(i,n,a,l){jr=la=null,Od(n),rl=null,to=0;var u=n.return;try{if(vx(i,u,n,a,ht)){ti=1,ru(i,Wn(a,i.current)),lt=null;return}}catch(d){if(u!==null)throw lt=u,d;ti=1,ru(i,Wn(a,i.current)),lt=null;return}n.flags&32768?(pt||l===1?i=!0:hl||(ht&536870912)!==0?i=!1:(Ss=i=!0,(l===2||l===9||l===3||l===6)&&(l=Rn.current,l!==null&&l.tag===13&&(l.flags|=16384))),My(n,i)):_u(n)}function _u(i){var n=i;do{if((n.flags&32768)!==0){My(n,Ss);return}i=n.return;var a=Sx(n.alternate,n,Vr);if(a!==null){lt=a;return}if(n=n.sibling,n!==null){lt=n;return}lt=n=i}while(n!==null);ti===0&&(ti=5)}function My(i,n){do{var a=wx(i.alternate,i);if(a!==null){a.flags&=32767,lt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){lt=i;return}lt=i=a}while(i!==null);ti=6,lt=null}function Ny(i,n,a,l,u,d,_,C,N){i.cancelPendingCommit=null;do vu();while(Ci!==0);if((_t&6)!==0)throw Error(s(327));if(n!==null){if(n===i.current)throw Error(s(177));if(d=n.lanes|n.childLanes,d|=od,zt(i,a,d,_,C,N),i===Rt&&(lt=Rt=null,ht=0),fl=n,xs=i,Yr=a,_f=d,vf=u,by=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Bx(le,function(){return zy(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=R.T,R.T=null,u=Y.p,Y.p=2,_=_t,_t|=4;try{Cx(i,n,a)}finally{_t=_,Y.p=u,R.T=l}}Ci=1,Ay(),Ly(),By()}}function Ay(){if(Ci===1){Ci=0;var i=xs,n=fl,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=R.T,R.T=null;var l=Y.p;Y.p=2;var u=_t;_t|=4;try{dy(n,i);var d=Lf,_=v_(i.containerInfo),C=d.focusedElem,N=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&__(C.ownerDocument.documentElement,C)){if(N!==null&&nd(C)){var $=N.start,oe=N.end;if(oe===void 0&&(oe=$),"selectionStart"in C)C.selectionStart=$,C.selectionEnd=Math.min(oe,C.value.length);else{var he=C.ownerDocument||document,X=he&&he.defaultView||window;if(X.getSelection){var ee=X.getSelection(),Be=C.textContent.length,Ve=Math.min(N.start,Be),kt=N.end===void 0?Ve:Math.min(N.end,Be);!ee.extend&&Ve>kt&&(_=kt,kt=Ve,Ve=_);var I=g_(C,Ve),O=g_(C,kt);if(I&&O&&(ee.rangeCount!==1||ee.anchorNode!==I.node||ee.anchorOffset!==I.offset||ee.focusNode!==O.node||ee.focusOffset!==O.offset)){var q=he.createRange();q.setStart(I.node,I.offset),ee.removeAllRanges(),Ve>kt?(ee.addRange(q),ee.extend(O.node,O.offset)):(q.setEnd(O.node,O.offset),ee.addRange(q))}}}}for(he=[],ee=C;ee=ee.parentNode;)ee.nodeType===1&&he.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<he.length;C++){var ue=he[C];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Mu=!!Af,Lf=Af=null}finally{_t=u,Y.p=l,R.T=a}}i.current=n,Ci=2}}function Ly(){if(Ci===2){Ci=0;var i=xs,n=fl,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=R.T,R.T=null;var l=Y.p;Y.p=2;var u=_t;_t|=4;try{ly(i,n.alternate,n)}finally{_t=u,Y.p=l,R.T=a}}Ci=3}}function By(){if(Ci===4||Ci===3){Ci=0,Bt();var i=xs,n=fl,a=Yr,l=by;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ci=5:(Ci=0,fl=xs=null,Oy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(Cs=null),wn(a),n=n.stateNode,Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot(Tt,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=R.T,u=Y.p,Y.p=2,R.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{R.T=n,Y.p=u}}(Yr&3)!==0&&vu(),xr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===yf?yo++:(yo=0,yf=i):yo=0,bo(0)}}function Oy(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Jl(n)))}function vu(){return Ay(),Ly(),By(),zy()}function zy(){if(Ci!==5)return!1;var i=xs,n=_f;_f=0;var a=wn(Yr),l=R.T,u=Y.p;try{Y.p=32>a?32:a,R.T=null,a=vf,vf=null;var d=xs,_=Yr;if(Ci=0,fl=xs=null,Yr=0,(_t&6)!==0)throw Error(s(331));var C=_t;if(_t|=4,_y(d.current),py(d,d.current,_,a),_t=C,bo(0,!1),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot(Tt,d)}catch{}return!0}finally{Y.p=u,R.T=l,Oy(i,n)}}function jy(i,n,a){n=Wn(a,n),n=Gd(i.stateNode,n,2),i=_s(i,n,2),i!==null&&(Fi(i,2),xr(i))}function bt(i,n,a){if(i.tag===3)jy(i,i,a);else for(;n!==null;){if(n.tag===3){jy(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Cs===null||!Cs.has(l))){i=Wn(a,i),a=Hv(2),l=_s(n,a,2),l!==null&&(Pv(a,l,n,i),Fi(l,2),xr(l));break}}n=n.return}}function wf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new Ex;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(a)||(pf=!0,u.add(a),i=Nx.bind(null,i,n,a),n.then(i,i))}function Nx(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Rt===i&&(ht&a)===a&&(ti===4||ti===3&&(ht&62914560)===ht&&300>$e()-du?(_t&2)===0&&pl(i,0):mf|=a,dl===ht&&(dl=0)),xr(i)}function Hy(i,n){n===0&&(n=ri()),i=ra(i,n),i!==null&&(Fi(i,n),xr(i))}function Ax(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),Hy(i,a)}function Lx(i,n){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(s(314))}l!==null&&l.delete(n),Hy(i,a)}function Bx(i,n){return Le(i,n)}var yu=null,gl=null,Cf=!1,bu=!1,xf=!1,Es=0;function xr(i){i!==gl&&i.next===null&&(gl===null?yu=gl=i:gl=gl.next=i),bu=!0,Cf||(Cf=!0,zx())}function bo(i,n){if(!xf&&bu){xf=!0;do for(var a=!1,l=yu;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var d=0;else{var _=l.suspendedLanes,C=l.pingedLanes;d=(1<<31-At(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Ky(l,d))}else d=ht,d=Kt(l,l===Rt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||Vt(l,d)||(a=!0,Ky(l,d));l=l.next}while(a);xf=!1}}function Ox(){Py()}function Py(){bu=Cf=!1;var i=0;Es!==0&&$x()&&(i=Es);for(var n=$e(),a=null,l=yu;l!==null;){var u=l.next,d=Iy(l,n);d===0?(l.next=null,a===null?yu=u:a.next=u,u===null&&(gl=a)):(a=l,(i!==0||(d&3)!==0)&&(bu=!0)),l=u}Ci!==0&&Ci!==5||bo(i),Es!==0&&(Es=0)}function Iy(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-At(d),C=1<<_,N=u[_];N===-1?((C&a)===0||(C&l)!==0)&&(u[_]=Si(C,n)):N<=n&&(i.expiredLanes|=C),d&=~C}if(n=Rt,a=ht,a=Kt(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(yt===2||yt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&je(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Vt(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&je(l),wn(a)){case 2:case 8:a=Ke;break;case 32:a=le;break;case 268435456:a=Qe;break;default:a=le}return l=Uy.bind(null,i),a=Le(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&je(l),i.callbackPriority=2,i.callbackNode=null,2}function Uy(i,n){if(Ci!==0&&Ci!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(vu()&&i.callbackNode!==a)return null;var l=ht;return l=Kt(i,i===Rt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(wy(i,l,n),Iy(i,$e()),i.callbackNode!=null&&i.callbackNode===a?Uy.bind(null,i):null)}function Ky(i,n){if(vu())return null;wy(i,n,!0)}function zx(){Yx(function(){(_t&6)!==0?Le(Z,Ox):Py()})}function kf(){if(Es===0){var i=tl;i===0&&(i=Qi,Qi<<=1,(Qi&261888)===0&&(Qi=256)),Es=i}return Es}function Wy(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:un(""+i)}function Fy(i,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,i.id&&a.setAttribute("form",i.id),n.parentNode.insertBefore(a,n),i=new FormData(i),a.parentNode.removeChild(a),i}function jx(i,n,a,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=Wy((u[Ai]||null).action),_=l.submitter;_&&(n=(n=_[Ai]||null)?Wy(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new qe("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Es!==0){var N=_?Fy(u,_):new FormData(u);Fd(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(C.preventDefault(),N=_?Fy(u,_):new FormData(u),Fd(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var Ef=0;Ef<ld.length;Ef++){var Tf=ld[Ef],Hx=Tf.toLowerCase(),Px=Tf[0].toUpperCase()+Tf.slice(1);cr(Hx,"on"+Px)}cr(S_,"onAnimationEnd"),cr(w_,"onAnimationIteration"),cr(C_,"onAnimationStart"),cr("dblclick","onDoubleClick"),cr("focusin","onFocus"),cr("focusout","onBlur"),cr(tx,"onTransitionRun"),cr(ix,"onTransitionStart"),cr(nx,"onTransitionCancel"),cr(x_,"onTransitionEnd"),Pn("onMouseEnter",["mouseout","mouseover"]),Pn("onMouseLeave",["mouseout","mouseover"]),Pn("onPointerEnter",["pointerout","pointerover"]),Pn("onPointerLeave",["pointerout","pointerover"]),ar("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ar("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ar("onBeforeInput",["compositionend","keypress","textInput","paste"]),ar("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ar("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ar("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var So="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(" "),Ix=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(So));function qy(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var d=void 0;if(n)for(var _=l.length-1;0<=_;_--){var C=l[_],N=C.instance,$=C.currentTarget;if(C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(oe){Oc(oe)}u.currentTarget=null,d=N}else for(_=0;_<l.length;_++){if(C=l[_],N=C.instance,$=C.currentTarget,C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(oe){Oc(oe)}u.currentTarget=null,d=N}}}}function ot(i,n){var a=n[Nr];a===void 0&&(a=n[Nr]=new Set);var l=i+"__bubble";a.has(l)||($y(n,i,2,!1),a.add(l))}function Df(i,n,a){var l=0;n&&(l|=4),$y(a,i,l,n)}var Su="_reactListening"+Math.random().toString(36).slice(2);function Rf(i){if(!i[Su]){i[Su]=!0,Pa.forEach(function(a){a!=="selectionchange"&&(Ix.has(a)||Df(a,!1,i),Df(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[Su]||(n[Su]=!0,Df("selectionchange",!1,n))}}function $y(i,n,a,l){switch(Sb(n)){case 2:var u=pk;break;case 8:u=mk;break;default:u=Ff}a=u.bind(null,n,a,i),u=void 0,!cs||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(n,a,{capture:!0,passive:u}):i.addEventListener(n,a,!0):u!==void 0?i.addEventListener(n,a,{passive:u}):i.addEventListener(n,a,!1)}function Mf(i,n,a,l,u){var d=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var C=l.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=l.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=nr(C),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){l=d=_;continue e}C=C.parentNode}}l=l.return}Br(function(){var $=d,oe=Js(a),he=[];e:{var X=k_.get(i);if(X!==void 0){var ee=qe,Be=i;switch(i){case"keypress":if(z(a)===0)break e;case"keydown":case"keyup":ee=LC;break;case"focusin":Be="focus",ee=Bi;break;case"focusout":Be="blur",ee=Bi;break;case"beforeblur":case"afterblur":ee=Bi;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":ee=Ye;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=ut;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=zC;break;case S_:case w_:case C_:ee=wi;break;case x_:ee=HC;break;case"scroll":case"scrollend":ee=ci;break;case"wheel":ee=IC;break;case"copy":case"cut":case"paste":ee=En;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=i_;break;case"toggle":case"beforetoggle":ee=KC}var Ve=(n&4)!==0,kt=!Ve&&(i==="scroll"||i==="scrollend"),I=Ve?X!==null?X+"Capture":null:X;Ve=[];for(var O=$,q;O!==null;){var ue=O;if(q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||q===null||I===null||(ue=dn(O,I),ue!=null&&Ve.push(wo(O,ue,q))),kt)break;O=O.return}0<Ve.length&&(X=new ee(X,Be,null,a,oe),he.push({event:X,listeners:Ve}))}}if((n&7)===0){e:{if(X=i==="mouseover"||i==="pointerover",ee=i==="mouseout"||i==="pointerout",X&&a!==os&&(Be=a.relatedTarget||a.fromElement)&&(nr(Be)||Be[ai]))break e;if((ee||X)&&(X=oe.window===oe?oe:(X=oe.ownerDocument)?X.defaultView||X.parentWindow:window,ee?(Be=a.relatedTarget||a.toElement,ee=$,Be=Be?nr(Be):null,Be!==null&&(kt=c(Be),Ve=Be.tag,Be!==kt||Ve!==5&&Ve!==27&&Ve!==6)&&(Be=null)):(ee=null,Be=$),ee!==Be)){if(Ve=Ye,ue="onMouseLeave",I="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(Ve=i_,ue="onPointerLeave",I="onPointerEnter",O="pointer"),kt=ee==null?X:Hn(ee),q=Be==null?X:Hn(Be),X=new Ve(ue,O+"leave",ee,a,oe),X.target=kt,X.relatedTarget=q,ue=null,nr(oe)===$&&(Ve=new Ve(I,O+"enter",Be,a,oe),Ve.target=q,Ve.relatedTarget=kt,ue=Ve),kt=ue,ee&&Be)t:{for(Ve=Ux,I=ee,O=Be,q=0,ue=I;ue;ue=Ve(ue))q++;ue=0;for(var Fe=O;Fe;Fe=Ve(Fe))ue++;for(;0<q-ue;)I=Ve(I),q--;for(;0<ue-q;)O=Ve(O),ue--;for(;q--;){if(I===O||O!==null&&I===O.alternate){Ve=I;break t}I=Ve(I),O=Ve(O)}Ve=null}else Ve=null;ee!==null&&Vy(he,X,ee,Ve,!1),Be!==null&&kt!==null&&Vy(he,kt,Be,Ve,!0)}}e:{if(X=$?Hn($):window,ee=X.nodeName&&X.nodeName.toLowerCase(),ee==="select"||ee==="input"&&X.type==="file")var mt=u_;else if(o_(X))if(h_)mt=QC;else{mt=GC;var Pe=XC}else ee=X.nodeName,!ee||ee.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?$&&lr($.elementType)&&(mt=u_):mt=ZC;if(mt&&(mt=mt(i,$))){c_(he,mt,a,oe);break e}Pe&&Pe(i,X,$),i==="focusout"&&$&&X.type==="number"&&$.memoizedProps.value!=null&&Lr(X,"number",X.value)}switch(Pe=$?Hn($):window,i){case"focusin":(o_(Pe)||Pe.contentEditable==="true")&&(Va=Pe,rd=$,Gl=null);break;case"focusout":Gl=rd=Va=null;break;case"mousedown":sd=!0;break;case"contextmenu":case"mouseup":case"dragend":sd=!1,y_(he,a,oe);break;case"selectionchange":if(ex)break;case"keydown":case"keyup":y_(he,a,oe)}var tt;if(ed)e:{switch(i){case"compositionstart":var dt="onCompositionStart";break e;case"compositionend":dt="onCompositionEnd";break e;case"compositionupdate":dt="onCompositionUpdate";break e}dt=void 0}else $a?a_(i,a)&&(dt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(dt="onCompositionStart");dt&&(n_&&a.locale!=="ko"&&($a||dt!=="onCompositionStart"?dt==="onCompositionEnd"&&$a&&(tt=E()):(tn=oe,us="value"in tn?tn.value:tn.textContent,$a=!0)),Pe=wu($,dt),0<Pe.length&&(dt=new Nc(dt,i,null,a,oe),he.push({event:dt,listeners:Pe}),tt?dt.data=tt:(tt=l_(a),tt!==null&&(dt.data=tt)))),(tt=FC?qC(i,a):$C(i,a))&&(dt=wu($,"onBeforeInput"),0<dt.length&&(Pe=new Nc("onBeforeInput","beforeinput",null,a,oe),he.push({event:Pe,listeners:dt}),Pe.data=tt)),jx(he,i,$,a,oe)}qy(he,n)})}function wo(i,n,a){return{instance:i,listener:n,currentTarget:a}}function wu(i,n){for(var a=n+"Capture",l=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=dn(i,a),u!=null&&l.unshift(wo(i,u,d)),u=dn(i,n),u!=null&&l.push(wo(i,u,d))),i.tag===3)return l;i=i.return}return[]}function Ux(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Vy(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,N=C.alternate,$=C.stateNode;if(C=C.tag,N!==null&&N===l)break;C!==5&&C!==26&&C!==27||$===null||(N=$,u?($=dn(a,d),$!=null&&_.unshift(wo(a,$,N))):u||($=dn(a,d),$!=null&&_.push(wo(a,$,N)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var Kx=/\r\n?/g,Wx=/\u0000|\uFFFD/g;function Yy(i){return(typeof i=="string"?i:""+i).replace(Kx,`
10
- `).replace(Wx,"")}function Xy(i,n){return n=Yy(n),Yy(i)===n}function xt(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||Un(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&Un(i,""+l);break;case"className":ss(i,"class",l);break;case"tabIndex":ss(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":ss(i,a,l);break;case"style":Fa(i,l,d);break;case"data":if(n!=="object"){ss(i,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=un(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="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 d=="function"&&(a==="formAction"?(n!=="input"&&xt(i,n,"name",u.name,u,null),xt(i,n,"formEncType",u.formEncType,u,null),xt(i,n,"formMethod",u.formMethod,u,null),xt(i,n,"formTarget",u.formTarget,u,null)):(xt(i,n,"encType",u.encType,u,null),xt(i,n,"method",u.method,u,null),xt(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=un(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=hn);break;case"onScroll":l!=null&&ot("scroll",i);break;case"onScrollEnd":l!=null&&ot("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=un(""+l),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":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):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":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":ot("beforetoggle",i),ot("toggle",i),_r(i,"popover",l);break;case"xlinkActuate":Li(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Li(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Li(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Li(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Li(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Li(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Li(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Li(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Li(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":_r(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=ls.get(a)||a,_r(i,a,l))}}function Nf(i,n,a,l,u,d){switch(a){case"style":Fa(i,l,d);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Un(i,l):(typeof l=="number"||typeof l=="bigint")&&Un(i,""+l);break;case"onScroll":l!=null&&ot("scroll",i);break;case"onScrollEnd":l!=null&&ot("scrollend",i);break;case"onClick":l!=null&&(i.onclick=hn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ia.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),n=a.slice(2,u?a.length-7:void 0),d=i[Ai]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof l=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):_r(i,a,l)}}}function Gi(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",i),ot("load",i);var l=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:xt(i,n,d,_,a,null)}}u&&xt(i,n,"srcSet",a.srcSet,a,null),l&&xt(i,n,"src",a.src,a,null);return;case"input":ot("invalid",i);var C=d=_=u=null,N=null,$=null;for(l in a)if(a.hasOwnProperty(l)){var oe=a[l];if(oe!=null)switch(l){case"name":u=oe;break;case"type":_=oe;break;case"checked":N=oe;break;case"defaultChecked":$=oe;break;case"value":d=oe;break;case"defaultValue":C=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(s(137,n));break;default:xt(i,n,l,oe,a,null)}}Gs(i,d,C,N,$,_,u,!1);return;case"select":ot("invalid",i),l=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(C=a[u],C!=null))switch(u){case"value":d=C;break;case"defaultValue":_=C;break;case"multiple":l=C;default:xt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?vr(i,!!l,n,!1):a!=null&&vr(i,!!l,a,!0);return;case"textarea":ot("invalid",i),d=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":l=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:xt(i,n,_,C,a,null)}In(i,l,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(l=a[N],l!=null)&&(N==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":xt(i,n,N,l,a,null));return;case"dialog":ot("beforetoggle",i),ot("toggle",i),ot("cancel",i),ot("close",i);break;case"iframe":case"object":ot("load",i);break;case"video":case"audio":for(l=0;l<So.length;l++)ot(So[l],i);break;case"image":ot("error",i),ot("load",i);break;case"details":ot("toggle",i);break;case"embed":case"source":case"link":ot("error",i),ot("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($ in a)if(a.hasOwnProperty($)&&(l=a[$],l!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:xt(i,n,$,l,a,null)}return;default:if(lr(n)){for(oe in a)a.hasOwnProperty(oe)&&(l=a[oe],l!==void 0&&Nf(i,n,oe,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&xt(i,n,C,l,a,null))}function Fx(i,n,a,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,C=null,N=null,$=null,oe=null;for(ee in a){var he=a[ee];if(a.hasOwnProperty(ee)&&he!=null)switch(ee){case"checked":break;case"value":break;case"defaultValue":N=he;default:l.hasOwnProperty(ee)||xt(i,n,ee,null,l,he)}}for(var X in l){var ee=l[X];if(he=a[X],l.hasOwnProperty(X)&&(ee!=null||he!=null))switch(X){case"type":d=ee;break;case"name":u=ee;break;case"checked":$=ee;break;case"defaultChecked":oe=ee;break;case"value":_=ee;break;case"defaultValue":C=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,n));break;default:ee!==he&&xt(i,n,X,ee,l,he)}}as(i,_,C,N,$,oe,d,u);return;case"select":ee=_=C=X=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":ee=N;default:l.hasOwnProperty(d)||xt(i,n,d,null,l,N)}for(u in l)if(d=l[u],N=a[u],l.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":X=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==N&&xt(i,n,u,d,l,N)}n=C,a=_,l=ee,X!=null?vr(i,!!a,X,!1):!!l!=!!a&&(n!=null?vr(i,!!a,n,!0):vr(i,!!a,a?[]:"",!1));return;case"textarea":ee=X=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!l.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:xt(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":X=u;break;case"defaultValue":ee=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&xt(i,n,_,u,l,d)}Zs(i,X,ee);return;case"option":for(var Be in a)X=a[Be],a.hasOwnProperty(Be)&&X!=null&&!l.hasOwnProperty(Be)&&(Be==="selected"?i.selected=!1:xt(i,n,Be,null,l,X));for(N in l)X=l[N],ee=a[N],l.hasOwnProperty(N)&&X!==ee&&(X!=null||ee!=null)&&(N==="selected"?i.selected=X&&typeof X!="function"&&typeof X!="symbol":xt(i,n,N,X,l,ee));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 Ve in a)X=a[Ve],a.hasOwnProperty(Ve)&&X!=null&&!l.hasOwnProperty(Ve)&&xt(i,n,Ve,null,l,X);for($ in l)if(X=l[$],ee=a[$],l.hasOwnProperty($)&&X!==ee&&(X!=null||ee!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(s(137,n));break;default:xt(i,n,$,X,l,ee)}return;default:if(lr(n)){for(var kt in a)X=a[kt],a.hasOwnProperty(kt)&&X!==void 0&&!l.hasOwnProperty(kt)&&Nf(i,n,kt,void 0,l,X);for(oe in l)X=l[oe],ee=a[oe],!l.hasOwnProperty(oe)||X===ee||X===void 0&&ee===void 0||Nf(i,n,oe,X,l,ee);return}}for(var I in a)X=a[I],a.hasOwnProperty(I)&&X!=null&&!l.hasOwnProperty(I)&&xt(i,n,I,null,l,X);for(he in l)X=l[he],ee=a[he],!l.hasOwnProperty(he)||X===ee||X==null&&ee==null||xt(i,n,he,X,l,ee)}function Gy(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function qx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&Gy(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var N=a[l],$=N.startTime;if($>C)break;var oe=N.transferSize,he=N.initiatorType;oe&&Gy(he)&&(N=N.responseEnd,_+=oe*(N<C?1:(C-$)/(N-$)))}if(--l,n+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return n/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Af=null,Lf=null;function Cu(i){return i.nodeType===9?i:i.ownerDocument}function Zy(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 Qy(i,n){if(i===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&n==="foreignObject"?0:i}function Bf(i,n){return i==="textarea"||i==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Of=null;function $x(){var i=window.event;return i&&i.type==="popstate"?i===Of?!1:(Of=i,!0):(Of=null,!1)}var Jy=typeof setTimeout=="function"?setTimeout:void 0,Vx=typeof clearTimeout=="function"?clearTimeout:void 0,eb=typeof Promise=="function"?Promise:void 0,Yx=typeof queueMicrotask=="function"?queueMicrotask:typeof eb<"u"?function(i){return eb.resolve(null).then(i).catch(Xx)}:Jy;function Xx(i){setTimeout(function(){throw i})}function Ts(i){return i==="head"}function tb(i,n){var a=n,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),bl(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Co(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Co(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[ir]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&Co(i.ownerDocument.body);a=u}while(a);bl(n)}function ib(i,n){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function zf(i){var n=i.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":zf(a),Xs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Gx(i,n,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[ir])switch(n){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==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(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(n==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=Yn(i.nextSibling),i===null)break}return null}function Zx(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Yn(i.nextSibling),i===null))return null;return i}function nb(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=Yn(i.nextSibling),i===null))return null;return i}function jf(i){return i.data==="$?"||i.data==="$~"}function Hf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Qx(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var l=function(){n(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function Yn(i){for(;i!=null;i=i.nextSibling){var n=i.nodeType;if(n===1||n===3)break;if(n===8){if(n=i.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return i}var Pf=null;function rb(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return Yn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function sb(i){i=i.previousSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return i;n--}else a!=="/$"&&a!=="/&"||n++}i=i.previousSibling}return null}function ab(i,n,a){switch(n=Cu(a),i){case"html":if(i=n.documentElement,!i)throw Error(s(452));return i;case"head":if(i=n.head,!i)throw Error(s(453));return i;case"body":if(i=n.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function Co(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);Xs(i)}var Xn=new Map,lb=new Set;function xu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Xr=Y.d;Y.d={f:Jx,r:ek,D:tk,C:ik,L:nk,m:rk,X:ak,S:sk,M:lk};function Jx(){var i=Xr.f(),n=mu();return i||n}function ek(i){var n=rr(i);n!==null&&n.tag===5&&n.type==="form"?xv(n):Xr.r(i)}var _l=typeof document>"u"?null:document;function ob(i,n,a){var l=_l;if(l&&typeof n=="string"&&n){var u=$i(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),lb.has(u)||(lb.add(u),i={rel:i,crossOrigin:a,href:n},l.querySelector(u)===null&&(n=l.createElement("link"),Gi(n,"link",i),jt(n),l.head.appendChild(n)))}}function tk(i){Xr.D(i),ob("dns-prefetch",i,null)}function ik(i,n){Xr.C(i,n),ob("preconnect",i,n)}function nk(i,n,a){Xr.L(i,n,a);var l=_l;if(l&&i&&n){var u='link[rel="preload"][as="'+$i(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+$i(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+$i(a.imageSizes)+'"]')):u+='[href="'+$i(i)+'"]';var d=u;switch(n){case"style":d=vl(i);break;case"script":d=yl(i)}Xn.has(d)||(i=y({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),Xn.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(xo(d))||n==="script"&&l.querySelector(ko(d))||(n=l.createElement("link"),Gi(n,"link",i),jt(n),l.head.appendChild(n)))}}function rk(i,n){Xr.m(i,n);var a=_l;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+$i(l)+'"][href="'+$i(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=yl(i)}if(!Xn.has(d)&&(i=y({rel:"modulepreload",href:i},n),Xn.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(ko(d)))return}l=a.createElement("link"),Gi(l,"link",i),jt(l),a.head.appendChild(l)}}}function sk(i,n,a){Xr.S(i,n,a);var l=_l;if(l&&i){var u=sr(l).hoistableStyles,d=vl(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(xo(d)))C.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":n},a),(a=Xn.get(d))&&If(i,a);var N=_=l.createElement("link");jt(N),Gi(N,"link",i),N._p=new Promise(function($,oe){N.onload=$,N.onerror=oe}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,ku(_,n,l)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function ak(i,n){Xr.X(i,n);var a=_l;if(a&&i){var l=sr(a).hoistableScripts,u=yl(i),d=l.get(u);d||(d=a.querySelector(ko(u)),d||(i=y({src:i,async:!0},n),(n=Xn.get(u))&&Uf(i,n),d=a.createElement("script"),jt(d),Gi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function lk(i,n){Xr.M(i,n);var a=_l;if(a&&i){var l=sr(a).hoistableScripts,u=yl(i),d=l.get(u);d||(d=a.querySelector(ko(u)),d||(i=y({src:i,async:!0,type:"module"},n),(n=Xn.get(u))&&Uf(i,n),d=a.createElement("script"),jt(d),Gi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function cb(i,n,a,l){var u=(u=Se.current)?xu(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"?(n=vl(a.href),a=sr(u).hoistableStyles,l=a.get(n),l||(l={type:"style",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=vl(a.href);var d=sr(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(xo(i)))&&!d._p&&(_.instance=d,_.state.loading=5),Xn.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},Xn.set(i,a),d||ok(u,i,a,_.state))),n&&l===null)throw Error(s(528,""));return _}if(n&&l!==null)throw Error(s(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=yl(a),a=sr(u).hoistableScripts,l=a.get(n),l||(l={type:"script",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function vl(i){return'href="'+$i(i)+'"'}function xo(i){return'link[rel="stylesheet"]['+i+"]"}function ub(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function ok(i,n,a,l){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=i.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Gi(n,"link",a),jt(n),i.head.appendChild(n))}function yl(i){return'[src="'+$i(i)+'"]'}function ko(i){return"script[async]"+i}function hb(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+$i(a.href)+'"]');if(l)return n.instance=l,jt(l),l;var u=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),jt(l),Gi(l,"style",u),ku(l,a.precedence,i),n.instance=l;case"stylesheet":u=vl(a.href);var d=i.querySelector(xo(u));if(d)return n.state.loading|=4,n.instance=d,jt(d),d;l=ub(a),(u=Xn.get(u))&&If(l,u),d=(i.ownerDocument||i).createElement("link"),jt(d);var _=d;return _._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Gi(d,"link",l),n.state.loading|=4,ku(d,a.precedence,i),n.instance=d;case"script":return d=yl(a.src),(u=i.querySelector(ko(d)))?(n.instance=u,jt(u),u):(l=a,(u=Xn.get(d))&&(l=y({},a),Uf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),jt(u),Gi(u,"link",l),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,ku(l,a.precedence,i));return n.instance}function ku(i,n,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,d=u,_=0;_<l.length;_++){var C=l[_];if(C.dataset.precedence===n)d=C;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(i,n.firstChild))}function If(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function Uf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var Eu=null;function db(i,n,a){if(Eu===null){var l=new Map,u=Eu=new Map;u.set(a,l)}else u=Eu,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[ir]||d[Wt]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=l.get(_);C?C.push(d):l.set(_,[d])}}return l}function fb(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function ck(i,n,a){if(a===1||n.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(i=n.disabled,typeof n.precedence=="string"&&i==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function pb(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function uk(i,n,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=vl(l.href),d=n.querySelector(xo(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=Tu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,jt(d);return}d=n.ownerDocument||n,l=ub(l),(u=Xn.get(u))&&If(l,u),d=d.createElement("link"),jt(d);var _=d;_._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Gi(d,"link",l),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Tu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var Kf=0;function hk(i,n){return i.stylesheets&&i.count===0&&Ru(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&Ru(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&Kf===0&&(Kf=62500*qx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ru(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>Kf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function Tu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ru(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Du=null;function Ru(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Du=new Map,n.forEach(dk,i),Du=null,Tu.call(i))}function dk(i,n){if(!(n.state.loading&4)){var a=Du.get(i);if(a)var l=a.get(null);else{a=new Map,Du.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||l,d===l&&a.set(null,u),a.set(_,u),this.count++,l=Tu.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var Eo={$$typeof:V,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function fk(i,n,a,l,u,d,_,C,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=Lt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lt(0),this.hiddenUpdates=Lt(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function mb(i,n,a,l,u,d,_,C,N,$,oe,he){return i=new fk(i,n,a,_,N,$,oe,he,C),n=1,d===!0&&(n|=24),d=Dn(3,null,null,n),i.current=d,d.stateNode=i,n=bd(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},xd(d),i}function gb(i){return i?(i=Ga,i):Ga}function _b(i,n,a,l,u,d){u=gb(u),l.context===null?l.context=u:l.pendingContext=u,l=gs(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=_s(i,l,n),a!==null&&(vn(a,i,n),no(a,i,n))}function vb(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function Wf(i,n){vb(i,n),(i=i.alternate)&&vb(i,n)}function yb(i){if(i.tag===13||i.tag===31){var n=ra(i,67108864);n!==null&&vn(n,i,67108864),Wf(i,67108864)}}function bb(i){if(i.tag===13||i.tag===31){var n=Ln();n=Ji(n);var a=ra(i,n);a!==null&&vn(a,i,n),Wf(i,n)}}var Mu=!0;function pk(i,n,a,l){var u=R.T;R.T=null;var d=Y.p;try{Y.p=2,Ff(i,n,a,l)}finally{Y.p=d,R.T=u}}function mk(i,n,a,l){var u=R.T;R.T=null;var d=Y.p;try{Y.p=8,Ff(i,n,a,l)}finally{Y.p=d,R.T=u}}function Ff(i,n,a,l){if(Mu){var u=qf(l);if(u===null)Mf(i,n,l,Nu,a),wb(i,l);else if(_k(u,i,n,a,l))l.stopPropagation();else if(wb(i,l),n&4&&-1<gk.indexOf(i)){for(;u!==null;){var d=rr(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=Dt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var N=1<<31-At(_);C.entanglements[1]|=N,_&=~N}xr(d),(_t&6)===0&&(fu=$e()+500,bo(0))}}break;case 31:case 13:C=ra(d,2),C!==null&&vn(C,d,2),mu(),Wf(d,2)}if(d=qf(l),d===null&&Mf(i,n,l,Nu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else Mf(i,n,l,null,a)}}function qf(i){return i=Js(i),$f(i)}var Nu=null;function $f(i){if(Nu=null,i=nr(i),i!==null){var n=c(i);if(n===null)i=null;else{var a=n.tag;if(a===13){if(i=h(n),i!==null)return i;i=null}else if(a===31){if(i=p(n),i!==null)return i;i=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;i=null}else n!==i&&(i=null)}}return Nu=i,null}function Sb(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(St()){case Z:return 2;case Ke:return 8;case le:case ze:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var Vf=!1,Ds=null,Rs=null,Ms=null,To=new Map,Do=new Map,Ns=[],gk="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 wb(i,n){switch(i){case"focusin":case"focusout":Ds=null;break;case"dragenter":case"dragleave":Rs=null;break;case"mouseover":case"mouseout":Ms=null;break;case"pointerover":case"pointerout":To.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Do.delete(n.pointerId)}}function Ro(i,n,a,l,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:l,nativeEvent:d,targetContainers:[u]},n!==null&&(n=rr(n),n!==null&&yb(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function _k(i,n,a,l,u){switch(n){case"focusin":return Ds=Ro(Ds,i,n,a,l,u),!0;case"dragenter":return Rs=Ro(Rs,i,n,a,l,u),!0;case"mouseover":return Ms=Ro(Ms,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return To.set(d,Ro(To.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,Do.set(d,Ro(Do.get(d)||null,i,n,a,l,u)),!0}return!1}function Cb(i){var n=nr(i.target);if(n!==null){var a=c(n);if(a!==null){if(n=a.tag,n===13){if(n=h(a),n!==null){i.blockedOn=n,Cn(i.priority,function(){bb(a)});return}}else if(n===31){if(n=p(a),n!==null){i.blockedOn=n,Cn(i.priority,function(){bb(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Au(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=qf(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);os=l,a.target.dispatchEvent(l),os=null}else return n=rr(a),n!==null&&yb(n),i.blockedOn=a,!1;n.shift()}return!0}function xb(i,n,a){Au(i)&&a.delete(n)}function vk(){Vf=!1,Ds!==null&&Au(Ds)&&(Ds=null),Rs!==null&&Au(Rs)&&(Rs=null),Ms!==null&&Au(Ms)&&(Ms=null),To.forEach(xb),Do.forEach(xb)}function Lu(i,n){i.blockedOn===n&&(i.blockedOn=null,Vf||(Vf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,vk)))}var Bu=null;function kb(i){Bu!==i&&(Bu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bu===i&&(Bu=null);for(var n=0;n<i.length;n+=3){var a=i[n],l=i[n+1],u=i[n+2];if(typeof l!="function"){if($f(l||a)===null)continue;break}var d=rr(a);d!==null&&(i.splice(n,3),n-=3,Fd(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function bl(i){function n(N){return Lu(N,i)}Ds!==null&&Lu(Ds,i),Rs!==null&&Lu(Rs,i),Ms!==null&&Lu(Ms,i),To.forEach(n),Do.forEach(n);for(var a=0;a<Ns.length;a++){var l=Ns[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Ns.length&&(a=Ns[0],a.blockedOn===null);)Cb(a),a.blockedOn===null&&Ns.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],d=a[l+1],_=u[Ai]||null;if(typeof d=="function")_||kb(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[Ai]||null)C=_.formAction;else if($f(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),kb(a)}}}function Eb(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Yf(i){this._internalRoot=i}Ou.prototype.render=Yf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(s(409));var a=n.current,l=Ln();_b(a,l,i,n,null,null)},Ou.prototype.unmount=Yf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;_b(i.current,2,null,i,null,null),mu(),n[ai]=null}};function Ou(i){this._internalRoot=i}Ou.prototype.unstable_scheduleHydration=function(i){if(i){var n=Ni();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Ns.length&&n!==0&&n<Ns[a].priority;a++);Ns.splice(a,0,i),a===0&&Cb(i)}};var Tb=t.version;if(Tb!=="19.2.6")throw Error(s(527,Tb,"19.2.6"));Y.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(n),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var yk={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{Tt=zu.inject(yk),Ot=zu}catch{}}return No.createRoot=function(i,n){if(!o(i))throw Error(s(299));var a=!1,l="",u=Bv,d=Ov,_=zv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=mb(i,1,!1,null,null,a,l,null,u,d,_,Eb),i[ai]=n.current,Rf(i),new Yf(n)},No.hydrateRoot=function(i,n,a){if(!o(i))throw Error(s(299));var l=!1,u="",d=Bv,_=Ov,C=zv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(C=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),n=mb(i,1,!0,n,a??null,l,u,N,d,_,C,Eb),n.context=gb(null),a=n.current,l=Ln(),l=Ji(l),u=gs(l),u.callback=null,_s(a,u,l),a=l,n.current.lanes=a,Fi(n,a),xr(n),i[ai]=n.current,Rf(i),new Ou(n)},No.version="19.2.6",No}var jb;function Rk(){if(jb)return Zf.exports;jb=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(),Zf.exports=Dk(),Zf.exports}var Mk=Rk();class fr extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}status}function Bh(e=fetch){return{getSession:(t={})=>Oe(e,`/api/auth/session${ec(t)}`),setupPassword:t=>Oe(e,"/api/auth/password",ct("POST",t)),login:t=>Oe(e,"/api/auth/login",ct("POST",t)),reauth:t=>Oe(e,"/api/auth/reauth",ct("POST",t)),logout:()=>Oe(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Oe(e,"/api/client-diagnostics",ct("POST",t)),setupTotp:()=>Oe(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Oe(e,"/api/auth/totp/activate",ct("POST",t)),disableTotp:()=>Oe(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Oe(e,"/api/auth/devices"),revokeDevice:async t=>{await Cl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Oe(e,"/api/auth/networks"),addNetwork:t=>Oe(e,"/api/auth/networks",ct("POST",t)),removeNetwork:async t=>{await Cl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Oe(e,"/api/agents"),addAgent:t=>Oe(e,"/api/agents",ct("POST",t)),reorderAgents:t=>Oe(e,"/api/agents/order",ct("PUT",{serverIds:t})),renameAgent:(t,r)=>Oe(e,`/api/agents/${encodeURIComponent(t)}`,ct("PATCH",{name:r})),getMainInfo:()=>Oe(e,"/api/main"),renameMain:t=>Oe(e,"/api/main",ct("PATCH",{name:t})),removeAgent:async t=>{await Cl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Oe(e,"/api/stats"),getAgentStats:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Oe(e,"/api/version"),checkUpdate:()=>Oe(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Oe(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Oe(e,"/api/terminals"),getTerminalLayout:()=>Oe(e,"/api/terminal-layout"),saveTerminalLayout:t=>Oe(e,"/api/terminal-layout",ct("PUT",t)),createFileRoot:t=>Oe(e,"/api/files/root",ct("POST",t)),listFiles:t=>Oe(e,"/api/files/list",ct("POST",t)),readFile:t=>Oe(e,"/api/files/read",ct("POST",t)),writeFile:t=>Oe(e,"/api/files/write",ct("POST",t)),createFileEntry:t=>Oe(e,"/api/files/create",ct("POST",t)),moveFileEntry:t=>Oe(e,"/api/files/move",ct("POST",t)),previewDeleteFileEntry:t=>Oe(e,"/api/files/delete-preview",ct("POST",t)),deleteFileEntry:t=>Oe(e,"/api/files/delete",ct("POST",t)),openFileInTerminal:t=>Oe(e,"/api/files/open",ct("POST",t)),previewFile:t=>U0(e,"/api/files/preview",ct("POST",t)),createTerminal:(t={})=>Oe(e,"/api/terminals",ct("POST",t)),closeTerminal:async t=>{await Cl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,r)=>Oe(e,`/api/terminals/${encodeURIComponent(t)}`,ct("PATCH",{title:r})),getTerminalHistory:(t,r={})=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/history${ec(r)}`),getTerminalTranscriptHistory:(t,r={})=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${ec(r)}`),getTerminalTranscriptSource:t=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Oe(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const r=new FormData;return r.append("asset",t),Oe(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:r})},updateNotificationAssetSelection:t=>Oe(e,"/api/notification-assets/selection",ct("PUT",t)),deleteNotificationAsset:async t=>{await Cl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function lc(e,t=fetch){const r=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Oe(t,r("terminals")),createTerminal:(s={})=>Oe(t,r("terminals"),ct("POST",s)),closeTerminal:async s=>{await Cl(t,r(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>Oe(t,r(`terminals/${encodeURIComponent(s)}`),ct("PATCH",{title:o})),getTerminalHistory:(s,o={})=>Oe(t,`${r(`terminals/${encodeURIComponent(s)}/history`)}${ec(o)}`),getTerminalTranscriptHistory:(s,o={})=>Oe(t,`${r(`terminals/${encodeURIComponent(s)}/transcript-history`)}${ec(o)}`),getTerminalTranscriptSource:s=>Oe(t,r(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Oe(t,r("terminal-layout")),saveTerminalLayout:s=>Oe(t,r("terminal-layout"),ct("PUT",s)),createFileRoot:s=>Oe(t,r("files/root"),ct("POST",s)),listFiles:s=>Oe(t,r("files/list"),ct("POST",s)),readFile:s=>Oe(t,r("files/read"),ct("POST",s)),writeFile:s=>Oe(t,r("files/write"),ct("POST",s)),createFileEntry:s=>Oe(t,r("files/create"),ct("POST",s)),moveFileEntry:s=>Oe(t,r("files/move"),ct("POST",s)),previewDeleteFileEntry:s=>Oe(t,r("files/delete-preview"),ct("POST",s)),deleteFileEntry:s=>Oe(t,r("files/delete"),ct("POST",s)),openFileInTerminal:s=>Oe(t,r("files/open"),ct("POST",s)),previewFile:s=>U0(t,r("files/preview"),ct("POST",s)),createWebSocketUrl:(s,o=window.location.href)=>Nk(r(`terminals/${encodeURIComponent(s)}/ws`),o)}}function Nk(e,t){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=e,r.search="",r.hash="",r.toString()}function ct(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function ec(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);const r=t.toString();return r?`?${r}`:""}async function Oe(e,t,r){const s=await e(t,r??{credentials:"same-origin"});await lg(s);try{return await s.json()}catch{throw new fr(s.status,"invalid_json_response")}}async function Cl(e,t,r){const s=await e(t,r);await lg(s)}async function U0(e,t,r){const s=await e(t,r);return await lg(s),s.blob()}async function lg(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const r=await e.json(),s=typeof r.error=="string"?r.error:r.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new fr(e.status,t)}const og="nterminal.theme.id",K0="nterminal.theme.accent",Lp="nterminal:theme",hh=[{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",...Hb({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",...Hb({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Ml="midnight";function Oh(e){return hh.some(t=>t.id===e)?e:Ml}function cg(e){return hh.find(t=>t.id===e)??hh[0]}function Fs(){if(typeof window>"u")return Ml;try{const e=window.localStorage.getItem(og);return e?Oh(e):zk(window.localStorage.getItem(K0))}catch{return Ml}}function Ak(e){const t=Oh(e);if(typeof window<"u"){try{window.localStorage.setItem(og,t)}catch{}ug(t),window.dispatchEvent(new CustomEvent(Lp,{detail:t}))}return t}function ug(e=Fs()){if(typeof document>"u")return;const t=cg(Oh(e)),r=document.documentElement;r.dataset.ntTheme=t.id,r.style.setProperty("color-scheme",t.mode),it(r,"--nt-bg",t.tokens.bg),it(r,"--nt-bg-2",t.tokens.bg2),it(r,"--nt-bg-sidebar",t.tokens.bgSidebar),it(r,"--nt-line",t.tokens.line),it(r,"--nt-line-2",t.tokens.line2),it(r,"--nt-fg",t.tokens.fg),it(r,"--nt-fg-2",t.tokens.fg2),it(r,"--nt-fg-3",t.tokens.fg3),it(r,"--nt-fg-4",t.tokens.fg4),it(r,"--nt-accent",t.tokens.accent),it(r,"--nt-accent-soft",t.tokens.accentSoft),it(r,"--nt-accent-glow",t.tokens.accentGlow),it(r,"--nt-on-accent",t.tokens.onAccent),it(r,"--nt-ok",t.tokens.ok),it(r,"--nt-danger",t.tokens.danger),it(r,"--nt-on-danger",t.tokens.onDanger),it(r,"--nt-danger-soft",t.tokens.dangerSoft),it(r,"--nt-danger-line",t.tokens.dangerLine),it(r,"--nt-warning",t.tokens.warning),it(r,"--nt-warn",t.tokens.warning),it(r,"--nt-warning-soft",t.tokens.warningSoft),it(r,"--nt-warning-glow",t.tokens.warningGlow),it(r,"--nt-scrim",t.tokens.scrim),it(r,"--nt-scrim-soft",t.tokens.scrimSoft),it(r,"--nt-shadow",t.tokens.shadow),it(r,"--nt-shadow-strong",t.tokens.shadowStrong),it(r,"--nt-floating-bg",t.tokens.floatingBg),it(r,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),it(r,"--nt-floating-bg-hover",t.tokens.floatingBgHover),it(r,"--nt-subtle-fill",t.tokens.subtleFill),it(r,"--nt-hover-fill",t.tokens.hoverFill),it(r,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),it(r,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),it(r,"--nt-transcript-user",t.tokens.transcriptUser),it(r,"--nt-transcript-assistant",t.tokens.transcriptAssistant),it(r,"--nt-transcript-tool",t.tokens.transcriptTool),it(r,"--nt-transcript-command",t.tokens.transcriptCommand),it(r,"--nt-transcript-code",t.tokens.transcriptCode),it(r,"--nt-transcript-search",t.tokens.transcriptSearch),it(r,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),it(r,"--nt-qr-bg",t.tokens.qrBg)}function Lk(e=Fs()){return cg(Oh(e)).xterm}function hg(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===og||r.key===K0)&&(ug(Fs()),e())};return window.addEventListener(Lp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Lp,e),window.removeEventListener("storage",t)}}function it(e,t,r){e.style.setProperty(t,r)}function Hb(e){const t=Bk(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 Bk(e){const t=[];for(let r=16;r<=e;r+=1)t.push(Ok(r));return t}function Ok(e){if(e>=16&&e<=231){const t=e-16,r=[0,95,135,175,215,255],s=r[Math.floor(t/36)%6],o=r[Math.floor(t/6)%6],c=r[t%6];return Pb(s,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return Pb(t,t,t)}return"#000000"}function Pb(e,t,r){return`#${tp(e)}${tp(t)}${tp(r)}`}function tp(e){return e.toString(16).padStart(2,"0")}function zk(e){return e==="signal-red"?"signal-red":Ml}function W0(){const e=v.useSyncExternalStore(hg,Fs,()=>Ml);return cg(e).mode==="light"?"-light":""}function F0({size:e=22}){const t=W0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function q0({height:e=18}){const t=W0(),r=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:r,height:e,alt:"NTerminal"})}var Wo=I0();const zh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function dg(e){return"nodeType"in e}function Sn(e){var t,r;return e?zl(e)?e:dg(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function fg(e){const{Document:t}=Sn(e);return e instanceof t}function Sc(e){return zl(e)?!1:e instanceof Sn(e).HTMLElement}function $0(e){return e instanceof Sn(e).SVGElement}function jl(e){return e?zl(e)?e.document:dg(e)?fg(e)?e:Sc(e)||$0(e)?e.ownerDocument:document:document:document}const qs=zh?v.useLayoutEffect:v.useEffect;function pg(e){const t=v.useRef(e);return qs(()=>{t.current=e}),v.useCallback(function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}function jk(){const e=v.useRef(null),t=v.useCallback((s,o)=>{e.current=setInterval(s,o)},[]),r=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function oc(e,t){t===void 0&&(t=[e]);const r=v.useRef(e);return qs(()=>{r.current!==e&&(r.current=e)},t),r}function wc(e,t){const r=v.useRef();return v.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function dh(e){const t=pg(e),r=v.useRef(null),s=v.useCallback(o=>{o!==r.current&&t?.(o,r.current),r.current=o},[]);return[r,s]}function Bp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let ip={};function jh(e,t){return v.useMemo(()=>{if(t)return t;const r=ip[e]==null?0:ip[e]+1;return ip[e]=r,e+"-"+r},[e,t])}function V0(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const b=c[g];b!=null&&(c[g]=b+e*f)}return c},{...t})}}const Dl=V0(1),fh=V0(-1);function Hk(e){return"clientX"in e&&"clientY"in e}function Y0(e){if(!e)return!1;const{KeyboardEvent:t}=Sn(e.target);return t&&e instanceof t}function Pk(e){if(!e)return!1;const{TouchEvent:t}=Sn(e.target);return t&&e instanceof t}function Op(e){if(Pk(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Hk(e)?{x:e.clientX,y:e.clientY}:null}const zp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[zp.Translate.toString(e),zp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),Ib="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Ik(e){return e.matches(Ib)?e:e.querySelector(Ib)}const Uk={display:"none"};function Kk(e){let{id:t,value:r}=e;return Ti.createElement("div",{id:t,style:Uk},r)}function Wk(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const o={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 Ti.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},r)}function Fk(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const X0=v.createContext(null);function qk(e){const t=v.useContext(X0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function $k(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:o,event:c}=s;e.forEach(h=>{var p;return(p=h[o])==null?void 0:p.call(h,c)})},[e]),t]}const Vk={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
- `},Yk={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Xk(e){let{announcements:t=Yk,container:r,hiddenTextDescribedById:s,screenReaderInstructions:o=Vk}=e;const{announce:c,announcement:h}=Fk(),p=jh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),qk(v.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:w}=y;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(y){let{active:S,over:w}=y;c(t.onDragOver({active:S,over:w}))},onDragEnd(y){let{active:S,over:w}=y;c(t.onDragEnd({active:S,over:w}))},onDragCancel(y){let{active:S,over:w}=y;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const b=Ti.createElement(Ti.Fragment,null,Ti.createElement(Kk,{id:s,value:o.draggable}),Ti.createElement(Wk,{id:p,announcement:h}));return r?Wo.createPortal(b,r):b}var Ei;(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"})(Ei||(Ei={}));function ph(){}function Ub(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Gk(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const pr=Object.freeze({x:0,y:0});function Zk(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function Qk(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Jk(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=o-s,p=c-r;if(s<o&&r<c){const g=t.width*t.height,f=e.width*e.height,b=h*p,y=b/(g+f-b);return Number(y.toFixed(4))}return 0}const eE=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const o=[];for(const c of s){const{id:h}=c,p=r.get(h);if(p){const g=Jk(p,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(Zk)};function tE(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function G0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:pr}function iE(e){return function(r){for(var s=arguments.length,o=new Array(s>1?s-1:0),c=1;c<s;c++)o[c-1]=arguments[c];return o.reduce((h,p)=>({...h,top:h.top+e*p.y,bottom:h.bottom+e*p.y,left:h.left+e*p.x,right:h.right+e*p.x}),{...r})}}const nE=iE(1);function rE(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 sE(e,t,r){const s=rE(t);if(!s)return e;const{scaleX:o,scaleY:c,x:h,y:p}=s,g=e.left-h-(1-o)*parseFloat(r),f=e.top-p-(1-c)*parseFloat(r.slice(r.indexOf(" ")+1)),b=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:g+b,bottom:f+y,left:g}}const aE={ignoreTransform:!1};function Cc(e,t){t===void 0&&(t=aE);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=Sn(e).getComputedStyle(e);f&&(r=sE(r,f,b))}const{top:s,left:o,width:c,height:h,bottom:p,right:g}=r;return{top:s,left:o,width:c,height:h,bottom:p,right:g}}function Kb(e){return Cc(e,{ignoreTransform:!0})}function lE(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function oE(e,t){return t===void 0&&(t=Sn(e).getComputedStyle(e)),t.position==="fixed"}function cE(e,t){t===void 0&&(t=Sn(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?r.test(c):!1})}function mg(e,t){const r=[];function s(o){if(t!=null&&r.length>=t||!o)return r;if(fg(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!Sc(o)||$0(o)||r.includes(o))return r;const c=Sn(e).getComputedStyle(o);return o!==e&&cE(o,c)&&r.push(o),oE(o,c)?r:s(o.parentNode)}return e?s(e):r}function Z0(e){const[t]=mg(e,1);return t??null}function np(e){return!zh||!e?null:zl(e)?e:dg(e)?fg(e)||e===jl(e).scrollingElement?window:Sc(e)?e:null:null}function Q0(e){return zl(e)?e.scrollX:e.scrollLeft}function J0(e){return zl(e)?e.scrollY:e.scrollTop}function jp(e){return{x:Q0(e),y:J0(e)}}var ji;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ji||(ji={}));function ew(e){return!zh||!e?!1:e===document.scrollingElement}function tw(e){const t={x:0,y:0},r=ew(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=s.y,p=e.scrollLeft>=s.x;return{isTop:o,isLeft:c,isBottom:h,isRight:p,maxScroll:s,minScroll:t}}const uE={x:.2,y:.2};function hE(e,t,r,s,o){let{top:c,left:h,right:p,bottom:g}=r;s===void 0&&(s=10),o===void 0&&(o=uE);const{isTop:f,isBottom:b,isLeft:y,isRight:S}=tw(e),w={x:0,y:0},x={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+D.height?(w.y=ji.Backward,x.y=s*Math.abs((t.top+D.height-c)/D.height)):!b&&g>=t.bottom-D.height&&(w.y=ji.Forward,x.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!S&&p>=t.right-D.width?(w.x=ji.Forward,x.x=s*Math.abs((t.right-D.width-p)/D.width)):!y&&h<=t.left+D.width&&(w.x=ji.Backward,x.x=s*Math.abs((t.left+D.width-h)/D.width)),{direction:w,speed:x}}function dE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:r,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function iw(e){return e.reduce((t,r)=>Dl(t,jp(r)),pr)}function fE(e){return e.reduce((t,r)=>t+Q0(r),0)}function pE(e){return e.reduce((t,r)=>t+J0(r),0)}function mE(e,t){if(t===void 0&&(t=Cc),!e)return;const{top:r,left:s,bottom:o,right:c}=t(e);Z0(e)&&(o<=0||c<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const gE=[["x",["left","right"],fE],["y",["top","bottom"],pE]];class gg{constructor(t,r){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=mg(r),o=iw(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of gE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(s),b=o[c]-f;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class tc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var o;(o=this.target)==null||o.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function _E(e){const{EventTarget:t}=Sn(e);return e instanceof t?e:jl(e)}function rp(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var Qn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Qn||(Qn={}));function Wb(e){e.preventDefault()}function vE(e){e.stopPropagation()}var Nt;(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"})(Nt||(Nt={}));const nw={start:[Nt.Space,Nt.Enter],cancel:[Nt.Esc],end:[Nt.Space,Nt.Enter,Nt.Tab]},yE=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Nt.Right:return{...r,x:r.x+25};case Nt.Left:return{...r,x:r.x-25};case Nt.Down:return{...r,y:r.y+25};case Nt.Up:return{...r,y:r.y-25}}};class rw{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:r}}=t;this.props=t,this.listeners=new tc(jl(r)),this.windowListeners=new tc(Sn(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Qn.Resize,this.handleCancel),this.windowListeners.add(Qn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Qn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&mE(s),r(pr)}handleKeyDown(t){if(Y0(t)){const{active:r,context:s,options:o}=this.props,{keyboardCodes:c=nw,coordinateGetter:h=yE,scrollBehavior:p="smooth"}=o,{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,b=f?{x:f.left,y:f.top}:pr;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:r,context:s.current,currentCoordinates:b});if(y){const S=fh(y,b),w={x:0,y:0},{scrollableAncestors:x}=s.current;for(const D of x){const L=t.code,{isTop:A,isRight:B,isLeft:V,isBottom:H,maxScroll:F,minScroll:re}=tw(D),ne=dE(D),de={x:Math.min(L===Nt.Right?ne.right-ne.width/2:ne.right,Math.max(L===Nt.Right?ne.left:ne.left+ne.width/2,y.x)),y:Math.min(L===Nt.Down?ne.bottom-ne.height/2:ne.bottom,Math.max(L===Nt.Down?ne.top:ne.top+ne.height/2,y.y))},ve=L===Nt.Right&&!B||L===Nt.Left&&!V,U=L===Nt.Down&&!H||L===Nt.Up&&!A;if(ve&&de.x!==y.x){const K=D.scrollLeft+S.x,W=L===Nt.Right&&K<=F.x||L===Nt.Left&&K>=re.x;if(W&&!S.y){D.scrollTo({left:K,behavior:p});return}W?w.x=D.scrollLeft-K:w.x=L===Nt.Right?D.scrollLeft-F.x:D.scrollLeft-re.x,w.x&&D.scrollBy({left:-w.x,behavior:p});break}else if(U&&de.y!==y.y){const K=D.scrollTop+S.y,W=L===Nt.Down&&K<=F.y||L===Nt.Up&&K>=re.y;if(W&&!S.x){D.scrollTo({top:K,behavior:p});return}W?w.y=D.scrollTop-K:w.y=L===Nt.Down?D.scrollTop-F.y:D.scrollTop-re.y,w.y&&D.scrollBy({top:-w.y,behavior:p});break}}this.handleMove(t,Dl(fh(y,this.referenceCoordinates),w))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}rw.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=nw,onActivation:o}=t,{active:c}=r;const{code:h}=e.nativeEvent;if(s.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Fb(e){return!!(e&&"distance"in e)}function qb(e){return!!(e&&"delay"in e)}class _g{constructor(t,r,s){var o;s===void 0&&(s=_E(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=r;const{event:c}=t,{target:h}=c;this.props=t,this.events=r,this.document=jl(h),this.documentListeners=new tc(this.document),this.listeners=new tc(s),this.windowListeners=new tc(Sn(h)),this.initialCoordinates=(o=Op(c))!=null?o:pr,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:r,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(Qn.Resize,this.handleCancel),this.windowListeners.add(Qn.DragStart,Wb),this.windowListeners.add(Qn.VisibilityChange,this.handleCancel),this.windowListeners.add(Qn.ContextMenu,Wb),this.documentListeners.add(Qn.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qb(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Fb(r)){this.handlePending(r);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,r){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Qn.Click,vE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Qn.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:o,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!o)return;const g=(r=Op(t))!=null?r:pr,f=fh(o,g);if(!s&&p){if(Fb(p)){if(p.tolerance!=null&&rp(f,p.tolerance))return this.handleCancel();if(rp(f,p.distance))return this.handleStart()}if(qb(p)&&rp(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Nt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const bE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class sw extends _g{constructor(t){const{event:r}=t,s=jl(r.target);super(t,bE,s)}}sw.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s?.({event:r}),!0)}}];const SE={move:{name:"mousemove"},end:{name:"mouseup"}};var Hp;(function(e){e[e.RightClick=2]="RightClick"})(Hp||(Hp={}));class aw extends _g{constructor(t){super(t,SE,jl(t.event.target))}}aw.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===Hp.RightClick?!1:(s?.({event:r}),!0)}}];const sp={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class lw extends _g{constructor(t){super(t,sp)}static setup(){return window.addEventListener(sp.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(sp.move.name,t)};function t(){}}}lw.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:o}=r;return o.length>1?!1:(s?.({event:r}),!0)}}];var ic;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ic||(ic={}));var mh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(mh||(mh={}));function wE(e){let{acceleration:t,activator:r=ic.Pointer,canScroll:s,draggingRect:o,enabled:c,interval:h=5,order:p=mh.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:S}=e;const w=xE({delta:y,disabled:!c}),[x,D]=jk(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),B=v.useMemo(()=>{switch(r){case ic.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case ic.DraggableRect:return o}},[r,o,g]),V=v.useRef(null),H=v.useCallback(()=>{const re=V.current;if(!re)return;const ne=L.current.x*A.current.x,de=L.current.y*A.current.y;re.scrollBy(ne,de)},[]),F=v.useMemo(()=>p===mh.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!B){D();return}for(const re of F){if(s?.(re)===!1)continue;const ne=f.indexOf(re),de=b[ne];if(!de)continue;const{direction:ve,speed:U}=hE(re,de,B,t,S);for(const K of["x","y"])w[K][ve[K]]||(U[K]=0,ve[K]=0);if(U.x>0||U.y>0){D(),V.current=re,x(H,h),L.current=U,A.current=ve;return}}L.current={x:0,y:0},A.current={x:0,y:0},D()},[t,H,s,D,c,h,JSON.stringify(B),JSON.stringify(w),x,f,F,b,JSON.stringify(S)])}const CE={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function xE(e){let{delta:t,disabled:r}=e;const s=Bp(t);return wc(o=>{if(r||!s||!o)return CE;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[ji.Backward]:o.x[ji.Backward]||c.x===-1,[ji.Forward]:o.x[ji.Forward]||c.x===1},y:{[ji.Backward]:o.y[ji.Backward]||c.y===-1,[ji.Forward]:o.y[ji.Forward]||c.y===1}}},[r,t,s])}function kE(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return wc(o=>{var c;return t==null?null:(c=s??o)!=null?c:null},[s,t])}function EE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{const{sensor:o}=s,c=o.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,s)}));return[...r,...c]},[]),[e,t])}var cc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(cc||(cc={}));var Pp;(function(e){e.Optimized="optimized"})(Pp||(Pp={}));const $b=new Map;function TE(e,t){let{dragging:r,dependencies:s,config:o}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=o,b=v.useRef(e),y=L(),S=oc(y),w=v.useCallback(function(A){A===void 0&&(A=[]),!S.current&&h(B=>B===null?A:B.concat(A.filter(V=>!B.includes(V))))},[S]),x=v.useRef(null),D=wc(A=>{if(y&&!r)return $b;if(!A||A===$b||b.current!==e||c!=null){const B=new Map;for(let V of e){if(!V)continue;if(c&&c.length>0&&!c.includes(V.id)&&V.rect.current){B.set(V.id,V.rect.current);continue}const H=V.node.current,F=H?new gg(g(H),H):null;V.rect.current=F,F&&B.set(V.id,F)}return B}return A},[e,c,r,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||w()},[r,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof p!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},p))},[p,y,w,...s]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function L(){switch(f){case cc.Always:return!1;case cc.BeforeDragging:return r;default:return!r}}}function ow(e,t){return wc(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function DE(e,t){return ow(e,t)}function RE(e){let{callback:t,disabled:r}=e;const s=pg(t),o=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,r]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Hh(e){let{callback:t,disabled:r}=e;const s=pg(t),o=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[r]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function ME(e){return new gg(Cc(e),e)}function Vb(e,t,r){t===void 0&&(t=ME);const[s,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??r)!=null?f:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=RE({callback(g){if(e)for(const f of g){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Hh({callback:c});return qs(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),s}function NE(e){const t=ow(e);return G0(e,t)}const Yb=[];function AE(e){const t=v.useRef(e),r=wc(s=>e?s&&s!==Yb&&e&&t.current&&e.parentNode===t.current.parentNode?s:mg(e):Yb,[e]);return v.useEffect(()=>{t.current=e},[e]),r}function LE(e){const[t,r]=v.useState(null),s=v.useRef(e),o=v.useCallback(c=>{const h=np(c.target);h&&r(p=>p?(p.set(h,jp(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){h(c);const p=e.map(g=>{const f=np(g);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,jp(f)]):null}).filter(g=>g!=null);r(p.length?new Map(p):null),s.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=np(g);f?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>Dl(c,h),pr):iw(e):pr,[e,t])}function Xb(e,t){t===void 0&&(t=[]);const r=v.useRef(null);return v.useEffect(()=>{r.current=null},t),v.useEffect(()=>{const s=e!==pr;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?fh(e,r.current):pr}function BE(e){v.useEffect(()=>{if(!zh)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function OE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{let{eventName:o,handler:c}=s;return r[o]=h=>{c(h,t)},r},{}),[e,t])}function cw(e){return v.useMemo(()=>e?lE(e):null,[e])}const Gb=[];function zE(e,t){t===void 0&&(t=Cc);const[r]=e,s=cw(r?Sn(r):null),[o,c]=v.useState(Gb);function h(){c(()=>e.length?e.map(g=>ew(g)?s:new gg(t(g),g)):Gb)}const p=Hh({callback:h});return qs(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),o}function jE(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Sc(t)?t:e}function HE(e){let{measure:t}=e;const[r,s]=v.useState(null),o=v.useCallback(f=>{for(const{target:b}of f)if(Sc(b)){s(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=Hh({callback:o}),h=v.useCallback(f=>{const b=jE(f);c?.disconnect(),b&&c?.observe(b),s(b?t(b):null)},[t,c]),[p,g]=dh(h);return v.useMemo(()=>({nodeRef:p,rect:r,setRef:g}),[r,p,g])}const PE=[{sensor:sw,options:{}},{sensor:rw,options:{}}],IE={current:{}},Qu={draggable:{measure:Kb},droppable:{measure:Kb,strategy:cc.WhileDragging,frequency:Pp.Optimized},dragOverlay:{measure:Cc}};class nc extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const UE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new nc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ph},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qu,measureDroppableContainers:ph,windowRect:null,measuringScheduled:!1},KE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ph,draggableNodes:new Map,over:null,measureDroppableContainers:ph},Ph=v.createContext(KE),WE=v.createContext(UE);function FE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new nc}}}function qE(e,t){switch(t.type){case Ei.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ei.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 Ei.DragEnd:case Ei.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ei.RegisterDroppable:{const{element:r}=t,{id:s}=r,o=new nc(e.droppable.containers);return o.set(s,r),{...e,droppable:{...e.droppable,containers:o}}}case Ei.SetDroppableDisabled:{const{id:r,key:s,disabled:o}=t,c=e.droppable.containers.get(r);if(!c||s!==c.key)return e;const h=new nc(e.droppable.containers);return h.set(r,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case Ei.UnregisterDroppable:{const{id:r,key:s}=t,o=e.droppable.containers.get(r);if(!o||s!==o.key)return e;const c=new nc(e.droppable.containers);return c.delete(r),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function $E(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:o}=v.useContext(Ph),c=Bp(s),h=Bp(r?.id);return v.useEffect(()=>{if(!t&&!s&&c&&h!=null){if(!Y0(c)||document.activeElement===c.target)return;const p=o.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[g.current,f.current]){if(!b)continue;const y=Ik(b);if(y){y.focus();break}}})}},[s,t,o,h,c]),null}function VE(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...s}),r):r}function YE(e){return v.useMemo(()=>({draggable:{...Qu.draggable,...e?.draggable},droppable:{...Qu.droppable,...e?.droppable},dragOverlay:{...Qu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function XE(e){let{activeNode:t,measure:r,initialRect:s,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof o=="boolean"?{x:o,y:o}:o;qs(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=r(f),y=G0(b,s);if(h||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=Z0(f);S&&S.scrollBy({top:y.y,left:y.x})}},[t,h,p,s,r])}const uw=v.createContext({...pr,scaleX:1,scaleY:1});var Ps;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ps||(Ps={}));const GE=v.memo(function(t){var r,s,o,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:b=PE,collisionDetection:y=eE,measuring:S,modifiers:w,...x}=t;const D=v.useReducer(qE,void 0,FE),[L,A]=D,[B,V]=$k(),[H,F]=v.useState(Ps.Uninitialized),re=H===Ps.Initialized,{draggable:{active:ne,nodes:de,translate:ve},droppable:{containers:U}}=L,K=ne!=null?de.get(ne):null,W=v.useRef({initial:null,translated:null}),P=v.useMemo(()=>{var vt;return ne!=null?{id:ne,data:(vt=K?.data)!=null?vt:IE,rect:W}:null},[ne,K]),j=v.useRef(null),[ae,R]=v.useState(null),[Y,G]=v.useState(null),Ce=oc(x,Object.values(x)),Te=jh("DndDescribedBy",h),M=v.useMemo(()=>U.getEnabled(),[U]),Q=YE(S),{droppableRects:fe,measureDroppableContainers:me,measuringScheduled:ge}=TE(M,{dragging:re,dependencies:[ve.x,ve.y],config:Q.droppable}),Se=kE(de,ne),Ee=v.useMemo(()=>Y?Op(Y):null,[Y]),Ne=Mi(),Ue=DE(Se,Q.draggable.measure);XE({activeNode:ne!=null?de.get(ne):null,config:Ne.layoutShiftCompensation,initialRect:Ue,measure:Q.draggable.measure});const te=Vb(Se,Q.draggable.measure,Ue),_e=Vb(Se?Se.parentElement:null),Ae=v.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:fe,draggableNodes:de,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),we=U.getNodeFor((r=Ae.current.over)==null?void 0:r.id),Me=HE({measure:Q.dragOverlay.measure}),Ie=(s=Me.nodeRef.current)!=null?s:Se,We=re?(o=Me.rect)!=null?o:te:null,ie=!!(Me.nodeRef.current&&Me.rect),ke=NE(ie?null:te),De=cw(Ie?Sn(Ie):null),Le=AE(re?we??Se:null),je=zE(Le),at=VE(w,{transform:{x:ve.x-ke.x,y:ve.y-ke.y,scaleX:1,scaleY:1},activatorEvent:Y,active:P,activeNodeRect:te,containerNodeRect:_e,draggingNodeRect:We,over:Ae.current.over,overlayNodeRect:Me.rect,scrollableAncestors:Le,scrollableAncestorRects:je,windowRect:De}),Bt=Ee?Dl(Ee,ve):null,$e=LE(Le),St=Xb($e),Z=Xb($e,[te]),Ke=Dl(at,St),le=We?nE(We,at):null,ze=P&&le?y({active:P,collisionRect:le,droppableRects:fe,droppableContainers:M,pointerCoordinates:Bt}):null,Qe=Qk(ze,"id"),[ft,$t]=v.useState(null),Tt=ie?at:Dl(at,Z),Ot=tE(Tt,(c=ft?.rect)!=null?c:null,te),Qt=v.useRef(null),At=v.useCallback((vt,Dt)=>{let{sensor:Kt,options:Vt}=Dt;if(j.current==null)return;const Si=de.get(j.current);if(!Si)return;const ri=vt.nativeEvent,Lt=new Kt({active:j.current,activeNode:Si,event:ri,options:Vt,context:Ae,onAbort(zt){if(!de.get(zt))return;const{onDragAbort:Yt}=Ce.current,si={id:zt};Yt?.(si),B({type:"onDragAbort",event:si})},onPending(zt,wt,Yt,si){if(!de.get(zt))return;const{onDragPending:wn}=Ce.current,Ni={id:zt,constraint:wt,initialCoordinates:Yt,offset:si};wn?.(Ni),B({type:"onDragPending",event:Ni})},onStart(zt){const wt=j.current;if(wt==null)return;const Yt=de.get(wt);if(!Yt)return;const{onDragStart:si}=Ce.current,Ji={activatorEvent:ri,active:{id:wt,data:Yt.data,rect:W}};Wo.unstable_batchedUpdates(()=>{si?.(Ji),F(Ps.Initializing),A({type:Ei.DragStart,initialCoordinates:zt,active:wt}),B({type:"onDragStart",event:Ji}),R(Qt.current),G(ri)})},onMove(zt){A({type:Ei.DragMove,coordinates:zt})},onEnd:Fi(Ei.DragEnd),onCancel:Fi(Ei.DragCancel)});Qt.current=Lt;function Fi(zt){return async function(){const{active:Yt,collisions:si,over:Ji,scrollAdjustedTranslate:wn}=Ae.current;let Ni=null;if(Yt&&wn){const{cancelDrop:Cn}=Ce.current;Ni={activatorEvent:ri,active:Yt,collisions:si,delta:wn,over:Ji},zt===Ei.DragEnd&&typeof Cn=="function"&&await Promise.resolve(Cn(Ni))&&(zt=Ei.DragCancel)}j.current=null,Wo.unstable_batchedUpdates(()=>{A({type:zt}),F(Ps.Uninitialized),$t(null),R(null),G(null),Qt.current=null;const Cn=zt===Ei.DragEnd?"onDragEnd":"onDragCancel";if(Ni){const qi=Ce.current[Cn];qi?.(Ni),B({type:Cn,event:Ni})}})}}},[de]),Ri=v.useCallback((vt,Dt)=>(Kt,Vt)=>{const Si=Kt.nativeEvent,ri=de.get(Vt);if(j.current!==null||!ri||Si.dndKit||Si.defaultPrevented)return;const Lt={active:ri};vt(Kt,Dt.options,Lt)===!0&&(Si.dndKit={capturedBy:Dt.sensor},j.current=Vt,At(Kt,Dt))},[de,At]),Wi=EE(b,Ri);BE(b),qs(()=>{te&&H===Ps.Initializing&&F(Ps.Initialized)},[te,H]),v.useEffect(()=>{const{onDragMove:vt}=Ce.current,{active:Dt,activatorEvent:Kt,collisions:Vt,over:Si}=Ae.current;if(!Dt||!Kt)return;const ri={active:Dt,activatorEvent:Kt,collisions:Vt,delta:{x:Ke.x,y:Ke.y},over:Si};Wo.unstable_batchedUpdates(()=>{vt?.(ri),B({type:"onDragMove",event:ri})})},[Ke.x,Ke.y]),v.useEffect(()=>{const{active:vt,activatorEvent:Dt,collisions:Kt,droppableContainers:Vt,scrollAdjustedTranslate:Si}=Ae.current;if(!vt||j.current==null||!Dt||!Si)return;const{onDragOver:ri}=Ce.current,Lt=Vt.get(Qe),Fi=Lt&&Lt.rect.current?{id:Lt.id,rect:Lt.rect.current,data:Lt.data,disabled:Lt.disabled}:null,zt={active:vt,activatorEvent:Dt,collisions:Kt,delta:{x:Si.x,y:Si.y},over:Fi};Wo.unstable_batchedUpdates(()=>{$t(Fi),ri?.(zt),B({type:"onDragOver",event:zt})})},[Qe]),qs(()=>{Ae.current={activatorEvent:Y,active:P,activeNode:Se,collisionRect:le,collisions:ze,droppableRects:fe,draggableNodes:de,draggingNode:Ie,draggingNodeRect:We,droppableContainers:U,over:ft,scrollableAncestors:Le,scrollAdjustedTranslate:Ke},W.current={initial:We,translated:le}},[P,Se,ze,le,de,Ie,We,fe,U,ft,Le,Ke]),wE({...Ne,delta:ve,draggingRect:le,pointerCoordinates:Bt,scrollableAncestors:Le,scrollableAncestorRects:je});const gr=v.useMemo(()=>({active:P,activeNode:Se,activeNodeRect:te,activatorEvent:Y,collisions:ze,containerNodeRect:_e,dragOverlay:Me,draggableNodes:de,droppableContainers:U,droppableRects:fe,over:ft,measureDroppableContainers:me,scrollableAncestors:Le,scrollableAncestorRects:je,measuringConfiguration:Q,measuringScheduled:ge,windowRect:De}),[P,Se,te,Y,ze,_e,Me,de,U,fe,ft,me,Le,je,Q,ge,De]),Qi=v.useMemo(()=>({activatorEvent:Y,activators:Wi,active:P,activeNodeRect:te,ariaDescribedById:{draggable:Te},dispatch:A,draggableNodes:de,over:ft,measureDroppableContainers:me}),[Y,Wi,P,te,A,Te,de,ft,me]);return Ti.createElement(X0.Provider,{value:V},Ti.createElement(Ph.Provider,{value:Qi},Ti.createElement(WE.Provider,{value:gr},Ti.createElement(uw.Provider,{value:Ot},f)),Ti.createElement($E,{disabled:p?.restoreFocus===!1})),Ti.createElement(Xk,{...p,hiddenTextDescribedById:Te}));function Mi(){const vt=ae?.autoScrollEnabled===!1,Dt=typeof g=="object"?g.enabled===!1:g===!1,Kt=re&&!vt&&!Dt;return typeof g=="object"?{...g,enabled:Kt}:{enabled:Kt}}}),ZE=v.createContext(null),Zb="button",QE="Draggable";function hw(e){let{id:t,data:r,disabled:s=!1,attributes:o}=e;const c=jh(QE),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:S}=v.useContext(Ph),{role:w=Zb,roleDescription:x="draggable",tabIndex:D=0}=o??{},L=g?.id===t,A=v.useContext(L?uw:ZE),[B,V]=dh(),[H,F]=dh(),re=OE(h,t),ne=oc(r);qs(()=>(y.set(t,{id:t,key:c,node:B,activatorNode:H,data:ne}),()=>{const ve=y.get(t);ve&&ve.key===c&&y.delete(t)}),[y,t]);const de=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":s,"aria-pressed":L&&w===Zb?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[s,w,D,L,x,b.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:de,isDragging:L,listeners:s?void 0:re,node:B,over:S,setNodeRef:V,setActivatorNodeRef:F,transform:A}}const JE="Droppable",e2={timeout:25};function vg(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:o}=e;const c=jh(JE),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(Ph),b=v.useRef({disabled:r}),y=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:L}={...e2,...o},A=oc(D??s),B=v.useCallback(()=>{if(!y.current){y.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),w.current=null},L)},[L]),V=Hh({callback:B,disabled:x||!h}),H=v.useCallback((de,ve)=>{V&&(ve&&(V.unobserve(ve),y.current=!1),de&&V.observe(de))},[V]),[F,re]=dh(H),ne=oc(t);return v.useEffect(()=>{!V||!F.current||(V.disconnect(),y.current=!1,V.observe(F.current))},[F,V]),v.useEffect(()=>(p({type:Ei.RegisterDroppable,element:{id:s,key:c,disabled:r,node:F,rect:S,data:ne}}),()=>p({type:Ei.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{r!==b.current.disabled&&(p({type:Ei.SetDroppableDisabled,id:s,key:c,disabled:r}),b.current.disabled=r)},[s,c,r,p]),{active:h,rect:S,isOver:g?.id===s,node:F,over:g,setNodeRef:re}}const t2=128,i2=512,Hl=100,n2="too_many_detached_terminals",r2=64,s2=4096;function dw(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>t2)return null;const r=t.workspaces.map(a2);return r.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function fw(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(r=>{if(!r||typeof r!="object")return!1;const s=r.detachedTerminalIds;return Array.isArray(s)&&s.length>Hl}):!1}function a2(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>i2)return null;const r=t.tabs.map(l2);if(r.some(o=>o===null))return null;const s=h2(t.detachedTerminalIds,Hl);return s===null?null:{id:t.id,title:t.title,defaultCwd:u2(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:r}}function l2(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 r=o2(t.root);return r?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:r}:null}function o2(e){if(!e||typeof e!="object")return null;let t=0;return Ip(e,1,()=>(t+=1,t<=s2))}function Ip(e,t,r){if(!e||typeof e!="object"||t>r2||!r())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 o=Ip(s.first,t+1,r),c=Ip(s.second,t+1,r);return!o||!c?null:{type:"split",direction:s.direction,ratio:c2(s.ratio),first:o,second:c}}function c2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function u2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function h2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const r=new Set,s=[];for(const o of e)typeof o!="string"||!o||r.has(o)||(r.add(o),s.push(o));return s}const pw=[{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"}],xa="__main__";function d2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function f2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Qb="Local",p2=3e4,m2=2,g2=6,mw="nterminal.serverList.viewMode.v1";function _2(){try{return window.localStorage.getItem(mw)==="list"?"list":"stats"}catch{return"stats"}}function v2(e){try{window.localStorage.setItem(mw,e)}catch{}}function ba(e,t){const r=[xa,...t.map(h=>h.id)],s=new Set(r),o=new Set,c=[];for(const h of e??[])!s.has(h)||o.has(h)||(o.add(h),c.push(h));for(const h of r)o.has(h)||c.push(h);return c}function y2(e,t){const r=new Map(e.map(s=>[s.id,s]));return ba(t,e).flatMap(s=>{if(s===xa)return[{kind:"main",id:xa}];const o=r.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function Jb(e,t){return e.length===t.length&&e.every((r,s)=>r===t[s])}function gw(e){return e===void 0?"":e==="error"?"offline":[`CPU ${er(e.cpuPercent)} ${yg(e)}`,`MEM ${er(e.memoryPercent)} ${ts(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${er(e.diskPercent)} ${ts(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${er(e.swapPercent)} ${ts(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function b2(e){if(!(e===void 0||e==="error"))return[`CPU ${er(e.cpuPercent)} (${yg(e)})`,`RAM ${er(e.memoryPercent)} (${ts(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${er(e.diskPercent)} (${ts(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${er(e.swapPercent)} (${ts(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function S2(e,t){const r=gw(t);return`${e}${r?` — ${r}`:""}. Double-click to rename.`}function er(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function yg(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`:`${Up(e.cpuPercent/100*t)}/${t} cores`}function ts(e,t){return!eS(e)||!eS(t)?"–/–":w2(e,t)}function w2(e,t){const r=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=r==="GB"?1024**3:r==="MB"?1024**2:1024;return`${Up(e/s)}/${Up(t/s)} ${r}`}function Up(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function eS(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function ju(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function C2(e){return[{label:"CPU",percent:er(e.cpuPercent),detail:yg(e),tone:ju(e.cpuPercent)},{label:"MEM",percent:er(e.memoryPercent),detail:ts(e.memoryUsedBytes,e.memoryTotalBytes),tone:ju(e.memoryPercent)},{label:"DISK",percent:er(e.diskPercent),detail:ts(e.diskUsedBytes,e.diskTotalBytes),tone:ju(e.diskPercent)},{label:"SWAP",percent:er(e.swapPercent),detail:ts(e.swapUsedBytes,e.swapTotalBytes),tone:ju(e.swapPercent)}]}function x2({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:b2(e),children:C2(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function tS({api:e,activeAgentId:t,onSelectServer:r,onSessionInvalid:s,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,b]=v.useState([xa]),[y,S]=v.useState(null),[w,x]=v.useState(null),[D,L]=v.useState(""),A=v.useRef(null),[B,V]=v.useState(()=>_2()),[H,F]=v.useState(null),[re,ne]=v.useState(null),[de,ve]=v.useState({}),U=v.useRef({}),K=v.useRef(0),W=v.useRef([]),P=v.useRef([xa]),j=v.useRef(null);v.useEffect(()=>{W.current=p},[p]),v.useEffect(()=>{const te=ba(f,p);P.current=te,Jb(te,f)||b(te)},[p,f]),v.useEffect(()=>{let te=!1;return e.listAgents().then(_e=>{te||(g(_e.agents),b(ba(_e.serverOrder,_e.agents)))}).catch(()=>{}),e.getMainInfo().then(_e=>{te||S(_e.name)}).catch(()=>{}),()=>{te=!0}},[e,o]),v.useEffect(()=>{w&&(A.current?.focus(),A.current?.select())},[w]),v.useEffect(()=>{let te=!1;function _e(){const we=[{key:"__main__",load:()=>e.getMainStats()},...p.map(Ie=>({key:Ie.id,load:()=>e.getAgentStats(Ie.id)}))],Me=new Set(we.map(Ie=>Ie.key));for(const Ie of Object.keys(U.current))Me.has(Ie)||delete U.current[Ie];ve(Ie=>{const We={};for(const ie of Me)ie in Ie&&(We[ie]=Ie[ie]);return We});for(const Ie of we)Ie.load().then(We=>{te||(U.current[Ie.key]=0,ve(ie=>Me.has(Ie.key)?{...ie,[Ie.key]:We}:ie))}).catch(We=>{if(te)return;if(We instanceof fr&&We.status===401&&Ie.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const ie=(U.current[Ie.key]??0)+1;U.current[Ie.key]=ie,ie>=m2&&ve(ke=>Me.has(Ie.key)?{...ke,[Ie.key]:"error"}:ke)})}_e();const Ae=window.setInterval(_e,p2);return()=>{te=!0,window.clearInterval(Ae)}},[e,p,s]);function ae(te){te==="main"?(L(y??""),x({kind:"main"})):(L(te.name),x({kind:"agent",id:te.id}))}async function R(){if(!w)return;const te=D.trim(),_e=w;if(x(null),_e.kind==="main"){const Ae=te||"";try{const we=await e.renameMain(Ae);S(we.name)}catch{}}else{if(!te)return;const Ae=p.find(we=>we.id===_e.id)?.name;g(we=>we.map(Me=>Me.id===_e.id?{...Me,name:te}:Me));try{await e.renameAgent(_e.id,te)}catch{Ae!==void 0&&g(we=>we.map(Me=>Me.id===_e.id?{...Me,name:Ae}:Me))}}}function Y(){x(null)}function G(te){V(te),v2(te)}function Ce(te,_e,Ae){if(te===_e)return;const we=ba(P.current,W.current),Me=we.findIndex(je=>je===te),Ie=we.findIndex(je=>je===_e);if(Me<0||Ie<0)return;const We=[...we],[ie]=We.splice(Me,1);if(!ie)return;const ke=We.findIndex(je=>je===_e);if(ke<0)return;const De=Ae==="before"?ke:ke+1;if(We.splice(De,0,ie),Jb(We,we))return;const Le=K.current+1;K.current=Le,P.current=We,b(We),e.reorderAgents(We).then(je=>{if(K.current===Le){W.current=je.agents;const at=ba(je.serverOrder,je.agents);P.current=at,g(je.agents),b(at)}}).catch(async()=>{if(K.current===Le)try{const je=await e.listAgents();if(K.current===Le){W.current=je.agents;const at=ba(je.serverOrder,je.agents);P.current=at,g(je.agents),b(at)}}catch{K.current===Le&&(P.current=we,b(we))}})}function Te(te,_e){const Ae=ba(P.current,W.current),we=Ae.findIndex(Ie=>Ie===te),Me=Ae[we+_e];we<0||!Me||Ce(te,Me,_e<0?"before":"after")}function M(te,_e){_e.pointerType==="mouse"&&_e.button!==0||(_e.stopPropagation(),j.current={sourceId:te,pointerId:_e.pointerId,startX:_e.clientX,startY:_e.clientY,active:!1,targetId:null,placement:"after"},_e.currentTarget.setPointerCapture?.(_e.pointerId))}function Q(te){const _e=j.current;if(!_e||_e.pointerId!==te.pointerId)return;const Ae=Math.hypot(te.clientX-_e.startX,te.clientY-_e.startY);if(!_e.active){if(Ae<g2)return;_e.active=!0,F(_e.sourceId)}const Me=document.elementFromPoint(te.clientX,te.clientY)?.closest("[data-server-id]"),Ie=Me?.dataset.serverId??null;if(!Me||!Ie||Ie===_e.sourceId){_e.targetId=null,ne(null);return}const We=Me.getBoundingClientRect(),ie=te.clientY<We.top+We.height/2?"before":"after";_e.targetId=Ie,_e.placement=ie,ne({serverId:Ie,placement:ie})}function fe(te){const _e=j.current;!_e||_e.pointerId!==te.pointerId||(te.stopPropagation(),te.currentTarget.releasePointerCapture?.(te.pointerId),j.current=null,F(null),ne(null),_e.active&&_e.targetId&&Ce(_e.sourceId,_e.targetId,_e.placement))}function me(te){const _e=j.current;_e&&_e.pointerId===te.pointerId&&te.currentTarget.releasePointerCapture?.(te.pointerId),j.current=null,F(null),ne(null)}const ge=y?.trim()||Qb,Se=w?.kind==="main",Ee=B==="stats",Ne=y2(p,f),Ue=Ne.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:Ne.map(te=>{const _e=te.kind==="main",Ae=_e?ge:te.agent.name,we=_e?xa:te.id,Me=de[we],Ie=gw(Me);return m.jsxs("button",{type:"button",className:`server-list-chip${(_e?t===null:t===te.id)?" server-list-chip--active":""}`,onClick:()=>r(_e?null:te.id),"aria-label":Ae,title:`${Ae}${Ie?` — ${Ie}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:f2(Ae)}),m.jsx("span",{className:"server-list-chip-pip","data-status":d2(Me)})]},te.id)})}):m.jsxs("div",{className:`server-list server-list--${B}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":B==="list",onClick:()=>G("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":B==="stats",onClick:()=>G("stats"),title:"Show resource usage",children:"Stats"})]}),Ne.map(te=>{const _e=te.kind==="main",Ae=_e?ge:te.agent.name,we=_e?xa:te.id,Me=_e?t===null:t===te.id,Ie=_e?Se:w?.kind==="agent"&&w.id===te.id,We=c?.({agentId:_e?null:te.id,serverId:te.id,label:Ae,active:Me}),ie=re?.serverId===te.id&&H!==te.id?` server-list-section--drop-target server-list-section--drop-${re.placement}`:"";return m.jsxs("section",{className:`server-list-section${ie}`,"aria-label":`${Ae} server`,children:[m.jsx("div",{className:["server-list-row",H===te.id?"server-list-row--dragging":"",re?.serverId===te.id&&H!==te.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":te.id,children:Ie?m.jsxs(m.Fragment,{children:[Ue?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:ke=>{ke.preventDefault(),R()},children:m.jsx("input",{ref:A,"aria-label":_e?"Rename main server":`Rename ${Ae}`,value:D,onChange:ke=>L(ke.target.value),onBlur:()=>{R()},onKeyDown:ke=>{ke.key==="Escape"&&(ke.preventDefault(),Y())},placeholder:_e?Qb:void 0})})]}):m.jsxs(m.Fragment,{children:[Ue?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":te.id,title:"Drag to reorder","aria-label":`Reorder ${Ae}`,"aria-grabbed":H===te.id,onPointerDown:ke=>M(te.id,ke),onPointerMove:Q,onPointerUp:fe,onPointerCancel:me,onKeyDown:ke=>{(ke.key==="ArrowUp"||ke.key==="ArrowDown")&&(ke.preventDefault(),ke.stopPropagation(),Te(te.id,ke.key==="ArrowUp"?-1:1))},onClick:ke=>ke.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Me?" server-list-item--active":""}`,onClick:()=>r(_e?null:te.id),onDoubleClick:ke=>{ke.preventDefault(),ae(_e?"main":{id:te.id,name:Ae})},title:S2(Ae,de[we]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:_e?void 0:te.agent.url,children:Ae})]}),Ee?m.jsx(x2,{entry:de[we]}):null]})]})}),We?m.jsx("div",{className:"server-list-children",children:We}):null]},te.id)})]})}function k2({api:e}){const[t,r]=v.useState([]),[s,o]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,b]=v.useState(""),[y,S]=v.useState("");async function w(){try{const[A,B,V]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);r(A.devices),o(B.networks),h(V.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(A){await e.revokeDevice(A),await w()}async function D(A){await e.removeNetwork(A),await w()}async function L(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),S(""),await w()}catch(B){g(B instanceof Error?B.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[p?m.jsx("p",{className:"form-error",children:p}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[A.label,A.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(A.id)},children:"revoke"})]},A.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:s.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?m.jsx("span",{className:"security-item-meta",children:A.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(A.id)},children:"remove"})]},A.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:L,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:A=>b(A.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:A=>S(A.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.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."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const _w="nterminal.notifications.completionEnabled",bg="nterminal.notifications.completionToastEnabled",Sg="nterminal.notifications.completionToastDurationSeconds",wg="nterminal.notifications.completionToastPersistent",Kp="nterminal:completion-toast-display",rc=6.5,Wp=2,Fp=60;function Ih(){return typeof window<"u"&&"Notification"in window}function vw(){try{return window.localStorage.getItem(_w)==="true"}catch{return!1}}function iS(e){try{window.localStorage.setItem(_w,e?"true":"false")}catch{}}function Ma(){return{enabled:R2(),durationSeconds:D2(),persistUntilDismissed:M2()}}function E2(e){if(typeof window<"u"){try{window.localStorage.setItem(bg,e?"true":"false")}catch{}xg()}return Ma()}function nS(e){const t=bw(e);if(typeof window<"u"){try{window.localStorage.setItem(Sg,String(t))}catch{}xg()}return Ma()}function T2(e){if(typeof window<"u"){try{window.localStorage.setItem(wg,e?"true":"false")}catch{}xg()}return Ma()}function yw(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===bg||r.key===Sg||r.key===wg)&&e()};return window.addEventListener(Kp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Kp,e),window.removeEventListener("storage",t)}}function Cg(){return Ih()?window.Notification.permission:"unsupported"}function D2(){if(typeof window>"u")return rc;try{const e=window.localStorage.getItem(Sg);return e===null?rc:bw(Number(e))}catch{return rc}}function R2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(bg)!=="false"}catch{return!0}}function M2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(wg)==="true"}catch{return!1}}function bw(e){if(!Number.isFinite(e))return rc;const t=Math.round(e*2)/2;return Math.max(Wp,Math.min(Fp,t))}function xg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Kp))}async function N2(){if(!Ih())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Cg()}}function A2(e){if(!Ih()||Cg()!=="granted"||!vw()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const L2=1500,kg="nterminal.terminal.fontSize",Eg="nterminal.terminal.fontFamily",qp="nterminal:terminal-font-size",$p="nterminal:terminal-font-family",Vp=11,Yp=20,Ea=14,gh=[{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:[]}],Nl="meslo";Xp(Nl);async function ap(e=Ea,t=Nl){if(typeof document>"u"||!document.fonts)return;const r=Cw(t).webFontFamilies;if(r.length===0)return;const s=Promise.all(r.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(o=>{globalThis.setTimeout(o,L2)})])}function Sw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Ea;const r=Math.round(t);return Math.max(Vp,Math.min(Yp,r))}function ww(e){return gh.some(t=>t.id===e)?e:Nl}function Xp(e){return Cw(e).cssFamily}function Cw(e){return gh.find(t=>t.id===e)??gh[0]}function Gp(){if(typeof window>"u")return Ea;try{const e=window.localStorage.getItem(kg);return e?Sw(e):Ea}catch{return Ea}}function Zp(){if(typeof window>"u")return Nl;try{return ww(window.localStorage.getItem(Eg))}catch{return Nl}}function Hu(e){const t=Sw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(kg,String(t))}catch{}return window.dispatchEvent(new CustomEvent(qp,{detail:t})),t}function B2(e){const t=ww(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Eg,t)}catch{}return window.dispatchEvent(new CustomEvent($p,{detail:t})),t}function xw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===kg&&e()};return window.addEventListener(qp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qp,e),window.removeEventListener("storage",t)}}function kw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Eg&&e()};return window.addEventListener($p,e),window.addEventListener("storage",t),()=>{window.removeEventListener($p,e),window.removeEventListener("storage",t)}}const Tg="nterminal.terminal.showScrollProgress",Qp="nterminal:terminal-scroll-progress",Dg="nterminal.terminal.tmuxScrollback.shell",Rg="nterminal.terminal.tmuxScrollback.agent",Mg="nterminal.terminal.tmuxScrollback.overrides",uc="nterminal:terminal-tmux-scrollback",O2=200;function Jp(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Tg)!=="false"}catch{return!0}}function z2(e){if(typeof window<"u"){try{window.localStorage.setItem(Tg,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Qp,{detail:e}))}return e}function Ew(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Tg&&e()};return window.addEventListener(Qp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qp,e),window.removeEventListener("storage",t)}}function em(){return Tw(Dg,!0)}function j2(e){return Dw(Dg,e,uc)}function tm(){return Tw(Rg,!0)}function H2(e){return Dw(Rg,e,uc)}function Ju(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Dg||r.key===Rg||r.key===Mg)&&e()};return window.addEventListener(uc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(uc,e),window.removeEventListener("storage",t)}}function lp(e){const r=Rw()[e];return typeof r=="boolean"?r:null}function P2(e,t){if(typeof window<"u"){try{const r=Rw(),s=Object.entries(r).filter(([c])=>c!==e);s.push([e,t]);const o=s.slice(-O2);window.localStorage.setItem(Mg,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(uc,{detail:{terminalId:e,enabled:t}}))}return t}function Tw(e,t){if(typeof window>"u")return t;try{const r=window.localStorage.getItem(e);if(r==="true")return!0;if(r==="false")return!1}catch{}return t}function Dw(e,t,r){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(r,{detail:t}))}return t}function Rw(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Mg);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const r={};for(const[s,o]of Object.entries(t))typeof o=="boolean"&&(r[s]=o);return r}catch{return{}}}const Ng="nterminal.shortcuts.workspace.v1",im="nterminal:workspace-shortcuts",hc=[{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}],Uh={"server.previous":yi("ArrowUp",{ctrlKey:!0}),"server.next":yi("ArrowDown",{ctrlKey:!0}),"tab.previous":yi("ArrowLeft",{ctrlKey:!0}),"tab.next":yi("ArrowRight",{ctrlKey:!0}),"tab.index":yi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":yi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":yi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":yi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":yi("KeyH",{altKey:!0}),"scrollback.toggle":yi("KeyS",{altKey:!0})},I2={"server.previous":yi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":yi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":yi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":yi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":yi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":yi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":yi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":yi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":yi("KeyH",{altKey:!0}),"scrollback.toggle":yi("KeyS",{altKey:!0})};function Na(){const e=Aw(Uh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Ng);if(!t)return e;const r=JSON.parse(t);for(const s of hc){const o=r[s.id];if(Y2(o)){const c=Lw(o,s);V2(c,I2[s.id])||(e[s.id]=c)}}}catch{return e}return e}function rS(){return JSON.stringify(Na())}function U2(e,t){const r=Na(),s=hc.find(o=>o.id===e);return s&&(r[e]=Lw(t,s),Ag(r)),r}function K2(e){const t=Na();return t[e]={...Uh[e]},Ag(t),t}function W2(){const e=Aw(Uh);return Ag(e),e}function _h(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Ng&&e()};return window.addEventListener(im,e),window.addEventListener("storage",t),()=>{window.removeEventListener(im,e),window.removeEventListener("storage",t)}}function F2(e,t){const r=zw(e);return!r||G2(r)||t.indexed&&Ow(e)===null||t.requiresPrimaryModifier&&!Bw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":r}}function Mw(e){const t=Na();for(const r of hc){const s=t[r.id];if(!(!s||!X2(e,s))){if(r.indexed){if(s.code!=="Digit")continue;const o=Ow(e);if(o!==null)return{id:r.id,index:o};continue}if(zw(e)===s.code)return{id:r.id,index:null}}}return null}function vh(e){return Nw(Na()[e])}function Nw(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(Z2(e.code)),t.join("+")}const q2=()=>vh("split.right"),$2=()=>vh("split.down");function yi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Aw(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r}]))}function V2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Ag(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Ng,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(im))}}function Lw(e,t){return t.requiresPrimaryModifier&&!Bw(e)?{...Uh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Bw(e){return e.ctrlKey||e.altKey||e.metaKey}function Y2(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 X2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Ow(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 zw(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 G2(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function Z2(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const r=/^Key([A-Z])$/.exec(e);if(r?.[1])return r[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 Q2="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 J2(e="nterminal",t=new Date){return{reason:"permission",message:Q2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function eT(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 jw=3600*1e3,tT="local",nm=new Set,Ks=new Map;let $s={checking:!1,hasUpdates:!1,lastCheckedAt:null},Lg=null,sc=null,yh=0,Hs=null;function iT(e){return nm.add(e),()=>{nm.delete(e)}}function sS(){return $s}function nT(e){const t=oT();Lg=e,Bg(),rm(e,t);const r=()=>{if(document.visibilityState!=="visible"||!Vs(e,t))return;const s=$s.lastCheckedAt;(s===null||Date.now()-s>=jw)&&rm(e,t)};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r),Vs(e,t)&&lT()}}function rT(e,t){Ks.set(e,Hw(t)),Al({...$s,hasUpdates:Og(),lastCheckedAt:Date.now()})}function op(e){e===void 0?Ks.clear():Ks.set(e,!1),Al({...$s,hasUpdates:Og()})}async function rm(e,t){if(!Vs(e,t))return;if(Hs&&Hs.api===e&&Hs.runId===t)return Hs.promise;Al({...$s,checking:!0});const r=sT(e,t).finally(()=>{Hs?.promise===r&&(Hs=null),Vs(e,t)&&(Al({...$s,checking:!1,lastCheckedAt:Date.now()}),aT(e,t))});return Hs={api:e,runId:t,promise:r},r}async function sT(e,t){try{const r=await e.listAgents();if(!Vs(e,t))return;const s=[{key:tT,check:()=>e.checkUpdate()},...r.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(s.map(async c=>{try{const h=await c.check();o.set(c.key,Hw(h))}catch{o.set(c.key,Ks.get(c.key)??!1)}})),!Vs(e,t))return;Ks.clear();for(const[c,h]of o)Ks.set(c,h);Al({...$s,hasUpdates:Og()})}catch{}}function aT(e,t){Vs(e,t)&&(Bg(),sc=window.setTimeout(()=>{sc=null,Vs(e,t)&&rm(e,t)},jw))}function lT(){yh+=1,Bg(),Lg=null,Hs=null,Ks.clear(),Al({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Bg(){sc!==null&&(window.clearTimeout(sc),sc=null)}function oT(){return yh+=1,yh}function Vs(e,t){return Lg===e&&yh===t}function Hw(e){return e.updateAvailable===!0}function Og(){return Array.from(Ks.values()).some(Boolean)}function Al(e){$s=e;for(const t of Array.from(nm))t()}const cT=e=>new Promise(t=>setTimeout(t,e));function uT({api:e,onAgentRemoved:t}){const[r,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[b,y]=v.useState(!1);function S(U,K){c(W=>({...W,[U]:{...W[U],...K}}))}const w=U=>U.id===null?e.getVersion():e.getAgentVersion(U.id),x=U=>U.id===null?e.checkUpdate():e.checkAgentUpdate(U.id),D=U=>U.id===null?e.runUpdate():e.runAgentUpdate(U.id);v.useEffect(()=>{let U=!1;return e.listAgents().then(K=>{if(U)return;const W=[{key:"local",id:null,name:"Local (main)"},...K.agents.map(P=>({key:P.id,id:P.id,name:P.name}))];s(W);for(const P of W)w(P).then(j=>S(P.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(P.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{U=!0}},[]);async function L(U){S(U.key,{busy:!0,status:"checking…",error:void 0});try{const K=await x(U);rT(U.key,K),S(U.key,{latestVersion:K.latestVersion,updateAvailable:K.updateAvailable,status:ne(K),...K.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(K){S(U.key,{busy:!1,error:K instanceof Error?K.message:"check failed"})}}async function A(){p(!0),await Promise.all(r.map(U=>L(U))),p(!1)}async function B(U,K){const W=Date.now()+18e4;for(;Date.now()<W;){await cT(3e3);try{const P=await w(U);if(K&&P.runningVersion!==K.runningVersion)return P}catch{}}return null}async function V(U){let K=o[U.key]?.version;if(!K)try{K=await w(U),S(U.key,{version:K,manualUpdate:K.manualUpdate??null})}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(U.key,{busy:!0,status:"updating…",error:void 0});let W;try{W=await D(U)}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!W.ok){const j=W.manualUpdate??(eT(W.message)?J2():null);return j?(S(U.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(U.key,{busy:!1,status:void 0,error:W.message}),"failed")}if(!W.changed)return S(U.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),op(U.key),"unchanged";S(U.key,{status:"restarting…"});const P=await B(U,K);return P?(S(U.key,{busy:!1,version:P,updateAvailable:!1,status:"updated",manualUpdate:P.manualUpdate??null}),op(U.key),U.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(U.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function H(U){if(!(U.id===null||!window.confirm([`Delete secondary server "${U.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
- `)))){S(U.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const W=await e.uninstallAgent(U.id);s(P=>P.filter(j=>j.key!==U.key)),c(P=>{const j={...P};return delete j[U.key],j}),op(U.key),t?.(U.id),f(W.message)}catch(W){S(U.key,{busy:!1,status:void 0,error:W instanceof Error?W.message:"delete failed"})}}}async function F(){p(!0),f(null);const U=r.filter(R=>R.id!==null),K=r.find(R=>R.id===null),W=await Promise.all(U.map(R=>V(R))),P=W.filter(R=>R==="failed").length;let j=W.filter(R=>R==="manual").length,ae=null;if(K&&(ae=await V(K),ae==="manual"&&(j+=1),ae==="updated")){P>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}P>0&&j>0?f("Some servers failed and some need manual update. Check each marked row."):P>0?f("Some secondary servers failed to update. Check their rows and retry."):j>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function re(U){return U?U.error?U.error:U.status?U.status:U.manualUpdate?"manual update required":U.version?`v${U.version.version}`:"…":"…"}function ne(U){return U.error?U.error:typeof U.updateAvailable=="boolean"?U.updateAvailable?`latest v${U.latestVersion??"available"}`:"up to date":"unknown"}function de(U){const K=U?.version;return K?`npm package v${K.runningVersion}`:""}async function ve(U,K){try{await hT(K),S(U,{copiedCommand:!0}),window.setTimeout(()=>S(U,{copiedCommand:!1}),1800)}catch(W){S(U,{error:W instanceof Error?W.message:"copy failed"})}}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{A()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{F()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsx("ul",{className:"security-list",children:r.map(U=>{const K=o[U.key],W=de(K),P=K?.manualUpdate??null,j=K?.version!==void 0&&K?.updateAvailable!==!1&&!K?.busy&&!h,ae=U.id!==null&&!K?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:U.name}),m.jsxs("span",{className:"security-item-meta",children:[W?`${W} — `:"",re(K)]})]}),P?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:P.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:P.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(U.key,P.command)},children:K?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{V(U)},disabled:!j,children:K?.busy?"…":"Update"}),U.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{H(U)},disabled:!ae,children:"Delete"}):null]})]},U.key)})})]})}async function hT(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 Pu=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function dT({onClose:e,api:t,updateAvailable:r=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const c=v.useMemo(()=>t??Bh(),[t]),[h,p]=v.useState(()=>Gp()),[g,f]=v.useState(()=>Zp()),[b,y]=v.useState(()=>Jp()),[S,w]=v.useState(()=>em()),[x,D]=v.useState(()=>tm()),[L,A]=v.useState(()=>Fs()),[B,V]=v.useState(()=>Na()),[H,F]=v.useState(null),[re,ne]=v.useState(null),[de,ve]=v.useState("appearance"),[U,K]=v.useState(()=>vw()),[W,P]=v.useState(()=>Ma()),[j,ae]=v.useState(()=>Cg()),[R,Y]=v.useState([]),[G,Ce]=v.useState([]),[Te,M]=v.useState([]),[Q,fe]=v.useState(5*1024*1024),[me,ge]=v.useState(!1),[Se,Ee]=v.useState(null),Ne=v.useRef(null),Ue=v.useRef(null),te=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),_e=v.useMemo(()=>new Set(G),[G]),Ae=!pT(G,Te);v.useEffect(()=>xw(()=>p(Gp())),[]),v.useEffect(()=>kw(()=>f(Zp())),[]),v.useEffect(()=>Ew(()=>y(Jp())),[]),v.useEffect(()=>Ju(()=>{w(em()),D(tm())}),[]),v.useEffect(()=>hg(()=>A(Fs())),[]),v.useEffect(()=>_h(()=>V(Na())),[]),v.useEffect(()=>yw(()=>P(Ma())),[]),v.useEffect(()=>{if(!H)return;const Z=hc.find(le=>le.id===H);if(!Z)return;const Ke=le=>{if(le.preventDefault(),le.stopPropagation(),le.key==="Escape"){F(null),ne(null);return}const ze=F2(le,Z);if(!ze){ne(fT(Z));return}V(U2(H,ze)),F(null),ne(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[H]),v.useEffect(()=>{let Z=!1;return c.listNotificationAssets().then(Ke=>{Z||De(Ke)}).catch(Ke=>{Z||Ee(Iu(Ke))}),()=>{Z=!0}},[c]);function we(Z){p(Hu(Number(Z)))}function Me(Z){P(nS(Number(Z)))}function Ie(Z){ve(Z);const Ke=Ue.current,le=te.current[Z];if(!Ke||!le)return;const ze=Math.max(0,aS(le,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:ze,behavior:"smooth"}):Ke.scrollTop=ze}function We(){const Z=Ue.current;if(!Z)return;if(Z.scrollTop+Z.clientHeight>=Z.scrollHeight-2){ve(Pu[Pu.length-1].id);return}let Ke="appearance";const le=Z.scrollTop+Math.min(180,Math.max(48,Z.clientHeight*.28));for(const ze of Pu){const Qe=te.current[ze.id];Qe&&aS(Qe,Z)<=le&&(Ke=ze.id)}ve(Ke)}function ie(Z){V(K2(Z)),F(null),ne(null)}function ke(){V(W2()),F(null),ne(null)}function De(Z){const Ke=Z.assets.filter(le=>le.enabled).map(le=>le.id);Y(Z.assets),Ce(Ke),M(Ke),fe(Z.maxFileBytes),Ee(null)}async function Le(){if(U){iS(!1),K(!1);return}let Z=j;Z==="default"&&(Z=await N2(),ae(Z)),Z==="granted"&&(iS(!0),K(!0))}async function je(Z){const Ke=Z?.[0];if(Ke){if(Ke.size>Q){Ee(`File must be ${cp(Q)} or smaller.`),Bt();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){Ee("Upload an MP4 or WebM video."),Bt();return}ge(!0),Ee(null);try{await c.uploadNotificationAsset(Ke),De(await c.listNotificationAssets()),s?.()}catch(le){Ee(Iu(le))}finally{ge(!1),Bt()}}}async function at(Z){ge(!0),Ee(null);try{await c.deleteNotificationAsset(Z),De(await c.listNotificationAssets()),s?.()}catch(Ke){Ee(Iu(Ke))}finally{ge(!1)}}function Bt(){Ne.current&&(Ne.current.value="")}function $e(Z,Ke){const le=new Set(G);if(Ke?le.add(Z):le.delete(Z),le.size===0){Ee("Keep at least one toast video selected.");return}Ee(null),Ce(Array.from(le))}async function St(){if(G.length===0){Ee("Keep at least one toast video selected.");return}ge(!0),Ee(null);try{const Z=await c.updateNotificationAssetSelection({enabledAssetIds:G});De(Z),s?.()}catch(Z){Ee(Iu(Z))}finally{ge(!1)}}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:Z=>Z.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Pu.map(Z=>m.jsxs("button",{type:"button","data-active":de===Z.id?"true":"false","aria-current":de===Z.id?"true":void 0,onClick:()=>Ie(Z.id),children:[Z.label,Z.id==="servers"&&r?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},Z.id))}),m.jsxs("div",{ref:Ue,className:"settings-content",onScroll:We,children:[m.jsxs("section",{id:"settings-appearance",ref:Z=>{te.current.appearance=Z},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:hh.map(Z=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===Z.id,"data-active":L===Z.id?"true":"false",onClick:()=>A(Ak(Z.id)),style:{"--settings-theme-bg":Z.tokens.bg,"--settings-theme-bg-2":Z.tokens.bg2,"--settings-theme-sidebar":Z.tokens.bgSidebar,"--settings-theme-line":Z.tokens.line,"--settings-theme-fg":Z.tokens.fg,"--settings-theme-fg-2":Z.tokens.fg2,"--settings-theme-accent":Z.tokens.accent,"--settings-theme-xterm-bg":Z.xterm.background,"--settings-theme-xterm-fg":Z.xterm.foreground,"--settings-theme-xterm-selection":Z.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:Z.label}),m.jsx("small",{children:Z.description})]})]},Z.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Vp,max:Yp,step:1,value:h,"aria-label":"Terminal font size",onChange:Z=>we(Z.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Vp,max:Yp,step:1,value:h,"aria-label":"Terminal font size value",onChange:Z=>we(Z.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Hu(Ea)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:Z=>f(B2(Z.currentTarget.value)),children:gh.map(Z=>m.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:Z=>y(z2(Z.currentTarget.checked))}),"Show scroll progress"]}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:S,onChange:Z=>w(j2(Z.currentTarget.checked))}),"Shell panes"]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:x,onChange:Z=>D(H2(Z.currentTarget.checked))}),"Codex/Claude panes"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:Z=>{te.current.shortcuts=Z},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ke,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),re?m.jsx("p",{className:"settings-error",children:re}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:hc.map(Z=>{const Ke=H===Z.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:Z.label}),m.jsx("span",{className:"settings-shortcut-group",children:Z.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{F(Z.id),ne(null)},children:Ke?"Press keys…":Nw(B[Z.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>ie(Z.id),children:"Reset"})]})]},Z.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:Z=>{te.current.notifications=Z},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),Ih()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:U&&j==="granted",onChange:()=>{Le()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="denied"?m.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."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.enabled,onChange:Z=>P(E2(Z.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:W.persistUntilDismissed?"Until closed":`${W.durationSeconds}s`}),m.jsx("input",{type:"range",min:Wp,max:Fp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:Z=>Me(Z.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Wp,max:Fp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:Z=>Me(Z.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!W.enabled||W.persistUntilDismissed,onClick:()=>P(nS(rc)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.persistUntilDismissed,disabled:!W.enabled,onChange:Z=>P(T2(Z.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[cp(Q)," max"]})]}),m.jsx("input",{ref:Ne,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:Z=>{je(Z.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:me,onClick:()=>Ne.current?.click(),children:"Upload video"}),Se?m.jsx("p",{className:"settings-error",children:Se}):null,R.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:R.map(Z=>m.jsxs("li",{"data-enabled":_e.has(Z.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:_e.has(Z.id),disabled:me,"aria-label":`Use ${Z.filename}`,onChange:Ke=>$e(Z.id,Ke.currentTarget.checked)}),m.jsx("video",{src:Z.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:Z.filename}),m.jsx("small",{children:Z.source==="built-in"?"Built-in":cp(Z.size)})]})]}),Z.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:me,"aria-label":`Delete ${Z.filename}`,onClick:()=>{at(Z.id)},children:"x"}):null]},Z.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:me||R.length===0||!Ae,onClick:()=>{St()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:Z=>{te.current.security=Z},className:"settings-section-group",children:m.jsx(k2,{api:c})}),m.jsx("div",{id:"settings-servers",ref:Z=>{te.current.servers=Z},className:"settings-section-group",children:m.jsx(uT,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function aS(e,t){const r=e.getBoundingClientRect(),s=t.getBoundingClientRect();return r.top-s.top+t.scrollTop}function cp(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 Iu(e){return e instanceof Error?e.message:"Request failed."}function fT(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 pT(e,t){if(e.length!==t.length)return!1;const r=new Set(t);return e.every(s=>r.has(s))}class _a extends Error{constructor(t,r){super(r),this.status=t,this.name="UploadClientError"}status}function mT(e){const t=e.createXhr?.()??new XMLHttpRequest,r=new FormData,s=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));r.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[o,c]of e.files.entries())r.append(`file${o}`,c.file);return new Promise((o,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,p(),o(y))},f=y=>{h||(h=!0,p(),c(y))},b=()=>{t.abort(),f(new _a(0,"Upload aborted."))};if(e.signal?.aborted){f(new _a(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new _a(t.status,"Invalid upload response."))}return}f(new _a(t.status,gT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new _a(0,"Upload failed.")),t.onabort=()=>f(new _a(0,"Upload aborted.")),t.ontimeout=()=>f(new _a(0,"Upload timed out.")),t.send(r)})}function gT(e,t){try{const r=JSON.parse(e),s=typeof r.error=="string"?r.error:r.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const _T="modulepreload",vT=function(e){return"/"+e},lS={},zg=function(t,r,s){let o=Promise.resolve();if(r&&r.length>0){let g=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");o=g(r.map(f=>{if(f=vT(f),f in lS)return;lS[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":_T,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((w,x)=>{S.addEventListener("load",w),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return o.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},yT=v.lazy(()=>zg(()=>import("./MarkdownPreview-DOXE7Rl3.js"),__vite__mapDeps([0,1])));function bT({api:e,activeTerminalId:t,activeTerminalCwd:r,workspaceRootPath:s=null,onOpenFile:o}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,b]=v.useState({}),[y,S]=v.useState(()=>new Set),[w,x]=v.useState(null),[D,L]=v.useState({type:"empty"}),[A,B]=v.useState("idle"),[V,H]=v.useState(null),F=v.useRef(null),re=v.useRef(null),ne=v.useRef(!1),de=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const U=ve.current,K=s?wT(s):t?oS(t,r):null,W=c?[c.rootPath,p].filter(Boolean).join("/"):"",P=w?.path??null;v.useEffect(()=>(ne.current=!0,()=>{ne.current=!1,de.current+=1,_e()}),[]),v.useEffect(()=>{ve.current=t,re.current=null,j(K)},[e]),v.useEffect(()=>{s&&K!==re.current&&ae(s,K)},[s,K]),v.useEffect(()=>{if(s||!U||t!==U)return;const ie=oS(U,r);ie!==re.current&&R(U,ie)},[U,t,r,s]);async function j(ie=K){if(s){await ae(s,ie);return}await R(t,ie)}async function ae(ie,ke=K){const De=Ae();if(re.current=ke,_e(),h(null),g(""),b({}),S(new Set),x(null),L({type:"empty"}),H(null),!ie){B("idle");return}B("loading");try{const Le=await e.createFileRoot({path:ie});if(!we(De))return;h({rootToken:Le.rootToken,rootPath:Le.rootPath});const je=await e.listFiles({rootToken:Le.rootToken,path:""});if(!we(De))return;Ce(je),B("idle")}catch(Le){we(De)&&(H(Gr(Le)),B("idle"))}}async function R(ie,ke=K){const De=Ae();if(re.current=ke,_e(),h(null),g(""),b({}),S(new Set),x(null),L({type:"empty"}),H(null),!ie){B("idle");return}B("loading");try{const Le=await e.createFileRoot({terminalId:ie});if(!we(De))return;h({rootToken:Le.rootToken,rootPath:Le.rootPath});const je=await e.listFiles({rootToken:Le.rootToken,path:""});if(!we(De))return;Ce(je),B("idle")}catch(Le){if(await Me(Le,De))return;we(De)&&(H(Gr(Le)),B("idle"))}}async function Y(ie=p,ke=c){if(!ke)return;const De=Ae();B("loading"),H(null);try{const Le=await e.listFiles({rootToken:ke.rootToken,path:ie});if(!we(De))return;Ce(Le),B("idle")}catch(Le){if(await Me(Le,De))return;we(De)&&(H(Gr(Le)),B("idle"))}}async function G(){if(s){await ae(s,K);return}ve.current=t,await R(t,K)}function Ce(ie){b(ke=>({...ke,[ie.path]:CT(ie.entries)}))}async function Te(ie){if(!(!up(ie)||!c)){if(x(ie),H(null),ie.kind==="directory"){g(ie.path),te(),await Q(ie);return}if(g(va(ie.path)),ie.editable){await me(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function M(ie){if(!(!up(ie)||!c)){if(x(ie),H(null),ie.kind==="directory"){g(ie.path),te(),await Q(ie);return}if(g(va(ie.path)),ie.editable){await ge(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function Q(ie){if(y.has(ie.path)){S(ke=>{const De=new Set(ke);return De.delete(ie.path),De});return}S(ke=>new Set(ke).add(ie.path)),await Y(ie.path)}function fe(ie,ke){ie.key==="Enter"&&(ie.preventDefault(),M(ke))}async function me(ie){if(!c)return;const ke=Ae();B("loading"),_e();try{const De=await e.readFile({rootToken:c.rootToken,path:ie.path});if(!we(ke))return;L({type:"text-preview",file:ie,read:De}),B("idle")}catch(De){if(await Me(De,ke))return;we(ke)&&(H(Gr(De)),B("idle"))}}async function ge(ie){if(!c)return;const ke=Ae();B("loading");try{await o({rootToken:c.rootToken,path:ie.path,...t?{terminalId:t}:{}}),we(ke)&&B("idle")}catch(De){if(await Me(De,ke))return;we(ke)&&(H(Gr(De)),B("idle"))}}async function Se(ie,ke){if(!c)return;const De=Ae();B("loading"),_e();try{const Le=await e.previewFile({rootToken:c.rootToken,path:ie.path});if(!we(De))return;const je=URL.createObjectURL(Le);if(!we(De)){URL.revokeObjectURL(je);return}F.current=je,L({type:"preview",file:ie,previewKind:ke,url:je}),B("idle")}catch(Le){if(await Me(Le,De))return;we(De)&&(H(Gr(Le)),B("idle"))}}async function Ee(ie){if(!c)return;const ke=ie==="file"?"New file":"New folder",De=window.prompt(ke,""),Le=w?w.kind==="directory"?w.path:va(w.path):p,je=cS(De,Le);if(je){H(null);try{const at=await e.createFileEntry({rootToken:c.rootToken,path:je,kind:ie});x(at.entry),await Y(Le)}catch(at){if(await Me(at))return;H(Gr(at))}}}async function Ne(){if(!c||!w)return;const ie=window.prompt("Move selected entry",w.path),ke=cS(ie,"");if(!ke||ke===w.path)return;const De=va(w.path),Le=va(ke);H(null);try{const je=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:ke});x(je.entry),g(je.entry.kind==="directory"?je.entry.path:va(je.entry.path)),te(),await Y(De),Le!==De&&await Y(Le)}catch(je){if(await Me(je))return;H(Gr(je))}}async function Ue(){if(!c||!w)return;const ie=w.path,ke=va(ie);H(null);try{const De=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Le=De.descendantCount>0?` and ${De.descendantCount} nested item${De.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${De.path}${Le}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:De.previewToken}),x(null),g(ke),S(je=>{const at=new Set(je);for(const Bt of je)(Bt===ie||Bt.startsWith(`${ie}/`))&&at.delete(Bt);return at}),te(),await Y(ke)}catch(De){if(await Me(De))return;H(Gr(De))}}function te(){de.current+=1,_e(),L({type:"empty"})}function _e(){F.current&&(URL.revokeObjectURL(F.current),F.current=null)}function Ae(){return de.current+=1,de.current}function we(ie){return ne.current&&ie===de.current}async function Me(ie,ke){return xT(ie)?(ke!==void 0&&!we(ke)||await j(K),!0):!1}function Ie(ie,ke){const De=up(ie),Le=ie.kind==="directory"&&y.has(ie.path),je=f[ie.path]??[],at={"--file-tree-depth":ke};return m.jsxs(Ti.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ie.kind,"data-expanded":Le,"data-active":P===ie.path,disabled:!De,style:at,"aria-expanded":ie.kind==="directory"?Le:void 0,"aria-label":`${ie.kind==="directory"?"Open folder":"Open file"} ${ie.name}`,title:ie.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{Te(ie)},onDoubleClick:()=>{M(ie)},onKeyDown:Bt=>fe(Bt,ie),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ie.kind==="directory"?Le?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:ie.name}),m.jsx("small",{children:ST(ie)})]}),Le?m.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Bt=>Ie(Bt,ke+1))}):null]},ie.path)}const We=f[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:W,children:W||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{G()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ee("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ee("directory")},children:"▣"})]})]}),V?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:V}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":W?`Files in ${W}`:"Files",children:We.map(ie=>Ie(ie,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Ne()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ue()},children:"Delete"})]})]}),A==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&A!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?m.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?m.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(yT,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function up(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function ST(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function oS(e,t){return`${e}\0${t??""}`}function wT(e){return`workspace\0${e}`}function CT(e){return[...e].sort((t,r)=>t.kind==="directory"&&r.kind!=="directory"?-1:t.kind!=="directory"&&r.kind==="directory"?1:t.name.localeCompare(r.name))}function va(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function cS(e,t){if(e===null)return null;const r=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return r?!t||r.includes("/")?r:`${t}/${r}`:null}function Gr(e){return e instanceof Error?e.message:"Request failed"}function xT(e){return e instanceof fr&&e.status===409&&e.message==="terminal_cwd_changed"}const kT=v.lazy(()=>zg(()=>import("./MarkdownPreview-DOXE7Rl3.js"),__vite__mapDeps([0,1])));function uS({api:e,editor:t,canClose:r,onClose:s}){const[o,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[b,y]=v.useState(null),[S,w]=v.useState(!1),[x,D]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),B=v.useRef(t.read.content),V=v.useRef(!1),H=v.useRef(!1),F=v.useRef(0),re=h!==o.content&&g!=="saving"&&!S;v.useEffect(()=>(H.current=!0,()=>{H.current=!1,F.current+=1}),[]),v.useEffect(()=>{F.current+=1,V.current=!1,L.current=t,A.current=t.read,B.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{B.current=h},[h]),v.useEffect(()=>{if(h===o.content||S)return;const K=window.setInterval(()=>{!V.current&&B.current!==A.current.content&&ne()},1e3);return()=>window.clearInterval(K)},[h===o.content,S,t.id]);async function ne(){if(V.current)return;const K=B.current,W=A.current;if(K===W.content)return;const P=L.current,j=F.current;V.current=!0,f("saving"),y(null),w(!1);try{const ae=await e.writeFile({rootToken:P.rootToken,path:P.path,content:K,expectedVersion:W.version});if(!H.current||j!==F.current)return;const R={...W,content:K,version:ae.version};A.current=R,c(R),f(B.current===K?"saved":"idle")}catch(ae){if(!H.current||j!==F.current)return;if(ae instanceof fr&&ae.status===409){w(!0),f("idle");return}y(ET(ae)),f("idle")}finally{j===F.current&&(V.current=!1)}}const de=g==="saving"?"saving":g==="saved"?"saved":o.language,ve=o.language==="markdown",U=ve&&x==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:de}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!re,onClick:()=>{ne()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${U?"Edit":"Preview"} ${t.title}`,onClick:()=>D(K=>K==="preview"?"edit":"preview"),children:U?"Edit":"Preview"}):null,r?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,U?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(kT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:K=>{const W=K.target.value;B.current=W,p(W),f("idle"),y(null),w(!1)}})]})}function ET(e){return e instanceof Error?e.message:"Request failed"}var TT=2,DT=1,RT=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,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),o=Math.max(0,parseInt(r.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=h.top+h.bottom,g=h.right+h.left,f=s-p,b=o-g-t;return{cols:Math.max(TT,Math.floor(b/e.css.cell.width)),rows:Math.max(DT,Math.floor(f/e.css.cell.height))}}};var Pw=Object.defineProperty,MT=Object.getOwnPropertyDescriptor,NT=(e,t)=>{for(var r in t)Pw(e,r,{get:t[r],enumerable:!0})},ni=(e,t,r,s)=>{for(var o=s>1?void 0:s?MT(t,r):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(o=(s?h(t,r,o):h(o))||o);return s&&o&&Pw(t,r,o),o},Re=(e,t)=>(r,s)=>t(r,s,e),hS="Terminal input",sm={get:()=>hS,set:e=>hS=e},dS="Too much output to announce, navigate to rows manually to read",am={get:()=>dS,set:e=>dS=e};function AT(e){return e.replace(/\r?\n/g,"\r")}function LT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function BT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function OT(e,t,r,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Iw(o,t,r,s)}}function Iw(e,t,r,s){e=AT(e),e=LT(e,r.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),t.value=""}function Uw(e,t,r){let s=r.getBoundingClientRect(),o=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function fS(e,t,r,s,o){Uw(e,t,r),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Is(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Kh(e,t=0,r=e.length){let s="";for(let o=t;o<r;++o){let c=e[o];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var zT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let r=e.length;if(!r)return 0;let s=0,o=0;if(this._interim){let c=e.charCodeAt(o++);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=o;c<r;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=r)return this._interim=h,s;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[s++]=(h-55296)*1024+p-56320+65536:(t[s++]=h,t[s++]=p);continue}h!==65279&&(t[s++]=h)}return s}},jT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let r=e.length;if(!r)return 0;let s=0,o,c,h,p,g=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)w<<=6,w|=D;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-x;for(;f<A;){if(f>=r)return 0;if(D=e[f++],(D&192)!==128){f--,S=!0;break}else this.interim[x++]=D,w<<=6,w|=D&63}S||(L===2?w<128?f--:t[s++]=w:L===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let b=r-4,y=f;for(;y<r;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((p=e[y+3])&128);)t[s++]=o,t[s++]=c,t[s++]=h,t[s++]=p,y+=4;if(o=e[y++],o<128)t[s++]=o;else if((o&224)===192){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(g=(o&31)<<6|c&63,g<128){y--;continue}t[s++]=g}else if((o&240)===224){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(g=(o&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((o&248)===240){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=h,s;if(p=e[y++],(p&192)!==128){y--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},Kw="",Us=" ",xc=class Ww{constructor(){this.fg=0,this.bg=0,this.extended=new bh}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 Ww;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}},bh=class Fw{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 Fw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},tr=class qw extends xc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new bh,this.combinedData=""}static fromCharData(t){let r=new qw;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Is(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pS="di$target",lm="di$dependencies",hp=new Map;function HT(e){return e[lm]||[]}function Ki(e){if(hp.has(e))return hp.get(e);let t=function(r,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");PT(t,r,o)};return t._id=e,hp.set(e,t),t}function PT(e,t,r){t[pS]===t?t[lm].push({id:e,index:r}):(t[lm]=[{id:e,index:r}],t[pS]=t)}var ln=Ki("BufferService"),$w=Ki("CoreMouseService"),Oa=Ki("CoreService"),IT=Ki("CharsetService"),jg=Ki("InstantiationService"),Vw=Ki("LogService"),on=Ki("OptionsService"),Yw=Ki("OscLinkService"),UT=Ki("UnicodeService"),kc=Ki("DecorationService"),om=class{constructor(e,t,r){this._bufferService=e,this._optionsService=t,this._oscLinkService=r}provideLinks(e,t){let r=this._bufferService.buffer.lines.get(e-1);if(!r){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,c=new tr,h=r.getTrimmedLength(),p=-1,g=-1,f=!1;for(let b=0;b<h;b++)if(!(g===-1&&!r.hasContent(b))){if(r.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:g+1,y:e},end:{x:b+(!f&&b===h-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:S,activate:(x,D)=>o?o.activate(x,D,S):KT(x,D),hover:(x,D)=>o?.hover?.(x,D,S),leave:(x,D)=>o?.leave?.(x,D,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,p=c.extended.urlId):(g=-1,p=-1)}}t(s)}};om=ni([Re(0,ln),Re(1,on),Re(2,Yw)],om);function KT(e,t){if(confirm(`Do you want to navigate to ${t}?
16
-
17
- WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Wh=Ki("CharSizeService"),is=Ki("CoreBrowserService"),Hg=Ki("MouseService"),ns=Ki("RenderService"),WT=Ki("SelectionService"),Xw=Ki("CharacterJoinerService"),Pl=Ki("ThemeService"),Gw=Ki("LinkProviderService"),FT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?mS.isErrorNoTelemetry(e)?new mS(e.message+`
18
-
19
- `+e.stack):new Error(e.message+`
20
-
21
- `+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)}},qT=new FT;function eh(e){$T(e)||qT.onUnexpectedError(e)}var cm="Canceled";function $T(e){return e instanceof VT?!0:e instanceof Error&&e.name===cm&&e.message===cm}var VT=class extends Error{constructor(){super(cm),this.name=this.message}};function YT(e){return new Error(`Illegal argument: ${e}`)}var mS=class um extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof um)return t;let r=new um;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},hm=class Zw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Zw.prototype)}};function Bn(e,t=0){return e[e.length-(1+t)]}var XT;(e=>{function t(c){return c<0}e.isLessThan=t;function r(c){return c<=0}e.isLessThanOrEqual=r;function s(c){return c>0}e.isGreaterThan=s;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(XT||={});function GT(e,t){let r=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(r,arguments))),o}}var Qw;(e=>{function t(H){return H&&typeof H=="object"&&typeof H[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function s(){return r}e.empty=s;function*o(H){yield H}e.single=o;function c(H){return t(H)?H:o(H)}e.wrap=c;function h(H){return H||r}e.from=h;function*p(H){for(let F=H.length-1;F>=0;F--)yield H[F]}e.reverse=p;function g(H){return!H||H[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(H){return H[Symbol.iterator]().next().value}e.first=f;function b(H,F){let re=0;for(let ne of H)if(F(ne,re++))return!0;return!1}e.some=b;function y(H,F){for(let re of H)if(F(re))return re}e.find=y;function*S(H,F){for(let re of H)F(re)&&(yield re)}e.filter=S;function*w(H,F){let re=0;for(let ne of H)yield F(ne,re++)}e.map=w;function*x(H,F){let re=0;for(let ne of H)yield*F(ne,re++)}e.flatMap=x;function*D(...H){for(let F of H)yield*F}e.concat=D;function L(H,F,re){let ne=re;for(let de of H)ne=F(ne,de);return ne}e.reduce=L;function*A(H,F,re=H.length){for(F<0&&(F+=H.length),re<0?re+=H.length:re>H.length&&(re=H.length);F<re;F++)yield H[F]}e.slice=A;function B(H,F=Number.POSITIVE_INFINITY){let re=[];if(F===0)return[re,H];let ne=H[Symbol.iterator]();for(let de=0;de<F;de++){let ve=ne.next();if(ve.done)return[re,e.empty()];re.push(ve.value)}return[re,{[Symbol.iterator](){return ne}}]}e.consume=B;async function V(H){let F=[];for await(let re of H)F.push(re);return Promise.resolve(F)}e.asyncToArray=V})(Qw||={});function Aa(e){if(Qw.is(e)){let t=[];for(let r of e)if(r)try{r.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 ZT(...e){return qt(()=>Aa(e))}function qt(e){return{dispose:GT(()=>{e()})}}var Jw=class e1{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{Aa(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?e1.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)}};Jw.DISABLE_DISPOSED_WARNING=!1;var Ws=Jw,st=class{constructor(){this._store=new Ws,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)}};st.None=Object.freeze({dispose(){}});var Ll=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}},es=typeof window=="object"?window:globalThis,dm=class fm{constructor(t){this.element=t,this.next=fm.Undefined,this.prev=fm.Undefined}};dm.Undefined=new dm(void 0);var Gt=dm,gS=class{constructor(){this._first=Gt.Undefined,this._last=Gt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Gt.Undefined}clear(){let e=this._first;for(;e!==Gt.Undefined;){let t=e.next;e.prev=Gt.Undefined,e.next=Gt.Undefined,e=t}this._first=Gt.Undefined,this._last=Gt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new Gt(e);if(this._first===Gt.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==Gt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Gt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Gt.Undefined&&e.next!==Gt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Gt.Undefined&&e.next===Gt.Undefined?(this._first=Gt.Undefined,this._last=Gt.Undefined):e.next===Gt.Undefined?(this._last=this._last.prev,this._last.next=Gt.Undefined):e.prev===Gt.Undefined&&(this._first=this._first.next,this._first.prev=Gt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Gt.Undefined;)yield e.element,e=e.next}},QT=globalThis.performance&&typeof globalThis.performance.now=="function",JT=class t1{static create(t){return new t1(t)}constructor(t){this._now=QT&&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=()=>st.None;function t(W,P){return y(W,()=>{},0,void 0,!0,void 0,P)}e.defer=t;function r(W){return(P,j=null,ae)=>{let R=!1,Y;return Y=W(G=>{if(!R)return Y?Y.dispose():R=!0,P.call(j,G)},null,ae),R&&Y.dispose(),Y}}e.once=r;function s(W,P,j){return f((ae,R=null,Y)=>W(G=>ae.call(R,P(G)),null,Y),j)}e.map=s;function o(W,P,j){return f((ae,R=null,Y)=>W(G=>{P(G),ae.call(R,G)},null,Y),j)}e.forEach=o;function c(W,P,j){return f((ae,R=null,Y)=>W(G=>P(G)&&ae.call(R,G),null,Y),j)}e.filter=c;function h(W){return W}e.signal=h;function p(...W){return(P,j=null,ae)=>{let R=ZT(...W.map(Y=>Y(G=>P.call(j,G))));return b(R,ae)}}e.any=p;function g(W,P,j,ae){let R=j;return s(W,Y=>(R=P(R,Y),R),ae)}e.reduce=g;function f(W,P){let j,ae={onWillAddFirstListener(){j=W(R.fire,R)},onDidRemoveLastListener(){j?.dispose()}},R=new xe(ae);return P?.add(R),R.event}function b(W,P){return P instanceof Array?P.push(W):P&&P.add(W),W}function y(W,P,j=100,ae=!1,R=!1,Y,G){let Ce,Te,M,Q=0,fe,me={leakWarningThreshold:Y,onWillAddFirstListener(){Ce=W(Se=>{Q++,Te=P(Te,Se),ae&&!M&&(ge.fire(Te),Te=void 0),fe=()=>{let Ee=Te;Te=void 0,M=void 0,(!ae||Q>1)&&ge.fire(Ee),Q=0},typeof j=="number"?(clearTimeout(M),M=setTimeout(fe,j)):M===void 0&&(M=0,queueMicrotask(fe))})},onWillRemoveListener(){R&&Q>0&&fe?.()},onDidRemoveLastListener(){fe=void 0,Ce.dispose()}},ge=new xe(me);return G?.add(ge),ge.event}e.debounce=y;function S(W,P=0,j){return e.debounce(W,(ae,R)=>ae?(ae.push(R),ae):[R],P,void 0,!0,void 0,j)}e.accumulate=S;function w(W,P=(ae,R)=>ae===R,j){let ae=!0,R;return c(W,Y=>{let G=ae||!P(Y,R);return ae=!1,R=Y,G},j)}e.latch=w;function x(W,P,j){return[e.filter(W,P,j),e.filter(W,ae=>!P(ae),j)]}e.split=x;function D(W,P=!1,j=[],ae){let R=j.slice(),Y=W(Te=>{R?R.push(Te):Ce.fire(Te)});ae&&ae.add(Y);let G=()=>{R?.forEach(Te=>Ce.fire(Te)),R=null},Ce=new xe({onWillAddFirstListener(){Y||(Y=W(Te=>Ce.fire(Te)),ae&&ae.add(Y))},onDidAddFirstListener(){R&&(P?setTimeout(G):G())},onDidRemoveLastListener(){Y&&Y.dispose(),Y=null}});return ae&&ae.add(Ce),Ce.event}e.buffer=D;function L(W,P){return(j,ae,R)=>{let Y=P(new B);return W(function(G){let Ce=Y.evaluate(G);Ce!==A&&j.call(ae,Ce)},void 0,R)}}e.chain=L;let A=Symbol("HaltChainable");class B{constructor(){this.steps=[]}map(P){return this.steps.push(P),this}forEach(P){return this.steps.push(j=>(P(j),j)),this}filter(P){return this.steps.push(j=>P(j)?j:A),this}reduce(P,j){let ae=j;return this.steps.push(R=>(ae=P(ae,R),ae)),this}latch(P=(j,ae)=>j===ae){let j=!0,ae;return this.steps.push(R=>{let Y=j||!P(R,ae);return j=!1,ae=R,Y?R:A}),this}evaluate(P){for(let j of this.steps)if(P=j(P),P===A)break;return P}}function V(W,P,j=ae=>ae){let ae=(...Ce)=>G.fire(j(...Ce)),R=()=>W.on(P,ae),Y=()=>W.removeListener(P,ae),G=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:Y});return G.event}e.fromNodeEventEmitter=V;function H(W,P,j=ae=>ae){let ae=(...Ce)=>G.fire(j(...Ce)),R=()=>W.addEventListener(P,ae),Y=()=>W.removeEventListener(P,ae),G=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:Y});return G.event}e.fromDOMEventEmitter=H;function F(W){return new Promise(P=>r(W)(P))}e.toPromise=F;function re(W){let P=new xe;return W.then(j=>{P.fire(j)},()=>{P.fire(void 0)}).finally(()=>{P.dispose()}),P.event}e.fromPromise=re;function ne(W,P){return W(j=>P.fire(j))}e.forward=ne;function de(W,P,j){return P(j),W(ae=>P(ae))}e.runAndSubscribe=de;class ve{constructor(P,j){this._observable=P,this._counter=0,this._hasChanged=!1;let ae={onWillAddFirstListener:()=>{P.addObserver(this)},onDidRemoveLastListener:()=>{P.removeObserver(this)}};this.emitter=new xe(ae),j&&j.add(this.emitter)}beginUpdate(P){this._counter++}handlePossibleChange(P){}handleChange(P,j){this._hasChanged=!0}endUpdate(P){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(W,P){return new ve(W,P).emitter.event}e.fromObservable=U;function K(W){return(P,j,ae)=>{let R=0,Y=!1,G={beginUpdate(){R++},endUpdate(){R--,R===0&&(W.reportChanges(),Y&&(Y=!1,P.call(j)))},handlePossibleChange(){},handleChange(){Y=!0}};W.addObserver(G),W.reportChanges();let Ce={dispose(){W.removeObserver(G)}};return ae instanceof Ws?ae.add(Ce):Array.isArray(ae)&&ae.push(Ce),Ce}}e.fromObservableLight=K})(Zi||={});var pm=class mm{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${mm._idPool++}`,mm.all.add(this)}start(t){this._stopWatch=new JT,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}}};pm.all=new Set,pm._idPool=0;var eD=pm,tD=-1,i1=class n1{constructor(t,r,s=(n1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new rD(p,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,r=0;for(let[s,o]of this._stacks)(!t||r<o)&&(t=[s,o],r=o);return t}};i1._idPool=1;var iD=i1,nD=class r1{constructor(t){this.value=t}static create(){let t=new Error;return new r1(t.stack??"")}print(){console.warn(this.value.split(`
22
- `).slice(2).join(`
23
- `))}},rD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},sD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},aD=0,dp=class{constructor(e){this.value=e,this.id=aD++}},lD=2,oD,xe=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new iD(e?.onListenerError??eh,this._options?.leakWarningThreshold??tD):void 0,this._perfMon=this._options?._profName?new eD(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,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new sD(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||eh)(g),st.None}if(this._disposed)return st.None;t&&(e=e.bind(t));let s=new dp(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=nD.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof dp?(this._deliveryQueue??=new cD,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=qt(()=>{o?.(),this._removeListener(s)});return r instanceof Ws?r.add(c):Array.isArray(r)&&r.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,r=t.indexOf(e);if(r===-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[r]=void 0;let s=this._deliveryQueue.current===this;if(this._size*lD<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:s&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let r=this._options?.onListenerError||eh;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(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 dp)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}},cD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},gm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new xe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new xe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};gm.INSTANCE=new gm;var Pg=gm;function uD(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}Pg.INSTANCE.onDidChangeZoomLevel;function hD(e){return Pg.INSTANCE.getZoomFactor(e)}Pg.INSTANCE.onDidChangeFullscreen;var Il=typeof navigator=="object"?navigator.userAgent:"",_m=Il.indexOf("Firefox")>=0,dD=Il.indexOf("AppleWebKit")>=0,Ig=Il.indexOf("Chrome")>=0,fD=!Ig&&Il.indexOf("Safari")>=0;Il.indexOf("Electron/")>=0;Il.indexOf("Android")>=0;var fp=!1;if(typeof es.matchMedia=="function"){let e=es.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=es.matchMedia("(display-mode: fullscreen)");fp=e.matches,uD(es,e,({matches:r})=>{fp&&t.matches||(fp=r)})}var xl="en",vm=!1,ym=!1,th=!1,s1=!1,Uu,ih=xl,_S=xl,pD,Qr,Ta=globalThis,jn;typeof Ta.vscode<"u"&&typeof Ta.vscode.process<"u"?jn=Ta.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(jn=process);var mD=typeof jn?.versions?.electron=="string",gD=mD&&jn?.type==="renderer";if(typeof jn=="object"){vm=jn.platform==="win32",ym=jn.platform==="darwin",th=jn.platform==="linux",th&&jn.env.SNAP&&jn.env.SNAP_REVISION,jn.env.CI||jn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Uu=xl,ih=xl;let e=jn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Uu=t.userLocale,_S=t.osLocale,ih=t.resolvedLanguage||xl,pD=t.languagePack?.translationsConfigFile}catch{}s1=!0}else typeof navigator=="object"&&!gD?(Qr=navigator.userAgent,vm=Qr.indexOf("Windows")>=0,ym=Qr.indexOf("Macintosh")>=0,(Qr.indexOf("Macintosh")>=0||Qr.indexOf("iPad")>=0||Qr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,th=Qr.indexOf("Linux")>=0,Qr?.indexOf("Mobi")>=0,ih=globalThis._VSCODE_NLS_LANGUAGE||xl,Uu=navigator.language.toLowerCase(),_S=Uu):console.error("Unable to resolve platform.");var a1=vm,Rr=ym,_D=th,vS=s1,Mr=Qr,Ls=ih,vD;(e=>{function t(){return Ls}e.value=t;function r(){return Ls.length===2?Ls==="en":Ls.length>=3?Ls[0]==="e"&&Ls[1]==="n"&&Ls[2]==="-":!1}e.isDefaultVariant=r;function s(){return Ls==="en"}e.isDefault=s})(vD||={});var yD=typeof Ta.postMessage=="function"&&!Ta.importScripts;(()=>{if(yD){let e=[];Ta.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let c=e[s];if(c.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return r=>{let s=++t;e.push({id:s,callback:r}),Ta.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var bD=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!bD&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var Sl=typeof navigator=="object"?navigator:{};vS||document.queryCommandSupported&&document.queryCommandSupported("copy")||Sl&&Sl.clipboard&&Sl.clipboard.writeText,vS||Sl&&Sl.clipboard&&Sl.clipboard.readText;var Ug=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}},pp=new Ug,yS=new Ug,bS=new Ug,SD=new Array(230),l1;(e=>{function t(p){return pp.keyCodeToStr(p)}e.toString=t;function r(p){return pp.strToKeyCode(p)}e.fromString=r;function s(p){return yS.keyCodeToStr(p)}e.toUserSettingsUS=s;function o(p){return bS.keyCodeToStr(p)}e.toUserSettingsGeneral=o;function c(p){return yS.strToKeyCode(p)||bS.strToKeyCode(p)}e.fromUserSettings=c;function h(p){if(p>=98&&p<=113)return null;switch(p){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pp.keyCodeToStr(p)}e.toElectronAccelerator=h})(l1||={});var wD=class o1{constructor(t,r,s,o,c){this.ctrlKey=t,this.shiftKey=r,this.altKey=s,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof o1&&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",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${r}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new CD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},CD=class{constructor(e){if(e.length===0)throw YT("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;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 xD(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return l1.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(_m)switch(t){case 59:return 85;case 60:if(_D)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Rr)return 57;break}else if(dD&&(Rr&&t===93||!Rr&&t===92))return 57;return SD[t]||0}var kD=Rr?256:2048,ED=512,TD=1024,DD=Rr?2048:256,SS=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=xD(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|=kD),this.altKey&&(t|=ED),this.shiftKey&&(t|=TD),this.metaKey&&(t|=DD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},wS=new WeakMap;function RD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var MD=class{static getSameOriginWindowChain(e){let t=wS.get(e);if(!t){t=[],wS.set(e,t);let r=e,s;do s=RD(r),s?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,s=0,o=this.getSameOriginWindowChain(e);for(let c of o){let h=c.window.deref();if(r+=h?.scrollY??0,s+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();r+=p.top,s+=p.left}return{top:r,left:s}}},Ku=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 r=MD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},CS=class{constructor(e,t=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let s=!1;if(Ig){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?_m&&!Rr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")fD&&a1?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?_m&&!Rr?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*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},c1=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),ND;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof AD?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Zi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:c1})})(ND||={});var AD=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?c1:(this._emitter||(this._emitter=new xe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Kg=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 hm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},LD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,r=globalThis){if(this.isDisposed)throw new hm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},t);this.disposable=qt(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},BD;(e=>{async function t(s){let o,c=await Promise.all(s.map(h=>h.then(p=>p,p=>{o||(o=p)})));if(typeof o<"u")throw o;return c}e.settled=t;function r(s){return new Promise(async(o,c)=>{try{await s(o,c)}catch(h){c(h)}})}e.withAsyncBody=r})(BD||={});var xS=class Zn{static fromArray(t){return new Zn(r=>{r.emitMany(t)})}static fromPromise(t){return new Zn(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Zn(async r=>{await Promise.all(t.map(async s=>r.emitOne(await s)))})}static merge(t){return new Zn(async r=>{await Promise.all(t.map(async s=>{for await(let o of s)r.emitOne(o)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new xe,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}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,r){return new Zn(async s=>{for await(let o of t)s.emitOne(r(o))})}map(t){return Zn.map(this,t)}static filter(t,r){return new Zn(async s=>{for await(let o of t)r(o)&&s.emitOne(o)})}filter(t){return Zn.filter(this,t)}static coalesce(t){return Zn.filter(t,r=>!!r)}coalesce(){return Zn.coalesce(this)}static async toPromise(t){let r=[];for await(let s of t)r.push(s);return r}toPromise(){return Zn.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())}};xS.EMPTY=xS.fromArray([]);var{getWindow:Dr,getWindowId:OD,onDidRegisterWindow:zD}=(function(){let e=new Map,t={window:es,disposables:new Ws};e.set(es.vscodeWindowId,t);let r=new xe,s=new xe,o=new xe;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(h){if(e.has(h.vscodeWindowId))return st.None;let p=new Ws,g={window:h,disposables:p.add(new Ws)};return e.set(h.vscodeWindowId,g),p.add(qt(()=>{e.delete(h.vscodeWindowId),s.fire(h)})),p.add(Xe(h,zi.BEFORE_UNLOAD,()=>{o.fire(h)})),r.fire(g),p},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let p=h;if(p?.ownerDocument?.defaultView)return p.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:es},getDocument(h){return Dr(h).document}}})(),jD=class{constructor(e,t,r,s){this._node=e,this._type=t,this._handler=r,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 Xe(e,t,r,s){return new jD(e,t,r,s)}var kS=function(e,t,r,s){return Xe(e,t,r,s)},Wg,HD=class extends LD{constructor(e){super(),this.defaultTarget=e&&Dr(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},ES=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){eh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,s=new Map,o=c=>{r.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),s.set(c,!0);h.length>0;)h.sort(ES.sort),h.shift().execute();s.set(c,!1)};Wg=(c,h,p=0)=>{let g=OD(c),f=new ES(h,p),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(f),r.get(g)||(r.set(g,!0),c.requestAnimationFrame(()=>o(g))),f}})();function PD(e){let t=e.getBoundingClientRect(),r=Dr(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var zi={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"},ID=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=yn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yn(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=yn(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=yn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yn(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 yn(e){return typeof e=="number"?`${e}px`:e}function ac(e){return new ID(e)}var u1=class{constructor(){this._hooks=new Ws,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(qt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Dr(e)}this._hooks.add(Xe(c,zi.POINTER_MOVE,h=>{if(h.buttons!==r){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Xe(c,zi.POINTER_UP,h=>this.stopMonitoring(!0)))}};function UD(e,t,r){let s=null,o=null;if(typeof r.value=="function"?(s="value",o=r.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(s="get",o=r.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;r[s]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,h)}),this[c]}}var Tr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Tr||={});var Fo=class rn extends st{constructor(){super(),this.dispatched=!1,this.targets=new gS,this.ignoreTargets=new gS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Zi.runAndSubscribe(zD,({window:t,disposables:r})=>{r.add(Xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),r.add(Xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),r.add(Xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:es,disposables:this._store}))}static addTarget(t){if(!rn.isTouchDevice())return st.None;rn.INSTANCE||(rn.INSTANCE=new rn);let r=rn.INSTANCE.targets.push(t);return qt(r)}static ignoreTarget(t){if(!rn.isTouchDevice())return st.None;rn.INSTANCE||(rn.INSTANCE=new rn);let r=rn.INSTANCE.ignoreTargets.push(t);return qt(r)}static isTouchDevice(){return"ontouchstart"in es||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:r,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[r],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(Tr.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,h=r.changedTouches.length;c<h;c++){let p=r.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(p.identifier))){console.warn("move of an UNKNOWN touch",p);continue}let g=this.activeTouches[p.identifier],f=Date.now()-g.initialTimeStamp;if(f<rn.HOLD_DELAY&&Math.abs(g.initialPageX-Bn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Bn(g.rollingPageY))<30){let b=this.newGestureEvent(Tr.Tap,g.initialTarget);b.pageX=Bn(g.rollingPageX),b.pageY=Bn(g.rollingPageY),this.dispatchEvent(b)}else if(f>=rn.HOLD_DELAY&&Math.abs(g.initialPageX-Bn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Bn(g.rollingPageY))<30){let b=this.newGestureEvent(Tr.Contextmenu,g.initialTarget);b.pageX=Bn(g.rollingPageX),b.pageY=Bn(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=Bn(g.rollingPageX),y=Bn(g.rollingPageY),S=Bn(g.rollingTimestamps)-g.rollingTimestamps[0],w=b-g.rollingPageX[0],x=y-g.rollingPageY[0],D=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(w)/S,w>0?1:-1,b,Math.abs(x)/S,x>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Tr.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(t){if(t.type===Tr.Tap){let r=new Date().getTime(),s=0;r-this._lastSetTapCountTime>rn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=r,t.tapCount=s}else(t.type===Tr.Change||t.type===Tr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let r=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==s;)o++,c=c.parentElement;r.push([o,s])}r.sort((s,o)=>s[0]-o[0]);for(let[s,o]of r)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,s,o,c,h,p,g,f){this.handle=Wg(t,()=>{let b=Date.now(),y=b-s,S=0,w=0,x=!0;o+=rn.SCROLL_FRICTION*y,p+=rn.SCROLL_FRICTION*y,o>0&&(x=!1,S=c*o*y),p>0&&(x=!1,w=g*p*y);let D=this.newGestureEvent(Tr.Change);D.translationX=S,D.translationY=w,r.forEach(L=>L.dispatchEvent(D)),x||this.inertia(t,r,b,o,c,h+S,p,g,f+w)})}onTouchMove(t){let r=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(Tr.Change,h.initialTarget);p.translationX=c.pageX-Bn(h.rollingPageX),p.translationY=c.pageY-Bn(h.rollingPageY),p.pageX=c.pageX,p.pageY=c.pageY,this.dispatchEvent(p),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Fo.SCROLL_FRICTION=-.005,Fo.HOLD_DELAY=700,Fo.CLEAR_TAP_COUNT_TIME=400,ni([UD],Fo,"isTouchDevice",1);var KD=Fo,Fg=class extends st{onclick(e,t){this._register(Xe(e,zi.CLICK,r=>t(new Ku(Dr(e),r))))}onmousedown(e,t){this._register(Xe(e,zi.MOUSE_DOWN,r=>t(new Ku(Dr(e),r))))}onmouseover(e,t){this._register(Xe(e,zi.MOUSE_OVER,r=>t(new Ku(Dr(e),r))))}onmouseleave(e,t){this._register(Xe(e,zi.MOUSE_LEAVE,r=>t(new Ku(Dr(e),r))))}onkeydown(e,t){this._register(Xe(e,zi.KEY_DOWN,r=>t(new SS(r))))}onkeyup(e,t){this._register(Xe(e,zi.KEY_UP,r=>t(new SS(r))))}oninput(e,t){this._register(Xe(e,zi.INPUT,t))}onblur(e,t){this._register(Xe(e,zi.BLUR,t))}onfocus(e,t){this._register(Xe(e,zi.FOCUS,t))}onchange(e,t){this._register(Xe(e,zi.CHANGE,t))}ignoreGesture(e){return KD.ignoreTarget(e)}},TS=11,WD=class extends Fg{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=TS+"px",this.domNode.style.height=TS+"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 u1),this._register(kS(this.bgDomNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(kS(this.domNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new HD),this._pointerdownScheduleRepeatTimer=this._register(new Kg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Dr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},FD=class bm{constructor(t,r,s,o,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,s=s|0,o=o|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=o,this.rawScrollTop=p,r<0&&(r=0),o+r>s&&(o=s-r),o<0&&(o=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=r,this.scrollWidth=s,this.scrollLeft=o,this.height=c,this.scrollHeight=h,this.scrollTop=p}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,r){return new bm(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new bm(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,r){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,p=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,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:o,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},qD=class extends st{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new FD(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 r=this._state.withScrollDimensions(e,t);this._setState(r,!!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 r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let s;t?s=new RS(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=RS.start(this._state,r,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 r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},DS=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function mp(e,t){let r=t-e;return function(s){return e+r*YD(s)}}function $D(e,t,r){return function(s){return s<r?e(s/r):t((s-r)/(1-r))}}var RS=class Sm{constructor(t,r,s,o){this.from=t,this.to=r,this.duration=o,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,r,s){if(Math.abs(t-r)>2.5*s){let o,c;return t<r?(o=t+.75*s,c=r-.75*s):(o=t-.75*s,c=r+.75*s),$D(mp(t,o),mp(c,r),.33)}return mp(t,r)}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 r=(t-this.startTime)/this.duration;if(r<1){let s=this.scrollLeft(r),o=this.scrollTop(r);return new DS(s,o,!1)}return new DS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,s){return Sm.start(t,r,s)}static start(t,r,s){s=s+10;let o=Date.now()-10;return new Sm(t,r,o,s)}};function VD(e){return Math.pow(e,3)}function YD(e){return 1-VD(1-e)}var XD=class extends st{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Kg)}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":"")))}},GD=140,h1=class extends Fg{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 XD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new u1),this._shouldRender=!0,this.domNode=ac(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(Xe(this.domNode.domNode,zi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new WD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,s){this.slider=ac(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Xe(this.slider.domNode,zi.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.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,r=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);r<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let o=PD(this.domNode.domNode);t=e.pageX-o.left,r=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,r);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),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),h=Math.abs(c-r);if(a1&&h>GD){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let p=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(p))},()=>{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()}},d1=class wm{constructor(t,r,s,o,c,h){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new wm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,s,o,c){let h=Math.max(0,s-t),p=Math.max(0,h-2*r),g=o>0&&o>s;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*p/o))),b=(p-f)/(o-s),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=wm._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 r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},ZD=class extends h1{constructor(e,t,r){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new d1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.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}},QD=class extends h1{constructor(e,t,r){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new d1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.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}},JD=500,MS=50,eR=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},Cm=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,r=0,s=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-s);if(t-=c,r+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(Ig){let r=Dr(t.browserEvent),s=hD(r);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,s){let o=null,c=new eR(t,r,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=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,o)}_computeScore(t,r){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),r){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(r.deltaX),p=Math.abs(r.deltaY),g=Math.max(Math.min(o,h),1),f=Math.max(Math.min(c,p),1),b=Math.max(o,h),y=Math.max(c,p);b%g===0&&y%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Cm.INSTANCE=new Cm;var tR=Cm,iR=class extends Fg{constructor(e,t,r){super(),this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new xe),this.onWillScroll=this._onWillScroll.event,this._options=rR(t),this._scrollable=r,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new QD(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new ZD(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=ac(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ac(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ac(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,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Kg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Aa(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,Rr&&(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 CS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Aa(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new CS(r))};this._mouseWheelToDispose.push(Xe(this._listenOnDomNode,zi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=tR.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!Rr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(o){let f=MS*o,b=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let f=MS*c,b=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),r=!0)}let s=r;!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,r=e.scrollLeft>0,s=r?" left":"",o=t?" top":"",c=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${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(),JD)}},nR=class extends iR{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function rR(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,Rr&&(t.className+=" mac"),t}var xm=class extends st{constructor(e,t,r,s,o,c,h,p){super(),this._bufferService=r,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new qD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Wg(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new nR(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(o.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(qt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(qt(()=>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(`
24
- `)})),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),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};xm=ni([Re(2,ln),Re(3,is),Re(4,$w),Re(5,Pl),Re(6,on),Re(7,ns)],xm);var km=class extends st{constructor(e,t,r,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=s,this._renderService=o,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(qt(()=>{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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};km=ni([Re(1,ln),Re(2,is),Re(3,kc),Re(4,ns)],km);var sR=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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},kr={full:0,left:0,center:0,right:0},Bs={full:0,left:0,center:0,right:0},Ao={full:0,left:0,center:0,right:0},Sh=class extends st{constructor(e,t,r,s,o,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=s,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,this._colorZoneStore=new sR,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(qt(()=>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);Bs.full=this._canvas.width,Bs.left=e,Bs.center=t,Bs.right=e,this._refreshDrawHeightConstants(),Ao.full=1,Ao.left=1,Ao.center=1+Bs.left,Ao.right=1+Bs.left+Bs.center}_refreshDrawHeightConstants(){kr.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);kr.left=t,kr.center=t,kr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.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(Ao[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kr[e.position||"full"]/2),Bs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kr[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=ni([Re(2,ln),Re(3,kc),Re(4,ns),Re(5,on),Re(6,Pl),Re(7,is)],Sh);var pe;(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=`
25
- `,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=""))(pe||={});var nh;(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="Ÿ"))(nh||={});var f1;(e=>e.ST=`${pe.ESC}\\`)(f1||={});var Em=class{constructor(e,t,r,s,o,c){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=s,this._coreService=o,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 r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.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),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"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=o+"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)}}};Em=ni([Re(2,ln),Re(3,on),Re(4,Oa),Re(5,ns)],Em);var Hi=0,Pi=0,Ii=0,ii=0,NS={css:"#00000000",rgba:0},bi;(e=>{function t(o,c,h,p){return p!==void 0?`#${ya(o)}${ya(c)}${ya(h)}${ya(p)}`:`#${ya(o)}${ya(c)}${ya(h)}`}e.toCss=t;function r(o,c,h,p=255){return(o<<24|c<<16|h<<8|p)>>>0}e.toRgba=r;function s(o,c,h,p){return{css:e.toCss(o,c,h,p),rgba:e.toRgba(o,c,h,p)}}e.toColor=s})(bi||={});var Ut;(e=>{function t(g,f){if(ii=(f.rgba&255)/255,ii===1)return{css:f.css,rgba:f.rgba};let b=f.rgba>>24&255,y=f.rgba>>16&255,S=f.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Hi=w+Math.round((b-w)*ii),Pi=x+Math.round((y-x)*ii),Ii=D+Math.round((S-D)*ii);let L=bi.toCss(Hi,Pi,Ii),A=bi.toRgba(Hi,Pi,Ii);return{css:L,rgba:A}}e.blend=t;function r(g){return(g.rgba&255)===255}e.isOpaque=r;function s(g,f,b){let y=rh.ensureContrastRatio(g.rgba,f.rgba,b);if(y)return bi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function o(g){let f=(g.rgba|255)>>>0;return[Hi,Pi,Ii]=rh.toChannels(f),{css:bi.toCss(Hi,Pi,Ii),rgba:f}}e.opaque=o;function c(g,f){return ii=Math.round(f*255),[Hi,Pi,Ii]=rh.toChannels(g.rgba),{css:bi.toCss(Hi,Pi,Ii,ii),rgba:bi.toRgba(Hi,Pi,Ii,ii)}}e.opacity=c;function h(g,f){return ii=g.rgba&255,c(g,ii*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Ut||={});var Zt;(e=>{let t,r;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Hi=parseInt(o.slice(1,2).repeat(2),16),Pi=parseInt(o.slice(2,3).repeat(2),16),Ii=parseInt(o.slice(3,4).repeat(2),16),bi.toColor(Hi,Pi,Ii);case 5:return Hi=parseInt(o.slice(1,2).repeat(2),16),Pi=parseInt(o.slice(2,3).repeat(2),16),Ii=parseInt(o.slice(3,4).repeat(2),16),ii=parseInt(o.slice(4,5).repeat(2),16),bi.toColor(Hi,Pi,Ii,ii);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.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 Hi=parseInt(c[1]),Pi=parseInt(c[2]),Ii=parseInt(c[3]),ii=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),bi.toColor(Hi,Pi,Ii,ii);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Hi,Pi,Ii,ii]=t.getImageData(0,0,1,1).data,ii!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:bi.toRgba(Hi,Pi,Ii,ii),css:o}}e.toColor=s})(Zt||={});var an;(e=>{function t(s){return r(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function r(s,o,c){let h=s/255,p=o/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+b*.7152+y*.0722}e.relativeLuminance2=r})(an||={});var rh;(e=>{function t(h,p){if(ii=(p&255)/255,ii===1)return p;let g=p>>24&255,f=p>>16&255,b=p>>8&255,y=h>>24&255,S=h>>16&255,w=h>>8&255;return Hi=y+Math.round((g-y)*ii),Pi=S+Math.round((f-S)*ii),Ii=w+Math.round((b-w)*ii),bi.toRgba(Hi,Pi,Ii)}e.blend=t;function r(h,p,g){let f=an.relativeLuminance(h>>8),b=an.relativeLuminance(p>>8);if(Zr(f,b)<g){if(b<f){let w=s(h,p,g),x=Zr(f,an.relativeLuminance(w>>8));if(x<g){let D=o(h,p,g),L=Zr(f,an.relativeLuminance(D>>8));return x>L?w:D}return w}let y=o(h,p,g),S=Zr(f,an.relativeLuminance(y>>8));if(S<g){let w=s(h,p,g),x=Zr(f,an.relativeLuminance(w>>8));return S>x?y:w}return y}}e.ensureContrastRatio=r;function s(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,x=p>>8&255,D=Zr(an.relativeLuminance2(S,w,x),an.relativeLuminance2(f,b,y));for(;D<g&&(S>0||w>0||x>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=Zr(an.relativeLuminance2(S,w,x),an.relativeLuminance2(f,b,y));return(S<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=s;function o(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,x=p>>8&255,D=Zr(an.relativeLuminance2(S,w,x),an.relativeLuminance2(f,b,y));for(;D<g&&(S<255||w<255||x<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=Zr(an.relativeLuminance2(S,w,x),an.relativeLuminance2(f,b,y));return(S<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(rh||={});function ya(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Zr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var aR=class extends xc{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},wh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new tr}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 r=[],s=t.translateToString(!0),o=0,c=0,h=0,p=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!==p||this._workCell.bg!==g){if(f-o>1){let b=this._getJoinedRanges(s,h,c,t,o);for(let y=0;y<b.length;y++)r.push(b[y])}o=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Us.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,h,c,t,o);for(let b=0;b<f.length;b++)r.push(f[b])}return r}_getJoinedRanges(e,t,r,s,o){let c=e.substring(t,r),h=[];try{h=this._characterJoiners[0].handler(c)}catch(p){console.error(p)}for(let p=1;p<this._characterJoiners.length;p++)try{let g=this._characterJoiners[p].handler(c);for(let f=0;f<g.length;f++)wh._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,s,o),h}_stringRangesToCellRanges(e,t,r){let s=0,o=!1,c=0,h=e[s];if(h){for(let p=r;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||Us.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=p,o=!0),h[1]<=c){if(h[1]=p,h=e[++s],!h)break;h[0]<=c?(h[0]=p,o=!0):o=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(r){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};wh=ni([Re(0,ln)],wh);function lR(e){return 57508<=e&&e<=57558}function oR(e){return 9472<=e&&e<=9631}function cR(e){return lR(e)||oR(e)}function uR(){return{css:{canvas:Wu(),cell:Wu()},device:{canvas:Wu(),cell:Wu(),char:{width:0,height:0,left:0,top:0}}}}function Wu(){return{width:0,height:0}}var Tm=class{constructor(e,t,r,s,o,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=s,this._coreService=o,this._decorationService=c,this._themeService=h,this._workCell=new tr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,s,o,c,h,p,g,f,b){let y=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();r&&x<c+1&&(x=c+1);let D,L=0,A="",B=0,V=0,H=0,F=0,re=!1,ne=0,de=!1,ve=0,U=0,K=[],W=f!==-1&&b!==-1;for(let P=0;P<x;P++){e.loadCell(P,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let ae=!1,R=P>=U,Y=P,G=this._workCell;if(S.length>0&&P===S[0][0]&&R){let we=S.shift(),Me=this._isCellInSelection(we[0],t);for(B=we[0]+1;B<we[1];B++)R&&=Me===this._isCellInSelection(B,t);R&&=!r||c<we[0]||c>=we[1],R?(ae=!0,G=new aR(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),Y=we[1]-1,j=G.getWidth()):U=we[1]}let Ce=this._isCellInSelection(P,t),Te=r&&P===c,M=W&&P>=f&&P<=b,Q=!1;this._decorationService.forEachDecorationAtCell(P,t,void 0,we=>{Q=!0});let fe=G.getChars()||Us;if(fe===" "&&(G.isUnderline()||G.isOverline())&&(fe=" "),ve=j*p-g.get(fe,G.isBold(),G.isItalic()),!D)D=this._document.createElement("span");else if(L&&(Ce&&de||!Ce&&!de&&G.bg===V)&&(Ce&&de&&w.selectionForeground||G.fg===H)&&G.extended.ext===F&&M===re&&ve===ne&&!Te&&!ae&&!Q&&R){G.isInvisible()?A+=Us:A+=fe,L++;continue}else L&&(D.textContent=A),D=this._document.createElement("span"),L=0,A="";if(V=G.bg,H=G.fg,F=G.extended.ext,re=M,ne=ve,de=Ce,ae&&c>=P&&c<=Y&&(c=P),!this._coreService.isCursorHidden&&Te&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(G.isBold()&&K.push("xterm-bold"),G.isItalic()&&K.push("xterm-italic"),G.isDim()&&K.push("xterm-dim"),G.isInvisible()?A=Us:A=G.getChars()||Us,G.isUnderline()&&(K.push(`xterm-underline-${G.extended.underlineStyle}`),A===" "&&(A=" "),!G.isUnderlineColorDefault()))if(G.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${xc.toColorRGB(G.getUnderlineColor()).join(",")})`;else{let we=G.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&G.isBold()&&we<8&&(we+=8),D.style.textDecorationColor=w.ansi[we].css}G.isOverline()&&(K.push("xterm-overline"),A===" "&&(A=" ")),G.isStrikethrough()&&K.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let me=G.getFgColor(),ge=G.getFgColorMode(),Se=G.getBgColor(),Ee=G.getBgColorMode(),Ne=!!G.isInverse();if(Ne){let we=me;me=Se,Se=we;let Me=ge;ge=Ee,Ee=Me}let Ue,te,_e=!1;this._decorationService.forEachDecorationAtCell(P,t,void 0,we=>{we.options.layer!=="top"&&_e||(we.backgroundColorRGB&&(Ee=50331648,Se=we.backgroundColorRGB.rgba>>8&16777215,Ue=we.backgroundColorRGB),we.foregroundColorRGB&&(ge=50331648,me=we.foregroundColorRGB.rgba>>8&16777215,te=we.foregroundColorRGB),_e=we.options.layer==="top")}),!_e&&Ce&&(Ue=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Se=Ue.rgba>>8&16777215,Ee=50331648,_e=!0,w.selectionForeground&&(ge=50331648,me=w.selectionForeground.rgba>>8&16777215,te=w.selectionForeground)),_e&&K.push("xterm-decoration-top");let Ae;switch(Ee){case 16777216:case 33554432:Ae=w.ansi[Se],K.push(`xterm-bg-${Se}`);break;case 50331648:Ae=bi.toColor(Se>>16,Se>>8&255,Se&255),this._addStyle(D,`background-color:#${AS((Se>>>0).toString(16),"0",6)}`);break;default:Ne?(Ae=w.foreground,K.push("xterm-bg-257")):Ae=w.background}switch(Ue||G.isDim()&&(Ue=Ut.multiplyOpacity(Ae,.5)),ge){case 16777216:case 33554432:G.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(D,Ae,w.ansi[me],G,Ue,void 0)||K.push(`xterm-fg-${me}`);break;case 50331648:let we=bi.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(D,Ae,we,G,Ue,te)||this._addStyle(D,`color:#${AS(me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Ae,w.foreground,G,Ue,te)||Ne&&K.push("xterm-fg-257")}K.length&&(D.className=K.join(" "),K.length=0),!Te&&!ae&&!Q&&R?L++:D.textContent=A,ve!==this.defaultSpacing&&(D.style.letterSpacing=`${ve}px`),y.push(D),P=Y}return D&&L&&(D.textContent=A),y}_applyMinimumContrast(e,t,r,s,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||cR(s.getCode()))return!1;let h=this._getContrastCache(s),p;if(!o&&!c&&(p=h.getColor(t.rgba,r.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);p=Ut.ensureContrastRatio(o||t,c||r,g),h.setColor((o||t).rgba,(c||r).rgba,p??null)}return p?(this._addStyle(e,`color:${p.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 r=this._selectionStart,s=this._selectionEnd;return!r||!s?!1:this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&t>=r[1]&&e<s[0]&&t<=s[1]:e<r[0]&&t>=r[1]&&e>=s[0]&&t<=s[1]:t>r[1]&&t<s[1]||r[1]===s[1]&&t===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&t===s[1]&&e<s[0]||r[1]<s[1]&&t===r[1]&&e>=r[0]}};Tm=ni([Re(1,Xw),Re(2,on),Re(3,is),Re(4,Oa),Re(5,kc),Re(6,Pl)],Tm);function AS(e,t,r){for(;e.length<r;)e=t+e;return e}var hR=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.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=[r,s,o,c],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(o),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,r,s){e===this._font&&t===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,r){let s=0;if(!t&&!r&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let h=this._measure(e,0);return h>0&&(this._flat[s]=h),h}let o=e;t&&(o+="B"),r&&(o+="I");let c=this._holey.get(o);if(c===void 0){let h=0;t&&(h|=1),r&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},dR=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,r,s=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,h=r[1]-o,p=Math.max(c,0),g=Math.min(h,e.rows-1);if(p>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function fR(){return new dR}var gp="xterm-dom-renderer-owner-",Gn="xterm-rows",Fu="xterm-fg-",LS="xterm-bg-",Lo="xterm-focus",qu="xterm-selection",pR=1,Dm=class extends st{constructor(e,t,r,s,o,c,h,p,g,f,b,y,S,w){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=s,this._viewportElement=o,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=b,this._coreService=y,this._coreBrowserService=S,this._themeService=w,this._terminalClass=pR++,this._rowElements=[],this._selectionRenderModel=fR(),this.onRequestRedraw=this._register(new xe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Gn),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(qu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=uR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(Tm,document),this._element.classList.add(gp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(qt(()=>{this._element.classList.remove(gp+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new hR(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Gn} 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} .${Gn} { 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} .${Gn} .xterm-dim { color: ${Ut.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Gn}.${Lo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Gn}.${Lo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Gn}.${Lo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Gn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Gn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Gn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Gn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Gn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${qu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${qu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${qu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Fu}${c} { color: ${h.css}; }${this._terminalSelector} .${Fu}${c}.xterm-dim { color: ${Ut.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${LS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Fu}257 { color: ${Ut.opaque(e.background).css}; }${this._terminalSelector} .${Fu}257.xterm-dim { color: ${Ut.multiplyOpacity(Ut.opaque(e.background),.5).css}; }${this._terminalSelector} .${LS}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 r=this._rowElements.length;r<=t;r++){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(Lo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Lo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(r){let g=e[0]>t[0];p.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=s===c?e[0]:0,f=c===o?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let b=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=o===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,r,s=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(r-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${h}px`,o}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 r=this._bufferService.buffer,s=r.ybase+r.y,o=Math.min(r.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+r.ydisp,b=this._rowElements[g],y=r.lines.get(f);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,f,f===s,h,p,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gp}${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,r,s,o,c){r<0&&(e=0),s<0&&(t=0);let h=this._bufferService.rows-1;r=Math.max(Math.min(r,h),0),s=Math.max(Math.min(s,h),0),o=Math.min(o,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,o-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=r;w<=s;++w){let x=w+p.ydisp,D=this._rowElements[w],L=p.lines.get(x);if(!D||!L)break;D.replaceChildren(...this._rowFactory.createRow(L,x,x===g,y,S,f,b,this.dimensions.css.cell.width,this._widthCache,c?w===r?e:0:-1,c?(w===s?t:o)-1:-1))}}};Dm=ni([Re(7,jg),Re(8,Wh),Re(9,on),Re(10,ln),Re(11,Oa),Re(12,is),Re(13,Pl)],Dm);var Rm=class extends st{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new xe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new gR(this._optionsService))}catch{this._measureStrategy=this._register(new mR(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())}};Rm=ni([Re(2,on)],Rm);var p1=class extends st{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)}},mR=class extends p1{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},gR=class extends p1{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}},_R=class extends st{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new vR(this._window)),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new xe),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(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(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}},vR=class extends st{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ll),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(qt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(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)}},yR=class extends st{constructor(){super(),this.linkProviders=[],this._register(qt(()=>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 qg(e,t,r){let s=r.getBoundingClientRect(),o=e.getComputedStyle(r),c=parseInt(o.getPropertyValue("padding-left")),h=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-h]}function bR(e,t,r,s,o,c,h,p,g){if(!c)return;let f=qg(e,t,r);if(f)return f[0]=Math.ceil((f[0]+(g?h/2:0))/h),f[1]=Math.ceil(f[1]/p),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var Mm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,s,o){return bR(window,e,t,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let r=qg(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};Mm=ni([Re(0,ns),Re(1,Wh)],Mm);var SR=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,r){this._rowCount=r,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=[]}},m1={};NT(m1,{getSafariVersion:()=>CR,isChromeOS:()=>y1,isFirefox:()=>g1,isIpad:()=>xR,isIphone:()=>kR,isLegacyEdge:()=>wR,isLinux:()=>$g,isMac:()=>Ch,isNode:()=>Fh,isSafari:()=>_1,isWindows:()=>v1});var Fh=typeof process<"u"&&"title"in process,Ec=Fh?"node":navigator.userAgent,Tc=Fh?"node":navigator.platform,g1=Ec.includes("Firefox"),wR=Ec.includes("Edge"),_1=/^((?!chrome|android).)*safari/i.test(Ec);function CR(){if(!_1)return 0;let e=Ec.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ch=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Tc),xR=Tc==="iPad",kR=Tc==="iPhone",v1=["Windows","Win16","Win32","WinCE"].includes(Tc),$g=Tc.indexOf("Linux")>=0,y1=/\bCrOS\b/.test(Ec),b1=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,r=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),o=e.timeRemaining(),r*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},ER=class extends b1{_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())}}},TR=class extends b1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},xh=!Fh&&"requestIdleCallback"in window?TR:ER,DR=class{constructor(){this._queue=new xh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Nm=class extends st{constructor(e,t,r,s,o,c,h,p,g){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=o,this._coreBrowserService=p,this._renderer=this._register(new Ll),this._pausedResizeTask=new DR,this._observerDisposable=this._register(new Ll),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 xe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new xe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new xe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new SR((f,b)=>this._renderRows(f,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new RR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(qt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.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(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.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 r=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=qt(()=>r.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,r=!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)),r||(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,r){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,t,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Nm=ni([Re(2,on),Re(3,Wh),Re(4,Oa),Re(5,kc),Re(6,ln),Re(7,is),Re(8,Pl)],Nm);var RR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,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 MR(e,t,r,s){let o=r.buffer.x,c=r.buffer.y;if(!r.buffer.hasScrollback)return LR(o,c,e,t,r,s)+qh(c,t,r,s)+BR(o,c,e,t,r,s);let h;if(c===t)return h=o>e?"D":"C",fc(Math.abs(o-e),dc(h,s));h=c>t?"D":"C";let p=Math.abs(c-t),g=AR(c>t?e:o,r)+(p-1)*r.cols+1+NR(c>t?o:e);return fc(g,dc(h,s))}function NR(e,t){return e-1}function AR(e,t){return t.cols-e}function LR(e,t,r,s,o,c){return qh(t,s,o,c).length===0?"":fc(w1(e,t,e,t-La(t,o),!1,o).length,dc("D",c))}function qh(e,t,r,s){let o=e-La(e,r),c=t-La(t,r),h=Math.abs(o-c)-OR(e,t,r);return fc(h,dc(S1(e,t),s))}function BR(e,t,r,s,o,c){let h;qh(t,s,o,c).length>0?h=s-La(s,o):h=t;let p=s,g=zR(e,t,r,s,o,c);return fc(w1(e,h,r,p,g==="C",o).length,dc(g,c))}function OR(e,t,r){let s=0,o=e-La(e,r),c=t-La(t,r);for(let h=0;h<Math.abs(o-c);h++){let p=S1(e,t)==="A"?-1:1;r.buffer.lines.get(o+p*h)?.isWrapped&&s++}return s}function La(e,t){let r=0,s=t.buffer.lines.get(e),o=s?.isWrapped;for(;o&&e>=0&&e<t.rows;)r++,s=t.buffer.lines.get(--e),o=s?.isWrapped;return r}function zR(e,t,r,s,o,c){let h;return qh(r,s,o,c).length>0?h=s-La(s,o):h=t,e<r&&h<=s||e>=r&&h<s?"C":"D"}function S1(e,t){return e>t?"A":"B"}function w1(e,t,r,s,o,c){let h=e,p=t,g="";for(;(h!==r||p!==s)&&p>=0&&p<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!o&&h<0&&(g+=c.buffer.translateBufferLineToString(p,!1,0,e+1),h=c.cols-1,e=h,p--);return g+c.buffer.translateBufferLineToString(p,!1,e,h)}function dc(e,t){let r=t?"O":"[";return pe.ESC+r+e}function fc(e,t){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=t;return r}var jR=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 BS(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 _p=50,HR=15,PR=50,IR=500,UR=" ",KR=new RegExp(UR,"g"),Am=class extends st{constructor(e,t,r,s,o,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=s,this._coreService=o,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new tr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new xe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new xe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new xe),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 jR(this._bufferService),this._activeSelectionMode=0,this._register(qt(()=>{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 r=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let p=r.translateBufferLineToString(h,!0,o,c);s.push(p)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let h=r.lines.get(c),p=r.translateBufferLineToString(c,!0);h?.isWrapped?s[s.length-1]+=p:s.push(p)}if(e[1]!==t[1]){let c=r.lines.get(t[1]),h=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=h:s.push(h)}}return s.map(o=>o.replace(KR," ")).join(v1?`\r
26
- `:`
27
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),$g&&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),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s||!t?!1:this._areCoordsInSelection(t,r,s)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s?!1:this._areCoordsInSelection([e,t],r,s)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=BS(r,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=qg(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-_p),_p),t/=_p,t/Math.abs(t)+Math.round(t*(HR-1)))}shouldForceSelection(e){return Ch?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(),PR)}_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&&!(Ch&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let s=r.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<IR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let s=MR(r[0]-1,r[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,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:o>1&&t!==s&&(r+=o-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let h=o.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,b=0,y=0,S=0,w=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let L=e[0],A=e[0];c.getWidth(L)===0&&(b++,L--),c.getWidth(A)===2&&(y++,A++);let B=c.getString(A).length;for(B>1&&(w+=B-1,g+=B-1);L>0&&p>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let V=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,L--):V>1&&(S+=V-1,p-=V-1),p--,L--}for(;A<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let V=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,A++):V>1&&(w+=V-1,g+=V-1),g++,A++}}g++;let x=p+f-b+S,D=Math.min(this._bufferService.cols,g-p+b+y-S-w);if(!(!t&&h.slice(p,g).trim()==="")){if(r&&x===0&&c.getCodePoint(0)!==32){let L=o.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let B=this._bufferService.cols-A.start;x-=B,D+=B}}}if(s&&x+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=o.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(D+=A.length)}}return{start:x,length:D}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=BS(r,this._bufferService.cols)}};Am=ni([Re(3,ln),Re(4,Oa),Re(5,Hg),Re(6,on),Re(7,ns),Re(8,is)],Am);var OS=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},zS=class{constructor(){this._color=new OS,this._css=new OS}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},xi=Object.freeze((()=>{let e=[Zt.toColor("#2e3436"),Zt.toColor("#cc0000"),Zt.toColor("#4e9a06"),Zt.toColor("#c4a000"),Zt.toColor("#3465a4"),Zt.toColor("#75507b"),Zt.toColor("#06989a"),Zt.toColor("#d3d7cf"),Zt.toColor("#555753"),Zt.toColor("#ef2929"),Zt.toColor("#8ae234"),Zt.toColor("#fce94f"),Zt.toColor("#729fcf"),Zt.toColor("#ad7fa8"),Zt.toColor("#34e2e2"),Zt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=t[r/36%6|0],o=t[r/6%6|0],c=t[r%6];e.push({css:bi.toCss(s,o,c),rgba:bi.toRgba(s,o,c)})}for(let r=0;r<24;r++){let s=8+r*10;e.push({css:bi.toCss(s,s,s),rgba:bi.toRgba(s,s,s)})}return e})()),Sa=Zt.toColor("#ffffff"),qo=Zt.toColor("#000000"),jS=Zt.toColor("#ffffff"),HS=qo,Bo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},WR=Sa,Lm=class extends st{constructor(e){super(),this._optionsService=e,this._contrastCache=new zS,this._halfContrastCache=new zS,this._onChangeColors=this._register(new xe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Sa,background:qo,cursor:jS,cursorAccent:HS,selectionForeground:void 0,selectionBackgroundTransparent:Bo,selectionBackgroundOpaque:Ut.blend(qo,Bo),selectionInactiveBackgroundTransparent:Bo,selectionInactiveBackgroundOpaque:Ut.blend(qo,Bo),scrollbarSliderBackground:Ut.opacity(Sa,.2),scrollbarSliderHoverBackground:Ut.opacity(Sa,.4),scrollbarSliderActiveBackground:Ut.opacity(Sa,.5),overviewRulerBorder:Sa,ansi:xi.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=Et(e.foreground,Sa),t.background=Et(e.background,qo),t.cursor=Ut.blend(t.background,Et(e.cursor,jS)),t.cursorAccent=Ut.blend(t.background,Et(e.cursorAccent,HS)),t.selectionBackgroundTransparent=Et(e.selectionBackground,Bo),t.selectionBackgroundOpaque=Ut.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Et(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ut.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Et(e.selectionForeground,NS):void 0,t.selectionForeground===NS&&(t.selectionForeground=void 0),Ut.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ut.opacity(t.selectionBackgroundTransparent,.3)),Ut.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ut.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Et(e.scrollbarSliderBackground,Ut.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Et(e.scrollbarSliderHoverBackground,Ut.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Et(e.scrollbarSliderActiveBackground,Ut.opacity(t.foreground,.5)),t.overviewRulerBorder=Et(e.overviewRulerBorder,WR),t.ansi=xi.slice(),t.ansi[0]=Et(e.black,xi[0]),t.ansi[1]=Et(e.red,xi[1]),t.ansi[2]=Et(e.green,xi[2]),t.ansi[3]=Et(e.yellow,xi[3]),t.ansi[4]=Et(e.blue,xi[4]),t.ansi[5]=Et(e.magenta,xi[5]),t.ansi[6]=Et(e.cyan,xi[6]),t.ansi[7]=Et(e.white,xi[7]),t.ansi[8]=Et(e.brightBlack,xi[8]),t.ansi[9]=Et(e.brightRed,xi[9]),t.ansi[10]=Et(e.brightGreen,xi[10]),t.ansi[11]=Et(e.brightYellow,xi[11]),t.ansi[12]=Et(e.brightBlue,xi[12]),t.ansi[13]=Et(e.brightMagenta,xi[13]),t.ansi[14]=Et(e.brightCyan,xi[14]),t.ansi[15]=Et(e.brightWhite,xi[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)t.ansi[s+16]=Et(e.extendedAnsi[s],xi[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()}}};Lm=ni([Re(0,on)],Lm);function Et(e,t){if(e!==void 0)try{return Zt.toColor(e)}catch{}return t}var FR=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},qR=class{constructor(){this._services=new FR,this._services.set(jg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=HT(e).sort((c,h)=>c.index-h.index),s=[];for(let c of r){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(h)}let o=r.length>0?r[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},$R={trace:0,debug:1,info:2,warn:3,error:4,off:5},VR="xterm.js: ",Bm=class extends st{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=$R[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":VR)+t,...r)}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)}};Bm=ni([Re(0,on)],Bm);var PS=class extends st{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new xe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new xe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new xe),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){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+r.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<r.length;s++)this._array[this._getCyclicIndex(e+s)]=r[s];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let s=this._length+r.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let o=t-1;o>=0;o--)this.set(e+o+r,this.get(e+o));let s=e+t+r-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+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},rt=3,vi=Object.freeze(new xc),$u=0,vp=2,$o=class C1{constructor(t,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*rt);let o=r||tr.fromCharData([0,Kw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let r=this._data[t*rt+0],s=r&2097151;return[this._data[t*rt+1],r&2097152?this._combined[t]:s?Is(s):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,r){this._data[t*rt+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*rt+0]=t|2097152|r[2]<<22):this._data[t*rt+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*rt+0]>>22}hasWidth(t){return this._data[t*rt+0]&12582912}getFg(t){return this._data[t*rt+1]}getBg(t){return this._data[t*rt+2]}hasContent(t){return this._data[t*rt+0]&4194303}getCodePoint(t){let r=this._data[t*rt+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*rt+0]&2097152}getString(t){let r=this._data[t*rt+0];return r&2097152?this._combined[t]:r&2097151?Is(r&2097151):""}isProtected(t){return this._data[t*rt+2]&536870912}loadCell(t,r){return $u=t*rt,r.content=this._data[$u+0],r.fg=this._data[$u+1],r.bg=this._data[$u+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*rt+0]=r.content,this._data[t*rt+1]=r.fg,this._data[t*rt+2]=r.bg}setCellFromCodepoint(t,r,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*rt+0]=r|s<<22,this._data[t*rt+1]=o.fg,this._data[t*rt+2]=o.bg}addCodepointToCell(t,r,s){let o=this._data[t*rt+0];o&2097152?this._combined[t]+=Is(r):o&2097151?(this._combined[t]=Is(o&2097151)+Is(r),o&=-2097152,o|=2097152):o=r|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*rt+0]=o}insertCells(t,r,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length-t){let o=new tr;for(let c=this.length-t-r-1;c>=0;--c)this.setCell(t+r+c,this.loadCell(t+c,o));for(let c=0;c<r;++c)this.setCell(t+c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,r,s){if(t%=this.length,r<this.length-t){let o=new tr;for(let c=0;c<this.length-t-r;++c)this.setCell(t+c,this.loadCell(t+r+c,o));for(let c=this.length-r;c<this.length;++c)this.setCell(c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,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,r,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);t<r&&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),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.setCell(t++,s)}resize(t,r){if(t===this.length)return this._data.length*4*vp<this._data.buffer.byteLength;let s=t*rt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,r)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let h=0;h<o.length;h++){let p=parseInt(o[h],10);p>=t&&delete this._combined[p]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let p=parseInt(c[h],10);p>=t&&delete this._extendedAttrs[p]}}return this.length=t,s*4*vp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*vp<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){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 r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new C1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*rt+0]&4194303)return t+(this._data[t*rt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*rt+0]&4194303||this._data[t*rt+2]&50331648)return t+(this._data[t*rt+0]>>22);return 0}copyCellsFrom(t,r,s,o,c){let h=t._data;if(c)for(let g=o-1;g>=0;g--){for(let f=0;f<rt;f++)this._data[(s+g)*rt+f]=h[(r+g)*rt+f];h[(r+g)*rt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}else for(let g=0;g<o;g++){for(let f=0;f<rt;f++)this._data[(s+g)*rt+f]=h[(r+g)*rt+f];h[(r+g)*rt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=r&&(this._combined[f-r+s]=t._combined[f])}}translateToString(t,r,s,o){r=r??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;r<s;){let h=this._data[r*rt+0],p=h&2097151,g=h&2097152?this._combined[r]:p?Is(p):Us;if(c+=g,o)for(let f=0;f<g.length;++f)o.push(r);r+=h>>22||1}return o&&o.push(r),c}};function YR(e,t,r,s,o,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let b=[e.get(p)];for(;g<e.length&&f.isWrapped;)b.push(f),f=e.get(++g);if(!c&&s>=p&&s<g){p+=b.length-1;continue}let y=0,S=pc(b,y,t),w=1,x=0;for(;w<b.length;){let L=pc(b,w,t),A=L-x,B=r-S,V=Math.min(A,B);b[y].copyCellsFrom(b[w],x,S,V,!1),S+=V,S===r&&(y++,S=0),x+=V,x===L&&(w++,x=0),S===0&&y!==0&&b[y-1].getWidth(r-1)===2&&(b[y].copyCellsFrom(b[y-1],r-1,S++,1,!1),b[y-1].setCell(r-1,o))}b[y].replaceCells(S,r,o);let D=0;for(let L=b.length-1;L>0&&(L>y||b[L].getTrimmedLength()===0);L--)D++;D>0&&(h.push(p+b.length-D),h.push(D)),p+=b.length-1}return h}function XR(e,t){let r=[],s=0,o=t[s],c=0;for(let h=0;h<e.length;h++)if(o===h){let p=t[++s];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,o=t[++s]}else r.push(h);return{layout:r,countRemoved:c}}function GR(e,t){let r=[];for(let s=0;s<t.length;s++)r.push(e.get(t[s]));for(let s=0;s<r.length;s++)e.set(s,r[s]);e.length=t.length}function ZR(e,t,r){let s=[],o=e.map((g,f)=>pc(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<o;){if(o-p<r){s.push(o-p);break}c+=r;let g=pc(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let b=f?r-1:r;s.push(b),p+=b}return s}function pc(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?r-1:r}var x1=class k1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=k1._nextId++,this._onDispose=this.register(new xe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Aa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};x1._nextId=1;var QR=x1,Di={},wa=Di.B;Di[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Di.A={"#":"£"};Di.B=void 0;Di[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Di.C=Di[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Di.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Di.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Di.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Di.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Di.E=Di[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Di.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Di.H=Di[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Di["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var IS=4294967295,US=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=vi.clone(),this.savedCharset=wa,this.markers=[],this._nullCell=tr.fromCharData([0,Kw,1,0]),this._whitespaceCell=tr.fromCharData([0,Us,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new xh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new PS(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 bh),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 bh),this._whitespaceCell}getBlankLine(e,t){return new $o(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>IS?IS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=vi);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 PS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(vi),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)s+=+this.lines.get(h).resize(e,r);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)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 $o(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new $o(e,r)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let h=this.lines.length-o;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=o}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,r);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 r=this._optionsService.rawOptions.reflowCursorLine,s=YR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(vi),r);if(s.length>0){let o=XR(this.lines,s);GR(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let s=this.getNullCell(vi),o=r;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new $o(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(vi),o=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let p=this.lines.get(h);if(!p||!p.isWrapped&&p.getTrimmedLength()<=e)continue;let g=[p];for(;p.isWrapped&&h>0;)p=this.lines.get(--h),g.unshift(p);if(!r){let V=this.ybase+this.y;if(V>=h&&V<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),b=ZR(g,this._cols,e),y=b.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+y):S=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let V=0;V<y;V++){let H=this.getBlankLine(vi,!0);w.push(H)}w.length>0&&(o.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let x=b.length-1,D=b[x];D===0&&(x--,D=b[x]);let L=g.length-y-1,A=f;for(;L>=0;){let V=Math.min(A,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[L],A-V,D-V,V,!0),D-=V,D===0&&(x--,D=b[x]),A-=V,A===0){L--;let H=Math.max(L,0);A=pc(g,H,this._cols)}}for(let V=0;V<g.length;V++)b[V]<e&&g[V].setCell(b[V],s);let B=y-S;for(;B-- >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+y,this.ybase+t-1)}if(o.length>0){let h=[],p=[];for(let D=0;D<this.lines.length;D++)p.push(this.lines.get(D));let g=this.lines.length,f=g-1,b=0,y=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(y&&y.start>f+S){for(let L=y.newLines.length-1;L>=0;L--)this.lines.set(D--,y.newLines[L]);D++,h.push({index:f+1,amount:y.newLines.length}),S+=y.newLines.length,y=o[++b]}else this.lines.set(D,p[f--]);let w=0;for(let D=h.length-1;D>=0;D--)h[D].index+=w,this.lines.onInsertEmitter.fire(h[D]),w+=h[D].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,r=0,s){let o=this.lines.get(e);return o?o.translateToString(t,r,s):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}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 QR(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},JR=class extends st{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new xe),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 US(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new US(!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)}},E1=2,T1=1,Om=class extends st{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,E1),this.rows=Math.max(e.rawOptions.rows||0,T1),this.buffers=this._register(new JR(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=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:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=r.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=r.ybase+r.scrollTop,c=r.ybase+r.scrollBottom;if(r.scrollTop===0){let h=r.lines.isFull;c===r.lines.length-1?h?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(c+1,0,s.clone()),h?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let h=c-o+1;r.lines.shiftElements(o+1,h-1,-1),r.lines.set(c,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Om=ni([Re(0,on)],Om);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:Ch,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},eM=["normal","bold","100","200","300","400","500","600","700","800","900"],tM=class extends st{constructor(e){super(),this._onOptionChange=this._register(new xe),this.onOptionChange=this._onOptionChange.event;let t={...wl};for(let r in e)if(r in t)try{let s=e[r];t[r]=this._sanitizeAndValidateOption(r,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(qt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in wl))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,s)=>{if(!(r in wl))throw new Error(`No option with key "${r}"`);s=this._sanitizeAndValidateOption(r,s),this.rawOptions[r]!==s&&(this.rawOptions[r]=s,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=wl[e]),!iM(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=eM.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 iM(e){return e==="block"||e==="underline"||e==="bar"}function Vo(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=t<=1?e[s]:e[s]&&Vo(e[s],t-1);return r}var KS=Object.freeze({insertMode:!1}),WS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),zm=class extends st{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new xe),this.onData=this._onData.event,this._onUserInput=this._register(new xe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new xe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Vo(KS),this.decPrivateModes=Vo(WS)}reset(){this.modes=Vo(KS),this.decPrivateModes=Vo(WS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.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))}};zm=ni([Re(0,ln),Re(1,Vw),Re(2,on)],zm);var FS={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 yp(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var bp=String.fromCharCode,qS={DEFAULT:e=>{let t=[yp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${bp(t[0])}${bp(t[1])}${bp(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yp(e,!0)};${e.x};${e.y}${t}`}},jm=class extends st{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new xe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(FS))this.addProtocol(s,FS[s]);for(let s of Object.keys(qS))this.addEncoding(s,qS[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,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let s=t/r,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_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,r){if(r){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)}};jm=ni([Re(0,ln),Re(1,Oa),Re(2,on)],jm);var Sp=[[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]],nM=[[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]],ki;function rM(e,t){let r=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=r;)if(o=r+s>>1,e>t[o][1])r=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var sM=class{constructor(){if(this.version="6",!ki){ki=new Uint8Array(65536),ki.fill(1),ki[0]=0,ki.fill(0,1,32),ki.fill(0,127,160),ki.fill(2,4352,4448),ki[9001]=2,ki[9002]=2,ki.fill(2,11904,42192),ki[12351]=1,ki.fill(2,44032,55204),ki.fill(2,63744,64256),ki.fill(2,65040,65050),ki.fill(2,65072,65136),ki.fill(2,65280,65377),ki.fill(2,65504,65511);for(let e=0;e<Sp.length;++e)ki.fill(0,Sp[e][0],Sp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ki[e]:rM(e,nM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),s=r===0&&t!==0;if(s){let o=ka.extractWidth(t);o===0?s=!1:o>r&&(r=o)}return ka.createPropertyValue(0,r,s)}},ka=class sh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new xe,this.onChange=this._onChange.event;let t=new sM;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,r,s=!1){return(t&16777215)<<3|(r&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 r=0,s=0,o=t.length;for(let c=0;c<o;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=o)return r+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:r+=this.wcwidth(f)}let p=this.charProperties(h,s),g=sh.extractWidth(p);sh.extractShouldJoin(p)&&(g-=sh.extractWidth(s)),r+=g,s=p}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},aM=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 $S(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Oo=2147483647,lM=256,D1=class Hm{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>lM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new Hm;if(!t.length)return r;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let c=0;c<o.length;++c)r.addSubParam(o[c]);else r.addParam(o)}return r}clone(){let t=new Hm(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 r=0;r<this.length;++r){t.push(this.params[r]);let s=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}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>Oo?Oo: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>Oo?Oo:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-s>0&&(t[r]=this._subParams.slice(s,o))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[r-1];s[r-1]=~o?Math.min(o*10+t,Oo):t}},zo=[],oM=class{constructor(){this._state=0,this._active=zo,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.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=zo}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=zo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||zo,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Kh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){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&&r-t>0&&this._put(e,t,r)}}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 r=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;s>=0&&(r=this._active[s].end(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=zo,this._id=-1,this._state=0}}},On=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Kh(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},jo=[],cM=class{constructor(){this._handlers=Object.create(null),this._active=jo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=jo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.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=jo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||jo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Kh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;s>=0&&(r=this._active[s].unhook(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=jo,this._ident=0}},Yo=new D1;Yo.addParam(0);var VS=class{constructor(e){this._handler=e,this._data="",this._params=Yo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Yo,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Kh(e,t,r),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(r=>(this._params=Yo,this._data="",this._hitLimit=!1,r));return this._params=Yo,this._data="",this._hitLimit=!1,t}},uM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,s){this.table[t<<8|e]=r<<4|s}addMany(e,t,r,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=r<<4|s}},Jn=160,hM=(function(){let e=new uM(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),r=(p,g)=>t.slice(p,g),s=r(32,127),o=r(0,24);o.push(25),o.push.apply(o,r(28,32));let c=r(0,14),h;e.setDefault(1,0),e.addMany(s,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(r(128,144),h,3,0),e.addMany(r(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,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(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(o,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(Jn,0,2,0),e.add(Jn,8,5,8),e.add(Jn,6,0,6),e.add(Jn,11,0,11),e.add(Jn,13,13,13),e})(),dM=class extends st{constructor(e=hM){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 D1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(qt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new oM),this._dcsParser=this._register(new cM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>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 o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=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 r<<=8,r|=s,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,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,r,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,r){let s=0,o=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let p=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(s!==24&&s!==26,r),h)return h;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],h=this._oscParser.end(s!==24&&s!==26,r),h)return h;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 p=c;p<t;++p){switch(s=e[p],o=this._transitions.table[this.currentState<<8|(s<160?s:Jn)],o>>4){case 2:for(let S=p+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Jn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Jn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Jn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Jn){this._printHandler(e,p,S),p=S-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:p,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&&(h=g[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._preserveStack(3,g,f,o,p),h;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(++p<t&&(s=e[p])>47&&s<60);p--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let b=this._escHandlers[this._collect<<8|s],y=b?b.length-1:-1;for(;y>=0&&(h=b[y](),h!==!0);y--)if(h instanceof Promise)return this._preserveStack(4,b,y,o,p),h;y<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 S=p+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Jn){this._dcsParser.put(e,p,S),p=S-1;break}break;case 14:if(h=this._dcsParser.unhook(s!==24&&s!==26),h)return this._preserveStack(6,[],0,o,p),h;s===27&&(o|=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 S=p+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Jn){this._oscParser.put(e,p,S),p=S-1;break}break;case 6:if(h=this._oscParser.end(s!==24&&s!==26),h)return this._preserveStack(5,[],0,o,p),h;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},fM=/^([\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})$/,pM=/^[\da-f]+$/;function YS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=fM.exec(t);if(r){let s=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/s*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/s*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),pM.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(r*o,r*o+r),16);s[o]=r===1?c<<4:r===2?c:r===3?c>>4:c>>8}return s}}function wp(e,t){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function mM(e,t=16){let[r,s,o]=e;return`rgb:${wp(r,t)}/${wp(s,t)}/${wp(o,t)}`}var gM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Os=131072,XS=10;function GS(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 ZS=5e3,QS=0,_M=class extends st{constructor(e,t,r,s,o,c,h,p,g=new dM){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=s,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new zT,this._utf8Decoder=new jT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=vi.clone(),this._eraseAttrDataInternal=vi.clone(),this._onRequestBell=this._register(new xe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new xe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new xe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new xe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new xe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new xe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new xe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new xe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new xe),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 Pm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:b.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,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:b,data:y})}),this._parser.setDcsHandlerFallback((f,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:b,payload:y})}),this._parser.setPrintHandler((f,b,y)=>this.print(f,b,y)),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(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nh.IND,()=>this.index()),this._parser.setExecuteHandler(nh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new On(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new On(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new On(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new On(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new On(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new On(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new On(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new On(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new On(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new On(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new On(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new On(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 Di)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 VS((f,b)=>this.requestStatusString(f,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),ZS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ZS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,s=this._activeBuffer.x,o=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Os&&(c=this._parseStack.position+Os)}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<Os&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Os))),h||this._dirtyRowTracker.clearRange(),e.length>Os)for(let f=c;f<e.length;f+=Os){let b=f+Os<e.length?f+Os:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(f,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,b),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,o,y,f),this._logSlowResolvingAsync(r),r}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let p=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(p,this._bufferService.rows-1)})}print(e,t,r){let s,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,b=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let S=this._parser.precedingJoinState;for(let w=t;w<r;++w){if(s=e[w],s<127&&c){let A=c[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let x=this._unicodeService.charProperties(s,S);o=ka.extractWidth(x);let D=ka.extractShouldJoin(x),L=D?ka.extractWidth(S):0;if(S=x,h&&this._onA11yChar.fire(Is(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-L>p){if(g){let A=y,B=this._activeBuffer.x-L;for(this._activeBuffer.x=L,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),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&y instanceof $o&&y.copyCellsFrom(A,B,0,L,!1);B<p;)A.setCellFromCodepoint(B++,0,1,b)}else if(this._activeBuffer.x=p-1,o===2)continue}if(D&&this._activeBuffer.x){let A=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-A,s,o);for(let B=o-L;--B>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(f&&(y.insertCells(this._activeBuffer.x,o-L,this._activeBuffer.getNullCell(b)),y.getWidth(p-1)===2&&y.setCellFromCodepoint(p-1,0,1,b)),y.setCellFromCodepoint(this._activeBuffer.x++,s,o,b),o>0)for(;--o;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=S,this._activeBuffer.x<p&&r-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>GS(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new VS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new On(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,r,s=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,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 r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(r,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 r=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(r,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(vi));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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);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 r=e.params[0]||1,s=ka.extractWidth(t),o=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),h=new Uint32Array(c.length*r),p=0;for(let f=0;f<c.length;){let b=c.codePointAt(f)||0;h[p++]=b,f+=b>65535?2:1}let g=p;for(let f=1;f<r;++f)h.copyWithin(g,0,p),g+=p;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.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,wa),this._charsetService.setgCharset(1,wa),this._charsetService.setgCharset(2,wa),this._charsetService.setgCharset(3,wa);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 r;(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"))(r||={});let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:b}=p,y=this._optionsService.rawOptions,S=(D,L)=>(h.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${D};${L}$y`),!0),w=D=>D?1:2,x=e.params[0];return t?x===2?S(x,4):x===4?S(x,w(h.modes.insertMode)):x===12?S(x,3):x===20?S(x,w(y.convertEol)):S(x,0):x===1?S(x,w(s.applicationCursorKeys)):x===3?S(x,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?S(x,w(s.origin)):x===7?S(x,w(s.wraparound)):x===8?S(x,3):x===9?S(x,w(o==="X10")):x===12?S(x,w(y.cursorBlink)):x===25?S(x,w(!h.isCursorHidden)):x===45?S(x,w(s.reverseWraparound)):x===66?S(x,w(s.applicationKeypad)):x===67?S(x,4):x===1e3?S(x,w(o==="VT200")):x===1002?S(x,w(o==="DRAG")):x===1003?S(x,w(o==="ANY")):x===1004?S(x,w(s.sendFocus)):x===1005?S(x,4):x===1006?S(x,w(c==="SGR")):x===1015?S(x,4):x===1016?S(x,w(c==="SGR_PIXELS")):x===1048?S(x,1):x===47||x===1047||x===1049?S(x,w(f===b)):x===2004?S(x,w(s.bracketedPasteMode)):x===2026?S(x,w(s.synchronizedOutput)):S(x,0)}_updateAttrColor(e,t,r,s,o){return t===2?(e|=50331648,e&=-16777216,e|=xc.fromColorRGB([r,s,o])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let s=[0,0,-1,0,0,0],o=0,c=0;do{if(s[c+o]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do s[1]===5&&(o=1),s[c+p+1+o]=h[p];while(++p<h.length&&p+c+1+o<s.length);break}if(s[1]===5&&c+o>=2||s[1]===2&&c+o>=5)break;s[1]&&(o=1)}while(++c+t<e.length&&c+o<s.length);for(let h=2;h<s.length;++h)s[h]===-1&&(s[h]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.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=vi.fg,e.bg=vi.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,r,s=this._curAttrData;for(let o=0;o<t;o++)r=e.params[o],r>=30&&r<=37?(s.fg&=-50331904,s.fg|=16777216|r-30):r>=40&&r<=47?(s.bg&=-50331904,s.bg|=16777216|r-40):r>=90&&r<=97?(s.fg&=-50331904,s.fg|=16777216|r-90|8):r>=100&&r<=107?(s.bg&=-50331904,s.bg|=16777216|r-100|8):r===0?this._processSGR0(s):r===1?s.fg|=134217728:r===3?s.bg|=67108864:r===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):r===5?s.fg|=536870912:r===7?s.fg|=67108864:r===8?s.fg|=1073741824:r===9?s.fg|=2147483648:r===2?s.bg|=134217728:r===21?this._processUnderline(2,s):r===22?(s.fg&=-134217729,s.bg&=-134217729):r===23?s.bg&=-67108865:r===24?(s.fg&=-268435457,this._processUnderline(0,s)):r===25?s.fg&=-536870913:r===27?s.fg&=-67108865:r===28?s.fg&=-1073741825:r===29?s.fg&=2147483647:r===39?(s.fg&=-67108864,s.fg|=vi.fg&16777215):r===49?(s.bg&=-67108864,s.bg|=vi.bg&16777215):r===38||r===48||r===58?o+=this._extractColor(e,o,s):r===53?s.bg|=1073741824:r===55?s.bg&=-1073741825:r===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):r===100?(s.fg&=-67108864,s.fg|=vi.fg&16777215,s.bg&=-67108864,s.bg|=vi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${r}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=vi.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 r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!GS(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(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>XS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>XS&&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=[],r=e.split(";");for(;r.length>1;){let s=r.shift(),o=r.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(JS(c))if(o==="?")t.push({type:0,index:c});else{let h=YS(o);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(r,s):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,o=r.findIndex(c=>c.startsWith("id="));return o!==-1&&(s=r[o].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 r=e.split(";");for(let s=0;s<r.length&&!(t>=this._specialColors.length);++s,++t)if(r[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=YS(r[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}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=[],r=e.split(";");for(let s=0;s<r.length;++s)if(/^\d+$/.exec(r[s])){let o=parseInt(r[s]);JS(o)&&t.push({type:2,index:o})}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,wa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(gM[e[0]],Di[e[1]]||wa),!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=vi.clone(),this._eraseAttrDataInternal=vi.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 tr;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 r=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=h=>(this._coreService.triggerDataEvent(`${pe.ESC}${h}${pe.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return r(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}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Pm=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&&(QS=e,e=t,t=QS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Pm=ni([Re(0,ln)],Pm);function JS(e){return 0<=e&&e<256}var vM=5e7,e0=12,yM=50,bM=class extends st{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 xe),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 r;for(;r=this._writeBuffer.shift();){this._action(r);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>vM)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let h=p=>performance.now()-r>=e0?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(r,p);o.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-r>=e0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>yM&&(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()}},Im=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 p=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(g,p)),this._dataByLinkId.set(g.id,g),g.id}let r=e,s=this._getEntryIdKey(r),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);r.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(r,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Im=ni([Re(0,ln)],Im);var t0=!1,SM=class extends st{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ll),this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onData=this._register(new xe),this.onData=this._onData.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new xe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new xe),this._instantiationService=new qR,this.optionsService=this._register(new tM(e)),this._instantiationService.setService(on,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Om)),this._instantiationService.setService(ln,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Bm)),this._instantiationService.setService(Vw,this._logService),this.coreService=this._register(this._instantiationService.createInstance(zm)),this._instantiationService.setService(Oa,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(jm)),this._instantiationService.setService($w,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ka)),this._instantiationService.setService(UT,this.unicodeService),this._charsetService=this._instantiationService.createInstance(aM),this._instantiationService.setService(IT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Im),this._instantiationService.setService(Yw,this._oscLinkService),this._inputHandler=this._register(new _M(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 bM((t,r)=>this._inputHandler.parse(t,r))),this._register(Zi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new xe),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&&!t0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),t0=!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,E1),t=Math.max(t,T1),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($S.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>($S(this._bufferService),!1))),this._windowsWrappingHeuristics.value=qt(()=>{for(let t of e)t.dispose()})}}},wM={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 CM(e,t,r,s){let o={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?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(o.key=pe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=pe.ESC+"[Z";break}o.key=pe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?pe.ESC+pe.CR:pe.CR,o.cancel=!0;break;case 27:o.key=pe.ESC,e.altKey&&(o.key=pe.ESC+pe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"D":t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"C":t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"A":t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"B":t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=pe.ESC+"[2~");break;case 46:c?o.key=pe.ESC+"[3;"+(c+1)+"~":o.key=pe.ESC+"[3~";break;case 36:c?o.key=pe.ESC+"[1;"+(c+1)+"H":t?o.key=pe.ESC+"OH":o.key=pe.ESC+"[H";break;case 35:c?o.key=pe.ESC+"[1;"+(c+1)+"F":t?o.key=pe.ESC+"OF":o.key=pe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=pe.ESC+"[5;"+(c+1)+"~":o.key=pe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=pe.ESC+"[6;"+(c+1)+"~":o.key=pe.ESC+"[6~";break;case 112:c?o.key=pe.ESC+"[1;"+(c+1)+"P":o.key=pe.ESC+"OP";break;case 113:c?o.key=pe.ESC+"[1;"+(c+1)+"Q":o.key=pe.ESC+"OQ";break;case 114:c?o.key=pe.ESC+"[1;"+(c+1)+"R":o.key=pe.ESC+"OR";break;case 115:c?o.key=pe.ESC+"[1;"+(c+1)+"S":o.key=pe.ESC+"OS";break;case 116:c?o.key=pe.ESC+"[15;"+(c+1)+"~":o.key=pe.ESC+"[15~";break;case 117:c?o.key=pe.ESC+"[17;"+(c+1)+"~":o.key=pe.ESC+"[17~";break;case 118:c?o.key=pe.ESC+"[18;"+(c+1)+"~":o.key=pe.ESC+"[18~";break;case 119:c?o.key=pe.ESC+"[19;"+(c+1)+"~":o.key=pe.ESC+"[19~";break;case 120:c?o.key=pe.ESC+"[20;"+(c+1)+"~":o.key=pe.ESC+"[20~";break;case 121:c?o.key=pe.ESC+"[21;"+(c+1)+"~":o.key=pe.ESC+"[21~";break;case 122:c?o.key=pe.ESC+"[23;"+(c+1)+"~":o.key=pe.ESC+"[23~";break;case 123:c?o.key=pe.ESC+"[24;"+(c+1)+"~":o.key=pe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=pe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=pe.DEL:e.keyCode===219?o.key=pe.ESC:e.keyCode===220?o.key=pe.FS:e.keyCode===221&&(o.key=pe.GS);else if((!r||s)&&e.altKey&&!e.metaKey){let h=wM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(p);e.shiftKey&&(g=g.toUpperCase()),o.key=pe.ESC+g}else if(e.keyCode===32)o.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=pe.ESC+p,o.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=pe.US),e.key==="@"&&(o.key=pe.NUL));break}return o}var di=0,xM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new xh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new xh,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((o,c)=>this._getKey(o)-this._getKey(c)),t=0,r=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(s[o]=e[t],t++):s[o]=this._array[r++];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||(di=this._search(t),di===-1)||this._getKey(this._array[di])!==t)return!1;do if(this._array[di]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(di),!0;while(++di<this._array.length&&this._getKey(this._array[di])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,r=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:r[s++]=this._array[o];this._array=r,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&&(di=this._search(e),!(di<0||di>=this._array.length)&&this._getKey(this._array[di])===e))do yield this._array[di];while(++di<this._array.length&&this._getKey(this._array[di])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(di=this._search(e),!(di<0||di>=this._array.length)&&this._getKey(this._array[di])===e))do t(this._array[di]);while(++di<this._array.length&&this._getKey(this._array[di])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let s=t+r>>1,o=this._getKey(this._array[s]);if(o>e)r=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Cp=0,i0=0,kM=class extends st{constructor(){super(),this._decorations=new xM(e=>e?.marker.line),this._onDecorationRegistered=this._register(new xe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new xe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(qt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new EM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let s=0,o=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,o=s+(c.options.width??1),e>=s&&e<o&&(!r||(c.options.layer??"bottom")===r)&&(yield c)}forEachDecorationAtCell(e,t,r,s){this._decorations.forEachByKey(t,o=>{Cp=o.options.x??0,i0=Cp+(o.options.width??1),e>=Cp&&e<i0&&(!r||(o.options.layer??"bottom")===r)&&s(o)})}},EM=class extends Ws{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new xe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new xe),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=Zt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Zt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},TM=1e3,DM=class{constructor(e,t=TM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,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 o=s-this._lastRefreshMs,c=this._debounceThresholdMS-o;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)}},n0=20,kh=class extends st{constructor(e,t,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.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=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new DM(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(`
28
- `))),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(Xe(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(qt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<n0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
29
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===n0+1&&(this._liveRegion.textContent+=am.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 r=this._terminal.buffer,s=r.lines.length.toString();for(let o=e;o<=t;o++){let c=r.lines.get(r.ydisp+o),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(r.ydisp+o+1).toString(),f=this._rowElements[o];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,h)),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 r=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=r.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==s)return;let h,p;if(t===0?(h=r,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=r,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),p.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},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,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(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let o=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let S=g<y.length?y[g]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=o(t),h=o(r);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.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,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};kh=ni([Re(1,jg),Re(2,is),Re(3,ns)],kh);var Um=class extends st{constructor(e,t,r,s,o){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new xe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new xe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(qt(()=>{Aa(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(Xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Xe(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 r=e.composedPath();for(let s=0;s<r.length;s++){let o=r[s];if(o.classList.contains("xterm"))break;if(o.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(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(s,h),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let c=0;c<o.length;c++){let h=o[c],p=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let f=p;f<=g;f++){if(r.has(f)){o.splice(c--,1);break}r.add(f)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(r=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){r=!0,this._handleNewLink(h);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&RM(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,Aa(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:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let s=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,r){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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,r){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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return r<=o&&o<=s}_positionFromMouseEvent(e,t,r){let s=r.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,r,s,o){return{x1:e,y1:t,x2:r,y2:s,cols:this._bufferService.cols,fg:o}}};Um=ni([Re(1,Hg),Re(2,ns),Re(3,ln),Re(4,Gw)],Um);function RM(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 MM=class extends SM{constructor(e={}){super(e),this._linkifier=this._register(new Ll),this.browser=m1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ll),this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new xe),this.onKey=this._onKey.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new xe),this.onBell=this._onBell.event,this._onFocus=this._register(new xe),this._onBlur=this._register(new xe),this._onA11yCharEmitter=this._register(new xe),this._onA11yTabEmitter=this._register(new xe),this._onWillOpen=this._register(new xe),this._setup(),this._decorationService=this._instantiationService.createInstance(kM),this._instantiationService.setService(kc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(yR),this._instantiationService.setService(Gw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(om)),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(qt(()=>{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 r,s="";switch(t.index){case 256:r="foreground",s="10";break;case 257:r="background",s="11";break;case 258:r="cursor",s="12";break;default:r="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Ut.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${mM(o)}${f1.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=bi.toColor(...t.color));else{let c=r;this._themeService.modifyColors(h=>h[c]=bi.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(kh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.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(pe.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 r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(r),c=this._renderService.dimensions.css.cell.width*o,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=h+"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(Xe(this.element,"copy",t=>{this.hasSelection()&&BT(t,this._selectionService)}));let e=t=>OT(t,this.textarea,this.coreService,this.optionsService);this._register(Xe(this.textarea,"paste",e)),this._register(Xe(this.element,"paste",e)),g1?this._register(Xe(this.element,"mousedown",t=>{t.button===2&&fS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Xe(this.element,"contextmenu",t=>{fS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),$g&&this._register(Xe(this.element,"auxclick",t=>{t.button===1&&Uw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Xe(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(Xe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",sm.get()),y1||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(_R,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(is,this._coreBrowserService),this._register(Xe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Rm,this._document,this._helperContainer),this._instantiationService.setService(Wh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Lm),this._instantiationService.setService(Pl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(wh),this._instantiationService.setService(Xw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Nm,this.rows,this.screenElement)),this._instantiationService.setService(ns,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Em,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mm),this._instantiationService.setService(Hg,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Um,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(xm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Am,this.element,this.screenElement,s)),this._instantiationService.setService(WT,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,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(km,this.screenElement)),this._register(Xe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(kh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Sh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&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(Dm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let p,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,p=c.button<3?c.button:3;break;case"mousedown":g=1,p=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,p=4;break;default:return!1}return g===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:p,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(r(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(r(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&r(c)},mousemove:c=>{c.buttons||r(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",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Xe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return r(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Xe(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 h=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!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){Iw(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,r){this._selectionService.setSelection(e,t,r)}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 r=CM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let s=this.rows-1;return this.scrollLines(r.type===2?-s:s),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===pe.ETX||r.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(NM(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(vi));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(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${r};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function NM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var AM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},LM=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 tr)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},r0=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 LM(t)}getNullCell(){return new tr}},BM=class extends st{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new xe),this.onBufferChange=this._onBufferChange.event,this._normal=new r0(this._core.buffers.normal,"normal"),this._alternate=new r0(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)}},OM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,s)=>t(r,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)}},zM=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}},jM=["cols","rows"],Er=0,HM=class extends st{constructor(e){super(),this._core=this._register(new MM(e)),this._addonManager=this._register(new AM),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],r=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(jM.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 OM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new zM(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 BM(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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}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
30
- `,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 sm.get()},set promptLabel(e){sm.set(e)},get tooMuchOutput(){return am.get()},set tooMuchOutput(e){am.set(e)}}}_verifyIntegers(...e){for(Er of e)if(Er===1/0||isNaN(Er)||Er%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Er of e)if(Er&&(Er===1/0||isNaN(Er)||Er%1!==0||Er<0))throw new Error("This API only accepts positive integers")}};class PM{pending=null;accept(t){let r="";for(const s of t)r+=this.acceptChar(s);return r}acceptChar(t){return t===""?this.acceptBackspace():A1.has(t)?this.acceptConsonant(t):L1.has(t)?this.acceptVowel(t):WM(t)&&this.canReplacePendingWith(t)?(this.pending=a0(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(B1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const r=KM.get(`${this.pending.final}${t}`);if(r)return this.pending.final=r,"";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=UM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const r=s0.get(this.pending.final);if(r){this.pending.final=r[0];const c=this.flushPending();return this.pending={initial:r[1],vowel:t},c}const s=this.pending.final,o=l0({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=s0.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 r=a0(t);return r.initial===this.pending.initial&&(!this.pending.vowel||r.vowel===this.pending.vowel)&&(!this.pending.final||r.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=l0(this.pending);return this.pending=null,t}}const Eh=44032,Th=21,kl=28,IM=19*Th*kl,R1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],M1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],N1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],A1=Vg(R1),L1=Vg(M1),B1=Vg(N1),UM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),O1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],KM=new Map(O1),s0=new Map(O1.map(([e,t])=>[t,[e[0],e[1]]]));function Vg(e){return new Map(e.map((t,r)=>[t,r]))}function WM(e){const t=e.codePointAt(0);return t!==void 0&&t>=Eh&&t<Eh+IM}function a0(e){const t=e.codePointAt(0)-Eh,r=Math.floor(t/(Th*kl)),s=Math.floor(t%(Th*kl)/kl),o=t%kl,c={initial:R1[r],vowel:M1[s]};return o===0?c:{...c,final:N1[o]}}function l0(e){if(!e.vowel)return e.initial;const t=A1.get(e.initial),r=L1.get(e.vowel),s=e.final?B1.get(e.final):0;return t===void 0||r===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Eh+(t*Th+r)*kl+s)}const FM=[{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 qM({ctrlActive:e,onCtrl:t,onStandaloneKey:r,onPreserveFocus:s,onHide:o}){function c(h){h.preventDefault(),h.stopPropagation(),s()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.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"}),FM.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>r(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const $M={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function VM(e){return $M[e]}function YM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const z1="--nterminal-viewport-height",j1="--nterminal-keyboard-inset-bottom",H1="data-nterminal-keyboard-visible",$h="data-nterminal-compose-open",Dh="nterminal:viewport-refresh",XM=120;function GM(e=window){const t=e.document.documentElement,r=e.visualViewport,s=iN(e);function o(){Yg(e)}return o(),r?.addEventListener("resize",o),r?.addEventListener("scroll",o),s?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(Dh,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{r?.removeEventListener("resize",o),r?.removeEventListener("scroll",o),s?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(Dh,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(z1),t.style.removeProperty(j1),t.removeAttribute(H1)}}function Yg(e=window){const t=e.document.documentElement,{keyboardInsetBottom:r,keyboardVisible:s}=P1(e),o=ZM(e,s);return o!==null&&o0(t,z1,`${o}px`),o0(t,j1,`${r}px`),QM(t,H1,String(s)),{viewportHeight:o,keyboardInsetBottom:r,keyboardVisible:s}}function P1(e=window){const t=JM(e);return{keyboardInsetBottom:t,keyboardVisible:t>XM}}function ZM(e,t){if((e.document.documentElement.hasAttribute($h)||t)&&Da(e.innerHeight))return e.innerHeight;const r=e.visualViewport?.height;return Da(r)?r:Da(e.innerHeight)?e.innerHeight:null}function Da(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function o0(e,t,r){e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}function QM(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function JM(e){return Math.max(eN(e),tN(e))}function eN(e){const t=e.visualViewport?.height;if(!Da(t)||!Da(e.innerHeight))return 0;const r=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-r))}function tN(e){if(!Da(e.innerHeight))return 0;const r=I1(e)?.boundingRect?.height;return!Da(r)||r>=e.innerHeight*.8?0:Math.round(r)}function I1(e){return e.navigator.virtualKeyboard}function iN(e){const t=I1(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Dc=new Map,mc=new Map,nN=Object.freeze({open:!1,text:""});function rN(e){let t=mc.get(e);return t||(t=new Set,mc.set(e,t)),t}function U1(e){const t=mc.get(e);if(t)for(const r of Array.from(t))r()}function Xg(e){return Dc.get(e)??nN}function sN(e,t){const r=rN(e);return r.add(t),()=>{r.delete(t)}}function aN(e,t){const r=Xg(e);r.open!==t&&(Dc.set(e,{...r,open:t}),U1(e))}function lN(e,t){const r=Xg(e);r.text!==t&&(Dc.set(e,{...r,text:t}),U1(e))}function Vu(e){Dc.delete(e),mc.delete(e)}function c0(){Dc.clear(),mc.clear()}const K1=120,oN="\x1B[200~",cN="\x1B[201~";function u0(e,t){const r=t.stripTrailingLineBreaks===!1?e:Gg(e),s=hN(r);return s?t.bracketedPasteMode?`${oN}${s}${cN}`:s:""}function uN(e){return e==="queue"?" ":"\r"}function Gg(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function hN(e){return e.replace(/\r\n/g,`
31
- `).replace(/\r/g,`
32
- `).replace(/\n/g,"\r")}const dN=420,fN=3e3,h0=650,pN=80,mN=3,ah=new Set;let Rl=null;function gN({terminalId:e,onSubmit:t,queueAvailable:r=!1,disabled:s=!1}){const o=v.useMemo(()=>B=>sN(e,B),[e]),c=v.useMemo(()=>()=>Xg(e),[e]),h=v.useSyncExternalStore(o,c,c),{open:p,text:g}=h,f=v.useRef(null),b=v.useRef(null),y=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!p||!lh()))return vN(e),()=>yN(e)},[p,e]),v.useLayoutEffect(()=>{const B=f.current?.closest(".terminal-pane");if(!B)return;function V(){B?.removeAttribute("data-compose-open"),B?.style.removeProperty("--compose-drawer-panel-height")}if(!p){V();return}const H=b.current;B.setAttribute("data-compose-open","true");function F(){const ve=H?.getBoundingClientRect().height??0;ve>0&&B?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}F();const re=[window.setTimeout(F,0),window.setTimeout(F,180),window.setTimeout(F,260)],ne=window.requestAnimationFrame?.(F)??null,de=typeof ResizeObserver=="function"&&H?new ResizeObserver(F):null;return de&&H&&de.observe(H),()=>{for(const ve of re)window.clearTimeout(ve);ne!==null&&window.cancelAnimationFrame?.(ne),de?.disconnect(),V()}},[p]),v.useEffect(()=>{if(!p){S.current?.(),S.current=null;return}d0(y.current),A()},[p]);function w(B){aN(e,B)}function x(B){lN(e,B)}function D(){_N(f.current),w(!1),f0()}function L(B="send"){if(!(s||!g)){if(t(g,B),x(""),lh()){y.current?.blur(),f0();return}window.setTimeout(()=>y.current?.focus(),K1+20)}}function A(){lh()&&(S.current?.(),S.current=bN())}return m.jsxs("div",{ref:f,className:"compose-drawer","data-open":p?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":p?"true":void 0,tabIndex:p?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:b,className:"compose-drawer-panel","aria-hidden":p?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:p?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:r?"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"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:y,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:p?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:B=>x(B.target.value),onFocus:A,onKeyDown:B=>{if(B.key==="Enter"&&(B.metaKey||B.ctrlKey)){if(B.preventDefault(),B.shiftKey){r&&L("queue");return}L("send");return}B.key==="Escape"&&(B.preventDefault(),D())},placeholder:r?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:p?0:-1,onClick:()=>{x(""),d0(y.current),A()},disabled:!g,children:"Clear"}),r?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:p?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>L("queue"),disabled:s||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:p?0:-1,onClick:()=>L("send"),disabled:s||!g,children:"Send"})]})]})]})}function _N(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function d0(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function lh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function f0(){if(!lh())return;const e=El;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function vN(e){Rl!==null&&(window.clearTimeout(Rl),Rl=null),ah.add(e),document.documentElement.setAttribute($h,"true"),El()}function yN(e){if(ah.delete(e),ah.size>0||Rl!==null){El();return}Rl=window.setTimeout(()=>{if(Rl=null,ah.size>0){El();return}document.documentElement.removeAttribute($h),El()},dN),El()}function bN(){let e=!1,t=null,r=null,s=null,o=0;const c=Date.now(),h=window.visualViewport,p=SN();function g(){t!==null&&(window.clearTimeout(t),t=null),r!==null&&(window.cancelAnimationFrame?.(r),r=null)}function f(){e||(e=!0,g(),h?.removeEventListener("resize",y),h?.removeEventListener("scroll",y),p?.removeEventListener("geometrychange",y))}function b(S){if(!e){if(S<h0&&typeof window.requestAnimationFrame=="function"){r=window.requestAnimationFrame(y);return}t=window.setTimeout(y,pN)}}function y(){if(e)return;g();const S=Yg(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?o+=1:(o=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=fN||w>=h0&&o>=mN){f();return}b(w)}return h?.addEventListener("resize",y),h?.addEventListener("scroll",y),p?.addEventListener("geometrychange",y),y(),f}function El(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Yg()}function SN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function wN(e,t){e.attachCustomKeyEventHandler(c=>{if(CN(c)){const h=p0(e);return h?(c.preventDefault(),c.stopPropagation(),m0(h),!1):!0}return xN(c)?(c.preventDefault(),c.stopPropagation(),kN(e,t),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const s=c=>{const h=p0(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),m0(h)}},o=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const p=Gg(h);c.preventDefault(),c.stopImmediatePropagation(),W1(e,p,t)};return r.addEventListener("copy",s,!0),r.addEventListener("paste",o,!0),{dispose(){r.removeEventListener("copy",s,!0),r.removeEventListener("paste",o,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function CN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function xN(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 kN(e,t){if(navigator.clipboard?.readText)try{const r=await navigator.clipboard.readText();if(!r)return;W1(e,Gg(r),t)}catch{}}function W1(e,t,r){if(t){if(r){r(t);return}e.paste(t)}}function p0(e){return e.hasSelection()?e.getSelection():""}async function m0(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}EN(e)}function EN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",r.style.opacity="0",document.body.appendChild(r),r.focus({preventScroll:!0}),r.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{r.remove(),t?.focus({preventScroll:!0})}}const TN=[4,10,11,12];function DN(e,t){const r=[e.parser.registerCsiHandler({final:"c"},s=>g0(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>g0(s)),e.parser.registerCsiHandler({final:"n"},s=>RN(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>MN(s)),e.parser.registerCsiHandler({final:"t"},s=>NN(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...TN.map(s=>e.parser.registerOscHandler(s,o=>AN(o)))];return{dispose(){for(const s of r)s.dispose()}}}function g0(e){return Vh(e)===0}function RN(e){const t=Vh(e);return t===5||t===6}function MN(e){return Vh(e)===6}function NN(e){const t=Vh(e);return t===14||t===16||t===18}function AN(e){return e.split(";").some(t=>t==="?")}function Vh(e){const t=e[0];return typeof t=="number"?t:0}const Ba=new Map,LN=2*1024*1024,BN=1500,ON=25e3;function zN(e,t){let r=Ba.get(e);r||(r=PN(e),Ba.set(e,r),Yh(r)),r.listeners.add(t);const s=c=>qN(r,c),o=()=>{r.listeners.delete(t)};return{status:r.status,snapshot:r.snapshot,output:r.output.slice(),history:r.history,send:s,detach:o}}function Xo(e){const t=Ba.get(e);t&&($N(t),Ba.delete(e))}function jN(e,t={}){const r=Ba.get(e);if(!r)return!1;r.exited=!1,r.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(r.preserveCachedOutputOnNextSnapshot=!0),r.reconnectTimer!==null&&(window.clearTimeout(r.reconnectTimer),r.reconnectTimer=null),Rc(r);const s=r.socket;return r.socket=null,Ca(r,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),Yh(r),!0}function HN(){for(const e of Ba.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Rc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ca(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Yh(e)}}function xp(){for(const e of Array.from(Ba.keys()))Xo(e)}function PN(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 Yh(e){if(!e.reconnectEnabled)return;Ca(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){Ca(e,"connected");for(const r of e.pendingOut)t.send(JSON.stringify(r));e.pendingOut.length=0,e.isAlive=!0,IN(e)}}),t.addEventListener("message",r=>{if(e.socket!==t)return;const s=typeof r.data=="string"?r.data:"";if(!s)return;let o=null;try{o=JSON.parse(s)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;return}const c=KN(e,o);F1(e,{type:"message",message:c})}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,Rc(e),r.code===1008){e.reconnectEnabled=!1,Ca(e,UN(r.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){Ca(e,"closed");return}Ca(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Yh(e)},BN)}}),t.addEventListener("error",()=>{})}function IN(e){Rc(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)}))}},ON)}function Rc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function UN(e){return e.trim().toLowerCase()==="unauthorized"}function KN(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,WN(e,t.output),kp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((r,s)=>r+s.length,0),kp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,kp(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 WN(e,t){const r=FN(e.output,t);if(r===0)return;const s=t.slice(r);for(const o of s)e.output.push(o),e.outputBytes+=o.length}function FN(e,t){const r=Math.min(e.length,t.length);for(let s=r;s>0;s-=1){let o=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){o=!1;break}if(o)return s}return 0}function kp(e){for(;e.outputBytes>LN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Ca(e,t){e.status!==t&&(e.status=t,F1(e,{type:"status",status:t}))}function F1(e,t){for(const r of Array.from(e.listeners))r(t)}function qN(e,t){const r=e.socket;return r&&r.readyState===WebSocket.OPEN?(r.send(JSON.stringify(t)),!0):((t.type==="input"||t.type==="cancel_scrollback")&&e.pendingOut.push(t),!1)}function $N(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Rc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const VN=[0,50,150,350],YN=2,XN=[300,1200,2500],GN=1e3,ZN=1e5,Km="\x1B[?1049l\x1B[?1047l\x1B[?47l",QN=new Set(["47","1047","1049"]),JN=400,eA=3,tA=3,iA=32,nA=1.42,rA=2,sA=24,aA=240,lA=60,oA=420,cA=6,uA=2,_0=[500,1500,3e3,5e3,8e3],v0=15e3,hA=40,Yu=240,dA=Ti.lazy(()=>zg(()=>import("./TranscriptMarkdownBody-BunI06BW.js"),__vite__mapDeps([2,1])));function y0({terminal:e,serverApi:t,active:r,visible:s=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:b,onAuthClose:y}){const S=v.useSyncExternalStore(xw,Gp,()=>Ea),w=v.useSyncExternalStore(kw,Zp,()=>Nl),x=v.useSyncExternalStore(Ew,Jp,()=>!0),D=v.useSyncExternalStore(Ju,em,()=>!0),L=v.useSyncExternalStore(Ju,tm,()=>!0),A=v.useSyncExternalStore(hg,Fs,()=>Ml),B=v.useSyncExternalStore(_h,()=>vh("history.toggle"),()=>"Alt+H"),V=v.useSyncExternalStore(_h,()=>vh("scrollback.toggle"),()=>"Alt+S"),H=v.useRef(null),F=v.useRef(null),re=v.useRef(null),ne=v.useRef(null),de=v.useRef({onExit:f,onSnapshot:b}),ve=v.useRef(t.createWebSocketUrl),U=v.useRef(y),K=v.useRef(null),W=v.useRef(null),P=v.useRef(null),j=v.useRef(!1),ae=v.useRef(new Map),R=v.useRef([]),Y=v.useRef(null),G=v.useRef(0),Ce=v.useRef(!1),Te=v.useRef(!1),M=v.useRef(!1),Q=v.useRef({terminalId:e.id,enabled:!1}),fe=v.useRef([]),me=v.useRef([]),ge=v.useRef(0),Se=v.useRef(!1),Ee=v.useRef(null),Ne=v.useRef(0),Ue=v.useRef(null),te=v.useRef(null),_e=v.useRef(!1),Ae=v.useRef(!1),we=v.useRef(!1),Me=v.useRef(!1),Ie=v.useRef(null),We=v.useRef(null),ie=v.useRef(!1),ke=v.useRef(!1),De=v.useRef(!1),Le=v.useRef(!1),je=v.useRef(!1),at=v.useRef(!1),Bt=v.useRef(!1),$e=v.useRef(r),St=v.useRef(s),Z=v.useRef(c),Ke=v.useRef(S),le=v.useRef(w),ze=v.useRef(!1),Qe=v.useRef(null),ft=v.useRef(null),$t=v.useRef(!1),Tt=v.useRef(null),[,Ot]=v.useState("connecting"),[Qt,At]=v.useState(!1),[Ri,Wi]=v.useState(null),[gr,Qi]=v.useState(!1),[Mi,vt]=v.useState(null),[Dt,Kt]=v.useState(!1),[Vt,Si]=v.useState(!1),[ri,Lt]=v.useState(!1),[Fi,zt]=v.useState(!1),[wt,Yt]=v.useState(null),[si,Ji]=v.useState(!1),[wn,Ni]=v.useState(()=>lp(e.id)),Cn=!!wt||Go(e.currentCommand),qi=!!wt||Go(e.currentCommand),Wt=e.capabilities?.tmuxScrollback===!0,ai=Wt&&(wn??(qi?L:D)),[Nr,Ha]=v.useState(!1);v.useLayoutEffect(()=>{$e.current=r},[r]),v.useLayoutEffect(()=>{St.current=s},[s]),v.useLayoutEffect(()=>{Z.current=c},[c]),v.useLayoutEffect(()=>{Ke.current=S},[S]),v.useLayoutEffect(()=>{le.current=w},[w]),v.useLayoutEffect(()=>{ze.current=si},[si]),v.useLayoutEffect(()=>{Qe.current=wt},[wt]),v.useLayoutEffect(()=>{$t.current=Cn},[Cn]),v.useLayoutEffect(()=>{const T=Q.current;Te.current=ai,M.current=Wt,Q.current={terminalId:e.id,enabled:ai},k0(H.current,ai),T.terminalId===e.id&&T.enabled&&!ai&&en(),ai||Lt(!1)},[e.id,ai,Wt]),v.useEffect(()=>{Ni(lp(e.id)),G.current=0,Ce.current=!1,Lt(!1),dn()},[e.id]),v.useEffect(()=>Ju(()=>{Ni(lp(e.id))}),[e.id]),v.useEffect(()=>{s&&r&&e.status==="running"&&(Jt(),be())},[r,s,e.status]),v.useEffect(()=>{de.current={onExit:f,onSnapshot:b}},[f,b]),v.useEffect(()=>{ve.current=t.createWebSocketUrl,U.current=y},[t,y]),v.useEffect(()=>{let T=!1,J=null,He=0;const Ye=BA(e.currentCommand),Ge=Go(e.currentCommand);function ut(){J!==null&&(window.clearTimeout(J),J=null)}function fi(Xt){if(T)return;let wi;if(Xt){if(!Ge)return;wi=v0}else if(He<_0.length){if(!Ye)return;wi=_0[He++]}else{if(!Ge)return;wi=v0}J=window.setTimeout(()=>{J=null,Bi()},wi)}async function Bi(){try{const Xt=await t.getTerminalTranscriptSource(e.id);if(T)return;Yt(wi=>wi&&Xt.source&&wi.provider===Xt.source.provider&&wi.sessionId===Xt.source.sessionId?wi:Xt.source),fi(!!Xt.source)}catch(Xt){if(T)return;Ep(Xt)&&Yt(null),fi(!1)}}return Yt(null),e.status!=="running"?()=>{T=!0,ut()}:(Bi(),()=>{T=!0,ut()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const T=wt?`${e.id}:${wt.provider}:${wt.sessionId}`:null,J=ft.current;J!==null&&T!==null&&J!==T&&ze.current&&Ji(!1),ft.current=T},[e.id,wt?.provider,wt?.sessionId]),v.useEffect(()=>{function T(J){if(!$e.current||!St.current||J.isComposing||J.key==="Process"||mA(J.target))return;const He=Mw(J);if(He?.id==="history.toggle"&&Qe.current){J.preventDefault(),J.stopPropagation(),Ji(Ye=>!Ye);return}if(He?.id==="scrollback.toggle"&&M.current){J.preventDefault(),J.stopPropagation(),k();return}}return window.addEventListener("keydown",T,!0),()=>window.removeEventListener("keydown",T,!0)},[]),v.useEffect(()=>{const T=F.current;T&&(T.options.disableStdin=e.status==="exited"),e.status==="exited"&&Ot("closed")},[e.status]),v.useEffect(()=>{const T=F.current;T&&(T.options.fontSize=S,ap(S,le.current).then(()=>{Ke.current===S&&Jt()}))},[S]),v.useEffect(()=>{const T=F.current;T&&(T.options.fontFamily=Xp(w),ap(Ke.current,w).then(()=>{le.current===w&&Jt()}))},[w]),v.useEffect(()=>{const T=F.current;T&&(T.options.theme=b0(A))},[A]),v.useEffect(()=>{const T=H.current;if(!T)return;let J=!1,He=null,Ye=null,Ge=null,ut=null,fi=null,Bi=null,Xt=null;K.current=null,je.current=!1,at.current=!1,Me.current=!1,nt(),rs();const wi=Ke.current,ta=le.current,En=new HM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Xp(ta),fontSize:wi,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:ZN,theme:{...b0(Fs())}}),Mc=new RT;return En.loadAddon(Mc),ut=DN(En),F.current=En,re.current=Mc,ap(wi,ta).then(()=>{if(J)return;En.open(T),k0(T,Te.current),je.current=!0,He=wN(En,se),St.current&&$e.current&&e.status==="running"&&be(),Jt(),fi=WA(T,En,()=>Ke.current*1.2,kn,br=>{Hn(br)},ls,cn,()=>Te.current,cs),Bi=IA(T,En,kn,br=>{Hn(br)},ls,cn,()=>Te.current,cs);const Nc=new PM;Ye=En.onData(br=>{if(Bt.current){const Lc=YM(br);if(Lc){ci(!1),z(Lc);return}}const Ac=Nc.accept(br);Ac&&z(Ac)}),Ge=En.onScroll(br=>{if(ke.current||Le.current||De.current){oi();return}Gs(),dr(En)&&In({scrollToBottom:!0}),kn(),!Te.current&&br<=3&&Hn()}),Xt=new ResizeObserver(()=>{Pn()}),Xt.observe(T),at.current&&(nr(),at.current=!1,Jt()),xn()}),()=>{tn(ne.current,{updateUi:!1}),J=!0,je.current=!1,at.current=!1,nt(),W.current=null,P.current=null,j.current=!1,Ar(),as(),De.current=!1,fi?.(),Bi?.(),Xt?.disconnect(),He?.dispose(),Ye?.dispose(),Ge?.dispose(),ut?.dispose(),En.dispose(),F.current=null,re.current=null}},[e.id]),v.useEffect(()=>{const T=ve.current(e.id),J=zN(T,Wl);return ne.current=J.send,Ot(J.status),J.status==="connected"&&Jt(),J.snapshot&&(de.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),F.current&&(Jt(),ir(J.output,J.history),Jt())),()=>{tn(J.send,{updateUi:!1}),J.detach(),ne.current=null}},[e.id,e.status]);function Wl(T){if(T.type==="status"){Ot(T.status),T.status==="unauthorized"&&U.current?.({source:"terminal-ws-1008",terminalId:e.id}),T.status==="connected"&&Jt();return}Ia(T.message)}function rs(T=[],J=null){fe.current=[],me.current=Xu(T),ge.current=0,Se.current=!1,Ee.current=null,De.current=!1,Ne.current+=1,Ue.current=J,te.current=null,_e.current=!1,Ae.current=!1,we.current=!1,at.current=!1,Tt.current=null,Ie.current=null,ie.current=!1,At(!1),Wi(null),Qi(!1),vt(null),Kt(!1),Si(!1)}function ir(T=[],J=null){rs(T,J),Xs()}function Xs(){if(!F.current||!je.current){at.current=!0;return}at.current=!1,nr()}async function nr(){const T=F.current;if(!T)return;const J=Gu(T,ie.current),He=J?me.current.length:ge.current;await rr(T,{liveOutputLimit:He,scrollToBottom:J}),F.current===T&&oi()}function rr(T,J={}){return new Promise(He=>{De.current=!0,Se.current=!1;const Ye=Ne.current+1;Ne.current=Ye;const Ge=Math.max(0,Math.min(J.liveOutputLimit??me.current.length,me.current.length)),ut=J.historyPages??fe.current,fi=()=>{if(F.current!==T||Ne.current!==Ye){He(!1);return}try{ge.current=Ge,J.scrollToBottom&&un(T)}finally{De.current=!1;const Xt=Zs();Xt?In(Xt):J.applyDeferredSnapshot!==!1&&lr(),He(!0)}},Bi=()=>{if(F.current!==T||Ne.current!==Ye){He(!1);return}T.clear();const Xt=Xu([...ut,...me.current.slice(0,Ge)]);if(Xt.length===0){fi();return}for(let wi=0;wi<Xt.length;wi+=1){const ta=Xt[wi];wi===Xt.length-1?T.write(ta,fi):T.write(ta)}};if(T.buffer.active.type==="alternate"){T.write(Km,Bi);return}Bi()})}async function Hn(T=0){const J=F.current;if(we.current||!J)return;if(Un(J)){oi();return}const He=Ue.current;we.current=!0,At(!0);const Ye=J.buffer.active.viewportY;try{let Ge=!!(He&&!He.hasMore);if(!Ge)try{const ut=await t.getTerminalHistory(e.id,{beforeLine:He?.startLine??0,limit:GN}),fi={startLine:ut.startLine,endLine:ut.endLine,hasMore:ut.hasMore};if(ut.output.length>0){await jt(J,ut.output,Ye,T)&&(Ue.current=fi);return}Ue.current=fi,Ge=!ut.hasMore}catch(ut){Ge=Ep(ut)}if(Ge){if(Un(J)){oi();return}await sr(J,Ye,T)}}catch{}finally{we.current=!1,At(!1)}}async function sr(T,J,He){if(!(_e.current||Ae.current))try{const Ye=te.current,Ge=await t.getTerminalTranscriptHistory(e.id,{...Ye?{cursor:Ye}:{},limit:JN}),ut=Ge.output.map(V1);if(!Ge.source)return;if(ut.length===0){Yt(Ge.source),te.current=Ge.cursor,Ae.current=!Ge.hasMore||!Ge.cursor;return}await jt(T,ut,J,He)&&(Yt(Ge.source),te.current=Ge.cursor,Ae.current=!Ge.hasMore||!Ge.cursor)}catch(Ye){Ep(Ye)&&(_e.current=!0)}}async function jt(T,J,He,Ye){if(Un(T))return oi(),!1;const Ge=[...J,...fe.current],ut=HA(J);return!await rr(T,{liveOutputLimit:ge.current,scrollToBottom:!1,historyPages:Ge,applyDeferredSnapshot:!1})||F.current!==T?!1:(fe.current=Ge,hn(T,Math.max(0,He+ut+Math.min(0,Ye))),ie.current=!dr(T),kn(),!0)}v.useEffect(()=>{const T=window.visualViewport;function J(){document.visibilityState==="visible"&&Jt()}function He(){Jt()}function Ye(){Pn()}function Ge(){Ka()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",He),window.addEventListener("resize",Ye),window.addEventListener(Dh,Ge),T?.addEventListener("resize",Ye),T?.addEventListener("scroll",Ye),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",He),window.removeEventListener("resize",Ye),window.removeEventListener(Dh,Ge),T?.removeEventListener("resize",Ye),T?.removeEventListener("scroll",Ye)}},[e.id]);function Pa(){const T=ve.current(e.id);Me.current=!0,Tt.current=null,Ot("reconnecting"),Jt(),jN(T,{preserveCachedOutputOnNextSnapshot:!0})}function Ia(T){if(T.type==="snapshot"&&T.terminal.id===e.id){de.current.onSnapshot(T.terminal,{notifyCompletion:!1});const He=F.current;if(!He)return;Jt();const Ye=Me.current;if(Me.current=!1,Ye){Ue.current=T.history??Ue.current,oi(),Jt();return}if(ql(He,T.terminal)){Fa(T.output,T.history??null),oi(),Jt();return}ir(T.output,T.history??null),Jt();return}if(T.type==="terminal_updated"&&T.terminal.id===e.id){de.current.onSnapshot(T.terminal,{notifyCompletion:!0});return}if(T.type==="output"&&T.terminalId===e.id){const He=G1(T.data);if(!He)return;me.current.push(He),F.current&&je.current?In({scrollToBottom:!0}):at.current=!0;return}const J=F.current;if(J){if(T.type==="exit"&&T.terminalId===e.id){de.current.onExit(T.exitCode),Ot("closed");return}T.type==="error"&&J.writeln(`\r
33
- [nterminal] ${T.message}`)}}function ar(T=25){if(document.visibilityState==="hidden"||!St.current||ae.current.has(T))return;const J=window.setTimeout(()=>{ae.current.delete(T),!Ua()&&ea()},T);ae.current.set(T,J)}function Pn(){Ua()||xn()}function Ua(){const T=_r();return T&&Wa(T)?(j.current=!0,P.current=T,!0):T&&Fl(T)?(j.current=!1,P.current=null,!0):((!T||!T.composeOpen&&!T.keyboardVisible)&&(j.current=!1,P.current=null),!1)}function Ka(){if(!j.current)return;const T=_r();T&&(T.composeOpen||T.keyboardVisible)||(j.current=!1,P.current=null)}function Wa(T){if(!T.mobileLike||!T.composeOpen&&!T.keyboardVisible)return!1;const J=W.current;return J?li(T.windowWidth,J.windowWidth)&&li(T.visualViewportWidth,J.visualViewportWidth)&&li(T.containerWidth,J.containerWidth):!1}function Fl(T){if(!T.mobileLike||T.composeOpen||T.keyboardVisible)return!1;const J=P.current;return!J||!J.composeOpen&&!J.keyboardVisible?!1:li(T.windowWidth,J.windowWidth)&&li(T.visualViewportWidth,J.visualViewportWidth)&&li(T.containerWidth,J.containerWidth)}function _r(){const T=H.current;if(!T||T.isConnected===!1)return null;const J=T.getBoundingClientRect(),He=Li(window.innerWidth)??0,Ye=Li(window.visualViewport?.width)??He,Ge=Li(J.width)??Li(T.clientWidth)??He;if(He<=0||Ye<=0||Ge<=0)return null;const{keyboardVisible:ut}=P1(),fi=document.documentElement.hasAttribute($h),Bi=ss()||ut;return{windowWidth:He,visualViewportWidth:Ye,containerWidth:Ge,composeOpen:fi,keyboardVisible:ut,mobileLike:Bi}}function ss(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Li(T){return typeof T=="number"&&Number.isFinite(T)&&T>0?T:null}function li(T,J){return Math.abs(T-J)<=YN}function xn(){for(const T of VN)ar(T)}function Jt(){K.current=null,xn()}function nt(){for(const T of ae.current.values())window.clearTimeout(T);ae.current.clear()}function Ar(){for(const T of R.current)window.clearTimeout(T);R.current=[]}function kn(){if(oi(),!Ie.current){Qi(!1);return}Qi(!0),as(),We.current=window.setTimeout(()=>{We.current=null,Qi(!1)},1200)}function oi(){const T=F.current,J=T?PA(T):null;if(Ie.current=J,Wi(J),Si(!!(T&&J)),Kt(!!(T&&J&&!dr(T))),J||!T||!$i()){vt(null);return}vt({alternate:T.buffer.active.type==="alternate"})}function $i(){const T=Ue.current;return fe.current.length>0||!!T?.hasMore}function as(){We.current!==null&&(window.clearTimeout(We.current),We.current=null)}function Gs(){const T=F.current;T&&(ie.current=!dr(T),oi())}function Lr(T){Ee.current=Tp(Ee.current,T)}function vr(T){const J=Ee.current;return Ee.current=null,Tp(J,T)}function Zs(){const T=Ee.current;return Ee.current=null,T}function In(T={}){const J=F.current;if(!J||!je.current){at.current=!0;return}if(De.current){Lr(T);return}if(Se.current){Lr(T);return}const He=vr(T);if(!He.force&&!Gu(J,ie.current)){oi();return}Se.current=!0;const Ye=Ne.current,Ge=()=>{if(F.current!==J||Ne.current!==Ye){Se.current=!1;return}if(!He.force&&!Gu(J,ie.current)){Se.current=!1,oi();return}const ut=ge.current,fi=me.current[ut];if(fi===void 0){Se.current=!1,He.scrollToBottom&&un(J),oi();const Bi=Zs();Bi?In(Tp(He,Bi)):lr();return}J.write(fi,()=>{if(F.current!==J||Ne.current!==Ye){Se.current=!1;return}ge.current=ut+1,Ge()})};Ge()}function Un(T){return!dr(T)&&(Qs()||Se.current||De.current)}function ql(T,J){return($t.current||Go(J?.currentCommand))&&!dr(T)}function Qs(){return ge.current<me.current.length}function Fa(T,J){Tt.current={output:T,history:J,appendFromLiveOutputIndex:ge.current}}function lr(){const T=F.current,J=Tt.current;if(!T||!J||!dr(T)||Qs()||Se.current||De.current)return;const He=Xu(J.output),Ye=Xu(me.current.slice(J.appendFromLiveOutputIndex));Tt.current=null,ir(jA(He,Ye),J.history),Jt()}function ls(){Le.current=!0}function cn(){Gs(),Le.current=!1;const T=F.current;T&&dr(T)&&In({scrollToBottom:!0})}function un(T){os(()=>E0(T))&&(ie.current=!1)}function hn(T,J){os(()=>(T.scrollToLine(J),!0))}function os(T){ke.current=!0;try{return T()}finally{ke.current=!1}}function Js(){const T=F.current;if(!T)return;const J=()=>{Te.current&&(us(ne.current),Lt(!1)),E0(T),ie.current=!1,oi(),In({force:!0,scrollToBottom:!0}),be()};if(T.buffer.active.type==="alternate"){T.write(Km,J);return}J()}function or(T){const J=F.current,He=H.current;if(!J||!He)return;const Ye=He.getBoundingClientRect();if(Ye.height<=0)return;const Ge=Math.max(0,Math.min(1,(T-Ye.top)/Ye.height)),ut=Math.round(J.buffer.active.baseY*Ge);ls();try{J.scrollToLine(ut)}finally{cn()}ie.current=!dr(J),oi(),kn(),ut<=3&&Hn()}function yr(T){T.preventDefault(),T.stopPropagation(),T.currentTarget.setPointerCapture?.(T.pointerId),or(T.clientY)}function qa(T){(T.buttons&1)!==0&&(T.preventDefault(),T.stopPropagation(),or(T.clientY))}function ea(){const T=F.current,J=re.current;if(!(!T||!J)&&!(document.visibilityState==="hidden"||!St.current||H.current?.isConnected===!1))try{const He=Gu(T,ie.current),Ye=_r();J.fit(),Ye&&(W.current=Ye),He&&un(T),T.refresh(0,Math.max(0,T.rows-1)),oi();const Ge={cols:T.cols,rows:T.rows},ut=K.current;if(ut&&ut.cols===Ge.cols&&ut.rows===Ge.rows)return;Br({type:"resize",terminalId:e.id,cols:Ge.cols,rows:Ge.rows})&&(K.current=Ge)}catch{}}function Br(T){const J=ne.current;return J?J(T):!1}function dn(){Y.current!==null&&(window.clearTimeout(Y.current),Y.current=null)}function fn(){dn();const T=Math.max(-Yu,Math.min(Yu,G.current));if(G.current=0,T===0)return!1;const J=Br({type:"scrollback_scroll",terminalId:e.id,lines:T});return J&&(Ce.current=!0,T<0&&Lt(!0)),J}function cs(T){if(!Te.current||T===0)return;const J=G.current+T;G.current=Math.max(-Yu,Math.min(Yu,J)),Y.current===null&&(Y.current=window.setTimeout(()=>{Y.current=null,fn()},hA))}function en(){us(ne.current)}function tn(T=ne.current,J={}){const He=Ce.current;dn(),G.current=0,Ce.current=!1,J.updateUi!==!1&&Lt(!1),He&&T?.({type:"cancel_scrollback",terminalId:e.id})}function us(T){dn(),G.current=0,Ce.current=!1,Lt(!1),T?.({type:"cancel_scrollback",terminalId:e.id})}function k(){if(!M.current)return;const T=!Te.current;Ni(P2(e.id,T)),E()}function E(){const T=F.current;T&&(un(T),oi())}function z(T){fn();const J=Ce.current;Ce.current=!1,J&&Lt(!1),In({force:!0,scrollToBottom:!0}),Br({type:"input",terminalId:e.id,data:T,...J?{cancelScrollbackMode:!0}:{}})&&AA(T)&&ce()}function se(T){const J=u0(T,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&z(J)}function ye(T,J){const He=u0(T,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});He&&z(He),window.setTimeout(()=>z(uN(J)),K1)}function ce(){!Z.current||!$e.current||(Ar(),R.current=XN.map(T=>{const J=window.setTimeout(()=>{R.current=R.current.filter(He=>He!==J),Z.current&&$e.current&&Br({type:"refresh_cwd",terminalId:e.id})},T);return J}))}function be(){ze.current||F.current?.focus()}const qe=v.useCallback(()=>{Ji(!1)},[]);function et(){zt(T=>{const J=!T;return Bt.current=J,J}),be()}function ci(T){Bt.current=T,zt(T)}function Ht(T){Bt.current&&ci(!1),z(VM(T)),be()}return m.jsxs("section",{className:"terminal-pane","data-active":r,"data-tmux-scrollback":ai?"true":"false",onMouseDown:()=>{r||p()},children:[m.jsx(gA,{terminal:e,canClose:o,tabId:h,transcriptSource:wt,transcriptShortcutLabel:B,scrollbackShortcutLabel:V,tmuxScrollbackSupported:Wt,tmuxScrollbackEnabled:ai,onToggleTmuxScrollback:k,onOpenTranscript:()=>Ji(!0),onReload:Pa,onClose:g}),m.jsx("div",{className:"xterm-container",ref:H}),Qt?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,x&&!ai&&Ri?m.jsxs("div",{className:"terminal-scroll-progress","data-active":gr,"aria-hidden":"true",children:[Ri.current,"/",Ri.total]}):x&&!ai&&Mi?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Mi.alternate?"alternate":"normal","aria-hidden":"true",children:[Mi.alternate?"alt ":"","0/?"]}):null,Dt||ai&&ri?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),Js()},children:"↓"}):null,Vt&&!ai?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:yr,onPointerMove:qa,children:m.jsx("span",{"aria-hidden":"true"})}):null,r&&e.status==="running"?Nr?m.jsx(qM,{ctrlActive:Fi,onCtrl:et,onStandaloneKey:Ht,onPreserveFocus:be,onHide:()=>Ha(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:T=>{T.stopPropagation(),be()},onPointerDown:T=>{T.stopPropagation(),be()},onClick:()=>Ha(!0),children:"⌨"}):null,m.jsx(gN,{terminalId:e.id,onSubmit:ye,queueAvailable:wt?.provider==="codex"||$1(e.currentCommand),disabled:e.status!=="running"}),si&&wt?m.jsx(_A,{terminalId:e.id,serverApi:t,source:wt,fontSize:S,onClose:qe}):null]})}function b0(e){return Lk(e)}function fA(e,t,r){const s=pA(e,t),o=S0(s*Math.max(1,r),lA,oA);return{limit:S0(Math.ceil(o/rA),sA,aA),maxLines:o}}function pA(e,t){const r=e?.clientHeight??0;if(r<=0)return iA;const s=Math.max(10,t*nA);return Math.max(1,Math.floor(r/s))}function S0(e,t,r){return Math.max(t,Math.min(r,Math.floor(e)))}function mA(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function gA({terminal:e,canClose:t,tabId:r,transcriptSource:s,transcriptShortcutLabel:o,scrollbackShortcutLabel:c,tmuxScrollbackSupported:h,tmuxScrollbackEnabled:p,onToggleTmuxScrollback:g,onOpenTranscript:f,onReload:b,onClose:y}){const S=hw({id:`pane-${e.id}`,disabled:!r,...r?{data:{kind:"pane",sourceTabId:r,terminalId:e.id}}:{}}),w={cursor:r?"grab":"default",opacity:S.isDragging?.5:void 0};return m.jsxs("header",{ref:S.setNodeRef,className:"terminal-pane-header",style:w,"data-dragging":S.isDragging,...S.attributes,...S.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),s?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Rh(s.provider)} transcript history`,"aria-label":`View ${Rh(s.provider)} transcript history`,onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),f()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:o})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),h&&e.status==="running"?m.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":p?"true":"false","aria-pressed":p,"aria-label":`Toggle tmux scrollback (${c})`,title:p?`Scroll input uses tmux scrollback (${c}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${c}).`,onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),g()},children:[p?m.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.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"}),m.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"})]}):m.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.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"}),m.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),m.jsx("kbd",{children:c})]}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),b()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),y()},children:"x"}):null]})}const _A=Ti.memo(function({terminalId:t,serverApi:r,source:s,fontSize:o,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),S=v.useRef(null),w=v.useRef(null),[x,D]=v.useState([]),[L,A]=v.useState(!1),[B,V]=v.useState(""),[H,F]=v.useState(-1),[re,ne]=v.useState(!1),[de,ve]=v.useState(-1),[U,K]=v.useState(null),[W,P]=v.useState(null),[j,ae]=v.useState(!1),[R,Y]=v.useState(!0),[G,Ce]=v.useState(!1),[Te,M]=v.useState(null);v.useEffect(()=>{function le(ze){ze.key==="Escape"&&(ze.preventDefault(),ze.stopPropagation(),c())}return document.addEventListener("keydown",le,!0),()=>document.removeEventListener("keydown",le,!0)},[c]),v.useEffect(()=>{p.current+=1;const le=p.current;return g.current=!1,f.current=!0,b.current=null,S.current=null,w.current=null,D([]),P(null),ae(!1),M(null),F(-1),ve(-1),K(null),Le(null,"initial",le),()=>{p.current===le&&(p.current+=1)}},[r,L,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const le=h.current;if(!le)return;if(f.current){if(R||x.length===0)return;f.current=!1;const Qe=()=>{le.scrollTop=le.scrollHeight};Qe(),window.requestAnimationFrame?.(Qe);return}const ze=b.current;ze!==null&&(b.current=null,le.scrollTop+=le.scrollHeight-ze)},[x,R,L]);const Q=Rh(s.provider),fe=x0(x,L),me=bA(fe),ge=xA(me),Se=ge.map(le=>le.key).join(""),Ee=U?ge.find(le=>le.key===U)?.entryIndex??null:null,Ne=B.trim().length>0,Ue=CA(me,B),te=Ue.length,_e=te>0?H>=0&&H<te?H:0:-1,Ae=_e>=0?Ue[_e]?.entryIndex??null:null,we=_e>=0?Ue[_e]??null:null,Me=Ne?Ae:Ee,Ie=Ne?Ae===null?null:"search":Ee===null?null:"prompt",We=fe?fe.split(`
34
- `).length-1:0,ie=ge.length>0&&de>=0&&de<ge.length?de:ge.length-1,ke=U??(ie>=0?ge[ie]?.key??null:null),De=Ne?te>0?`${_e+1}/${te} ${te===1?"match":"matches"} · ${We} ${We===1?"line":"lines"}`:`0 matches · ${We} ${We===1?"line":"lines"}`:ge.length>0?`${ie+1}/${ge.length} prompts · ${We} ${We===1?"line":"lines"}`:`0 prompts · ${We} ${We===1?"line":"lines"}`;v.useEffect(()=>{const le=B.trim().toLowerCase();F(ze=>!le||te===0?-1:y.current!==le?0:ze>=0&&ze<te?ze:0),y.current=le},[B,te]),v.useEffect(()=>{if(Ne){K(null);return}U&&!ge.some(le=>le.key===U)&&K(null),ve(le=>{if(ge.length===0)return w.current=null,-1;const ze=w.current?ge.findIndex(ft=>ft.key===w.current):-1,Qe=ze>=0?ze:le>=0&&le<ge.length?le:ge.length-1;return w.current=ge[Qe]?.key??null,Qe})},[U,Ne,Se]),v.useEffect(()=>{const le=S.current;if(!le||ge.length===0)return;S.current=null;const ze=le.anchorKey?ge.findIndex(ft=>ft.key===le.anchorKey):-1,Qe=ze>0?ze-1:0;St(Qe)},[Se]);async function Le(le,ze,Qe=p.current){if(!g.current){g.current=!0,ze==="initial"?Y(!0):(Ce(!0),b.current=h.current?.scrollHeight??null),M(null);try{await je(le,ze,Qe)}catch(ft){if(p.current!==Qe)return;M(ft instanceof Error?ft.message:"Failed to load transcript history.")}finally{p.current===Qe&&(g.current=!1,Y(!1),Ce(!1))}}}async function je(le,ze,Qe){let ft=le,$t=0,Tt=[];const Ot=ze==="initial"&&s.provider!=="claude"?uA:cA;for(;p.current===Qe;){const Qt=await r.getTerminalTranscriptHistory(t,{...ft?{cursor:ft}:{},...fA(h.current,o,ze==="initial"?eA:tA),includeTools:L});if(p.current!==Qe)return;const At=C0(Qt.output,s.provider,{includeTools:L}),Ri=at(Qt,ze,Tt,At);if(At&&(Tt=[At,...Tt],Ri))return;if(!Qt.hasMore||!Qt.cursor||$t>=Ot){Tt.length>0&&D(Wi=>ze==="older"?[...Tt,...Wi]:Tt);return}ft=Qt.cursor,$t+=1}}function at(le,ze,Qe,ft=C0(le.output,s.provider,{includeTools:L})){if(P(le.cursor),ae(!!(le.hasMore&&le.cursor)),!ft)return!1;const $t=[ft,...Qe];return x0($t,L)?(D(Tt=>ze==="older"?[...$t,...Tt]:$t),!0):!1}function Bt(){const le=h.current;le&&(Ke(),!(le.scrollTop>72||!j||!W||g.current)&&Le(W,"older"))}function $e(le){te!==0&&F(ze=>{const Qe=_e>=0?_e:le>0?-1:0;return((ze>=0&&ze<te?ze:Qe)+le+te)%te})}function St(le){const ze=ge[le];ze&&(w.current=ze.key,ve(le),K(ze.key))}async function Z(le){if(ge.length===0){le<0&&j&&W&&!g.current&&(S.current={anchorKey:null},await Le(W,"older"));return}const Qe=(de>=0&&de<ge.length?de:le<0?ge.length-1:-1)+le;if(Qe>=0&&Qe<ge.length){St(Qe);return}le<0&&Qe<0&&j&&W&&!g.current&&(S.current={anchorKey:ge[0]?.key??null},await Le(W,"older"))}function Ke(){if(Ne)return;const le=h.current;if(!le)return;const Qe=le.getBoundingClientRect().top+Math.min(140,Math.max(48,le.clientHeight*.28));let ft=null;for(const $t of RA(le)){const Tt=MA($t);if(Tt!==null)if($t.getBoundingClientRect().top<=Qe)ft=Tt;else break}if(ft!==null){const $t=ge[ft]?.key??null;w.current=$t,ve(ft),U&&U!==$t&&K(null)}}return m.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:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:le=>le.stopPropagation(),onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[Q," JSONL"]}),m.jsx("span",{title:s.sessionId,children:s.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:L,onChange:le=>A(le.currentTarget.checked)}),"Show tool output"]}),m.jsx("label",{className:"transcript-search",children:m.jsx("input",{type:"search",value:B,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:le=>V(le.currentTarget.value),onKeyDown:le=>{le.key==="Enter"&&(le.preventDefault(),Ne?$e(le.shiftKey?-1:1):Z(le.shiftKey?-1:1))}})}),m.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":re,"aria-label":"Toggle prompt list",onClick:()=>ne(le=>!le),disabled:ge.length===0,children:"List"}),m.jsxs("div",{className:"transcript-search-actions","aria-label":Ne?"Search result navigation":"Prompt navigation",children:[m.jsx("button",{type:"button",onClick:()=>Ne?$e(-1):void Z(-1),disabled:Ne?te===0:ge.length===0&&!j,"aria-label":Ne?"Previous search match":"Previous user prompt",title:Ne?"Previous search match":"Previous user prompt",children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>Ne?$e(1):void Z(1),disabled:Ne?te===0:ge.length===0,"aria-label":Ne?"Next search match":"Next user prompt",title:Ne?"Next search match":"Next user prompt",children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:De})]}),re?m.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:ge.length>0?ge.map((le,ze)=>m.jsxs("button",{type:"button",className:ke===le.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>St(ze),children:[m.jsx("span",{children:le.timestampLabel}),m.jsx("strong",{children:le.snippet})]},`${le.key}:${ze}`)):m.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Bt,children:[G?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&j?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,fe?m.jsx(vA,{entries:me,searchQuery:B,activeEntryIndex:Me,activeEntryMode:Ie,activeSearchMatch:we,fontSize:o}):null,R?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!R&&!fe&&!Te?j&&W?m.jsxs("div",{className:"transcript-dialog-status",children:[L?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{Le(W,"older")},disabled:G,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,Te?m.jsx("div",{className:"transcript-dialog-error",children:Te}):null]})]})})});function vA({entries:e,searchQuery:t,activeEntryIndex:r,activeEntryMode:s,activeSearchMatch:o,fontSize:c}){const h=v.useRef(new Map);v.useEffect(()=>{if(r===null)return;const g=h.current.get(r);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===r?f[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[r,s,o,t]);let p=-1;return m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const b=g.kind==="user"?++p:null,y=r===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return m.jsxs("section",{ref:S=>{S?h.current.set(f,S):h.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${y}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...b!==null?{"data-transcript-prompt-position":b}:{},children:[g.header?m.jsx("div",{className:"transcript-entry-header",children:q1(g.header,t)}):null,g.body?m.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?m.jsx(w0,{text:g.body,searchQuery:t}):m.jsx(Ti.Suspense,{fallback:m.jsx(w0,{text:g.body,searchQuery:t}),children:m.jsx(dA,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function w0({text:e,searchQuery:t}){const r=e.endsWith(`
35
- `)?e.slice(0,-1).split(`
36
- `):e.split(`
37
- `);return m.jsx("pre",{className:"transcript-entry-pre",children:r.map((s,o)=>m.jsx("span",{className:`transcript-line transcript-line-${NA(s,o===0||r[o-1]?.trim()==="")}`,children:q1(s,t)},o))})}function q1(e,t){const r=t.trim();if(!r)return e||" ";const s=e.toLowerCase(),o=r.toLowerCase(),c=[];let h=0,p=s.indexOf(o);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+r.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=s.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function yA(e,t){const r=t.trim().toLowerCase();if(!r)return 0;const s=e.toLowerCase();let o=0,c=s.indexOf(r);for(;c!==-1;)o+=1,c=s.indexOf(r,c+r.length);return o}function bA(e){const t=e.endsWith(`
38
- `)?e.slice(0,-1):e;if(!t)return[];const r=[];let s=null,o="plain",c=[];function h(){const p=SA(c).join(`
39
- `);(s||p)&&r.push({header:s,body:p,kind:o}),s=null,o="plain",c=[]}for(const p of t.split(`
40
- `)){const g=wA(p);g?(h(),s=p,o=g):c.push(p)}return h(),r}function SA(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function wA(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const r=t[1]??"";return r==="User"?"user":r==="Codex"||r==="Claude"?"assistant":r==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(r)?"tool":null}function CA(e,t){const r=[];for(let s=0;s<e.length;s+=1){const o=e[s];if(!o)continue;const c=o.header?`${o.header}
41
- ${o.body}`:o.body,h=yA(c,t);for(let p=0;p<h;p+=1)r.push({entryIndex:s,matchIndexInEntry:p})}return r}function xA(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:kA(c),entry:c,entryIndex:o})}const r=new Map,s=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const h=r.get(c.contentKey)??0;r.set(c.contentKey,h+1),s.set(o,JSON.stringify([c.contentKey,h]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:s.get(c)??JSON.stringify([o.contentKey,0]),snippet:TA(o.entry.body),timestampLabel:DA(o.entry.header)}))}function kA(e){return JSON.stringify([e.header??"",e.body.length,EA(e.body)])}function EA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function TA(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function DA(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function RA(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function MA(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const r=Number(t);return Number.isInteger(r)&&r>=0?r:null}function NA(e,t){const r=e.trim();if(!r)return"blank";const s=r.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(r);return(o||t)&&/^User$/.test(s)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(o||t)&&/^System$/.test(s)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||X1(r))?"tool":/^(?:\$|>|❯|➜)\s+/.test(r)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(r)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(r)?"error":/^\[[^\]]+\]/.test(r)||/^(?:info|debug|warn)\b/i.test(r)?"dim":"plain"}function AA(e){return e.includes("\r")||e.includes(`
42
- `)}function Ep(e){return e instanceof fr&&e.status===404}function Go(e){return $1(e)||LA(e)}function $1(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function LA(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function BA(e){if(Go(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Rh(e){return e==="codex"?"Codex":"Claude"}function C0(e,t,r={}){const s=`[nterminal] ${Rh(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
43
- `).replace(/\r/g,`
44
- `).replace(s,"").replace(/\n{3,}/g,`
45
-
46
- `).trimEnd(),c=V1(o),h=r.includeTools?c:Y1(c);return h?`${h}
47
- `:""}function V1(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,r)=>{const s=OA(r);return s?`[${s}]`:t})}function OA(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const r=t.getFullYear(),s=Ho(t.getMonth()+1),o=Ho(t.getDate()),c=Ho(t.getHours()),h=Ho(t.getMinutes()),p=Ho(t.getSeconds());return`${r}-${s}-${o} ${c}:${h}:${p}`}function Ho(e){return e.toString().padStart(2,"0")}function x0(e,t){return e.map(r=>t?r:Y1(r)).filter(Boolean).map(r=>r.endsWith(`
48
- `)?r:`${r}
49
- `).join("")}function Y1(e){if(!e)return"";const t=e.split(`
50
- `),r=[];let s=!1,o=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?zA(h):null;if(g&&(s=g==="tool",o=!1),X1(h)){o=!0,c=!1;continue}if(o){p?(o=!1,s||r.push(h),c=!0):c=!1;continue}s||r.push(h),c=p}return r.join(`
51
- `).replace(/\n{3,}/g,`
52
-
53
- `).trimEnd()}function zA(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function X1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function jA(e,t){if(t.length===0)return e;let r=0;const s=Math.min(e.length,t.length);for(let o=s;o>0;o-=1){let c=!0;for(let h=0;h<o;h+=1)if(e[e.length-o+h]!==t[h]){c=!1;break}if(c){r=o;break}}return[...e,...t.slice(r)]}function HA(e){let t=0;for(const r of e){if(!r)continue;const s=r.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function Xu(e){const t=[];for(const r of e){const s=G1(r);s&&t.push(s)}return t}function G1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,r,s)=>{const o=r.split(";").filter(Boolean).filter(c=>!QN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${s}`:""})}function Tp(e,t={}){const r={};return(e?.force||t.force)&&(r.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(r.scrollToBottom=!0),r}function PA(e){const t=e.buffer.active,r=t.baseY+e.rows;return r<=e.rows?null:{current:Math.max(1,Math.min(r,t.viewportY+1)),total:r}}function k0(e,t){const r=e?.querySelector(".xterm .xterm-viewport");if(r){if(t){r.dataset.nterminalTmuxScrollHidden="true",r.style.setProperty("overflow-y","hidden","important"),r.style.setProperty("scrollbar-color","transparent transparent","important"),r.style.setProperty("scrollbar-width","none","important"),r.style.setProperty("-ms-overflow-style","none");return}r.dataset.nterminalTmuxScrollHidden==="true"&&(delete r.dataset.nterminalTmuxScrollHidden,r.style.removeProperty("overflow-y"),r.style.removeProperty("scrollbar-color"),r.style.removeProperty("scrollbar-width"),r.style.removeProperty("-ms-overflow-style"))}}function dr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Gu(e,t){return!t||dr(e)}function E0(e){return dr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function IA(e,t,r,s,o,c,h,p){const g=f=>{const b=KA(f);if(b!==0){if(h()){if(qA(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),p(b);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),UA(t,b,r,s,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function UA(e,t,r,s,o,c){const h=()=>{o();try{e.scrollLines(t)}finally{c()}r(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Km,h);return}h()}function KA(e){const r=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(r===0)return 0;const s=r<0?Math.floor(r):Math.ceil(r);return Math.max(-30,Math.min(30,s))}function WA(e,t,r,s,o,c,h,p,g){let f=null,b=0;const y={passive:!1};function S(D){f=Dp(D),b=0}function w(D){const L=Dp(D);if(L===null){f=null,b=0;return}if(f===null){f=L;return}const A=L.clientY-f.clientY;if(f=L,D.cancelable&&D.preventDefault(),A===0)return;if(FA(t)&&$A(t,L,-A)){b=0;return}b-=A/r();const B=b<0?Math.ceil(b):Math.floor(b);if(B!==0){if(b-=B,p()){g(B);return}c();try{t.scrollLines(B)}finally{h()}s(),B<0&&t.buffer.active.viewportY<=3&&o(B)}}function x(D){if(D.touches.length>0){f=Dp(D);return}f=null,b=0}return e.addEventListener("touchstart",S,y),e.addEventListener("touchmove",w,y),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",S,y),e.removeEventListener("touchmove",w,y),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Dp(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function FA(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function qA(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function $A(e,t,r){const s=e.element;return s?(s.dispatchEvent(VA(t,r)),!0):!1}function VA(e,t){const r=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:r};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const o=new Event("wheel",s);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function Wm({node:e,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:S,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,onAuthClose:V}){const H=S??Fm(e);if(y.length===0&&b){const de=qm(e),ve=de.some(U=>U.key===b)?b:de[0]?.key;if(de.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:de.map(U=>{const K=U.key===ve;if(U.type==="editor"){const P=r[U.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:P?m.jsx(uS,{api:s,editor:P,canClose:H>1,onClose:()=>B(U.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},U.key)}const W=t[U.terminalId];return W?m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx(y0,{terminal:W,serverApi:s,active:K,visible:c&&K,canClose:H>1,refreshCwdOnEnter:h&&K,tabId:p,onSelect:()=>w(U.terminalId),onClose:()=>x(U.terminalId),onExit:P=>L(U.terminalId,P),onSnapshot:A,...V?{onAuthClose:V}:{}})},U.key):m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},U.key)})})}if(e.type==="pane"){const de=t[e.terminalId];if(!de)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(y0,{terminal:de,serverApi:s,active:e.terminalId===o,visible:c,canClose:H>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:p,onSelect:()=>w(e.terminalId),onClose:()=>x(e.terminalId),onExit:K=>L(e.terminalId,K),onSnapshot:A,...V?{onAuthClose:V}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(Zu,{terminalId:e.terminalId,side:"top"}),m.jsx(Zu,{terminalId:e.terminalId,side:"right"}),m.jsx(Zu,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Zu,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const de=r[e.editorId];return de?m.jsx(uS,{api:s,editor:de,canClose:H>1,onClose:()=>B(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const F=Math.max(.1,Math.min(.9,e.ratio)),re=1-F,ne=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${F}fr) 1px minmax(0, ${re}fr)`}:{gridTemplateRows:`minmax(0, ${F}fr) 1px minmax(0, ${re}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ne,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Wm,{node:e.first,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,0],totalPanes:H,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,...V?{onAuthClose:V}:{}})}),m.jsx(YA,{direction:e.direction,path:y,onResize:D}),m.jsx("div",{className:"split-cell",children:m.jsx(Wm,{node:e.second,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,1],totalPanes:H,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,...V?{onAuthClose:V}:{}})})]})}function Zu({terminalId:e,side:t}){const{setNodeRef:r,isOver:s}=vg({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:r,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function YA({direction:e,path:t,onResize:r}){function s(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-p.left)/p.width:(b.clientY-p.top)/p.height;r(t,Math.min(.9,Math.max(.1,y)))}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 m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Fm(e){return e.type==="pane"||e.type==="editor"?1:Fm(e.first)+Fm(e.second)}function qm(e){return e.type==="pane"?[{key:XA(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:GA(e.editorId),type:"editor",editorId:e.editorId}]:[...qm(e.first),...qm(e.second)]}function XA(e){return`terminal:${e}`}function GA(e){return`editor:${e}`}const Xh="workspace-default",ZA="NTerminal";function QA(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function JA(e,t){switch(t.type){case"workspace.hydrated":return $m(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return e3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return r3(e,t.workspaceId);case"workspace.selected":return Z1(e,t.workspaceId);case"workspace.renamed":return t3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return i3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return n3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return Q1(e,t.terminal);case"terminal.split":return s3(e,t.terminal,t.direction);case"terminal.updated":return g3(e,t.terminal);case"terminal.exited":return _3(e,t.terminalId,t.exitCode);case"terminal.closed":return tC(e,t.terminalId);case"terminal.detached":return v3(e,t.terminalId,t.workspaceId);case"editor.split":return a3(e,t.editorId,t.title,t.direction);case"editor.closed":return y3(e,t.editorId);case"pane.selected":return p3(e,t.terminalId);case"pane.resized":return m3(e,t.path,t.ratio);case"tab.selected":return o3(e,t.tabId);case"tab.renamed":return f3(e,t.tabId,t.title);case"tab.reordered":return Zg(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return c3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return J1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return eC(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return u3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return l3(e);default:return e}}function e3(e,t){if(e.workspaces.some(s=>s.id===t.id))return Z1(e,t.id);const r={id:t.id,title:t.title,defaultCwd:mr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,r],activeWorkspaceId:r.id}}function Z1(e,t){return e.workspaces.some(r=>r.id===t)?{...e,activeWorkspaceId:t}:e}function t3(e,t,r){const s=r.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===s?h:(o=!0,{...h,title:s}));return o?{...e,workspaces:c}:e}function i3(e,t,r){const s=mr(r);let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===s?h:(o=!0,{...h,defaultCwd:s}));return o?{...e,workspaces:c}:e}function n3(e,t,r,s){if(t===r)return e;const o=e.workspaces.findIndex(y=>y.id===t),c=e.workspaces.findIndex(y=>y.id===r);if(o<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(o,1);if(!p)return e;const g=h.findIndex(y=>y.id===r);if(g<0)return e;const f=s==="before"?g:g+1,b=h.slice();return b.splice(f,0,p),d3(e.workspaces,b)?e:{...e,workspaces:b}}function r3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const r=e.workspaces.find(p=>p.id===t),s=new Set(r?Mh(r):[]),o={...e.terminals};for(const p of s)delete o[p];const c=e.workspaces.filter(p=>p.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:o}}function Q1(e,t){const r=nC(e),s=za(r)??Zh(),o=oC(t);return{...r,activeWorkspaceId:s.id,terminals:{...r.terminals,[t.id]:t},workspaces:r.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??mr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:lC(c,t.id))}}function s3(e,t,r){const s=za(e),o=s?Gh(s):void 0;if(!s||!o)return Q1(e,t);const c=o.activeTerminalId,h=_c(o.root,c,{type:"split",direction:r,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(p=>p.id===s.id?{...p,defaultCwd:p.defaultCwd??mr(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:lC(p,t.id))}}function a3(e,t,r,s){const o=za(e),c=o?Gh(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,p=_c(c.root,h,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:r}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function l3(e){const t=za(e),r=t?Gh(t):void 0;return r?tC(e,r.activeTerminalId):e}function o3(e,t){const r=za(e);return!r||!r.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===r.id?{...s,activeTabId:t}:s)}}function Zg(e,t,r){const s=e.workspaces.map(o=>{const c=o.tabs.findIndex(b=>b.id===t);if(c<0)return o;const h=o.tabs.slice(),[p]=h.splice(c,1);if(!p)return o;const g=Math.max(0,Math.min(h.length,r)),f=h.slice();return f.splice(g,0,p),h3(o.tabs,f)?o:{...o,tabs:f}});return s.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:s}}function c3(e,t,r,s,o){if(r===s||!e.terminals[r]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(x=>x.id===t);if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y=Bl(b.root,r);if(!y){const x=g.tabs.filter((D,L)=>L!==f);return{...g,tabs:x}}const S={...b,root:y,activeTerminalId:Ui(y)[0]??b.activeTerminalId},w=g.tabs.slice();return w[f]=S,{...g,tabs:w}});const h=o==="left"||o==="right"?"vertical":"horizontal",p=o==="left"||o==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>Ui(D.root).includes(s));if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y={type:"pane",terminalId:r},S={type:"split",direction:h,ratio:.5,first:p?y:{type:"pane",terminalId:s},second:p?{type:"pane",terminalId:s}:y},w=_c(b.root,s,S),x=g.tabs.slice();return x[f]={...b,root:w,activeTerminalId:r},{...g,tabs:x,activeTabId:b.id}}),nC({...e,workspaces:c})}function J1(e,t,r,s){let o=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(B=>B.id===t);if(A>=0){o=L,c=A;break}}if(o<0)return e;const h=e.workspaces[o],p=h.tabs[c],g=Ui(p.root);if(!g.includes(r))return e;if(g.length===1)return Zg(e,t,s);const f=Bl(p.root,r);if(!f)return e;const b={...p,root:f,activeTerminalId:Ui(f)[0]??p.activeTerminalId},y=e.terminals[r],S={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:y?.title??"",activeTerminalId:r,root:{type:"pane",terminalId:r}},w=h.tabs.slice();w[c]=b;const x=Math.max(0,Math.min(w.length,s));w.splice(x,0,S);const D=e.workspaces.slice();return D[o]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:D}}function eC(e,t,r,s=Number.MAX_SAFE_INTEGER){const o=rC(e.workspaces,t),c=e.workspaces.find(f=>f.id===r);if(!o||!c)return e;if(o.workspace.id===r)return s===Number.MAX_SAFE_INTEGER?e:Zg(e,t,s);const h=Ui(o.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===o.workspace.id)return ja({...f,tabs:f.tabs.filter(b=>b.id!==t)});if(f.id===r){const b=f.tabs.slice(),y=Math.max(0,Math.min(b.length,s));return b.splice(y,0,o.tab),{...f,defaultCwd:f.defaultCwd??mr(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:b,activeTabId:o.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:r}}function u3(e,t,r,s,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),h=rC(e.workspaces,t);if(!c||!h||!e.terminals[r]||!Ui(h.tab.root).includes(r))return e;if(h.workspace.id===s)return J1(e,t,r,o);if(Ui(h.tab.root).length===1)return eC(e,t,s,o);const g=Bl(h.tab.root,r);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Ui(g)[0]??h.tab.activeTerminalId},b=e.terminals[r],y={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:b.title??r,activeTerminalId:r,root:{type:"pane",terminalId:r}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return ja({...w,tabs:w.tabs.map(x=>x.id===t?f:x)});if(w.id===s){const x=w.tabs.slice(),D=Math.max(0,Math.min(x.length,o));return x.splice(D,0,y),{...w,defaultCwd:w.defaultCwd??mr(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(L=>L!==r),tabs:x,activeTabId:y.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function h3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function d3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function f3(e,t,r){const s=r.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===s?f:(o=!0,p=!0,{...f,title:s}));return p?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function p3(e,t){const r=e.workspaces.find(o=>o.tabs.some(c=>Ol(c.root,t))),s=r?.tabs.find(o=>Ol(o.root,t));return!r||!s?e:{...e,activeWorkspaceId:r.id,workspaces:e.workspaces.map(o=>o.id===r.id?{...o,activeTabId:s.id,tabs:o.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:o)}}function m3(e,t,r){const s=za(e),o=s?Gh(s):void 0;if(!s||!o)return e;const c=Qm(o.root,t,hC(r));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===s.id?{...h,tabs:h.tabs.map(p=>p.id===o.id?{...p,root:c}:p)}:h)}}function $m(e,t,r,s){const o=Object.fromEntries(e.map(y=>[y.id,y])),c=new Set(e.map(y=>y.id)),h=new Set,p=!!(r&&r.some(y=>cC(y))||t&&t.some(y=>uC(y)));let g=b3(t,r,c,h);g.length===0&&(g=[Zh()]);const f=typeof s=="string"&&g.some(y=>y.id===s)?s:g[0]?.id??null,b=f??g[0]?.id??Xh;for(const y of e)if(!h.has(y.id)){if(p)g=C3(g,b,y.id,y);else{const S=oC(y);g=k3(g,b,S,y)}h.add(y.id)}return{workspaces:g.map(y=>ja(x3(y,o))),activeWorkspaceId:f,terminals:o}}function gc(e){return Ui(e.root)}function Vm(e){return Jm(e.root)}function Mh(e){return Qg([...e.tabs.flatMap(t=>Ui(t.root)),...e.detachedTerminalIds])}function Rp(e){const t=e.workspaces.map(r=>{const s=r.tabs.flatMap(o=>{const c=Gm(o.root);return c?[{...o,root:c}]:[]});return ja({...r,tabs:s})});return{activeWorkspaceId:t.some(r=>r.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function g3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(r=>({...r,tabs:r.tabs.map(s=>Ol(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function _3(e,t,r){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:r}}}:e}function tC(e,t){const r={...e.terminals};return delete r[t],iC(e,t,r)}function v3(e,t,r){if(!e.terminals[t])return e;const s=(r&&e.workspaces.some(c=>c.id===r)?r:null)??S3(e,t)?.id??w3(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Xh,o=e.workspaces.find(c=>c.id===s);return!o||!aC(o,t)?e:iC(e,t,{...e.terminals},{detachToWorkspaceId:s})}function iC(e,t,r,s={}){let o=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=Bl(g.root,t);if(!f)continue;const b=Ui(f),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&p.push({...g,root:f,activeTerminalId:y})}return ja({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});s.detachToWorkspaceId&&r[t]&&(o=o.map(h=>h.id===s.detachToWorkspaceId?sC(h,t,r[t]):h));const c=o.some(h=>h.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:r}}function y3(e,t){const r=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const p=Ym(h.root,t);if(!p)continue;const g=Ui(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return ja({...o,tabs:c})}),s=r.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:r,activeWorkspaceId:s?e.activeWorkspaceId:r[0]?.id??null}}function b3(e,t,r,s){if(t&&t.length>0){const o=[];for(const c of t)cC(c)&&o.push(T0(c,r,s));if(o.length>0)return o}return[T0({...Zh(),tabs:e??[]},r,s)]}function T0(e,t,r){const s=[];for(const c of e.tabs){if(!uC(c))continue;const h=Xm(c.root,t);if(!h)continue;const p=Ui(h);for(const f of p)r.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&s.push({...c,root:h,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||r.has(c)||(r.add(c),o.push(c));return ja({...e,defaultCwd:mr(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function nC(e){return za(e)?e:{...e,workspaces:[Zh()],activeWorkspaceId:Xh}}function za(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Gh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function rC(e,t){for(const r of e){const s=r.tabs.findIndex(o=>o.id===t);if(s>=0)return{workspace:r,tab:r.tabs[s],tabIndex:s}}return null}function S3(e,t){return e.workspaces.find(r=>r.tabs.some(s=>Ol(s.root,t)))}function w3(e,t){return e.workspaces.find(r=>r.detachedTerminalIds.includes(t))}function C3(e,t,r,s){return e.map(o=>o.id===t?sC(o,r,s):o)}function sC(e,t,r){return aC(e,t)?{...e,defaultCwd:e.defaultCwd??mr(r?.cwd),detachedTerminalIds:Qg([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function aC(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Hl}function lC(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(r=>r!==t)}:e}function x3(e,t){if(e.defaultCwd)return e;const r=Mh(e).find(o=>!!t[o]),s=r?mr(t[r]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Zh(){return{id:Xh,title:ZA,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ja(e){const t=e.tabs.some(r=>r.id===e.activeTabId);return{...e,defaultCwd:mr(e.defaultCwd),detachedTerminalIds:Qg(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function k3(e,t,r,s){const o=Ui(r.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??mr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,r],activeTabId:c.activeTabId??r.id}:c)}function oC(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function _c(e,t,r){return e.type==="pane"?e.terminalId===t?r:e:e.type==="editor"?e:{...e,first:_c(e.first,t,r),second:_c(e.second,t,r)}}function Bl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const r=Bl(e.first,t),s=Bl(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function Ym(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const r=Ym(e.first,t),s=Ym(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function Xm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const r=Xm(e.first,t),s=Xm(e.second,t);return r&&s?{...e,ratio:hC(e.ratio),first:r,second:s}:r??s}function Gm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Gm(e.first),r=Gm(e.second);return t&&r?{...e,first:t,second:r}:t??r}function cC(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 uC(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Zm(t.root)}function Zm(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")&&Zm(t.first)&&Zm(t.second):!1}function Qm(e,t,r){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===r?e:{...e,ratio:r};const[s,...o]=t;if(s===0){const c=Qm(e.first,o,r);return c===e.first?e:{...e,first:c}}if(s===1){const c=Qm(e.second,o,r);return c===e.second?e:{...e,second:c}}return e}function hC(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function mr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Qg(e){const t=new Set,r=[];for(const s of e)!s||t.has(s)||(t.add(s),r.push(s));return r}function Ol(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Ol(e.first,t)||Ol(e.second,t)}function Ui(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ui(e.first),...Ui(e.second)]}function Jm(e){return e.type==="pane"||e.type==="editor"?1:Jm(e.first)+Jm(e.second)}const Ys=new Map,vc=new Map,yc=new Map,bc=new Map;function Ul(e){return e??"__local__"}function E3(e){return{agentId:e,state:QA(),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 Mt(e){const t=Ul(e);let r=Ys.get(t);return r||(r=E3(e),Ys.set(t,r)),r}function dC(e,t){const r=Ul(e);let s=vc.get(r);return s||(s=new Set,vc.set(r,s)),s.add(t),()=>{s.delete(t)}}function T3(e){const t=Ul(e),r=vc.get(t);if(r)for(const s of Array.from(r))s()}function Kl(e,t){Ys.set(Ul(e),t),T3(e)}const eg=new Set;function D3(e){return eg.add(e),()=>{eg.delete(e)}}function Po(e,t){const r=Mt(e),s=Ul(e);t.type==="workspace.hydrated"&&(yc.delete(s),bc.delete(s));const o=JA(r.state,t);let c=r.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=r.state.terminals[t.terminal.id],b=O3(s),y=z3(s);if(t.notifyCompletion===!0&&t.terminal.agentStatus)t.terminal.agentStatus.state==="working"&&y.add(t.terminal.id),t.terminal.agentStatus.state==="done"&&y.has(t.terminal.id)&&(h=R0(o,t.terminal.id,f?.currentCommand??null),y.delete(t.terminal.id)),t.terminal.agentStatus.state==="idle"&&y.delete(t.terminal.id),b.delete(t.terminal.id);else{const S=f?.activity==="busy",w=t.terminal.activity==="busy",x=t.terminal.activity==="idle";t.notifyCompletion===!0&&w&&b.add(t.terminal.id),t.notifyCompletion===!0&&S&&x&&b.has(t.terminal.id)&&(h=R0(o,t.terminal.id,f?.currentCommand??null)),(x||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(h){const S=fC(o,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=R3(o,t.tabId)?.tab??null;else{const y=o.workspaces.find(S=>S.id===t.workspaceId);f=y?.tabs.find(S=>S.id===y.activeTabId)??null}const b=f?Ui(f.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const S of b)y.delete(S);c=y}}const p=o!==r.state,g=c!==r.unreadCompletions;if((p||g)&&Kl(e,{...r,state:o,unreadCompletions:c}),g&&Jg(),h)for(const f of Array.from(eg))f({agentId:e,...h})}function fC(e,t){for(const r of e.workspaces)for(const s of r.tabs)if(Ui(s.root).includes(t))return{workspace:r,tab:s};return null}function R3(e,t){for(const r of e.workspaces){const s=r.tabs.find(o=>o.id===t);if(s)return{workspace:r,tab:s}}return null}const tg=new Set;function M3(e){return tg.add(e),()=>{tg.delete(e)}}function N3(){let e=0;for(const t of Ys.values())e+=t.unreadCompletions.size;return e}function Jg(){for(const e of Array.from(tg))e()}function A3(e,t){const r=Mt(e);if(!r.unreadCompletions.has(t))return;const s=new Set(r.unreadCompletions);s.delete(t),Kl(e,{...r,unreadCompletions:s}),Jg()}function D0(e,t){const r=Mt(e);t!==r.state&&Kl(e,{...r,state:t})}function Mp(e,t){const r=Mt(e),s=t(r.editors);s!==r.editors&&Kl(e,{...r,editors:s})}function zs(e,t,r){const s=Mt(e);s.loaded===t&&s.error===r||Kl(e,{...s,loaded:t,error:r})}function Io(e,t,r){const s=Mt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===r||Kl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:r})}function L3(e){const t=Mt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function B3(e){const t=Ul(e),r=Ys.get(t);r&&r.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(r.mutable.saveCoord.saveTimer);const s=r?r.unreadCompletions.size>0:!1;Ys.delete(t),vc.delete(t),yc.delete(t),bc.delete(t),s&&Jg()}function Np(){for(const e of Ys.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Ys.clear(),vc.clear(),yc.clear(),bc.clear()}function O3(e){let t=yc.get(e);return t||(t=new Set,yc.set(e,t)),t}function z3(e){let t=bc.get(e);return t||(t=new Set,bc.set(e,t)),t}function R0(e,t,r){const s=fC(e,t);return s?{terminalId:t,tabId:s.tab.id,commandName:r}:null}function ig(e,t){let r=!1,s=!1,o=null,c=!1;for(const h of gc(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,r=!0;continue}p.activity==="busy"?(s=!0,r=!0,!o&&p.currentCommand&&(o=p.currentCommand)):p.activity==="idle"&&(r=!0)}}return r?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function e_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function ng(e,t){const r=t[e.activeTerminalId];return e.title||r?.title||e.activeTerminalId}function j3(e,t,r,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${r} pane${r===1?"":"s"}`}function H3({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:x}){const[D,L]=v.useState(null),[A,B]=v.useState(!1),[V,H]=v.useState(null),F=v.useRef(null),re=e.findIndex(j=>j.id===t),ne=re>=0?e[re]:e[0]??null,de=ne?ig(ne,r):null,ve=ne?Vm(ne):0,U=ne?ng(ne,r):"No tab";v.useEffect(()=>{F.current?.focus(),F.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!A)return;const j=ae=>{ae.key==="Escape"&&B(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[A]),v.useEffect(()=>{A&&e.length===0&&B(!1)},[A,e.length]);function K(j,ae){L({tabId:j,title:ae})}function W(){if(!D)return;const j=D.title.trim();j&&w(D.tabId,j),L(null)}function P(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${q2()}`,onClick:y,disabled:!x,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${$2()}`,onClick:S,disabled:!x,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:p,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:U,onClick:()=>B(!0),disabled:e.length===0,children:[de?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":de.state,"aria-hidden":"true",title:e_(de)}):null,m.jsx("span",{children:U}),m.jsxs("small",{children:[re>=0?re+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,ae)=>{const R=gc(j),Y=Vm(j),G=ng(j,r),Ce=j.id===t,Te=D?.tabId===j.id,M=ig(j,r),Q=s?.has(j.id)??!1;return m.jsxs(Ti.Fragment,{children:[m.jsx(M0,{index:ae}),m.jsx(P3,{tab:j,active:Ce,editing:Te,title:G,paneCount:Y,terminalIds:R,canClose:e.length>1,editValue:Te?D.title:null,editInputRef:Te?F:null,activity:M,unread:Q,onSelect:()=>c(j.id),onBeginRename:()=>K(j.id,G),onCloseAll:()=>g(R),onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:fe=>L({tabId:j.id,title:fe})})]},j.id)}),m.jsx(M0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(o?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(j=>m.jsx(U3,{terminal:j,onReattach:()=>f?.(j.id),onDelete:()=>H(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),x?P():null]}),A?m.jsx(I3,{tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:D,editInputRef:F,onClose:()=>B(!1),onSelectTab:j=>{c(j),B(!1)},onCreateTab:()=>{h(),B(!1)},onBeginRename:K,onCloseTerminals:j=>{g(j),B(!1)},onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:(j,ae)=>L({tabId:j,title:ae}),onReattachTerminal:j=>{f?.(j),B(!1)},onDeleteTerminal:j=>{H(j),B(!1)}}):null,V?m.jsx(K3,{terminal:V,onCancel:()=>H(null),onConfirm:()=>{b?.(V.id),H(null)}}):null]})}function P3({tab:e,active:t,editing:r,title:s,paneCount:o,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:b,onBeginRename:y,onCloseAll:S,onCommitRename:w,onCancelRename:x,onRenameChange:D}){const{attributes:L,listeners:A,setNodeRef:B,transform:V,isDragging:H}=hw({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:r}),F={transform:zp.Translate.toString(V),opacity:H?.4:void 0,zIndex:H?2:void 0};return m.jsxs("div",{ref:B,className:"terminal-tab","data-active":t,"data-dragging":H,"data-unread":f?"true":void 0,style:F,...L,...A,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:e_(g)}):null,r&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:re=>{re.preventDefault(),w()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${s}`,value:h,onBlur:w,onChange:re=>D(re.target.value),onKeyDown:re=>{if(re.key==="Enter"){re.preventDefault(),w();return}re.key==="Escape"&&(re.preventDefault(),x())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:b,onDoubleClick:re=>{re.preventDefault(),y()},children:[m.jsx("span",{children:s}),m.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!r?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),S()},children:"x"}):null]})}function I3({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:b,onCloseTerminals:y,onCommitRename:S,onCancelRename:w,onRenameChange:x,onReattachTerminal:D,onDeleteTerminal:L}){const A=v.useRef(null);return v.useEffect(()=>{A.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:p,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:B=>B.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:p,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((B,V)=>{const H=gc(B),F=Vm(B),re=ng(B,r),ne=B.id===t,de=c?.tabId===B.id,ve=ig(B,r),U=s?.has(B.id)??!1;return m.jsxs("div",{ref:ne?A:null,className:"mobile-tab-sheet-row","data-active":ne,"data-unread":U?"true":void 0,children:[de&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:K=>{K.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${re}`,value:c.title,onBlur:S,onChange:K=>x(B.id,K.target.value),onKeyDown:K=>{if(K.key==="Enter"){K.preventDefault(),S();return}K.key==="Escape"&&(K.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${re}`,onClick:()=>g(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:V+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:re}),m.jsx("small",{children:j3(B,r,F,ve)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ve?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:e_(ve)}):null,m.jsx("span",{children:F})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[de?m.jsx("button",{type:"button","aria-label":`Done renaming ${re}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${re}`,onClick:()=>b(B.id,re),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${re}`,onClick:()=>y(H),children:"×"}):null]})]},B.id)}),(o?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(o??[]).map(B=>{const V=B.title||B.cwd||B.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${V}`,onClick:()=>D(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:V}),m.jsx("small",{children:B.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${V}`,onClick:()=>L(B),children:"×"})})]},B.id)})]}):null]})]})})}function M0({index:e}){const{setNodeRef:t,isOver:r}=vg({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":r,"aria-hidden":"true"})}function U3({terminal:e,onReattach:t,onDelete:r}){const s=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
54
- ${e.cwd}
55
- (detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:o,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),m.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(),r()},children:"×"})]})}function K3({terminal:e,onCancel:t,onConfirm:r}){const s=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:s}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:r,children:"Delete"})]})]})})}function W3({uploads:e,onDismiss:t,onDismissAll:r,onRetry:s,onCancel:o}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",p=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${Y3(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?oh(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:r,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(F3,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>o(g.id)},g.id))})]})}function F3({upload:e,compact:t,onDismiss:r,onRetry:s,onCancel:o}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":oh(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:oh(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${oh(e)}`,onClick:r,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(q3,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx($3,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function q3({toast:e}){const t=e.percent===null?X3(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function $3({response:e,compact:t}){const r=e.results.filter(h=>h.status==="failed"),s=e.results.filter(h=>h.status==="uploaded"),o=t?3:6,c=[...r,...s].slice(0,o);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,p)=>m.jsx(V3,{result:h},`${h.relativePath}-${p}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function V3({result:e}){const t=e.savedRelativePath??e.relativePath,r=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),r?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function oh(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,r=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${r} files`}return"Upload failed"}function Y3(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 X3(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function G3({toast:e,onActivate:t,onDismiss:r}){if(!e)return null;const s=e,o=s.commandName?`${s.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),r()}function h(p){p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(s)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:s.tabTitle}),m.jsx("span",{children:o})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:p=>p.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const Z3=Qo(0,0,1,1),Jr=1e-6;function Q3(e){return pC(e).map(t=>t.terminalId)}function pC(e){return Zo(e,Z3).sort(i5).map((t,r)=>({...t,index:r+1}))}function J3(e,t,r){const s=pC(e),o=s.find(h=>h.terminalId===t);return o?s.filter(h=>h.terminalId!==t).map(h=>t5(o,h,r)).filter(h=>h!==null).sort(n5)[0]?.entry.terminalId??null:null}function e5(e,t){return!Number.isInteger(t)||t<1?null:Q3(e)[t-1]??null}function Zo(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const r=r5(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*r;return[...Zo(e.first,Qo(t.left,t.top,o,t.bottom)),...Zo(e.second,Qo(o,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*r;return[...Zo(e.first,Qo(t.left,t.top,t.right,s)),...Zo(e.second,Qo(t.left,s,t.right,t.bottom))]}function t5(e,t,r){const s=e.bounds,o=t.bounds,c=N0(s.left,s.right,o.left,o.right),h=N0(s.top,s.bottom,o.top,o.bottom);switch(r){case"left":return o.centerX>=s.centerX-Jr||h<=Jr?null:{entry:t,primaryDistance:Math.max(0,s.left-o.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:h};case"right":return o.centerX<=s.centerX+Jr||h<=Jr?null:{entry:t,primaryDistance:Math.max(0,o.left-s.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:h};case"up":return o.centerY>=s.centerY-Jr||c<=Jr?null:{entry:t,primaryDistance:Math.max(0,s.top-o.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};case"down":return o.centerY<=s.centerY+Jr||c<=Jr?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};default:return null}}function i5(e,t){return Tl(e.bounds.top,t.bounds.top)||Tl(e.bounds.left,t.bounds.left)}function n5(e,t){return Tl(e.primaryDistance,t.primaryDistance)||Tl(e.perpendicularDistance,t.perpendicularDistance)||Tl(t.overlap,e.overlap)||Tl(e.entry.index,t.entry.index)}function Tl(e,t){const r=e-t;return Math.abs(r)<=Jr?0:r}function N0(e,t,r,s){return Math.max(0,Math.min(t,s)-Math.max(e,r))}function Qo(e,t,r,s){return{left:e,top:t,right:r,bottom:s,centerX:e+(r-e)/2,centerY:t+(s-t)/2}}function r5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class s5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function A0(e){return e?Array.from(e.types??[]).includes("Files")||vC(e.items).some(r=>r.kind==="file")?!0:yC(e.files).length>0:!1}async function a5(e){const t=vC(e.items).filter(r=>r.kind==="file");return t.length>0?l5(t):o5(e.files)}async function l5(e){const t=[];for(const r of e){const s=d5(r);if(s){await mC(s,"",t);continue}const o=r.getAsFile();if(o){t.push({relativePath:gC(o),file:o});continue}throw new s5("Folder upload is not supported by this browser.")}return t}function o5(e){return yC(e).map(t=>({relativePath:gC(t),file:t}))}async function mC(e,t,r){const s=p5(t,e.name);if(e.isFile){const h=await c5(e);r.push({relativePath:s,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await u5(o);for(const h of c)await mC(h,s,r)}function c5(e){return new Promise((t,r)=>{e.file(t,s=>r(s))})}async function u5(e){const t=[];for(;;){const r=await h5(e);if(r.length===0)return t;t.push(...r)}}function h5(e){return new Promise((t,r)=>{e.readEntries(t,s=>r(s))})}function gC(e){const t=e.webkitRelativePath;return _C(typeof t=="string"&&t?t:e.name)}function d5(e){const t=e.webkitGetAsEntry?.();return f5(t)?t:null}function f5(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 p5(e,t){return _C(e?`${e}/${t}`:t)}function _C(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function vC(e){return e?Array.from(e):[]}function yC(e){return e?Array.from(e):[]}const L0="nterminal.terminalWorkspaces.v2",bC="nterminal.sidebarCollapsed.v1",m5=75,B0=pw.map(e=>e.url),g5=pw[0].url,_5=6;function v5({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:h=async()=>{},onSessionInvalid:p}){const g=v.useMemo(()=>e??Bh(),[e]),f=v.useMemo(()=>t??lc(null),[t]),b=v.useMemo(()=>z5(r),[r]),y=v.useMemo(()=>k=>dC(r,k),[r]),S=v.useMemo(()=>()=>Mt(r),[r]),w=v.useSyncExternalStore(y,S,S),x=w.state,D=w.editors,L=!w.loaded,A=w.error,[B,V]=v.useState(!1),[H,F]=v.useState(()=>W5()),[re,ne]=v.useState("servers"),[de,ve]=v.useState(!1),U=v.useSyncExternalStore(iT,sS,sS);v.useSyncExternalStore(_h,rS,rS);const[K,W]=v.useState(0),[P,j]=v.useState(null),[ae,R]=v.useState(()=>[null]),[Y,G]=v.useState(0),[Ce,Te]=v.useState(()=>[r]),[M,Q]=v.useState(()=>new Set),[fe,me]=v.useState({}),[ge,Se]=v.useState(null),Ee=v.useRef(0),Ne=v.useRef(0),[Ue,te]=v.useState(null),[_e,Ae]=v.useState(null),we=v.useRef(null),Me=v.useRef(0),Ie=v.useRef(null),We=v.useRef(null),ie=v.useRef(null),[ke,De]=v.useState(null),Le=Gk(Ub(aw,{activationConstraint:{distance:8}}),Ub(lw,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>nT(g),[g]);function je(k){const E=k.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){De({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&De({tabId:E.sourceTabId,terminalId:E.terminalId})}}function at(k){De(null);const E=k.active.data.current,z=k.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){nt({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){nt({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&nt({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){nt({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){nt({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&nt({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Bt(){De(null)}const $e=x.workspaces.find(k=>k.id===x.activeWorkspaceId)??x.workspaces[0],St=$e?.tabs.find(k=>k.id===$e.activeTabId)??$e?.tabs[0],Z=St?.activeTerminalId??null,Ke=Z?x.terminals[Z]:void 0,le=L5("(max-width: 760px)"),ze=v.useMemo(()=>St?Nh(St.root):[],[St]),Qe=$e&&St?Jo(r,$e.id,St.id):null,ft=St?SC(ze,St.activeTerminalId,Qe?fe[Qe]:void 0):null,$t=le&&ze.length>1,Tt=v.useMemo(()=>($e?.detachedTerminalIds??[]).flatMap(k=>{const E=x.terminals[k];return E?[E]:[]}),[$e?.detachedTerminalIds,x.terminals]),Ot=v.useMemo(()=>{const k=new Set;for(const E of $e?.tabs??[])gc(E).some(z=>w.unreadCompletions.has(z))&&k.add(E.id);return k},[$e?.tabs,w.unreadCompletions]),[Qt,At]=v.useState([]),Ri=v.useRef([]),Wi=v.useRef(null),[gr,Qi]=v.useState(null),[Mi,vt]=v.useState(null),[Dt,Kt]=v.useState([]),[Vt,Si]=v.useState(()=>Ma()),ri=v.useRef(0),Lt=v.useRef(r),Fi=v.useRef(B0),zt=v.useRef(Vt),wt=v.useRef(()=>{});wt.current=Gs;const Yt=v.useCallback(async()=>{try{const k=await g.listNotificationAssets();Kt(k.assets.filter(E=>E.enabled).map(E=>E.url))}catch{Kt([])}},[g]);v.useEffect(()=>{Te(k=>k.some(E=>bn(E,r))?k:[...k,r])},[r]);const si=v.useCallback(k=>{const E=Mt(k),z=lc(k);for(const se of Object.keys(E.state.terminals))Xo(z.createWebSocketUrl(se)),Vu(se);B3(k),Te(se=>se.filter(ye=>!bn(ye,k))),Q(se=>{const ye=`${uh(k)}:`;let ce=!1;const be=new Set;for(const qe of se){if(qe.startsWith(ye)){ce=!0;continue}be.add(qe)}return ce?be:se}),me(se=>{const ye=`${uh(k)}:`;let ce=!1;const be={};for(const[qe,et]of Object.entries(se)){if(qe.startsWith(ye)){ce=!0;continue}be[qe]=et}return ce?be:se})},[]);v.useEffect(()=>{let k=!1;return g.listAgents().then(E=>{if(!k){const z=E.agents.map(ye=>ye.id),se=[null,...z];r!==null&&!z.includes(r)&&(si(r),s?.(null)),R(se)}}).catch(()=>{}),()=>{k=!0}},[r,g,si,s,Y]);const Ji=v.useCallback(k=>{si(k),G(E=>E+1),bn(k,Lt.current)&&s?.(null)},[si,s]);v.useEffect(()=>{R(k=>k.some(E=>bn(E,r))?k:[...k,r])},[r]),v.useEffect(()=>{Lt.current=r},[r]),v.useEffect(()=>{j(null)},[r]),v.useEffect(()=>{const k=Ie.current;if(!k)return;if(!bn(k.agentId,r)){Ie.current=null;return}if(!w.loaded||x.workspaces.length===0)return;Ie.current=null;const E=k.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];E&&E.id!==x.activeWorkspaceId&&nt({type:"workspace.selected",workspaceId:E.id})},[r,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const k=We.current;if(k){if(!bn(k.agentId,r)){We.current=null;return}w.loaded&&(We.current=null,x.workspaces.some(E=>E.id===k.workspaceId)&&nt({type:"workspace.selected",workspaceId:k.workspaceId}))}},[r,w.loaded,x.workspaces]),v.useEffect(()=>{const k=ie.current;if(k){if(!bn(k.agentId,r)){ie.current=null;return}w.loaded&&(ie.current=null,w.error||qi())}},[r,w.error,w.loaded]),v.useEffect(()=>{Yt()},[Yt]),v.useEffect(()=>yw(()=>Si(Ma())),[]),v.useEffect(()=>{const k=E=>{wt.current(E)};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{Fi.current=Dt.length>0?Dt:B0},[Dt]),v.useEffect(()=>{zt.current=Vt},[Vt]),v.useEffect(()=>{if(!w.loaded||!$e||!St)return;const k=Jo(r,$e.id,St.id);Q(E=>{if(E.has(k))return E;const z=new Set(E);return z.add(k),z})},[r,w.loaded,$e?.id,St?.id]),v.useEffect(()=>()=>{Br()},[]),v.useEffect(()=>D3(k=>{const E=Mt(k.agentId).state,z=E.workspaces.flatMap(be=>be.tabs).find(be=>be.id===k.tabId),se=E.terminals[k.terminalId],ye=z?.title?.trim()||se?.title||k.commandName||"terminal",ce=document.visibilityState==="visible"&&bn(k.agentId,Lt.current)&&k.tabId===O5(E);if(ce||A2({tabTitle:ye,commandName:k.commandName,terminalId:k.terminalId}),!ce&&document.visibilityState==="visible"&&zt.current.enabled){const be=ri.current+1;ri.current=be;const qe=Fi.current;Qi({id:be,agentId:k.agentId,terminalId:k.terminalId,tabId:k.tabId,tabTitle:ye,commandName:k.commandName,assetSrc:qe[Math.floor(Math.random()*qe.length)]??g5})}}),[]),v.useEffect(()=>{if(!gr||Vt.persistUntilDismissed)return;const k=window.setTimeout(()=>{Qi(E=>E?.id===gr.id?null:E)},Vt.durationSeconds*1e3);return()=>window.clearTimeout(k)},[gr,Vt]),v.useEffect(()=>{F5(H),H&&Ni()},[H]),v.useEffect(()=>{let k=!1;async function E(){if(!Mt(r).loaded){zs(r,!1,null);try{let se=null,ye=null;try{se=j5(b)}catch(et){if(!(et instanceof Lh))throw et;ye=et}const[ce,be]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),qe=ce.terminals.length>0?ce.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!k){const et=be.layout?CC(be.layout):null;if(!et&&ye)throw ye;const ci=et??se??{},Ht=$m(qe,void 0,ci.savedWorkspaces,ci.savedActiveWorkspaceId),T=Rp(Ht);D0(r,Ht),Io(r,be.revision,JSON.stringify(T)),zs(r,!0,null),!et&&se&&dn(T,{baseRevision:be.revision})}}catch(se){!k&&!Jt(se)&&zs(r,!0,js(se))}}}return E(),()=>{k=!0}},[r,f,K]);function wn(){zs(r,!1,null),W(k=>k+1)}function Ni(){Ee.current+=1,Ne.current+=1,Se(null)}function Cn(k){Ee.current+=1,Ne.current+=1,Se(E=>E&&{...E,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function qi(){Ee.current+=1,Ne.current+=1;const k=x.workspaces.length+1,E=ai();Se({mode:"create",workspaceId:null,title:`Workspace ${k}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Nr(E)}function Wt(k){if(bn(k,r)){qi();return}ie.current={agentId:k},s?.(k)}function Ai(k){if(H&&!B)return;const E=x.workspaces.find(se=>se.id===k);if(!E)return;Ee.current+=1,Ne.current+=1;const z=E.defaultCwd??Ke?.cwd??"";Se({mode:"edit",workspaceId:k,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Nr(z)}function ai(){return $e?.defaultCwd??Ke?.cwd??""}async function Nr(k){const E=Ee.current+1;Ee.current=E;const z=k.trim();if(Se(se=>se&&{...se,cwd:k,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const se=await f.createFileRoot({path:z}),ye=await f.listFiles({rootToken:se.rootToken,path:""});if(Ee.current!==E)return;Se(ce=>ce&&{...ce,cwd:se.rootPath,browseRoot:{rootToken:se.rootToken,rootPath:se.rootPath},browseEntries:ye.entries.filter(be=>be.kind==="directory"),browseStatus:"idle",error:null})}catch(se){if(Ee.current!==E)return;Se(ye=>ye&&{...ye,browseStatus:"idle",error:js(se)})}}async function Ha(){const k=ge;if(!k)return;const E=k.title.trim(),z=k.cwd.trim();if(!E||!z){Se({...k,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const se=Ne.current+1;Ne.current=se,Se({...k,submitStatus:"submitting",error:null});try{const ye=await f.createFileRoot({path:z});if(Ne.current!==se)return;if(k.mode==="create"){const ce=x.workspaces.length+1;nt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ce}`,title:E,defaultCwd:ye.rootPath})}else k.workspaceId&&(nt({type:"workspace.renamed",workspaceId:k.workspaceId,title:E}),nt({type:"workspace.defaultCwdChanged",workspaceId:k.workspaceId,defaultCwd:ye.rootPath}));Se(null)}catch(ye){if(Ne.current!==se)return;Se(ce=>ce&&{...ce,submitStatus:"idle",error:js(ye)})}}function Wl(k){Ne.current+=1,Se(k)}function rs(k,E,z){if(k===E)return;const se=x.workspaces.some(ce=>ce.id===k),ye=x.workspaces.some(ce=>ce.id===E);!se||!ye||nt({type:"workspace.reordered",sourceWorkspaceId:k,targetWorkspaceId:E,placement:z})}function ir(k,E){const z=x.workspaces.findIndex(ye=>ye.id===k),se=x.workspaces[z+E];z<0||!se||rs(k,se.id,E<0?"before":"after")}function Xs(k,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),we.current={sourceId:k,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function nr(k){const E=we.current;if(!E||E.pointerId!==k.pointerId)return;const z=Math.hypot(k.clientX-E.startX,k.clientY-E.startY);if(!E.active){if(z<_5)return;E.active=!0,te(E.sourceId)}const ye=document.elementFromPoint(k.clientX,k.clientY)?.closest("[data-workspace-id]"),ce=ye?.dataset.workspaceId??null;if(!ye||!ce||ce===E.sourceId||!x.workspaces.some(et=>et.id===ce)){E.targetId=null,Ae(null);return}const be=ye.getBoundingClientRect(),qe=k.clientY<be.top+be.height/2?"before":"after";E.targetId=ce,E.placement=qe,Ae({workspaceId:ce,placement:qe})}function rr(k){const E=we.current;!E||E.pointerId!==k.pointerId||(k.preventDefault(),k.stopPropagation(),k.currentTarget.releasePointerCapture?.(k.pointerId),we.current=null,te(null),Ae(null),E.active&&E.targetId&&rs(E.sourceId,E.targetId,E.placement))}function Hn(k){const E=we.current;E&&E.pointerId===k.pointerId&&k.currentTarget.releasePointerCapture?.(k.pointerId),we.current=null,te(null),Ae(null)}async function sr(){await xn(async()=>{const k=$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},E=await f.createTerminal(k);nt({type:"terminal.created",terminal:E.terminal})})}async function jt(k){await xn(async()=>{const E=Z?{parentTerminalId:Z,cols:80,rows:24}:$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},z=await f.createTerminal(E);nt({type:"terminal.split",terminal:z.terminal,direction:k})})}async function Pa(k){let E=Z,z=Qe;const se=$e?.defaultCwd?.trim();if(!E&&!se)throw new Error("No active pane is available.");const ye=await f.readFile(k);if(!E&&se){const qe=await f.createTerminal({cols:80,rows:24,cwd:se});E=qe.terminal.id,nt({type:"terminal.created",terminal:qe.terminal})}if(E){nt({type:"pane.selected",terminalId:E});const qe=Mt(r).state,et=qe.workspaces.find(Ht=>Ht.id===qe.activeWorkspaceId)??qe.workspaces[0],ci=et?.tabs.find(Ht=>Ht.id===et.activeTabId)??et?.tabs[0];z=et&&ci?Jo(r,et.id,ci.id):null}const ce=`editor-${Date.now().toString(36)}-${L3(r)}`,be=K5(ye.path);Mp(r,qe=>({...qe,[ce]:{id:ce,title:be,rootToken:k.rootToken,path:ye.path,read:ye}})),z&&me(qe=>({...qe,[z]:wC(ce)})),nt({type:"editor.split",editorId:ce,title:be,direction:"vertical"})}function Ia(k){Mp(r,E=>{const z={...E};return delete z[k],z}),nt({type:"editor.closed",editorId:k})}function ar(k){Pn([k])}function Pn(k){const E=[...new Set(k)].filter(se=>x.terminals[se]);if(E.length===0)return;const z=E.length===1?x.terminals[E[0]]?.title||x.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;j(null),vt({terminalIds:E,label:z,workspaceId:$e?.id??x.activeWorkspaceId??null})}function Ua(k,E){const z=In(k,E);if(!z)return!1;const se=k.filter(ye=>!z.detachedTerminalIds.includes(ye));if(z.detachedTerminalIds.length+se.length>Hl)return j(P5(z.detachedTerminalIds.length)),!1;j(null);for(const ye of k)nt(z.id?{type:"terminal.detached",terminalId:ye,workspaceId:z.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Ka(k){await xn(async()=>{for(const E of k)await Li(E),Xo(f.createWebSocketUrl(E)),Vu(E),nt({type:"terminal.closed",terminalId:E})})}async function Wa(k){const E=x.workspaces.find(z=>z.id===k);!E||x.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await xn(async()=>{const z=Mh(E),se=[];let ye=null;for(const be of z)try{await Li(be)}catch(qe){se.push(js(qe)),qe instanceof fr&&qe.status===401&&!f.isAgent&&(ye=qe)}finally{Xo(f.createWebSocketUrl(be)),Vu(be)}const ce=E.tabs.flatMap(be=>rg(be.root));if(ce.length>0){const be=new Set(ce);Mp(r,qe=>{const et={...qe};for(const ci of be)delete et[ci];return et})}if(nt({type:"workspace.closed",workspaceId:k}),ye)throw ye;if(se.length>0)throw new Error(`Workspace was removed, but ${se.length} terminal session${se.length===1?"":"s"} may still be running. ${se[0]}`)})}async function Fl(k){await xn(async()=>{await Li(k),Xo(f.createWebSocketUrl(k)),Vu(k),nt({type:"terminal.closed",terminalId:k})})}async function _r(k,E){const z=E.trim();if(!z)return;let se=null;for(const ye of x.workspaces){const ce=ye.tabs.find(be=>be.id===k);if(ce){se=ce.activeTerminalId;break}}if(nt({type:"tab.renamed",tabId:k,title:z}),!!se)try{const ye=await f.renameTerminal(se,z);Ar({type:"terminal.updated",terminal:ye.terminal})}catch(ye){zs(r,!0,js(ye))}}function ss(k){const E=x.terminals[k];E&&nt({type:"terminal.created",terminal:E})}async function Li(k){try{await f.closeTerminal(k)}catch(E){if(E instanceof fr&&E.status===404)return;throw E}}async function li(){await xn(async()=>{await h()})}async function xn(k){zs(r,!0,null);try{await k()}catch(E){if(Jt(E))return;zs(r,!0,js(E))}}function Jt(k){return k instanceof fr&&k.status===401&&!f.isAgent&&p?(p({source:"workspace-api-401",status:401,activeAgentId:r}),!0):!1}function nt(k){Po(r,k);const E=Mt(r),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const se=Rp(z);JSON.stringify(se)!==E.lastPersistedLayoutJson&&ea(se)}function Ar(k){Po(r,k)}function kn(k,E,z,se){const ye=Jo(k,E,z);me(ce=>({...ce,[ye]:se}))}function oi(k){Qe&&me(E=>({...E,[Qe]:k}))}function $i(k,E){const z=Ah(k);E?kn(r,E.workspaceId,E.tabId,z):oi(z),nt({type:"pane.selected",terminalId:k})}function as(k){oi(k.key),k.type==="terminal"&&nt({type:"pane.selected",terminalId:k.terminalId})}function Gs(k){if(de||Mi||k.isComposing||k.key==="Process"||x5(k.target))return;const E=b5(k);if(!E)return;if(k.preventDefault(),k.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){vr(E.type==="server.next"?1:-1);return}const z=Mt(r).state,se=z.workspaces.find(be=>be.id===z.activeWorkspaceId)??z.workspaces[0],ye=se?.tabs.find(be=>be.id===se.activeTabId)??se?.tabs[0];if(E.type==="split"){if(!ye)return;jt(E.direction);return}if(!se||!ye)return;if(E.type==="tab.previous"||E.type==="tab.next"){const be=C5(se.tabs,ye.id,E.type==="tab.next"?1:-1);be&&nt({type:"tab.selected",tabId:be.id});return}if(E.type==="tab.index"){const be=se.tabs[E.index-1];be&&nt({type:"tab.selected",tabId:be.id});return}const ce=S5(ye.root,ye.activeTerminalId,E);ce&&$i(ce,{workspaceId:se.id,tabId:ye.id})}function Lr(k,E){if(!s||ae.length===0)return;const z=ae.findIndex(be=>bn(be,r)),ye=((z===-1?0:z)+k+ae.length)%ae.length,ce=ae[ye]??null;bn(ce,r)||(E&&(Ie.current={agentId:ce,edge:E}),s(ce))}function vr(k){const E=Mt(r).state,z=E.workspaces;if(z.length===0){Lr(k,k===1?"first":"last");return}const se=z.findIndex(be=>be.id===E.activeWorkspaceId),ce=(se===-1?0:se)+k;if(ce>=0&&ce<z.length){nt({type:"workspace.selected",workspaceId:z[ce].id});return}Lr(k,k===1?"first":"last")}function Zs(k,E){if(bn(k,r)){nt({type:"workspace.selected",workspaceId:E});return}We.current={agentId:k,workspaceId:E},s?.(k)}function In(k,E){if(E)return x.workspaces.find(z=>z.id===E)??null;for(const z of k){const se=x.workspaces.find(ce=>ce.tabs.some(be=>gc(be).includes(z)));if(se)return se;const ye=x.workspaces.find(ce=>ce.detachedTerminalIds.includes(z));if(ye)return ye}return x.workspaces.find(z=>z.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Un(k){A0(k.dataTransfer)&&(k.preventDefault(),k.dataTransfer.dropEffect="copy")}function ql(k){if(!A0(k.dataTransfer))return;k.preventDefault();const E=I5(Mt(r).state),z=Me.current+1;if(Me.current=z,!E){ls({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}ls({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),Qs(z,E.id,k.dataTransfer)}async function Qs(k,E,z){try{const se=await a5(z);if(se.length===0)throw new Error("No files were found in the drop.");cn(k,{id:k,status:"queued",fileCount:se.length,message:"Queued"},{terminalId:E,files:se})}catch(se){cn(k,{id:k,status:"failed",fileCount:0,message:js(se)},{terminalId:E})}finally{lr()}}async function Fa(k){const E=Ri.current.find(ce=>ce.id===k);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,se=E.files,ye=new AbortController;Wi.current=k,cn(k,{id:k,status:"uploading",fileCount:se.length,loaded:0,total:null,percent:null},{terminalId:z,files:se,abortController:ye});try{const ce=await mT({terminalId:z,files:se,signal:ye.signal,onProgress:ci=>{cn(k,{id:k,status:"uploading",fileCount:se.length,loaded:ci.loaded,total:ci.total,percent:ci.percent},{terminalId:z,files:se,abortController:ye})}}),be=ce.failed>0?ce.uploaded>0?"partial":"failed":"success",qe=ce.failed>0?U5(ce):void 0,et={id:k,status:be,fileCount:se.length,response:ce};qe&&(et.message=qe),cn(k,et,{terminalId:z,files:se})}catch(ce){cn(k,{id:k,status:"failed",fileCount:se.length,message:ye.signal.aborted?"Upload canceled.":js(ce)},{terminalId:z,files:se})}finally{Wi.current===k&&(Wi.current=null),lr()}}function lr(){if(Wi.current!==null)return;const k=Ri.current.find(E=>E.status==="queued");k?.terminalId&&k.files&&k.files.length>0&&Fa(k.id)}function ls(k){un(E=>[...E,k])}function cn(k,E,z={}){un(se=>se.map(ye=>{if(ye.id!==k)return ye;const ce={...E},be=z.terminalId??ye.terminalId,qe=z.files??ye.files;return be!==void 0&&(ce.terminalId=be),qe!==void 0&&(ce.files=qe),z.abortController!==void 0&&(ce.abortController=z.abortController),ce}))}function un(k){const E=k(Ri.current);Ri.current=E,At(E)}function hn(k){Ri.current.find(z=>z.id===k)?.abortController?.abort(),Wi.current===k&&(Wi.current=null),un(z=>z.filter(se=>se.id!==k)),lr()}function os(){for(const k of Ri.current)k.abortController?.abort();Wi.current=null,un(()=>[])}function Js(k){const E=Ri.current.find(z=>z.id===k);if(E){if(E.status==="queued"){hn(k);return}E.abortController?.abort()}}function or(k){const E=Ri.current.find(se=>se.id===k);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=yr(E);if(z.length===0){cn(k,{id:k,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}cn(k,{id:k,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),lr()}function yr(k){const E=k.files??[],z="response"in k?k.response:void 0;if(!z)return E;const se=z.results.filter(be=>be.status==="failed").map(be=>be.relativePath);if(se.length===0)return[];const ye=new Map;for(const be of E){const qe=ye.get(be.relativePath)??[];qe.push(be),ye.set(be.relativePath,qe)}const ce=[];for(const be of se){const et=ye.get(be)?.shift();et&&ce.push(et)}return ce}function qa(k){const z=Mt(k.agentId).state.workspaces.find(se=>se.tabs.some(ye=>ye.id===k.tabId));z&&kn(k.agentId,z.id,k.tabId,Ah(k.terminalId)),Po(k.agentId,{type:"pane.selected",terminalId:k.terminalId}),A3(k.agentId,k.terminalId),bn(k.agentId,r)||s?.(k.agentId),Qi(null)}function ea(k){const E=Mt(r).mutable.saveCoord;E.pendingLayoutSave=k,Uo(k,b),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&dn(z)},m5)}function Br(){const k=Mt(r).mutable.saveCoord;k.saveTimer!==null&&(window.clearTimeout(k.saveTimer),k.saveTimer=null);const E=k.pendingLayoutSave;k.pendingLayoutSave=null,E&&(Uo(E,b),dn(E))}function dn(k,E={}){const z=Mt(r).mutable.saveCoord;z.nextPersistLayout=k,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const se=z.nextPersistLayout,ye=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,se&&await fn(se,ye!==void 0?{baseRevision:ye}:{})}))}async function fn(k,E={}){const z=Mt(r),se=E.baseRevision??z.layoutRevision,ye={layout:k,...typeof se=="number"?{baseRevision:se}:{}};try{const ce=await f.saveTerminalLayout(ye),be=ce.layout??k;Io(r,ce.revision,JSON.stringify(be)),Uo(be,b);return}catch(ce){if(ce instanceof fr&&ce.status===400&&ce.message===n2){H5(r,b),zs(r,!0,xC());return}if(ce instanceof fr&&ce.status===409)try{const be=await f.getTerminalLayout(),qe=Mt(r).mutable.saveCoord;if(qe.nextPersistLayout||qe.pendingLayoutSave){const et=be.layout?JSON.stringify(be.layout):Mt(r).lastPersistedLayoutJson;Io(r,be.revision,et);return}if(be.layout){const et=Mt(r).state,ci=$m(Object.values(et.terminals),void 0,be.layout.workspaces,be.layout.activeWorkspaceId),Ht=Rp(ci);D0(r,ci),Io(r,be.revision,JSON.stringify(Ht)),Uo(Ht,b)}else Io(r,be.revision,z.lastPersistedLayoutJson);return}catch{}Uo(k,b)}}const cs=q5(o),en=!H||B,tn=en?re:"servers";function us(k){const E=k.active?w:Mt(k.agentId),z=k.active?x:E.state,se=k.active?w.loaded:E.loaded,ye=k.active?A:E.error;return m.jsxs("div",{className:`workspace-list-panel${k.active?" workspace-list-panel--active-server":""}`,"aria-label":`${k.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${k.label}`,title:"New workspace",onClick:()=>Wt(k.agentId),children:"+"})]}),se?ye?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(k.agentId),children:ye}):m.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(ce=>{const be=k.active&&ce.id===$e?.id,qe=Mh(ce).length,et=k.active&&z.workspaces.length>1,ci=_e?.workspaceId===ce.id&&Ue!==ce.id?_e.placement:null;return m.jsxs(R5,{workspaceId:ce.id,active:be,disabled:!k.active,reorderable:et,dragging:Ue===ce.id,dropPlacement:ci,children:[et?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ce.id,title:"Drag to reorder","aria-label":`Reorder ${ce.title}`,"aria-grabbed":Ue===ce.id,onPointerDown:Ht=>Xs(ce.id,Ht),onPointerMove:nr,onPointerUp:rr,onPointerCancel:Hn,onKeyDown:Ht=>{(Ht.key==="ArrowUp"||Ht.key==="ArrowDown")&&(Ht.preventDefault(),Ht.stopPropagation(),ir(ce.id,Ht.key==="ArrowUp"?-1:1))},onClick:Ht=>Ht.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":be?"page":void 0,title:ce.defaultCwd??void 0,onClick:()=>Zs(k.agentId,ce.id),onDoubleClick:()=>{k.active&&Ai(ce.id)},children:[m.jsx("span",{className:"workspace-list-name",children:ce.title}),m.jsxs("small",{children:[ce.defaultCwd??"No folder"," · ",qe," ",qe===1?"session":"sessions"]})]}),k.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ce.title}`,title:"Edit workspace",onClick:()=>Ai(ce.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ce.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Wa(ce.id)},children:"x"})]}):null]},ce.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(k.agentId),children:"Open server to load workspaces"})]})}return m.jsx(GE,{sensors:Le,onDragStart:je,onDragEnd:at,onDragCancel:Bt,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":H,"data-sidebar-open":B,onDragOver:Un,onDrop:ql,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>V(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[m.jsxs("div",{className:"workspace-brand-lockup",children:[en?m.jsx(q0,{height:20}):m.jsx(F0,{size:24}),c&&en?m.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":H?"Expand sidebar":"Collapse sidebar",title:H?"Expand sidebar":"Collapse sidebar",onClick:()=>F(k=>!k),children:H?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>V(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${tn==="files"?"files":"servers"}`,children:[en?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":re==="servers",onClick:()=>{ne("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":re==="files",onClick:()=>{ne("files")},children:"Files"})]}):null,tn==="servers"&&en?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(tS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:Y,renderServerChildren:us})}):null,en?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(tS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:Y,compact:!0})}),tn==="files"?m.jsx(bT,{api:f,activeTerminalId:Z,activeTerminalCwd:Ke?.cwd??null,workspaceRootPath:$e?.defaultCwd??Ke?.cwd??null,onOpenFile:Pa}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[en?m.jsx("span",{children:cs}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ve(!0),children:[m.jsx(z0,{name:"settings"}),U.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),en?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{li()},children:m.jsx(z0,{name:"logout"})}):null]})]})]}),de?m.jsx(dT,{api:g,onClose:()=>ve(!1),updateAvailable:U.hasUpdates,onNotificationAssetsChanged:()=>{Yt()},onAgentRemoved:Ji}):null,ge?m.jsx(k5,{dialog:ge,activePaneCwd:Ke?.cwd??null,activeWorkspaceCwd:$e?.defaultCwd??null,onChange:Wl,onManualCwdChange:Cn,onBrowse:Nr,onCancel:Ni,onSubmit:()=>{Ha()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":$t?"true":void 0,children:[m.jsx(H3,{tabs:$e?.tabs??[],activeTabId:$e?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Ot,detachedTerminals:Tt,onSelectTab:k=>nt({type:"tab.selected",tabId:k}),onCreateTab:()=>{sr()},onToggleWorkspaces:()=>V(k=>!k),onCloseTerminals:k=>Pn(k),onReattachTerminal:k=>ss(k),onDeleteTerminal:k=>{Fl(k)},onSplitVertical:()=>{jt("vertical")},onSplitHorizontal:()=>{jt("horizontal")},onRenameTab:(k,E)=>{_r(k,E)},activePaneAvailable:!!Z}),$t?m.jsx(N5,{targets:ze,activeLeafKey:ft,terminals:x.terminals,editors:D,onSelect:as}):null,A?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:A}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:wn,children:"Retry"}),r!==null&&s?m.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!St?m.jsx(D5,{onCreate:()=>{sr()}}):null,Ce.map(k=>{const E=bn(k,r);return m.jsx(y5,{agentId:k,active:E,activeServerApi:E?f:void 0,visitedTabKeys:M,refreshCwdOnEnter:E&&tn==="files",draggingTab:E?ke:null,mobileSplitFocus:le,mobileFocusedLeafByTabKey:fe,onSelect:z=>{E&&$i(z)},onClose:z=>{E&&ar(z)},onCloseEditor:z=>{E&&Ia(z)},onResize:(z,se)=>{E&&nt({type:"pane.resized",path:z,ratio:se})},onExit:(z,se)=>{E?Ar({type:"terminal.exited",terminalId:z,exitCode:se}):Po(k,{type:"terminal.exited",terminalId:z,exitCode:se})},onSnapshot:(z,se)=>{const ye={type:"terminal.updated",terminal:z,notifyCompletion:se?.notifyCompletion===!0};E?Ar(ye):Po(k,ye)},...k===null&&p?{onAuthClose:z=>p({...z,source:z?.source??"terminal-ws-1008",activeAgentId:k})}:{}},uh(k))})]}),Mi?m.jsx(M5,{label:Mi.label,count:Mi.terminalIds.length,warning:P,onCancel:()=>{j(null),vt(null)},onHide:()=>{Ua(Mi.terminalIds,Mi.workspaceId)&&vt(null)},onDelete:()=>{const k=Mi.terminalIds;j(null),vt(null),Ka(k)}}):null,m.jsx(G3,{toast:gr,onActivate:qa,onDismiss:()=>Qi(null)}),m.jsx(W3,{uploads:Qt,onDismiss:hn,onDismissAll:os,onRetry:or,onCancel:Js})]})]})})}function y5({agentId:e,active:t,activeServerApi:r,visitedTabKeys:s,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,onAuthClose:x}){const D=v.useMemo(()=>ve=>dC(e,ve),[e]),L=v.useMemo(()=>()=>Mt(e),[e]),A=v.useSyncExternalStore(D,L,L),B=v.useMemo(()=>lc(e),[e]),V=r??B,H=A.state,F=H.workspaces.find(ve=>ve.id===H.activeWorkspaceId)??H.workspaces[0],re=F?.id??null,de=(F?.tabs.find(ve=>ve.id===F.activeTabId)??F?.tabs[0])?.id??null;return!A.loaded||H.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:H.workspaces.flatMap(ve=>ve.tabs.map(U=>{const K=t&&ve.id===re&&U.id===de,W=Jo(e,ve.id,U.id),P=Nh(U.root),j=h&&P.length>1?SC(P,U.activeTerminalId,p[W]):null;return!K&&!s.has(W)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":K,"aria-hidden":!K,children:m.jsx(Wm,{node:U.root,terminals:H.terminals,editors:A.editors,api:V,activeTerminalId:U.activeTerminalId,visible:K,refreshCwdOnEnter:K&&o,tabId:U.id,dropZoneActive:K&&c!==null,draggingTerminalId:K?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,...x?{onAuthClose:x}:{}})},`${ve.id}:${U.id}`)}))})}function b5(e){const t=Mw(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 r=w5(e.key);return r?{type:"pane.direction",direction:r}:null}return null}function S5(e,t,r){switch(r.type){case"pane.direction":return J3(e,t,r.direction);case"pane.index":return e5(e,r.index);default:return null}}function w5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function C5(e,t,r){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+r+e.length)%e.length]??null}function Nh(e){return e.type==="pane"?[{key:Ah(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:wC(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Nh(e.first),...Nh(e.second)]}function rg(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...rg(e.first),...rg(e.second)]}function SC(e,t,r){if(r&&e.some(o=>o.key===r))return r;const s=t?Ah(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function Ah(e){return`terminal:${e}`}function wC(e){return`editor:${e}`}function x5(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 k5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:r,onChange:s,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function y(w){s(x=>x&&{...x,...w})}function S(w){w&&(y({cwd:w,error:null}),c(w))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||p()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:w=>y({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:b,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(r),disabled:b||!r,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(T5(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{c(E5(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function E5(e,t){return t?t.startsWith("/")?ch(t):ch(`${e||"/"}/${t}`):ch(e)}function T5(e){const t=ch(e);if(!t||t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function ch(e){const t=e.trim();if(!t)return"";const r=t.replace(/\/+/g,"/");return r==="/"?"/":r.endsWith("/")?r.slice(0,-1):r}function D5({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function R5({workspaceId:e,active:t,disabled:r=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=vg({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:r}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function M5({label:e,count:t,warning:r,onCancel:s,onHide:o,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),r?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:r}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function N5({targets:e,activeLeafKey:t,terminals:r,editors:s,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(S=>S.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],b=O0(f,r,s);function y(S){const w=(g+S+e.length)%e.length,x=e[w];x&&o(x)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const x=O0(S,r,s),D=A5(S,r,s),L=S.key===f.key;return m.jsxs("button",{type:"button","data-active":L,onClick:()=>{o(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:x}),m.jsx("small",{children:D})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function O0(e,t,r){if(e.type==="editor")return r[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function A5(e,t,r){if(e.type==="editor"){const c=r[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 L5(e){const[t,r]=v.useState(()=>B5(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){r(!1);return}const s=window.matchMedia(e),o=()=>r(s.matches);return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):(s.addListener(o),()=>s.removeListener(o))},[e]),t}function B5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function bn(e,t){return e===t}function O5(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 uh(e){return e??"__local__"}function Jo(e,t,r){return`${uh(e)}:${t}:${r}`}class Lh extends Error{constructor(){super(xC())}}function z5(e){return e?{workspaceKey:`${L0}:${e}`}:{workspaceKey:L0}}function j5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const r=JSON.parse(t);if(fw(r))throw new Lh;const s=dw(r);return s?CC(s):null}catch(r){if(r instanceof Lh)throw r;return null}}function CC(e){if(fw(e))throw new Lh;const t=dw(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Uo(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function H5(e,t){const r=Mt(e).lastPersistedLayoutJson;if(r){localStorage.setItem(t.workspaceKey,r);return}localStorage.removeItem(t.workspaceKey)}function P5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Hl}. Re-open or delete hidden sessions before hiding more.`}function xC(){return`A saved terminal layout has more than ${Hl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function I5(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],r=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],s=r?e.terminals[r.activeTerminalId]:void 0;return s?.status==="running"?s:null}function U5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function K5(e){return e.split("/").filter(Boolean).pop()??e}function W5(){try{return localStorage.getItem(bC)==="true"}catch{return!1}}function F5(e){try{localStorage.setItem(bC,e?"true":"false")}catch{}}function q5(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const r=t-Date.now();if(r<=0)return"session · expired";const s=Math.max(1,Math.floor(r/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function z0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function js(e){return e instanceof Error?e.message:"Request failed"}function $5({api:e,onDone:t}){const[r,s]=v.useState(null),[o,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(L=>{D||(s(L.qrDataUrl),c(L.secret))}).catch(L=>{D||w(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function x(D){if(D.preventDefault(),!!o){f(!0),y(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(L){y(L instanceof Error?L.message:"Verification failed")}finally{f(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!r||!o?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.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."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:r,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:o})]}),m.jsxs("form",{className:"auth-form",onSubmit:x,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:D=>p(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?m.jsx("p",{className:"form-error",children:b}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}const kC="nterminal.clientDiagnostics.v1",EC=150,V5=24,Y5=160;let j0=!1,Ko=null;function X5(){j0||typeof window>"u"||(j0=!0,zn("page.load",{navigation:sL(),visibility:document.visibilityState,online:navigator.onLine,viewport:RC(),standalone:rL()}),document.addEventListener("visibilitychange",()=>{zn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{zn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{zn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>zn("network.online")),window.addEventListener("offline",()=>zn("network.offline")),window.addEventListener("focus",()=>zn("window.focus")),window.addEventListener("blur",()=>zn("window.blur")),window.addEventListener("error",e=>{zn("runtime.error",{message:e.message,source:aL(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{zn("runtime.unhandledrejection",{reason:lL(e.reason)})}))}function zn(e,t={}){const r={at:new Date().toISOString(),event:Qh(e,80),data:DC({...t,visibility:t.visibility??iL(),online:t.online??nL(),viewport:t.viewport??RC()})},s=TC();return s.push(r),G5(s.slice(-EC)),r}function TC(){try{const e=window.localStorage.getItem(kC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(Z5).filter(r=>r!==null).slice(-EC):[]}catch{return[]}}async function t_(e,t=fetch){if(Ko)return Ko;const r=TC(),s={reason:Qh(e,80),events:r},o=JSON.stringify(s);Ko=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Ko}finally{Ko=null}}function G5(e){try{window.localStorage.setItem(kC,JSON.stringify(e))}catch{}}function Z5(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:Qh(t.event,80),...t.data&&typeof t.data=="object"?{data:DC(t.data)}:{}}}function DC(e){const t={};for(const[r,s]of Object.entries(e).slice(0,V5)){const o=Qh(r,64);if(!o||Q5(o))continue;const c=J5(s);c!==void 0&&(t[o]=c)}return t}function Q5(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function J5(e){if(typeof e=="string")return eL(e,Y5);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Qh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function eL(e,t){return tL(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function tL(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 iL(){return typeof document>"u"?void 0:document.visibilityState}function nL(){return typeof navigator>"u"?void 0:navigator.onLine}function RC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function rL(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function sL(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function aL(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 lL(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function oL(e){return{source:Ap(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Ap(e.terminalId)}:{},...e?.detail?{detail:Ap(e.detail)}:{}}}function cL(e){return{invalidationSource:e.source}}function uL(e){zn("auth.session_invalid.request",MC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),t_("session-invalid-request").catch(()=>{}))}function hL(e,t){zn("auth.session_invalid.result",{...MC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),t_("session-invalid-result").catch(()=>{}))}function MC(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 Ap(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function dL({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s}){const o=v.useMemo(()=>e??Bh(),[e]),c=v.useMemo(()=>t??lc(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(B=>{A||(p(B),f(null))}).catch(B=>{A||(f(Ra(B)),p(null))}),()=>{A=!0}},[o]);const S=gL(h);v.useEffect(()=>{const A=y.current;zn("auth.view",{view:S,previousView:A,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),A==="workspace"&&S!=="workspace"&&t_(`auth-left-workspace-${S}`).catch(()=>{}),y.current=S},[h,S]);async function w(){const A=await o.getSession();p(A),f(null)}async function x(){xp(),Np(),c0(),f(null),p(null);try{await w()}catch(A){f(Ra(A))}}function D(A){const B=oL(A);if(uL(B),b.current)return b.current;const V=(async()=>{f(null);try{const H=await o.getSession(cL(B));if(hL(B,H.authenticated),p(H),H.authenticated){HN();return}xp(),Np(),c0()}catch(H){f(Ra(H))}finally{b.current=null}})();return b.current=V,V}if(S==="workspace")return m.jsx(v5,{api:o,serverApi:c,activeAgentId:r,onSelectServer:s,sessionExpiresAt:h?.expiresAt??null,previewMode:h?.previewMode===!0,onSessionInvalid:A=>{D(A)},onLogout:async()=>{xp(),Np();const A=await o.logout();p(A)}});const L={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(F0,{size:26}),m.jsxs("div",{children:[m.jsx(q0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:L[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,S==="setup_password"?m.jsx(fL,{api:o,onSession:A=>{p(A)}}):null,S==="setup_totp"?m.jsx($5,{api:o,onDone:()=>{w()}}):null,S==="login"?m.jsx(pL,{api:o,session:h,onSession:p,onRefresh:w}):null,S==="reauth"?m.jsx(mL,{api:o,session:h,onSession:p,onFullLogin:()=>p(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function fL({api:e,onSession:t}){const[r,s]=v.useState(""),[o,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function b(y){y.preventDefault(),p(!0),f(null);try{if(r!==o){f("Passwords do not match");return}t(await e.setupPassword({password:r}))}catch(S){f(Ra(S))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:b,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:r,onChange:y=>s(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:o,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||r.length<8||o.length<8,children:"Set password"})]})}function pL({api:e,session:t,onSession:r,onRefresh:s}){const[o,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(!1),[S,w]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),y(!0),w(null);try{r(await e.login({password:o,...x?{otp:h}:{},rememberNetwork:g}))}catch(B){w(Ra(B))}finally{y(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:L,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),x?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:A=>p(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||o.length===0||x&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function mL({api:e,session:t,onSession:r,onFullLogin:s}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,b]=v.useState(!1),[y,S]=v.useState(!1),[w,x]=v.useState(!1),[D,L]=v.useState(null),A=Ti.useCallback(async(V,H)=>{b(!0),L(null);try{r(await e.reauth({...V?{otp:V}:{},rememberNetwork:H}))}catch(F){L(Ra(F))}finally{b(!1)}},[e,r]);v.useEffect(()=>{if(o){let V=!1;S(!0),x(!1),L(null);const H=window.setTimeout(()=>{V||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(F=>{V||r(F)}).catch(F=>{V||(L(Ra(F)),x(!0))}).finally(()=>{window.clearTimeout(H),V||S(!1)}),()=>{V=!0,window.clearTimeout(H)}}},[e,o,r]);async function B(V){V.preventDefault(),await A(c,p)}return o&&y&&!w&&!D?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:B,children:[o&&w&&!D?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:V=>h(V.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:V=>g(V.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?m.jsx("p",{className:"form-error",children:D}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function gL(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Ra(e){return e instanceof Error?e.message:"Request failed"}const H0="NTerminal",sg="nterminal.activeAgentId";function _L(){const[e,t]=v.useState(()=>vL()),r=v.useMemo(()=>Bh(),[]),s=v.useMemo(()=>lc(e),[e]);v.useEffect(()=>{const c=()=>{const h=N3();document.title=h>0?`(${h}) ${H0}`:H0};return c(),M3(c)},[]);function o(c){yL(c),t(c)}return m.jsx(dL,{api:r,activeAgentId:e,serverApi:s,onSelectServer:o})}function vL(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(sg);return e&&e.trim()?e:null}catch{return null}}function yL(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(sg,e);return}window.localStorage.removeItem(sg)}catch{}}const P0=["gesturestart","gesturechange","gestureend"],bL=[".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 SL(e=window){if(!CL(e))return()=>{};const t={passive:!1},r=e.document;function s(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!wL(c.target))&&s(c)}for(const c of P0)r.addEventListener(c,s,t);return r.addEventListener("touchmove",o,t),r.addEventListener("dblclick",s,t),()=>{for(const c of P0)r.removeEventListener(c,s,t);r.removeEventListener("touchmove",o,t),r.removeEventListener("dblclick",s,t)}}function wL(e){return e instanceof Element&&e.closest(bL)!==null}function CL(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}X5();GM();SL();ug();Mk.createRoot(document.getElementById("root")).render(m.jsx(Ti.StrictMode,{children:m.jsx(_L,{})}));export{Ti as R,Sk as g,m as j};